|
@@ -283,13 +283,13 @@ THREE.Vector4.prototype = {
|
|
|
|
|
|
lengthSq: function () {
|
|
lengthSq: function () {
|
|
|
|
|
|
- return this.dot( this );
|
|
|
|
|
|
+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
length: function () {
|
|
length: function () {
|
|
|
|
|
|
- return Math.sqrt( this.lengthSq() );
|
|
|
|
|
|
+ return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
@@ -307,8 +307,15 @@ THREE.Vector4.prototype = {
|
|
|
|
|
|
setLength: function ( l ) {
|
|
setLength: function ( l ) {
|
|
|
|
|
|
- return this.normalize().multiplyScalar( l );
|
|
|
|
|
|
+ var oldLength = this.length();
|
|
|
|
+
|
|
|
|
+ if( oldLength ) {
|
|
|
|
|
|
|
|
+ this.multiplyScalar( l / oldLength );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return this;
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
lerpSelf: function ( v, alpha ) {
|
|
lerpSelf: function ( v, alpha ) {
|