1

I want to get the name of an object i clicked at. The model is loaded into the Scene with ColladaLoader.js. My Problem is, i just get the THREE.Mesh object but i need the THREE.Object3D object, because the Mesh doesn't contain the name.

If i use the following code:

scene.traverse (function (object){
    console.log(object);
});

I get:

THREE.Object3D {uuid: "085928DC-5493-4C57-B142-51D2A95F27B6", name: "Schraube_M4x16_002", type: "Object3D", parent: THREE.Object3D, children: Array[1]…} 
THREE.Mesh {uuid: "1AD3D989-CEB7-4B89-BE88-6D58C1C24AD6", name: "", type: "Mesh", parent: THREE.Object3D, children: Array[0]…} 

The Object3D has a name the Mesh not. But Raycast only returns meshes How to fix that?

3
  • add a name to your mesh. Commented Feb 4, 2015 at 15:23
  • But how to assign the collada names to each mesh. My Collada Model contains many children. Commented Feb 4, 2015 at 15:25
  • 1
    If you traverse up the tree from your mesh you will hit the Object3D. Otherwise you would have to modify the ColladaLoader. Commented Feb 4, 2015 at 15:41

1 Answer 1

1

I finally modifyed the ColladaLoader and added the node's name to the mesh.

function createSceneGraph( node, parent ) {
    ...
    // geometries
    ...
    } else {
        if ( geom.isLineStrip === true ) {
            mesh = new THREE.Line ( geom );
        } else {
            mesh = new THREE.Mesh ( geom, material );
        }
        mesh.name = node.name;
    }
    ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.