部門 > Three.js > 回転

「部門/Three.js/回転」の編集履歴(バックアップ)一覧に戻る

部門/Three.js/回転 - (2013/01/31 (木) 01:38:48) のソース

Three.jsで物体を回転させるときに最もよく使われるのはオイラー角のもよう。オイラー角の定義は
[[オイラー角 - Wikipedia>http://ja.wikipedia.org/wiki/%E3%82%AA%E3%82%A4%E3%83%A9%E3%83%BC%E8%A7%92]]
[[Euler Angles -- from Wolfram MathWorld>http://mathworld.wolfram.com/EulerAngles.html]]
にあるような感じで、ふつうはこれと同じようにz-x-zの順で回転すると思うんだが(ランダウの力学の定義もこうだった)、
[[ロテーションについて - webgl - three.js>http://webgl.akjava.com/three-js/rotation]]
によるとx-y-zの順で回転するらしい。別の定義でオイラー角を計算し直すのはめんどうなので、Three.jsのほうでなんとかしてくれませんか。上のリンクからeulerOrder()というメソッドを使えばいいとわかっても引数をどうすればいいのか不明だったのだけど、そのままだった。
#highlight(){object.eulerOrder('XYZ');}
のようにする。(例えば、[[Streaming data from Blender into Three.js (WebGL+Websockets)>http://blenderartists.org/forum/showthread.php?243522-Streaming-data-from-Blender-into-Three-js-(WebGL-Websockets)&s=d0fc5b1e2c831db8ef438d1556c8cf8c&p=2053198&viewfull=1#post2053198]]に載ってた。)

ちなみにROOTにおける回転は、
[[TRotation>http://root.cern.ch/root/html/TRotation.html]] 
にあるようにz-x-zの順。

*参考リンク
-[[ロテーションについて - webgl - three.js>http://webgl.akjava.com/three-js/rotation]]
-[[クォータニオンによる視点の移動 (WebGL(Three.js))>http://www.natural-science.or.jp/article/20120416225426.php]]
-[[three.jsでの 物体の座標軸回転 - jsdo.it - Share JavaScript, HTML5 and CSS>http://jsdo.it/qa/79]]


#comment_num2()