Hi all!
I have two scenes. I need to move the little man from scene2
to scene1
(as in the screenshot). How to do it?
Hi all!
I have two scenes. I need to move the little man from scene2
to scene1
(as in the screenshot). How to do it?
I think “you can’t” or at least is not trivial.
Kindly check Multi scene sharing object (meshes, materials) and Multi scene sharing object (meshes, materials) - #2 by Deltakosh for more info.
I was struggling to do the same and find that just reloading the mesh is fast enough. I cache them when it makes sense and dispose them when not needed. I also suggest looking into Copies, Clones, and Instancing | Babylon.js Documentation for ways to optimize handling meshes.
You could also check AssetContainers to ease the process Asset Containers | Babylon.js Documentation (babylonjs.com)
The serialization method works well.
Here is a demo for those who will come to this topic in the future.
The question remains: how to do this using AssetContainer?
AssetContainer is always tied to one scene
, and, as far as I understand, you cannot take a mesh from AssetContainer and just add it to another scene
Hey @Deltakosh. What can you say about AssetContainer?
You are right this is linked to a scene. The scene keeps track of everything memory and resources wise
One option for you would be to serialize the mesh and then deserialize it in the new scene
AssetsContainers are meant to isolate meshes inside a scene as we do not recommend to have multiple scenes if they share resources
So the only way to transfer a mesh from one scene
to another scene
is through serialization?
Can you elaborate on why you suggested using AssetContainer in this post? What was the idea?
I think @carolhmj may have misunderstood your ask
You should not do that, because after a mesh is disposed you should not continue using it. In fact, whatever the type of object, if it has been disposed, you should stop using it as its state is no longer valid.
Yes, sorry, I did misunderstand it
Okay. Thanks everyone for the answers! Then for now I will assume that the only correct option is serialization