|
@@ -559,41 +559,47 @@ Object.assign( Box3.prototype, {
|
|
|
|
|
|
},
|
|
|
|
|
|
- applyMatrix4: function () {
|
|
|
-
|
|
|
- var points = [
|
|
|
- new Vector3(),
|
|
|
- new Vector3(),
|
|
|
- new Vector3(),
|
|
|
- new Vector3(),
|
|
|
- new Vector3(),
|
|
|
- new Vector3(),
|
|
|
- new Vector3(),
|
|
|
- new Vector3()
|
|
|
- ];
|
|
|
-
|
|
|
- return function applyMatrix4( matrix ) {
|
|
|
-
|
|
|
- // transform of empty box is an empty box.
|
|
|
- if ( this.isEmpty() ) return this;
|
|
|
-
|
|
|
- // NOTE: I am using a binary pattern to specify all 2^3 combinations below
|
|
|
- points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000
|
|
|
- points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001
|
|
|
- points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010
|
|
|
- points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011
|
|
|
- points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100
|
|
|
- points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101
|
|
|
- points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110
|
|
|
- points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111
|
|
|
-
|
|
|
- this.setFromPoints( points );
|
|
|
+ applyMatrix4: function applyMatrix4( matrix ) {
|
|
|
|
|
|
- return this;
|
|
|
+ // transform of empty box is an empty box.
|
|
|
+ if ( this.isEmpty( ) ) return this;
|
|
|
|
|
|
- };
|
|
|
+ var m = matrix.elements;
|
|
|
|
|
|
- }(),
|
|
|
+ var xax = m[ 0 ] * this.min.x;
|
|
|
+ var xay = m[ 1 ] * this.min.x;
|
|
|
+ var xaz = m[ 2 ] * this.min.x;
|
|
|
+
|
|
|
+ var xbx = m[ 0 ] * this.max.x;
|
|
|
+ var xby = m[ 1 ] * this.max.x;
|
|
|
+ var xbz = m[ 2 ] * this.max.x;
|
|
|
+
|
|
|
+ var yax = m[ 4 ] * this.min.y;
|
|
|
+ var yay = m[ 5 ] * this.min.y;
|
|
|
+ var yaz = m[ 6 ] * this.min.y;
|
|
|
+
|
|
|
+ var ybx = m[ 4 ] * this.max.y;
|
|
|
+ var yby = m[ 5 ] * this.max.y;
|
|
|
+ var ybz = m[ 6 ] * this.max.y;
|
|
|
+
|
|
|
+ var zax = m[ 8 ] * this.min.z;
|
|
|
+ var zay = m[ 9 ] * this.min.z;
|
|
|
+ var zaz = m[ 10 ] * this.min.z;
|
|
|
+
|
|
|
+ var zbx = m[ 8 ] * this.max.z;
|
|
|
+ var zby = m[ 9 ] * this.max.z;
|
|
|
+ var zbz = m[ 10 ] * this.max.z;
|
|
|
+
|
|
|
+ this.min.x = Math.min( xax, xbx ) + Math.min( yax, ybx ) + Math.min( zax, zbx ) + m[ 12 ];
|
|
|
+ this.min.y = Math.min( xay, xby ) + Math.min( yay, yby ) + Math.min( zay, zby ) + m[ 13 ];
|
|
|
+ this.min.z = Math.min( xaz, xbz ) + Math.min( yaz, ybz ) + Math.min( zaz, zbz ) + m[ 14 ];
|
|
|
+ this.max.x = Math.max( xax, xbx ) + Math.max( yax, ybx ) + Math.max( zax, zbx ) + m[ 12 ];
|
|
|
+ this.max.y = Math.max( xay, xby ) + Math.max( yay, yby ) + Math.max( zay, zby ) + m[ 13 ];
|
|
|
+ this.max.z = Math.max( xaz, xbz ) + Math.max( yaz, ybz ) + Math.max( zaz, zbz ) + m[ 14 ];
|
|
|
+
|
|
|
+ return this;
|
|
|
+
|
|
|
+ },
|
|
|
|
|
|
translate: function ( offset ) {
|
|
|
|