Loading GLB Files from Web Chache?

Hello Fellow BabylonJS Users,

I’m currently facing the problem of wanting to import a glb file that i previously stored via the Web Chache API. I tried several things like using the async loader directly, using import etc. couldn’t get it working…

What i do wonder is if there is by any means a way to load a glb file not via requesting in from the sever, i need to preload the glb as there is some addtional data attached which i need to remove before the file is a valid glb. After That step i’m left with a arrayBuffer object that contains the glb.

The first try of loading it resulted in a JSON Parser error e.g it said it found a Unexpected B at position 0 while when i looked at the data i wasn’t able to find that…

Thanks for every Reply i hope the question is clear…

You can load a glb file providing a base64 encoded data:

Yeah i know but i can’t really do base64 encoding on that data set it seems. Or at least i would need todo it in the fronted. And when i did that for some reason i got a json parsing error. I i just normaly import the glb/dracocompressed then i don have that problem…

Basically when i try to load it i get: SyntaxError: Unexpected token b in JSON at position 0

Also the asset is quite big…

Are you prepending your encoded data with data:base64, as in:

https://playground.babylonjs.com/#7F6S08#15

?

If you can make a PG (even with a smaller glb), it will be easier to look for the problem.

Yes i preappend data:base64, sadly no diffrence it Errors on some json thing.
Though the model seems to be ok because when i load it just from the server then it does that without any problems.

Yeah i will make a tiny POC and add it here again…

Here is the answer for some reasons the loaders are not correctly loaded when say the npm local version of babylonjs is used this doesn’t happend when one loads the cdn versions.