1 /**
  2  * @author zz85 / http://www.lab4games.net/zz85/blog
  3  *
  4  **/
  5 
  6 /**************************************************************
  7  *	Curved Path - a curve path is simply a array of connected
  8  *  curves, but retains the api of a curve
  9  **************************************************************/
 10 
 11 /**@constructor*/
 12 THREE.CurvePath = function () {
 13 
 14 	this.curves = [];
 15 	this.bends = [];
 16 	
 17 	this.autoClose = false; // Automatically closes the path
 18 };
 19 
 20 THREE.CurvePath.prototype = Object.create( THREE.Curve.prototype );
 21 
 22 THREE.CurvePath.prototype.add = function ( curve ) {
 23 
 24 	this.curves.push( curve );
 25 
 26 };
 27 
 28 THREE.CurvePath.prototype.checkConnection = function() {
 29 	// TODO
 30 	// If the ending of curve is not connected to the starting
 31 	// or the next curve, then, this is not a real path
 32 };
 33 
 34 THREE.CurvePath.prototype.closePath = function() {
 35 	// TODO Test
 36 	// and verify for vector3 (needs to implement equals)
 37 	// Add a line curve if start and end of lines are not connected
 38 	var startPoint = this.curves[0].getPoint(0);
 39 	var endPoint = this.curves[this.curves.length-1].getPoint(1);
 40 	
 41 	if (!startPoint.equals(endPoint)) {
 42 		this.curves.push( new THREE.LineCurve(endPoint, startPoint) );
 43 	}
 44 	
 45 };
 46 
 47 // To get accurate point with reference to
 48 // entire path distance at time t,
 49 // following has to be done:
 50 
 51 // 1. Length of each sub path have to be known
 52 // 2. Locate and identify type of curve
 53 // 3. Get t for the curve
 54 // 4. Return curve.getPointAt(t')
 55 
 56 THREE.CurvePath.prototype.getPoint = function( t ) {
 57 
 58 	var d = t * this.getLength();
 59 	var curveLengths = this.getCurveLengths();
 60 	var i = 0, diff, curve;
 61 
 62 	// To think about boundaries points.
 63 
 64 	while ( i < curveLengths.length ) {
 65 
 66 		if ( curveLengths[ i ] >= d ) {
 67 
 68 			diff = curveLengths[ i ] - d;
 69 			curve = this.curves[ i ];
 70 
 71 			var u = 1 - diff / curve.getLength();
 72 
 73 			return curve.getPointAt( u );
 74 
 75 			break;
 76 		}
 77 
 78 		i ++;
 79 
 80 	}
 81 
 82 	return null;
 83 
 84 	// loop where sum != 0, sum > d , sum+1 <d
 85 
 86 };
 87 
 88 /*
 89 THREE.CurvePath.prototype.getTangent = function( t ) {
 90 };*/
 91 
 92 
 93 // We cannot use the default THREE.Curve getPoint() with getLength() because in
 94 // THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath
 95 // getPoint() depends on getLength
 96 
 97 THREE.CurvePath.prototype.getLength = function() {
 98 
 99 	var lens = this.getCurveLengths();
100 	return lens[ lens.length - 1 ];
101 
102 };
103 
104 // Compute lengths and cache them
105 // We cannot overwrite getLengths() because UtoT mapping uses it.
106 
107 THREE.CurvePath.prototype.getCurveLengths = function() {
108 
109 	// We use cache values if curves and cache array are same length
110 
111 	if ( this.cacheLengths && this.cacheLengths.length == this.curves.length ) {
112 
113 		return this.cacheLengths;
114 
115 	};
116 
117 	// Get length of subsurve
118 	// Push sums into cached array
119 
120 	var lengths = [], sums = 0;
121 	var i, il = this.curves.length;
122 
123 	for ( i = 0; i < il; i ++ ) {
124 
125 		sums += this.curves[ i ].getLength();
126 		lengths.push( sums );
127 
128 	}
129 
130 	this.cacheLengths = lengths;
131 
132 	return lengths;
133 
134 };
135 
136 
137 
138 // Returns min and max coordinates, as well as centroid
139 
140 THREE.CurvePath.prototype.getBoundingBox = function () {
141 
142 	var points = this.getPoints();
143 
144 	var maxX, maxY, maxZ;
145 	var minX, minY, minZ;
146 
147 	maxX = maxY = Number.NEGATIVE_INFINITY;
148 	minX = minY = Number.POSITIVE_INFINITY;
149 
150 	var p, i, il, sum;
151 
152 	var v3 = points[0] instanceof THREE.Vector3;
153 
154 	sum = v3 ? new THREE.Vector3() : new THREE.Vector2();
155 
156 	for ( i = 0, il = points.length; i < il; i ++ ) {
157 
158 		p = points[ i ];
159 
160 		if ( p.x > maxX ) maxX = p.x;
161 		else if ( p.x < minX ) minX = p.x;
162 
163 		if ( p.y > maxY ) maxY = p.y;
164 		else if ( p.y < minY ) minY = p.y;
165 
166 		if (v3) {
167 
168 			if ( p.z > maxZ ) maxZ = p.z;
169 			else if ( p.z < minZ ) minZ = p.z;
170 
171 		}
172 
173 		sum.addSelf( p );
174 
175 	}
176 
177 	var ret = {
178 
179 		minX: minX,
180 		minY: minY,
181 		maxX: maxX,
182 		maxY: maxY,
183 		centroid: sum.divideScalar( il )
184 	
185 	};
186 
187 	if (v3) {
188 
189 		ret.maxZ = maxZ;
190 		ret.minZ = minZ;
191 	
192 	}
193 
194 	return ret;
195 
196 };
197 
198 /**************************************************************
199  *	Create Geometries Helpers
200  **************************************************************/
201 
202 /// Generate geometry from path points (for Line or ParticleSystem objects)
203 
204 THREE.CurvePath.prototype.createPointsGeometry = function( divisions ) {
205 
206 	var pts = this.getPoints( divisions, true );
207 	return this.createGeometry( pts );
208 
209 };
210 
211 // Generate geometry from equidistance sampling along the path
212 
213 THREE.CurvePath.prototype.createSpacedPointsGeometry = function( divisions ) {
214 
215 	var pts = this.getSpacedPoints( divisions, true );
216 	return this.createGeometry( pts );
217 
218 };
219 
220 THREE.CurvePath.prototype.createGeometry = function( points ) {
221 
222 	var geometry = new THREE.Geometry();
223 
224 	for ( var i = 0; i < points.length; i ++ ) {
225 
226 		geometry.vertices.push( new THREE.Vector3( points[ i ].x, points[ i ].y, points[ i ].z || 0) );
227 
228 	}
229 
230 	return geometry;
231 
232 };
233 
234 
235 /**************************************************************
236  *	Bend / Wrap Helper Methods
237  **************************************************************/
238 
239 // Wrap path / Bend modifiers?
240 
241 THREE.CurvePath.prototype.addWrapPath = function ( bendpath ) {
242 
243 	this.bends.push( bendpath );
244 
245 };
246 
247 THREE.CurvePath.prototype.getTransformedPoints = function( segments, bends ) {
248 
249 	var oldPts = this.getPoints( segments ); // getPoints getSpacedPoints
250 	var i, il;
251 
252 	if ( !bends ) {
253 
254 		bends = this.bends;
255 
256 	}
257 
258 	for ( i = 0, il = bends.length; i < il; i ++ ) {
259 
260 		oldPts = this.getWrapPoints( oldPts, bends[ i ] );
261 
262 	}
263 
264 	return oldPts;
265 
266 };
267 
268 THREE.CurvePath.prototype.getTransformedSpacedPoints = function( segments, bends ) {
269 
270 	var oldPts = this.getSpacedPoints( segments );
271 
272 	var i, il;
273 
274 	if ( !bends ) {
275 
276 		bends = this.bends;
277 
278 	}
279 
280 	for ( i = 0, il = bends.length; i < il; i ++ ) {
281 
282 		oldPts = this.getWrapPoints( oldPts, bends[ i ] );
283 
284 	}
285 
286 	return oldPts;
287 
288 };
289 
290 // This returns getPoints() bend/wrapped around the contour of a path.
291 // Read http://www.planetclegg.com/projects/WarpingTextToSplines.html
292 
293 THREE.CurvePath.prototype.getWrapPoints = function ( oldPts, path ) {
294 
295 	var bounds = this.getBoundingBox();
296 
297 	var i, il, p, oldX, oldY, xNorm;
298 
299 	for ( i = 0, il = oldPts.length; i < il; i ++ ) {
300 
301 		p = oldPts[ i ];
302 
303 		oldX = p.x;
304 		oldY = p.y;
305 
306 		xNorm = oldX / bounds.maxX;
307 
308 		// If using actual distance, for length > path, requires line extrusions
309 		//xNorm = path.getUtoTmapping(xNorm, oldX); // 3 styles. 1) wrap stretched. 2) wrap stretch by arc length 3) warp by actual distance
310 
311 		xNorm = path.getUtoTmapping( xNorm, oldX );
312 
313 		// check for out of bounds?
314 
315 		var pathPt = path.getPoint( xNorm );
316 		var normal = path.getNormalVector( xNorm ).multiplyScalar( oldY );
317 
318 		p.x = pathPt.x + normal.x;
319 		p.y = pathPt.y + normal.y;
320 
321 	}
322 
323 	return oldPts;
324 
325 };
326 
327 

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

mbt skor nike sverige louboutin skor hollister sverige polo ralph lauren skjorta woolrich jacka dam canada goose jacka woolrich jacka ray ban rea canada goose rea michael kors rea new balance skor ralph lauren skjorta new balance rea uggs sverige lacoste rea christian louboutin skor moncler jacka nike shox barbour jacka uggs rea