Relevant documents: getObjectById , getObjectByName . Important note from getObjectByName :
Note that for most objects, the name is the default empty string. You will have to install it manually in order to use this method.
This may be why you are getting undefined . Also, if you get undefined , try to access .name or .id for an error.
Another important point that I learned is that the value that getObjectById needs to getObjectById is object.id , not object.uuid . In addition, object.id is essentially just an object index in the children array.
Putting it all together:
// var object = new THREE.Mesh(...) or similar object.name = 'objectName'; scene.add(object); var retrievedObject = scene.getObjectById(object.id); // or var retrievedObject = scene.getObjectByName('objectName'); alert(retrievedObject.name);
source share