XRLightEstimate: primaryLightIntensity 属性
XRLightEstimate 接口的只读primaryLightIntensity 属性返回一个 DOMPointReadOnly 对象,该对象表示来自 XRLightProbe 的 probeSpace 的主光源的强度。
值
一个 DOMPointReadOnly 对象,其中 RGB 值映射到 x、y 和 z 值。w 值始终为 1.0。如果没有来自用户环境的估计值,则该点为 {x: 0.0, y: 0.0, z: 0.0, w: 1.0},表示没有光照。
示例
在 XRFrame 循环中,您可以使用 primaryLightDirection 和 primaryLightIntensity 属性来渲染基于最突出光源的阴影,例如。
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;
}
规范
| 规范 |
|---|
| WebXR 光照估算 API Level 1 # dom-xrlightestimate-primarylightintensity |
浏览器兼容性
加载中…