1

私はThree.jsのような太陽系を再現しようとしていますが、惑星を星の周りに傾けて回転させることはできません:

回転角度

これはフィドルのサンプルですが、回転が間違っています: http://goo.gl/MzcwI

私はこの解決策を試しました: 軸three.jsで3Dオブジェクトを回転させる方法は? 成功せずに。

誰かが私を助ける手がかりを持っているなら、ありがとう

4

3 に答える 3

1

ピボットのルート位置に要素を追加する必要がありました。これにより、回転できる一種の新しい計画が作成されます。

ここで解決します。

jsfiddle
于 2012-11-30T17:17:53.533 に答える
0

やってみました?

function animate() {

  pivot.rotation.y += 0.01;
  pivot.rotation.x += 0.01;
  requestAnimationFrame(animate);
  render();

}
于 2012-11-30T15:55:16.613 に答える
0

メッシュの位置ベクトルだけを使用して回転させたい場合は、次のようにするだけです。

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 値については、目的の回転角度を取得するために値をいじる必要があります。シータを大きくすると速度が上がります。

于 2014-02-19T00:47:28.463 に答える