regionNeighbor

function regionNeighbor
universe/src/terrain.ts:217
regionNeighbor(region: RegionAddress, di: number, dj: number) → RegionAddress

The region di cells along u and dj cells along v from this one, wrapping onto the adjacent cube face where the step leaves this one.

The classic cube-sphere bug farm is the six-by-four table of edge rotations that says which of a neighbor's axes runs which way, and the eight points where three faces meet is where it is always wrong. There is no table here. The step is taken in the source face's extended coordinates, turned into a direction — which is the same direction whichever face claims it — and asked which region contains it. The rotation is a consequence of directionToFace picking the dominant axis, so it cannot disagree with the sampling in regionDirection or with regionForDirection in the streamer.

At a cube corner three faces meet and there are seven neighbors, not eight: the diagonal step off the corner names one of the three faces rather than a missing fourth, and which one is a consequence of the dominant-axis tie-break. That is a real answer to a question with no answer, and callers that walk a ring have to tolerate a repeat rather than assume eight distinct cells.

regionRegionAddress
Undocumented
dinumber
Undocumented
djnumber
Undocumented