Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: a wider BaseArgType #34

Merged
merged 2 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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