|
@@ -1555,6 +1555,22 @@
|
|
|
return result;
|
|
|
|
|
|
};
|
|
|
+
|
|
|
+ const _q = new THREE.Quaternion();
|
|
|
+
|
|
|
+ class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
|
|
|
+
|
|
|
+ interpolate_( i1, t0, t, t1 ) {
|
|
|
+
|
|
|
+ const result = super.interpolate_( i1, t0, t, t1 );
|
|
|
+
|
|
|
+ _q.fromArray( result ).normalize().toArray( result );
|
|
|
+
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
/*********************************/
|
|
|
|
|
|
/********** INTERNALS ************/
|
|
@@ -3271,7 +3287,8 @@
|
|
|
// A CUBICSPLINE keyframe in glTF has three output values for each input value,
|
|
|
// representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
|
|
|
// must be divided by three to get the interpolant's sampleSize argument.
|
|
|
- return new GLTFCubicSplineInterpolant( this.times, this.values, this.getValueSize() / 3, result );
|
|
|
+ const interpolantType = this instanceof THREE.QuaternionKeyframeTrack ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
|
|
|
+ return new interpolantType( this.times, this.values, this.getValueSize() / 3, result );
|
|
|
|
|
|
}; // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
|
|
|
|