# SixDOfDragBehavior creates virtual scene which updates \_LastCreatedScene

**URL:** <https://forum.babylonjs.com/t/sixdofdragbehavior-creates-virtual-scene-which-updates-lastcreatedscene/15548>\
**Category:** Bugs\
**Tags:** gizmo\
**Created:** [November 9, 2020, 11:01pm UTC](https://forum.babylonjs.com/t/sixdofdragbehavior-creates-virtual-scene-which-updates-lastcreatedscene/15548 "2020-11-09T23:01:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![davegould41](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/davegould41/32/13785_2.png) [@davegould41](https://forum.babylonjs.com/u/davegould41)\
**Post date:** [November 9, 2020, 11:01pm UTC](https://forum.babylonjs.com/t/sixdofdragbehavior-creates-virtual-scene-which-updates-lastcreatedscene/15548/1 "2020-11-09T23:01:54Z")

</div>

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](https://github.com/BabylonJS/Babylon.js/blob/5638bba4b294a8141fe1065506ae2afdec0ba02c/src/Behaviors/Meshes/sixDofDragBehavior.ts#L97))… 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

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [November 10, 2020, 12:15am UTC](https://forum.babylonjs.com/t/sixdofdragbehavior-creates-virtual-scene-which-updates-lastcreatedscene/15548/2 "2020-11-10T00:15:19Z")

</div>

pinging @Cedric

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [November 10, 2020, 2:48pm UTC](https://forum.babylonjs.com/t/sixdofdragbehavior-creates-virtual-scene-which-updates-lastcreatedscene/15548/3 "2020-11-10T14:48:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![davegould41](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/davegould41/32/13785_2.png) [@davegould41](https://forum.babylonjs.com/u/davegould41)\
**Post date:** [November 10, 2020, 4:48pm UTC](https://forum.babylonjs.com/t/sixdofdragbehavior-creates-virtual-scene-which-updates-lastcreatedscene/15548/4 "2020-11-10T16:48:55Z")

</div>

Wow you guys are awesome!! @Cedric @Deltakosh

Will this be in 4.2?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [November 10, 2020, 4:56pm UTC](https://forum.babylonjs.com/t/sixdofdragbehavior-creates-virtual-scene-which-updates-lastcreatedscene/15548/5 "2020-11-10T16:56:06Z")

</div>

yes!
