AssetContainer.instantiateModelsToScene() method does not copy an InstancedMesh.renderOverlay

Hello, it’s me again with a different question. Continuing on in my project I have this Playground where a mesh is added to an AssetContainer.

There are two meshes, a mesh and its instance and both are required to have its renderOverlay = true.

So far, only the mesh but not the instance gets the renderOverlay affected.

I tried cloning, but that didn’t work out with a complex mesh and it’s multiple instances.

Hints anyone?

I appreciate the time for anyone reading this post.

If you apply renderOverlay to the original mesh, it works - https://playground.babylonjs.com/#54UKRQ#4
(line 25, sphere.renderOverlay = true;)
If you apply renderOverlay to the instance, it will not work; instance will only repeat the original mesh overlay settings.

I appreciate your suggestion, @labris, though I should’ve clarified it better.

The steps are to:

  1. Setup the meshes
  2. Add the meshes to an AssetContainer class.
  3. Remove the meshes from the scene by removeAllFromScene()
  4. Instantiate them through instantiateModelsToScene() method or related from the AssetContainer class.
  5. renderOverlay, the meshes and its instances here
  6. Dispose the meshes
  7. just in case, reinstantiate/clone and re-renderOverlay the meshes rerenderOverlay.
  8. Rinse and repeat steps 4 - 7 till the end of the session.

The concept here is like when a mesh would flash red or would get copied or instantiated again and also flash red.

Thanks.

Have a look at https://playground.babylonjs.com/#54UKRQ#6

Sorry for the lack of response in a while. when I tried to use the playground to do 2 or more instances of the 2 spheres, it doesn’t work. Based on this example:Babylon.js Playground

I these are my results.

https://playground.babylonjs.com/#54UKRQ#8

So this example (which I believe is working one) doesn’t suit your needs? https://playground.babylonjs.com/#54UKRQ#10

Well, I’m not explaining myself clearly and you are trying your very hardest but the example I used in the playgrounds are not that well suited. I have created a new playground with this time a widget or a multi-sphere something.

First the widgets are defined, then removed then are instanced to the scene. I want a widget to be highlighted in these examples but I got unusual results when instanced meshes are involved.

  1. the large sphere is highlighted but the second, little spheres are not in this example
    https://playground.babylonjs.com/#UWGR66#4

  2. In this example, everything is highlighted, but the instances “spill” to each one.
    https://playground.babylonjs.com/#UWGR66#3

So, this should’ve been the example playground I should’ve used from the start. Any one has suggestions, nudges or hints that prevent a spill over or a needed extra highlight for the instanced smaller spheres in this example? That’s the quirk I am experiencing with my project. I’m clearly missing something.

1 Like

As you may see in console, in the1st example you overlay 2 spheres and they are shown red - does it seem correct? - https://playground.babylonjs.com/#UWGR66#5

3 Likes

Yes, it does. sphere3 is an instance of sphere2, not a clone. Also, is there a way to make the renderOverlay = true with sphere3 AND not spill over to the other widgets like that happened in the examples I gave in playground example (#2)?

The only solution I could find is to just do a clone, not instances of the meshes.

Thanks in advance.