Although the times the floating point math messes up confuse me all the more...
Regarding your H-curves--I guess that original code you cited, opaque as it is, can produce [x, y] coordinates for an H-curve that might run in webgl? GLSL doesn't support recursion, or--best as I can see--any other form of dynamic looping where the number of loops is set before the program executes. Which makes it a tricky language to program these in.
I believe it's just an inlined set of iterations, honestly. The paper it was part of describes a recursive tiling algorithm, it would surprise me if they had a code implementation that did not have recursion (or inlined recursion) without also describing that
Oh yeah, looking at the code all the y coordinate and x coordinate functions do call themselves when i > 36 or something. Hmm. I do think the flipping strategy in the Hilbert fork of this notebook could probably be adapted for the square H curve in some way.
I just realized: my implementation effectively produces a vector field - a Uint8Array representing the grid and for every point in space it says to which neighbor the curve will step. You could try using that as a uniform input - so generate the tiling on the CPU just once, feed the output to webgl, do something with a shader to interpret that vector field. Could that work?
I've been thinking about another strategy for implementing the H curve that I think ought to work, but I simply have trouble tracking the rotations. Here's a notebook that explains the idea in canvas--the webgl code just produces a tangle of spaghetti at the moment. Basically the idea is that if you fill out only half the square, the H-curve neatly subdivides into a set of L shapes. https://observablehq.com/d/cf69b572eb172e6e.
Half the points are flipped only in 1d, and only the other half have a full 2d range of motion.
I suspect there's an implication in there for what a 3d H-curve would look like as well, though I can't quite see it.
> I simply have trouble tracking the rotations.
Oof, I feel you. I basically was stuck with implementing the curve until I came up with the method that I used because of the necessary rotations. The approch that you're working on is a lot closer to the method in the original paper actually!
OK, got it! https://observablehq.com/@bmschmidt/webgl-h-curve Not that I entirely understand how. My impression of that code from the original is that they lay out many more points than they need to, probably both for performance but also maybe to avoid some of the low level description of what's going on in that shape.