# Scale gizmo on my own

**URL:** <https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192>\
**Category:** Questions\
**Created:** [March 15, 2021, 2:37pm UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192 "2021-03-15T14:37:49Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Symlis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/symlis/32/7350_2.png) [@Symlis](https://forum.babylonjs.com/u/Symlis)\
**Post date:** [March 15, 2021, 2:37pm UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/1 "2021-03-15T14:37:50Z")

</div>

Hello everyone!

I came into this playground: [https://playground.babylonjs.com/#EBPQH9#51](https://playground.babylonjs.com/#EBPQH9#51)  
There’s an orthographic mode + scroll.

I added gizmo to it and it’s very big. Is there any way to scale the gizmo on my own? So when I scroll in this mode gizmo will be bigger/smaller depends on the scroll value.

---

<div class="post-metadata">

**Author:** ![Symlis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/symlis/32/7350_2.png) [@Symlis](https://forum.babylonjs.com/u/Symlis)\
**Post date:** [March 15, 2021, 3:54pm UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/2 "2021-03-15T15:54:54Z")

</div>

I kinda made it but I’m not sure if it’s the best approach

[https://playground.babylonjs.com/#EBPQH9#56](https://playground.babylonjs.com/#EBPQH9#56) (lines 16-22)

I’m wondering if it gonna works so smooth when I’ll have much more gizmos on my scene.

---

<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:** [March 15, 2021, 4:51pm UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/3 "2021-03-15T16:51:40Z")

</div>

You can use `gizmo.scaleRatio` (default is one). Set a lower value like 0.1 and see it it fits your needs.

[Orthographic zoom demo | Babylon.js Playground](https://playground.babylonjs.com/#EBPQH9#57)

---

<div class="post-metadata">

**Author:** ![Symlis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/symlis/32/7350_2.png) [@Symlis](https://forum.babylonjs.com/u/Symlis)\
**Post date:** [March 16, 2021, 8:55am UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/4 "2021-03-16T08:55:41Z")

</div>

Thanks, `gizmo.scaleRatio` looks much better than `gizmo.xGizmo._rootMesh.getChildren()[0].scaling.set(gizmoScaling, gizmoScaling, gizmoScaling)`.

Please correct me if I’m wrong but I think `scaleRatio` doesn’t work on gizmoManager [https://playground.babylonjs.com/#4TBMBR#62](https://playground.babylonjs.com/#4TBMBR#62) ← this playground doesn’t work after adding scale ratio for eq. position gizmo

---

<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:** [March 16, 2021, 9:03am UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/5 "2021-03-16T09:03:06Z")

</div>

Let me take a look.

---

<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:** [March 16, 2021, 12:54pm UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/6 "2021-03-16T12:54:10Z")

</div>

PR for scaleRatio : [Exposed `scaleRatio` for GizmoManager by CedricGuillemet · Pull Request #10060 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/10060)

Gizmomanager creation had a breaking change since 4.2  
Now create one this way:

```auto
var gizmoManager = new BABYLON.GizmoManager(scene, 1, new BABYLON.UtilityLayerRenderer(scene), new BABYLON.UtilityLayerRenderer(scene));

```

---

<div class="post-metadata">

**Author:** ![Symlis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/symlis/32/7350_2.png) [@Symlis](https://forum.babylonjs.com/u/Symlis)\
**Post date:** [March 17, 2021, 2:28pm UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/7 "2021-03-17T14:28:08Z")

</div>

Thanks, that’s very helpful. I switched to version 4.2.0-beta.16 so I’ve got those extra arguments in GizmoManager in my app. I’m wondering if there’s a method/property so I could get all GizmoManagers from the scene and filter ones I need to use. Or does GizmoManager have id or something that I could get it from the scene?

---

<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:** [March 17, 2021, 2:31pm UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/8 "2021-03-17T14:31:06Z")

</div>

Do you really need multiple gizmo manager? If so, you can keep a list of managers when you create a new one.

---

<div class="post-metadata">

**Author:** ![Symlis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/symlis/32/7350_2.png) [@Symlis](https://forum.babylonjs.com/u/Symlis)\
**Post date:** [March 17, 2021, 2:45pm UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/9 "2021-03-17T14:45:30Z")

</div>

@Cedric Ye, I think that’s easier for me to manage multiple meshes and components made out of them.

I was thinking about extending GizmoManager class and add to it uniqe id. But still I wont have list of gizmoManagers in my scene. So I’ll have to extend scene class by gizmoManager list.

---

<div class="post-metadata">

**Author:** ![Symlis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/symlis/32/7350_2.png) [@Symlis](https://forum.babylonjs.com/u/Symlis)\
**Post date:** [March 31, 2021, 1:35pm UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/10 "2021-03-31T13:35:49Z")

</div>

@Cedric, actually I’ve got a question about gizmoManagers. I think the main reason why I’m creating many gizmoManagers it’s because I want different dragBehaviors on specific meshes.

Can we, in babylon, somehow distinguish different dragBehavior on the same gizmo (for the same gizmo, eq. yPlane)?

I made this playground for an example [https://playground.babylonjs.com/#4YM59Z#1](https://playground.babylonjs.com/#4YM59Z#1)  
it’s no matter to which sphere gizmo is attached, it will always console.log(“sphere 1 drag behavior”). I know I could make global variable and change it in the `gizmoManager.onAttachedToMeshObservable` and then add some `if's` or `switch` in the `onDragObservable` but I guess that’s not the point. Or is it? 😃  
I think it would be great if there was info about mesh the that’s being dragged, in the callback function

---

<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:** [March 31, 2021, 2:05pm UTC](https://forum.babylonjs.com/t/scale-gizmo-on-my-own/19192/11 "2021-03-31T14:05:42Z")

</div>

You can try to attach your logic to `onAttachedToMeshObservableSearch`

> **[GizmoManager | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/babylon.gizmomanager#onattachedtomeshobservable)**
>
> Helps setup gizmo's in the scene to rotate/scale/position nodes \[API\]

Depending on the mesh, you switch the gizmo properties.
