Skip to content

Commit

Permalink
feat: a wider BaseArgType
Browse files Browse the repository at this point in the history
  • Loading branch information
iwoplaza committed Oct 24, 2024
1 parent 571d055 commit f2cd07b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
/**
* A type wider than `number[]`, omitting any instance functions
* unused by the API, e.g., map, sort. This allows the math
* functions to operate on a wider range of array-like
* values.
*/
export interface MutableNumberArray {
readonly length: number;
[n: number]: number;
}

/**
* The types you can pass to most functions that take an
* array of numbers.
*/
export type BaseArgType = Float32Array | Float64Array | number[];
export type BaseArgType = Float32Array | Float64Array | MutableNumberArray;

function wrapConstructor<T extends new(...args: any[]) => any>(
OriginalConstructor: T,
Expand Down
3 changes: 2 additions & 1 deletion src/wgpu-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Some docs
* @namespace wgpu-matrix
*/
import {BaseArgType, ZeroArray} from './types';
import {MutableNumberArray, BaseArgType, ZeroArray} from './types';
import {Mat3Arg, Mat3Type, getAPI as getMat3API} from './mat3-impl';
import {Mat4Arg, Mat4Type, getAPI as getMat4API} from './mat4-impl';
import {QuatArg, QuatType, getAPI as getQuatAPI, RotationOrder} from './quat-impl';
Expand All @@ -15,6 +15,7 @@ export {
RotationOrder,
utils,

MutableNumberArray,
BaseArgType,

Mat3Arg,
Expand Down

0 comments on commit f2cd07b

Please sign in to comment.