XRFrame: phương thức getLightEstimate()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Phương thức getLightEstimate() của giao diện XRFrame trả về một đối tượng XRLightEstimate chứa các giá trị ánh sáng ước tính cho một XRLightProbe cho trước.

Cú pháp

js
getLightEstimate(lightProbe)

Tham số

lightProbe

Một đối tượng XRLightProbe chứa trạng thái ánh sáng hiện tại của khung.

Giá trị trả về

Một đối tượng XRLightEstimate hoặc null nếu thiết bị không thể ước tính ánh sáng cho khung này.

Ví dụ

Lấy ước tính ánh sáng cho từng khung

Với XRLightProbe của một phiên, phương thức getLightEstimate() lấy đối tượng XRLightEstimate chứa các giá trị ánh sáng cho từng khung.

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;
}

Thông số kỹ thuật

Specification
WebXR Lighting Estimation API Level 1
# dom-xrframe-getlightestimate

Tương thích trình duyệt

Xem thêm