One of my first major projects in Resonite was to implement a triangulation algorithm.
Throughout my use of Resonite, I often use procedural meshes, since they not only take up less storage, but are also more convenient to create in VR. However, there is only a limited selection of primitives and other miscellaneous shapes available by default.
While helping two separate friends on their map making, we ran into the problem of creating organic shapes to fill lakes and rivers. Quads didn't fit, so my first idea was using a built-in convex hull shape. However, they also could not properly fill the shapes and they don't have the UVs required for normal water texture animations.
This then, is where the idea came from to generate a 2D polygon given as set of points. After a small bit of research, I came across the ear clipping algorithm, which would be able to give me the raw triangles, that I can place for the polygon to be formed.
ProtoFlux Implementation
However, it turns out that implementing this particular algorithm in ProtoFlux was not going to be an easy task. The main problem is that the language (as of 2024/5) does not have support for macros or proper functions with return values! This means that the main algorithm has to be done as one big block of static code. I used an existing Python Implementation as a reference.
There were some issued with keeping track of all the data the algorithm uses, but with enough wires, that was all possible.
One particular challenge was to determine if a point is within a triangle. The reference Implementation used some barycentric coordinate conversions to determine this. The problem with that is that the original function is a densely packed mathematical formula. However, ProtoFlux only had nodes. This caused quite a mess of crossing wires and nodes! During debugging of this, I ended up having to make the snippet receive and send web requests to a python server in order to compare with the original.

Other than this though, the final product is shockingly stable and still one of my favorite things I have created in Essonite!