2
0
Эх сурвалжийг харах

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 жил өмнө
parent
commit
b66633e2be

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

@@ -58,7 +58,6 @@
 		</div>
 		<div>
 		Transforms this Box3 with the supplied matrix.
-		This method must not be used on empty boxes.
 		</div>
 
 		<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 ) {
 
+			// 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
@@ -423,7 +426,6 @@ THREE.Box3.prototype = {
 			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.makeEmpty();
 			this.setFromPoints( points );
 
 			return this;