@@ -144,11 +144,11 @@ Object.assign( Box3.prototype, {
144144
145145 } ,
146146
147- setFromObject : function ( object ) {
147+ setFromObject : function ( object , minimal = false ) {
148148
149149 this . makeEmpty ( ) ;
150150
151- return this . expandByObject ( object ) ;
151+ return this . expandByObject ( object , minimal ) ;
152152
153153 } ,
154154
@@ -237,7 +237,7 @@ Object.assign( Box3.prototype, {
237237
238238 } ,
239239
240- expandByObject : function ( object ) {
240+ expandByObject : function ( object , minimal = false ) {
241241
242242 // Computes the world-axis-aligned bounding box of an object (including its children),
243243 // accounting for both the object's, and children's, world transforms
@@ -248,24 +248,39 @@ Object.assign( Box3.prototype, {
248248
249249 if ( geometry !== undefined ) {
250250
251- if ( geometry . boundingBox = == null ) {
251+ if ( minimal && geometry . attributes != undefined && geometry . attributes . position ! == undefined ) {
252252
253- geometry . computeBoundingBox ( ) ;
253+ const position = geometry . attributes . position ;
254+ for ( let i = 0 , l = position . count ; i < l ; i ++ ) {
254255
255- }
256+ _vector . set ( position . getX ( i ) , position . getY ( i ) , position . getZ ( i ) ) ;
257+ _vector . applyMatrix4 ( object . matrixWorld ) ;
258+ this . expandByPoint ( _vector ) ;
259+
260+ }
261+
262+ } else {
263+
264+ if ( geometry . boundingBox === null ) {
256265
257- _box . copy ( geometry . boundingBox ) ;
258- _box . applyMatrix4 ( object . matrixWorld ) ;
266+ geometry . computeBoundingBox ( ) ;
259267
260- this . union ( _box ) ;
268+ }
269+
270+ _box . copy ( geometry . boundingBox ) ;
271+ _box . applyMatrix4 ( object . matrixWorld ) ;
272+
273+ this . union ( _box ) ;
274+
275+ }
261276
262277 }
263278
264279 const children = object . children ;
265280
266281 for ( let i = 0 , l = children . length ; i < l ; i ++ ) {
267282
268- this . expandByObject ( children [ i ] ) ;
283+ this . expandByObject ( children [ i ] , minimal ) ;
269284
270285 }
271286
0 commit comments