提交 3080578f 编写于 作者: M Mr.doob

Added hovered boolean to TransformControls. Improved Editor mouse behaviour.

上级 86f7b443
......@@ -99,16 +99,12 @@ var Viewport = function ( signals ) {
onMouseDownPosition.set( event.layerX, event.layerY );
controls.enabled = true;
if ( transformControls.hovered === false ) {
document.addEventListener( 'mousemove', onMouseMove, false );
document.addEventListener( 'mouseup', onMouseUp, false );
};
var onMouseMove = function ( event ) {
controls.enabled = true;
document.addEventListener( 'mouseup', onMouseUp, false );
controls.enabled = transformControls.active === false;
}
};
......@@ -146,7 +142,6 @@ var Viewport = function ( signals ) {
controls.enabled = false;
document.removeEventListener( 'mousemove', onMouseMove );
document.removeEventListener( 'mouseup', onMouseUp );
};
......@@ -158,7 +153,6 @@ var Viewport = function ( signals ) {
if ( intersects.length > 0 && intersects[ 0 ].object === selected ) {
controls.focus( selected );
controls.enabled = true;
}
......@@ -177,6 +171,7 @@ var Viewport = function ( signals ) {
transformControls.update();
} );
controls.enabled = false;
// signals
......
......@@ -8,11 +8,16 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
// TODO: Make non-uniform scale and rotate play nice in hierarchies
// TODO: ADD RXYZ contol
this.camera = camera;
this.domElement = ( domElement !== undefined ) ? domElement : document;
this.document = ( doc !== undefined ) ? doc : document;
this.object = undefined;
this.active = false;
this.hovered = false;
this.mode = 'translate';
this.space = 'local';
this.scale = 1;
......@@ -358,6 +363,8 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
this.detatch = function ( object ) {
this.object = undefined;
this.hide();
this.domElement.removeEventListener( 'mousedown', onMouseDown, false );
......@@ -368,6 +375,8 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
this.update = function () {
if ( this.object === undefined ) return;
this.object.updateMatrixWorld();
worldPosition.getPositionFromMatrix( this.object.matrixWorld );
worldRotation.setEulerFromRotationMatrix( tempMatrix.extractRotation(this.object.matrixWorld ));
......@@ -613,6 +622,8 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
}
scope.hovered = true;
} else if ( hovered !== null ) {
hovered.material.color.copy( hoveredColor );
......@@ -622,6 +633,8 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
scope.dispatchEvent( changeEvent );
scope.hovered = false;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册