Way back in April 2024, you wrote
Where do you think the primary culprits are in terms of big classes or code?
One of the things I’ve noticed is repeated code for basic Vector or Matrix functions in different dimensions. There are Vector2, Vector3, Color3, Color4, Matrix (4x4), Matrix2d (3x3), Path2d, Path3d, and maybe a couple more. And there seems to be repeated code for higher-level (e.g. path) calculations in different dimensions as well (bezier, hermite, catmullrom).
At a (hopefully slim) cost in performance, I think there may be ways to combine multiple dimensions in one class by including dimensions within Matrix and treat Vectors as 1-dimensional Matrices. Once done, some of the higher-level functions then can possibly become dimension independent.
A simple example is that multiplying a vector with a matrix would be the same code as multiplying two matrices. In fact, multiplying by any size matrices (that can be multiplied) would use that same code.
I’ve done some of that work developing an alternative Matrix class but it is not yet a full replacement for the existing Matrix class.
A slight aside, I don’t yet see the value in the ThinMaths class that exists in the repo and currently implements a small number of matrix functions.
From a performance standpoint, I’ve noticed some array slinging (creating, copying) that might be reduced. I haven’t wrapped my head around all the different use cases (or workarounds already in place), but there seems to be a bit of “create an array just so we can copy that array or operate on elements of the array” with regard to Curves, Paths, and VerticesData. An easy example of this is creating a Vector3 array that I know under the hood has to be copied to a Float32Array. I’m not sure where all the existing workarounds are (such as the many places that can take a Vector3 array or a Float32Array).