XRLightEstimate

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 in secure contexts (HTTPS), in some or all supporting browsers.

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

Giao diện XRLightEstimate của WebXR Device API cung cấp các giá trị ánh sáng ước tính cho một XRLightProbe tại thời điểm được đại diện bởi một XRFrame.

Để lấy đối tượng XRLightEstimate, hãy gọi phương thức XRFrame.getLightEstimate().

Thuộc tính phiên bản

XRLightEstimate.primaryLightDirection Read only Experimental

Một DOMPointReadOnly đại diện cho hướng đến nguồn sáng chính từ probeSpace của XRLightProbe.

XRLightEstimate.primaryLightIntensity Read only Experimental

Một DOMPointReadOnly (với các giá trị x, y, z được ánh xạ đến RGB) đại diện cho cường độ của nguồn sáng chính từ probeSpace của XRLightProbe.

XRLightEstimate.sphericalHarmonicsCoefficients Read only Experimental

Một Float32Array chứa 9 hệ số hài cầu.

Phương thức phiên bản

Không có.

Ví dụ

Lấy đối tượng XRLightProbe

Đầu tiên, sử dụng phương thức XRSession.requestLightProbe() để lấy bộ thăm dò ánh sáng từ một phiên. Sau đó, trong vòng lặp XRFrame, phương thức getLightEstimate() sẽ trả về một đối tượng XRLightEstimate chứa các giá trị ánh sáng cho mỗi khung hình.

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
# xrlightestimate-interface

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

Xem thêm