Giter VIP home page Giter VIP logo

webvr-boilerplate's Introduction

WebVR Boilerplate

A starting point for web-based VR experiences that work well in both Google Cardboard and Oculus Rift. Also provides a good fallback for experiencing the same content without requiring a VR device.

Uses the webvr-polyfill project to provide VR support even if no VR device is available. This gives good fallbacks for Cardboard, mobile devices and desktop devices.

What's inside...

THREE.js three.min.js

  • WebGL helper library that greatly simplifies 3D graphics.

VRControls VRControls.js

  • THREE.js controls which take advantage of the WebVR API.
  • Usually attached to the THREE.Camera to look around the scene.

VREffect VREffect.js

  • THREE.js effect which renders a scene with two cameras in it.
  • Puts the two images side-by-side.

WebVR polyfill webvr-polyfill.js

  • For Cardboard rendering.
  • On mobile, supports rotation via DeviceOrientation.
  • On desktop, supports looking with the mouse or with arrow keys.

WebVR manager webvr-manager.js (lives in this repository)

  • Feature detects for WebVR (or the polyfill).
  • If WebVR is available, places an active WebVR button on the bottom.
  • Other means of getting into VR mode: double click anywhere, double tap anywhere.
  • For desktop, if an HMD is connected, goes into split-screen rendering mode. Otherwise, goes into immersive fullscreen mode (with pointer lock).
  • For mobile, goes into Cardboard side-by-side rendering mode.

TODO: Provide a configuration UI for switching modes if we guessed wrong.

Instructions

  1. Include webvr-polyfill.js in your project.
  2. Include webvr-manager.js and instantiate a WebVRManager object, passing in your VREffect instance (from the THREE.js effect library) as first argument.

For example,

var effect = new THREE.VREffect(renderer);
var mgr = new WebVRManager(effect);

For more information, see index.html, which should be well commented and self-explanatory.

Related projects

Useful resources

webvr-boilerplate's People

Contributors

borismus avatar dmitriykovalev avatar caseyyee avatar brianpeiris avatar

Watchers

James Cloos avatar Idries avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.