From 70d4b69e93d7e23369378bbe0bf1f1ebbf6974eb Mon Sep 17 00:00:00 2001 From: Ib Green Date: Sat, 3 Aug 2024 09:10:06 -0400 Subject: [PATCH] wip --- .eslintrc.cjs | 1 + modules/core/src/classes/euler.ts | 3 ++- modules/core/src/classes/matrix3.ts | 1 + modules/core/src/classes/matrix4.ts | 1 + .../core/src/classes/spherical-coordinates.ts | 3 +-- modules/core/src/gl-matrix/vec2.ts | 18 +++++++++--------- modules/core/src/index.ts | 17 +++++++++++++++-- modules/core/src/lib/common.ts | 4 +++- modules/culling/package.json | 3 ++- .../src/lib/perspective-off-center-frustum.ts | 2 +- modules/geospatial/package.json | 3 ++- yarn.lock | 2 ++ 12 files changed, 40 insertions(+), 18 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 5c42c102..be35dfde 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -27,6 +27,7 @@ module.exports = getESLintConfig({ rules: { 'no-use-before-define': 0, 'import/no-unresolved': 0, + 'import/named': 0, '@typescript-eslint/ban-ts-comment': 0 // We do need our ts-ignores } }, diff --git a/modules/core/src/classes/euler.ts b/modules/core/src/classes/euler.ts index a564d660..80a30d59 100644 --- a/modules/core/src/classes/euler.ts +++ b/modules/core/src/classes/euler.ts @@ -14,6 +14,7 @@ import {checkNumber} from '../lib/validators'; const ERR_UNKNOWN_ORDER = 'Unknown Euler angle order'; const ALMOST_ONE = 0.99999; +// eslint-disable-next-line no-shadow enum RotationOrder { ZYX = 0, YXZ = 1, @@ -71,8 +72,8 @@ export class Euler extends MathArray { super(-0, -0, -0, -0); // eslint-disable-next-line prefer-rest-params if (arguments.length > 0 && Array.isArray(arguments[0])) { - // eslint-disable-next-line prefer-rest-params // @ts-expect-error + // eslint-disable-next-line prefer-rest-params this.fromVector3(...arguments); } else { this.set(x, y, z, order); diff --git a/modules/core/src/classes/matrix3.ts b/modules/core/src/classes/matrix3.ts index 8d8b9476..7218cbfb 100644 --- a/modules/core/src/classes/matrix3.ts +++ b/modules/core/src/classes/matrix3.ts @@ -22,6 +22,7 @@ import { import {transformMat3 as vec2_transformMat3} from '../gl-matrix/vec2'; import {transformMat3 as vec3_transformMat3} from '../gl-matrix/vec3'; +// eslint-disable-next-line no-shadow enum INDICES { COL0ROW0 = 0, COL0ROW1 = 1, diff --git a/modules/core/src/classes/matrix4.ts b/modules/core/src/classes/matrix4.ts index 234e3286..8bb06805 100644 --- a/modules/core/src/classes/matrix4.ts +++ b/modules/core/src/classes/matrix4.ts @@ -31,6 +31,7 @@ import {transformMat4 as vec2_transformMat4} from '../gl-matrix/vec2'; import {transformMat4 as vec3_transformMat4} from '../gl-matrix/vec3'; import {transformMat4 as vec4_transformMat4} from '../gl-matrix/vec4'; +// eslint-disable-next-line no-shadow enum INDICES { COL0ROW0 = 0, COL0ROW1 = 1, diff --git a/modules/core/src/classes/spherical-coordinates.ts b/modules/core/src/classes/spherical-coordinates.ts index d862317d..1b179301 100644 --- a/modules/core/src/classes/spherical-coordinates.ts +++ b/modules/core/src/classes/spherical-coordinates.ts @@ -6,8 +6,7 @@ // Adaptation of THREE.js Spherical class, under MIT license import {NumericArray} from '@math.gl/types'; import {Vector3} from './vector3'; -import {formatValue, equals, config} from '../lib/common'; -import {degrees, radians, clamp} from '../lib/common'; +import {formatValue, equals, config, degrees, radians, clamp} from '../lib/common'; // @ts-ignore gl-matrix types... import * as vec3 from '../gl-matrix/vec3'; diff --git a/modules/core/src/gl-matrix/vec2.ts b/modules/core/src/gl-matrix/vec2.ts index bb45aa21..072f7da1 100644 --- a/modules/core/src/gl-matrix/vec2.ts +++ b/modules/core/src/gl-matrix/vec2.ts @@ -12,9 +12,9 @@ import * as glMatrix from './common.js'; /** * Creates a new, empty vec2 * - * @returns {NumericArray} a new 2D vector + * @returns a new 2D vector */ -export function create() { +export function create(): NumericArray { const out = new glMatrix.ARRAY_TYPE(2); if (glMatrix.ARRAY_TYPE != Float32Array) { out[0] = 0; @@ -26,10 +26,10 @@ export function create() { /** * Creates a new vec2 initialized with values from an existing vector * - * @param {Readonly} a vector to clone - * @returns {NumericArray} a new 2D vector + * @param a vector to clone + * @returns a new 2D vector */ -export function clone(a) { +export function clone(a: Readonly): NumericArray { const out = new glMatrix.ARRAY_TYPE(2); out[0] = a[0]; out[1] = a[1]; @@ -39,11 +39,11 @@ export function clone(a) { /** * Creates a new vec2 initialized with the given values * - * @param {Number} x X component - * @param {Number} y Y component - * @returns {NumericArray} a new 2D vector + * @param x X component + * @param y Y component + * @returns a new 2D vector */ -export function fromValues(x, y) { +export function fromValues(x: number, y: number): NumericArray { const out = new glMatrix.ARRAY_TYPE(2); out[0] = x; out[1] = y; diff --git a/modules/core/src/index.ts b/modules/core/src/index.ts index 8b5be8eb..373c167c 100644 --- a/modules/core/src/index.ts +++ b/modules/core/src/index.ts @@ -3,9 +3,22 @@ // Copyright (c) vis.gl contributors // types -export type {TypedArray, TypedArrayConstructor, NumberArray, NumericArray} from '@math.gl/types'; +export type { + TypedArray, + TypedArrayConstructor, + NumericArray, + NumberArray, + NumberArray2, + NumberArray3, + NumberArray4, + NumberArray6, + NumberArray8, + NumberArray9, + NumberArray12, + NumberArray16 +} from '@math.gl/types'; -export type {isTypedArray, isNumericArray} from '@math.gl/types'; +export type {isTypedArray, isNumberArray, isNumericArray} from '@math.gl/types'; // classes export {Vector2} from './classes/vector2'; diff --git a/modules/core/src/lib/common.ts b/modules/core/src/lib/common.ts index 104d9517..c571f93f 100644 --- a/modules/core/src/lib/common.ts +++ b/modules/core/src/lib/common.ts @@ -2,6 +2,8 @@ // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors +/* eslint-disable no-shadow */ // radians and degrees are common variable names + import type {NumericArray} from '@math.gl/types'; import type {MathArray} from '../classes/base/math-array'; @@ -301,7 +303,7 @@ function duplicateArray(array: NumericArray): NumericArray { // otherwise applies func to the argument value function map( value: number | NumericArray, - func: (x: number, index?: number, result?: NumericArray) => number, + func: (x: number, index?: number, resultArray?: NumericArray) => number, result?: NumericArray ): number | NumericArray { if (isArray(value)) { diff --git a/modules/culling/package.json b/modules/culling/package.json index 06d2cdd3..2df48e51 100644 --- a/modules/culling/package.json +++ b/modules/culling/package.json @@ -42,7 +42,8 @@ "src" ], "dependencies": { - "@math.gl/core": "4.1.0-alpha.1" + "@math.gl/core": "4.1.0-alpha.1", + "@math.gl/types": "4.1.0-alpha.1" }, "gitHead": "e1a95300cb225a90da6e90333d4adf290f7ba501" } diff --git a/modules/culling/src/lib/perspective-off-center-frustum.ts b/modules/culling/src/lib/perspective-off-center-frustum.ts index 6dc3f9a7..97362586 100644 --- a/modules/culling/src/lib/perspective-off-center-frustum.ts +++ b/modules/culling/src/lib/perspective-off-center-frustum.ts @@ -5,7 +5,7 @@ // - It has not been fully adapted to math.gl conventions // - Documentation has not been ported -import {Vector3, Vector2, Matrix4, assert, NumberArray} from '@math.gl/core'; +import {Vector3, Vector2, Matrix4, assert, NumericArray} from '@math.gl/core'; import {CullingVolume} from './culling-volume'; import {Plane} from './plane'; diff --git a/modules/geospatial/package.json b/modules/geospatial/package.json index 8604b939..7b90c0b0 100644 --- a/modules/geospatial/package.json +++ b/modules/geospatial/package.json @@ -39,7 +39,8 @@ "src" ], "dependencies": { - "@math.gl/core": "4.1.0-alpha.1" + "@math.gl/core": "4.1.0-alpha.1", + "@math.gl/types": "4.1.0-alpha.1" }, "gitHead": "e1a95300cb225a90da6e90333d4adf290f7ba501" } diff --git a/yarn.lock b/yarn.lock index 8fa3bd29..d3e23982 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2408,6 +2408,7 @@ __metadata: resolution: "@math.gl/culling@workspace:modules/culling" dependencies: "@math.gl/core": "npm:4.1.0-alpha.1" + "@math.gl/types": "npm:4.1.0-alpha.1" languageName: unknown linkType: soft @@ -2444,6 +2445,7 @@ __metadata: resolution: "@math.gl/geospatial@workspace:modules/geospatial" dependencies: "@math.gl/core": "npm:4.1.0-alpha.1" + "@math.gl/types": "npm:4.1.0-alpha.1" languageName: unknown linkType: soft