Importing GLB file issue

I get the error Unexpected magic: 1329865020 when trying to import my glb file using scene loader.

 BABYLON.SceneLoader.ImportMesh("", "../assets/", "demo.glb", scene, function (newMeshes, particleSystems, skeletons) {
          // do stuff here
        });

I am using Webpack and Vue Cli. How can I solve this issue?

Hi. We need more details.
From where you have the glb file. Do you export it from Max, Blender or other software?
Did you try it on https://sandbox.babylonjs.com and there is working?
Did you import Gltf loader?
More of your code will help too :slight_smile:

Hey @MarianG, it was exported in Max by an artist as a gltf file. I used an online converter by sbtron. I tried the sandbox and everything works fine there. I imported the gltf loader. The sample code is in my original post. The code works fine if I import a glb using a URL like rawgit, but does not work with files that are stored locally.

Then I have no idea.
Let see maybe somebody else can help you

By imported locally you meant from a local webserver? Because browsers does not allow you to load data from localfile system directly (for security reasons)

Yes, I mean a local web server, not the file system.

There is a magic number at the beginning on a GLB file. The Unexpected magic: 1329865020 error means that the beginning of the header of the GLB is wrong. 1329865020 in hex is 4F44213C which doesn’t match the expected value of 46546C67. What kind of local web server are you using?

I am using the webpack server that comes with the Vue command line tool.

that should work then. Do you have any console or network error in f12?

I have a console error, but no network error.

Can you share your page somewhere so we can see it live?

I don’t have a live version, but I have created a repo that reproduces the issue: GitHub - dtrinh100/babylon-glb-issue

the file duck.glb is returning “<DOCTYPE html><html lang=“en”><head>…” you need to serve the file from your /public assets folder.

edit: move duck.glb into /public/assets/ (you need to make that folder).

1 Like