@math.gl/core 4.2.0-alpha.5 → 4.2.0-alpha.6
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/classes/euler.d.ts +37 -25
- package/dist/classes/euler.d.ts.map +1 -1
- package/dist/classes/euler.js +99 -54
- package/dist/classes/euler.js.map +1 -1
- package/dist/classes/pose.d.ts.map +1 -1
- package/dist/classes/pose.js +2 -3
- package/dist/classes/pose.js.map +1 -1
- package/dist/index.cjs +102 -55
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/classes/euler.ts +111 -60
- package/src/classes/pose.ts +2 -3
- package/src/index.ts +1 -0
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
|
|
5639
|
-
(function(
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
})(
|
|
5647
|
-
var
|
|
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
|
|
5667
|
+
return "zyx";
|
|
5651
5668
|
}
|
|
5669
|
+
/** @deprecated Pass the string `'yxz'` directly. */
|
|
5652
5670
|
static get YXZ() {
|
|
5653
|
-
return
|
|
5671
|
+
return "yxz";
|
|
5654
5672
|
}
|
|
5673
|
+
/** @deprecated Pass the string `'xzy'` directly. */
|
|
5655
5674
|
static get XZY() {
|
|
5656
|
-
return
|
|
5675
|
+
return "xzy";
|
|
5657
5676
|
}
|
|
5677
|
+
/** @deprecated Pass the string `'zxy'` directly. */
|
|
5658
5678
|
static get ZXY() {
|
|
5659
|
-
return
|
|
5679
|
+
return "zxy";
|
|
5660
5680
|
}
|
|
5681
|
+
/** @deprecated Pass the string `'yzx'` directly. */
|
|
5661
5682
|
static get YZX() {
|
|
5662
|
-
return
|
|
5683
|
+
return "yzx";
|
|
5663
5684
|
}
|
|
5685
|
+
/** @deprecated Pass the string `'xyz'` directly. */
|
|
5664
5686
|
static get XYZ() {
|
|
5665
|
-
return
|
|
5687
|
+
return "xyz";
|
|
5666
5688
|
}
|
|
5689
|
+
/** @deprecated Pass the string `'zyx'` directly. */
|
|
5667
5690
|
static get RollPitchYaw() {
|
|
5668
|
-
return
|
|
5691
|
+
return "zyx";
|
|
5669
5692
|
}
|
|
5693
|
+
/** @deprecated Pass the string `'zyx'` directly. */
|
|
5670
5694
|
static get DefaultOrder() {
|
|
5671
|
-
return
|
|
5695
|
+
return "zyx";
|
|
5672
5696
|
}
|
|
5697
|
+
/** @deprecated Pass an {@link EulerRotationOrder} string directly. */
|
|
5673
5698
|
static get RotationOrders() {
|
|
5674
|
-
return
|
|
5699
|
+
return ROTATION_ORDERS;
|
|
5675
5700
|
}
|
|
5701
|
+
/** @deprecated Euler rotation orders are already represented as strings. */
|
|
5676
5702
|
static rotationOrder(order) {
|
|
5677
|
-
return
|
|
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 =
|
|
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,
|
|
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
|
-
|
|
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] =
|
|
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],
|
|
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,
|
|
5889
|
+
return this.set(roll, pitch, yaw, "zyx");
|
|
5862
5890
|
}
|
|
5863
|
-
fromRotationMatrix(m, order =
|
|
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
|
|
5903
|
+
case RotationOrderIndex.XYZ:
|
|
5876
5904
|
return q.rotateX(this[0]).rotateY(this[1]).rotateZ(this[2]);
|
|
5877
|
-
case
|
|
5905
|
+
case RotationOrderIndex.YXZ:
|
|
5878
5906
|
return q.rotateY(this[1]).rotateX(this[0]).rotateZ(this[2]);
|
|
5879
|
-
case
|
|
5907
|
+
case RotationOrderIndex.ZXY:
|
|
5880
5908
|
return q.rotateZ(this[2]).rotateX(this[0]).rotateY(this[1]);
|
|
5881
|
-
case
|
|
5909
|
+
case RotationOrderIndex.ZYX:
|
|
5882
5910
|
return q.rotateZ(this[2]).rotateY(this[1]).rotateX(this[0]);
|
|
5883
|
-
case
|
|
5911
|
+
case RotationOrderIndex.YZX:
|
|
5884
5912
|
return q.rotateY(this[1]).rotateZ(this[2]).rotateX(this[0]);
|
|
5885
|
-
case
|
|
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 =
|
|
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
|
-
|
|
5904
|
-
switch (
|
|
5905
|
-
case
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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] =
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
6117
|
+
const order = ROTATION_ORDER_INDICES[value];
|
|
6118
|
+
if (order === void 0) {
|
|
6090
6119
|
throw new Error(ERR_UNKNOWN_ORDER);
|
|
6091
6120
|
}
|
|
6092
|
-
return
|
|
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
|
|
6151
|
+
this.orientation = new Euler().fromArray(orientation);
|
|
6105
6152
|
} else {
|
|
6106
|
-
this.orientation = new Euler(roll, pitch, yaw,
|
|
6153
|
+
this.orientation = new Euler(roll, pitch, yaw, "zyx");
|
|
6107
6154
|
}
|
|
6108
6155
|
}
|
|
6109
6156
|
get x() {
|