I’m currently trying to build a distributable version of a project that includes models in the GLTF format. In the IDE, such models are loaded without problem. However, in the distributable version the loading of them fails, producing an error message in the log of the following form:
:loader(error): Extension of file <file-path>.gltf is unrecognized; cannot load.
Currently known scene file types are:
Bam .bam
:loader(error): Couldn't load file <file-path>.gltf: all matching files on model path invalid (the model path is currently: <model-path>)
The fact that the error only lists “bam” as a known file-type seems to suggest that GLTF support hasn’t been included in the build.
Conversely, however, I do have “panda3d-gltf” in my “requirements.txt” file.
At least in the case of building my Arena FPS Sample Program, which includes both .bam and .gltf models, the bdist process has no errors and produces a working executable.
I’ve now committed a few changes that I’ve made since last you saw the project, I believe, so it might be worth updating on your end before you attempt a build.
I’ve continued our discussion in a PM, though for everybody else who might be watching this thread, I did get the project in question to build with .gltf files in a working executable.
I’m not sure what the problem in the original post was, however, I’ll defer to somebody else on that.
I should perhaps clarify: The project does build and even run on my end–but the distributable version produces the errors shown in the first post when run, where the source version does not.
Surely Panda is capable of loading files from two different extensions…? o_0
Or will it still load bam/egg.pz files if the default is set to “gltf”, but then allow the loading of the latter…?
I really don’t think that you should ship panda3d-gltf and the .gltf files with your game; rather you should register an extension handler to convert them to .bam files upon running build_apps, similar to what happens when you pack an .egg file.
@Moguri perhaps we should look for a way for panda3d-gltf to automatically register such a handler with build_apps?
As it happens, behind the scenes the GLTF files in question have been converted to bam files for me, so I no longer require support for the former in my build. Nevertheless, thank you all for your help here, and perhaps this will prove useful to others in the future!
I know this a bit old, but I haven’t been able to load GLTF or GLB with Panda at all. I have been using this guy’s tool: GitHub - Moguri/panda3d-gltf: glTF utilities for Panda3D to convert them to bam (I am not affiliated with that repo). It seems to work well for me so far… All of my models were originally glb, but converted to bam with gltf2bam. And I have built executables on Ubuntu and Windows 11 without any issues.
One other good thing is that gltf2bam works with a venv too as long as the venv is activated… on both Windows and Ubuntu I do not follow the typical install directions that are given in Panda3d documentation. I just treat it like any other python lib and install it into a virtualenv. I have not had any issues so far. Although I did have to apt install the recommended libs on Ubuntu… Windows worked right off the bat (odd lol).