Using instantiateModelsToScene and "cloneMaterial" parameter to change materials?

PG here: https://www.babylonjs-playground.com/#S7E00P#20

I’m trying to figure out how to use instantiateModelsToScene with the cloneMaterial parameter properly. There’s not much info in the documentation about how to get the cloned material, and I’m hoping someone can point me in the right direction.

I’m trying to instantiate a model from an asset container, then change one of the materials in the appropriate mesh each time it is instantiated. I’ve set the instantiateModelsToScene cloneMaterial parameter to “true”, but I don’t notice any difference. I’ve tried changing the material BEFORE using instantiateModelsToScene, which does work in my project, but the material appears linked to the root object and is applied to all instances. Am I using the wrong approach here?

Thanks in advance.

Cloning materials does work:
image
The original material is Alien and your two clones are myName.

instantiateModelsToScene does not return the cloned materials, it returns only rootNodes, skeletons and animationGroups.

Boy do I feel dumb after that one! I wasn’t using the scene explorer to verify the materials were being cloned. Thanks for pointing me in the right direction!

:grimacing: