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

Merge pull request #12651 from dmarcos/headObject

Add the ability to specify an alternative Object3D to the camera to apply the pose coming from a VRDevice
......@@ -14,6 +14,8 @@ function WebVRManager( renderer ) {
var device = null;
var frameData = null;
var poseTarget = null;
if ( typeof window !== 'undefined' && 'VRFrameData' in window ) {
frameData = new window.VRFrameData();
......@@ -85,6 +87,12 @@ function WebVRManager( renderer ) {
};
this.setPoseTarget = function ( object ) {
if ( object !== undefined ) poseTarget = object;
};
this.getCamera = function ( camera ) {
if ( device === null ) return camera;
......@@ -97,24 +105,35 @@ function WebVRManager( renderer ) {
//
var pose = frameData.pose;
var poseObject;
if ( poseTarget !== null ) {
poseObject = poseTarget;
} else {
poseObject = camera;
}
if ( pose.position !== null ) {
camera.position.fromArray( pose.position );
poseObject.position.fromArray( pose.position );
} else {
camera.position.set( 0, 0, 0 );
poseObject.position.set( 0, 0, 0 );
}
if ( pose.orientation !== null ) {
camera.quaternion.fromArray( pose.orientation );
poseObject.quaternion.fromArray( pose.orientation );
}
camera.updateMatrixWorld();
poseObject.updateMatrixWorld();
var stageParameters = device.stageParameters;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册