Export and import glTF models¶
glTF 2.0 is the recommended starting point for bringing 3D models and scenes into jMonkeyEngine. It carries meshes, PBR materials and, where supported by the exporter and importer, animation and other scene data.
In Blender, build your scene using glTF-compatible materials, export it as glTF or GLB, and put the resulting file and any external textures under your project's resource root, for example game-assets/src/main/assets in a project generated by the Initializer. Preserve the relative paths of external files. Load the model by its path relative to that root:
Spatial model = assetManager.loadModel("Models/Scene/scene.glb");
rootNode.attachChild(model);
Start with a small asset and check its texture orientation, scale, normals, animation and materials in the engine. PBR materials also need suitable lighting and an environment to resemble their appearance in the authoring tool; the PBR guide explains how to set these up. Some authoring-tool features do not map directly to glTF or to the engine's importer, so test the features your asset uses.
The Khronos glTF Sample Assets repository provides assets for testing. Check the license of each asset before redistributing it.
Export checklist¶
- Apply or check the object's scale and orientation in the authoring tool. Keep the scene hierarchy readable.
- Use the metallic-roughness PBR workflow and connect textures through a glTF-compatible material. Export animations only when needed.
- Export a
.glbfor a convenient single-file asset, or.gltfwith its external files. Put the complete export in your shared resources. - Load it in a small jMonkeyEngine scene. Set up a sky and an environment probe, then compare material roughness, normals, scale and animation with the original.
Preparing a model in Blender¶
Use a Principled BSDF material with glTF-supported base color, metallic, roughness and normal textures. Apply transforms when appropriate for your model and rig, and verify scale and orientation after import. Use the glTF exporter's animation options to include the actions and shape keys you need; bake constraints or procedural motion that the exporter cannot represent. Export a small test first and check the resulting animation and materials in the engine.
The engine needs the glTF loader supplied by jme3-plugins. Check that the generated project includes it when importing glTF. See the Blender glTF exporter manual for current exporter options. glTF extension support varies: test the exact features used by your asset.
Load an official sample remotely¶
The engine's jme3test.model.TestGltfLoading demonstrates UrlLocator with the Khronos glTF Sample Assets. For example:
assetManager.registerLocator(
"https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/refs/heads/main/",
UrlLocator.class);
Spatial radio = assetManager.loadModel("Models/BoomBox/glTF-Binary/BoomBox.glb");
rootNode.attachChild(radio);
This example requires network access and a compatible glTF loader. Because remote loading can take time or fail, a production application should load assets asynchronously and handle failures, or use packaged or cached assets. Before distributing a model, check its license and the glTF extensions it uses.