XRLightProbe
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
TheXRLightProbe interface of theWebXR Device API contains lighting information at a given point in the user's environment. You can get anXRLighting object using theXRSession.requestLightProbe() method.
This object doesn't itself contain lighting values, but it is used to collect lighting states for eachXRFrame. SeeXRLightEstimate for the estimated lighting values for anXRLightProbe.
In this article
Instance properties
XRLightProbe.onreflectionchangeEvent handler property for the
reflectionchangeevent.XRLightProbe.probeSpaceRead onlyExperimentalAn
XRSpacetracking the position and orientation the lighting estimations are relative to.
Instance methods
None.
Events
reflectionchangeExperimentalFired each time the estimated reflection cube map changes. (This happens when the user moves around and the environment's lighting changes.)
Examples
>Getting anXRLightProbe object for a session
Use theXRSession.requestLightProbe() method to get a light probe.
const lightProbe = await xrSession.requestLightProbe();Getting a probe pose within anXRFrame
Pass the light probe'sprobeSpace toXRFrame.getPose() to get a light probe for a pose.
const probePose = xrFrame.getPose(lightProbe.probeSpace, xrReferenceSpace);Using thereflectionchange event
PassXRLightProbe to get a reflection cube map whenever thereflectionchange event fires. See alsoXRWebGLBinding.getReflectionCubeMap().
const glBinding = new XRWebGLBinding(xrSession, gl);const lightProbe = await xrSession.requestLightProbe();let glCubeMap = glBinding.getReflectionCubeMap(lightProbe);lightProbe.addEventListener("reflectionchange", () => { glCubeMap = glBinding.getReflectionCubeMap(lightProbe);});Specifications
| Specification |
|---|
| WebXR Lighting Estimation API Level 1> # xrlightprobe-interface> |