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.