XRSession: phương thức requestLightProbe()
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 requestLightProbe() của giao diện XRSession trả về một Promise resolve với một đối tượng XRLightProbe ước tính thông tin ánh sáng tại một điểm nhất định trong môi trường của người dùng.
Cú pháp
requestLightProbe()
requestLightProbe(options)
Tham số
optionsOptional-
Một đối tượng chứa các tùy chọn cấu hình, cụ thể:
reflectionFormat-
Định dạng phản chiếu nội bộ cho biết cách dữ liệu texture được biểu diễn,
srgba8(giá trị mặc định) hoặcrgba16f. Xem thêmXRSession.preferredReflectionFormat.
Giá trị trả về
Một Promise resolve với một đối tượng XRLightProbe.
Ngoại lệ
Thay vì ném ngoại lệ thực sự, requestLightProbe() từ chối promise được trả về với một DOMException, cụ thể là một trong các ngoại lệ sau:
NotSupportedErrorDOMException-
Được ném nếu
lighting-estimationkhông phải là tính năng đã bật trongXRSystem.requestSession()hoặc nếureflectionFormatkhông phải làsrgb8hoặcpreferredReflectionFormat. InvalidStateErrorDOMException-
Được ném nếu phiên đã kết thúc.
Ví dụ
>Yêu cầu một light probe với định dạng ưa thích của hệ thống
Định dạng mặc định là srgb8, tuy nhiên, một số công cụ kết xuất có thể sử dụng các định dạng khác (dynamic range cao). Bạn có thể yêu cầu light probe bằng XRSession.preferredReflectionFormat để báo cáo định dạng nội bộ ưa thích.
const lightProbe = await xrSession.requestLightProbe({
reflectionFormat: xrSession.preferredReflectionFormat,
});
Thông số kỹ thuật
| Specification |
|---|
| WebXR Lighting Estimation API Level 1> # dom-xrsession-requestlightprobe> |