用tree.js的动画不接受我的圆环
我是三分的新手,无法弄清为什么此动画不接受圆环作为参数。如果不设置“ torustobemaved”作为参数,它的工作原理就完全可以。
const geometry = new THREE.TorusGeometry(25, 0.2, 26, 100);
const material = new THREE.MeshStandardMaterial({ color: 0xccaa55 });
const torus = new THREE.Mesh(geometry, material);
torus.position.set(-15, -15, -15);
scene.add(torus);
function animate(torusToBeMoved) {
requestAnimationFrame(animate(torusToBeMoved));
torusToBeMoved.rotation.x += 0.01;
torusToBeMoved.rotation.y += 0.005;
torusToBeMoved.rotation.z += 0.01;
controls.update();
renderer.render(scene, camera);
}
animate(torus);```
I am new to Three.js and cannot work out why this animation does not accept the torus as a parameter. Without setting 'torusToBeMoved' as a parameter it works just perfectly fine..
const geometry = new THREE.TorusGeometry(25, 0.2, 26, 100);
const material = new THREE.MeshStandardMaterial({ color: 0xccaa55 });
const torus = new THREE.Mesh(geometry, material);
torus.position.set(-15, -15, -15);
scene.add(torus);
function animate(torusToBeMoved) {
requestAnimationFrame(animate(torusToBeMoved));
torusToBeMoved.rotation.x += 0.01;
torusToBeMoved.rotation.y += 0.005;
torusToBeMoved.rotation.z += 0.01;
controls.update();
renderer.render(scene, camera);
}
animate(torus);```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您将函数的返回值作为参数传递,而不是将函数传递为参数,因此您遇到了“最大调用堆栈大小超过”错误。使用回调作为参数应解决问题:
You are running into a "Maximum call stack size exceeded" error since you are passing the return value of the function as parameter instead of passing the function as parameter. Utilizing a callback as parameter should solve the issue: