Forráskód Böngészése

SelectionBox: Clean up.

Mr.doob 3 éve
szülő
commit
b88cb7f8e2
1 módosított fájl, 17 hozzáadás és 17 törlés
  1. 17 17
      examples/jsm/interactive/SelectionBox.js

+ 17 - 17
examples/jsm/interactive/SelectionBox.js

@@ -43,8 +43,8 @@ class SelectionBox {
 		this.startPoint = new Vector3();
 		this.endPoint = new Vector3();
 		this.collection = [];
+		this.instances = {};
 		this.deep = deep;
-		this.instanceDetection = {};
 
 	}
 
@@ -175,39 +175,39 @@ class SelectionBox {
 
 		if ( object.isMesh || object.isLine || object.isPoints ) {
 
-				if ( object instanceof InstancedMesh ) {
+			if ( object.isInstancedMesh ) {
 
-					this.instanceDetection[ object.uuid ] = [];
+				this.instances[ object.uuid ] = [];
 
-					for ( let instanceId = 0; instanceId < object.count; instanceId ++ ) {
+				for ( let instanceId = 0; instanceId < object.count; instanceId ++ ) {
 
-						object.getMatrixAt( instanceId, _matrix );
-						_matrix.decompose( _center, _quaternion, _scale );
+					object.getMatrixAt( instanceId, _matrix );
+					_matrix.decompose( _center, _quaternion, _scale );
 
-						if ( frustum.containsPoint( _center ) ) {
-
-							this.instanceDetection[ object.uuid ].push( instanceId );
+					if ( frustum.containsPoint( _center ) ) {
 
-						}
+						this.instances[ object.uuid ].push( instanceId );
 
 					}
 
-				} else {
+				}
 
-					if ( object.geometry.boundingSphere === null ) object.geometry.computeBoundingSphere();
+			} else {
 
-					_center.copy( object.geometry.boundingSphere.center );
+				if ( object.geometry.boundingSphere === null ) object.geometry.computeBoundingSphere();
 
-					_center.applyMatrix4( object.matrixWorld );
+				_center.copy( object.geometry.boundingSphere.center );
 
-					if ( frustum.containsPoint( _center ) ) {
+				_center.applyMatrix4( object.matrixWorld );
 
-						this.collection.push( object );
+				if ( frustum.containsPoint( _center ) ) {
 
-					}
+					this.collection.push( object );
 
 				}
 
+			}
+
 		}
 
 		if ( object.children.length > 0 ) {