--- title: VRLayer slug: Web/API/VRLayerInit translation_of: Web/API/VRLayerInit original_slug: Web/API/VRLayer --- <div>{{APIRef("WebVR API")}}{{SeeCompatTable}}</div> <p><a href="/ja/docs/Web/API/WebVR_API">WebVR API</a> の <strong><code>VRLayer</code></strong> インターフェイス (ディクショナリ)は,VRHMDへ表示したいコンテンツレイヤー( {{domxref("HTMLCanvasElement")}} または {{domxref("OffscreenCanvas")}})を表します。</p> <p>{{domxref("VRDisplay.requestPresent()")}} メソッドを使うことでレイヤーを表示することができます。</p> <h2 id="プロパティ">プロパティ</h2> <dl> <dt>{{domxref("VRLayer.leftBounds")}}</dt> <dd>{{domxref("VRDisplay")}} に表示されるキャンバスの左側テクスチャ境界を定義します。</dd> <dt>{{domxref("VRLayer.rightBounds")}}</dt> <dd>{{domxref("VRDisplay")}} に表示されるキャンバスの右側テクスチャ境界を定義します。</dd> <dt>{{domxref("VRLayer.source")}}</dt> <dd>{{domxref("VRDisplay")}} に表示されるコンテンツの対象となるキャンバスを定義します。</dd> </dl> <h2 id="例">例</h2> <pre class="notranslate">// 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(); ... }); }); } }); }</pre> <p>{{domxref("VRLayerInit")}} objects look something like this:</p> <pre class="notranslate">{ leftBounds : [ ... ], rightBounds: [ ... ], source: <em>canvasReference</em> }</pre> <div class="blockIndicator note"> <p><strong>Note</strong>: The <code>canvasReference</code> refers to the {{htmlelement("canvas")}} element itself, not the WebGL context associated with the canvas. The other two members are arrays</p> </div> <h2 id="仕様">仕様</h2> <table class="standard-table"> <tbody> <tr> <th scope="col">仕様</th> <th scope="col">ステータス</th> <th scope="col">備考</th> </tr> <tr> <td>{{SpecName('WebVR', '#interface-vrlayer', 'VRLayer')}}</td> <td>{{Spec2('WebVR')}}</td> <td>初回定義</td> </tr> </tbody> </table> <h2 id="ブラウザの互換性">ブラウザの互換性</h2> <p>{{Compat("api.VRLayerInit")}}</p> <div id="compat-mobile"></div> <h2 id="参照">参照</h2> <ul> <li><a href="/ja/docs/Web/API/WebVR_API">WebVR API homepage</a>.</li> <li><a href="http://mozvr.com/">MozVr.com</a> — Mozilla VRチームのデモ,ダウンロード,その他のリソース.</li> </ul>