source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/Content/Web/mrdoob-three.js-4862f5f/src/extras/curves/ClosedSplineCurve3.js@ 28897

Last change on this file since 28897 was 28897, checked in by davidb, 10 years ago

GUI front-end to server base plus web page content

File size: 1.3 KB
Line 
1/**************************************************************
2 * Closed Spline 3D curve
3 **************************************************************/
4
5
6THREE.ClosedSplineCurve3 = THREE.Curve.create(
7
8 function ( points /* array of Vector3 */) {
9
10 this.points = (points == undefined) ? [] : points;
11
12 },
13
14 function ( t ) {
15
16 var v = new THREE.Vector3();
17 var c = [];
18 var points = this.points, point, intPoint, weight;
19 point = ( points.length - 0 ) * t;
20 // This needs to be from 0-length +1
21
22 intPoint = Math.floor( point );
23 weight = point - intPoint;
24
25 intPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / points.length ) + 1 ) * points.length;
26 c[ 0 ] = ( intPoint - 1 ) % points.length;
27 c[ 1 ] = ( intPoint ) % points.length;
28 c[ 2 ] = ( intPoint + 1 ) % points.length;
29 c[ 3 ] = ( intPoint + 2 ) % points.length;
30
31 v.x = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].x, points[ c[ 1 ] ].x, points[ c[ 2 ] ].x, points[ c[ 3 ] ].x, weight );
32 v.y = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].y, points[ c[ 1 ] ].y, points[ c[ 2 ] ].y, points[ c[ 3 ] ].y, weight );
33 v.z = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].z, points[ c[ 1 ] ].z, points[ c[ 2 ] ].z, points[ c[ 3 ] ].z, weight );
34
35 return v;
36
37 }
38
39);
Note: See TracBrowser for help on using the repository browser.