{"id":10019,"library":"panda3d-gltf","title":"Panda3D glTF Utilities","description":"`panda3d-gltf` provides utilities to load glTF (GL Transmission Format) 3D models into the Panda3D engine. It handles parsing glTF files and converting their data (meshes, materials, textures, animations, scenes) into Panda3D's native scene graph format, simplifying the process of integrating glTF assets. The current version is 1.3.0, with releases occurring as needed for fixes and feature enhancements, rather than on a fixed schedule.","status":"active","version":"1.3.0","language":"en","source_language":"en","source_url":"https://github.com/panda3d/panda3d-gltf","tags":["panda3d","gltf","3d","model-loading","game-development","asset-pipeline"],"install":[{"cmd":"pip install panda3d-gltf","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core 3D engine that this library integrates with.","package":"panda3d"},{"reason":"Used internally for parsing glTF file structures.","package":"pypi-gltf"}],"imports":[{"note":"The `gltf_loader` module is exposed directly at the top level for convenience, avoid importing it from its submodule path unless directly referencing its classes.","wrong":"from panda3d_gltf.gltf_loader import gltf_loader","symbol":"gltf_loader","correct":"from panda3d_gltf import gltf_loader"},{"note":"Use this to access the lower-level GLTFLoader class for more control over the loading process.","symbol":"GLTFLoader","correct":"from panda3d_gltf.gltf_loader import GLTFLoader"},{"note":"For converting glTF models into Panda3D's native BAM format for faster loading.","symbol":"Converter","correct":"from panda3d_gltf.converter import Converter"}],"quickstart":{"code":"from direct.showbase.ShowBase import ShowBase\nfrom panda3d_gltf import gltf_loader\n\nclass MyApp(ShowBase):\n    def __init__(self):\n        ShowBase.__init__(self)\n\n        self.disableMouse() # Disable default camera control\n        self.cam.setPos(0, -10, 0)\n        self.cam.lookAt(0, 0, 0)\n        self.setBackgroundColor(0.1, 0.1, 0.1)\n\n        # --- User provided glTF model is required ---\n        # Replace 'path/to/your_model.gltf' with an actual glTF file path.\n        # For a runnable example, ensure this file exists or use a known sample.\n        # Example: a simple 'box.gltf' in a 'models' directory.\n        model_path = 'models/box.gltf' \n        \n        try:\n            model = gltf_loader.load_gltf(model_path)\n            if model:\n                model.reparent_to(self.render)\n                model.setPos(0, 0, 0) # Adjust position as needed\n                model.setScale(1)    # Adjust scale as needed\n                print(f\"Successfully loaded {model_path}\")\n            else:\n                print(f\"Failed to load {model_path}. Model object is None.\")\n        except Exception as e:\n            print(f\"Error loading glTF model from {model_path}: {e}\")\n            print(\"Please ensure the glTF file exists and is valid.\")\n\napp = MyApp()\napp.run()","lang":"python","description":"This quickstart demonstrates how to initialize a basic Panda3D application and load a glTF model using `panda3d-gltf`. It sets up a camera and a dark background for visibility. Users must replace `'models/box.gltf'` with the actual path to their glTF file. It also includes basic error handling for file loading issues."},"warnings":[{"fix":"Refer to the `panda3d-gltf` GitHub README for updated import paths and usage patterns for versions 1.0.0 and newer.","message":"Version 1.0.0 introduced a complete rewrite of the API. Code written for pre-1.0 versions is not compatible with 1.x and will require significant updates.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Ensure that the directory containing your glTF model and its dependencies (textures, bins) is added to Panda3D's VFS using `loader.mountFileSys` or `Filename.setModuleDir(os.path.abspath(os.path.dirname(__file__)))` at the start of your application, or provide absolute paths.","message":"Panda3D's Virtual File System (VFS) handles asset paths, and it might not automatically resolve relative paths as expected without `addDirectory` calls or using Panda3D's `Filename` object. This can lead to `FileNotFoundError` for models or textures.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Check the `panda3d-gltf` documentation for supported extensions. If an extension isn't supported, you may need to preprocess the glTF file to bake down unsupported features or manually implement custom loading logic.","message":"Not all glTF extensions are fully supported by `panda3d-gltf`. Models using advanced or custom extensions (e.g., specific PBR material extensions not common in core glTF, or complex animation nodes) may not load correctly or might lose certain features.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Verify the file path. Ensure the file exists relative to your script or add the directory containing the model to Panda3D's search path using `loader.mountFileSys` or similar VFS methods.","cause":"The glTF file specified in `gltf_loader.load_gltf()` does not exist at the given path, or Panda3D's Virtual File System cannot find it.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'your_model.gltf'"},{"fix":"Correct the import and call: `from panda3d_gltf import gltf_loader` then `gltf_loader.load_gltf('your_model.gltf')`.","cause":"Attempting to call `panda3d_gltf.load_gltf()` directly. The `load_gltf` function is part of the `gltf_loader` submodule.","error":"AttributeError: module 'panda3d_gltf' has no attribute 'load_gltf'"},{"fix":"Add appropriate light sources to your Panda3D scene and ensure they are parented to `render`. For example, add `self.render.setShaderAuto()` and `self.render.setLight(some_light_node_path)`.","cause":"The Panda3D scene might be missing proper lighting. glTF models often rely on PBR (Physically Based Rendering) and require lights (e.g., `DirectionalLight`, `AmbientLight`) to be visible.","error":"Model loads but appears completely dark or as a solid, untextured color."}]}