XRLightEstimate: primaryLightDirection 属性
XRLightEstimate 接口的只读 primaryLightDirection 属性返回一个 DOMPointReadOnly 对象,该对象表示来自 XRLightProbe 的 probeSpace 到主要光源的方向。
值
一个 DOMPointReadOnly 对象。如果用户环境中没有可估算的值,则该点为 { x: 0.0, y: 1.0, z: 0.0, w: 0.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-primarylightdirection |
浏览器兼容性
加载中…