فهرست منبع

Editor: Fixed EditorControls so it doesn't pass the center.

Mr.doob 11 سال پیش
والد
کامیت
8dce74c776
1فایلهای تغییر یافته به همراه14 افزوده شده و 11 حذف شده
  1. 14 11
      examples/js/controls/EditorControls.js

+ 14 - 11
examples/js/controls/EditorControls.js

@@ -52,28 +52,31 @@ THREE.EditorControls = function ( object, domElement ) {
 
 
 	};
 	};
 
 
-	this.pan = function ( distance ) {
+	this.pan = function ( delta ) {
 
 
-		normalMatrix.getNormalMatrix( object.matrix );
+		var distance = object.position.distanceTo( center );
 
 
-		distance.applyMatrix3( normalMatrix );
-		distance.multiplyScalar( vector.copy( center ).sub( object.position ).length() * 0.001 );
+		delta.multiplyScalar( distance * 0.001 );
+		delta.applyMatrix3( normalMatrix.getNormalMatrix( object.matrix ) );
 
 
-		object.position.add( distance );
-		center.add( distance );
+		object.position.add( delta );
+		center.add( delta );
 
 
 		scope.dispatchEvent( changeEvent );
 		scope.dispatchEvent( changeEvent );
 
 
 	};
 	};
 
 
-	this.zoom = function ( distance ) {
+	this.zoom = function ( delta ) {
 
 
-		normalMatrix.getNormalMatrix( object.matrix );
+		var distance = object.position.distanceTo( center );
 
 
-		distance.applyMatrix3( normalMatrix );
-		distance.multiplyScalar( vector.copy( center ).sub( object.position ).length() * 0.001 );
+		delta.multiplyScalar( distance * 0.001 );
 
 
-		object.position.add( distance );
+		if ( delta.length() > distance ) return;
+
+		delta.applyMatrix3( normalMatrix.getNormalMatrix( object.matrix ) );
+
+		object.position.add( delta );
 
 
 		scope.dispatchEvent( changeEvent );
 		scope.dispatchEvent( changeEvent );