@math.gl/core 4.1.0-alpha.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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export type { TypedArray, TypedArrayConstructor, NumberArray, 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";
@@ -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;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "version": "4.1.0-alpha.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.1.0-alpha.1"
48
+ "@math.gl/types": "4.1.0-alpha.2"
49
49
  },
50
- "gitHead": "1a4dbbc6ab46271459d610411a7c644e45135c2c"
50
+ "gitHead": "59eb434870991d06aecff5b1dee38078af0ca447"
51
51
  }
@@ -50,7 +50,7 @@ export abstract class MathArray extends Array<number> {
50
50
  return Array.isArray(arrayOrObject)
51
51
  ? this.copy(arrayOrObject)
52
52
  : // @ts-ignore
53
- this.fromObject(arrayOrObject);
53
+ this.fromObject(arrayOrObject);
54
54
  }
55
55
 
56
56
  to<T extends NumericArray | Record<string, unknown>>(arrayOrObject: T): T {
@@ -14,6 +14,7 @@ import {checkNumber} from '../lib/validators';
14
14
  const ERR_UNKNOWN_ORDER = 'Unknown Euler angle order';
15
15
  const ALMOST_ONE = 0.99999;
16
16
 
17
+ // eslint-disable-next-line no-shadow
17
18
  enum RotationOrder {
18
19
  ZYX = 0,
19
20
  YXZ = 1,
@@ -71,8 +72,8 @@ export class Euler extends MathArray {
71
72
  super(-0, -0, -0, -0);
72
73
  // eslint-disable-next-line prefer-rest-params
73
74
  if (arguments.length > 0 && Array.isArray(arguments[0])) {
74
- // eslint-disable-next-line prefer-rest-params
75
75
  // @ts-expect-error
76
+ // eslint-disable-next-line prefer-rest-params
76
77
  this.fromVector3(...arguments);
77
78
  } else {
78
79
  this.set(x, y, z, order);
@@ -22,6 +22,7 @@ import {
22
22
  import {transformMat3 as vec2_transformMat3} from '../gl-matrix/vec2';
23
23
  import {transformMat3 as vec3_transformMat3} from '../gl-matrix/vec3';
24
24
 
25
+ // eslint-disable-next-line no-shadow
25
26
  enum INDICES {
26
27
  COL0ROW0 = 0,
27
28
  COL0ROW1 = 1,
@@ -31,6 +31,7 @@ import {transformMat4 as vec2_transformMat4} from '../gl-matrix/vec2';
31
31
  import {transformMat4 as vec3_transformMat4} from '../gl-matrix/vec3';
32
32
  import {transformMat4 as vec4_transformMat4} from '../gl-matrix/vec4';
33
33
 
34
+ // eslint-disable-next-line no-shadow
34
35
  enum INDICES {
35
36
  COL0ROW0 = 0,
36
37
  COL0ROW1 = 1,
@@ -6,8 +6,7 @@
6
6
  // Adaptation of THREE.js Spherical class, under MIT license
7
7
  import {NumericArray} from '@math.gl/types';
8
8
  import {Vector3} from './vector3';
9
- import {formatValue, equals, config} from '../lib/common';
10
- import {degrees, radians, clamp} from '../lib/common';
9
+ import {formatValue, equals, config, degrees, radians, clamp} from '../lib/common';
11
10
  // @ts-ignore gl-matrix types...
12
11
  import * as vec3 from '../gl-matrix/vec3';
13
12
 
@@ -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;
package/src/index.ts CHANGED
@@ -3,9 +3,22 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  // types
6
- export type {TypedArray, TypedArrayConstructor, NumberArray, 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';
7
20
 
8
- export type {isTypedArray, isNumericArray} from '@math.gl/types';
21
+ export type {isTypedArray, isNumberArray, isNumericArray} from '@math.gl/types';
9
22
 
10
23
  // classes
11
24
  export {Vector2} from './classes/vector2';
package/src/lib/common.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
+ /* eslint-disable no-shadow */ // radians and degrees are common variable names
6
+
5
7
  import type {NumericArray} from '@math.gl/types';
6
8
 
7
9
  import type {MathArray} from '../classes/base/math-array';
@@ -301,7 +303,7 @@ function duplicateArray(array: NumericArray): NumericArray {
301
303
  // otherwise applies func to the argument value
302
304
  function map(
303
305
  value: number | NumericArray,
304
- func: (x: number, index?: number, result?: NumericArray) => number,
306
+ func: (x: number, index?: number, resultArray?: NumericArray) => number,
305
307
  result?: NumericArray
306
308
  ): number | NumericArray {
307
309
  if (isArray(value)) {
@@ -2,10 +2,10 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {NumberArray} from '@math.gl/types';
5
+ import {NumericArray} from '@math.gl/types';
6
6
  import {config} from './common';
7
7
 
8
- export function validateVector(v: NumberArray, length: number): boolean {
8
+ export function validateVector(v: NumericArray, length: number): boolean {
9
9
  if (v.length !== length) {
10
10
  return false;
11
11
  }
@@ -25,7 +25,7 @@ export function checkNumber(value: unknown): number {
25
25
  return value as number;
26
26
  }
27
27
 
28
- export function checkVector<T extends NumberArray>(
28
+ export function checkVector<T extends NumericArray>(
29
29
  v: T,
30
30
  length: number,
31
31
  callerName: string = ''