XRLightEstimate: primaryLightIntensity property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The read-only primaryLightIntensity property of the XRLightEstimate interface returns a DOMPointReadOnly representing the intensity of the primary light source from the probeSpace of an XRLightProbe.

Value

A DOMPointReadOnly object where an RGB value is mapped to the x, y, and z values. The w value is always 1.0. If no estimated values from the user's environment are available, the point will be {x: 0.0, y: 0.0, z: 0.0, w: 1.0}, representing no illumination.

Examples

Within an XRFrame loop, you can use the primaryLightDirection and primaryLightIntensity properties to render shadows based on the most prominent light source, for example.

js
const lightProbe = await xrSession.requestLightProbe();

// frame loop
function onXRFrame(time, xrFrame) {
  let lightEstimate = xrFrame.getLightEstimate(lightProbe);

  // Render lights

  // Available properties
  lightEstimate.primaryLightDirection;
  lightEstimate.primaryLightIntensity;
}

Specifications

Specification
WebXR Lighting Estimation API Level 1
# dom-xrlightestimate-primarylightintensity

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
primaryLightIntensity
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

See also