|
@@ -11,7 +11,7 @@ var APP = {
|
|
|
var loader = new THREE.ObjectLoader();
|
|
|
var camera, scene, renderer;
|
|
|
|
|
|
- var vr, controls, effect;
|
|
|
+ var controls, effect, cameraVR, isVR;
|
|
|
|
|
|
var events = {};
|
|
|
|
|
@@ -22,7 +22,7 @@ var APP = {
|
|
|
|
|
|
this.load = function ( json ) {
|
|
|
|
|
|
- vr = json.project.vr;
|
|
|
+ isVR = json.project.vr;
|
|
|
|
|
|
renderer = new THREE.WebGLRenderer( { antialias: true } );
|
|
|
renderer.setClearColor( 0x000000 );
|
|
@@ -115,22 +115,13 @@ var APP = {
|
|
|
camera.aspect = this.width / this.height;
|
|
|
camera.updateProjectionMatrix();
|
|
|
|
|
|
- if ( vr === true ) {
|
|
|
+ if ( isVR === true ) {
|
|
|
|
|
|
- if ( camera.parent === null ) {
|
|
|
+ cameraVR = new THREE.PerspectiveCamera();
|
|
|
+ cameraVR.projectionMatrix = camera.projectionMatrix;
|
|
|
+ camera.add( cameraVR );
|
|
|
|
|
|
- // camera needs to be in the scene so camera2 matrix updates
|
|
|
-
|
|
|
- scene.add( camera );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- var camera2 = camera.clone();
|
|
|
- camera.add( camera2 );
|
|
|
-
|
|
|
- camera = camera2;
|
|
|
-
|
|
|
- controls = new THREE.VRControls( camera );
|
|
|
+ controls = new THREE.VRControls( cameraVR );
|
|
|
effect = new THREE.VREffect( renderer );
|
|
|
|
|
|
if ( WEBVR.isAvailable() === true ) {
|
|
@@ -195,10 +186,12 @@ var APP = {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( vr === true ) {
|
|
|
+ if ( isVR === true ) {
|
|
|
+
|
|
|
+ camera.updateMatrixWorld();
|
|
|
|
|
|
controls.update();
|
|
|
- effect.render( scene, camera );
|
|
|
+ effect.render( scene, cameraVR );
|
|
|
|
|
|
} else {
|
|
|
|