Is there a way to auto-load external assets with SceneLoader? I want to add a “player” mesh reference in the Editor, and have the player asset container imported automatically - without baking it into the babylon file.
The Loading Assets From Memory page describes something similar, but involves manual steps to convert assets into blobs; what I’m looking for is a mechanism to invoke the AssetsManager to load external assets on the fly.
There’s also the Incremental Loading System, which seems to do what I want, but that requires converting scenes into another format.
Sorry for the lack of clarity. I am calling SceneLoader.LoadAsync, and would like it to automatically call ImportMeshAsync when it finds a reference to an external mesh.
The more I think about this, the more it sounds like a feature request, rather than something that already exists… But I was hoping to be able to write some something like this:
What stops you from doing what you are describing? We don’t know when you need the mesh (other than when the mesh is in frustum but hasn’t been downloaded yet).
You can share between scenes using the assets container, and I actually assume you are referring to something very similar to the asset container - Asset Containers | Babylon.js Documentation
What stops me is that I need to modify the code of the MeshLoader, which I’m not familiar with. Maybe I can add a callback, like onLoadMesh, which would be called for every “mesh” block, and expect a Mesh return value. Then the MeshLoader caller can customize the loading process.
By sharing assets, I mean at design time. I’d like to basically drag or import a mesh into the scene, without embedding it in the scene json. The assets change all the time - I don’t wan’t to have to update every “level” whenever a mesh changes.
This will require some custom implementation on your side, loading the assets you need using code (and not only using the loader, as you expect). The .babylon file was not planned with that feature in mind.
Sorry
We will be happy to consider that as a feature for future versions, and I will be very happy if you submit an issue for it on github, but TBH I don’t see it happening in the near future, so I wouldn’t count on it being developed in the next major version (i.e. 6.X). And we are always happy to accept PRs with new features that we discussed here