XRView: isFirstPersonObserver property
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 isFirstPersonObserver của giao diện XRView là giá trị boolean cho biết XRView có phải là chế độ xem quan sát góc nhìn thứ nhất hay không.
Để tạo bản ghi video của camera thiết bị AR, bạn không thể chỉ đơn giản sử dụng một trong các mắt đã dựng, vì thường sẽ có độ lệch vật lý. Một số thiết bị cung cấp chế độ xem phụ, chế độ xem quan sát góc nhìn thứ nhất, có eye là none.
Để nhận chế độ xem quan sát góc nhìn thứ nhất, bạn cần bật rõ ràng bộ mô tả tính năng "secondary-views" (thường là tính năng tùy chọn). Xem XRSystem.requestSession() để biết chi tiết.
Thuộc tính isFirstPersonObserver cho phép bạn kiểm tra chế độ xem phụ nào là chế độ xem quan sát góc nhìn thứ nhất.
Ví dụ
>Kiểm tra chế độ xem quan sát góc nhìn thứ nhất
// Make sure to enable "secondary-view"
navigator.xr
.requestSession("immersive-ar", {
optionalFeatures: ["secondary-views"],
})
.then((session) => {
// …
session.requestAnimationFrame((frame) => {
const views = frame.getViewerPose(space);
// Make sure to iterate over all views
for (const view of views) {
if (view.isFirstPersonObserver) {
renderFPO();
} else {
render();
}
}
});
});
Thông số kỹ thuật
| Specification |
|---|
| WebXR Augmented Reality Module - Level 1> # dom-xrview-isfirstpersonobserver> |