three.js动画
旋转立方体
function renderScene(){
cube.rotation.x += 0.02;
cube.rotation.y += 0.02;
cube.rotation.z += 0.02;
requestAnimationFrame(renderScene);
stats.update();
renderer.render(scene,camera);
}
renderScene();
弹跳球
var step = 0;
function renderScene() {
step += 0.2; //定义球体弹跳的速度
sphere.position.x = 20 + 10 * (Math.cos(step));
sphere.position.y = 2 + 10 * Math.abs(Math.sin(step));
requestAnimationFrame(renderScene);
stats.update();
renderer.render(scene, camera);
}
renderScene();