diff --git a/src/types.ts b/src/types.ts index 87cb587..8769bad 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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 any>( OriginalConstructor: T, diff --git a/src/wgpu-matrix.ts b/src/wgpu-matrix.ts index d757056..4f51b2f 100644 --- a/src/wgpu-matrix.ts +++ b/src/wgpu-matrix.ts @@ -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'; @@ -15,6 +15,7 @@ export { RotationOrder, utils, + MutableNumberArray, BaseArgType, Mat3Arg,