[英]Tween animation is instant instead of smooth, What gives?
想法是在单击按钮时从当前相机位置移动到网格的中心(它是一个球体,我想在其中)。
这是一个带有补间的函数,onUpdate 被调用,但它是即时的,而不是随着时间的推移执行,是什么给出的?
nextButton.onclick = function () {
const cameraCoords = { x: camera.position.x, y: camera.position.y, z: camera.position.z };
new TWEEN.Tween( cameraCoords )
.to( { x: mesh2.position.x, y: mesh2.position.y, z: mesh2.position.z }, 600)
.easing(TWEEN.Easing.Linear.None)
.onUpdate(function () {
camera.position.set(mesh2.position.x, mesh2.position.y, mesh2.position.z);
})
.start();
};
这是我称之为补间更新的动画函数(以防这里出现问题)。
function animate(time) {
requestAnimationFrame( animate );
controls.update();
TWEEN.update(time);
renderer.render( scene, camera );
}
animate();
谢谢!
问题出在onUpdate
回调中:
camera.position.set(mesh2.position.x, mesh2.position.y, mesh2.position.z);
当您应该设置cameraCoords
对象中的当前位置时,您总是在设置结束位置:
camera.position.set(cameraCoords.x, cameraCoords.y, cameraCoords.z);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.