提交 c497b863 编写于 作者: K Kevin Schmidt

Brief:Switching to domElement coordinates

BUGZID:
Summary:
This switches the "screen" variable to use the domElement's dimensions & location rather
than the window.

It also removes the "radius" variable in favor of using each dimension's value (ie
width & height)
上级 1838bae4
...@@ -70,14 +70,14 @@ THREE.TrackballControls = function ( object, domElement ) { ...@@ -70,14 +70,14 @@ THREE.TrackballControls = function ( object, domElement ) {
// methods // methods
this.handleResize = function () { this.handleResize = function () {
var rect = this.domElement.getBoundingClientRect();
this.screen.width = rect.width;
this.screen.height = rect.height;
this.screen.width = window.innerWidth; this.screen.offsetLeft = rect.left;
this.screen.height = window.innerHeight; this.screen.offsetTop = rect.top;
this.screen.offsetLeft = 0;
this.screen.offsetTop = 0;
this.radius = ( this.screen.width + this.screen.height ) / 4;
}; };
...@@ -94,8 +94,8 @@ THREE.TrackballControls = function ( object, domElement ) { ...@@ -94,8 +94,8 @@ THREE.TrackballControls = function ( object, domElement ) {
this.getMouseOnScreen = function ( clientX, clientY ) { this.getMouseOnScreen = function ( clientX, clientY ) {
return new THREE.Vector2( return new THREE.Vector2(
( clientX - _this.screen.offsetLeft ) / _this.radius * 0.5, ( clientX - _this.screen.offsetLeft ) / _this.screen.width,
( clientY - _this.screen.offsetTop ) / _this.radius * 0.5 ( clientY - _this.screen.offsetTop ) / _this.screen.height
); );
}; };
...@@ -103,8 +103,8 @@ THREE.TrackballControls = function ( object, domElement ) { ...@@ -103,8 +103,8 @@ THREE.TrackballControls = function ( object, domElement ) {
this.getMouseProjectionOnBall = function ( clientX, clientY ) { this.getMouseProjectionOnBall = function ( clientX, clientY ) {
var mouseOnBall = new THREE.Vector3( var mouseOnBall = new THREE.Vector3(
( clientX - _this.screen.width * 0.5 - _this.screen.offsetLeft ) / _this.radius, ( clientX - _this.screen.width * 0.5 - _this.screen.offsetLeft ) / (_this.screen.width*.5),
( _this.screen.height * 0.5 + _this.screen.offsetTop - clientY ) / _this.radius, ( _this.screen.height * 0.5 + _this.screen.offsetTop - clientY ) / (_this.screen.height*.5),
0.0 0.0
); );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册