【发布时间】:2019-08-01 16:25:19
【问题描述】:
我想重复一个动画组(球体移动,然后是矩形),然后在名为 expected_output 的 div 中写入重复的次数。但由于某种原因,它跳过了动画,即动画没有开始。
这里是功能代码:
var j = 1
var fieldNameElement = document.getElementById("expected_output");
function animator_repeat(){
const animationClip = new THREE.AnimationClip(null,3, [track1]);
const animationClip1 = new THREE.AnimationClip(null,3, [track]);
const animationAction = mesh.userData.mixer.clipAction(animationClip);
const animationAction1 = cube.userData.mixer.clipAction(animationClip1);
animationAction.setLoop(THREE.LoopRepeat ,1);
animationAction.play();
mesh.userData.mixer.addEventListener( 'finished', () => {
animationAction1.setLoop(THREE.LoopRepeat ,1);
animationAction1.play();
cube.userData.mixer.addEventListener( 'finished', () => {
if(j<6){
fieldNameElement.textContent = "Number: "+(j+1).toString();
animator_repeat()
j = j+1
}
});
} )
}
这里是 jsfiddle: https://jsfiddle.net/xgnj4fbh/6/
你可以看到它跳过,3,4
有人可以解释发生了什么问题吗?
谢谢
【问题讨论】:
标签: javascript animation three.js