# Problem with boundingBoxGizmo fixedDragMeshScreenSize when using a nested camera

**URL:** <https://forum.babylonjs.com/t/problem-with-boundingboxgizmo-fixeddragmeshscreensize-when-using-a-nested-camera/46992>\
**Category:** Questions\
**Created:** [January 5, 2024, 7:23pm UTC](https://forum.babylonjs.com/t/problem-with-boundingboxgizmo-fixeddragmeshscreensize-when-using-a-nested-camera/46992 "2024-01-05T19:23:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [January 5, 2024, 7:23pm UTC](https://forum.babylonjs.com/t/problem-with-boundingboxgizmo-fixeddragmeshscreensize-when-using-a-nested-camera/46992/1 "2024-01-05T19:23:30Z")

</div>

So in Frame we have a third person camera that is the child of our first person camera. The first person camera is responsible for moving around the scene while the third person acts as an orbit camera that like mentioned prior is a child of the fpc.

We have a situation where the scale boxes are doing very unpredictable scaling when a user has an object being dragged and moved with the player.

After doing some digging I noticed in the method for setting their size the gizmoLayer uses the activeCamera.position which in our setup would always be a localized position instead of the global position. Would there be a way to work around this? Im thinking just changing the code here:

> <https://github.com/BabylonJS/Babylon.js/blob/3dda3fd63bb8d99e5d2b3ed31be1954cdb98f86c/packages/dev/core/src/Gizmos/boundingBoxGizmo.ts#L852>

to say

```auto
scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition, this._tmpVector);

```

would fix the problem or am I mistaken in thinking that?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [January 5, 2024, 11:52pm UTC](https://forum.babylonjs.com/t/problem-with-boundingboxgizmo-fixeddragmeshscreensize-when-using-a-nested-camera/46992/2 "2024-01-05T23:52:07Z")

</div>

I guess this makes sense !!! Can you “monkeypatch” in Frame and validates that it works there before creating a PR ?

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [January 6, 2024, 6:28am UTC](https://forum.babylonjs.com/t/problem-with-boundingboxgizmo-fixeddragmeshscreensize-when-using-a-nested-camera/46992/3 "2024-01-06T06:28:51Z")

</div>

“monkeypatch” 😏 I see what you did there.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [January 8, 2024, 7:02pm UTC](https://forum.babylonjs.com/t/problem-with-boundingboxgizmo-fixeddragmeshscreensize-when-using-a-nested-camera/46992/4 "2024-01-08T19:02:31Z")

</div>

It does look like that fixed the problem when I polyfilled over the method with the fix.

Ill submit a PR here.

> <https://github.com/BabylonJS/Babylon.js/pull/14687>
>
> There was a bug where if the active utility layers camera was a child of an obje…ct the calculations would use the local position instead of the desired global position.

@sebavan

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [January 8, 2024, 7:23pm UTC](https://forum.babylonjs.com/t/problem-with-boundingboxgizmo-fixeddragmeshscreensize-when-using-a-nested-camera/46992/5 "2024-01-08T19:23:18Z")

</div>

ahah did not even noticed primate monkey patching… this goes way too deep for me 🙂
