@@ -15,9 +15,6 @@ THREE.VREffect = function ( renderer, onError ) {
15
15
var eyeTranslationL = new THREE . Vector3 ( ) ;
16
16
var eyeTranslationR = new THREE . Vector3 ( ) ;
17
17
var renderRectL , renderRectR ;
18
- var headMatrix = new THREE . Matrix4 ( ) ;
19
- var headToEyeMatrixL = new THREE . Matrix4 ( ) ;
20
- var headToEyeMatrixR = new THREE . Matrix4 ( ) ;
21
18
22
19
var frameData = null ;
23
20
if ( 'VRFrameData' in window ) {
@@ -292,6 +289,10 @@ THREE.VREffect = function ( renderer, onError ) {
292
289
camera . matrixWorld . decompose ( cameraL . position , cameraL . quaternion , cameraL . scale ) ;
293
290
camera . matrixWorld . decompose ( cameraR . position , cameraR . quaternion , cameraR . scale ) ;
294
291
292
+ var scale = this . scale ;
293
+ cameraL . translateOnAxis ( eyeTranslationL , scale ) ;
294
+ cameraR . translateOnAxis ( eyeTranslationR , scale ) ;
295
+
295
296
if ( vrDisplay . getFrameData ) {
296
297
297
298
vrDisplay . depthNear = camera . near ;
@@ -302,23 +303,12 @@ THREE.VREffect = function ( renderer, onError ) {
302
303
cameraL . projectionMatrix . elements = frameData . leftProjectionMatrix ;
303
304
cameraR . projectionMatrix . elements = frameData . rightProjectionMatrix ;
304
305
305
- getHeadToEyeMatrices ( frameData ) ;
306
-
307
- cameraL . updateMatrix ( ) ;
308
- cameraL . applyMatrix ( headToEyeMatrixL ) ;
309
-
310
- cameraR . updateMatrix ( ) ;
311
- cameraR . applyMatrix ( headToEyeMatrixR ) ;
312
-
313
306
} else {
314
307
315
308
cameraL . projectionMatrix = fovToProjection ( eyeParamsL . fieldOfView , true , camera . near , camera . far ) ;
316
309
cameraR . projectionMatrix = fovToProjection ( eyeParamsR . fieldOfView , true , camera . near , camera . far ) ;
317
310
318
- var scale = this . scale ;
319
- cameraL . translateOnAxis ( eyeTranslationL , scale ) ;
320
- cameraR . translateOnAxis ( eyeTranslationR , scale ) ;
321
-
311
+
322
312
}
323
313
324
314
// render left eye
@@ -386,42 +376,6 @@ THREE.VREffect = function ( renderer, onError ) {
386
376
387
377
//
388
378
389
- var poseOrientation = new THREE . Quaternion ( ) ;
390
- var posePosition = new THREE . Vector3 ( ) ;
391
-
392
- function getHeadToEyeMatrices ( frameData ) {
393
-
394
- // Compute the matrix for the position of the head based on the pose
395
- if ( frameData . pose . orientation ) {
396
-
397
- poseOrientation . fromArray ( frameData . pose . orientation ) ;
398
- headMatrix . makeRotationFromQuaternion ( poseOrientation ) ;
399
-
400
- } else {
401
-
402
- headMatrix . identity ( ) ;
403
-
404
- }
405
-
406
- if ( frameData . pose . position ) {
407
-
408
- posePosition . fromArray ( frameData . pose . position ) ;
409
- headMatrix . setPosition ( posePosition ) ;
410
-
411
- }
412
-
413
- // Take the view matricies and multiply them by the head matrix, which
414
- // leaves only the head-to-eye transform.
415
- headToEyeMatrixL . fromArray ( frameData . leftViewMatrix ) ;
416
- headToEyeMatrixL . premultiply ( headMatrix ) ;
417
- headToEyeMatrixL . getInverse ( headToEyeMatrixL ) ;
418
-
419
- headToEyeMatrixR . fromArray ( frameData . rightViewMatrix ) ;
420
- headToEyeMatrixR . premultiply ( headMatrix ) ;
421
- headToEyeMatrixR . getInverse ( headToEyeMatrixR ) ;
422
-
423
- }
424
-
425
379
function fovToNDCScaleOffset ( fov ) {
426
380
427
381
var pxscale = 2.0 / ( fov . leftTan + fov . rightTan ) ;
0 commit comments