私はThree.jsのような太陽系を再現しようとしていますが、惑星を星の周りに傾けて回転させることはできません:
これはフィドルのサンプルですが、回転が間違っています: http://goo.gl/MzcwI
私はこの解決策を試しました: 軸three.jsで3Dオブジェクトを回転させる方法は? 成功せずに。
誰かが私を助ける手がかりを持っているなら、ありがとう
私はThree.jsのような太陽系を再現しようとしていますが、惑星を星の周りに傾けて回転させることはできません:
これはフィドルのサンプルですが、回転が間違っています: http://goo.gl/MzcwI
私はこの解決策を試しました: 軸three.jsで3Dオブジェクトを回転させる方法は? 成功せずに。
誰かが私を助ける手がかりを持っているなら、ありがとう
やってみました?
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 値については、目的の回転角度を取得するために値をいじる必要があります。シータを大きくすると速度が上がります。