Jmonkey engine how to load glb 3d objects

  1. Create new gradle project
  2. Open build.gradle and update dependecies to latest verison, add plugins dependecie. example:
plugins {
    id 'java'
    id 'application'

group 'com.mygame'
version '1.0'

sourceCompatibility = 1.8
mainClassName = "com.mygame.Main"

repositories {

project.ext {
  jmeVer = '3.5.1-stable'

project(":assets") {
    apply plugin: "java"
    buildDir = rootProject.file("build/assets")

    sourceSets {
        main {
            resources {
                srcDir '.'

dependencies {

  implementation "org.jmonkeyengine:jme3-core:$jmeVer"
  implementation "org.jmonkeyengine:jme3-desktop:$jmeVer"
  implementation "org.jmonkeyengine:jme3-lwjgl:$jmeVer"
  implementation "org.jmonkeyengine:jme3-plugins:$jmeVer"
    // We definitely want a UI
    compile "com.simsilica:lemur:1.13.0"
    compile "com.simsilica:lemur-proto:1.11.0"

    // And our base code for sim-etheral, SiO2, etc.
    // (many of these need to be built locally and 'gradle install'ed as of this writing)

    compile ''
    compile 'org.slf4j:slf4j-api:1.7.13'
    runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
    implementation 'org.apache.logging.log4j:log4j-api:2.8.2'
    implementation 'org.apache.logging.log4j:log4j-core:2.8.2'
    implementation 'org.codehaus.groovy:groovy-all:2.4.15'


jar {
    manifest {
        attributes 'Main-Class': "$mainClassName"
  1. Open blender with 3d model and press file->export->gltf select glb
  2. Place glb object to models folder
  3. Setup assets location folder. load model and add light example:
    public void simpleInitApp() {
        assetManager.registerLocator("./assets", FileLocator.class);
        Spatial object = assetManager.loadModel("Models/object.glb");
        object.setLocalTranslation(-1, -1, -1);
    private void setUpLight() {
           // We add light so we see the scene
        AmbientLight al = new AmbientLight();

        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());

This is great. Thank you!

Just wondering, is it recommended to use gltf glb models directly? Or is the jmonkeyengine j3o still the way to go?

1 Like

Ultimately, it depends on if you are ok with your models taking up 100x the RAM and 100x the CPU to read. If so then glb is fine.

But if you want to minimize RAM usage and the amount of work necessary to read the data then j3o is still the best option.

I still convert all of my models to j3o. (Even wrote an open source utility to make it easier to incorporate into builds. JMEC)

Also, there’s never been a single GLTF model that I haven’t tweaked in some way once loading, whether scale, or material, or whatever… and that can all be built into the j3o once.


ok. so j3o is still the way. was just wondering if I maybe do too much :smiley:

1 Like

You can convert glb to j3o in jmonkey (faster to load)

1 Like

Does the model load after you the window is created, or before?

It loads instantly at the time of invoking loadAsset() on the same thread, however you can change when it loads before the start of the application (before initialize()) using setAssetManager() within your simpleApplication and load your assets before you start the window.