XRFrame: getLightEstimate() 方法
XRFrame 介面的 getLightEstimate() 方法返回一個 XRLightEstimate 物件,其中包含給定 XRLightProbe 的估計光照值。
語法
js
getLightEstimate(lightProbe)
引數
lightProbe-
一個
XRLightProbe物件,包含當前幀的光照狀態。
返回值
如果裝置無法估計此幀的光照,則返回 XRLightEstimate 物件或 null。
示例
獲取每一幀的光照估算
給定一個會話的 XRLightProbe,getLightEstimate() 方法將獲取一個 XRLightEstimate 物件,其中包含每一幀的光照值。
js
const lightProbe = await xrSession.requestLightProbe();
// frame loop
function onXRFrame(time, xrFrame) {
let lightEstimate = xrFrame.getLightEstimate(lightProbe);
// Use light estimate data to light the scene
// Available properties
lightEstimate.sphericalHarmonicsCoefficients;
lightEstimate.primaryLightDirection;
lightEstimate.primaryLightIntensity;
}
規範
| 規範 |
|---|
| WebXR 光照估算 API Level 1 # dom-xrframe-getlightestimate |
瀏覽器相容性
載入中…