SceneLoader file type autodetect and What is unexpected magic

I try to append some scenes with SceneLoader.Append but I get this error. File types are glb and gltf. I try them not simulatenously, but at different times.

BJS - [18:19:30]: Unable to load from http://localhost:3001/mavi-kutu.glb/mavi-kutu.glb: Unexpected magic: 1784835931

What does this error mean? What do I do wrong?

Is it related to the wrong file type I try to append?

How can I use SceneLoader.Append to automatically know what to do regardless of file format I try to load, whether glb, gltf, obj, or babylon

The magic number is part of the header of a GLB file. See glTF/specification/2.0 at master · KhronosGroup/glTF · GitHub

For a GLB, this number is expected to be HEX 0x46546C67 (1179937895). The error you are seeing just means the loader parsed out a different number than expected for a GLB file. Are you sure this file is actually a GLB file?

1 Like

Later I found an error in my code taht does not hand in correct type to node.js fs.writeFile funciton. So what it writes to file supposed to be a glb file was just [object Object]. So that must be the reason of the error then.

Thanks a lot.

But what about the SceneLoader thing?

According to example in doc here Load from any file type - glTF, OBJ, STL, etc. - Babylon.js Documentation the args ommittable. So maybe it auto detects what is the file format.

If you don’t pass in the extension string, the loader will detect what kind of asset it is based on the file extension from the URL.

1 Like