1 /**
2 * @author zz85 / https://github.com/zz85
3 * Parametric Surfaces Geometry
4 * based on the brilliant article by @prideout http://prideout.net/blog/?p=44
5 *
6 * new THREE.ParametricGeometry( parametricFunction, uSegments, ySegements, useTris );
7 *
8 */
9
10 /**@constructor*/
11 THREE.ParametricGeometry = function ( func, slices, stacks, useTris ) {
12
13 THREE.Geometry.call( this );
14
15 var verts = this.vertices;
16 var faces = this.faces;
17 var uvs = this.faceVertexUvs[ 0 ];
18
19 useTris = (useTris === undefined) ? false : useTris;
20
21 var i, il, j, p;
22 var u, v;
23
24 var stackCount = stacks + 1;
25 var sliceCount = slices + 1;
26
27 for ( i = 0; i <= stacks; i ++ ) {
28
29 v = i / stacks;
30
31 for ( j = 0; j <= slices; j ++ ) {
32
33 u = j / slices;
34
35 p = func( u, v );
36 verts.push( p );
37
38 }
39 }
40
41 var a, b, c, d;
42 var uva, uvb, uvc, uvd;
43
44 for ( i = 0; i < stacks; i ++ ) {
45
46 for ( j = 0; j < slices; j ++ ) {
47
48 a = i * sliceCount + j;
49 b = i * sliceCount + j + 1;
50 c = (i + 1) * sliceCount + j;
51 d = (i + 1) * sliceCount + j + 1;
52
53 uva = new THREE.UV( j / slices, i / stacks );
54 uvb = new THREE.UV( ( j + 1 ) / slices, i / stacks );
55 uvc = new THREE.UV( j / slices, ( i + 1 ) / stacks );
56 uvd = new THREE.UV( ( j + 1 ) / slices, ( i + 1 ) / stacks );
57
58 if ( useTris ) {
59
60 faces.push( new THREE.Face3( a, b, c ) );
61 faces.push( new THREE.Face3( b, d, c ) );
62
63 uvs.push( [ uva, uvb, uvc ] );
64 uvs.push( [ uvb, uvd, uvc ] );
65
66 } else {
67
68 faces.push( new THREE.Face4( a, b, d, c ) );
69 uvs.push( [ uva, uvb, uvd, uvc ] );
70
71 }
72
73 }
74
75 }
76
77 // console.log(this);
78
79 // magic bullet
80 // var diff = this.mergeVertices();
81 // console.log('removed ', diff, ' vertices by merging');
82
83 this.computeCentroids();
84 this.computeFaceNormals();
85 this.computeVertexNormals();
86
87 };
88
89 THREE.ParametricGeometry.prototype = Object.create( THREE.Geometry.prototype );
90
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