提交 273241e1 编写于 作者: E Eric Haines 提交者: Mr.doob

Always use clientHeight

上级 b5fdfca9
......@@ -164,20 +164,14 @@ THREE.OrbitControls = function ( object, domElement ) {
// half of the fov is center to top of screen
targetDistance *= Math.tan( (scope.object.fov/2) * Math.PI / 180.0 );
// we actually don't use screenWidth, since perspective camera is fixed to screen height
var height = ( scope.domElement.height !== undefined ) ?
scope.domElement.height : scope.domElement.body.clientHeight;
scope.panLeft( 2 * delta.x * targetDistance / height );
scope.panUp( 2 * delta.y * targetDistance / height );
scope.panLeft( 2 * delta.x * targetDistance / scope.domElement.body.clientHeight );
scope.panUp( 2 * delta.y * targetDistance / scope.domElement.body.clientHeight );
}
else if ( scope.object.top !== undefined )
{
// orthographic
var width = ( scope.domElement.width !== undefined ) ?
scope.domElement.width : scope.domElement.body.clientWidth;
var height = ( scope.domElement.height !== undefined ) ?
scope.domElement.height : scope.domElement.body.clientHeight;
scope.panLeft( delta.x * (scope.object.right - scope.object.left) / width );
scope.panUp( delta.y * (scope.object.top - scope.object.bottom) / height );
scope.panLeft( delta.x * (scope.object.right - scope.object.left) / scope.domElement.body.clientWidth );
scope.panUp( delta.y * (scope.object.top - scope.object.bottom) / scope.domElement.body.clientHeight );
}
else
{
......@@ -328,14 +322,10 @@ THREE.OrbitControls = function ( object, domElement ) {
rotateEnd.set( event.clientX, event.clientY );
rotateDelta.subVectors( rotateEnd, rotateStart );
var width = ( scope.domElement.width !== undefined ) ?
scope.domElement.width : scope.domElement.body.clientWidth;
var height = ( scope.domElement.height !== undefined ) ?
scope.domElement.height : scope.domElement.body.clientHeight;
// rotating across whole screen goes 360 degrees around
scope.rotateLeft( 2 * Math.PI * rotateDelta.x / width * scope.rotateSpeed );
scope.rotateLeft( 2 * Math.PI * rotateDelta.x / scope.domElement.body.clientWidth * scope.rotateSpeed );
// rotating up and down along whole screen attempts to go 360, but limited to 180
scope.rotateUp( 2 * Math.PI * rotateDelta.y / height * scope.rotateSpeed );
scope.rotateUp( 2 * Math.PI * rotateDelta.y / scope.domElement.body.clientHeight * scope.rotateSpeed );
rotateStart.copy( rotateEnd );
......@@ -507,14 +497,10 @@ THREE.OrbitControls = function ( object, domElement ) {
rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
rotateDelta.subVectors( rotateEnd, rotateStart );
var width = ( scope.domElement.width !== undefined ) ?
scope.domElement.width : scope.domElement.body.clientWidth;
var height = ( scope.domElement.height !== undefined ) ?
scope.domElement.height : scope.domElement.body.clientHeight;
// rotating across whole screen goes 360 degrees around
scope.rotateLeft( 2 * Math.PI * rotateDelta.x / width * scope.rotateSpeed );
scope.rotateLeft( 2 * Math.PI * rotateDelta.x / scope.domElement.body.clientWidth * scope.rotateSpeed );
// rotating up and down along whole screen attempts to go 360, but limited to 180
scope.rotateUp( 2 * Math.PI * rotateDelta.y / height * scope.rotateSpeed );
scope.rotateUp( 2 * Math.PI * rotateDelta.y / scope.domElement.body.clientHeight * scope.rotateSpeed );
rotateStart.copy( rotateEnd );
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册