UNPKG

1.34 kBJavaScriptView Raw
1/**
2 * @author timothypratley / https://github.com/timothypratley
3 * @author Mugen87 / https://github.com/Mugen87
4 */
5
6import { Geometry } from '../core/Geometry.js';
7import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';
8
9// OctahedronGeometry
10
11function OctahedronGeometry( radius, detail ) {
12
13 Geometry.call( this );
14
15 this.type = 'OctahedronGeometry';
16
17 this.parameters = {
18 radius: radius,
19 detail: detail
20 };
21
22 this.fromBufferGeometry( new OctahedronBufferGeometry( radius, detail ) );
23 this.mergeVertices();
24
25}
26
27OctahedronGeometry.prototype = Object.create( Geometry.prototype );
28OctahedronGeometry.prototype.constructor = OctahedronGeometry;
29
30// OctahedronBufferGeometry
31
32function OctahedronBufferGeometry( radius, detail ) {
33
34 var vertices = [
35 1, 0, 0, - 1, 0, 0, 0, 1, 0,
36 0, - 1, 0, 0, 0, 1, 0, 0, - 1
37 ];
38
39 var indices = [
40 0, 2, 4, 0, 4, 3, 0, 3, 5,
41 0, 5, 2, 1, 2, 5, 1, 5, 3,
42 1, 3, 4, 1, 4, 2
43 ];
44
45 PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );
46
47 this.type = 'OctahedronBufferGeometry';
48
49 this.parameters = {
50 radius: radius,
51 detail: detail
52 };
53
54}
55
56OctahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );
57OctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry;
58
59
60export { OctahedronGeometry, OctahedronBufferGeometry };