Hello, I had a long forced break to continue with my engine , but I’m back now 100% with it
With the purpose of cache meshes in memory, and clone them to be used in N scenes which can be loaded and unloaded at any time, my question:
How can I clone a mesh with no scene associated to any other scene?
I load the mesh (an all its assets) using BABYLON.SceneLoader.ImportMeshAsync(path, file) with no scene associated. The file is a .babylon file, which could use assets within its same path (textures, etc). I think when I don’t define the scene in ImportMeshAsync, babylon associate the loaded mesh to the last scene, and that would be a problem since I don’t want to associate this mesh to any scene.
Then I want to clone that mesh into any scene or scenes.
Any amount of meshes can be cloned to N scenes.
I don’t see the Mesh.clone method to associate the cloned mesh to any scene.
How could I associate a cloned mesh to a scene?
Is there a better way to cache a mesh and all its assets in memory to be cloned to any amount of scenes?
For now, the better way I’m thinking out is to zip or save somehow the mesh folder content into memory, and use ImportMeshAsync with that folder stored in memory, assigning to it a scene. But I don’t like it beucase in that way I force the user to use a separated folder for each mesh + assets, which could drive to problems.
Is there a way to identify the assets files belonging to a mesh? Then I can store each one of them in memory independently.
I’m loading the mesh from a .babylon file (I export the mesh from Blender), so I load the scene using LoadAsync, then I grab the mesh and I serialize it, but when I use ImportMeshAsync to unserialize, I get an error that the texture cannot be loaded because it doesn’t exists in the root path.
Is there any solution for this?
How can I serialize a mesh and all its assets loaded from a .babylon file with LoadAsync?
Test importing the scene from .babylon file and not serializing the mesh:
Test importing the scene from .babylon file and serializing the mesh: Since I have to import the mesh to different scenes, I cannot use sceneLoaded for any other purpose than loading the mesh and storing it in memory.
As the texture has already been loaded by the first call to SceneLoader, it will not be loaded again. The correct root url is required so that the full url can be searched for an existing texture in the cache, and because it will be found, the texture will not be reloaded but reused.
You can see it in this PG:
Look at the console log:
The first number is the texture identifier, while the second is the internal texture identifier. The texture identifier is different in each scene because a new Texture is created, but the internal texture identifier is the same, meaning that the GPU texture (InternalTexture) is reused in both cases.
Am I doing right caching all the rest of assets with the same purpose to use them in afterewards scenes?
.babylon files to append meshes or scene blocks.
.pngs or .jpgs used to create textures for sprites using BABYLON.Texture.
fonts
audios
Is it possible to disable that babylon cache so I have the full control over it?
Or maybe I can forget of this feature if babylon handles the cache of totality of assets, and I can implement an automatic cache system in the future using disableOfflineSupportExceptionRules, which I’m not sure that can cover my neccesities.
The aim is to let the users to allow or disallow cache for each asset, that’s why I’m doing this.