|
@@ -176,9 +176,15 @@ THREE.Vector3.prototype = {
|
|
|
|
|
|
minSelf: function ( v ) {
|
|
|
|
|
|
- this.x = Math.min( this.x, v.x );
|
|
|
- this.y = Math.min( this.y, v.y );
|
|
|
- this.z = Math.min( this.z, v.z );
|
|
|
+ if( this.x > min.x ) {
|
|
|
+ this.x = min.x;
|
|
|
+ }
|
|
|
+ if( this.y > min.y ) {
|
|
|
+ this.y = min.y;
|
|
|
+ }
|
|
|
+ if( this.z > min.z ) {
|
|
|
+ this.z = min.z;
|
|
|
+ }
|
|
|
|
|
|
return this;
|
|
|
|
|
@@ -186,14 +192,48 @@ THREE.Vector3.prototype = {
|
|
|
|
|
|
maxSelf: function ( v ) {
|
|
|
|
|
|
- this.x = Math.max( this.x, v.x );
|
|
|
- this.y = Math.max( this.y, v.y );
|
|
|
- this.z = Math.max( this.z, v.z );
|
|
|
+ if( this.x < max.x ) {
|
|
|
+ this.x = max.x;
|
|
|
+ }
|
|
|
+ if( this.y < max.y ) {
|
|
|
+ this.y = max.y;
|
|
|
+ }
|
|
|
+ if( this.z < max.z ) {
|
|
|
+ this.z = max.z;
|
|
|
+ }
|
|
|
|
|
|
return this;
|
|
|
|
|
|
},
|
|
|
|
|
|
+ clampSelf: function ( min, max ) {
|
|
|
+
|
|
|
+ // This function assumes min < max, if this assumption isn't true it will not operate correctly
|
|
|
+
|
|
|
+ if( this.x < min.x ) {
|
|
|
+ this.x = min.x;
|
|
|
+ }
|
|
|
+ else if( this.x > max.x ) {
|
|
|
+ this.x = max.x;
|
|
|
+ }
|
|
|
+
|
|
|
+ if( this.y < min.y ) {
|
|
|
+ this.y = min.y;
|
|
|
+ }
|
|
|
+ else if( this.y > max.y ) {
|
|
|
+ this.y = max.y;
|
|
|
+ }
|
|
|
+
|
|
|
+ if( this.z < min.z ) {
|
|
|
+ this.z = min.z;
|
|
|
+ }
|
|
|
+ else if( this.z > max.z ) {
|
|
|
+ this.z = max.z;
|
|
|
+ }
|
|
|
+
|
|
|
+ return this;
|
|
|
+ },
|
|
|
+
|
|
|
negate: function() {
|
|
|
|
|
|
return this.multiplyScalar( - 1 );
|