Looking for id´s and names of meshes

Hi Three.js followers,

Looking for id´s and names of meshes

With this page, I found 3 id´s and respective names.
id 3 … name scene_name
id 8 … name cubeA
id 9 … name cubeB

Please, help me to find what are the 1,2,5,6,7 others id´s.

PS: console.logs errors in Firefox were detected and corrected:
a) the way id s were written … changed to id’s,
b) if(scene.getObjectById(w)){…} is now included in the search for id’s,
c) the original url of the page is mantained on the site (id_name.html).

the link:


Again, Thanks for the great Three.js Team!

José Roberto Lazzareschi

I’m confused about what you’re asking because your scene appears to only have two objects.

Screen Shot 2022-09-16 at 8.07.42 PM

Hello Chris,
then 3 scene.getObjectById().id appeared.
but as id=3, id=8 and id=9,
Please, help me to find what are the 1,2,5,6,7 ids.
Thank You for the interest.

Hello Chris,
In other words…
Why cubeA and cubeB, the two meshes, received id 8 and id 9?

Hello jrlazz -

I think that objects in a scene have incrementing IDs. They appear to start at 10, though this could vary between scenes, or maybe even versions of three.

Here is an example fiddle with 10 cubes and a camera. I log each ID, they increment starting from 10.

Hello Chris,

With Copyright 2010-2022 Three.js Authors const REVISION = ‘137’, happened:
id= 4 … name is: scene_name
id= 10 … name is: cubeA, and
id= 11 … name is: cubeB.
OK… different for different versions… but still not justified for me.

Thank You again for the look for an answer…

First of all, not just your cubes, but also, for example, your camera (or lights, if you had any) have their id. Secondly, those ids are not necessarily consecutive, so there can be “gaps” between ids. You can find which are the objects corresponding to the other ids you mentioned in at least 2 ways:

  • use a console.log(scene); somewhere outside any loop in your code, and manually examine the scene’s children, grandchildren, etc. and notice their ids
  • do the above automatically, by using something like for (var i = 0; i < 10; i++) {try {console.log(scene.getObjectById(i));} catch {};};, or, if you want a more compact form, log the scene.getObjectById(i).type instead in the loop; obviously, the 10 value in the for can be adjusted based on what you estimate that your maximum id will be

As already pointed out by @notchris, your code yields some errors and, well, it’s not that friendly on resources, so I’ll leave adding one of the above to it in your hands, so to speak.

P.S. Getting your objects by name, assuming that you set them to unique values, is a more reliable way to get your objects, a way that you have full control over.

1 Like

Hello Yin,
Thank You very much for Your observations!
I will try the suggestions to find the scene’s children, grandchildren, etc.

You’re welcome - glad to help. :wink:

Hello Chris and Yin,
I made some changes in the original (QUESTION) post.
Now id_name_r1.html.
console.log(scene); and
for (var i = 0; i < 10; i++) {try {console.log(scene.getObjectById(i));} catch {};};
var objects = [ ];
scene.traverse( ( child ) => { if ( child.isMesh || child.isPoints || child.isLine ) objects.push( child );console.log(child);} ); … (from [ Mugen87 Michael Herzog in Get list of all children - #2 by Mugen87 )
I could not find news… only two childs cubeA and cubeB.
I will continue to try discovering why “those ids are not necessarily consecutive, so there can be “gaps” between ids”.
Thank You for the interest with this post.

Well, good luck with that, and if you find why, let me know. I actually discovered this while exploring my own project object ids, which also had gaps between them. To be honest, I anticipated that and it doesn’t seem strange to me, but obviously I don’t know the internal reason for it, I just shared what I found out in a similar examination process.

Hello Yin,
Thank You Very Much again for the attention. :slightly_smiling_face:
I asked help from Klaus Hoffmeister (hofk) too!


in the library, it goes like this:

let _object3DId = 0;


class Object3D extends EventDispatcher {

  constructor() {


	this.isObject3D = true;

	Object.defineProperty( this, 'id', { value: _object3DId ++ } ); // <- HERE

every time you create an Object3D of any kind, the id is increased by one.

Hi Friends, I will be out for some days… and hope to test these new suggestions and continue this search when get back.
Thanks for Your interest.