Importing gltf assets

Hi everybody,

I have a question about the gltf import. If i import the same gltf asset several times, materials are created several times.

Is it possible to keep the former materials instead of creating them again and again ?

Thanks,

Boris

1 Like

Hi. Maybe you don’t need import same file again? Simply save your model in variable and reuse

1 Like

I need to place it in several positions. So i need several copies of my mesh. But maybe i don’t understand exactly what you’re proposing.

You can use instancing to have multiple meshes sharing materials. Will also have a performance boost.
Instances | Babylon.js Documentation (babylonjs.com)

3 Likes

I thought @brianzinn gave me the solution but it’s a little bit more difficult because my mesh is made with several submeshes and nodes and i cannot find the tree structure anymore.

Here’s the playground : https://playground.babylonjs.com/#3PE956#1

The rotation issue is because the instance doesn’t have the root mesh (__root__) that transforms from right handed to left handed. You can do it manually but it’s easier to use instantiateHierarchy to copy the whole node tree for you, like below. :slight_smile:

2 Likes