maxbit89 maxbit89 - 2 years ago 238
Javascript Question

WebGL/Three.js set mesh offset

I have a question about

How do I set an offset to a mesh?
The basic code is available at:

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 Source

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 );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download