Unexpected Magic? Glb/react babylonjs

Getting this error message:

react-reconciler.production.min.js:128 Error: Unexpected magic: 1936876918
at glTFFileLoader.ts:841:23

strangely, my glb file works locally. I use Netlify to serve my site, but then I get the error above. Any solutions?

Hello and welcome to the Babylon community!

The “unexpected magic” error refers to the GLB format header, which has to have a specific value: glTF™ 2.0 Specification (khronos.org) - 0x46546C67 in hex which is 1179937895 in decimal. Since your file is working fine locally but not remotely, I wonder if this might be some kind of server setup adding data to the beginning of your files? :thinking:

How are you loading this GLB? Do you have it in a directory in your setup and load it from that path?

Put your model assets in the /public folder. If you a model in /public/models/myModel.glb, for example, then the rootUrl of your models is /models.

What’s happening is that babylonjs is being served your index.html file for every file that cannot be found - this is how we can navigate to /some/random/url and the react-router will pick up on that. You can look in your network tab to confirm this is happening, but also when you get the folder/rootUrl right you will see that.

edit: upon re-reading it may be a configuration issue. Are you deploying to the root folder or your netlify site? If you are in a sub-folder then you need to edit the “homepage” in your package.json to set the rootUrl correctly.
edit 2: and then use ${process.env.PUBLIC_URL}/models

Hello @rajanrahman just checking in if you still have an issue

This answer helped me fix the same problem after hours of trying to figure it out. Thank you!

1 Like