Three.JS - Child object rotation in it's place

删除回忆录丶 提交于 2019-12-12 01:07:49

问题


I tried absolutely everything, and it's second day that I can't move an child mesh around it's center.

https://github.com/mrdoob/three.js/issues/1219 - This doesn't work for me.

I think I can't create correctly the position matrix between the child and the parent center points.

I'd like to set the object central point, in the place the object is on the scene, and rotate by any axis with it staying in it's place.

Any help is most welcome...I'm getting frustrated by that ;/


回答1:


If you want change position, you have to set property position.

If you want rotate child object, you have to pick axis and degrees. Object will rotate around it's center (point [0,0,0])

obj.rotateOnAxis(new THREE.Vector3(0,0,1), 90*Math.PI/180); 
// rotate 90 degrees around Z axis

But if you want rotate child object and ensure, that specific child vertex will stay at same place, it's not that easy. I do it this way - prepare child object and place its center (0,0,0) vertex in point, where you want "do" rotation. If you changes child object this way, you can translate it and then rotate it around axis you want. And it's center point will stay at same place during rotation.



来源:https://stackoverflow.com/questions/17221222/three-js-child-object-rotation-in-its-place

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