maxbit89 maxbit89 - 5 months ago 40
Javascript Question

WebGL/Three.js set mesh offset

I have a question about

three.js
.
How do I set an offset to a mesh?
The basic code is available at: http://lukas.achatz.ws/tst/webgl_003.html

What I want is to set a position offset and also that point should be used as the rotation reference.

I tried:
mesh.applyMatrix( new THREE.Matrix4().makeTranslation( -2, 0, 0 ) );
but this only moves the mesh in the scene.

Answer

You can simply do:

var group = new THREE.Group();
scene.add( group );

var mesh = new THREE.Mesh( ..., ... );
mesh.position.set( -2, 0, 0 );
group.add( mesh );