webxr_boilerplate icon indicating copy to clipboard operation
webxr_boilerplate copied to clipboard

A toolkit for creating WebVR experiences with Aframe, Webpack and Firebase

WebVR Boilerplate

WebVR Boilerplate is a toolkit for WebVR creators to develop, build and deploy static WebVR experiences to the web. WebVR Boilerplate comes with a hot-reload webserver, the latest builds of Aframe, Aframe's best community components and a Webpack build pipeline that packages your content for Firebase Hosting. Some other features are:

  • Cross compatibility across HTC Vive, Oculus Rift/Go, Gear VR, iOS and Android devices. (Tested 6.14.18)
  • Spatial Audio, Shadows, Controllers, Teleport, Physics and Environment code examples
  • Local development server that can be viewed on external devices in realtime (helpful for debugging on iOS/Android)
  • All code is integrated into the Aframe Entity and Component system for best performance
  • Dependencies are loaded through Webpack modules and NPM

Installation

git clone https://github.com/ianpetrarca/webvr_boilerplate.git
cd webvr_boilerplate
npm install

File Structure + Descriptions

├── build                  # Webpack Production build output 
├── src                    # Source files
    ├── components         # Folder for Aframe components (JS)
    └── templates          # Folder for resuseable Aframe entities (HTML)
├── .firebaserc            # Connects your project to Firebase Hosting 
├── firebase.json          # Specifies which directory to upload to Firebase
├── package.json           # NPM 
├── webpack.config.js      # Webpack Config file for dev server/production builds

Development Stage

To spin up a localhost site, run the following command then point a WebVR friendly browser to http://localhost:8080/

npm run dev

To view the dev server on an external device find out your local IP address (Type 'ipconfig' in any terminal) and view the 8080 port. This may look like:

192.168.1.165:8080

WebVR-Boilerplate was designed for Single-Page-Applications and does not handle multiple html files without reconfiguring the webpack.config.js HTMLWebpack plugin.

Building

To build and optimze your HTML/JS run:

 npm run build

This will Webpack build your ./src folder into the ./build directory with the specifications made in the webpack.config.js file.

Deploying

WebVR-Boilerplate uses Firebase for quick and easy static-asset hosting. If you haven't already, install Firebase by running:

npm install -g firebase-tools

After installing Firebase, run init and setup a hosting connection:

firebase init 

The firebase.json file tells Firebase Hosting to use the _./build directory. Find out more about Firebase Hosting Here

Once Firebase is installed and initialized, run the following code to build and deploy your code:

npm run deploy

Credits

Aframe has an amazing community of developers, here are the people/projects that are being used in WebVR Boilerplate: