# "update Gizmo Rotation To Match Attached Mesh" doesn't work

**URL:** <https://forum.babylonjs.com/t/update-gizmo-rotation-to-match-attached-mesh-doesnt-work/41875>\
**Category:** Bugs\
**Tags:** gizmo\
**Created:** [June 23, 2023, 2:35pm UTC](https://forum.babylonjs.com/t/update-gizmo-rotation-to-match-attached-mesh-doesnt-work/41875 "2023-06-23T14:35:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sr\_minhoon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sr_minhoon/32/21769_2.png) [@sr\_minhoon](https://forum.babylonjs.com/u/sr_minhoon)\
**Post date:** [June 23, 2023, 2:35pm UTC](https://forum.babylonjs.com/t/update-gizmo-rotation-to-match-attached-mesh-doesnt-work/41875/1 "2023-06-23T14:35:49Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#31M2AP%23414)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

After rotating the z-axis (blue) in the playground, rotating the y-axis (green) rotates the mesh around the local axis. Only the gizmo is fixed to the global axis.

However, in babylonjs version 5.9 or lower, if you apply “updateGizmoRotationToMatchAttachedMesh = false”, the mesh rotates based on the global axis.

Is this an update from version 6? Or is it a bug?

If updated, what option should I enable to rotate the mesh around a global axis?

// Below is babylonjs version 6 or higher.  
 ![화면 기록 2023-06-23 오후 11.50.47](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/c/fca51165e117ab67bd9d892949484039115171b2.gif)

// This is version 5.9.0 of babylonjs.  
 ![화면 기록 2023-06-23 오후 11.51.05](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/a/da5abd13eec57980f7c0482af5768082bdf147e9.gif)

// This is the source code created for version testing. (Version 5.9 and 6 used the same source code.)

```auto

import {
  ArcRotateCamera,
  Engine,
  HemisphericLight,
  MeshBuilder,
  PositionGizmo,
  RotationGizmo,
  Scene,
  UtilityLayerRenderer,
  Vector3,
} from "babylonjs";
import { useEffect, useRef } from "react";
import "./App.css";

function App() {
  const ref = useRef<HTMLCanvasElement>(null);

  useEffect(() => {
    const engine = new Engine(ref.current, true, {
      doNotHandleContextLost: true,
      stencil: true,
    });
    const scene = new Scene(engine);
    const camera = new ArcRotateCamera(
      "camera",
      0,
      0,
      50,
      Vector3.Zero(),
      scene
    );
    // const camera = new FreeCamera("camera1", new Vector3(0, 5, -10), scene);
    camera.attachControl(ref.current, true);

    const light = new HemisphericLight("light", new Vector3(0, 1, 1), scene);
    light.intensity = 0.7;

    scene.onReadyObservable.addOnce(() => {
      const box = MeshBuilder.CreateBox("test", { size: 10 }, scene);

      const gizmoRenderer = new UtilityLayerRenderer(scene);
      const gizmos = [];
      const transGizmo = new PositionGizmo(gizmoRenderer);
      transGizmo.scaleRatio = 1.5;
      const rotGizmo = new RotationGizmo(gizmoRenderer);
      // disable local axes, then use global axes
      rotGizmo.updateGizmoRotationToMatchAttachedMesh = false;

      rotGizmo.attachedMesh = box;

      gizmos.push(transGizmo);
      gizmos.push(rotGizmo);
      gizmos.forEach((gizmo) => {
        gizmo.attachedNode = box;
      });
    });

    engine.runRenderLoop(() => {
      scene.render();
    });

    return () => {
      scene.dispose();
      engine.dispose();
    };
  }, []);

  return (
    <>
      <canvas ref={ref} style={{ width: "100vw", height: "100vh" }} />
    </>
  );
}

export default App;

```

---

<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:** [June 23, 2023, 9:48pm UTC](https://forum.babylonjs.com/t/update-gizmo-rotation-to-match-attached-mesh-doesnt-work/41875/2 "2023-06-23T21:48:20Z")

</div>

Adding @Cedric our Gizmo Guru

---

<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:** [June 26, 2023, 9:42am UTC](https://forum.babylonjs.com/t/update-gizmo-rotation-to-match-attached-mesh-doesnt-work/41875/3 "2023-06-26T09:42:01Z")

</div>

This issue is fixed with [Gizmo+inspector world/local coordinates switch by CedricGuillemet · Pull Request #14001 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/14001)  
You can try the PG with this link :  
[https://playground.babylonjs.com/?snapshot=refs/pull/14001/merge#31M2AP#414](https://playground.babylonjs.com/?snapshot=refs/pull/14001/merge#31M2AP#414)

---

<div class="post-metadata">

**Author:** ![sr\_minhoon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sr_minhoon/32/21769_2.png) [@sr\_minhoon](https://forum.babylonjs.com/u/sr_minhoon)\
**Post date:** [June 27, 2023, 3:07am UTC](https://forum.babylonjs.com/t/update-gizmo-rotation-to-match-attached-mesh-doesnt-work/41875/4 "2023-06-27T03:07:31Z")

</div>

@Cedric Thank you so much, Cedric! When the next version is released, I will apply it to my project immediately!
