
An experimental approach to expressing vector math in js (tagged template literals)
If you're looking for a more intuitive way to handle vector mathematics in JavaScript, fv might just be the solution you need. This lightweight library, built around tagged template literals, facilitates a more natural expression of vector operations, reminiscent of more sophisticated languages like GLSL or C++. It's designed to make vector math less cumbersome and more accessible, ultimately enhancing readability in your code.
What sets fv apart is its approach to operator overloading and swizzling, enabling developers to write code that is clean and straightforward. While it’s still a nascent tool, the potential it shows in simplifying vector math makes it worth exploring further.
Operator Overloading: Easily perform vector arithmetic with standard operators like +, -, *, and more, mimicking the familiar syntax from languages like GLSL.
Swizzling Support: Access vector components flexibly with syntax such as v.xyxy, making it easy to rearrange or reuse vector elements.
Built-in GLSL Functions: Utilize common vector functions such as dot, cross, and length, alongside everyday math functions like sin and cos, enhancing functionality without extra overhead.
Custom Function Registration: Create and register your own functions and operators, providing the flexibility to adapt the library to your specific needs.
Dimensional Versatility: Works seamlessly with any vector dimensions (2D, 3D, 4D, etc.), without requiring special classes, so you can use standard arrays as vectors.
Caching Mechanism: Takes advantage of a caching system for parsed expressions, optimizing performance by compiling syntax trees only once for repeated evaluations.
Easy Integration: Suitable for both browser and Node.js environments, allowing developers to integrate it into their preferred workflow effortlessly.
