XRSession: thuộc tính enabledFeatures
Khả dụng hạn chế
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 enabledFeatures của giao diện XRSession trả về một mảng các tính năng đã được bật (cấp phép) cho một XRSession. Điều này chứa tất cả requiredFeatures và một tập con của optionalFeatures đã được yêu cầu với XRSystem.requestSession().
Giá trị
Một Array các chuỗi.
Ví dụ
>Phát hiện các tính năng phiên WebXR có sẵn
Phương thức XRSystem.requestSession() cho phép bạn yêu cầu tính năng phiên XR. Các tính năng có thể được yêu cầu dưới dạng requiredFeatures (XRSession phải hỗ trợ tính năng) hoặc dưới dạng optionalFeatures (XRSession có thể hỗ trợ tính năng). Thuộc tính enabledFeatures xác định những tính năng nào thực sự khả dụng trong phiên.
navigator.xr
.requestSession("immersive-ar", {
requiredFeatures: ["local", "hit-test"],
optionalFeatures: ["anchors"],
})
.then((xrSession) => {
// Log enabledFeatures
console.log(xrSession.enabledFeatures);
// Check if anchors can be used
if (xrSession.enabledFeatures.includes("anchors")) {
// Go ahead and set up anchors
}
});
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| WebXR Device API> # dom-xrsession-enabledfeatures> |