How to load gltf format model with AssetsManager.addMeshTask

How to load gltf Model in Reactjs project with AssetsManager.addMeshTask
I have successfully loaded .babylon model but I want to load .gltf model.
How can I load the .gltf file model?

here is my code snippet

 loadModels = () => {
    let loader = new AssetsManager(this.scene)   
    let loadModel = loader.addMeshTask("test", "", "", "model.babylon")
    loadModel.onSuccess = ( t ) => {
       // do some code
       // .....
    return loader

when I load
loader.addMeshTask(“test”, “”, “/3Dmodel/”, “test_2.gltf”)
then it give this error

Unable to import meshes from /3Dmodel/test_2.gltf: importMesh of unknown TypeError: Cannot read property ‘0’ of undefined
at Function…/node_modules/babylonjs/babylon.js.d.FromArray (babylon.js:1)
at Function…/node_modules/babylonjs/babylon.js._.Parse (babylon.js:1)
at Object.importMesh (babylon.js:1)
at babylon.js:1
at d (babylon.js:1)
at XMLHttpRequest.o (babylon.js:1)


Did you make sure to reference the gltf loader?

1 Like

Thanks for the response.
I am new to this.
How can I make sure reference of “gltf loader” can you give me any example for this.

I am following this

also, I get this tutorial
and I have successfully loaded gltf file through SceneLoader.Append method.
but I want to load like AssetsManager.addMeshTask.

AssetsManager.addMeshTask eventually calls SceneLoader.ImportMesh which is very similar to SceneLoader.Append. Can you repro this in the playground using AssetsManager.addMeshTask?

1 Like

@bghgary Thanks for guide.

@Deltakosh I understand your point when I import ‘babylonjs-loaders’; then addMeshTask successfully import gltf file.

1 Like