このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

VRDisplay.isPresenting

Deprecated

Avoid using this feature in new projects. Development of the WebVR API halted in favor of WebXR. This feature may be a candidate for removal from web standards or browsers.

Consider using the following features instead: WebXR.

isPresentingVRDisplay インターフェイスの読み取り専用プロパティで、 VRDisplay が現在コンテンツを表示中かどうかを示す論理値を返します。

メモ: このプロパティは、古い WebVR API の一部でした。 WebXR Device APIに置き換えられました。

論理値です。 true の場合はそのディスプレイが表示中であることを意味します。 false はそうではないことを示します。

js
function onVRExitPresent() {
  // No sense in exiting presentation if we're not actually presenting.
  // (This may happen if we get an event like vrdisplaydeactivate when
  // we weren't presenting.)
  if (!vrDisplay.isPresenting) return;
  vrDisplay.exitPresent().then(
    function () {
      // Nothing to do because we're handling things in onVRPresentChange.
    },
    function (err) {
      var errMsg = "exitPresent failed.";
      if (err && err.message) {
        errMsg += "<br/>" + err.message;
      }
      VRSamplesUtil.addError(errMsg, 2000);
    },
  );
}

メモ: このコードスニペットは Google's VR Presentation demo から取ったものです。

仕様書

このインターフェイスは、古い WebVR API の一部でしたが、 WebXR Device API に置き換えられました。標準化される予定はありません。

すべてのブラウザーが新しい WebXR API を実装するまで、すべてのブラウザーで動作する WebXR アプリケーションを開発するには、A-FrameBabylon.jsThree.js などのフレームワークを利用したり、ポリフィルを利用したりすると良いでしょう [1]

ブラウザーの互換性

関連情報