Handy as a 3D mouse controller

I am trying to use my cell phone as a 3D mouse. I have found a test program that displays the accelerationIncludingGravity values when I move my cell phone.

I have set the event as external variable e. But my box remains unchanged. Can someone give me a hint where the bug might be?

Here is my code:

CodingCrusader/tickets/backlog/deviceorientationHandy2.html at main · CodingWizzard/CodingCrusader

fixed.

setInterval(() => {
    if (e !== null) {
        box.rotation.x = BABYLON.Tools.ToRadians(e.accelerationIncludingGravity.x * 10); // Skaliert die Werte
        box.rotation.y = BABYLON.Tools.ToRadians(e.accelerationIncludingGravity.y * 10);
        box.rotation.z = BABYLON.Tools.ToRadians(e.accelerationIncludingGravity.z * 10);
    }
}, 200);
2 Likes