(x,z)
| 6884 | /* World point -> the cell that contains it. Cube rounding, the standard trick; |
| 6885 | this is the whole of the picking system — no raycast, no colliders. */ |
| 6886 | function hexAt(x,z){ |
| 6887 | const q=(2/3)*x/HC, r=(-x/3+Math.sqrt(3)/3*z)/HC; |
| 6888 | const cx=q, cz=r, cy=-cx-cz; |
| 6889 | let rx=Math.round(cx), ry=Math.round(cy), rz=Math.round(cz); |
| 6890 | const dx=Math.abs(rx-cx), dy=Math.abs(ry-cy), dz=Math.abs(rz-cz); |
| 6891 | if(dx>dy&&dx>dz) rx=-ry-rz; else if(dy>dz) ry=-rx-rz; else rz=-rx-ry; |
| 6892 | return [rx,rz]; |
| 6893 | } |
| 6894 | |
| 6895 | /* A district's territory is its land plus a verge for the border to live in. |
| 6896 | It tracks the CURRENT level, so a district that has been read once owns one |
no outgoing calls
no test coverage detected