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

Vector*: Simplified setLength(). See #7326.

上级 071418ab
...@@ -379,15 +379,9 @@ THREE.Vector2.prototype = { ...@@ -379,15 +379,9 @@ THREE.Vector2.prototype = {
}, },
setLength: function ( l ) { setLength: function ( length ) {
var oldLength = this.length(); this.multiplyScalar( length / this.length() );
if ( oldLength !== 0 && l !== oldLength ) {
this.multiplyScalar( l / oldLength );
}
return this; return this;
......
...@@ -584,15 +584,9 @@ THREE.Vector3.prototype = { ...@@ -584,15 +584,9 @@ THREE.Vector3.prototype = {
}, },
setLength: function ( l ) { setLength: function ( length ) {
var oldLength = this.length(); this.multiplyScalar( length / this.length() );
if ( oldLength !== 0 && l !== oldLength ) {
this.multiplyScalar( l / oldLength );
}
return this; return this;
...@@ -701,7 +695,7 @@ THREE.Vector3.prototype = { ...@@ -701,7 +695,7 @@ THREE.Vector3.prototype = {
angleTo: function ( v ) { angleTo: function ( v ) {
var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) ); var theta = this.dot( v ) / Math.sqrt( this.lengthSq() * v.lengthSq() );
// clamp, to handle numerical problems // clamp, to handle numerical problems
......
...@@ -589,15 +589,9 @@ THREE.Vector4.prototype = { ...@@ -589,15 +589,9 @@ THREE.Vector4.prototype = {
}, },
setLength: function ( l ) { setLength: function ( length ) {
var oldLength = this.length(); this.multiplyScalar( length / this.length() );
if ( oldLength !== 0 && l !== oldLength ) {
this.multiplyScalar( l / oldLength );
}
return this; return this;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册