@@ -11,7 +11,7 @@ var APP = {
11
11
var loader = new THREE . ObjectLoader ( ) ;
12
12
var camera , scene , renderer ;
13
13
14
- var vr , controls , effect ;
14
+ var controls , effect , cameraVR , isVR ;
15
15
16
16
var events = { } ;
17
17
@@ -22,7 +22,7 @@ var APP = {
22
22
23
23
this . load = function ( json ) {
24
24
25
- vr = json . project . vr ;
25
+ isVR = json . project . vr ;
26
26
27
27
renderer = new THREE . WebGLRenderer ( { antialias : true } ) ;
28
28
renderer . setClearColor ( 0x000000 ) ;
@@ -115,22 +115,13 @@ var APP = {
115
115
camera . aspect = this . width / this . height ;
116
116
camera . updateProjectionMatrix ( ) ;
117
117
118
- if ( vr === true ) {
118
+ if ( isVR === true ) {
119
119
120
- if ( camera . parent === null ) {
120
+ cameraVR = new THREE . PerspectiveCamera ( ) ;
121
+ cameraVR . projectionMatrix = camera . projectionMatrix ;
122
+ camera . add ( cameraVR ) ;
121
123
122
- // camera needs to be in the scene so camera2 matrix updates
123
-
124
- scene . add ( camera ) ;
125
-
126
- }
127
-
128
- var camera2 = camera . clone ( ) ;
129
- camera . add ( camera2 ) ;
130
-
131
- camera = camera2 ;
132
-
133
- controls = new THREE . VRControls ( camera ) ;
124
+ controls = new THREE . VRControls ( cameraVR ) ;
134
125
effect = new THREE . VREffect ( renderer ) ;
135
126
136
127
if ( WEBVR . isAvailable ( ) === true ) {
@@ -195,10 +186,12 @@ var APP = {
195
186
196
187
}
197
188
198
- if ( vr === true ) {
189
+ if ( isVR === true ) {
190
+
191
+ camera . updateMatrixWorld ( ) ;
199
192
200
193
controls . update ( ) ;
201
- effect . render ( scene , camera ) ;
194
+ effect . render ( scene , cameraVR ) ;
202
195
203
196
} else {
204
197
0 commit comments