File tree Expand file tree Collapse file tree 3 files changed +32
-14
lines changed
Expand file tree Collapse file tree 3 files changed +32
-14
lines changed Original file line number Diff line number Diff line change @@ -1296,10 +1296,7 @@ class Object3D extends EventDispatcher {
12961296
12971297 object . geometryInfo = this . _geometryInfo . map ( info => ( {
12981298 ...info ,
1299- boundingBox : info . boundingBox ? {
1300- min : info . boundingBox . min . toArray ( ) ,
1301- max : info . boundingBox . max . toArray ( )
1302- } : undefined ,
1299+ boundingBox : info . boundingBox ? info . boundingBox . toJSON ( ) : undefined ,
13031300 boundingSphere : info . boundingSphere ? {
13041301 radius : info . boundingSphere . radius ,
13051302 center : info . boundingSphere . center . toArray ( )
@@ -1341,10 +1338,7 @@ class Object3D extends EventDispatcher {
13411338
13421339 if ( this . boundingBox !== null ) {
13431340
1344- object . boundingBox = {
1345- min : this . boundingBox . min . toArray ( ) ,
1346- max : this . boundingBox . max . toArray ( )
1347- } ;
1341+ object . boundingBox = this . boundingBox . toJSON ( ) ;
13481342
13491343 }
13501344
Original file line number Diff line number Diff line change @@ -979,9 +979,7 @@ class ObjectLoader extends Loader {
979979 let sphere = null ;
980980 if ( info . boundingBox !== undefined ) {
981981
982- box = new Box3 ( ) ;
983- box . min . fromArray ( info . boundingBox . min ) ;
984- box . max . fromArray ( info . boundingBox . max ) ;
982+ box = new Box3 ( ) . fromJSON ( info . boundingBox ) ;
985983
986984 }
987985
@@ -1035,9 +1033,7 @@ class ObjectLoader extends Loader {
10351033
10361034 if ( data . boundingBox !== undefined ) {
10371035
1038- object . boundingBox = new Box3 ( ) ;
1039- object . boundingBox . min . fromArray ( data . boundingBox . min ) ;
1040- object . boundingBox . max . fromArray ( data . boundingBox . max ) ;
1036+ object . boundingBox = new Box3 ( ) . fromJSON ( data . boundingBox ) ;
10411037
10421038 }
10431039
Original file line number Diff line number Diff line change @@ -714,6 +714,34 @@ class Box3 {
714714
715715 }
716716
717+ /**
718+ * Returns a serialized structure of the bounding box.
719+ *
720+ * @return {Object } Serialized structure with fields representing the object state.
721+ */
722+ toJSON ( ) {
723+
724+ return {
725+ min : this . min . toArray ( ) ,
726+ max : this . max . toArray ( )
727+ } ;
728+
729+ }
730+
731+ /**
732+ * Returns a serialized structure of the bounding box.
733+ *
734+ * @param {Object } json - The serialized json to set the box from.
735+ * @return {Box3 } A reference to this bounding box.
736+ */
737+ fromJSON ( json ) {
738+
739+ this . min . fromArray ( json . min ) ;
740+ this . max . fromArray ( json . max ) ;
741+ return this ;
742+
743+ }
744+
717745}
718746
719747const _points = [
You can’t perform that action at this time.
0 commit comments