BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

keyframeTrack.createInterpolant()

Description

The createInterpolant() method creates an instance of DiscreteInterpolant, LinearInterpolant, or CubicSplineInterpolant based on the interpolation type specified in the KeyframeTrack object.

Syntax

createInterpolant() : Interpolant

Return Value

An instance of the Interpolant class, representing the interpolation between keyframes.

Interpolation Types

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.

Examples

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();