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.interpolantFactoryMethodDiscrete()

该方法是THREE.KeyframeTrack类的静态属性,用于创建“离散插值”的插值器工厂方法,可以用于所有不需要中间值(也就是没有过渡效果)的关键帧动画效果。

语法

THREE.KeyframeTrack.interpolantFactoryMethodDiscrete(result: any) : Function

参数

  • result(任意类型):将在调用插值器前存放结果的变量

返回值

返回一个接受两个参数的函数:(result: any, sampleValues: Array, sampleTimes: Array, frameRate: Number)

  • result(任意类型):将在调用插值器后存放结果的变量
  • sampleValuesArray) : 包含动画关键帧的值的数组
  • sampleTimesArray) : 包含动画关键帧的时间点的数组
  • frameRateNumber):每秒渲染的帧数(如果未提供,则默认为60)

示例

const result = {
  position: new THREE.Vector3(),
  quaternion: new THREE.Quaternion()
}

const positionValues = [
  new THREE.Vector3(0, 0, 0),
  new THREE.Vector3(50, 0, 0),
  new THREE.Vector3(100, 0, 0)
]

const quaternionValues = [
  new THREE.Quaternion(),
  new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI / 2),
  new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI)
]

const track = new THREE.KeyframeTrack('.position', [0, 1, 2], positionValues.flat(), THREE.InterpolateDiscrete)
const quatTrack = new THREE.QuaternionKeyframeTrack('.quaternion', [0, 1, 2], quaternionValues.flat(), THREE.InterpolateDiscrete)

const mixer = new THREE.AnimationMixer(mesh)
const clip = new THREE.AnimationClip('clip', -1, [track, quatTrack])
const action = mixer.clipAction(clip)

// 将使用离散插值器
track.createInterpolant = THREE.KeyframeTrack.interpolantFactoryMethodDiscrete(result)
quatTrack.createInterpolant = THREE.QuaternionKeyframeTrack.interpolateDiscrete

参考