The read-only primaryLightDirection
property of the XRLightEstimate
interface returns a DOMPointReadOnly
representing the direction to the primary light source from the probeSpace
of an XRLightProbe
.
The read-only primaryLightDirection
property of the XRLightEstimate
interface returns a DOMPointReadOnly
representing the direction to the primary light source from the probeSpace
of an XRLightProbe
.
A DOMPointReadOnly
object. If no estimated values from the user's environment are available, the point will be { x: 0.0, y: 1.0, z: 0.0, w: 0.0 }
, representing a light shining straight down from above.
Within an XRFrame
loop, you can use the primaryLightDirection
and primaryLightIntensity
properties to render shadows based on the most prominent light source, for example.
const lightProbe = await xrSession.requestLightProbe(); // frame loop function onXRFrame(time, xrFrame) { let lightEstimate = xrFrame.getLightEstimate(lightProbe); // Render lights ... // Available properties lightEstimate.primaryLightDirection; lightEstimate.primaryLightIntensity; }
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
primaryLightDirection |
90 |
90 |
No |
No |
76 |
No |
No |
90 |
No |
No |
No |
15.0 |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XRLightEstimate/primaryLightDirection