VRLayerInit.source
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
VRLayerInit
インターフェイス(ディクショナリ)の source
プロパティは、 VRDisplay
によってコンテンツが表示されるキャンバスを定義します。
構文
var myVRLayerInit = { };
myVRLayerInit.source = myCanvas;
値
HTMLCanvasElement
または OffscreenCanvas
オブジェクト。
例
// currently returns an empty array
var layers = vrDisplay.getLayers();
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];
console.log('Display found');
// Starting the presentation when the button is clicked: It can only be called in response to a user gesture
btn.addEventListener('click', function() {
vrDisplay.requestPresent([{ source: canvas }]).then(function() {
console.log('Presenting to WebVR display');
// Here it returns an array of VRLayerInit objects
var layers = vrDisplay.getLayers();
...
});
});
}
});
}
VRLayerInit
objects look something like this:
{
leftBounds : [ ... ],
rightBounds: [ ... ],
source: canvasReference
}
Note: The canvasReference
refers to the <canvas>
element itself, not the WebGL context associated with the canvas. The other two members are arrays
仕様
仕様 | ステータス | 備考 |
---|---|---|
WebVR 1.1 source の定義 |
ドラフト | 初回定義 |
ブラウザー実装状況
No compatibility data found for api.VRLayerInit.source
.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.
関連項目
- WebVR API homepage
- MozVr.com — demos, downloads, and other resources from the Mozilla VR team.