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

Improve matrix and vector types #11427

Open
mourner opened this issue Jan 20, 2022 · 0 comments
Open

Improve matrix and vector types #11427

mourner opened this issue Jan 20, 2022 · 0 comments

Comments

@mourner
Copy link
Member

mourner commented Jan 20, 2022

A follow-up to #11400 — there are still multiple ways we could make those types stricter and more useful:

  • Currently we often use [] as an input type for vector/matrix calculations, resolved as Array<number>. The problem with this is that we can't type-check array length of resulting objects (vec/mat2/3/4 can all be interchangeably interpreted as the same type), and arrays are not compatible with tuples that we use for typing uniform inputs like uniform3f. We should probably exclude Array<number> as input type for these methods and replace them with tuples that have explicit length.
  • We use either Float64Array, Float32Array or Array for matrices inconsistently throughout the codebase. Ideally we would settle on one way of doing this — either always using Float64Array for intermediary calculations and then converting to Float32Array which WebGL expects at the end, or switching to arrays everywhere so that we never loose precision.

cc @ansis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant