MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / interpolateCatmullRom

Function interpolateCatmullRom

Three.js/js/Three66.js:31206–31235  ·  view source on GitHub ↗
( points, scale )

Source from the content-addressed store, hash-verified

31204 // Catmull-Rom spline
31205
31206 var interpolateCatmullRom = function ( points, scale ) {
31207
31208 var c = [], v3 = [],
31209 point, intPoint, weight, w2, w3,
31210 pa, pb, pc, pd;
31211
31212 point = ( points.length - 1 ) * scale;
31213 intPoint = Math.floor( point );
31214 weight = point - intPoint;
31215
31216 c[ 0 ] = intPoint === 0 ? intPoint : intPoint - 1;
31217 c[ 1 ] = intPoint;
31218 c[ 2 ] = intPoint > points.length - 2 ? intPoint : intPoint + 1;
31219 c[ 3 ] = intPoint > points.length - 3 ? intPoint : intPoint + 2;
31220
31221 pa = points[ c[ 0 ] ];
31222 pb = points[ c[ 1 ] ];
31223 pc = points[ c[ 2 ] ];
31224 pd = points[ c[ 3 ] ];
31225
31226 w2 = weight * weight;
31227 w3 = weight * w2;
31228
31229 v3[ 0 ] = interpolate( pa[ 0 ], pb[ 0 ], pc[ 0 ], pd[ 0 ], weight, w2, w3 );
31230 v3[ 1 ] = interpolate( pa[ 1 ], pb[ 1 ], pc[ 1 ], pd[ 1 ], weight, w2, w3 );
31231 v3[ 2 ] = interpolate( pa[ 2 ], pb[ 2 ], pc[ 2 ], pd[ 2 ], weight, w2, w3 );
31232
31233 return v3;
31234
31235 };
31236
31237 var interpolate = function ( p0, p1, p2, p3, t, t2, t3 ) {
31238

Callers 1

Three66.jsFile · 0.70

Calls 1

interpolateFunction · 0.70

Tested by

no test coverage detected