瀏覽代碼

align code of clampLength to setLength

Mugen87 10 年之前
父節點
當前提交
c4c85e8883
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 2 2
      src/math/Vector2.js
  2. 2 2
      src/math/Vector3.js

+ 2 - 2
src/math/Vector2.js

@@ -296,9 +296,9 @@ THREE.Vector2.prototype = {
 
 		var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
 
-		if ( newLength !== oldLength ) {
+		if ( oldLength !== 0 && newLength !== oldLength ) {
 
-			this.divideScalar( oldLength ).multiplyScalar( newLength );
+			this.multiplyScalar( newLength / oldLength );
 
 		}
 

+ 2 - 2
src/math/Vector3.js

@@ -526,9 +526,9 @@ THREE.Vector3.prototype = {
 
 		var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
 
-		if ( newLength !== oldLength ) {
+		if ( oldLength !== 0 && newLength !== oldLength ) {
 
-			this.divideScalar( oldLength ).multiplyScalar( newLength );
+			this.multiplyScalar( newLength / oldLength );
 
 		}
 

粤ICP备19079148号