Highlight or changing material in instance meshes

I’m using Babylon for BIM projects, there are multiple instances from different objects and when I’m trying to change the material or added to the HighLightLayer doesn’t work as I want. There is an interesting solution that I found here: Source A and here: Source B, it works partially changing the material or highlighting object, but the issue that I have is related to the position of the object, because when I cloned the object, the object inherited the absolutePosition, absoluteRotationQuaternion and absoluteScaling and I’m not able to solve it, because those properties are readonly. Using the available properties to change these values, it does not solve the task because the properties already mention updates with another values.

Thanks in advance for any help or suggestion!

Welcome aboard!

Why do you need changing those properties? Cloning the mesh should create a clone right at the same location than the cloned mesh (as we can see in the samples you provided). Even if the mesh has a parent, the cloned mesh is created as a child of this same parent so it should work.

Are you able to create a repro in the Playground so that we can have a look?

Hi Evgeni_Popov, thanks for your faster replied,
The point is because if I clone the instance selected, I won’t be able to change the material or highlight the cloned object because it will be an instanceMesh and I will have another issues because, I understood that it’s not possible to do it with instances, is for that reason I used this Source B, that it seems useful, but the position, rotation and in other case scaling part doesn’t work, I’ll try to undestand how to create the repo in the Playground, for a while this image


In addition to the position you also need to set the scaling/rotation of the picked mesh to the cloned mesh because the cloned mesh is the master mesh:


1 Like

Hi again!
I hope this could help to understand the issues
No available!!!

Thanks Evgeni_Popov!

Please use this link!!

The cloned mesh has the same parent than the master mesh. If it’s the same parent than the instance it’s ok, but if it isn’t it fails. You should set the parent of the clone to be the same parent than the instance:


Thanks a lot Evgeni_Popov!