Meshes of the same name affect each other when creating multiple engines

I build models with web components. That is, I will create a new BaseScene class (new DOM, new engine, new scene), then when I build the meshes, I will just extend from BaseScene => Each mesh has its own dom structure, engine, canvas, etc.
But, when I render multiple mesh and manipulate the mesh values, the meshes are affected by each other despite running on different engines.
E.g.: <mesh-a /> (1) <mesh-b /> (2) => mesh-a and mesh-b have the same mesh name => dispose on 1 => 2 has been affected.
I tried renaming the mesh; the meshes no longer affect each other; also, I log the engine and notice that it is using the same name. After that, I kept the same name for the meshes and changed the engine name by force; the meshes were no longer affected.
telegram-cloud-photo-size-5-6314324296125756911-x

=> If the engines have the same name, it utilizes the same engine regardless of how many engines are initialized, correct?

Could someone help me in answering this question?
Thank you!

Every engine needs a GL context. if it is shared, there will be a collision during rendering - one will influence the other rendering process.
You can create more than one engine, but it would be better to provide them a different context. The naming shouldn’t matter - you can load the same mesh in different engines and scenes, and they will run independent of other meshes. There might be a static cache between the engines, but it would be for assets, not for the transformations or the mesh’s properties.
If you do want to share an engine between scenes you can use the LastCreatedEngine static member in the EngineStore class. Create it if it doesn’t exist, use it if it does.
Can you share a reproduction?

2 Likes