@math.gl/core 4.2.0-alpha.5 → 5.0.0-alpha.1

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.
package/dist/index.cjs CHANGED
@@ -5635,46 +5635,72 @@ var SphericalCoordinates = class _SphericalCoordinates {
5635
5635
  // dist/classes/euler.js
5636
5636
  var ERR_UNKNOWN_ORDER = "Unknown Euler angle order";
5637
5637
  var ALMOST_ONE = 0.99999;
5638
- var RotationOrder;
5639
- (function(RotationOrder2) {
5640
- RotationOrder2[RotationOrder2["ZYX"] = 0] = "ZYX";
5641
- RotationOrder2[RotationOrder2["YXZ"] = 1] = "YXZ";
5642
- RotationOrder2[RotationOrder2["XZY"] = 2] = "XZY";
5643
- RotationOrder2[RotationOrder2["ZXY"] = 3] = "ZXY";
5644
- RotationOrder2[RotationOrder2["YZX"] = 4] = "YZX";
5645
- RotationOrder2[RotationOrder2["XYZ"] = 5] = "XYZ";
5646
- })(RotationOrder || (RotationOrder = {}));
5647
- var Euler = class _Euler extends MathArray {
5638
+ var RotationOrderIndex;
5639
+ (function(RotationOrderIndex2) {
5640
+ RotationOrderIndex2[RotationOrderIndex2["ZYX"] = 0] = "ZYX";
5641
+ RotationOrderIndex2[RotationOrderIndex2["YXZ"] = 1] = "YXZ";
5642
+ RotationOrderIndex2[RotationOrderIndex2["XZY"] = 2] = "XZY";
5643
+ RotationOrderIndex2[RotationOrderIndex2["ZXY"] = 3] = "ZXY";
5644
+ RotationOrderIndex2[RotationOrderIndex2["YZX"] = 4] = "YZX";
5645
+ RotationOrderIndex2[RotationOrderIndex2["XYZ"] = 5] = "XYZ";
5646
+ })(RotationOrderIndex || (RotationOrderIndex = {}));
5647
+ var ROTATION_ORDER_INDICES = {
5648
+ zyx: RotationOrderIndex.ZYX,
5649
+ yxz: RotationOrderIndex.YXZ,
5650
+ xzy: RotationOrderIndex.XZY,
5651
+ zxy: RotationOrderIndex.ZXY,
5652
+ yzx: RotationOrderIndex.YZX,
5653
+ xyz: RotationOrderIndex.XYZ
5654
+ };
5655
+ var ROTATION_ORDERS = {
5656
+ ZYX: "zyx",
5657
+ YXZ: "yxz",
5658
+ XZY: "xzy",
5659
+ ZXY: "zxy",
5660
+ YZX: "yzx",
5661
+ XYZ: "xyz"
5662
+ };
5663
+ var Euler = class extends MathArray {
5648
5664
  // Constants
5665
+ /** @deprecated Pass the string `'zyx'` directly. */
5649
5666
  static get ZYX() {
5650
- return RotationOrder.ZYX;
5667
+ return "zyx";
5651
5668
  }
5669
+ /** @deprecated Pass the string `'yxz'` directly. */
5652
5670
  static get YXZ() {
5653
- return RotationOrder.YXZ;
5671
+ return "yxz";
5654
5672
  }
5673
+ /** @deprecated Pass the string `'xzy'` directly. */
5655
5674
  static get XZY() {
5656
- return RotationOrder.XZY;
5675
+ return "xzy";
5657
5676
  }
5677
+ /** @deprecated Pass the string `'zxy'` directly. */
5658
5678
  static get ZXY() {
5659
- return RotationOrder.ZXY;
5679
+ return "zxy";
5660
5680
  }
5681
+ /** @deprecated Pass the string `'yzx'` directly. */
5661
5682
  static get YZX() {
5662
- return RotationOrder.YZX;
5683
+ return "yzx";
5663
5684
  }
5685
+ /** @deprecated Pass the string `'xyz'` directly. */
5664
5686
  static get XYZ() {
5665
- return RotationOrder.XYZ;
5687
+ return "xyz";
5666
5688
  }
5689
+ /** @deprecated Pass the string `'zyx'` directly. */
5667
5690
  static get RollPitchYaw() {
5668
- return RotationOrder.ZYX;
5691
+ return "zyx";
5669
5692
  }
5693
+ /** @deprecated Pass the string `'zyx'` directly. */
5670
5694
  static get DefaultOrder() {
5671
- return RotationOrder.ZYX;
5695
+ return "zyx";
5672
5696
  }
5697
+ /** @deprecated Pass an {@link EulerRotationOrder} string directly. */
5673
5698
  static get RotationOrders() {
5674
- return RotationOrder;
5699
+ return ROTATION_ORDERS;
5675
5700
  }
5701
+ /** @deprecated Euler rotation orders are already represented as strings. */
5676
5702
  static rotationOrder(order) {
5677
- return RotationOrder[order];
5703
+ return order;
5678
5704
  }
5679
5705
  get ELEMENTS() {
5680
5706
  return 4;
@@ -5686,7 +5712,7 @@ var Euler = class _Euler extends MathArray {
5686
5712
  * @param {Number=} [z]
5687
5713
  * @param {Number=} [order]
5688
5714
  */
5689
- constructor(x = 0, y = 0, z = 0, order = _Euler.DefaultOrder) {
5715
+ constructor(x = 0, y = 0, z = 0, order = "zyx") {
5690
5716
  super(-0, -0, -0, -0);
5691
5717
  if (arguments.length > 0 && Array.isArray(arguments[0])) {
5692
5718
  this.fromVector3(...arguments);
@@ -5707,7 +5733,7 @@ var Euler = class _Euler extends MathArray {
5707
5733
  const roll = Math.atan2(t3, t4);
5708
5734
  const pitch = Math.asin(t2);
5709
5735
  const yaw = Math.atan2(t1, t0);
5710
- return this.set(roll, pitch, yaw, _Euler.RollPitchYaw);
5736
+ return this.set(roll, pitch, yaw, "zyx");
5711
5737
  }
5712
5738
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
5713
5739
  fromObject(object) {
@@ -5722,7 +5748,9 @@ var Euler = class _Euler extends MathArray {
5722
5748
  this[0] = array[0];
5723
5749
  this[1] = array[1];
5724
5750
  this[2] = array[2];
5725
- this[3] = Number.isFinite(array[3]) || this.order;
5751
+ if (Number.isFinite(array[3]) && validateOrder(array[3])) {
5752
+ this[3] = array[3];
5753
+ }
5726
5754
  return this.check();
5727
5755
  }
5728
5756
  // Sets the three angles, and optionally sets the rotation order
@@ -5731,7 +5759,7 @@ var Euler = class _Euler extends MathArray {
5731
5759
  this[0] = x;
5732
5760
  this[1] = y;
5733
5761
  this[2] = z;
5734
- this[3] = Number.isFinite(order) ? order : this[3];
5762
+ this[3] = order ? checkOrder(order) : this[3];
5735
5763
  return this.check();
5736
5764
  }
5737
5765
  validate() {
@@ -5837,14 +5865,14 @@ var Euler = class _Euler extends MathArray {
5837
5865
  }
5838
5866
  // rotation order, in all three angle notations
5839
5867
  get order() {
5840
- return this[3];
5868
+ return getOrder(this[3]);
5841
5869
  }
5842
5870
  set order(value) {
5843
5871
  this[3] = checkOrder(value);
5844
5872
  }
5845
5873
  // Constructors
5846
- fromVector3(v, order) {
5847
- return this.set(v[0], v[1], v[2], Number.isFinite(order) ? order : this[3]);
5874
+ fromVector3(v, order = this.order) {
5875
+ return this.set(v[0], v[1], v[2], order);
5848
5876
  }
5849
5877
  // TODO - with and without 4th element
5850
5878
  fromArray(array, offset = 0) {
@@ -5858,9 +5886,9 @@ var Euler = class _Euler extends MathArray {
5858
5886
  }
5859
5887
  // Common ZYX rotation order
5860
5888
  fromRollPitchYaw(roll, pitch, yaw) {
5861
- return this.set(roll, pitch, yaw, RotationOrder.ZYX);
5889
+ return this.set(roll, pitch, yaw, "zyx");
5862
5890
  }
5863
- fromRotationMatrix(m, order = _Euler.DefaultOrder) {
5891
+ fromRotationMatrix(m, order = "zyx") {
5864
5892
  this._fromRotationMatrix(m, order);
5865
5893
  return this.check();
5866
5894
  }
@@ -5872,17 +5900,17 @@ var Euler = class _Euler extends MathArray {
5872
5900
  getQuaternion() {
5873
5901
  const q = new Quaternion();
5874
5902
  switch (this[3]) {
5875
- case RotationOrder.XYZ:
5903
+ case RotationOrderIndex.XYZ:
5876
5904
  return q.rotateX(this[0]).rotateY(this[1]).rotateZ(this[2]);
5877
- case RotationOrder.YXZ:
5905
+ case RotationOrderIndex.YXZ:
5878
5906
  return q.rotateY(this[1]).rotateX(this[0]).rotateZ(this[2]);
5879
- case RotationOrder.ZXY:
5907
+ case RotationOrderIndex.ZXY:
5880
5908
  return q.rotateZ(this[2]).rotateX(this[0]).rotateY(this[1]);
5881
- case RotationOrder.ZYX:
5909
+ case RotationOrderIndex.ZYX:
5882
5910
  return q.rotateZ(this[2]).rotateY(this[1]).rotateX(this[0]);
5883
- case RotationOrder.YZX:
5911
+ case RotationOrderIndex.YZX:
5884
5912
  return q.rotateY(this[1]).rotateZ(this[2]).rotateX(this[0]);
5885
- case RotationOrder.XZY:
5913
+ case RotationOrderIndex.XZY:
5886
5914
  return q.rotateX(this[0]).rotateZ(this[2]).rotateY(this[1]);
5887
5915
  default:
5888
5916
  throw new Error(ERR_UNKNOWN_ORDER);
@@ -5896,13 +5924,13 @@ var Euler = class _Euler extends MathArray {
5896
5924
  // const q = new Quaternion().setFromEuler(this);
5897
5925
  // return this.setFromQuaternion(q, newOrder);
5898
5926
  /* eslint-disable complexity, max-statements, one-var */
5899
- _fromRotationMatrix(m, order = _Euler.DefaultOrder) {
5927
+ _fromRotationMatrix(m, order = "zyx") {
5900
5928
  const m11 = m[0], m12 = m[4], m13 = m[8];
5901
5929
  const m21 = m[1], m22 = m[5], m23 = m[9];
5902
5930
  const m31 = m[2], m32 = m[6], m33 = m[10];
5903
- order = order || this[3];
5904
- switch (order) {
5905
- case _Euler.XYZ:
5931
+ const orderIndex = order ? checkOrder(order) : this[3];
5932
+ switch (orderIndex) {
5933
+ case RotationOrderIndex.XYZ:
5906
5934
  this[1] = Math.asin(clamp(m13, -1, 1));
5907
5935
  if (Math.abs(m13) < ALMOST_ONE) {
5908
5936
  this[0] = Math.atan2(-m23, m33);
@@ -5912,7 +5940,7 @@ var Euler = class _Euler extends MathArray {
5912
5940
  this[2] = 0;
5913
5941
  }
5914
5942
  break;
5915
- case _Euler.YXZ:
5943
+ case RotationOrderIndex.YXZ:
5916
5944
  this[0] = Math.asin(-clamp(m23, -1, 1));
5917
5945
  if (Math.abs(m23) < ALMOST_ONE) {
5918
5946
  this[1] = Math.atan2(m13, m33);
@@ -5922,7 +5950,7 @@ var Euler = class _Euler extends MathArray {
5922
5950
  this[2] = 0;
5923
5951
  }
5924
5952
  break;
5925
- case _Euler.ZXY:
5953
+ case RotationOrderIndex.ZXY:
5926
5954
  this[0] = Math.asin(clamp(m32, -1, 1));
5927
5955
  if (Math.abs(m32) < ALMOST_ONE) {
5928
5956
  this[1] = Math.atan2(-m31, m33);
@@ -5932,7 +5960,7 @@ var Euler = class _Euler extends MathArray {
5932
5960
  this[2] = Math.atan2(m21, m11);
5933
5961
  }
5934
5962
  break;
5935
- case _Euler.ZYX:
5963
+ case RotationOrderIndex.ZYX:
5936
5964
  this[1] = Math.asin(-clamp(m31, -1, 1));
5937
5965
  if (Math.abs(m31) < ALMOST_ONE) {
5938
5966
  this[0] = Math.atan2(m32, m33);
@@ -5942,7 +5970,7 @@ var Euler = class _Euler extends MathArray {
5942
5970
  this[2] = Math.atan2(-m12, m22);
5943
5971
  }
5944
5972
  break;
5945
- case _Euler.YZX:
5973
+ case RotationOrderIndex.YZX:
5946
5974
  this[2] = Math.asin(clamp(m21, -1, 1));
5947
5975
  if (Math.abs(m21) < ALMOST_ONE) {
5948
5976
  this[0] = Math.atan2(-m23, m22);
@@ -5952,7 +5980,7 @@ var Euler = class _Euler extends MathArray {
5952
5980
  this[1] = Math.atan2(m13, m33);
5953
5981
  }
5954
5982
  break;
5955
- case _Euler.XZY:
5983
+ case RotationOrderIndex.XZY:
5956
5984
  this[2] = Math.asin(-clamp(m12, -1, 1));
5957
5985
  if (Math.abs(m12) < ALMOST_ONE) {
5958
5986
  this[0] = Math.atan2(m32, m22);
@@ -5965,7 +5993,7 @@ var Euler = class _Euler extends MathArray {
5965
5993
  default:
5966
5994
  throw new Error(ERR_UNKNOWN_ORDER);
5967
5995
  }
5968
- this[3] = order;
5996
+ this[3] = orderIndex;
5969
5997
  return this;
5970
5998
  }
5971
5999
  _getRotationMatrix(result) {
@@ -5978,7 +6006,7 @@ var Euler = class _Euler extends MathArray {
5978
6006
  const d = Math.sin(y);
5979
6007
  const f = Math.sin(z);
5980
6008
  switch (this[3]) {
5981
- case _Euler.XYZ: {
6009
+ case RotationOrderIndex.XYZ: {
5982
6010
  const ae = a * e, af = a * f, be = b * e, bf = b * f;
5983
6011
  te[0] = c * e;
5984
6012
  te[4] = -c * f;
@@ -5991,7 +6019,7 @@ var Euler = class _Euler extends MathArray {
5991
6019
  te[10] = a * c;
5992
6020
  break;
5993
6021
  }
5994
- case _Euler.YXZ: {
6022
+ case RotationOrderIndex.YXZ: {
5995
6023
  const ce = c * e, cf = c * f, de = d * e, df = d * f;
5996
6024
  te[0] = ce + df * b;
5997
6025
  te[4] = de * b - cf;
@@ -6004,7 +6032,7 @@ var Euler = class _Euler extends MathArray {
6004
6032
  te[10] = a * c;
6005
6033
  break;
6006
6034
  }
6007
- case _Euler.ZXY: {
6035
+ case RotationOrderIndex.ZXY: {
6008
6036
  const ce = c * e, cf = c * f, de = d * e, df = d * f;
6009
6037
  te[0] = ce - df * b;
6010
6038
  te[4] = -a * f;
@@ -6017,7 +6045,7 @@ var Euler = class _Euler extends MathArray {
6017
6045
  te[10] = a * c;
6018
6046
  break;
6019
6047
  }
6020
- case _Euler.ZYX: {
6048
+ case RotationOrderIndex.ZYX: {
6021
6049
  const ae = a * e, af = a * f, be = b * e, bf = b * f;
6022
6050
  te[0] = c * e;
6023
6051
  te[4] = be * d - af;
@@ -6030,7 +6058,7 @@ var Euler = class _Euler extends MathArray {
6030
6058
  te[10] = a * c;
6031
6059
  break;
6032
6060
  }
6033
- case _Euler.YZX: {
6061
+ case RotationOrderIndex.YZX: {
6034
6062
  const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
6035
6063
  te[0] = c * e;
6036
6064
  te[4] = bd - ac * f;
@@ -6043,7 +6071,7 @@ var Euler = class _Euler extends MathArray {
6043
6071
  te[10] = ac - bd * f;
6044
6072
  break;
6045
6073
  }
6046
- case _Euler.XZY: {
6074
+ case RotationOrderIndex.XZY: {
6047
6075
  const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
6048
6076
  te[0] = c * e;
6049
6077
  te[4] = -f;
@@ -6086,10 +6114,29 @@ function validateOrder(value) {
6086
6114
  return value >= 0 && value < 6;
6087
6115
  }
6088
6116
  function checkOrder(value) {
6089
- if (value < 0 && value >= 6) {
6117
+ const order = ROTATION_ORDER_INDICES[value];
6118
+ if (order === void 0) {
6090
6119
  throw new Error(ERR_UNKNOWN_ORDER);
6091
6120
  }
6092
- return value;
6121
+ return order;
6122
+ }
6123
+ function getOrder(value) {
6124
+ switch (value) {
6125
+ case RotationOrderIndex.ZYX:
6126
+ return "zyx";
6127
+ case RotationOrderIndex.YXZ:
6128
+ return "yxz";
6129
+ case RotationOrderIndex.XZY:
6130
+ return "xzy";
6131
+ case RotationOrderIndex.ZXY:
6132
+ return "zxy";
6133
+ case RotationOrderIndex.YZX:
6134
+ return "yzx";
6135
+ case RotationOrderIndex.XYZ:
6136
+ return "xyz";
6137
+ default:
6138
+ throw new Error(ERR_UNKNOWN_ORDER);
6139
+ }
6093
6140
  }
6094
6141
 
6095
6142
  // dist/classes/pose.js
@@ -6101,9 +6148,9 @@ var Pose = class {
6101
6148
  this.position = new Vector3(x, y, z);
6102
6149
  }
6103
6150
  if (Array.isArray(orientation) && orientation.length === 4) {
6104
- this.orientation = new Euler(orientation, orientation[3]);
6151
+ this.orientation = new Euler().fromArray(orientation);
6105
6152
  } else {
6106
- this.orientation = new Euler(roll, pitch, yaw, Euler.RollPitchYaw);
6153
+ this.orientation = new Euler(roll, pitch, yaw, "zyx");
6107
6154
  }
6108
6155
  }
6109
6156
  get x() {