|
4582 | 4582 |
|
4583 | 4583 | this.texture = new Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding ); |
4584 | 4584 |
|
| 4585 | + this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : true; |
| 4586 | + |
4585 | 4587 | this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; |
4586 | 4588 | this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true; |
4587 | 4589 | this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null; |
|
5241 | 5243 |
|
5242 | 5244 | }, |
5243 | 5245 |
|
5244 | | - applyMatrix4: function () { |
5245 | | - |
5246 | | - var points = [ |
5247 | | - new Vector3(), |
5248 | | - new Vector3(), |
5249 | | - new Vector3(), |
5250 | | - new Vector3(), |
5251 | | - new Vector3(), |
5252 | | - new Vector3(), |
5253 | | - new Vector3(), |
5254 | | - new Vector3() |
5255 | | - ]; |
| 5246 | + applyMatrix4: function ( matrix ) { |
5256 | 5247 |
|
5257 | | - return function applyMatrix4( matrix ) { |
| 5248 | + // transform of empty box is an empty box. |
| 5249 | + if ( this.isEmpty( ) ) return this; |
5258 | 5250 |
|
5259 | | - // transform of empty box is an empty box. |
5260 | | - if ( this.isEmpty() ) return this; |
| 5251 | + var m = matrix.elements; |
5261 | 5252 |
|
5262 | | - // NOTE: I am using a binary pattern to specify all 2^3 combinations below |
5263 | | - points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000 |
5264 | | - points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001 |
5265 | | - points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010 |
5266 | | - points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011 |
5267 | | - points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100 |
5268 | | - points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101 |
5269 | | - points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110 |
5270 | | - points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111 |
| 5253 | + var xax = m[ 0 ] * this.min.x, xay = m[ 1 ] * this.min.x, xaz = m[ 2 ] * this.min.x; |
| 5254 | + var xbx = m[ 0 ] * this.max.x, xby = m[ 1 ] * this.max.x, xbz = m[ 2 ] * this.max.x; |
| 5255 | + var yax = m[ 4 ] * this.min.y, yay = m[ 5 ] * this.min.y, yaz = m[ 6 ] * this.min.y; |
| 5256 | + var ybx = m[ 4 ] * this.max.y, yby = m[ 5 ] * this.max.y, ybz = m[ 6 ] * this.max.y; |
| 5257 | + var zax = m[ 8 ] * this.min.z, zay = m[ 9 ] * this.min.z, zaz = m[ 10 ] * this.min.z; |
| 5258 | + var zbx = m[ 8 ] * this.max.z, zby = m[ 9 ] * this.max.z, zbz = m[ 10 ] * this.max.z; |
5271 | 5259 |
|
5272 | | - this.setFromPoints( points ); |
| 5260 | + this.min.x = Math.min( xax, xbx ) + Math.min( yax, ybx ) + Math.min( zax, zbx ) + m[ 12 ]; |
| 5261 | + this.min.y = Math.min( xay, xby ) + Math.min( yay, yby ) + Math.min( zay, zby ) + m[ 13 ]; |
| 5262 | + this.min.z = Math.min( xaz, xbz ) + Math.min( yaz, ybz ) + Math.min( zaz, zbz ) + m[ 14 ]; |
| 5263 | + this.max.x = Math.max( xax, xbx ) + Math.max( yax, ybx ) + Math.max( zax, zbx ) + m[ 12 ]; |
| 5264 | + this.max.y = Math.max( xay, xby ) + Math.max( yay, yby ) + Math.max( zay, zby ) + m[ 13 ]; |
| 5265 | + this.max.z = Math.max( xaz, xbz ) + Math.max( yaz, ybz ) + Math.max( zaz, zbz ) + m[ 14 ]; |
5273 | 5266 |
|
5274 | | - return this; |
5275 | | - |
5276 | | - }; |
| 5267 | + return this; |
5277 | 5268 |
|
5278 | | - }(), |
| 5269 | + }, |
5279 | 5270 |
|
5280 | 5271 | translate: function ( offset ) { |
5281 | 5272 |
|
|
0 commit comments