Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// This file contains the boilerplate to execute your React app.
// If you want to modify your application's content, start in "index.js"
import {Math as VRMath, ReactInstance, Surface} from 'react-360-web';
import KeyboardModule from './react-360-keyboard/KeyboardModule';
import WebVRPolyfill from 'webvr-polyfill';
const polyfill = new WebVRPolyfill();
function init(bundle, parent, options = {}) {
const r360 = new ReactInstance(bundle, parent, {
// Add custom options here
fullScreen: true,
nativeModules: [KeyboardModule.addModule],
...options,
});
// Render your app content to the default cylinder surface
r360.renderToSurface(
r360.createRoot('Keyboard360', {
/* initial props */
}),
r360.getDefaultSurface(),
);
if (model.defaultToWebgl2 && webgl2Supported) {
result = model.canvas.getContext('webgl2'); // , options);
if (result) {
model.webgl2 = true;
vtkDebugMacro('using webgl2');
}
}
if (!result) {
vtkDebugMacro('using webgl1');
result =
model.canvas.getContext('webgl', options) ||
model.canvas.getContext('experimental-webgl', options);
}
/* eslint-disable */
const polyfill = new WebVRPolyfill({
// Ensures the polyfill is always active on mobile, due to providing
// a polyfilled CardboardVRDisplay when no native API is available,
// and also polyfilling even when the native API is available, due to
// providing a CardboardVRDisplay when no native VRDisplays exist.
PROVIDE_MOBILE_VRDISPLAY: true,
// Polyfill optimizations
DIRTY_SUBMIT_FRAME_BINDINGS: false,
BUFFER_SCALE: 0.75,
});
/* eslint-enable */
// Do we have webvr support
if (navigator.getVRDisplays) {
navigator.getVRDisplays().then((displays) => {
if (displays.length > 0) {
// take the first display for now
/*global THREE:true*/
/*global TWEEN:true*/
import './css/main.css';
import VRButton from './button';
import Router from './router';
import Gazer from './gazer';
import WebVRPolyfill from 'webvr-polyfill';
const polyfill = new WebVRPolyfill();
const $scope = {};
function create(routers, container, fov, far) {
_createRootScene(...Array.prototype.slice.call(arguments, 1));
Router.createRouter(routers);
Router.onchange = removeScene;
Router.onload = addScene;
$scope.router = Router;
}
function _createRootScene(container = document.body, fov = 70, far = 5000) {
if (!(container instanceof HTMLElement)) {
throw new Error('container is not a HTMLElement!');
}
// Initialize the scene
const scene = new THREE.Scene();
// Initialize the camera
const camera = new THREE.PerspectiveCamera(fov, window.innerWidth / window.innerHeight, 0.1, far);
import WebVRPolyfill from "webvr-polyfill";
import "./polyfill/audio.js";
if (window.Promise) {
// IE11 does not support Promise, used by WebVRPolyfill, so don't create the fill to begin with (VR won't be supported anyway).
var webvrPolyFill = new WebVRPolyfill();
}
export {ShaderLibrary} from "./shader/ShaderLibrary";
// generated by gulp
import "./../../build/tmp/shaderlib.js";
//
// root level API:
//
export {
init, destroy, start, stop,
META, capabilities,
onPreFrame, onFrame,
TextureWrapMode, TextureFilter, CullMode, StencilOp, Comparison, ElementType, BlendFactor, BlendOperation, ClearMask, InitOptions, TextureFormat, DataType, BufferUsage, CubeFace
if (this.videojsErrorsSupport_) {
player.errors({errors});
}
// IE 11 does not support enough webgl to be supported
// older safari does not support cors, so it wont work
if (videojs.browser.IE_VERSION || !utils.corsSupport) {
// if a player triggers error before 'loadstart' is fired
// video.js will reset the error overlay
this.player_.on('loadstart', () => {
this.triggerError_({code: 'web-vr-not-supported', dismiss: false});
});
return;
}
this.polyfill_ = new WebVRPolyfill({
// do not show rotate instructions
ROTATE_INSTRUCTIONS_DISABLED: true
});
this.polyfill_ = new WebVRPolyfill();
this.handleVrDisplayActivate_ = videojs.bind(this, this.handleVrDisplayActivate_);
this.handleVrDisplayDeactivate_ = videojs.bind(this, this.handleVrDisplayDeactivate_);
this.handleResize_ = videojs.bind(this, this.handleResize_);
this.animate_ = videojs.bind(this, this.animate_);
this.setProjection(this.options_.projection);
// any time the video element is recycled for ads
// we have to reset the vr state and re-init after ad
this.on(player, 'adstart', () => player.setTimeout(() => {
// if the video element was recycled for this ad
import WebVRPolyfill from 'webvr-polyfill';
const polyfill = new WebVRPolyfill();