未验证 提交 0c866a87 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #13414 from brianpeiris/r90-culling-fix

Fix camera transforms in VR
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册