这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
canPresent
只读特性在
VRDisplayCapabilities
interface returns a
布尔
stating whether the VR display is capable of presenting content (e.g. through an HMD).
This is useful for identifying "magic window" devices that are capable of 6DoF tracking but for which
VRDisplay.requestPresent()
is not meaningful. If
canPresent
is
false
,调用
VRDisplay.requestPresent()
will fail, and
VRDisplay.getEyeParameters()
将返回
null
.
var canIPresent = vrDisplayCapabilitiesInstance.canPresent;
A
布尔
.
function reportDisplays() {
navigator.getVRDisplays().then(function(displays) {
for(var i = 0; i < displays.length; i++) {
var cap = displays[i].capabilities;
// cap is a VRDisplayCapabilities object
var listItem = document.createElement('li');
listItem.innerHTML = '<strong>Display ' + (i+1) + '</strong>'
+ '<br>VR Display ID: ' + displays[i].displayId
+ '<br>VR Display Name: ' + displays[i].displayName
+ '<br>Display can present content: ' + cap.canPresent
+ '<br>Display is separate from the computer\'s main display: ' + cap.hasExternalDisplay
+ '<br>Display can return position info: ' + cap.hasPosition
+ '<br>Display can return orientation info: ' + cap.hasOrientation
+ '<br>Display max layers: ' + cap.maxLayers;
list.appendChild(listItem);
}
});
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebVR 1.1
The definition of 'canPresent' in that specification. |
草案 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
canPresent
弃用
|
Chrome No | Edge 15 — 79 |
Firefox
55
|
IE No | Opera ? | Safari ? | WebView Android No |
Chrome Android
56 — 80
Disabled
|
Firefox Android 55 | Opera Android ? | Safari iOS ? |
Samsung Internet Android
6.0
|
完整支持
不支持
兼容性未知
实验。期望将来行为有所改变。
弃用。不要用于新网站。
见实现注意事项。
用户必须明确启用此特征。