|
@@ -4,6 +4,8 @@
|
|
|
|
|
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
|
import { Vector4 } from '../../math/Vector4.js';
|
|
|
+import { Vector3 } from '../../math/Vector3.js';
|
|
|
+import { Quaternion } from '../../math/Quaternion.js';
|
|
|
import { ArrayCamera } from '../../cameras/ArrayCamera.js';
|
|
|
import { PerspectiveCamera } from '../../cameras/PerspectiveCamera.js';
|
|
|
|
|
@@ -26,6 +28,8 @@ function WebVRManager( renderer ) {
|
|
|
}
|
|
|
|
|
|
var matrixWorldInverse = new Matrix4();
|
|
|
+ var tempQuaternion = new Quaternion();
|
|
|
+ var tempPosition = new Vector3();
|
|
|
|
|
|
var cameraL = new PerspectiveCamera();
|
|
|
cameraL.bounds = new Vector4( 0.0, 0.0, 0.5, 1.0 );
|
|
@@ -104,38 +108,42 @@ function WebVRManager( renderer ) {
|
|
|
|
|
|
//
|
|
|
|
|
|
- var pose = frameData.pose;
|
|
|
- var poseObject = poseTarget !== null ? poseTarget : camera;
|
|
|
+ var stageParameters = device.stageParameters;
|
|
|
|
|
|
- if ( pose.position !== null ) {
|
|
|
+ if ( stageParameters ) {
|
|
|
|
|
|
- poseObject.position.fromArray( pose.position );
|
|
|
+ standingMatrix.fromArray( stageParameters.sittingToStandingTransform );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- poseObject.position.set( 0, 0, 0 );
|
|
|
+ standingMatrix.makeTranslation( 0, scope.userHeight, 0 );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( pose.orientation !== null ) {
|
|
|
|
|
|
- poseObject.quaternion.fromArray( pose.orientation );
|
|
|
+ var pose = frameData.pose;
|
|
|
+ var poseObject = poseTarget !== null ? poseTarget : camera;
|
|
|
|
|
|
- }
|
|
|
+ // We want to manipulate poseObject by its position and quaternion components since users may rely on them.
|
|
|
+ poseObject.matrix.copy( standingMatrix );
|
|
|
+ poseObject.matrix.decompose( poseObject.position, poseObject.quaternion, poseObject.scale );
|
|
|
|
|
|
- var stageParameters = device.stageParameters;
|
|
|
+ if ( pose.orientation !== null ) {
|
|
|
|
|
|
- if ( stageParameters ) {
|
|
|
+ tempQuaternion.fromArray ( pose.orientation );
|
|
|
+ poseObject.quaternion.multiply( tempQuaternion );
|
|
|
|
|
|
- standingMatrix.fromArray( stageParameters.sittingToStandingTransform );
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
+ if ( pose.position !== null ) {
|
|
|
|
|
|
- standingMatrix.makeTranslation( 0, scope.userHeight, 0 );
|
|
|
+ tempQuaternion.setFromRotationMatrix( standingMatrix );
|
|
|
+ tempPosition.fromArray( pose.position );
|
|
|
+ tempPosition.applyQuaternion( tempQuaternion );
|
|
|
+ poseObject.position.add( tempPosition );
|
|
|
|
|
|
}
|
|
|
|
|
|
- poseObject.position.applyMatrix4( standingMatrix );
|
|
|
poseObject.updateMatrixWorld();
|
|
|
|
|
|
if ( device.isPresenting === false ) return camera;
|