GLTF Importer fails to load assets via input stream


I’m working on my own converter for jme files to streamline setting assets up specifically for my game. I’ve done this in the past pretty easily using swing’s filechooser and loading and exporting via file streams. I wanted to give gltf format a try since it seems promising and I discovered an issue. Because gltf separates its data into 2 files my usual stream importing is failing!

    public void simpleInitApp() {
        //use a file stream to load and asset not registered to an asset directory
        File targetAsset = new File(System.getProperty("user.dir")+
        //start a file stream to load this asset
        try(InputStream in = new FileInputStream(targetAsset)){
            AssetKey key = new ModelKey(targetAsset.getPath());
            Spatial spat = (Spatial)assetManager
                    .loadAssetFromStream(new ModelKey(targetAsset.getPath()), in);
            System.out.println("Spatial loaded from "+targetAsset+" with key "+key+" gives us "+spat);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(TestGLTF.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(TestGLTF.class.getName()).log(Level.SEVERE, null, ex);
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.asset.AssetLoadException: An error occurred loading /mnt/DragonLair/Docs/Dev/JME/JMonkeyProjects/JMEConverter/wip/TestCube.gltf
	at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(
	at com.jme3.scene.plugins.gltf.GltfLoader.load(
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(
	at com.jme3.asset.DesktopAssetManager.loadAssetFromStream(
	at com.mru.converter.TestGLTF.simpleInitApp(
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(
Caused by: com.jme3.asset.AssetNotFoundException: /mnt/DragonLair/Docs/Dev/JME/JMonkeyProjects/JMEConverter/wip/TestCube.bin
	at com.jme3.asset.DesktopAssetManager.loadAsset(
	at com.jme3.scene.plugins.gltf.GltfLoader.getBytes(
	at com.jme3.scene.plugins.gltf.GltfLoader.readData(
	at com.jme3.scene.plugins.gltf.GltfLoader.readBuffer(
	at com.jme3.scene.plugins.gltf.GltfLoader$VertexBufferPopulator.populate(
	at com.jme3.scene.plugins.gltf.GltfLoader$VertexBufferPopulator.populate(
	at com.jme3.scene.plugins.gltf.GltfLoader.readAccessorData(
	at com.jme3.scene.plugins.gltf.GltfLoader.readMeshPrimitives(
	at com.jme3.scene.plugins.gltf.GltfLoader.readNode(
	at com.jme3.scene.plugins.gltf.GltfLoader.readChild(
	at com.jme3.scene.plugins.gltf.GltfLoader.readScenes(
	at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(
	... 8 more

This isn’t severe for me, the easy workaround is to simply add the root of the files location to the assetmanager and it’ll find the bin no problem, but this definitely seems like a bug to me. The gltf importer should have a way to determine if the asset import is via a stream or assetkey and if it is via a stream attempt to open a new stream for the bin (I’m not sure how feasible this is).

For now I’m gonna keep trying gltf and simply register the root when I open a stream and clear it when I close.


own converter? or maybe now you mean you want specify different asset location? because that is what i see based on your code.

if im correct you want have different asset locations.

myself i do it for development with gradle like:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
        runtime project(':Assets')     // production
    } else {
        runtime files("..//SeparateAssetsDir/assets")  // develop

then load models same way as in standard JME. (gradle take care of it, you can specify many pull asset locations)

never tried changing logic of assetManager paths.


The code is literally the simplest case to get it to fail. Not at all what I’m using for my app. I have an editor in swing I use for importing models, assigning materials and game attributes (stats and stuff) then exporting all of that to jme file formats to be packaged with my game.

I use the following for my assets folder and it doesn’t require a conditional (compiles and runs fine in netbeans as well as packaged)

    apply plugin: "java"
    buildDir = rootProject.file("build/assets")
    sourceSets {
        main {
            resources {
                srcDir '.'

I forget where I found that, not mine originally but works perfectly


dont get me wrong, i understand you want verify issue(because it looks like). just wanted provide you simple alternative-way for different .gltf locations where you need NO modifications.(just assetManager.load … like it would be in project, but its not)

and it dont require conditional, i would try something like:

dependencies {
        runtime files("/mnt/DragonLair/Docs/Dev/JME/JMonkeyProjects/JMEConverter") 

replacing path with some variables and load “wip/TestCube.gltf” in assetManager.

about issue, someone else should look at it. im not familiar with assetManager modifications.


The asset manager is not really designed for game editors. It’s built for loading resources in a game. That is not going to change. JME is very adamant about not compromising the engine design just to support some random game editor’s needs.

As such, if you want to use the asset manager in your game editor then you have to work around things. The easiest way in this case I think is to register your own asset locator that will let you resolve things relative to whatever current directory you want.

While the asset manager doesn’t outwardly support the type of thing you want to do, it is very ‘pluggable’.

Really any format that depends on other files will have the same issue.


Can you try this, I once was using this in an editor to locate assets at runtime .

 * Runtime asset locator
 * @author Ali-RS 
public class RuntimeLocator implements AssetLocator{
    private String rootPath;

    public RuntimeLocator() {

    public void setRootPath(String rootPath) {
        this.rootPath = rootPath;
    public AssetInfo locate(AssetManager manager, AssetKey key) {

        Path assetPath = Paths.get(rootPath + File.separator + key.toString());
        if (Files.exists(assetPath)) {
            try {
                return new StreamAssetInfo(manager, key, Files.newInputStream(assetPath));
            } catch (final IOException e) {
                throw new RuntimeException(e);
        } else {
            return null;


You need to register it in asset manager
assetManager.registerLocator(rootPath, RuntimeLocator.class);

then you can load your asset as usual with AssetManager.
Have not tried it for gltf/glb, hope it works.


Isn’t that precisely what com.jme3.asset.plugins.FileLocator is for?


Yes, swapping out a new file locator all the time is definitely possible. I was thinking of something that could be configured dynamically.

It’s possible that the asset manager implementations prevent such a thing… there are quite a few questionable design decisions in there.


While I don’t want to argue jme should cater to every designers needs, this clearly comes off as a bug to me. If the asset manager supports loading assets via streams, I would argue that loading assets via a stream should work.


Cool. I look forward to your redesign of the AssetManager that covers this.