The createInterpolant()
method creates an instance of DiscreteInterpolant
, LinearInterpolant
, or CubicSplineInterpolant
based on the interpolation type specified in the KeyframeTrack
object.
createInterpolant() : Interpolant
An instance of the Interpolant
class, representing the interpolation between keyframes.
There are three types of interpolation that can be used by createInterpolant()
:
DiscreteInterpolant
- the value of the keyframe at a given moment in time is returned directly.LinearInterpolant
- the value of the keyframe at a given moment in time is linearly interpolated between the adjacent keyframes.CubicSplineInterpolant
- the value of the keyframe at a given moment in time is interpolated using a cubic spline curve that passes through each keyframe.Creating a LinearInterpolant
:
const positionTrack = new THREE.KeyframeTrack("mesh.position", [0, 1, 2], [0, 100, 0, -100, 0]);
const positionInterpolant = positionTrack.createInterpolant();
Creating a CubicSplineInterpolant
:
const rotationTrack = new THREE.KeyframeTrack("mesh.rotation", [0, 1, 2], [0, 0, 0, Math.PI/2, 0, Math.PI, 0, -Math.PI/2, 0]);
const rotationInterpolant = rotationTrack.createInterpolant();