I’m using the below code to load a model. It saves successfully and I dont see anything in the BinaryExporter.save() that indicates its running async or in a background thread. And I dont see any listeners so when it completes it should be there to load. I have also tried using Thread.sleep() in between saving and loading without success. Exception in thread "Thread-2" com.jme3.asset.AssetNotFoundException: conversions/SK_Mummy.j3o. I’m sure I’m missing something simple but I cant seem to find it yet.
fun loadModel(path: String) {
Thread {
val model: Spatial = assetManager.loadModel(path)
var j3o: Spatial? = null
val filename = path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf("."))
val j3oPath = "conversions/$filename.j3o"
val conversion = File((j3oPath))
val be = BinaryExporter()
try {
be.save(model, conversion)// successfully completes successfully
j3o = assetManager.loadModel(j3oPath)// AssetNotFoundException
} catch (e: IOException) {
e.printStackTrace()
}
listener.onModelReady(j3o!!)
}.start()
}
I think the assetmanager and binary exporter have different roots (the asset manager being for loading from resources after all). Have you looked in the file system to see if the j3o is there?
(I assume this is just a minimal example to demonstrate the issue? There isn’t really a good reason to save then immediately reload an asset)
I read that assets should be converted to j3o to improve performance. If its only because it loads faster then I probably dont need to convert it. Things may have improved now.
Yeah, it improves load performance. It doesnt affect performance beyond that. If you want to ship another model format nothing terrible will happen, your users will just have a load screen for a little longer (or little hiccups as models are loaded during runtime if you aren’t loading async)