name:
js/hexagon.js
-rw-r--r--
2324
1function newHexagon(size, thickness) {
2 var object = new THREE.Geometry();
3
4 for (var i = 0; i <= 5; i++) {
5 var angle = (i * 2 * Math.PI / 6);
6 object.vertices.push( new THREE.Vector3( size * Math.sin(angle), thickness, size * Math.cos(angle)));
7 }
8
9 for (var i = 5; i >= 0; i--) {
10 var angle = (i * 2 * Math.PI / 6);
11 object.vertices.push( new THREE.Vector3(size * Math.sin(angle) , 0, size * Math.cos(angle)));
12 }
13
14 object.faces.push( new THREE.Face3( 0, 1, 5) );
15 object.faces.push( new THREE.Face3( 1, 2, 4) );
16 object.faces.push( new THREE.Face3( 1, 4, 5) );
17 object.faces.push( new THREE.Face3( 2, 3, 4) );
18
19 object.faces.push( new THREE.Face3( 6, 7, 11) );
20 object.faces.push( new THREE.Face3( 7, 8, 10) );
21 object.faces.push( new THREE.Face3( 7, 10, 11) );
22 object.faces.push( new THREE.Face3( 8, 9, 10) );
23
24 object.faces.push( new THREE.Face3( 10, 1, 0) );
25 object.faces.push( new THREE.Face3( 0, 11, 10) );
26
27 object.faces.push( new THREE.Face3( 5, 6, 0) );
28 object.faces.push( new THREE.Face3( 6, 11, 0) );
29
30 object.faces.push( new THREE.Face3( 2, 1, 10) );
31 object.faces.push( new THREE.Face3( 10, 9, 2) );
32
33 object.faces.push( new THREE.Face3( 3, 2, 9) );
34 object.faces.push( new THREE.Face3( 9, 8, 3) );
35
36 object.faces.push( new THREE.Face3( 5, 4, 7) );
37 object.faces.push( new THREE.Face3( 7, 6, 5) );
38
39 object.faces.push( new THREE.Face3( 4, 3, 7) );
40 object.faces.push( new THREE.Face3( 3, 8, 7) );
41
42 object.faces.push( new THREE.Face3( 8, 4, 3) );
43 object.faces.push( new THREE.Face3( 7, 4, 8) );
44
45 object.computeFaceNormals();
46
47 return object;
48}
49
50
51function newFloorHexagon(size, thickness) {
52 var object = new THREE.Geometry();
53
54 for (var i = 0; i <= 5; i++) {
55 var angle = (i * 2 * Math.PI / 6);
56 object.vertices.push( new THREE.Vector3( size * Math.sin(angle), thickness, size * Math.cos(angle)));
57 }
58
59 for (var i = 5; i >= 0; i--) {
60 var angle = (i * 2 * Math.PI / 6);
61 object.vertices.push( new THREE.Vector3(size * Math.sin(angle) , 0, size * Math.cos(angle)));
62 }
63
64 object.faces.push( new THREE.Face3( 0, 1, 5) );
65 object.faces.push( new THREE.Face3( 1, 2, 4) );
66 object.faces.push( new THREE.Face3( 1, 4, 5) );
67 object.faces.push( new THREE.Face3( 2, 3, 4) );
68
69 object.computeFaceNormals();
70
71 return object;
72}