Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

three.js rotate Object3d around Y axis at it center

I have an Object3d in Three.JS that is a group of some Mesh objects.
I want to rotate this group around the Y axis, at it center, that is far from world center (0,0,0).
I just know the Group.rotate.y += deg code, but for each axis direction it always rotate the object around (0,0,0), not my group center!
How can i fix this?

UPDATE:

Read the comments

like image 343
MeTe-30 Avatar asked Jul 28 '13 10:07

MeTe-30


People also ask

How do you rotate the y axis in blender?

To rotate objects, activate Rotate mode by pressing RKEY. As in Grab mode, you can change the rotation by moving the mouse, confirm with LMB, or ENTER cancel with RMB or ESC. Rotation in 3D space occurs around an axis, and there are various ways to define this axis.


1 Answers

Have a look at Object3D's rotateOnAxis(axis, angle) function. It should be something like:

//declared once at the top of your code
var axis = new THREE.Vector3(0.5,0.5,0);//tilted a bit on x and y - feel free to plug your different axis here
//in your update/draw function
rad += radIncrement;
object.rotateOnAxis(axis,rad);

HTH

like image 146
George Profenza Avatar answered Oct 15 '22 16:10

George Profenza