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.primaryLightDirectionRead only Experimental-
Một
DOMPointReadOnlyđại diện cho hướng đến nguồn sáng chính từprobeSpacecủaXRLightProbe. XRLightEstimate.primaryLightIntensityRead 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ừprobeSpacecủaXRLightProbe. XRLightEstimate.sphericalHarmonicsCoefficientsRead only Experimental-
Một
Float32Arraychứ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.
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> |