【发布时间】:2012-11-30 07:02:08
【问题描述】:
我正在尝试像 Three.js 那样重现太阳系,但我无法让行星围绕恒星倾斜旋转:
这是一个小提琴示例,但旋转错误: http://goo.gl/MzcwI
我试过这个解决方案: How to rotate a 3D object on axis three.js? 没有成功。
如果有人有线索可以帮助我, 谢谢
【问题讨论】:
标签: javascript 3d webgl three.js orbital-mechanics
我正在尝试像 Three.js 那样重现太阳系,但我无法让行星围绕恒星倾斜旋转:
这是一个小提琴示例,但旋转错误: http://goo.gl/MzcwI
我试过这个解决方案: How to rotate a 3D object on axis three.js? 没有成功。
如果有人有线索可以帮助我, 谢谢
【问题讨论】:
标签: javascript 3d webgl three.js orbital-mechanics
【讨论】:
你试过了吗?
function animate() {
pivot.rotation.y += 0.01;
pivot.rotation.x += 0.01;
requestAnimationFrame(animate);
render();
}
【讨论】:
如果您只想使用网格的位置向量进行旋转,您可以简单地执行类似
的操作theta = 0;/* Global variable */
function render(){
orbiter = /* Get the planet you want to rotate*/;
orbiter.mesh.position.x = Math.cos( theta ) *100;
orbiter.mesh.position.z = Math.sin( theta ) *25;
orbiter.mesh.position.y = Math.cos( theta ) * -60;
theta +=.02;
renderer.render( scene, camera );
}
function animate(){ animation_id = requestAnimationFrame( animate ); render(); }
animate();
您将不得不使用这些值来获得所需的旋转角度 - 特别是对于 position.y 值。增加 theta 应该会提高速度。
【讨论】: