Function watchDeviceOrientation

  • Enable monitor of the device orientation to detect the current orientation of the device as compared to the Earth coordinate frame. (one some device a first user gesture will be required before calling this function)

    Returns boolean

    false if not supported or permission not granted by the user

    device

    • device.alpha
    • device.beta
    • device.gamma
    // try to enable device orientation event on user gesture
    me.input.registerPointerEvent("pointerleave", me.game.viewport, function() {
    if (me.device.watchDeviceOrientation() === true) {
    // Success
    me.input.releasePointerEvent("pointerleave", me.game.viewport);
    } else {
    // ... fail at enabling the device orientation event
    }
    });