提交 75c9b190 编写于 作者: B Brandon Jones 提交者: Mr.doob

Partial revert of some WebVR 1.1 changes (#9709)

They didn't produce correct eye translations in all cases (specifically
standing scenes.) This reverted version may not be 100% accurate on
future hardware (if the eyes have a rotation component, for example) but
it's correct on all current WebVR implementations. That's better than
blatantly wrong in some cases.

Use of the WebVR-provided projection matricies has been left in, since
that was working correctly.
上级 fcf11a2a
......@@ -15,9 +15,6 @@ THREE.VREffect = function ( renderer, onError ) {
var eyeTranslationL = new THREE.Vector3();
var eyeTranslationR = new THREE.Vector3();
var renderRectL, renderRectR;
var headMatrix = new THREE.Matrix4();
var headToEyeMatrixL = new THREE.Matrix4();
var headToEyeMatrixR = new THREE.Matrix4();
var frameData = null;
if ( 'VRFrameData' in window ) {
......@@ -293,6 +290,10 @@ THREE.VREffect = function ( renderer, onError ) {
camera.matrixWorld.decompose( cameraL.position, cameraL.quaternion, cameraL.scale );
camera.matrixWorld.decompose( cameraR.position, cameraR.quaternion, cameraR.scale );
var scale = this.scale;
cameraL.translateOnAxis( eyeTranslationL, scale );
cameraR.translateOnAxis( eyeTranslationR, scale );
if ( vrDisplay.getFrameData ) {
vrDisplay.depthNear = camera.near;
......@@ -303,23 +304,12 @@ THREE.VREffect = function ( renderer, onError ) {
cameraL.projectionMatrix.elements = frameData.leftProjectionMatrix;
cameraR.projectionMatrix.elements = frameData.rightProjectionMatrix;
getHeadToEyeMatrices( frameData );
cameraL.updateMatrix();
cameraL.applyMatrix( headToEyeMatrixL );
cameraR.updateMatrix();
cameraR.applyMatrix( headToEyeMatrixR );
} else {
cameraL.projectionMatrix = fovToProjection( eyeParamsL.fieldOfView, true, camera.near, camera.far );
cameraR.projectionMatrix = fovToProjection( eyeParamsR.fieldOfView, true, camera.near, camera.far );
var scale = this.scale;
cameraL.translateOnAxis( eyeTranslationL, scale );
cameraR.translateOnAxis( eyeTranslationR, scale );
}
// render left eye
......@@ -387,42 +377,6 @@ THREE.VREffect = function ( renderer, onError ) {
//
var poseOrientation = new THREE.Quaternion();
var posePosition = new THREE.Vector3();
function getHeadToEyeMatrices( frameData ) {
// Compute the matrix for the position of the head based on the pose
if ( frameData.pose.orientation ) {
poseOrientation.fromArray( frameData.pose.orientation );
headMatrix.makeRotationFromQuaternion( poseOrientation );
} else {
headMatrix.identity();
}
if ( frameData.pose.position ) {
posePosition.fromArray( frameData.pose.position );
headMatrix.setPosition( posePosition );
}
// Take the view matricies and multiply them by the head matrix, which
// leaves only the head-to-eye transform.
headToEyeMatrixL.fromArray( frameData.leftViewMatrix );
headToEyeMatrixL.premultiply( headMatrix );
headToEyeMatrixL.getInverse( headToEyeMatrixL );
headToEyeMatrixR.fromArray( frameData.rightViewMatrix );
headToEyeMatrixR.premultiply( headMatrix );
headToEyeMatrixR.getInverse( headToEyeMatrixR );
}
function fovToNDCScaleOffset( fov ) {
var pxscale = 2.0 / ( fov.leftTan + fov.rightTan );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册