LoginSignup
7
5

More than 5 years have passed since last update.

iOS SafariでReactVRを二眼モード

Last updated at Posted at 2017-11-25

webvr-polyfill を使うとiOSブラウザでも確認できる模様.
https://github.com/googlevr/webvr-polyfill

プロジェクトルートでwebvr-polyfillをinstall

npm install -save webvr-polyfill

webvr-polyfillをimport

client.js
// Auto-generated content.
// This file contains the boilerplate to set up your React app.
// If you want to modify your application, start in "index.vr.js"

// Auto-generated content.
import {VRInstance} from 'react-vr-web';
import 'webvr-polyfill';

initにWebVRPolyfill.InstallWebVRSpecShim();の一行を追加

client.js
function init(bundle, parent, options) {
  WebVRPolyfill.InstallWebVRSpecShim();
  const vr = new VRInstance(bundle, 'rvr_sample', parent, {
    // Add custom options here
    ...options,
  });
  vr.render = function() {
    // Any custom behavior you want to perform on each frame goes here
  };
  // Begin the animation loop
  vr.start();
  return vr;
}

デプロイして実機確認

IMG_7735.PNG

Cardboardのインストラクションが表示されれば成功.
画面縦向きのロックがされている場合は外して,横向きにすると

IMG_7736.PNG
バレルディストーションがかかった二眼モードに移行できます.

iOS Safari, Chromeにて確認.
ChromeだとURLバーが表示されるのでデフォルトフルスクリーンになるSafariがいいかも.

demo

ref

7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5