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
);
}
});