File tree 3 files changed +32
-14
lines changed 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 {
1296
1296
1297
1297
object . geometryInfo = this . _geometryInfo . map ( info => ( {
1298
1298
...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 ,
1303
1300
boundingSphere : info . boundingSphere ? {
1304
1301
radius : info . boundingSphere . radius ,
1305
1302
center : info . boundingSphere . center . toArray ( )
@@ -1341,10 +1338,7 @@ class Object3D extends EventDispatcher {
1341
1338
1342
1339
if ( this . boundingBox !== null ) {
1343
1340
1344
- object . boundingBox = {
1345
- min : this . boundingBox . min . toArray ( ) ,
1346
- max : this . boundingBox . max . toArray ( )
1347
- } ;
1341
+ object . boundingBox = this . boundingBox . toJSON ( ) ;
1348
1342
1349
1343
}
1350
1344
Original file line number Diff line number Diff line change @@ -979,9 +979,7 @@ class ObjectLoader extends Loader {
979
979
let sphere = null ;
980
980
if ( info . boundingBox !== undefined ) {
981
981
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 ) ;
985
983
986
984
}
987
985
@@ -1035,9 +1033,7 @@ class ObjectLoader extends Loader {
1035
1033
1036
1034
if ( data . boundingBox !== undefined ) {
1037
1035
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 ) ;
1041
1037
1042
1038
}
1043
1039
Original file line number Diff line number Diff line change @@ -714,6 +714,34 @@ class Box3 {
714
714
715
715
}
716
716
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
+
717
745
}
718
746
719
747
const _points = [
You can’t perform that action at this time.
0 commit comments