Help needed for loading gltf with blob or arraybuffer

Hi guys, new here. great community

I’ve been staring at the doc for a while, I’m still having a hardtime trying load a basic gltf model from loose files.
i have .gltf .bin .pngs in memory, blob or buffer either one is fine
how do i go about loading the model? please share
(not considering glb)

Hello and welcome!

Maybe this example will help - https://playground.babylonjs.com/#7F6S08#2

thanks for the quick reply, I saw this example in the doc.

but what about sub resources like textures?

let’s just use this example you shared, if there are resources like textures referenced by the gltf, how do i load or prep them so the loader can correctly pick them up?

thank you for the help

Well, just for textures it is simple, like

    var res = await fetch('/textures/palm.png');
    var blob = await res.blob();
    var blobURL = URL.createObjectURL(blob);

But the problem is with references. There could be different ways to solve them, and currently I am not sure which is better. Here is quite a long thread about it - Modify gltf in runtime,fallback for textures
Pinging @bghgary , GLTF master :slight_smile:

3 Likes

thank you so much for helping.

yea the references are giving me problems. ive seen some discussion about hooking into gltfloader’s preproess url to fix up the path. i dont have a clear mental picture yet, but will look into it some more

2 Likes

Yes, that should work. Another thread (slightly shorter), about the same kind of question.

https://forum.babylonjs.com/t/does-gltf-loader-support-loading-separate-blob-stream/26602

1 Like

Hello @decafbagel just checking in, do you still have any questions? :slight_smile: