recursal/MDN huggingface dataset:
XRRigidTransform: position property
===================================

 The read-only `XRRigidTransform` property
 **`position`** is a `DOMPointReadOnly` object which
 provides the 3D point, specified in meters, describing the translation component of the
 transform.

Value
-----

 A read-only `DOMPointReadOnly` indicating the 3D position component of the
 transform matrix. The units are meters.

**Note:** The `w` component of the point is always 1.0.

Examples
--------

 To create a reference space which can be used to place an object at eye level (assuming
 eye level is 1.5 meters):


```js
function onSessionStarted(xrSession) {
  xrSession.addEventListener("end", onSessionEnded);

  gl = initGraphics(xrSession);

  const glLayer = new XRWebGLLayer(xrSession, gl);
  xrSession.updateRenderState({ baseLayer: glLayer });

  if (immersiveSession) {
    xrSession
      .requestReferenceSpace("bounded-floor")
      .then((refSpace) => {
        refSpaceCreated(refSpace);
      })
      .catch(() => {
        session.requestReferenceSpace("local-floor").then(refSpaceCreated);
      });
  } else {
    session.requestReferenceSpace("viewer").then(refSpaceCreated);
  }
}

function refSpaceCreated(refSpace) {
  xrReferenceSpace = immersiveSession
    ? refSpace
    : refSpace.getOffsetReferenceSpace(new XRRigidTransform({ y: -1.5 }));
  xrSession.requestAnimationFrame(onFrame);
}
```


 After setting up the graphics context for WebXR use, this begins by looking to see if a
 variable `immersiveSession` is `true`; if so, we first request a
 `bounded-floor` reference space. If that fails (probably because
 `bounded-floor` isn't supported), we try requesting a
 `local-floor` reference space.

 If we're not in an immersive session, we instead request a `viewer`
 reference space.

 In all cases, once the space has been obtained, it gets passed into the
 `refSpaceCreated()` function. For immersive spaces, the specified space is
 saved for future use. However, for inline sessions, we know we're in a space not
 automatically adjusted for floor level, so we request an offset reference space to shift
 the viewer's height to 1.5 meters above the presumed floor level of 0 meters. That new
 reference space is used instead of the one initially received.

Finally, an animation frame request is submitted.

Specifications
--------------

| Specification |
| --- |
| WebXR Device API # dom-xrrigidtransform-position |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
XRRigidTransform: inverse property
==================================

 The read-only **`inverse`** property
 of the `XRRigidTransform` interface returns another
 `XRRigidTransform` object which is the inverse of its owning
 transform. That is, you can always get the inverse of any
 `XRRigidTransform` using its `inverse` property, instead of having
 to explicitly generate it.

Value
-----

 An `XRRigidTransform` which contains the inverse of the
 `XRRigidTransform` on which it's accessed.

 Applying the inverse of a transform to any object previously transformed by the parent
 `XRRigidTransform` always undoes the transformation, resulting in the object
 returning to its previous pose. In other words, its position and orientation both return
 to their prior configurations.

Examples
--------

 In this example, the model view matrix for an object is computed by taking the view
 matrix and multiplying it by the object's pose matrix.


```js
const modelViewMatrix = mat4.create();

for (const view of pose.view) {
  const viewport = glLayer.getViewport(view);
  gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);

  // …

  mat4.multiply(modelViewMatrix, view.transform.inverse.matrix, objectMatrix);
  gl.uniformMatrix4fv(
    programInfo.uniformLocations.modelViewMatrix,
    false,
    modelViewMatrix,
  );

  // …
}
```


 This outline of a renderer's core code shows how the pose's view gets represented by
 taking its transform's inverse's matrix as the model view matrix used to transform
 objects based on the viewer's position and orientation. The inverse's matrix is
 multiplied by the object's matrix to get the model view matrix, which is then passed
 into the shader program by setting a uniform to contain that information.

Specifications
--------------

| Specification |
| --- |
| WebXR Device API # dom-xrrigidtransform-inverse |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
XRRigidTransform: orientation property
======================================

 The read-only `XRRigidTransform` property
 **`orientation`** is a `DOMPointReadOnly`
 containing a normalized quaternion (also called a **unit
quaternion** or **versor**)
 specifying the rotational component of the transform represented by the object.
 If you specify a quaternion whose length is not exactly 1.0 meters, it will be
 normalized for you.

Value
-----

 A `DOMPointReadOnly` object which contains a unit quaternion providing the
 orientation component of the transform. As a unit quaternion, the length of the returned
 quaternion is always 1.0 meters.

Examples
--------

 To create a reference space which is oriented to look straight up, positioned 2 meters
 off of ground level:


```js
xrReferenceSpace = refSpace.getOffsetReferenceSpace(
  new XRRigidTransform({ y: -2 }, { x: 0.0, y: 1.0, z: 0.0, w: 1.0 }),
);
```


 The unit quaternion specified here is [0.0, 1.0, 0.0, 1.0] to indicate that the object
 should be facing directly along the *y* axis.

Specifications
--------------

| Specification |
| --- |
| WebXR Device API # dom-xrrigidtransform-orientation |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Movement, orientation, and motion
* Unit quaternions
* Quaternions and spatial rotation
XRRigidTransform: XRRigidTransform() constructor
================================================

 The
 **`XRRigidTransform()`** constructor creates
 a new `XRRigidTransform` object, representing the position and
 orientation of a point or object. Among other things,
 `XRRigidTransform` is used when providing a transform to translate between
 coordinate systems across spaces.

Syntax
------


```js
new XRRigidTransform()
new XRRigidTransform(position)
new XRRigidTransform(position, orientation)
```

### Parameters

`position` Optional

 An object which specifies the coordinates
 at which the point or object is located. These dimensions are specified in meters. If
 this parameter is left out or is invalid, the
 position used is assumed to be `{x: 0, y: 0, z: 0, w: 1}`. `w`
 must *always* be 1.


`orientation` Optional

 An object which specifies the direction in
 which the object is facing. The default value for `orientation` is
 `{x: 0, y: 0, z: 0, w: 1}`. The specified orientation gets normalized if
 it's not already.


### Return value

 A new `XRRigidTransform` object which has been initialized to represent a
 transform matrix that would adjust the position and orientation of an object from the
 origin to the specified `position` and facing in the direction indicated by
 `orientation`.

### Exceptions

`TypeError`

 Thrown if the value of the `w` coordinate in the specified `position` is
 not 1.0.


Examples
--------

 In this example, the beginning of the animation of a scene is shown, starting with a
 request for a reference space of a given type, then shifting the coordinate system based
 on a transform before requesting the first animation frame.


```js
let animationFrameRequestID = 0;

xrSession.requestReferenceSpace("local-floor").then((refSpace) => {
  xrReferenceSpace = refSpace.getOffsetReferenceSpace(
    new XRRigidTransform(viewerPosition, viewerOrientation),
  );
  animationFrameRequestID = xrSession.requestAnimationFrame(drawFrame);
});
```


 After requesting a reference space of type `local-floor`, the returned
 promise is eventually resolved, at which time we receive a new reference space object,
 `refSpace`. After creating an `XRRigidTransform` from the viewer's
 initial position and orientation, we pass the new transform into
 `getOffsetReferenceSpace()` to
 create *another* reference space, now offset so that its origin is located at the
 same place in space as the coordinates given by `viewerPosition`, with the
 orientation also revised in the same fashion.

 Then `requestAnimationFrame()` is
 called to ask for a new animation frame to draw into. The `drawFrame()`
 callback will be executed when the system is ready to draw the next frame.

You can find more examples in Movement, orientation, and motion.

Specifications
--------------

| Specification |
| --- |
| WebXR Device API # dom-xrrigidtransform-xrrigidtransform |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
EventSource: readyState property
================================

 The **`readyState`** read-only property of the
 `EventSource` interface returns a number representing the state of the
 connection.

Value
-----

A number representing the state of the connection. Possible values are:

* `0` — connecting
* `1` — open
* `2` — closed
Examples
--------


```js
const evtSource = new EventSource("sse.php");
console.log(evtSource.readyState);
```


**Note:** You can find a full example on GitHub — see Simple SSE demo using PHP.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-eventsource-readystate-dev |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `EventSource`
EventSource: url property
=========================

 The **`url`** read-only property of the
 `EventSource` interface returns a string representing the
 URL of the source.

Value
-----

A string representing the URL of the source.

Examples
--------


```js
const evtSource = new EventSource("sse.php");
console.log(evtSource.url);
```


**Note:** You can find a full example on GitHub — see Simple SSE demo using PHP.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-eventsource-url-dev |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `EventSource`
EventSource: message event
==========================

The `message` event of the `EventSource` API is fired when data is received through an event source.

This event is not cancelable and does not bubble.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("message", (event) => {});

onmessage = (event) => {};
```

Event type
----------

A `MessageEvent`. Inherits from `Event`.

Event

MessageEventEvent properties
----------------

*This interface also inherits properties from its parent, `Event`.*

`MessageEvent.data` Read only 

The data sent by the message emitter.

`MessageEvent.origin` Read only 

A string representing the origin of the message emitter.

`MessageEvent.lastEventId` Read only 

A string representing a unique ID for the event.

`MessageEvent.source` Read only 

A `MessageEventSource` (which can be a WindowProxy, `MessagePort`, or `ServiceWorker` object) representing the message emitter.

`MessageEvent.ports` Read only 

An array of `MessagePort` objects representing the ports associated with the channel the message is being sent through (where appropriate, e.g. in channel messaging or when sending a message to a shared worker).

Examples
--------

In this basic example, an `EventSource` is created to receive events from the server; a page with the name `sse.php` is responsible for generating the events.


```js
const evtSource = new EventSource("sse.php");
const eventList = document.querySelector("ul");

evtSource.addEventListener("message", (e) => {
  const newElement = document.createElement("li");

  newElement.textContent = `message: ${e.data}`;
  eventList.appendChild(newElement);
});
```

### onmessage equivalent


```js
evtSource.onmessage = (e) => {
  const newElement = document.createElement("li");

  newElement.textContent = `message: ${e.data}`;
  eventList.appendChild(newElement);
};
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # event-message |
| HTML Standard # handler-eventsource-onmessage |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using server-sent events
* `open`
* `error`
EventSource: withCredentials property
=====================================

 The **`withCredentials`** read-only property of the
 `EventSource` interface returns a boolean value indicating whether
 the `EventSource` object was instantiated with CORS credentials set.

Value
-----

 A boolean value indicating whether the `EventSource` object was
 instantiated with CORS credentials set (`true`), or not (`false`,
 the default).

Examples
--------


```js
const evtSource = new EventSource("sse.php");
console.log(evtSource.withCredentials);
```


**Note:** You can find a full example on GitHub — see Simple SSE demo using PHP.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-eventsource-withcredentials-dev |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `EventSource`
EventSource: open event
=======================

The `open` event of the `EventSource` API is fired when a connection with an event source is opened.

This event is not cancelable and does not bubble.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("open", (event) => {});

onopen = (event) => {};
```

Event type
----------

A generic `Event`.

Examples
--------


```js
const evtSource = new EventSource("sse.php");

// addEventListener version
evtSource.addEventListener("open", (e) => {
  console.log("The connection has been established.");
});

// onopen version
evtSource.onopen = (e) => {
  console.log("The connection has been established.");
};
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # event-open |
| HTML Standard # handler-eventsource-onopen |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using server-sent events
* `open`
* `error`
* `message`
EventSource: close() method
===========================

 The **`close()`** method of the `EventSource`
 interface closes the connection, if one is made, and sets the
 `EventSource.readyState` attribute to `2` (closed).

**Note:** If the connection is already closed, the method does nothing.

Syntax
------


```js
close()
```

### Parameters

None.

### Return value

None (`undefined`).

Examples
--------


```js
const button = document.querySelector("button");
const evtSource = new EventSource("sse.php");

button.onclick = () => {
  console.log("Connection closed");
  evtSource.close();
};
```


**Note:** You can find a full example on GitHub — see Simple SSE demo using PHP.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-eventsource-close-dev |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `EventSource`
EventSource: EventSource() constructor
======================================

 The **`EventSource()`**
 constructor returns a newly-created `EventSource`, which represents a
 remote resource.

Syntax
------


```js
new EventSource(url)
new EventSource(url, options)
```

### Parameters

`url`

 A string that represents the location of the remote resource
 serving the events/messages.


`options` Optional

Provides options to configure the new connection. The possible entries are:

`withCredentials` Optional

 A boolean value, defaulting to `false`, indicating
 if CORS should be set to `include` credentials.



Examples
--------


```js
const evtSource = new EventSource("sse.php");
const eventList = document.querySelector("ul");

evtSource.onmessage = (e) => {
  const newElement = document.createElement("li");

  newElement.textContent = `message: ${e.data}`;
  eventList.appendChild(newElement);
};
```


**Note:** You can find a full example on GitHub — see Simple SSE demo using PHP.

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-eventsource-dev |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `EventSource`
EventSource: error event
========================

The `error` event of the `EventSource` API is fired when a connection with an event source fails to be opened.

This event is not cancelable and does not bubble.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("error", (event) => {});

onerror = (event) => {};
```

Event type
----------

A generic `Event`.

Examples
--------


```js
const evtSource = new EventSource("sse.php");

// addEventListener version
evtSource.addEventListener("error", (e) => {
  console.log("An error occurred while attempting to connect.");
});

// onerror version
evtSource.onerror = (e) => {
  console.log("An error occurred while attempting to connect.");
};
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # event-error |
| HTML Standard # handler-eventsource-onerror |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using server-sent events
* `open`
* `message`
HTMLScriptElement: referrerPolicy property
==========================================

 The **`referrerPolicy`** property of the
 `HTMLScriptElement` interface reflects the HTML
 `referrerpolicy` of the `<script>` element, which defines how the referrer is set when fetching the script and any scripts it imports.

Value
-----

A string; one of the following:

`no-referrer`

 The `Referer` header will be omitted entirely. No referrer
 information is sent along with requests.


`no-referrer-when-downgrade`

 The URL is sent
 as a referrer when the protocol security level stays the same (e.g.HTTP→HTTP,
 HTTPS→HTTPS), but isn't sent to a less secure destination (e.g. HTTPS→HTTP).


`origin`

 Only send the origin of the document as the referrer in all cases.
 The document `https://example.com/page.html` will send the referrer
 `https://example.com/`.


`origin-when-cross-origin`

 Send a full URL when performing a same-origin request, but only send the origin of
 the document for other cases.


`same-origin`

 A referrer will be sent for same-site origins, but
 cross-origin requests will contain no referrer information.


`strict-origin`

 Only send the origin of the document as the referrer when the protocol security
 level stays the same (e.g. HTTPS→HTTPS), but don't send it to a less secure
 destination (e.g. HTTPS→HTTP).


`strict-origin-when-cross-origin` (default)

 This is the user agent's default behavior if no policy is specified. Send a full URL when performing a same-origin request, only send the origin when the
 protocol security level stays the same (e.g. HTTPS→HTTPS), and send no header to a
 less secure destination (e.g. HTTPS→HTTP).


`unsafe-url`

 Send a full URL when performing a same-origin or cross-origin request. This policy
 will leak origins and paths from TLS-protected resources to insecure origins.
 Carefully consider the impact of this setting.




**Note:** An empty string value (`""`) is both the default
 value, and a fallback value if `referrerpolicy` is not supported. If
 `referrerpolicy` is not explicitly specified on the
 `<script>` element, it will adopt a higher-level referrer policy,
 i.e. one set on the whole document or domain. If a higher-level policy is not
 available, the empty string is treated as being equivalent to
 `no-referrer-when-downgrade`.


Examples
--------


```js
const scriptElem = document.createElement("script");
scriptElem.src = "/";
scriptElem.referrerPolicy = "unsafe-url";
document.body.appendChild(scriptElem);
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-script-referrerpolicy |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `HTMLIFrameElement.referrerPolicy`
HTMLScriptElement: crossOrigin property
=======================================

The **`crossOrigin`** property of the `HTMLScriptElement` interface reflects the Cross-Origin Resource Sharing settings for the script element. For classic scripts from other origins, this controls if full error information will be exposed. For module scripts, it controls the script itself and any script it imports. See CORS settings attributes for details.

Value
-----

A string of a keyword specifying the CORS mode to use when fetching the resource. Possible values are:

`anonymous` or an empty string (`""`)

Requests sent by the `HTMLScriptElement` will use the `cors` mode and the `same-origin` credentials mode. This means that CORS is enabled and credentials are sent *if* the resource is fetched from the same origin from which the document was loaded.

`use-credentials`

Requests sent by the `HTMLScriptElement` will use the `cors` mode and the `include` credentials mode. All resources requests by the element will use CORS, regardless of which domain the fetch is from.

If the `crossOrigin` property is specified with any other value, it is the same as specifing it as the `anonymous`.

If the `crossOrigin` property is not specified, the resource is fetched without CORS (the `no-cors` mode and the `same-origin` credentials mode).

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-script-crossorigin |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `HTMLImageElement.crossOrigin`
* `HTMLLinkElement.crossOrigin`
* `HTMLMediaElement.crossOrigin`