XRLightEstimate: thuộc tính primaryLightDirection

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.

Thuộc tính chỉ đọc primaryLightDirection của giao diện XRLightEstimate trả về một DOMPointReadOnly đại diện cho hướng đến nguồn sáng chính từ probeSpace của XRLightProbe.

Giá trị

Một đối tượng DOMPointReadOnly. Nếu không có giá trị ước tính nào từ môi trường của người dùng, điểm sẽ là { x: 0.0, y: 1.0, z: 0.0, w: 0.0 }, đại diện cho ánh sáng chiếu thẳng xuống từ trên cao.

Ví dụ

Trong vòng lặp XRFrame, bạn có thể sử dụng các thuộc tính primaryLightDirectionprimaryLightIntensity để render bóng dựa trên nguồn sáng nổi bật nhất, ví dụ.

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

Thông số kỹ thuật

Specification
WebXR Lighting Estimation API Level 1
# dom-xrlightestimate-primarylightdirection

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

Xem thêm