我对Three.js很陌生(只有1天的经验),我想创建一个太阳系模型,因此我需要行星沿着它们的轨道(圆)移动。
function render() {
requestAnimationFrame(render);
sun.rotation.y += 0.01;
mercury.rotation.y +=0.03;
renderer.render(scene, camera);
}
render();
我尝试使用样条曲线来解决这个问题,但是由于不知道如何使用requestAnimationFrame与变量一起进行动画处理(只会简单的增量操作,例如+=0.03),所以无法实现。
mercury.position = spline.getPoint(t);
尝试使用数学计算,但结果相同。不知道如何对变量进行动画处理。
mercury.position.x = 20*Math.cos(4) + 0;
但是我没有任何在JS中进行动画制作的经验。因此,我对这个请求AnimationFrame的东西感到非常困惑,它来自一些教程,对我来说就像一个黑匣子。