Unable to import mesh

I’m unable to import mesh using ImportMeshAsync function. I followed the docs Importing Meshes | Babylon.js Documentation .
I’m getting the below console error when I do it in my local.

I’m using these imports.

<script src="https://cdn.babylonjs.com/babylon.max.js"></script>

<script src="js/sceneLoader.js" type="module"></script>

<script src="https://cdn.babylonjs.com/serializers/babylonjs.serializers.js"></script>

<script src="https://cdn.babylonjs.com/serializers/babylonjs.serializers.min.js"></script>

And I’ve specified the file path correctly.

PG link - https://playground.babylonjs.com/#PE4GC4#1

Am I missing anything ?
@Cedric @Evgeni_Popov Kindly suggest me.


when using GitHub, use external link raw.githubusercontent.com

1 Like

@Dshah_H thanks for pointing that. But can you please look into the error which I posted it from my local.
I gave some github link just to work in PG so that I can share it here. Anyways, providing raw.githubusercontent.com worked.

I tried giving my localhost url in PG, then also I didn’t get any output. I’ve the required files in the given file path.

You have too many parameters to ImportMeshAsync, you shoud remove "":

 "http://localhost:8000/scene_input/", 'AnimatedMorphCube.gltf', scene);

Removed extra quotes - https://playground.babylonjs.com/#PE4GC4#7
But still blank output.

JFYI - I have downloaded the same file to my local and using the same one which I tried on github one https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/AnimatedMorphCube/glTF-Binary/AnimatedMorphCube.glb ( PG link posted in my previous comment - https://playground.babylonjs.com/#PE4GC4#2 )

This PG does work:


So if you replace the url by a local url it should work too, provided you have correctly setup your local web server.

1 Like

I ran python http server on my local path and made use of that. (“python -m http.server” used this command)

So, does it work? What do you have in the browser console?

The gltf file is found so it should work.

Just in case, you can try to replace http://localhost:8000/scene_input/ with ./scene_input/.

It didn’t work even though that file is present.

@Evgeni_Popov I tried writing the code in my VS code by giving the file path from my local disk. It’s showing up this error

Try to use babylonjs.loaders.js instead of babylon.glTF1FileLoader.js as your file is probably not a gltf1 file.

I’ve included it, still seeing this error

I’m not sure, why it’s not able to find babylon.glTF1FileLoader.js / babylon.glTF2FileLoader.js .Do I need something to get these included.

You need to include the packages in your page to be able to use the functions from them. See what the Playground is doing:

@Evgeni_Popov have included all the imports.

It seems to be a bug in your code handling the onSuccess task: you try to set a position for an object which is undefined. You will need to debug this on your side, we won’t be able to help more except if you can provide a PG that reproduces the error.

1 Like