The XRLightEstimate
interface of the WebXR Device API provides the estimated lighting values for an XRLightProbe
at the time represented by an XRFrame
.
To get an XRLightEstimate
object, call the XRFrame.getLightEstimate()
method.
First, use the XRSession.requestLightProbe()
method to get a light probe from a session. Then, within an XRFrame
loop, the getLightEstimate()
method will return a XRLightEstimate
object containing the lighting values for each frame.
const lightProbe = await xrSession.requestLightProbe();
function onXRFrame(time, xrFrame) {
let lightEstimate = xrFrame.getLightEstimate(lightProbe);
lightEstimate.sphericalHarmonicsCoefficients;
lightEstimate.primaryLightDirection;
lightEstimate.primaryLightIntensity;
}