Javascript 在特定时间播放混音器动画(playAt()或skipTo())
我有一个.gltf中的基本网格动画,我想在特定时间以秒为单位播放 以下是加载程序和混合器设置:Javascript 在特定时间播放混音器动画(playAt()或skipTo()),javascript,three.js,Javascript,Three.js,我有一个.gltf中的基本网格动画,我想在特定时间以秒为单位播放 以下是加载程序和混合器设置: GLTFLoader.load( 'myscene.gltf', function ( gltf ) { model = gltf.scene; scene.add( model ); mixer = new THREE.AnimationMixer( model ); mixer.clipAction(gltf.animations[0]) .se
GLTFLoader.load( 'myscene.gltf', function ( gltf ) {
model = gltf.scene;
scene.add( model );
mixer = new THREE.AnimationMixer( model );
mixer.clipAction(gltf.animations[0])
.setDuration( 60 ) //total of 1 min
.play();
render();
});
在render()中,我有:
function render() {
var delta = clock.getDelta();
if (mixer != null) {
mixer.update(delta);
};
//console.log(delta); //Doesn't show anything valuable.
renderer.clear();
composer.render();
counter++;
}
到目前为止,我尝试了.startAt(10)
,这只是在播放之前的一个延迟。它确实应该重命名为.delay()
startAt()
应该是我要找的。我还尝试了.play(10)
,但它不起作用<代码>混音器。时间返回自播放以来经过的实际时间(以秒为单位),但不能设置为任何值
我不明白整件
clock.getDelta()
的事情,也不知道它怎么知道播放什么,因为数字似乎在重复。如何使动画在动画中以10秒的速度开始。。。或者特定的关键帧编号?当您调用.clipAction()
时,您会得到一个AnimationAction
类型的对象,您可以使用它来链接命令(如上面的示例所示)。您可以将其存储在变量中,然后使用AnimationAction
的.time
属性告诉它从何处开始,而不是链接
var mixer = new THREE.AnimationMixer( model );
var action = mixer.clipAction( gltf.animations[ 0 ] );
action.setDuration( 60 )
action.play();
action.time = 5;
您可以阅读有关
.time
属性的更多信息。我确实阅读了有关.time和其他内容的文档。我就是不明白为什么mixer.time=5代码>不工作。。。我想它是只读的。。。哈哈。非常感谢。是的,我自己也在经历同样的过程。我仍然被AnimationMixer、AnimationClip和AnimationAction之间的相似性所扭曲,发现自己一直试图更改错误的属性。:)@米罗,你明白了吗?