WebVR API の VRDisplay
インターフェイスは,このAPIがサポートしているVRデバイスを現します.VRDisplayにはデバイスIDやデスクリプションのような汎用的な情報が含まれていて,VRシーンの表示を開始するためのメソッドや,目のパラメータやディスプレイの備える機能の取得,その他の重要な機能を含んでいます。
Navigator.getVRDisplays()
を呼び出すことで,すべての接続されているVRのデバイスの配列が返されます。
プロパティ
VRDisplay.capabilities
読取専用VRDisplay
の備える機能を示すVRDisplayCapabilities
オブジェクトを返します.VRDisplay.depthFar
- eye view frustum(ビューフラスタム;つまりシーンの可視領域の境界) のfar平面を定義しているz-depthの取得と設定を行います.
VRDisplay.depthNear
- eye view frustum(ビューフラスタム;つまりシーンの可視領域の境界) のnear平面を定義しているz-depthの取得と設定を行います.
VRDisplay.displayId
読取専用- このVRDisplay固有のIDを返します.このIDはGamepad API (参照
Gamepad.displayId
) の関連付けのために使用されます. VRDisplay.displayName
読取専用VRDisplay
を識別するための人間が読める形式の名前を返します.VRDisplay.isConnected
読取専用VRDisplay
がコンピュータに接続されているか否かを示すBoolean
を返します.VRDisplay.isPresenting
読取専用VRDisplay
が現在コンテンツを表示中であるか否かを示すBoolean
を返します.VRDisplay.stageParameters
読取専用VRDisplay
がルームスケール体験をサポートしている場合に,ルームスケールパラメータを含んだVRStageParameters
オブジェクトを返します.
メソッド
VRDisplay.getEyeParameters()
- 指定した側の眼のパラメータを含む
VREyeParameters
オブジェクトを返します. VRDisplay.getLayers()
VRDisplay
に表示中のレイヤーを返します.VRDisplay.getPose()
- 現在のフレームが実際に描画される時点の未来の
VRDisplay
の予測ポーズを決めるVRPose
オブジェクトを返します. VRDisplay.getImmediatePose()
- (予測なしの)
VRDisplay
のポーズを決めるVRPose
オブジェクトを返します. VRDisplay.resetPose()
- 現在の
VRPose.position
とVRPose.orientation
を"原点/ゼロ"位置の値として扱うように,VRDisplay
のポーズをリセットします. VRDisplay.cancelAnimationFrame()
Window.cancelAnimationFrame
の特別な実装で,VRDisplay.requestAnimationFrame()
を未登録状態にすることをコールバック可能にしています.VRDisplay.requestAnimationFrame()
Window.requestAnimationFrame
の特別な実装で,VRDisplay
の新しいフレームが描画される際に毎回呼出されるコールバック関数を持っています.VRDisplay.requestPresent()
VRDisplay
へのシーン描画を開始します.VRDisplay.exitPresent()
VRDisplay
のシーン描画を停止します.VRDisplay.submitFrame()
VRLayer
の現在の状態をキャプチャし,VRDisplay
上にそれを表示します.-
非推奨のメソッド
VRDisplay.getPose()
- Returns a
VRPose
object defining the future predicted pose of theVRDisplay
as it will be when the current frame is actually presented. This method is deprecated — instead, you should useVRDisplay.getFrameData()
, which also provides aVRPose
object. -
廃止されたメソッド
VRDisplay.getImmediatePose()
- Returns a
VRPose
object defining the current pose of theVRDisplay
, with no prediction applied. This is no longer needed, and has been removed from the spec. VRDisplay.hardwareUnitId
- Returns a
DOMString
defining the shared ID of the display, and any other devices that are part of that hardware set (e.g. controllers). This is no longer needed, and has been removed from the spec. Displays now useVRDisplay.displayId
, and corresponsing controllers will now return the same ID underGamepad.displayId
.
例
if(navigator.getVRDisplays) { console.log('WebVR 1.1 supported'); // Then get the displays attached to the computer navigator.getVRDisplays().then(function(displays) { // If a display is available, use it to present the scene if(displays.length > 0) { vrDisplay = displays[0]; // Now we have our VRDisplay object and can do what we want with it } }); }
Note: この完全なコードは raw-webgl-example で確認できます。
仕様
仕様 | ステータス | 備考 |
---|---|---|
Unknown VRDisplay の定義 |
不明 | 初回定義 |
ブラウザー実装状況
BCD tables only load in the browser
参照
- WebVR API homepage.
- MozVr.com — Mozilla VRチームのデモ,ダウンロード,その他のリソース.