@math.gl/core 4.0.0 → 4.0.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.
Files changed (124) hide show
  1. package/dist/classes/base/math-array.d.ts +1 -2
  2. package/dist/classes/base/math-array.js +220 -266
  3. package/dist/classes/base/matrix.d.ts +1 -2
  4. package/dist/classes/base/matrix.js +52 -53
  5. package/dist/classes/base/vector.d.ts +1 -2
  6. package/dist/classes/base/vector.js +121 -135
  7. package/dist/classes/euler.d.ts +2 -3
  8. package/dist/classes/euler.js +462 -533
  9. package/dist/classes/matrix3.d.ts +2 -3
  10. package/dist/classes/matrix3.js +185 -190
  11. package/dist/classes/matrix4.d.ts +1 -2
  12. package/dist/classes/matrix4.js +516 -452
  13. package/dist/classes/pose.d.ts +4 -5
  14. package/dist/classes/pose.js +104 -119
  15. package/dist/classes/quaternion.d.ts +1 -2
  16. package/dist/classes/quaternion.js +257 -233
  17. package/dist/classes/spherical-coordinates.d.ts +3 -4
  18. package/dist/classes/spherical-coordinates.js +138 -147
  19. package/dist/classes/vector2.d.ts +1 -2
  20. package/dist/classes/vector2.js +101 -85
  21. package/dist/classes/vector3.d.ts +1 -2
  22. package/dist/classes/vector3.js +125 -136
  23. package/dist/classes/vector4.d.ts +2 -3
  24. package/dist/classes/vector4.js +106 -114
  25. package/dist/gl-matrix/common.d.ts +0 -1
  26. package/dist/gl-matrix/common.js +38 -6
  27. package/dist/gl-matrix/mat3.d.ts +0 -1
  28. package/dist/gl-matrix/mat3.js +699 -425
  29. package/dist/gl-matrix/mat4.d.ts +0 -1
  30. package/dist/gl-matrix/mat4.js +1879 -1339
  31. package/dist/gl-matrix/quat.d.ts +0 -1
  32. package/dist/gl-matrix/quat.js +655 -257
  33. package/dist/gl-matrix/vec2.d.ts +0 -1
  34. package/dist/gl-matrix/vec2.js +529 -212
  35. package/dist/gl-matrix/vec3.d.ts +0 -1
  36. package/dist/gl-matrix/vec3.js +703 -335
  37. package/dist/gl-matrix/vec4.d.ts +0 -1
  38. package/dist/gl-matrix/vec4.js +579 -293
  39. package/dist/gl-matrix/wip/index.d.ts +3 -4
  40. package/dist/gl-matrix/wip/index.js +2 -1
  41. package/dist/gl-matrix/wip/mat2.d.ts +0 -1
  42. package/dist/gl-matrix/wip/mat2.js +333 -157
  43. package/dist/gl-matrix/wip/mat2d.d.ts +0 -1
  44. package/dist/gl-matrix/wip/mat2d.js +377 -202
  45. package/dist/gl-matrix/wip/quat2.d.ts +0 -1
  46. package/dist/gl-matrix/wip/quat2.js +647 -409
  47. package/dist/index.cjs +60 -100
  48. package/dist/index.cjs.map +7 -0
  49. package/dist/index.d.ts +21 -22
  50. package/dist/index.js +23 -16
  51. package/dist/lib/assert.d.ts +0 -1
  52. package/dist/lib/assert.js +3 -4
  53. package/dist/lib/common.d.ts +2 -3
  54. package/dist/lib/common.js +163 -134
  55. package/dist/lib/gl-matrix-extras.d.ts +0 -1
  56. package/dist/lib/gl-matrix-extras.js +39 -36
  57. package/dist/lib/math-utils.d.ts +0 -1
  58. package/dist/lib/math-utils.js +2 -1
  59. package/dist/lib/validators.d.ts +0 -1
  60. package/dist/lib/validators.js +22 -25
  61. package/package.json +5 -6
  62. package/src/classes/matrix3.ts +1 -1
  63. package/dist/classes/base/math-array.d.ts.map +0 -1
  64. package/dist/classes/base/math-array.js.map +0 -1
  65. package/dist/classes/base/matrix.d.ts.map +0 -1
  66. package/dist/classes/base/matrix.js.map +0 -1
  67. package/dist/classes/base/vector.d.ts.map +0 -1
  68. package/dist/classes/base/vector.js.map +0 -1
  69. package/dist/classes/euler.d.ts.map +0 -1
  70. package/dist/classes/euler.js.map +0 -1
  71. package/dist/classes/matrix3.d.ts.map +0 -1
  72. package/dist/classes/matrix3.js.map +0 -1
  73. package/dist/classes/matrix4.d.ts.map +0 -1
  74. package/dist/classes/matrix4.js.map +0 -1
  75. package/dist/classes/pose.d.ts.map +0 -1
  76. package/dist/classes/pose.js.map +0 -1
  77. package/dist/classes/quaternion.d.ts.map +0 -1
  78. package/dist/classes/quaternion.js.map +0 -1
  79. package/dist/classes/spherical-coordinates.d.ts.map +0 -1
  80. package/dist/classes/spherical-coordinates.js.map +0 -1
  81. package/dist/classes/vector2.d.ts.map +0 -1
  82. package/dist/classes/vector2.js.map +0 -1
  83. package/dist/classes/vector3.d.ts.map +0 -1
  84. package/dist/classes/vector3.js.map +0 -1
  85. package/dist/classes/vector4.d.ts.map +0 -1
  86. package/dist/classes/vector4.js.map +0 -1
  87. package/dist/gl-matrix/common.d.ts.map +0 -1
  88. package/dist/gl-matrix/common.js.map +0 -1
  89. package/dist/gl-matrix/mat3.d.ts.map +0 -1
  90. package/dist/gl-matrix/mat3.js.map +0 -1
  91. package/dist/gl-matrix/mat4.d.ts.map +0 -1
  92. package/dist/gl-matrix/mat4.js.map +0 -1
  93. package/dist/gl-matrix/quat.d.ts.map +0 -1
  94. package/dist/gl-matrix/quat.js.map +0 -1
  95. package/dist/gl-matrix/vec2.d.ts.map +0 -1
  96. package/dist/gl-matrix/vec2.js.map +0 -1
  97. package/dist/gl-matrix/vec3.d.ts.map +0 -1
  98. package/dist/gl-matrix/vec3.js.map +0 -1
  99. package/dist/gl-matrix/vec4.d.ts.map +0 -1
  100. package/dist/gl-matrix/vec4.js.map +0 -1
  101. package/dist/gl-matrix/wip/index.d.ts.map +0 -1
  102. package/dist/gl-matrix/wip/index.js.map +0 -1
  103. package/dist/gl-matrix/wip/mat2.d.ts.map +0 -1
  104. package/dist/gl-matrix/wip/mat2.js.map +0 -1
  105. package/dist/gl-matrix/wip/mat2d.d.ts.map +0 -1
  106. package/dist/gl-matrix/wip/mat2d.js.map +0 -1
  107. package/dist/gl-matrix/wip/quat2.d.ts.map +0 -1
  108. package/dist/gl-matrix/wip/quat2.js.map +0 -1
  109. package/dist/gl-matrix/wip/types.d.js +0 -2
  110. package/dist/gl-matrix/wip/types.d.js.map +0 -1
  111. package/dist/index.d.ts.map +0 -1
  112. package/dist/index.js.map +0 -1
  113. package/dist/lib/assert.d.ts.map +0 -1
  114. package/dist/lib/assert.js.map +0 -1
  115. package/dist/lib/common.d.ts.map +0 -1
  116. package/dist/lib/common.js.map +0 -1
  117. package/dist/lib/gl-matrix-extras.d.ts.map +0 -1
  118. package/dist/lib/gl-matrix-extras.js.map +0 -1
  119. package/dist/lib/gl-matrix.d.js +0 -2
  120. package/dist/lib/gl-matrix.d.js.map +0 -1
  121. package/dist/lib/math-utils.d.ts.map +0 -1
  122. package/dist/lib/math-utils.js.map +0 -1
  123. package/dist/lib/validators.d.ts.map +0 -1
  124. package/dist/lib/validators.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { NumericArray } from '@math.gl/types';
2
- import { Matrix } from './base/matrix';
2
+ import { Matrix } from "./base/matrix.js";
3
3
  declare enum INDICES {
4
4
  COL0ROW0 = 0,
5
5
  COL0ROW1 = 1,
@@ -48,7 +48,7 @@ export declare class Matrix3 extends Matrix {
48
48
  invert(): this;
49
49
  multiplyLeft(a: NumericArray): this;
50
50
  multiplyRight(a: NumericArray): this;
51
- rotate(radians: number): NumericArray;
51
+ rotate(radians: number): this;
52
52
  scale(factor: NumericArray | number): this;
53
53
  translate(vec: NumericArray): this;
54
54
  transform(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
@@ -60,4 +60,3 @@ export declare class Matrix3 extends Matrix {
60
60
  transformVector3(vector: Readonly<NumericArray>, result?: NumericArray): NumericArray;
61
61
  }
62
62
  export {};
63
- //# sourceMappingURL=matrix3.d.ts.map
@@ -1,3 +1,5 @@
1
+ // Copyright (c) 2017 Uber Technologies, Inc.
2
+ // MIT License
1
3
  import { Matrix } from "./base/matrix.js";
2
4
  import { checkVector } from "../lib/validators.js";
3
5
  import { vec4_transformMat3 } from "../lib/gl-matrix-extras.js";
@@ -5,204 +7,197 @@ import { fromQuat as mat3_fromQuat, determinant as mat3_determinant, transpose a
5
7
  import { transformMat3 as vec2_transformMat3 } from "../gl-matrix/vec2.js";
6
8
  import { transformMat3 as vec3_transformMat3 } from "../gl-matrix/vec3.js";
7
9
  var INDICES;
8
-
9
10
  (function (INDICES) {
10
- INDICES[INDICES["COL0ROW0"] = 0] = "COL0ROW0";
11
- INDICES[INDICES["COL0ROW1"] = 1] = "COL0ROW1";
12
- INDICES[INDICES["COL0ROW2"] = 2] = "COL0ROW2";
13
- INDICES[INDICES["COL1ROW0"] = 3] = "COL1ROW0";
14
- INDICES[INDICES["COL1ROW1"] = 4] = "COL1ROW1";
15
- INDICES[INDICES["COL1ROW2"] = 5] = "COL1ROW2";
16
- INDICES[INDICES["COL2ROW0"] = 6] = "COL2ROW0";
17
- INDICES[INDICES["COL2ROW1"] = 7] = "COL2ROW1";
18
- INDICES[INDICES["COL2ROW2"] = 8] = "COL2ROW2";
11
+ INDICES[INDICES["COL0ROW0"] = 0] = "COL0ROW0";
12
+ INDICES[INDICES["COL0ROW1"] = 1] = "COL0ROW1";
13
+ INDICES[INDICES["COL0ROW2"] = 2] = "COL0ROW2";
14
+ INDICES[INDICES["COL1ROW0"] = 3] = "COL1ROW0";
15
+ INDICES[INDICES["COL1ROW1"] = 4] = "COL1ROW1";
16
+ INDICES[INDICES["COL1ROW2"] = 5] = "COL1ROW2";
17
+ INDICES[INDICES["COL2ROW0"] = 6] = "COL2ROW0";
18
+ INDICES[INDICES["COL2ROW1"] = 7] = "COL2ROW1";
19
+ INDICES[INDICES["COL2ROW2"] = 8] = "COL2ROW2";
19
20
  })(INDICES || (INDICES = {}));
20
-
21
21
  const IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
22
22
  export class Matrix3 extends Matrix {
23
- static get IDENTITY() {
24
- return getIdentityMatrix();
25
- }
26
-
27
- static get ZERO() {
28
- return getZeroMatrix();
29
- }
30
-
31
- get ELEMENTS() {
32
- return 9;
33
- }
34
-
35
- get RANK() {
36
- return 3;
37
- }
38
-
39
- get INDICES() {
40
- return INDICES;
41
- }
42
-
43
- constructor(array, ...args) {
44
- super(-0, -0, -0, -0, -0, -0, -0, -0, -0);
45
-
46
- if (arguments.length === 1 && Array.isArray(array)) {
47
- this.copy(array);
48
- } else if (args.length > 0) {
49
- this.copy([array, ...args]);
50
- } else {
51
- this.identity();
52
- }
53
- }
54
-
55
- copy(array) {
56
- this[0] = array[0];
57
- this[1] = array[1];
58
- this[2] = array[2];
59
- this[3] = array[3];
60
- this[4] = array[4];
61
- this[5] = array[5];
62
- this[6] = array[6];
63
- this[7] = array[7];
64
- this[8] = array[8];
65
- return this.check();
66
- }
67
-
68
- identity() {
69
- return this.copy(IDENTITY_MATRIX);
70
- }
71
-
72
- fromObject(object) {
73
- return this.check();
74
- }
75
-
76
- fromQuaternion(q) {
77
- mat3_fromQuat(this, q);
78
- return this.check();
79
- }
80
-
81
- set(m00, m10, m20, m01, m11, m21, m02, m12, m22) {
82
- this[0] = m00;
83
- this[1] = m10;
84
- this[2] = m20;
85
- this[3] = m01;
86
- this[4] = m11;
87
- this[5] = m21;
88
- this[6] = m02;
89
- this[7] = m12;
90
- this[8] = m22;
91
- return this.check();
92
- }
93
-
94
- setRowMajor(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
95
- this[0] = m00;
96
- this[1] = m10;
97
- this[2] = m20;
98
- this[3] = m01;
99
- this[4] = m11;
100
- this[5] = m21;
101
- this[6] = m02;
102
- this[7] = m12;
103
- this[8] = m22;
104
- return this.check();
105
- }
106
-
107
- determinant() {
108
- return mat3_determinant(this);
109
- }
110
-
111
- transpose() {
112
- mat3_transpose(this, this);
113
- return this.check();
114
- }
115
-
116
- invert() {
117
- mat3_invert(this, this);
118
- return this.check();
119
- }
120
-
121
- multiplyLeft(a) {
122
- mat3_multiply(this, a, this);
123
- return this.check();
124
- }
125
-
126
- multiplyRight(a) {
127
- mat3_multiply(this, this, a);
128
- return this.check();
129
- }
130
-
131
- rotate(radians) {
132
- mat3_rotate(this, this, radians);
133
- return this.check();
134
- }
135
-
136
- scale(factor) {
137
- if (Array.isArray(factor)) {
138
- mat3_scale(this, this, factor);
139
- } else {
140
- mat3_scale(this, this, [factor, factor]);
141
- }
142
-
143
- return this.check();
144
- }
145
-
146
- translate(vec) {
147
- mat3_translate(this, this, vec);
148
- return this.check();
149
- }
150
-
151
- transform(vector, result) {
152
- let out;
153
-
154
- switch (vector.length) {
155
- case 2:
156
- out = vec2_transformMat3(result || [-0, -0], vector, this);
157
- break;
158
-
159
- case 3:
160
- out = vec3_transformMat3(result || [-0, -0, -0], vector, this);
161
- break;
162
-
163
- case 4:
164
- out = vec4_transformMat3(result || [-0, -0, -0, -0], vector, this);
165
- break;
166
-
167
- default:
168
- throw new Error('Illegal vector');
169
- }
170
-
171
- checkVector(out, vector.length);
172
- return out;
173
- }
174
-
175
- transformVector(vector, result) {
176
- return this.transform(vector, result);
177
- }
178
-
179
- transformVector2(vector, result) {
180
- return this.transform(vector, result);
181
- }
182
-
183
- transformVector3(vector, result) {
184
- return this.transform(vector, result);
185
- }
186
-
23
+ static get IDENTITY() {
24
+ return getIdentityMatrix();
25
+ }
26
+ static get ZERO() {
27
+ return getZeroMatrix();
28
+ }
29
+ get ELEMENTS() {
30
+ return 9;
31
+ }
32
+ get RANK() {
33
+ return 3;
34
+ }
35
+ get INDICES() {
36
+ return INDICES;
37
+ }
38
+ constructor(array, ...args) {
39
+ // PERF NOTE: initialize elements as double precision numbers
40
+ super(-0, -0, -0, -0, -0, -0, -0, -0, -0);
41
+ if (arguments.length === 1 && Array.isArray(array)) {
42
+ this.copy(array);
43
+ }
44
+ else if (args.length > 0) {
45
+ this.copy([array, ...args]);
46
+ }
47
+ else {
48
+ this.identity();
49
+ }
50
+ }
51
+ copy(array) {
52
+ // Element wise copy for performance
53
+ this[0] = array[0];
54
+ this[1] = array[1];
55
+ this[2] = array[2];
56
+ this[3] = array[3];
57
+ this[4] = array[4];
58
+ this[5] = array[5];
59
+ this[6] = array[6];
60
+ this[7] = array[7];
61
+ this[8] = array[8];
62
+ return this.check();
63
+ }
64
+ // Constructors
65
+ identity() {
66
+ return this.copy(IDENTITY_MATRIX);
67
+ }
68
+ /**
69
+ *
70
+ * @param object
71
+ * @returns self
72
+ */
73
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
74
+ fromObject(object) {
75
+ return this.check();
76
+ }
77
+ /** Calculates a 3x3 matrix from the given quaternion
78
+ * q quat Quaternion to create matrix from
79
+ */
80
+ fromQuaternion(q) {
81
+ mat3_fromQuat(this, q);
82
+ return this.check();
83
+ }
84
+ /**
85
+ * accepts column major order, stores in column major order
86
+ */
87
+ // eslint-disable-next-line max-params
88
+ set(m00, m10, m20, m01, m11, m21, m02, m12, m22) {
89
+ this[0] = m00;
90
+ this[1] = m10;
91
+ this[2] = m20;
92
+ this[3] = m01;
93
+ this[4] = m11;
94
+ this[5] = m21;
95
+ this[6] = m02;
96
+ this[7] = m12;
97
+ this[8] = m22;
98
+ return this.check();
99
+ }
100
+ /**
101
+ * accepts row major order, stores as column major
102
+ */
103
+ // eslint-disable-next-line max-params
104
+ setRowMajor(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
105
+ this[0] = m00;
106
+ this[1] = m10;
107
+ this[2] = m20;
108
+ this[3] = m01;
109
+ this[4] = m11;
110
+ this[5] = m21;
111
+ this[6] = m02;
112
+ this[7] = m12;
113
+ this[8] = m22;
114
+ return this.check();
115
+ }
116
+ // Accessors
117
+ determinant() {
118
+ return mat3_determinant(this);
119
+ }
120
+ // Modifiers
121
+ transpose() {
122
+ mat3_transpose(this, this);
123
+ return this.check();
124
+ }
125
+ /** Invert a matrix. Note that this can fail if the matrix is not invertible */
126
+ invert() {
127
+ mat3_invert(this, this);
128
+ return this.check();
129
+ }
130
+ // Operations
131
+ multiplyLeft(a) {
132
+ mat3_multiply(this, a, this);
133
+ return this.check();
134
+ }
135
+ multiplyRight(a) {
136
+ mat3_multiply(this, this, a);
137
+ return this.check();
138
+ }
139
+ rotate(radians) {
140
+ mat3_rotate(this, this, radians);
141
+ return this.check();
142
+ }
143
+ scale(factor) {
144
+ if (Array.isArray(factor)) {
145
+ mat3_scale(this, this, factor);
146
+ }
147
+ else {
148
+ mat3_scale(this, this, [factor, factor]);
149
+ }
150
+ return this.check();
151
+ }
152
+ translate(vec) {
153
+ mat3_translate(this, this, vec);
154
+ return this.check();
155
+ }
156
+ // Transforms
157
+ transform(vector, result) {
158
+ let out;
159
+ switch (vector.length) {
160
+ case 2:
161
+ out = vec2_transformMat3(result || [-0, -0], vector, this);
162
+ break;
163
+ case 3:
164
+ out = vec3_transformMat3(result || [-0, -0, -0], vector, this);
165
+ break;
166
+ case 4:
167
+ out = vec4_transformMat3(result || [-0, -0, -0, -0], vector, this);
168
+ break;
169
+ default:
170
+ throw new Error('Illegal vector');
171
+ }
172
+ checkVector(out, vector.length);
173
+ return out;
174
+ }
175
+ /** @deprecated */
176
+ transformVector(vector, result) {
177
+ return this.transform(vector, result);
178
+ }
179
+ /** @deprecated */
180
+ transformVector2(vector, result) {
181
+ return this.transform(vector, result);
182
+ }
183
+ /** @deprecated */
184
+ transformVector3(vector, result) {
185
+ return this.transform(vector, result);
186
+ }
187
187
  }
188
188
  let ZERO_MATRIX3;
189
189
  let IDENTITY_MATRIX3 = null;
190
-
191
190
  function getZeroMatrix() {
192
- if (!ZERO_MATRIX3) {
193
- ZERO_MATRIX3 = new Matrix3([0, 0, 0, 0, 0, 0, 0, 0, 0]);
194
- Object.freeze(ZERO_MATRIX3);
195
- }
196
-
197
- return ZERO_MATRIX3;
191
+ if (!ZERO_MATRIX3) {
192
+ ZERO_MATRIX3 = new Matrix3([0, 0, 0, 0, 0, 0, 0, 0, 0]);
193
+ Object.freeze(ZERO_MATRIX3);
194
+ }
195
+ return ZERO_MATRIX3;
198
196
  }
199
-
200
197
  function getIdentityMatrix() {
201
- if (!IDENTITY_MATRIX3) {
202
- IDENTITY_MATRIX3 = new Matrix3();
203
- Object.freeze(IDENTITY_MATRIX3);
204
- }
205
-
206
- return IDENTITY_MATRIX3;
198
+ if (!IDENTITY_MATRIX3) {
199
+ IDENTITY_MATRIX3 = new Matrix3();
200
+ Object.freeze(IDENTITY_MATRIX3);
201
+ }
202
+ return IDENTITY_MATRIX3;
207
203
  }
208
- //# sourceMappingURL=matrix3.js.map
@@ -1,5 +1,5 @@
1
1
  import { NumericArray } from '@math.gl/types';
2
- import { Matrix } from './base/matrix';
2
+ import { Matrix } from "./base/matrix.js";
3
3
  declare enum INDICES {
4
4
  COL0ROW0 = 0,
5
5
  COL0ROW1 = 1,
@@ -223,4 +223,3 @@ export declare class Matrix4 extends Matrix {
223
223
  makeTranslation(x: number, y: number, z: number): this;
224
224
  }
225
225
  export {};
226
- //# sourceMappingURL=matrix4.d.ts.map