The current version of VGal, the small project Im developing (see it here) uses LoadAssetContainer to get an initial glb file. The scene is updated by calling addalltoscene. As the action of the user takes you to a different virtual place a new asset-container is loaded and the former one is kept in memory. Calling addalltoscene/removeallfromscene I update the scene.
Im trying to have an alternative approach (to reduce the download size) in which all the images/materials are downloaded separately and the scene is rendered on the fly from scratch. The initial idea was to save the items in a container using moveAllFromScene and then add the new elements, but that does not seem to work. The items are not removed from the scene and the new ones are not visible.
Is this approach conceptually correct, or otherwise what should be the right way to do it? Shall I have to dispose the scene and recreate it?
just wanted some reassurance that Im not missing something basic (like the scene needs to be disposed and recreated …). I’ll keep on testing and if does not work put some live code on a server for demo.
You were right,. The issue was (as almost always) in my code. I have found, however a small problem loading and removing assets from an the asset container array. The sequence is something like:
setup another scene elements
the problem is that the movealltoscene call triggers that the assetcontainer internal variable _wasAddedToScene is set to true. The removefromscene does not cause to be back to false, and that seems to prevent that subsequent calls to movealltoscene have any effect.
I can fix it by resetting that internal variable, and then it works, but it seems something is not right in my code or in babylon. Any ideas?
Thanks @sebavan, now I fully understand what you meant. Yes, using removeallfrom scene sets the internal variable properly. I will change it. My final question would be whether this different behaviour is evident? I would have not guessed it.