Overview
As long as I understand that this is an old question, and there is a lot more information about it now, I will send an answer anyway, since the previously published answers are not updated.
I created a basic plunker that illustrates what you need to do to get the three.js, webvr, and oculus commands working. Note. I couldn’t fully work in full screen mode under the plunger, but if you run the plunk with oculus Rift (OR) in mozilla nightly build you should see that head rotation works. You can get the full VR experience if you run it outside the plunker.
I think another good reference app is RiftSketch . This is what I first used to learn how to get OR to work in a browser (this is actually an application written by the original poster of this question).
Here are the relevant fragments of webvr that will differ from the standard three.js application:
this.controls = new THREE.VRControls(this.camera); this.effect = new THREE.VREffect(this.renderer); this.effect.setSize(this.width, this.height); this.vrManager = new WebVRManager(this.renderer, this.effect);
and in the render function:
this.controls.update(); this.renderer.render(this.scene, this.camera); if (this.vrManager.isVRMode()) { this.effect.render(this.scene, this.camera); } else { this.renderer.render(this.scene, this.camera); }
Required Modules
Another thing you need to do is provide the following four libraries (in addition to three.js):
- VRControls.js
- VREffect.js
- webvr-manager.js
- webvr- polyfill.js
VRControls.js and VREffect.js are available from the three.js library under the examples / js / controls and examples / js / effects sections respectively.
Update: I recommend that you get all the libraries from the webvr-templateplate github , since the three.js doesn't seem to have the latest versions.
The other two can be obtained by webvr-template github.
You can directly access the webvr API as described here , but I think it’s much easier to use the support libraries.
Final words
You basically do not need to deal with the Oculus Rift SDK. The only people who need to directly access the SDK API are Unity engine developers and Mozilla API developers.
WebVR creates a common API that attempts to provide a standardized interface for all HMD devices, such as Cardboard, OR and (possibly in the future) Samsung, HTC Vive, leap motion, etc. If you decide to use VRControls and VREffects, you have an additional layer API to make it even easier. This is basically just a bunch of template. After all, I don’t understand that you really understand what really happens behind the scenes. You basically just install it once and never touch it again.
Once you have OR support, then development for your application is pretty much like any other three.js application.