sceneLoadedCallback scene parameter usage

I managed to make it work finally :smiley:

The error was that the serialization was being executed before the scene was actually ready to be serialized. The solution was to place it inside a executeWhenReady block

onSceneLoaded(sceneFile: File, babylonScene: BABYLON.Scene)
{
   /*WRONG*/
   const serializedScene = BABYLON.SceneSerializer.Serialize(babylonScene);
  
   /*CORRECT*/
   babylonScene.executeWhenReady(() =>
   {
      const serializedScene = BABYLON.SceneSerializer.Serialize(babylonScene);
      const jsonObj = JSON.stringify(serializedScene);
      // broadcast object via socket.io here
    });
    .
    .
    .
}

Thank you again for your help @aWeirdo and @Evgeni_Popov

2 Likes