I am using Append from Babylon’s scene loader in my project to import my meshes. I have noticed that I only have control over my meshes inside the append function. Is there a way to have a reference to the meshes outside the append function?
Yes I am aware of what you said, but these only give you control of the meshes inside the append function. Is there a way to access these meshes outside the append function?
You can use these functions anywhere you want, as long as the meshes are imported in your scene before you try to use them - which depends on your game logic.
By “inside the append function”, I assume you mean the asynchronous callback that is declared:
BABYLON.SceneLoader.Append("", "https://dl.dropbox.com/s/b7bjy69g307d64h/Thonker.glb", scene, function (scene) {
//Here?
});
It might make more sense if you switch to the AppendAsync method, which returns a Promise that can be awaited:
await BABYLON.SceneLoader.AppendAsync("", "https://dl.dropbox.com/s/b7bjy69g307d64h/Thonker.glb", scene);
for(const mesh of scene.meshes) {
//do something with your meshes "outside" of the AppendAsync function
}