SixDOfDragBehavior creates virtual scene which updates _LastCreatedScene

Hi All,

I was debugging an issue in my application and noticed something strange.

Even though the last scene I created was my main applicationScene, because Babylon’s GizmoManager creates a new _VirtualScene for BoundingBox, the EngineStore.LastCreatedScene() will change (as shown here)… which causes issues downstream.

Several constructors in Babylon offer scene as an optional param

  • BABYLON.Inspector.Show(scene?) // Scene is optional
  • new BABYLON.Mesh(scene?) // Scene is optional for everything that extends Node

If the optional param is empty they will default to EngineStore.LastCreatedScene
this._scene = <Scene>(scene || EngineStore.LastCreatedScene);

If we can guarantee LastCreatedScene points to the last scene the user created (not a scene created by Babylon), this defaulting logic should be true for most scenarios

pinging @Cedric

1 Like

Something like this then : don't add sixDofDrag scene to the last created ones by CedricGuillemet · Pull Request #9381 · BabylonJS/Babylon.js · GitHub
when virtual, the scene constructor doesn’t set it as the last created one.

1 Like

Wow you guys are awesome!! @Cedric @Deltakosh

Will this be in 4.2?


1 Like