@galacean/engine-math 1.1.0-beta.23 → 1.1.0-beta.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -697,8 +697,11 @@ function _create_class(Constructor, protoProps, staticProps) {
697
697
  * @param out - The center point of this bounding box
698
698
  * @returns The center point of this bounding box
699
699
  */ _proto.getCenter = function getCenter(out) {
700
- Vector3.add(this.min, this.max, out);
701
- Vector3.scale(out, 0.5, out);
700
+ var _this = this, min = _this.min, max = _this.max;
701
+ var centerX = max._x + min._x;
702
+ var centerY = max._y + min._y;
703
+ var centerZ = max._z + min._z;
704
+ out.set(isNaN(centerX) ? 0 : centerX * 0.5, isNaN(centerY) ? 0 : centerY * 0.5, isNaN(centerZ) ? 0 : centerZ * 0.5);
702
705
  return out;
703
706
  };
704
707
  /**
@@ -706,8 +709,11 @@ function _create_class(Constructor, protoProps, staticProps) {
706
709
  * @param out - The extent of this bounding box
707
710
  * @returns The extent of this bounding box
708
711
  */ _proto.getExtent = function getExtent(out) {
709
- Vector3.subtract(this.max, this.min, out);
710
- Vector3.scale(out, 0.5, out);
712
+ var _this = this, min = _this.min, max = _this.max;
713
+ var extentX = max._x - min._x;
714
+ var extentY = max._y - min._y;
715
+ var extentZ = max._z - min._z;
716
+ out.set(isNaN(extentX) ? 0 : extentX * 0.5, isNaN(extentY) ? 0 : extentY * 0.5, isNaN(extentZ) ? 0 : extentZ * 0.5);
711
717
  return out;
712
718
  };
713
719
  /**
@@ -817,9 +823,9 @@ function _create_class(Constructor, protoProps, staticProps) {
817
823
  Vector3.transformCoordinate(center, matrix, center);
818
824
  var x = extent.x, y = extent.y, z = extent.z;
819
825
  var e = matrix.elements;
820
- extent.x = Math.abs(x * e[0]) + Math.abs(y * e[4]) + Math.abs(z * e[8]);
821
- extent.y = Math.abs(x * e[1]) + Math.abs(y * e[5]) + Math.abs(z * e[9]);
822
- extent.z = Math.abs(x * e[2]) + Math.abs(y * e[6]) + Math.abs(z * e[10]);
826
+ // prettier-ignore
827
+ var e0 = e[0], e1 = e[1], e2 = e[2], e4 = e[4], e5 = e[5], e6 = e[6], e8 = e[8], e9 = e[9], e10 = e[10];
828
+ extent.set((e0 === 0 ? 0 : Math.abs(x * e0)) + (e4 === 0 ? 0 : Math.abs(y * e4)) + (e8 === 0 ? 0 : Math.abs(z * e8)), (e1 === 0 ? 0 : Math.abs(x * e1)) + (e5 === 0 ? 0 : Math.abs(y * e5)) + (e9 === 0 ? 0 : Math.abs(z * e9)), (e2 === 0 ? 0 : Math.abs(x * e2)) + (e6 === 0 ? 0 : Math.abs(y * e6)) + (e10 === 0 ? 0 : Math.abs(z * e10)));
823
829
  // set min、max
824
830
  Vector3.subtract(center, extent, out.min);
825
831
  Vector3.add(center, extent, out.max);
package/dist/module.js CHANGED
@@ -693,8 +693,11 @@ function _create_class(Constructor, protoProps, staticProps) {
693
693
  * @param out - The center point of this bounding box
694
694
  * @returns The center point of this bounding box
695
695
  */ _proto.getCenter = function getCenter(out) {
696
- Vector3.add(this.min, this.max, out);
697
- Vector3.scale(out, 0.5, out);
696
+ var _this = this, min = _this.min, max = _this.max;
697
+ var centerX = max._x + min._x;
698
+ var centerY = max._y + min._y;
699
+ var centerZ = max._z + min._z;
700
+ out.set(isNaN(centerX) ? 0 : centerX * 0.5, isNaN(centerY) ? 0 : centerY * 0.5, isNaN(centerZ) ? 0 : centerZ * 0.5);
698
701
  return out;
699
702
  };
700
703
  /**
@@ -702,8 +705,11 @@ function _create_class(Constructor, protoProps, staticProps) {
702
705
  * @param out - The extent of this bounding box
703
706
  * @returns The extent of this bounding box
704
707
  */ _proto.getExtent = function getExtent(out) {
705
- Vector3.subtract(this.max, this.min, out);
706
- Vector3.scale(out, 0.5, out);
708
+ var _this = this, min = _this.min, max = _this.max;
709
+ var extentX = max._x - min._x;
710
+ var extentY = max._y - min._y;
711
+ var extentZ = max._z - min._z;
712
+ out.set(isNaN(extentX) ? 0 : extentX * 0.5, isNaN(extentY) ? 0 : extentY * 0.5, isNaN(extentZ) ? 0 : extentZ * 0.5);
707
713
  return out;
708
714
  };
709
715
  /**
@@ -813,9 +819,9 @@ function _create_class(Constructor, protoProps, staticProps) {
813
819
  Vector3.transformCoordinate(center, matrix, center);
814
820
  var x = extent.x, y = extent.y, z = extent.z;
815
821
  var e = matrix.elements;
816
- extent.x = Math.abs(x * e[0]) + Math.abs(y * e[4]) + Math.abs(z * e[8]);
817
- extent.y = Math.abs(x * e[1]) + Math.abs(y * e[5]) + Math.abs(z * e[9]);
818
- extent.z = Math.abs(x * e[2]) + Math.abs(y * e[6]) + Math.abs(z * e[10]);
822
+ // prettier-ignore
823
+ var e0 = e[0], e1 = e[1], e2 = e[2], e4 = e[4], e5 = e[5], e6 = e[6], e8 = e[8], e9 = e[9], e10 = e[10];
824
+ extent.set((e0 === 0 ? 0 : Math.abs(x * e0)) + (e4 === 0 ? 0 : Math.abs(y * e4)) + (e8 === 0 ? 0 : Math.abs(z * e8)), (e1 === 0 ? 0 : Math.abs(x * e1)) + (e5 === 0 ? 0 : Math.abs(y * e5)) + (e9 === 0 ? 0 : Math.abs(z * e9)), (e2 === 0 ? 0 : Math.abs(x * e2)) + (e6 === 0 ? 0 : Math.abs(y * e6)) + (e10 === 0 ? 0 : Math.abs(z * e10)));
819
825
  // set min、max
820
826
  Vector3.subtract(center, extent, out.min);
821
827
  Vector3.add(center, extent, out.max);