Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen committed Aug 3, 2024
1 parent 8bd1d9c commit 70d4b69
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 18 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
Expand Down
3 changes: 2 additions & 1 deletion modules/core/src/classes/euler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions modules/core/src/classes/matrix3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions modules/core/src/classes/matrix4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions modules/core/src/classes/spherical-coordinates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
18 changes: 9 additions & 9 deletions modules/core/src/gl-matrix/vec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,10 +26,10 @@ export function create() {
/**
* Creates a new vec2 initialized with values from an existing vector
*
* @param {Readonly<NumericArray>} 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>): NumericArray {
const out = new glMatrix.ARRAY_TYPE(2);
out[0] = a[0];
out[1] = a[1];
Expand All @@ -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;
Expand Down
17 changes: 15 additions & 2 deletions modules/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 3 additions & 1 deletion modules/core/src/lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 2 additions & 1 deletion modules/culling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion modules/culling/src/lib/perspective-off-center-frustum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 2 additions & 1 deletion modules/geospatial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 70d4b69

Please sign in to comment.