|
@@ -75,7 +75,8 @@ class BatchedMesh extends Mesh {
|
|
|
|
|
|
this.isBatchedMesh = true;
|
|
|
this.perObjectFrustumCulled = true;
|
|
|
- this.frustumCulled = false;
|
|
|
+ this.boundingBox = null;
|
|
|
+ this.boundingSphere = null;
|
|
|
|
|
|
this._drawRanges = [];
|
|
|
this._reservedRanges = [];
|
|
@@ -248,6 +249,56 @@ class BatchedMesh extends Mesh {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ computeBoundingBox() {
|
|
|
+
|
|
|
+ if ( this.boundingBox === null ) {
|
|
|
+
|
|
|
+ this.boundingBox = new Box3();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const geometryCount = this._geometryCount;
|
|
|
+ const boundingBox = this.boundingBox;
|
|
|
+ const active = this._active;
|
|
|
+
|
|
|
+ boundingBox.makeEmpty();
|
|
|
+ for ( let i = 0; i < geometryCount; i ++ ) {
|
|
|
+
|
|
|
+ if ( active[ i ] === false ) continue;
|
|
|
+
|
|
|
+ this.getMatrixAt( i, _matrix );
|
|
|
+ this.getBoundingBoxAt( i, _box ).applyMatrix4( _matrix );
|
|
|
+ boundingBox.union( _box );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ computeBoundingSphere() {
|
|
|
+
|
|
|
+ if ( this.boundingSphere === null ) {
|
|
|
+
|
|
|
+ this.boundingSphere = new Sphere();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const geometryCount = this._geometryCount;
|
|
|
+ const boundingSphere = this.boundingSphere;
|
|
|
+ const active = this._active;
|
|
|
+
|
|
|
+ boundingSphere.makeEmpty();
|
|
|
+ for ( let i = 0; i < geometryCount; i ++ ) {
|
|
|
+
|
|
|
+ if ( active[ i ] === false ) continue;
|
|
|
+
|
|
|
+ this.getMatrixAt( i, _matrix );
|
|
|
+ this.getBoundingSphereAt( i, _sphere ).applyMatrix4( _matrix );
|
|
|
+ boundingSphere.union( _sphere );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
addGeometry( geometry, vertexCount = - 1, indexCount = - 1 ) {
|
|
|
|
|
|
this._initializeGeometry( geometry );
|
|
@@ -706,6 +757,8 @@ class BatchedMesh extends Mesh {
|
|
|
|
|
|
this.geometry = source.geometry.clone();
|
|
|
this.perObjectFrustumCulled = source.perObjectFrustumCulled;
|
|
|
+ this.boundingBox = source.boundingBox !== null ? source.boundingBox.clone() : null;
|
|
|
+ this.boundingSphere = source.boundingSphere !== null ? source.boundingSphere.clone() : null;
|
|
|
|
|
|
this._drawRanges = source._drawRanges.map( range => ( { ...range } ) );
|
|
|
this._reservedRanges = source._reservedRanges.map( range => ( { ...range } ) );
|