@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
package/dist/index.d.ts CHANGED
@@ -1,11 +1,16 @@
1
- export type { TypedArray, NumericArray } from '@math.gl/types';
2
- export type { isTypedArray, isNumericArray } from '@math.gl/types';
1
+ export type { TypedArray, TypedArrayConstructor, NumericArray, NumberArray, NumberArray2, NumberArray3, NumberArray4, NumberArray6, NumberArray8, NumberArray9, NumberArray12, NumberArray16 } from '@math.gl/types';
2
+ export type { isTypedArray, isNumberArray, isNumericArray } from '@math.gl/types';
3
3
  export { Vector2 } from "./classes/vector2.js";
4
4
  export { Vector3 } from "./classes/vector3.js";
5
5
  export { Vector4 } from "./classes/vector4.js";
6
6
  export { Matrix3 } from "./classes/matrix3.js";
7
7
  export { Matrix4 } from "./classes/matrix4.js";
8
8
  export { Quaternion } from "./classes/quaternion.js";
9
+ export type { Vector2Like } from "./classes/vector2.js";
10
+ export type { Vector3Like } from "./classes/vector3.js";
11
+ export type { Vector4Like } from "./classes/vector4.js";
12
+ export type { Matrix3Like } from "./classes/matrix3.js";
13
+ export type { Matrix4Like } from "./classes/matrix4.js";
9
14
  export { SphericalCoordinates } from "./classes/spherical-coordinates.js";
10
15
  export { Pose } from "./classes/pose.js";
11
16
  export { Euler } from "./classes/euler.js";
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
- // luma.gl, MIT license
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
2
4
  // classes
3
5
  export { Vector2 } from "./classes/vector2.js";
4
6
  export { Vector3 } from "./classes/vector3.js";
@@ -1,3 +1,6 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  export function assert(condition, message) {
2
5
  if (!condition) {
3
6
  throw new Error(`math.gl assertion ${message}`);
@@ -1,4 +1,6 @@
1
- // math.gl, MIT license
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
2
4
  const RADIANS_TO_DEGREES = (1 / Math.PI) * 180;
3
5
  const DEGREES_TO_RADIANS = (1 / 180) * Math.PI;
4
6
  const DEFAULT_CONFIG = {
@@ -1,3 +1,6 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // vec2 additions
2
5
  export function vec2_transformMat4AsVector(out, a, m) {
3
6
  const x = a[0];
@@ -1,3 +1,6 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  // NOTE: Added to make Cesium-derived test cases work
2
5
  // TODO: Determine if/how to keep
3
6
  export const EPSILON1 = 1e-1;
@@ -1,5 +1,5 @@
1
- import { NumberArray } from '@math.gl/types';
2
- export declare function validateVector(v: NumberArray, length: number): boolean;
1
+ import { NumericArray } from '@math.gl/types';
2
+ export declare function validateVector(v: NumericArray, length: number): boolean;
3
3
  export declare function checkNumber(value: unknown): number;
4
- export declare function checkVector<T extends NumberArray>(v: T, length: number, callerName?: string): T;
4
+ export declare function checkVector<T extends NumericArray>(v: T, length: number, callerName?: string): T;
5
5
  export declare function deprecated(method: string, version: string): void;
@@ -1,3 +1,6 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { config } from "./common.js";
2
5
  export function validateVector(v, length) {
3
6
  if (v.length !== length) {
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "version": "4.0.1",
9
+ "version": "4.1.0-alpha.2",
10
10
  "keywords": [
11
11
  "webgl",
12
12
  "javascript",
@@ -45,7 +45,7 @@
45
45
  "./src/lib/common.js"
46
46
  ],
47
47
  "dependencies": {
48
- "@math.gl/types": "4.0.1"
48
+ "@math.gl/types": "4.1.0-alpha.2"
49
49
  },
50
- "gitHead": "33f369ba3a259f79acc3fa8181190c9da8841648"
50
+ "gitHead": "59eb434870991d06aecff5b1dee38078af0ca447"
51
51
  }
@@ -1,4 +1,7 @@
1
- // math.gl, MIT License
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
2
5
  import {NumericArray} from '@math.gl/types';
3
6
  import {ConfigurationOptions, config, formatValue, equals, isArray} from '../../lib/common';
4
7
 
@@ -47,7 +50,7 @@ export abstract class MathArray extends Array<number> {
47
50
  return Array.isArray(arrayOrObject)
48
51
  ? this.copy(arrayOrObject)
49
52
  : // @ts-ignore
50
- this.fromObject(arrayOrObject);
53
+ this.fromObject(arrayOrObject);
51
54
  }
52
55
 
53
56
  to<T extends NumericArray | Record<string, unknown>>(arrayOrObject: T): T {
@@ -1,5 +1,8 @@
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
5
+
3
6
  import {NumericArray} from '@math.gl/types';
4
7
  import {MathArray} from './math-array';
5
8
  import {checkNumber} from '../../lib/validators';
@@ -1,5 +1,8 @@
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
5
+
3
6
  import {NumericArray} from '@math.gl/types';
4
7
  import {MathArray} from './math-array';
5
8
  import {checkNumber} from '../../lib/validators';
@@ -1,5 +1,8 @@
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
5
+
3
6
  import {MathArray} from './base/math-array';
4
7
  import {Quaternion} from './quaternion';
5
8
  import {NumericArray} from '@math.gl/types';
@@ -11,6 +14,7 @@ import {checkNumber} from '../lib/validators';
11
14
  const ERR_UNKNOWN_ORDER = 'Unknown Euler angle order';
12
15
  const ALMOST_ONE = 0.99999;
13
16
 
17
+ // eslint-disable-next-line no-shadow
14
18
  enum RotationOrder {
15
19
  ZYX = 0,
16
20
  YXZ = 1,
@@ -68,8 +72,8 @@ export class Euler extends MathArray {
68
72
  super(-0, -0, -0, -0);
69
73
  // eslint-disable-next-line prefer-rest-params
70
74
  if (arguments.length > 0 && Array.isArray(arguments[0])) {
71
- // eslint-disable-next-line prefer-rest-params
72
75
  // @ts-expect-error
76
+ // eslint-disable-next-line prefer-rest-params
73
77
  this.fromVector3(...arguments);
74
78
  } else {
75
79
  this.set(x, y, z, order);
@@ -1,7 +1,9 @@
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
 
4
- import {NumericArray} from '@math.gl/types';
6
+ import {NumericArray, NumberArray9} from '@math.gl/types';
5
7
  import {Matrix} from './base/matrix';
6
8
  import {checkVector} from '../lib/validators';
7
9
 
@@ -20,6 +22,7 @@ import {
20
22
  import {transformMat3 as vec2_transformMat3} from '../gl-matrix/vec2';
21
23
  import {transformMat3 as vec3_transformMat3} from '../gl-matrix/vec3';
22
24
 
25
+ // eslint-disable-next-line no-shadow
23
26
  enum INDICES {
24
27
  COL0ROW0 = 0,
25
28
  COL0ROW1 = 1,
@@ -34,6 +37,13 @@ enum INDICES {
34
37
 
35
38
  const IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
36
39
 
40
+ /** Helper type that captures array length for a 3x3 matrix */
41
+ export type Matrix3Like = Matrix3 | NumberArray9;
42
+
43
+ /**
44
+ * A 3x3 matrix with common linear algebra operations
45
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
46
+ */
37
47
  export class Matrix3 extends Matrix {
38
48
  static get IDENTITY(): Readonly<Matrix3> {
39
49
  return getIdentityMatrix();
@@ -1,7 +1,9 @@
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
 
4
- import {NumericArray} from '@math.gl/types';
6
+ import {NumericArray, NumberArray16} from '@math.gl/types';
5
7
  import {Matrix} from './base/matrix';
6
8
  import {checkVector} from '../lib/validators';
7
9
 
@@ -29,6 +31,7 @@ import {transformMat4 as vec2_transformMat4} from '../gl-matrix/vec2';
29
31
  import {transformMat4 as vec3_transformMat4} from '../gl-matrix/vec3';
30
32
  import {transformMat4 as vec4_transformMat4} from '../gl-matrix/vec4';
31
33
 
34
+ // eslint-disable-next-line no-shadow
32
35
  enum INDICES {
33
36
  COL0ROW0 = 0,
34
37
  COL0ROW1 = 1,
@@ -55,7 +58,13 @@ const DEFAULT_FAR = 500;
55
58
 
56
59
  const IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
57
60
 
58
- /** 4x4 matrix */
61
+ /** Helper type that captures array length for a 4x4 matrix */
62
+ export type Matrix4Like = Matrix4 | NumberArray16;
63
+
64
+ /**
65
+ * A 4x4 matrix with common linear algebra operations
66
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
67
+ */
59
68
  export class Matrix4 extends Matrix {
60
69
  static get IDENTITY(): Readonly<Matrix4> {
61
70
  return getIdentityMatrix();
@@ -1,5 +1,8 @@
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
5
+
3
6
  import {Matrix4} from './matrix4';
4
7
  import {Vector3} from './vector3';
5
8
  import {Euler} from './euler';
@@ -1,5 +1,8 @@
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
5
+
3
6
  import {NumericArray} from '@math.gl/types';
4
7
  import {MathArray} from './base/math-array';
5
8
  import {checkNumber, checkVector} from '../lib/validators';
@@ -1,10 +1,12 @@
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
5
+
3
6
  // Adaptation of THREE.js Spherical class, under MIT license
4
7
  import {NumericArray} from '@math.gl/types';
5
8
  import {Vector3} from './vector3';
6
- import {formatValue, equals, config} from '../lib/common';
7
- import {degrees, radians, clamp} from '../lib/common';
9
+ import {formatValue, equals, config, degrees, radians, clamp} from '../lib/common';
8
10
  // @ts-ignore gl-matrix types...
9
11
  import * as vec3 from '../gl-matrix/vec3';
10
12
 
@@ -1,5 +1,10 @@
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
5
+
6
+ import {NumericArray, NumberArray2} from '@math.gl/types';
7
+
3
8
  import {Vector} from './base/vector';
4
9
  import {config, isArray} from '../lib/common';
5
10
  import {checkNumber} from '../lib/validators';
@@ -10,11 +15,13 @@ import {
10
15
  transformMat2 as vec2_transformMat2
11
16
  } from '../gl-matrix/vec2';
12
17
  import {vec2_transformMat4AsVector} from '../lib/gl-matrix-extras';
13
- import {NumericArray} from '@math.gl/types';
18
+
19
+ /** Helper type that captures array length for a 2 element vector */
20
+ export type Vector2Like = Vector2 | NumberArray2;
14
21
 
15
22
  /**
16
- * Two-element vector class.
17
- * Subclass of Array<number>
23
+ * Two-element vector class with common linear algebra operations.
24
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
18
25
  */
19
26
  export class Vector2 extends Vector {
20
27
  // Creates a new, empty vec2
@@ -1,6 +1,9 @@
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
- import {NumericArray} from '@math.gl/types';
5
+
6
+ import {NumericArray, NumberArray3} from '@math.gl/types';
4
7
  import {Vector} from './base/vector';
5
8
  import {config, isArray} from '../lib/common';
6
9
  import {checkNumber} from '../lib/validators';
@@ -22,9 +25,12 @@ const ORIGIN = [0, 0, 0];
22
25
 
23
26
  let ZERO: Vector3;
24
27
 
28
+ /** Helper type that captures array length for a 3 element vector */
29
+ export type Vector3Like = Vector3 | NumberArray3;
30
+
25
31
  /**
26
- * Three-element vector class.
27
- * Subclass of Array<number>
32
+ * Three-element vector class with common linear algebra operations.
33
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
28
34
  */
29
35
  export class Vector3 extends Vector {
30
36
  static get ZERO(): Vector3 {
@@ -1,7 +1,9 @@
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
 
4
- import {NumericArray} from '@math.gl/types';
6
+ import {NumericArray, NumberArray4} from '@math.gl/types';
5
7
  /* eslint-disable camelcase */
6
8
  import {
7
9
  transformMat4 as vec4_transformMat4,
@@ -17,9 +19,12 @@ import type {Matrix4} from './matrix4';
17
19
 
18
20
  let ZERO: Vector4;
19
21
 
22
+ /** Helper type that captures array length for a 4 element vector */
23
+ export type Vector4Like = Vector4 | NumberArray4;
24
+
20
25
  /**
21
- * Four-element vector class.
22
- * Subclass of Array<number>
26
+ * Four-element vector class with common linear algebra operations.
27
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
23
28
  */
24
29
  export class Vector4 extends Vector {
25
30
  static get ZERO(): Vector4 {
@@ -12,9 +12,9 @@ import * as glMatrix from './common.js';
12
12
  /**
13
13
  * Creates a new, empty vec2
14
14
  *
15
- * @returns {NumericArray} a new 2D vector
15
+ * @returns a new 2D vector
16
16
  */
17
- export function create() {
17
+ export function create(): NumericArray {
18
18
  const out = new glMatrix.ARRAY_TYPE(2);
19
19
  if (glMatrix.ARRAY_TYPE != Float32Array) {
20
20
  out[0] = 0;
@@ -26,10 +26,10 @@ export function create() {
26
26
  /**
27
27
  * Creates a new vec2 initialized with values from an existing vector
28
28
  *
29
- * @param {Readonly<NumericArray>} a vector to clone
30
- * @returns {NumericArray} a new 2D vector
29
+ * @param a vector to clone
30
+ * @returns a new 2D vector
31
31
  */
32
- export function clone(a) {
32
+ export function clone(a: Readonly<NumericArray>): NumericArray {
33
33
  const out = new glMatrix.ARRAY_TYPE(2);
34
34
  out[0] = a[0];
35
35
  out[1] = a[1];
@@ -39,11 +39,11 @@ export function clone(a) {
39
39
  /**
40
40
  * Creates a new vec2 initialized with the given values
41
41
  *
42
- * @param {Number} x X component
43
- * @param {Number} y Y component
44
- * @returns {NumericArray} a new 2D vector
42
+ * @param x X component
43
+ * @param y Y component
44
+ * @returns a new 2D vector
45
45
  */
46
- export function fromValues(x, y) {
46
+ export function fromValues(x: number, y: number): NumericArray {
47
47
  const out = new glMatrix.ARRAY_TYPE(2);
48
48
  out[0] = x;
49
49
  out[1] = y;
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  // @eslint-disable
2
6
  // @ts-nocheck
3
7
 
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  // @ts-nocheck
2
6
  /* eslint-disable */
3
7
 
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  // @ts-nocheck
2
6
  /* eslint-disable */
3
7
 
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  // @ts-nocheck
2
6
  /* eslint-disable */
3
7
  import * as glMatrix from './common.js';
package/src/index.ts CHANGED
@@ -1,9 +1,24 @@
1
- // luma.gl, MIT license
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
2
4
 
3
5
  // types
4
- export type {TypedArray, NumericArray} from '@math.gl/types';
6
+ export type {
7
+ TypedArray,
8
+ TypedArrayConstructor,
9
+ NumericArray,
10
+ NumberArray,
11
+ NumberArray2,
12
+ NumberArray3,
13
+ NumberArray4,
14
+ NumberArray6,
15
+ NumberArray8,
16
+ NumberArray9,
17
+ NumberArray12,
18
+ NumberArray16
19
+ } from '@math.gl/types';
5
20
 
6
- export type {isTypedArray, isNumericArray} from '@math.gl/types';
21
+ export type {isTypedArray, isNumberArray, isNumericArray} from '@math.gl/types';
7
22
 
8
23
  // classes
9
24
  export {Vector2} from './classes/vector2';
@@ -13,6 +28,12 @@ export {Matrix3} from './classes/matrix3';
13
28
  export {Matrix4} from './classes/matrix4';
14
29
  export {Quaternion} from './classes/quaternion';
15
30
 
31
+ export type {Vector2Like} from './classes/vector2';
32
+ export type {Vector3Like} from './classes/vector3';
33
+ export type {Vector4Like} from './classes/vector4';
34
+ export type {Matrix3Like} from './classes/matrix3';
35
+ export type {Matrix4Like} from './classes/matrix4';
36
+
16
37
  // experimental
17
38
  export {SphericalCoordinates} from './classes/spherical-coordinates';
18
39
  export {Pose} from './classes/pose';
package/src/lib/assert.ts CHANGED
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  export function assert(condition: unknown, message?: string): void {
2
6
  if (!condition) {
3
7
  throw new Error(`math.gl assertion ${message}`);
package/src/lib/common.ts CHANGED
@@ -1,4 +1,8 @@
1
- // math.gl, MIT license
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ /* eslint-disable no-shadow */ // radians and degrees are common variable names
2
6
 
3
7
  import type {NumericArray} from '@math.gl/types';
4
8
 
@@ -299,7 +303,7 @@ function duplicateArray(array: NumericArray): NumericArray {
299
303
  // otherwise applies func to the argument value
300
304
  function map(
301
305
  value: number | NumericArray,
302
- func: (x: number, index?: number, result?: NumericArray) => number,
306
+ func: (x: number, index?: number, resultArray?: NumericArray) => number,
303
307
  result?: NumericArray
304
308
  ): number | NumericArray {
305
309
  if (isArray(value)) {
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  /* eslint-disable camelcase */
2
6
  import {NumericArray} from '@math.gl/types';
3
7
  // vec2 additions
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  type NumericArray =
2
6
  | Int8Array
3
7
  | Uint8Array
@@ -1,3 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  // NOTE: Added to make Cesium-derived test cases work
2
6
  // TODO: Determine if/how to keep
3
7
  export const EPSILON1 = 1e-1;
@@ -1,26 +1,11 @@
1
- // Copyright (c) 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- import {NumberArray} from '@math.gl/types';
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {NumericArray} from '@math.gl/types';
21
6
  import {config} from './common';
22
7
 
23
- export function validateVector(v: NumberArray, length: number): boolean {
8
+ export function validateVector(v: NumericArray, length: number): boolean {
24
9
  if (v.length !== length) {
25
10
  return false;
26
11
  }
@@ -40,7 +25,7 @@ export function checkNumber(value: unknown): number {
40
25
  return value as number;
41
26
  }
42
27
 
43
- export function checkVector<T extends NumberArray>(
28
+ export function checkVector<T extends NumericArray>(
44
29
  v: T,
45
30
  length: number,
46
31
  callerName: string = ''