@math.gl/core 4.0.1 → 4.1.0-alpha.2

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 (59) hide show
  1. package/dist/classes/base/math-array.js +3 -0
  2. package/dist/classes/base/matrix.js +4 -0
  3. package/dist/classes/base/vector.js +4 -0
  4. package/dist/classes/euler.js +5 -2
  5. package/dist/classes/matrix3.d.ts +7 -1
  6. package/dist/classes/matrix3.js +8 -1
  7. package/dist/classes/matrix4.d.ts +7 -2
  8. package/dist/classes/matrix4.js +8 -2
  9. package/dist/classes/pose.js +3 -1
  10. package/dist/classes/quaternion.js +4 -0
  11. package/dist/classes/spherical-coordinates.js +5 -2
  12. package/dist/classes/vector2.d.ts +5 -3
  13. package/dist/classes/vector2.js +5 -3
  14. package/dist/classes/vector3.d.ts +5 -3
  15. package/dist/classes/vector3.js +6 -2
  16. package/dist/classes/vector4.d.ts +5 -3
  17. package/dist/classes/vector4.js +5 -3
  18. package/dist/gl-matrix/vec2.d.ts +10 -9
  19. package/dist/gl-matrix/vec2.js +6 -6
  20. package/dist/gl-matrix/wip/index.js +3 -0
  21. package/dist/gl-matrix/wip/mat2.d.ts +1 -1
  22. package/dist/gl-matrix/wip/mat2.js +3 -0
  23. package/dist/gl-matrix/wip/mat2d.js +3 -0
  24. package/dist/gl-matrix/wip/quat2.js +3 -0
  25. package/dist/index.cjs.map +2 -2
  26. package/dist/index.d.ts +7 -2
  27. package/dist/index.js +3 -1
  28. package/dist/lib/assert.js +3 -0
  29. package/dist/lib/common.js +3 -1
  30. package/dist/lib/gl-matrix-extras.js +3 -0
  31. package/dist/lib/math-utils.js +3 -0
  32. package/dist/lib/validators.d.ts +3 -3
  33. package/dist/lib/validators.js +3 -0
  34. package/package.json +3 -3
  35. package/src/classes/base/math-array.ts +5 -2
  36. package/src/classes/base/matrix.ts +4 -1
  37. package/src/classes/base/vector.ts +4 -1
  38. package/src/classes/euler.ts +6 -2
  39. package/src/classes/matrix3.ts +12 -2
  40. package/src/classes/matrix4.ts +12 -3
  41. package/src/classes/pose.ts +4 -1
  42. package/src/classes/quaternion.ts +4 -1
  43. package/src/classes/spherical-coordinates.ts +5 -3
  44. package/src/classes/vector2.ts +11 -4
  45. package/src/classes/vector3.ts +10 -4
  46. package/src/classes/vector4.ts +9 -4
  47. package/src/gl-matrix/vec2.ts +9 -9
  48. package/src/gl-matrix/wip/index.js +4 -0
  49. package/src/gl-matrix/wip/mat2.js +4 -0
  50. package/src/gl-matrix/wip/mat2d.js +4 -0
  51. package/src/gl-matrix/wip/quat2.ts +4 -0
  52. package/src/index.ts +24 -3
  53. package/src/lib/assert.ts +4 -0
  54. package/src/lib/common.ts +6 -2
  55. package/src/lib/gl-matrix-extras.ts +4 -0
  56. package/src/lib/gl-matrix.d.ts +4 -0
  57. package/src/lib/math-utils.ts +4 -0
  58. package/src/lib/validators.ts +7 -22
  59. package/src/gl-matrix/wip/types.d.ts +0 -93
@@ -1,3 +1,6 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { config, formatValue, equals, isArray } from "../../lib/common.js";
2
5
  /** Base class for vectors and matrices */
3
6
  export class MathArray extends Array {
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ // Copyright (c) 2017 Uber Technologies, Inc.
1
5
  import { MathArray } from "./math-array.js";
2
6
  import { checkNumber } from "../../lib/validators.js";
3
7
  import { config } from "../../lib/common.js";
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ // Copyright (c) 2017 Uber Technologies, Inc.
1
5
  import { MathArray } from "./math-array.js";
2
6
  import { checkNumber } from "../../lib/validators.js";
3
7
  import { assert } from "../../lib/assert.js";
@@ -1,5 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // Copyright (c) 2017 Uber Technologies, Inc.
2
- // MIT License
3
5
  import { MathArray } from "./base/math-array.js";
4
6
  import { Quaternion } from "./quaternion.js";
5
7
  import { clamp } from "../lib/common.js";
@@ -7,6 +9,7 @@ import { checkNumber } from "../lib/validators.js";
7
9
  // Internal constants
8
10
  const ERR_UNKNOWN_ORDER = 'Unknown Euler angle order';
9
11
  const ALMOST_ONE = 0.99999;
12
+ // eslint-disable-next-line no-shadow
10
13
  var RotationOrder;
11
14
  (function (RotationOrder) {
12
15
  RotationOrder[RotationOrder["ZYX"] = 0] = "ZYX";
@@ -63,8 +66,8 @@ export class Euler extends MathArray {
63
66
  super(-0, -0, -0, -0);
64
67
  // eslint-disable-next-line prefer-rest-params
65
68
  if (arguments.length > 0 && Array.isArray(arguments[0])) {
66
- // eslint-disable-next-line prefer-rest-params
67
69
  // @ts-expect-error
70
+ // eslint-disable-next-line prefer-rest-params
68
71
  this.fromVector3(...arguments);
69
72
  }
70
73
  else {
@@ -1,4 +1,4 @@
1
- import { NumericArray } from '@math.gl/types';
1
+ import { NumericArray, NumberArray9 } from '@math.gl/types';
2
2
  import { Matrix } from "./base/matrix.js";
3
3
  declare enum INDICES {
4
4
  COL0ROW0 = 0,
@@ -11,6 +11,12 @@ declare enum INDICES {
11
11
  COL2ROW1 = 7,
12
12
  COL2ROW2 = 8
13
13
  }
14
+ /** Helper type that captures array length for a 3x3 matrix */
15
+ export type Matrix3Like = Matrix3 | NumberArray9;
16
+ /**
17
+ * A 3x3 matrix with common linear algebra operations
18
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
19
+ */
14
20
  export declare class Matrix3 extends Matrix {
15
21
  static get IDENTITY(): Readonly<Matrix3>;
16
22
  static get ZERO(): Readonly<Matrix3>;
@@ -1,11 +1,14 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // Copyright (c) 2017 Uber Technologies, Inc.
2
- // MIT License
3
5
  import { Matrix } from "./base/matrix.js";
4
6
  import { checkVector } from "../lib/validators.js";
5
7
  import { vec4_transformMat3 } from "../lib/gl-matrix-extras.js";
6
8
  import { fromQuat as mat3_fromQuat, determinant as mat3_determinant, transpose as mat3_transpose, invert as mat3_invert, multiply as mat3_multiply, rotate as mat3_rotate, scale as mat3_scale, translate as mat3_translate } from "../gl-matrix/mat3.js";
7
9
  import { transformMat3 as vec2_transformMat3 } from "../gl-matrix/vec2.js";
8
10
  import { transformMat3 as vec3_transformMat3 } from "../gl-matrix/vec3.js";
11
+ // eslint-disable-next-line no-shadow
9
12
  var INDICES;
10
13
  (function (INDICES) {
11
14
  INDICES[INDICES["COL0ROW0"] = 0] = "COL0ROW0";
@@ -19,6 +22,10 @@ var INDICES;
19
22
  INDICES[INDICES["COL2ROW2"] = 8] = "COL2ROW2";
20
23
  })(INDICES || (INDICES = {}));
21
24
  const IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
25
+ /**
26
+ * A 3x3 matrix with common linear algebra operations
27
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
28
+ */
22
29
  export class Matrix3 extends Matrix {
23
30
  static get IDENTITY() {
24
31
  return getIdentityMatrix();
@@ -1,4 +1,4 @@
1
- import { NumericArray } from '@math.gl/types';
1
+ import { NumericArray, NumberArray16 } from '@math.gl/types';
2
2
  import { Matrix } from "./base/matrix.js";
3
3
  declare enum INDICES {
4
4
  COL0ROW0 = 0,
@@ -18,7 +18,12 @@ declare enum INDICES {
18
18
  COL3ROW2 = 14,
19
19
  COL3ROW3 = 15
20
20
  }
21
- /** 4x4 matrix */
21
+ /** Helper type that captures array length for a 4x4 matrix */
22
+ export type Matrix4Like = Matrix4 | NumberArray16;
23
+ /**
24
+ * A 4x4 matrix with common linear algebra operations
25
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
26
+ */
22
27
  export declare class Matrix4 extends Matrix {
23
28
  static get IDENTITY(): Readonly<Matrix4>;
24
29
  static get ZERO(): Readonly<Matrix4>;
@@ -1,5 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // Copyright (c) 2017 Uber Technologies, Inc.
2
- // MIT License
3
5
  import { Matrix } from "./base/matrix.js";
4
6
  import { checkVector } from "../lib/validators.js";
5
7
  /* eslint-disable camelcase */
@@ -9,6 +11,7 @@ import { fromQuat as mat4_fromQuat, frustum as mat4_frustum, lookAt as mat4_look
9
11
  import { transformMat4 as vec2_transformMat4 } from "../gl-matrix/vec2.js";
10
12
  import { transformMat4 as vec3_transformMat4 } from "../gl-matrix/vec3.js";
11
13
  import { transformMat4 as vec4_transformMat4 } from "../gl-matrix/vec4.js";
14
+ // eslint-disable-next-line no-shadow
12
15
  var INDICES;
13
16
  (function (INDICES) {
14
17
  INDICES[INDICES["COL0ROW0"] = 0] = "COL0ROW0";
@@ -33,7 +36,10 @@ const DEFAULT_ASPECT = 1;
33
36
  const DEFAULT_NEAR = 0.1;
34
37
  const DEFAULT_FAR = 500;
35
38
  const IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
36
- /** 4x4 matrix */
39
+ /**
40
+ * A 4x4 matrix with common linear algebra operations
41
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
42
+ */
37
43
  export class Matrix4 extends Matrix {
38
44
  static get IDENTITY() {
39
45
  return getIdentityMatrix();
@@ -1,5 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // Copyright (c) 2017 Uber Technologies, Inc.
2
- // MIT License
3
5
  import { Matrix4 } from "./matrix4.js";
4
6
  import { Vector3 } from "./vector3.js";
5
7
  import { Euler } from "./euler.js";
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ // Copyright (c) 2017 Uber Technologies, Inc.
1
5
  import { MathArray } from "./base/math-array.js";
2
6
  import { checkNumber, checkVector } from "../lib/validators.js";
3
7
  import { Vector4 } from "./vector4.js";
@@ -1,6 +1,9 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ // Copyright (c) 2017 Uber Technologies, Inc.
1
5
  import { Vector3 } from "./vector3.js";
2
- import { formatValue, equals, config } from "../lib/common.js";
3
- import { degrees, radians, clamp } from "../lib/common.js";
6
+ import { formatValue, equals, config, degrees, radians, clamp } from "../lib/common.js";
4
7
  // @ts-ignore gl-matrix types...
5
8
  import * as vec3 from "../gl-matrix/vec3.js";
6
9
  // TODO - import epsilon
@@ -1,8 +1,10 @@
1
+ import { NumericArray, NumberArray2 } from '@math.gl/types';
1
2
  import { Vector } from "./base/vector.js";
2
- import { NumericArray } from '@math.gl/types';
3
+ /** Helper type that captures array length for a 2 element vector */
4
+ export type Vector2Like = Vector2 | NumberArray2;
3
5
  /**
4
- * Two-element vector class.
5
- * Subclass of Array<number>
6
+ * Two-element vector class with common linear algebra operations.
7
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
6
8
  */
7
9
  export declare class Vector2 extends Vector {
8
10
  constructor(x?: number | Readonly<NumericArray>, y?: number);
@@ -1,13 +1,15 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // Copyright (c) 2017 Uber Technologies, Inc.
2
- // MIT License
3
5
  import { Vector } from "./base/vector.js";
4
6
  import { config, isArray } from "../lib/common.js";
5
7
  import { checkNumber } from "../lib/validators.js";
6
8
  import { transformMat4 as vec2_transformMat4, transformMat3 as vec2_transformMat3, transformMat2d as vec2_transformMat2d, transformMat2 as vec2_transformMat2 } from "../gl-matrix/vec2.js";
7
9
  import { vec2_transformMat4AsVector } from "../lib/gl-matrix-extras.js";
8
10
  /**
9
- * Two-element vector class.
10
- * Subclass of Array<number>
11
+ * Two-element vector class with common linear algebra operations.
12
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
11
13
  */
12
14
  export class Vector2 extends Vector {
13
15
  // Creates a new, empty vec2
@@ -1,8 +1,10 @@
1
- import { NumericArray } from '@math.gl/types';
1
+ import { NumericArray, NumberArray3 } from '@math.gl/types';
2
2
  import { Vector } from "./base/vector.js";
3
+ /** Helper type that captures array length for a 3 element vector */
4
+ export type Vector3Like = Vector3 | NumberArray3;
3
5
  /**
4
- * Three-element vector class.
5
- * Subclass of Array<number>
6
+ * Three-element vector class with common linear algebra operations.
7
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
6
8
  */
7
9
  export declare class Vector3 extends Vector {
8
10
  static get ZERO(): Vector3;
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ // Copyright (c) 2017 Uber Technologies, Inc.
1
5
  import { Vector } from "./base/vector.js";
2
6
  import { config, isArray } from "../lib/common.js";
3
7
  import { checkNumber } from "../lib/validators.js";
@@ -8,8 +12,8 @@ import { vec3_transformMat2, vec3_transformMat4AsVector } from "../lib/gl-matrix
8
12
  const ORIGIN = [0, 0, 0];
9
13
  let ZERO;
10
14
  /**
11
- * Three-element vector class.
12
- * Subclass of Array<number>
15
+ * Three-element vector class with common linear algebra operations.
16
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
13
17
  */
14
18
  export class Vector3 extends Vector {
15
19
  static get ZERO() {
@@ -1,9 +1,11 @@
1
- import { NumericArray } from '@math.gl/types';
1
+ import { NumericArray, NumberArray4 } from '@math.gl/types';
2
2
  import { Vector } from "./base/vector.js";
3
3
  import type { Matrix4 } from "./matrix4.js";
4
+ /** Helper type that captures array length for a 4 element vector */
5
+ export type Vector4Like = Vector4 | NumberArray4;
4
6
  /**
5
- * Four-element vector class.
6
- * Subclass of Array<number>
7
+ * Four-element vector class with common linear algebra operations.
8
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
7
9
  */
8
10
  export declare class Vector4 extends Vector {
9
11
  static get ZERO(): Vector4;
@@ -1,5 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // Copyright (c) 2017 Uber Technologies, Inc.
2
- // MIT License
3
5
  /* eslint-disable camelcase */
4
6
  import { transformMat4 as vec4_transformMat4, transformQuat as vec4_transformQuat } from "../gl-matrix/vec3.js";
5
7
  import { vec4_transformMat2, vec4_transformMat3 } from "../lib/gl-matrix-extras.js";
@@ -8,8 +10,8 @@ import { config, isArray } from "../lib/common.js";
8
10
  import { checkNumber } from "../lib/validators.js";
9
11
  let ZERO;
10
12
  /**
11
- * Four-element vector class.
12
- * Subclass of Array<number>
13
+ * Four-element vector class with common linear algebra operations.
14
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
13
15
  */
14
16
  export class Vector4 extends Vector {
15
17
  static get ZERO() {
@@ -1,3 +1,4 @@
1
+ import type { NumericArray } from '@math.gl/types';
1
2
  /**
2
3
  * 2 Dimensional Vector
3
4
  * @module vec2
@@ -5,24 +6,24 @@
5
6
  /**
6
7
  * Creates a new, empty vec2
7
8
  *
8
- * @returns {NumericArray} a new 2D vector
9
+ * @returns a new 2D vector
9
10
  */
10
- export declare function create(): any[] | Float32Array;
11
+ export declare function create(): NumericArray;
11
12
  /**
12
13
  * Creates a new vec2 initialized with values from an existing vector
13
14
  *
14
- * @param {Readonly<NumericArray>} a vector to clone
15
- * @returns {NumericArray} a new 2D vector
15
+ * @param a vector to clone
16
+ * @returns a new 2D vector
16
17
  */
17
- export declare function clone(a: any): any[] | Float32Array;
18
+ export declare function clone(a: Readonly<NumericArray>): NumericArray;
18
19
  /**
19
20
  * Creates a new vec2 initialized with the given values
20
21
  *
21
- * @param {Number} x X component
22
- * @param {Number} y Y component
23
- * @returns {NumericArray} a new 2D vector
22
+ * @param x X component
23
+ * @param y Y component
24
+ * @returns a new 2D vector
24
25
  */
25
- export declare function fromValues(x: any, y: any): any[] | Float32Array;
26
+ export declare function fromValues(x: number, y: number): NumericArray;
26
27
  /**
27
28
  * Copy the values from one vec2 to another
28
29
  *
@@ -8,7 +8,7 @@ import * as glMatrix from './common.js';
8
8
  /**
9
9
  * Creates a new, empty vec2
10
10
  *
11
- * @returns {NumericArray} a new 2D vector
11
+ * @returns a new 2D vector
12
12
  */
13
13
  export function create() {
14
14
  const out = new glMatrix.ARRAY_TYPE(2);
@@ -21,8 +21,8 @@ export function create() {
21
21
  /**
22
22
  * Creates a new vec2 initialized with values from an existing vector
23
23
  *
24
- * @param {Readonly<NumericArray>} a vector to clone
25
- * @returns {NumericArray} a new 2D vector
24
+ * @param a vector to clone
25
+ * @returns a new 2D vector
26
26
  */
27
27
  export function clone(a) {
28
28
  const out = new glMatrix.ARRAY_TYPE(2);
@@ -33,9 +33,9 @@ export function clone(a) {
33
33
  /**
34
34
  * Creates a new vec2 initialized with the given values
35
35
  *
36
- * @param {Number} x X component
37
- * @param {Number} y Y component
38
- * @returns {NumericArray} a new 2D vector
36
+ * @param x X component
37
+ * @param y Y component
38
+ * @returns a new 2D vector
39
39
  */
40
40
  export function fromValues(x, y) {
41
41
  const out = new glMatrix.ARRAY_TYPE(2);
@@ -1,3 +1,6 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // @eslint-disable
2
5
  // @ts-nocheck
3
6
  import * as glMatrix from './common.js';
@@ -154,7 +154,7 @@ export function frob(a: ReadonlyMat2): number;
154
154
  * @param {ReadonlyMat2} U the upper triangular matrix
155
155
  * @param {ReadonlyMat2} a the input matrix to factorize
156
156
  */
157
- export function LDU(L: ReadonlyMat2, D: ReadonlyMat2, U: ReadonlyMat2, a: ReadonlyMat2): ReadonlyMat2[];
157
+ export function LDU(L: ReadonlyMat2, D: ReadonlyMat2, U: ReadonlyMat2, a: ReadonlyMat2): any[];
158
158
  /**
159
159
  * Adds two mat2's
160
160
  *
@@ -1,3 +1,6 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // @ts-nocheck
2
5
  /* eslint-disable */
3
6
  import * as glMatrix from './common.js';
@@ -1,3 +1,6 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // @ts-nocheck
2
5
  /* eslint-disable */
3
6
  import * as glMatrix from './common.js';
@@ -1,3 +1,6 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // @ts-nocheck
2
5
  /* eslint-disable */
3
6
  import * as glMatrix from './common.js';