1 /**
2 * @author mrdoob / http://mrdoob.com/
3 */
4
5 /**@constructor*/
6 THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {
7
8 THREE.Geometry.call( this );
9
10 this.radius = radius || 50;
11
12 this.widthSegments = Math.max( 3, Math.floor( widthSegments ) || 8 );
13 this.heightSegments = Math.max( 2, Math.floor( heightSegments ) || 6 );
14
15 phiStart = phiStart !== undefined ? phiStart : 0;
16 phiLength = phiLength !== undefined ? phiLength : Math.PI * 2;
17
18 thetaStart = thetaStart !== undefined ? thetaStart : 0;
19 thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
20
21 var x, y, vertices = [], uvs = [];
22
23 for ( y = 0; y <= this.heightSegments; y ++ ) {
24
25 var verticesRow = [];
26 var uvsRow = [];
27
28 for ( x = 0; x <= this.widthSegments; x ++ ) {
29
30 var u = x / this.widthSegments;
31 var v = y / this.heightSegments;
32
33 var vertex = new THREE.Vector3();
34 vertex.x = - this.radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
35 vertex.y = this.radius * Math.cos( thetaStart + v * thetaLength );
36 vertex.z = this.radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
37
38 this.vertices.push( vertex );
39
40 verticesRow.push( this.vertices.length - 1 );
41 uvsRow.push( new THREE.UV( u, 1 - v ) );
42
43 }
44
45 vertices.push( verticesRow );
46 uvs.push( uvsRow );
47
48 }
49
50 for ( y = 0; y < this.heightSegments; y ++ ) {
51
52 for ( x = 0; x < this.widthSegments; x ++ ) {
53
54 var v1 = vertices[ y ][ x + 1 ];
55 var v2 = vertices[ y ][ x ];
56 var v3 = vertices[ y + 1 ][ x ];
57 var v4 = vertices[ y + 1 ][ x + 1 ];
58
59 var n1 = this.vertices[ v1 ].clone().normalize();
60 var n2 = this.vertices[ v2 ].clone().normalize();
61 var n3 = this.vertices[ v3 ].clone().normalize();
62 var n4 = this.vertices[ v4 ].clone().normalize();
63
64 var uv1 = uvs[ y ][ x + 1 ].clone();
65 var uv2 = uvs[ y ][ x ].clone();
66 var uv3 = uvs[ y + 1 ][ x ].clone();
67 var uv4 = uvs[ y + 1 ][ x + 1 ].clone();
68
69 if ( Math.abs( this.vertices[ v1 ].y ) === this.radius ) {
70
71 this.faces.push( new THREE.Face3( v1, v3, v4, [ n1, n3, n4 ] ) );
72 this.faceVertexUvs[ 0 ].push( [ uv1, uv3, uv4 ] );
73
74 } else if ( Math.abs( this.vertices[ v3 ].y ) === this.radius ) {
75
76 this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ] ) );
77 this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3 ] );
78
79 } else {
80
81 this.faces.push( new THREE.Face4( v1, v2, v3, v4, [ n1, n2, n3, n4 ] ) );
82 this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3, uv4 ] );
83
84 }
85
86 }
87
88 }
89
90 this.computeCentroids();
91 this.computeFaceNormals();
92
93 this.boundingSphere = { radius: this.radius };
94
95 };
96
97 THREE.SphereGeometry.prototype = Object.create( THREE.Geometry.prototype );
98
nike free rn
new balance hombre baratas
cinturones gucci
ugg rebajas
cinturon gucci
ray ban baratas
nike cortez
peuterey mujer
christian louboutin madrid
mbt zapatos
gafas ray ban baratas
mbt ofertas
air max blancas
mbt barcelona
nike air max 90
woolrich barcelona
nike mujer
botas ugg
gafas de sol carrera aratas
air max 2016 baratas
oakley baratas
nike air max 2016