Manually applying rotations and translations to Matrix4 in THREE.JS

依然范特西╮ 提交于 2019-12-23 13:22:36

问题


I am trying to understand the co-ordinate spaces of three.js, I understand that there is object.matrix and object.matrixWorld.

After stumbling upon this blog post Matrix Basics. How to step away from storing an orientation as ’3 angles’, I decided to try to learn how to manipulate properties of the Matrix4 manually thus avoiding using Euler rotations.

All I am trying to do is translate my cube away from the origin 0,0,0 then rotate it in world space. The result in my mind would be that the cube translates on y axis first, then the rotate would bring it in a large arc back to the plane, but what actually happens is it just goes back to the origin ignoring the translation.

I have been doing a lot of reading about vectors and matrices and I'm confident I understand the theory behind them enough now. What I don't really get is how three.js handles the matrixWorld and matrix. I've attempted both!

Here is a fiddle to demonstrate: http://jsfiddle.net/SCXNQ/151/

Just look in the render() function to see what I'm trying to do!

EDIT - [solved] UPDATED JS FIDDLE OF WORKING VERSION 14/09/12

With the help of the answer below, I thought I would post my updated fiddle demonstrating what I wanted to achieve - http://jsfiddle.net/SCXNQ/363/


回答1:


Have a look at this, which is what I think you want.

EDIT: Oops, got the Matrix order wrong (another thing that you need to have a solid grasp of) -> try this aswell.



来源:https://stackoverflow.com/questions/11118126/manually-applying-rotations-and-translations-to-matrix4-in-three-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!