Open davjhan opened 2 months ago
I'm not sure if I should add mutable methods for everything though, I'm trying to balance performance and bundle size, and I'm currently already unhappy with the bundle size. I've been adding mutable & non-allocating methods to the hot paths that I found while implementing pencil, but Vector
wasn't used very much compared to Point
and Matrix
so I've focused my efforts there.
The approach 2 is interesting though, I'll think about it.
It would be great to have a way to do vector operations without allocating more memory. It's very common when doing graphical programming to have lines like:
It would be great to be able to write this more performantly as:
Approach 1
Name the mutable methods in the same way as the rest of the lib:
.subMut
or.subtractMut
,addMut
Approach 2
Matter.js takes in as input an output vector to assign the result. https://brm.io/matter-js/docs/classes/Vector.html