IcosahedronGeometry.js 1.5 KB
Newer Older
B
bentok 已提交
1 2
import { Geometry } from '../core/Geometry.js';
import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';
M
Mugen87 已提交
3

M
Mugen87 已提交
4
// IcosahedronGeometry
M
Mr.doob 已提交
5

M
Mr.doob 已提交
6
function IcosahedronGeometry( radius, detail ) {
7

M
Mugen87 已提交
8
	Geometry.call( this );
9

10 11 12 13 14 15
	this.type = 'IcosahedronGeometry';

	this.parameters = {
		radius: radius,
		detail: detail
	};
G
gero3 已提交
16

17
	this.fromBufferGeometry( new IcosahedronBufferGeometry( radius, detail ) );
18 19
	this.mergeVertices();

M
Mr.doob 已提交
20
}
21

22
IcosahedronGeometry.prototype = Object.create( Geometry.prototype );
R
Rich Harris 已提交
23 24
IcosahedronGeometry.prototype.constructor = IcosahedronGeometry;

M
Mugen87 已提交
25
// IcosahedronBufferGeometry
M
Mr.doob 已提交
26 27 28

function IcosahedronBufferGeometry( radius, detail ) {

M
Mugen87 已提交
29
	const t = ( 1 + Math.sqrt( 5 ) ) / 2;
M
Mr.doob 已提交
30

M
Mugen87 已提交
31
	const vertices = [
J
Josua Pedersen 已提交
32
		- 1, t, 0, 	1, t, 0, 	- 1, - t, 0, 	1, - t, 0,
M
Mugen87 已提交
33 34
		 0, - 1, t, 	0, 1, t,	0, - 1, - t, 	0, 1, - t,
		 t, 0, - 1, 	t, 0, 1, 	- t, 0, - 1, 	- t, 0, 1
M
Mr.doob 已提交
35 36
	];

M
Mugen87 已提交
37
	const indices = [
M
Mugen87 已提交
38 39 40
		 0, 11, 5, 	0, 5, 1, 	0, 1, 7, 	0, 7, 10, 	0, 10, 11,
		 1, 5, 9, 	5, 11, 4,	11, 10, 2,	10, 7, 6,	7, 1, 8,
		 3, 9, 4, 	3, 4, 2,	3, 2, 6,	3, 6, 8,	3, 8, 9,
J
Josua Pedersen 已提交
41
		 4, 9, 5, 	2, 4, 11,	6, 2, 10,	8, 6, 7,	9, 8, 1
M
Mr.doob 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
	];

	PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );

	this.type = 'IcosahedronBufferGeometry';

	this.parameters = {
		radius: radius,
		detail: detail
	};

}

IcosahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );
IcosahedronBufferGeometry.prototype.constructor = IcosahedronBufferGeometry;
R
Rich Harris 已提交
57

M
Mugen87 已提交
58

M
Mr.doob 已提交
59
export { IcosahedronGeometry, IcosahedronBufferGeometry };