All Projects → immersive-web → Webvr Polyfill

immersive-web / Webvr Polyfill

Licence: apache-2.0
Use WebVR today, without requiring a special browser build.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Webvr Polyfill

Webxr Polyfill
Use the WebXR Device API today, providing fallbacks to native WebVR 1.1 and Cardboard
Stars: ✭ 251 (-81.31%)
Mutual labels:  polyfill, webvr, webxr
360WebPlayer
The easiest way to stream 360 videos and pictures on your website or blog.
Stars: ✭ 31 (-97.69%)
Mutual labels:  webvr, webxr
cardboard-vr-display
A JavaScript implementation of a WebVR 1.1 VRDisplay
Stars: ✭ 84 (-93.75%)
Mutual labels:  polyfill, webvr
Moonrider
🌕🏄🏿 Surf the musical road among the stars. Side project built by two people in a few months to demonstrate WebXR.
Stars: ✭ 292 (-78.26%)
Mutual labels:  webvr, webxr
aframe-react
React library for A-frame
Stars: ✭ 58 (-95.68%)
Mutual labels:  webvr, webxr
spacesvr
A standardized reality for the future of the 3D Web.
Stars: ✭ 135 (-89.95%)
Mutual labels:  webvr, webxr
webvr-polyfill-dpdb
An up-to-date Device Parameter Database for the WebVR Polyfill
Stars: ✭ 29 (-97.84%)
Mutual labels:  polyfill, webvr
Babylon.js
Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework.
Stars: ✭ 15,479 (+1052.57%)
Mutual labels:  webvr, webxr
Ideaspace
😎 Create interactive 3D and VR web experiences for desktop, mobile & VR devices
Stars: ✭ 344 (-74.39%)
Mutual labels:  webvr, webxr
Engine
Fast and lightweight JavaScript game engine built on WebGL and glTF
Stars: ✭ 6,890 (+413.03%)
Mutual labels:  webvr, webxr
Networked Aframe
A web framework for building multi-user virtual reality experiences.
Stars: ✭ 803 (-40.21%)
Mutual labels:  webvr, webxr
Webxr Webpack Boilerplate
Starter Kit for building rich, immersive WebXR projects (featuring A-Frame) PWA with Webpack and SASS
Stars: ✭ 48 (-96.43%)
Mutual labels:  webvr, webxr
Webar Article
WebAR-Article is a responsive and information rich website that is progressively enhanced with Augmented Reality content exposed through experimental web technologies.
Stars: ✭ 225 (-83.25%)
Mutual labels:  webvr, webxr
webvrrocks
Your guide to Virtual Reality in the browser.
Stars: ✭ 116 (-91.36%)
Mutual labels:  webvr, webxr
Three.vrcontroller
Support hand controllers for Oculus, Vive, Windows Mixed Reality, Daydream, GearVR, and more by adding VRController to your existing Three.js-based WebVR project.
Stars: ✭ 213 (-84.14%)
Mutual labels:  webvr, webxr
MixedRealityResources
Mixed Reality related resources
Stars: ✭ 190 (-85.85%)
Mutual labels:  webvr, webxr
Remixvr
RemixVR is a tool for collaboratively building customisable VR experiences.
Stars: ✭ 129 (-90.39%)
Mutual labels:  webvr, webxr
Unity Webxr Export
Develop and export WebXR experiences using Unity WebGL
Stars: ✭ 130 (-90.32%)
Mutual labels:  webvr, webxr
Three Mesh Bvh
A BVH implementation to speed up raycasting against three.js meshes.
Stars: ✭ 302 (-77.51%)
Mutual labels:  webvr, webxr
Exokit
Native VR/AR/XR engine for JavaScript 🦖
Stars: ✭ 809 (-39.76%)
Mutual labels:  webvr, webxr

WebVR Polyfill

Build Status Build Status

A JavaScript implementation of the WebVR spec. This project ensures your WebVR content works on any platform, whether or not the browser/device has native WebVR support, or when there are inconsistencies in implementation.

Take a look at basic WebVR samples that use this polyfill.

Installing

Script

Download the build at build/webvr-polyfill.js and include it as a script tag, or use a CDN. You can also use the minified file in the same location as webvr-polyfill.min.js.

  <script src='webvr-polyfill.js'></script>
  <!-- or use a link to a CDN -->
  <script src='https://cdn.jsdelivr.net/npm/[email protected]/build/webvr-polyfill.js'></script>

npm

If you're using a build tool like browserify or webpack, install it via npm.

$ npm install --save webvr-polyfill

Using

Instructions for using versions >=0.10.0. For <=0.9.x versions, see 0.9.40 tag.

The webvr-polyfill exposes a single constructor, WebVRPolyfill that takes an object for configuration. See full configuration options at src/config.js.

Be sure to instantiate the polyfill before calling any of your VR code! The polyfill needs to patch the API if it does not exist so your content code can assume that the WebVR API will just work.

If using script tags, a WebVRPolyfill global constructor will exist.

var polyfill = new WebVRPolyfill();

In a modular ES6 world, import and instantiate the constructor similarly.

import WebVRPolyfill from 'webvr-polyfill';
const polyfill = new WebVRPolyfill();

Here's an example of querying displays and setting up controls based on environment. Remember, you'll still need to provide controls and code to support a desktop-like experience if no native VRDisplays are found, as the CardboardVRDisplay is only on mobile. See the example.

// Polyfill always provides us with `navigator.getVRDisplays`
navigator.getVRDisplays().then(displays => {
  // If we have a native VRDisplay, or if the polyfill
  // provided us with a CardboardVRDisplay, use it
  if (displays.length) {
    vrDisplay = displays[0];
    controls = new THREE.VRControls(camera);
    vrDisplay.requestAnimationFrame(animate);
  } else {
    // If we don't have a VRDisplay, we're probably on
    // a desktop environment, so set up desktop-oriented controls
    controls = new THREE.OrbitControls(camera);
    requestAnimationFrame(animate);
  }
});

iframes

There are some concerns and caveats when embedding polyfilled WebVR content inside iframes. More information is documented in the cardboard-vr-display README.

Goals

The polyfill's goal is to provide a library so that developers can create content targeting the WebVR API without worrying about what browsers and devices their users have in a world of growing, but fragmented support.

The three main components of the polyfill are:

  • Injects a WebVR 1.1 JavaScript implementation if one does not exist
  • Patches browsers that have an incomplete or inconsistent implementation of the API
  • Provide a synthesized CardboardVRDisplay on mobile when WebVR is not supported, or if it does have native support but no native VRDisplays and PROVIDE_MOBILE_VRDISPLAY is true (default).

Performance

Performance is critical for VR. If you find your application is too sluggish, consider tweaking some of the above parameters. In particular, keeping BUFFER_SCALE at 0.5 (the default) will likely help a lot.

Developing

If you're interested in developing and contributing on the polyfill itself, you'll need to have npm installed and familiarize yourself with some commands below. For full list of commands available, see package.json scripts.

$ git clone [email protected]:immersive-web/webvr-polyfill.git
$ cd webvr-polyfill/

# Install dependencies
$ npm install

# Build uncompressed JS file
$ npm run build

# Run tests
$ npm test

# Watch src/* directory and auto-rebuild on changes
$ npm watch

Testing

Right now there are some unit tests in the configuration and logic for how things get polyfilled. Be sure to run tests before submitting any PRs, and bonus points for having new tests!

$ npm test

Due to the nature of the polyfill, be also sure to test the examples with your changes where appropriate.

Releasing a new version

For maintainers only, to cut a new release for npm, use the [npm version] command. The preversion, version and postversion npm scripts will run tests, build, add built files and tag to git, push to github, and publish the new npm version.

npm version <semverstring>

License

This program is free software for both commercial and non-commercial use, distributed under the Apache 2.0 License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].