1 /**
2 * @author jonobr1 / http://jonobr1.com
3 *
4 * Creates a one-sided polygonal geometry from a path shape. Similar to
5 * ExtrudeGeometry.
6 *
7 * parameters = {
8 *
9 * curveSegments: <int>, // number of points on the curves. NOT USED AT THE MOMENT.
10 *
11 * material: <int> // material index for front and back faces
12 * uvGenerator: <Object> // object that provides UV generator functions
13 *
14 * }
15 **/
16
17 /**@constructor*/
18 THREE.ShapeGeometry = function ( shapes, options ) {
19
20 THREE.Geometry.call( this );
21
22 if ( shapes instanceof Array === false ) shapes = [ shapes ];
23
24 this.shapebb = shapes[ shapes.length - 1 ].getBoundingBox();
25
26 this.addShapeList( shapes, options );
27
28 this.computeCentroids();
29 this.computeFaceNormals();
30
31 };
32
33 THREE.ShapeGeometry.prototype = Object.create( THREE.Geometry.prototype );
34
35 /**
36 * Add an array of shapes to THREE.ShapeGeometry.
37 */
38 THREE.ShapeGeometry.prototype.addShapeList = function ( shapes, options ) {
39
40 for ( var i = 0, l = shapes.length; i < l; i++ ) {
41
42 this.addShape( shapes[ i ], options );
43
44 }
45
46 return this;
47
48 };
49
50 /**
51 * Adds a shape to THREE.ShapeGeometry, based on THREE.ExtrudeGeometry.
52 */
53 THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) {
54
55 if ( options === undefined ) options = {};
56
57 var material = options.material;
58 var uvgen = options.UVGenerator === undefined ? THREE.ExtrudeGeometry.WorldUVGenerator : options.UVGenerator;
59
60 var shapebb = this.shapebb;
61
62 //
63
64 var i, l, hole, s;
65
66 var shapesOffset = this.vertices.length;
67 var shapePoints = shape.extractPoints();
68
69 var vertices = shapePoints.shape;
70 var holes = shapePoints.holes;
71
72 var reverse = !THREE.Shape.Utils.isClockWise( vertices );
73
74 if ( reverse ) {
75
76 vertices = vertices.reverse();
77
78 // Maybe we should also check if holes are in the opposite direction, just to be safe...
79
80 for ( i = 0, l = holes.length; i < l; i++ ) {
81
82 hole = holes[ i ];
83
84 if ( THREE.Shape.Utils.isClockWise( hole ) ) {
85
86 holes[ i ] = hole.reverse();
87
88 }
89
90 }
91
92 reverse = false;
93
94 }
95
96 var faces = THREE.Shape.Utils.triangulateShape( vertices, holes );
97
98 // Vertices
99
100 var contour = vertices;
101
102 for ( i = 0, l = holes.length; i < l; i++ ) {
103
104 hole = holes[ i ];
105 vertices = vertices.concat( hole );
106
107 }
108
109 //
110
111 var vert, vlen = vertices.length;
112 var face, flen = faces.length;
113 var cont, clen = contour.length;
114
115 for ( i = 0; i < vlen; i++ ) {
116
117 vert = vertices[ i ];
118
119 this.vertices.push( new THREE.Vector3( vert.x, vert.y, 0 ) );
120
121 }
122
123 for ( i = 0; i < flen; i++ ) {
124
125 face = faces[ i ];
126
127 var a = face[ 0 ] + shapesOffset;
128 var b = face[ 1 ] + shapesOffset;
129 var c = face[ 2 ] + shapesOffset;
130
131 this.faces.push( new THREE.Face3( a, b, c, null, null, material ) );
132 this.faceVertexUvs[ 0 ].push( uvgen.generateBottomUV( this, shape, options, a, b, c ) );
133
134 }
135
136 };
137
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