XRLightEstimate: thuộc tính primaryLightIntensity
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 primaryLightIntensity của giao diện XRLightEstimate trả về một DOMPointReadOnly đại diện cho cường độ của nguồn sáng chính từ probeSpace của XRLightProbe.
Giá trị
Một đối tượng DOMPointReadOnly trong đó giá trị RGB được ánh xạ đến các giá trị x, y và z. Giá trị w luôn là 1.0. 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: 0.0, z: 0.0, w: 1.0}, đại diện cho không có ánh sáng.
Ví dụ
Trong vòng lặp XRFrame, bạn có thể sử dụng các thuộc tính primaryLightDirection và primaryLightIntensity để render bóng dựa trên nguồn sáng nổi bật nhất, ví dụ.
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-primarylightintensity> |