From 008f370d38e95bf07168f7d4087482c85366b393 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 13 Nov 2023 17:59:39 +0000 Subject: [PATCH] Merge pull request #120 from w3c/editorial/section-division-more-dfns SHA: c0bb08af98e24a1cd01302be65311223aa1e3b4b Reason: push, by rakuco Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- index.html | 759 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 530 insertions(+), 229 deletions(-) diff --git a/index.html b/index.html index f020678..042f954 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ - + +

DeviceOrientation Event Specification

-

Editor’s Draft,

+

Editor’s Draft,

More details about this document
@@ -938,11 +959,17 @@

Table of Contents

  • 4.2 Device Motion
  • - 5 Description + 5 API
    1. 5.1 deviceorientation Event
    2. 5.2 deviceorientationabsolute Event -
    3. 5.3 devicemotion Event +
    4. + 5.3 devicemotion Event +
        +
      1. 5.3.1 The DeviceMotionEventAcceleration interface +
      2. 5.3.2 The DeviceMotionEventRotationRate interface +
      3. 5.3.3 The DeviceMotionEvent interface +
    5. 5.4 Permission model
  • 6 Security and privacy considerations @@ -1104,27 +1131,27 @@

    Note: In native platform terms, this is similar to an absolute OrientationSensor on Windows, a rotation vector sensor on Android, or the xMagneticNorthZVertical option for Core Motion.

    4.2. Device Motion

    This specification expresses a device’s motion in space by measuring its acceleration and rotation rate, which are obtained from an accelerometer and a gyroscope. The data is provided relative to the device coordinate system summarized in the previous section.

    -

    Acceleration is the rate of change of velocity of a device with respect to time. Is is expressed in meters per second squared (m/s2). When the acceleration includes gravity, its value includes the effect of gravity and represents proper acceleration ([PROPERACCELERATION]). When the device is in free-fall, the acceleration is 0 m/s2.

    -

    Linear acceleration, on the other hand, represents the device’s acceleration rate without the contribution of the gravity force. When the device is laying flat on a table, its linear acceleration is 0 m/s2.

    -

    Note: In practice, acceleration with gravity represents the raw readings obtained from an Motion Sensors Explainer § accelerometer, or the [G-FORCE] whereas linear acceleration provides the readings of a Motion Sensors Explainer § linear-acceleration-sensor and is likely a fusion sensor. [MOTION-SENSORS] and [ACCELEROMETER] both contain a more detailed discussion about the different types of accelerometers and accelerations that can be measured.

    +

    Acceleration is the rate of change of velocity of a device with respect to time. Is is expressed in meters per second squared (m/s2).

    +

    Linear acceleration represents the device’s acceleration rate without the contribution of the gravity force. When the device is laying flat on a table, its linear acceleration is 0 m/s2.

    +

    When the acceleration includes gravity, its value includes the effect of gravity and represents proper acceleration ([PROPERACCELERATION]). When the device is in free-fall, the acceleration is 0 m/s2. This is less useful in many applications but is provided as a means of providing best-effort support by implementations that are unable to provide linear acceleration (due, for example, to the lack of a gyroscope).

    +

    Note: In practice, acceleration with gravity represents the raw readings obtained from an Motion Sensors Explainer § accelerometer, or the [G-FORCE] whereas linear acceleration provides the readings of a Motion Sensors Explainer § linear-acceleration-sensor and is likely a fusion sensor. [MOTION-SENSORS] and [ACCELEROMETER] both contain a more detailed discussion about the different types of accelerometers and accelerations that can be measured.

    The rotation rate measures the rate at which the device rotates about a specified axis in the device coordinate system. As with device orientation, rotations must use the right-hand convention, such that positive rotation around an axis is clockwise when viewed along the positive direction of the axis. The rotation rate is measured in degrees per second (deg/s).

    Note: [MOTION-SENSORS] and [GYROSCOPE] both contain a more detailed discussion of gyroscopes, rotation rates and measurements.

    -

    5. Description

    +

    5. API

    5.1. deviceorientation Event

    -

    The ondeviceorientation attribute is an event handler IDL attribute for the ondeviceorientation event handler, whose event handler event type is deviceorientation.

    partial interface Window {
    -    [SecureContext] attribute EventHandler ondeviceorientation;
    +    [SecureContext] attribute EventHandler ondeviceorientation;
     };
     
     [Exposed=Window, SecureContext]
     interface DeviceOrientationEvent : Event {
         constructor(DOMString type, optional DeviceOrientationEventInit eventInitDict = {});
    -    readonly attribute double? alpha;
    -    readonly attribute double? beta;
    -    readonly attribute double? gamma;
    -    readonly attribute boolean absolute;
    +    readonly attribute double? alpha;
    +    readonly attribute double? beta;
    +    readonly attribute double? gamma;
    +    readonly attribute boolean absolute;
     
    -    static Promise<PermissionState> requestPermission();
    +    static Promise<PermissionState> requestPermission();
     };
     
     dictionary DeviceOrientationEventInit : EventInit {
    @@ -1134,82 +1161,168 @@ 

    boolean absolute = false; };

    -

    The alpha attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null.

    -

    The beta attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null.

    -

    The gamma attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null.

    -

    The absolute attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to false.

    -

    The static requestPermission() operation, when invoked, must run these steps:

    -
      -
    1. -

      Let promise be a new promise.

      -
    2. -

      Run these steps in parallel:

      -
        -
      1. -

        Let permission be permission for relevant settings object’s origin.

        -
      2. -

        If permission is "default" and the relevant global object does not have transient activation, then reject promise with a NotAllowedError DOMException and abort these steps.

        -
      3. -

        If permission is "default", ask the user whether sharing device orientation +

        The ondeviceorientation attribute is an event handler IDL attribute for the ondeviceorientation event handler, whose event handler event type is deviceorientation.

        +

        The alpha attribute must return the value it was initialized to. It represents the rotation around the Z axis in the Z - X' - Y'' intrinsic Tait-Bryan angles described in § 4.1 Device Orientation.

        +

        The beta attribute must return the value it was initialized to. It represents the rotation around the X' axis (produced after the rotation around the Z axis has been applied) axis in the Z - X' - Y'' intrinsic Tait-Bryan angles described in § 4.1 Device Orientation.

        +

        The gamma attribute must return the value it was initialized to. It represents the rotation around the Y'' axis (produced after the rotation around the Z and X' axes have been applied in this order) in the Z - X' - Y'' intrinsic Tait-Bryan angles described in § 4.1 Device Orientation.

        +

        The absolute attribute must return the value it was initialized to. It indicates whether relative orientation or absolute orientation data is being provided.

        +
        + The requestPermission() method steps are: +
          +
        1. +

          Let promise be a new promise.

          +
        2. +

          Run these steps in parallel:

          +
            +
          1. +

            Let permission be permission for relevant settings object’s origin.

            +
          2. +

            If permission is "default" and the relevant global object does not have transient activation, then reject promise with a NotAllowedError DOMException and abort these steps.

            +
          3. +

            If permission is "default", ask the user whether sharing device orientation for the relevant settings object’s origin is acceptable. If it is, set permission to "granted", and "denied" otherwise.

            -
          4. -

            Queue a task to run these steps:

            -
              -
            1. -

              Set permission for the relevant settings object’s origin to permission.

              -
            2. -

              Fulfill promise with permission.

              -
            -
          -
        3. -

          Return promise.

          -
        -

        Whenever a significant change in orientation occurs, the User Agent must fire an event named deviceorientation using DeviceOrientationEvent on the window object. The definition of a significant change in this context is left to the implementation, though a maximum threshold for change of one degree is recommended. Implementations may also fire the event if they have reason to believe that the page does not have sufficiently fresh data.

        -

        The alpha, beta and gamma attributes of the event must specify the relative orientation of the device in terms of the transformation from an implementation-defined reference coordinate frame.

        -

        The alpha, beta and gamma attributes must be expressed in degrees and must not be more precise than 0.1 degrees.

        -

        If relative orientation data cannot be obtained or the resulting data is more accurate, the implementation can choose to provide absolute orientation data instead. In either case, the absolute property must be set accordingly to reflect the choice.

        -

        Implementations that are unable to provide all three angles must set the values of the unknown angles to null. If any angles are provided, the absolute property must be set appropriately. If an implementation can never provide orientation information, the event should be fired with the alpha, beta and gamma attributes set to null.

        +
      4. +

        Queue a task to run these steps:

        +
          +
        1. +

          Set permission for the relevant settings object’s origin to permission.

          +
        2. +

          Fulfill promise with permission.

          +
        +
      +
    3. +

      Return promise.

      +
    +
  • +
    + To fire an orientation event given a event name (a string), window (a Window) and absolute (a boolean): +
      +
    1. +

      If absolute is false:

      +
        +
      1. +

        Let orientation be the device’s relative orientation in the tridimensional plane.

        +
      +
    2. +

      Otherwise:

      +
        +
      1. +

        Let orientation be the device’s absolute orientation in the tridimensional plane.

        +
      +
    3. +

      Let z rotation be orientation’s representation as intrinsic Tait-Bryan angles Z - X' - Y'' along the Z axis, or null if the implementation cannot provide an angle value.

      +
    4. +

      If z rotation is not null, limit z rotation’s precision to 0.1 degrees.

      +
    5. +

      Let x rotation be orientation’s representation as intrinsic Tait-Bryan angles Z - X' - Y'' along the X' axis, or null if the implementation cannot provide an angle value.

      +
    6. +

      If x rotation is not null, limit x rotation’s precision to 0.1 degrees.

      +
    7. +

      Let y rotation be orientation’s representation as intrinsic Tait-Bryan angles Z - X' - Y'' along the Y'' axis, or null if the implementation cannot provide an angle value.

      +
    8. +

      If y rotation is not null, limit y rotation’s precision to 0.1 degrees.

      +
    9. +

      Fire an event named event name at window, using DeviceOrientationEvent, with the alpha attribute initialized to z rotation, the beta attribute initialized to x rotation, the gamma attribute initialized to y rotation, and the absolute attribute initialized to absolute.

      +
    +
    +

    A significant change in orientation indicates a difference in orientation values compared to the previous ones that warrants the firing of a deviceorientation or deviceorientationabsolute event. The process of determining whether a significant change in orientation has occurred is implementation-defined, though a maximum threshold for change of 1 degree is recommended. Implementations may also consider that it has occurred if they have reason to believe that the page does not have sufficiently fresh data.

    +
    + Whenever a significant change in orientation occurs, the user agent must execute the following steps on a navigable’s active window window: +
      +
    1. +

      If the implementation cannot provide relative orientation or the resulting absolute orientation data is more accurate:

      +
        +
      1. +

        Let absolute be true.

        +
      +
    2. +

      Otherwise:

      +
        +
      1. +

        Let absolute be false.

        +
      +
    3. +

      Invoke fire an orientation event with deviceorientation, window, and absolute.

      +
    +
    +

    If an implementation can never provide orientation information, the event should be fired with the alpha, beta and gamma attributes set to null.

    5.2. deviceorientationabsolute Event

    - -

    User agents implementing this specification must fire an event named deviceorientationabsolute using DeviceOrientationEvent on the window object whenever a significant change in orientation occurs.

    -

    The ondeviceorientationabsolute attribute is an event handler IDL attribute for the ondeviceorientationabsolute event handler, whose event handler event type is deviceorientationabsolute.

    -
    partial interface Window {
    -    [SecureContext] attribute EventHandler ondeviceorientationabsolute;
    +   
    +
    partial interface Window {
    +    [SecureContext] attribute EventHandler ondeviceorientationabsolute;
     };
     
    -

    A "deviceorientationabsolute" event is completely analogous to the deviceorientation event, except that it must always provide absolute orientation data.

    -

    The absolute property must be set to true.

    -

    If an implementation can never provide absolute orientation information, the event should be fired with the alpha, beta and gamma attributes set to null.

    +

    The ondeviceorientationabsolute attribute is an event handler IDL attribute for the ondeviceorientationabsolute event handler, whose event handler event type is deviceorientationabsolute.

    +

    A deviceorientationabsolute event is completely analogous to the deviceorientation event, except that it must always provide absolute orientation data.

    +
    + Whenever a significant change in orientation occurs, the user agent must execute the following steps on a navigable’s active window window: +
      +
    1. +

      Invoke fire an orientation event with deviceorientationabsolute, window, and true.

      +
    +
    +

    If an implementation can never provide absolute orientation information, the event should be fired with the alpha, beta and gamma attributes set to null.

    5.3. devicemotion Event

    -

    User agents implementing this specification must fire an event named devicemotion using DeviceMotionEvent on the window object.

    -

    The ondevicemotion attribute is an event handler IDL attribute for the ondevicemotion event handler, whose event handler event type is devicemotion.

    -
    partial interface Window {
    -    [SecureContext] attribute EventHandler ondevicemotion;
    -};
    -
    -[Exposed=Window, SecureContext]
    +   

    5.3.1. The DeviceMotionEventAcceleration interface

    +
    [Exposed=Window, SecureContext]
     interface DeviceMotionEventAcceleration {
    -    readonly attribute double? x;
    -    readonly attribute double? y;
    -    readonly attribute double? z;
    +    readonly attribute double? x;
    +    readonly attribute double? y;
    +    readonly attribute double? z;
     };
    -
    -[Exposed=Window, SecureContext]
    +
    +

    The DeviceMotionEventAcceleration interface represents the device’s acceleration as described in § 4.2 Device Motion. It has the following associated data:

    +
    +
    x axis acceleration +
    +

    The device’s acceleration rate along the X axis, or null. It is initially null.

    +
    y axis acceleration +
    +

    The device’s acceleration rate along the Y axis, or null. It is initially null.

    +
    z axis acceleration +
    +

    The device’s acceleration rate along the Z axis, or null. It is initially null.

    +
    +

    The x getter steps are to return the value of this’s x axis acceleration.

    +

    The y getter steps are to return the value of this’s y axis acceleration.

    +

    The z getter steps are to return the value of this’s z axis acceleration.

    +

    5.3.2. The DeviceMotionEventRotationRate interface

    +
    [Exposed=Window, SecureContext]
     interface DeviceMotionEventRotationRate {
    -    readonly attribute double? alpha;
    -    readonly attribute double? beta;
    -    readonly attribute double? gamma;
    +    readonly attribute double? alpha;
    +    readonly attribute double? beta;
    +    readonly attribute double? gamma;
    +};
    +
    +

    The DeviceMotionEventRotationRate interface represents the device’s rotation rate as described in § 4.2 Device Motion. It has the following associated data:

    +
    +
    x axis rotation rate +
    +

    The device’s rotation rate about the X axis, or null. It is initially null.

    +
    y axis rotation rate +
    +

    The device’s rotation rate about the Y axis, or null. It is initially null.

    +
    z axis rotation rate +
    +

    The device’s rotation rate about the Z axis, or null. It is initially null.

    +
    +

    The alpha getter steps are to return the value of this’s x axis rotation rate.

    +

    The beta getter steps are to return the value of this’s y axis rotation rate.

    +

    The gamma getter steps are to return the value of this’s z axis rotation rate.

    +

    5.3.3. The DeviceMotionEvent interface

    +
    partial interface Window {
    +    [SecureContext] attribute EventHandler ondevicemotion;
     };
     
     [Exposed=Window, SecureContext]
     interface DeviceMotionEvent : Event {
         constructor(DOMString type, optional DeviceMotionEventInit eventInitDict = {});
    -    readonly attribute DeviceMotionEventAcceleration? acceleration;
    -    readonly attribute DeviceMotionEventAcceleration? accelerationIncludingGravity;
    -    readonly attribute DeviceMotionEventRotationRate? rotationRate;
    -    readonly attribute double interval;
    +    readonly attribute DeviceMotionEventAcceleration? acceleration;
    +    readonly attribute DeviceMotionEventAcceleration? accelerationIncludingGravity;
    +    readonly attribute DeviceMotionEventRotationRate? rotationRate;
    +    readonly attribute double interval;
     
    -    static Promise<PermissionState> requestPermission();
    +    static Promise<PermissionState> requestPermission();
     };
     
     dictionary DeviceMotionEventAccelerationInit {
    @@ -1231,42 +1344,107 @@ 

    double interval = 0; };

    -

    The acceleration attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null.

    -

    The accelerationIncludingGravity attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null.

    -

    The rotationRate attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null.

    -

    The interval attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to 0.

    -

    The static requestPermission() operation, when invoked, must run these steps:

    -
      -
    1. -

      Let promise be a new promise.

      -
    2. -

      Run these steps in parallel:

      -
        -
      1. -

        Let permission be permission for relevant settings object’s origin.

        -
      2. -

        If permission is "default" and the relevant global object does not have transient activation, then reject promise with a NotAllowedError DOMException and abort these steps.

        -
      3. -

        If permission is "default", ask the user whether sharing device motion +

        The ondevicemotion attribute is an event handler IDL attribute for the ondevicemotion event handler, whose event handler event type is devicemotion.

        +

        The acceleration attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the device’s linear acceleration.

        +

        The accelerationIncludingGravity attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the device’s acceleration with gravity.

        +

        The rotationRate attribute must return the value it was initialized to. When the object is created, this attribute must be initialized to null. It represents the device’s rotation rate.

        +

        The interval attribute must return the value it was initialized to. It represents the interval at which data is obtained from the underlying hardware and must be expressed in milliseconds (ms). It is constant to simplify filtering of the data by the Web application.

        +
        + The requestPermission() method steps are: +
          +
        1. +

          Let promise be a new promise.

          +
        2. +

          Run these steps in parallel:

          +
            +
          1. +

            Let permission be permission for relevant settings object’s origin.

            +
          2. +

            If permission is "default" and the relevant global object does not have transient activation, then reject promise with a NotAllowedError DOMException and abort these steps.

            +
          3. +

            If permission is "default", ask the user whether sharing device motion for the relevant settings object’s origin is acceptable. If it is, set permission to "granted", and "denied" otherwise.

            -
          4. -

            Queue a task to run these steps:

            -
              -
            1. -

              Set permission for the relevant settings object’s origin to permission.

              -
            2. -

              Fulfill promise with permission.

              -
            -
          -
        3. -

          Return promise.

          -
        -

        In the DeviceMotionEvent events fired by the user agent, the following requirements must apply:

        -

        The acceleration attribute must be initialized with the device’s linear acceleration. The value must not be more precise than 0.1 m/s2.

        -

        Implementations that are unable to provide acceleration data without the effect of gravity (due, for example, to the lack of a gyroscope) may instead supply acceleration with gravity. This is less useful in many applications but is provided as a means of providing best-effort support. In this case, the accelerationIncludingGravity attribute must be initialized with the acceleration with gravity measurements. Again, the value must not be more precise than 0.1 m/s2.

        -

        The rotationRate attribute must be initialized with the device’s rotation rate. It must be expressed as the rate of change of the angles defined as alpha (x axis), beta (y axis), gamma (z axis). Each attribute must not be more precise than 0.1 degrees per second.

        -

        The interval attribute must be initialized with the interval at which data is obtained from the underlying hardware and must be expressed in milliseconds (ms). It must be a constant, to simplify filtering of the data by the Web application.

        -

        Implementations that are unable to provide all attributes must initialize the values of the unknown attributes to null. If an implementation can never provide motion information, the event should be fired with the acceleration, accelerationIncludingGravity and rotationRate attributes set to null.

        +
      4. +

        Queue a task to run these steps:

        +
          +
        1. +

          Set permission for the relevant settings object’s origin to permission.

          +
        2. +

          Fulfill promise with permission.

          +
        +
      +
    3. +

      Return promise.

      +
    +
    +
    + At an implementation-defined interval interval, the user agent must execute the following steps on a navigable’s active window window: +
      +
    1. +

      Let acceleration be null.

      +
    2. +

      Let accelerationIncludingGravity be null.

      +
    3. +

      Let rotationRate be null.

      +
    4. +

      If the implementation is able to provide linear acceleration:

      +
        +
      1. +

        Set acceleration to a new DeviceMotionEventAcceleration created in window’s realm.

        +
      2. +

        Set acceleration’s x axis acceleration to the device’s linear acceleration along the X axis, or null if it cannot be provided.

        +
      3. +

        If acceleration’s x axis acceleration is not null, limit its precision to no more than 0.1 m/s2.

        +
      4. +

        Set acceleration’s y axis acceleration to the device’s linear acceleration along the Y axis, or null if it cannot be provided.

        +
      5. +

        If acceleration’s y axis acceleration is not null, limit its precision to no more than 0.1 m/s2.

        +
      6. +

        Set acceleration’s z axis acceleration to the device’s linear acceleration along the Z axis, or null if it cannot be provided.

        +
      7. +

        If acceleration’s z axis acceleration is not null, limit its precision to no more than 0.1 m/s2.

        +
      +
    5. +

      If the implementation is able to provide acceleration with gravity:

      +
        +
      1. +

        Set accelerationIncludingGravity to a new DeviceMotionEventAcceleration created in window’s realm.

        +
      2. +

        Set accelerationIncludingGravity’s x axis acceleration to the device’s acceleration with gravity along the X axis, or null if it cannot be provided.

        +
      3. +

        If accelerationIncludingGravity’s x axis acceleration is not null, limit its precision to no more than 0.1 m/s2.

        +
      4. +

        Set accelerationIncludingGravity’s y axis acceleration to the device’s acceleration with gravity along the Y axis, or null if it cannot be provided.

        +
      5. +

        If accelerationIncludingGravity’s y axis acceleration is not null, limit its precision to no more than 0.1 m/s2.

        +
      6. +

        Set accelerationIncludingGravity’s z axis acceleration to the device’s acceleration with gravity along the Z axis, or null if it cannot be provided.

        +
      7. +

        If accelerationIncludingGravity’s z axis acceleration is not null, limit its precision to no more than 0.1 m/s2.

        +
      +
    6. +

      If the implementation is able to provide rotation rate:

      +
        +
      1. +

        Set rotationRate to a new DeviceMotionEventRotationRate created in window’s realm.

        +
      2. +

        Set rotationRate’s x axis rotation rate to the device’s rotation rate about the X axis, or null if it cannot be provided.

        +
      3. +

        If rotationRate’s x axis rotation rate is not null, limit its precision to no more than 0.1 deg/s.

        +
      4. +

        Set rotationRate’s y axis rotation rate to the device’s rotation rate about the Y axis, or null if it cannot be provided.

        +
      5. +

        If rotationRate’s y axis rotation rate is not null, limit its precision to no more than 0.1 deg/s.

        +
      6. +

        Set rotationRate’s z axis rotation rate to the device’s rotation rate about the Z axis, or null if it cannot be provided.

        +
      7. +

        If rotationRate’s z axis rotation rate is not null, limit its precision to no more than 0.1 deg/s.

        +
      +
    7. +

      Fire an event named devicemotion at window, using DeviceMotionEvent, with the acceleration attribute initialized to acceleration, the accelerationIncludingGravity attribute initialized to accelerationIncludingGravity, the rotationRate attribute initialized to rotationRate, and the interval attribute initialized to interval.

      +
    +
    +

    If an implementation can never provide motion information, the event should be fired with the acceleration, accelerationIncludingGravity and rotationRate attributes set to null.

    5.4. Permission model

    Further implementation experience is being gathered for the permission model and specification clarifications informed by this experience are being discussed in GitHub issue #74.

    Implementations may choose to share device orientation & motion only if the @@ -1303,11 +1481,11 @@

    In light of that, implementations may consider permissions or visual indicators to signify the use of sensors by the web page. Furthermore, to minimize privacy risks, the chance of fingerprinting and other attacks the implementations must:

    @@ -1365,7 +1543,7 @@

    A.1 Calcul

    provided that β and γ are not both zero.

    -

    The compass heading calculation above can be represented in JavaScript as follows to return the correct compass heading when the provided parameters are defined, not null and represent absolute values.

    +

    The compass heading calculation above can be represented in JavaScript as follows to return the correct compass heading when the provided parameters are defined, not null and represent absolute values.

    var degtorad = Math.PI / 180; // Degree-to-Radian conversion
     
     function compassHeading( alpha, beta, gamma ) {
    @@ -1414,7 +1592,7 @@ 

    A.2 Alte

    If R represents the rotation matrix of the device in the earth frame XYZ, then since the initial body frame is aligned with the earth, R is as follows.

    R = ZXY = [[cos(alpha) cos(gamma)-sin(alpha) sin(beta) sin(gamma), -cos(beta) sin(alpha), cos(gamma) sin(alpha) sin(beta)+cos(alpha) sin(gamma)], [cos(gamma) sin(alpha)+cos(alpha) sin(beta) sin(gamma), cos(alpha) cos(beta), sin(alpha) sin(gamma)-cos(alpha) cos(gamma) sin(beta)], [-cos(beta) sin(gamma), sin(beta), cos(beta) cos(gamma)]]
    - The above combined rotation matrix can be represented in JavaScript as follows provided passed parameters are defined, not null and represent absolute values. + The above combined rotation matrix can be represented in JavaScript as follows provided passed parameters are defined, not null and represent absolute values.
    var degtorad = Math.PI / 180; // Degree-to-Radian conversion
     
     function getRotationMatrix( alpha, beta, gamma ) {
    @@ -1459,7 +1637,7 @@ 

    A.2 Alte

    If q represents the unit quaternion of the device in the earth frame XYZ, then since the initial body frame is aligned with the earth, q is as follows.

    q = [[q_w], [q_x], [q_y], [q_z]] = [[cos(beta)cos(gamma)cos(alpha) - sin(beta)sin(gamma)sin(alpha)], [sin(beta)cos(gamma)cos(alpha) - cos(beta)sin(gamma)sin(alpha)], [cos(beta)sin(gamma)cos(alpha) + sin(beta)cos(gamma)sin(alpha)], [cos(beta)cos(gamma)sin(alpha) + sin(beta)sin(gamma)cos(alpha)]]
    - The above quaternion can be represented in JavaScript as follows provided the passed parameters are defined, are absolute values and those parameters are not null. + The above quaternion can be represented in JavaScript as follows provided the passed parameters are defined, are absolute values and those parameters are not null.
    var degtorad = Math.PI / 180; // Degree-to-Radian conversion
     
     function getQuaternion( alpha, beta, gamma ) {
    @@ -1509,75 +1687,76 @@ 

    attribute for DeviceMotionEvent, in § 5.3 -
  • dict-member for DeviceMotionEventInit, in § 5.3 +
  • attribute for DeviceMotionEvent, in § 5.3.3 +
  • dict-member for DeviceMotionEventInit, in § 5.3.3
  • accelerationIncludingGravity
  • acceleration with gravity, in § 4.2
  • alpha
  • beta
  • constructor(type)
  • constructor(type, eventInitDict) -
  • devicemotion, in § 5.3 -
  • DeviceMotionEvent, in § 5.3 -
  • DeviceMotionEventAcceleration, in § 5.3 -
  • DeviceMotionEventAccelerationInit, in § 5.3 -
  • DeviceMotionEventInit, in § 5.3 -
  • DeviceMotionEventRotationRate, in § 5.3 -
  • DeviceMotionEventRotationRateInit, in § 5.3 -
  • DeviceMotionEvent(type), in § 5.3 -
  • DeviceMotionEvent(type, eventInitDict), in § 5.3 +
  • devicemotion, in § 5.3.3 +
  • DeviceMotionEvent, in § 5.3.3 +
  • DeviceMotionEventAcceleration, in § 5.3.1 +
  • DeviceMotionEventAccelerationInit, in § 5.3.3 +
  • DeviceMotionEventInit, in § 5.3.3 +
  • DeviceMotionEventRotationRate, in § 5.3.2 +
  • DeviceMotionEventRotationRateInit, in § 5.3.3 +
  • DeviceMotionEvent(type), in § 5.3.3 +
  • DeviceMotionEvent(type, eventInitDict), in § 5.3.3
  • deviceorientation, in § 5.1
  • deviceorientationabsolute, in § 5.2
  • DeviceOrientationEvent, in § 5.1
  • DeviceOrientationEventInit, in § 5.1
  • DeviceOrientationEvent(type), in § 5.1
  • DeviceOrientationEvent(type, eventInitDict), in § 5.1 +
  • fire an orientation event, in § 5.1
  • gamma
  • interval
  • Linear acceleration, in § 4.2 -
  • ondevicemotion, in § 5.3 +
  • ondevicemotion, in § 5.3.3
  • ondeviceorientation, in § 5.1
  • ondeviceorientationabsolute, in § 5.2
  • permission, in § 5.4 @@ -1585,34 +1764,41 @@

    method for DeviceMotionEvent, in § 5.3 +
  • method for DeviceMotionEvent, in § 5.3.3
  • method for DeviceOrientationEvent, in § 5.1
  • rotation rate, in § 4.2
  • rotationRate +
  • significant change in orientation, in § 5.1
  • x +
  • x axis acceleration, in § 5.3.1 +
  • x axis rotation rate, in § 5.3.2
  • y +
  • y axis acceleration, in § 5.3.1 +
  • y axis rotation rate, in § 5.3.2
  • z +
  • z axis acceleration, in § 5.3.1 +
  • z axis rotation rate, in § 5.3.2

    Terms defined by reference

      @@ -1655,13 +1841,13 @@

      origin
    • origin (for environment settings object)
    • queue a task +
    • realm
    • relevant global object
    • same origin
    • secure context
    • top-level traversable
    • transient activation
    • visibility state -
    • window
  • [INFRA] defines the following terms: @@ -1689,6 +1875,8 @@

    SecureContext
  • boolean
  • double +
  • new +
  • this

    References

    @@ -1744,18 +1932,18 @@

    IDL Index

    partial interface Window {
    -    [SecureContext] attribute EventHandler ondeviceorientation;
    +    [SecureContext] attribute EventHandler ondeviceorientation;
     };
     
     [Exposed=Window, SecureContext]
     interface DeviceOrientationEvent : Event {
         constructor(DOMString type, optional DeviceOrientationEventInit eventInitDict = {});
    -    readonly attribute double? alpha;
    -    readonly attribute double? beta;
    -    readonly attribute double? gamma;
    -    readonly attribute boolean absolute;
    +    readonly attribute double? alpha;
    +    readonly attribute double? beta;
    +    readonly attribute double? gamma;
    +    readonly attribute boolean absolute;
     
    -    static Promise<PermissionState> requestPermission();
    +    static Promise<PermissionState> requestPermission();
     };
     
     dictionary DeviceOrientationEventInit : EventInit {
    @@ -1766,36 +1954,36 @@ 

    I }; partial interface Window { - [SecureContext] attribute EventHandler ondeviceorientationabsolute; -}; - -partial interface Window { - [SecureContext] attribute EventHandler ondevicemotion; + [SecureContext] attribute EventHandler ondeviceorientationabsolute; }; [Exposed=Window, SecureContext] interface DeviceMotionEventAcceleration { - readonly attribute double? x; - readonly attribute double? y; - readonly attribute double? z; + readonly attribute double? x; + readonly attribute double? y; + readonly attribute double? z; }; [Exposed=Window, SecureContext] interface DeviceMotionEventRotationRate { - readonly attribute double? alpha; - readonly attribute double? beta; - readonly attribute double? gamma; + readonly attribute double? alpha; + readonly attribute double? beta; + readonly attribute double? gamma; +}; + +partial interface Window { + [SecureContext] attribute EventHandler ondevicemotion; }; [Exposed=Window, SecureContext] interface DeviceMotionEvent : Event { constructor(DOMString type, optional DeviceMotionEventInit eventInitDict = {}); - readonly attribute DeviceMotionEventAcceleration? acceleration; - readonly attribute DeviceMotionEventAcceleration? accelerationIncludingGravity; - readonly attribute DeviceMotionEventRotationRate? rotationRate; - readonly attribute double interval; + readonly attribute DeviceMotionEventAcceleration? acceleration; + readonly attribute DeviceMotionEventAcceleration? accelerationIncludingGravity; + readonly attribute DeviceMotionEventRotationRate? rotationRate; + readonly attribute double interval; - static Promise<PermissionState> requestPermission(); + static Promise<PermissionState> requestPermission(); }; dictionary DeviceMotionEventAccelerationInit { @@ -2517,75 +2705,90 @@

    I + \ No newline at end of file