three.js icon indicating copy to clipboard operation
three.js copied to clipboard

Copy Mesh World Location to new Mesh

Open dimitrii opened this issue 14 years ago • 1 comments

I have a scene with several meshes moving around. I want to take a snap shot and make a copy of all of the mesh locations by placing a new instance of a mesh in the scene in the same location & with the same rotation. I can't simply copy the mesh's .position & .rotation because the mesh is a child to other meshes. I tried to .clone() the mesh's matrixWorld but that didn't work. How do you inherit the world location of a mesh?

This is what I was trying to do:


// mesh is an existing mesh loaded into a scene
// geom is an existing geometry definition

var material = new THREE.MeshFaceMaterial();

var newMesh = new THREE.Mesh( geom, material);

newMesh.matrixWorld = mesh.matrixWorld.clone();

scene.add(newMesh);

Any help would be much appreciated.

dimitrii avatar Dec 05 '12 05:12 dimitrii

#1979

mrdoob avatar Dec 05 '12 15:12 mrdoob