Răsfoiți Sursa

Ensure empty box is still an empty box after a Box3.applyTransform

* ensure that an empty box is still an empty box aftering being transformed.

* fix docs to match new behavior.
Ben Houston (Clara.io) 9 ani în urmă
părinte
comite
b66633e2be
2 a modificat fișierele cu 3 adăugiri și 2 ștergeri
  1. 0 1
      docs/api/math/Box3.html
  2. 3 1
      src/math/Box3.js

+ 0 - 1
docs/api/math/Box3.html

@@ -58,7 +58,6 @@
 		</div>
 		</div>
 		<div>
 		<div>
 		Transforms this Box3 with the supplied matrix.
 		Transforms this Box3 with the supplied matrix.
-		This method must not be used on empty boxes.
 		</div>
 		</div>
 
 
 		<h3>[method:Vector3 clampPoint]( [page:Vector3 point], [page:Vector3 optionalTarget] ) [page:Box3 this]</h3>
 		<h3>[method:Vector3 clampPoint]( [page:Vector3 point], [page:Vector3 optionalTarget] ) [page:Box3 this]</h3>

+ 3 - 1
src/math/Box3.js

@@ -413,6 +413,9 @@ THREE.Box3.prototype = {
 
 
 		return function ( matrix ) {
 		return function ( 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
 			// 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[ 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[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001
@@ -423,7 +426,6 @@ THREE.Box3.prototype = {
 			points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110
 			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
 			points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix );	// 111
 
 
-			this.makeEmpty();
 			this.setFromPoints( points );
 			this.setFromPoints( points );
 
 
 			return this;
 			return this;