The rotation of a mesh object [metaquest]

Hey guys, I have been using this code to drag and rotate an object. But of course, it only works on the computer, when I try it on the meta quest with raycaster it doesn’t work.

Is there any way to do the same thing but on metaquest?

let rotating = false;
let rightDir = new BABYLON.Vector3();
let upDir = new BABYLON.Vector3();
const sensitivity = 0.005;

  scene.onPointerObservable.add((pointerInfo) => {
    if (pointerInfo.type === BABYLON.PointerEventTypes.POINTERDOWN) {
      if (pointerInfo.pickInfo.pickedMesh === tetra) {
        rotating = true;
        scene.activeCamera.detachControl();
      }
    } else if (
      pointerInfo.type === BABYLON.PointerEventTypes.POINTERUP &&
      rotating
    ) {
      rotating = false;
      scene.activeCamera.attachControl();
    } else if (
      pointerInfo.type === BABYLON.PointerEventTypes.POINTERMOVE &&
      rotating
    ) {
      const matrix = scene.activeCamera.getWorldMatrix();
      rightDir.copyFromFloats(matrix.m[0], matrix.m[1], matrix.m[2]);
      upDir.copyFromFloats(matrix.m[4], matrix.m[5], matrix.m[6]);

      tetra.rotateAround(
        tetra.position,
        rightDir,
        pointerInfo.event.movementY * -1 * sensitivity
      );
      tetra.rotateAround(
        tetra.position,
        upDir,
        pointerInfo.event.movementX * -1 * sensitivity
      );
    }
  });

cc @RaananW

Using the camera’s matrix, detaching and so on, is usually wrong in XR. In XR you would want to duplicate the controller’s rotation. The simplest is just setting the object’s parent to be the controller on pointer down, and setting the parent back to null in pointer up (using the setParent function).

Want to share a working playground? I will be happy to look at the code?