Loaading all materials from gltf in typescript

Hello,

I am trying to load a model with multiple materials so I can easily switch them in runtime, without the need to define them in the code.
The problem is the GLTFloader loads only user material.
I have found this Standalone GLTF Materials? - #10 by Deltakosh , but doing it in my typescript project throws an error :

Property 'loadAllMaterials' does not exist on type 'ISceneLoaderPlugin | ISceneLoaderPluginAsync'.Property
           'loadAllMaterials' does not exist on type 'ISceneLoaderPlugin'.

     L82:  SceneLoader.OnPluginActivatedObservable.add((plugin) => {
     L83:      plugin.loadAllMaterials = true;
     L84:  });

I am using 5.0.0-alpha.60.
Any idea how to make it work?

You need to cast the plugin into GLTFFileLoader to be able to use those in typescript. To be safe you could test plugin.name === “gltf” before.

1 Like

Great,
Thank you Sebavan. Still new to typescript.

1 Like