[SOLVED] Load gltf files from URL


I am trying to load this GLTF file from a URL in the Playcanvas editor:

I tried to load with the playcanvas-gltf library but it doesn’t load it, and the playcanvas viewer loads it correctly if you drop the above file in the viewer, I saw the code here which loads it:

The only question I had was, would I have to rewrite this code in the editor to load gltf files from a URL or there is any utility scripts I can use to load them in the editor just like with GLB files?

Hi @Saad_Haider ,

Calling @slimbuck most likely he will know.

1 Like

Hi @Saad_Haider,

If you are loading glTF/glb files that are self contained and have no external references (i.e. all textures and animations, meshes etc are embedded in the file), then you don’t need to worry about implementing processBufferView, processImage etc.

The process functions are only needed if you require special handling of external references. For example in the viewer, these files are provided by the browser’s drop handler and so these special functions are required.

In your case it looks like the glTF is self-contained and you don’t need to bother with any special handling. Not sure if you’re aware, but playcanvas-gltf is now legacy and has been superseded by the engine’s built-in loading of glTF files. I would suggest you give that a try.

Hope that helps!


You can see an example of loading a glTF file using the engine here. (Make sure to expand the code pane on the right to see source code).

1 Like

Thank you, that totally makes sense, I tried loading it with the example code and it works perfectly!

1 Like