Instanced Mesh on object with multiple children

Hi.

I’m making a project that uses a lot of repeated geometries.
For example, one of them is BoxGeometry.
Initially, I was creating a mesh for each object.
However, I saw that I was making a CPU call for each object.
I found the InstancedMesh reduces the number of draw calls.
I tried the InstancedMesh on BoxGeometry, and it worked.
When I was trying more complex objects (with children), that have multiple geometries, it didn’t work.
Anyone knows what I need to do in the more complex objects.

Thank you.

1 Like

Hi!
For some ideas, have a look at this post: Mesh Instancing with nested hierarchy - #2 by prisoner849

1 Like

Hi!

Thank you for your answer.
I forgot a detail.
Every geometry has a different material.
For example, a car has wheels, a body, and other parts.
Each part has a different material.
These geometries/materials are part of the same mesh, which I load from an obj file.

The fact that I have different materials changes anything?
Do I have to create an InstancedMesh for each of the children?

Thank You!

I think if 10 cars.
One InstancedMesh for car body with 10 instances.
One InstancedMesh for car wheels with 10 instances.
And update matrix every frame.