Three.js: How to select the point of object rotation?

Created on 5 Aug 2011  ·  5Comments  ·  Source: mrdoob/three.js

Hello!
I made the model using Blender. If I use mesh.rotation.y - it rotates, but around the one fixed point (axis). If I move the object (mesh.position.x) - it moves, but the rotation axis stay in the same place relative to the object.

How can I select the rotation axis position?

//Sorry for my English. I'm not a native English speaker

Question

All 5 comments

You can do it this way... say you want the axis position be at ( -100, 0, 0 ):

var dummy = new THREE.Object3D();
var your_object = new THREE.Mesh( geometry, material );
your_object.position.x = 100;
dummy.addChild( your_object );

scene.addObject( dummy );

Thanks! That was very helpful

When I try this

var dummy = new THREE.Object3D();
var your_object = new THREE.Mesh( geometry, material );
your_object.position.x = 100;
dummy.addChild( your_object );

scene.addObject( dummy );

It show "Uncaught TypeError: dummy.addChild is not a function at :4:11" this error

addChild() and addObject() were renamed long ago to just add().

@merbin2012 You can instead translate the geometry: geometry.translate( x, y, z ).

See this stackoverflow answer.

Was this page helpful?
1 / 5 - 1 ratings

Related issues

lmcd picture lmcd  ·  74Comments

RicoLiu picture RicoLiu  ·  100Comments

arefin86 picture arefin86  ·  64Comments

mrdoob picture mrdoob  ·  84Comments

fernandojsg picture fernandojsg  ·  85Comments