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

在Three.js中,KeyframeTrack.shift()是用于移动关键帧轨道中所有关键帧时间的方法。该方法返回一个修改后的KeyframeTrack对象。

语法

animationTrack.shift( amount );
  • amount:必需,表示要移动的时间量,以秒为单位,可以为正数或负数。

示例

以下示例演示了如何使用keyframeTrack.shift()方法将一个关键帧轨道中的所有关键帧时间向左移动1秒钟,与同时移动第二个轨道中的所有关键帧时间相对应:

// 定义第一个关键帧轨道
const track1 = new THREE.KeyframeTrack( 
    '.position', // 属性名称
    [0, 1, 2],   // 关键帧时间点
    [-10, 0, 10] // 关键帧值
);

// 定义第二个关键帧轨道
const track2 = new THREE.KeyframeTrack( 
    '.rotation', // 属性名称
    [0, 1, 2],   // 关键帧时间点
    [0, Math.PI/2, Math.PI] // 关键帧值
);

// 移动第一个关键帧轨道中的所有关键帧时间
track1.shift(-1);

// 移动第二个关键帧轨道中的所有关键帧时间
track2.shift(-1);

注意事项

  • amount参数可以为正数或负数,正数表示向右移动关键帧时间,而负数表示向左移动。
  • 移动后的关键帧时间必须是非负数,如果移动后的时间小于0,则会自动调整为0。
  • keyframeTrack.shift()方法返回一个修改后的KeyframeTrack对象,所以需要将其保存到变量中才能继续使用。