POCKET CITY / STUDY / LEVEL 5 OF 5
Table
and street.
Because a building is a list and not a model, the same list can be drawn twice: once as a 9 cm-per-cell model on the table, once as a 55 cm-per-cell district you stand inside. The scene keeps both sets of cubes and shows one at a time. On the table, the build surface can be zoomed to make cells easier to aim at, but the gold lot must stay put, which takes a small trick with the order of move and scale. And while the AI thinks, the scene has to show something honest, because the request gives no progress.
The same list, twice
drag the zoom; the gold corner does not moveTable: cells of 9 cm
Street: cells of 55 cm, a person for scale
What GROW CITY shows
the four states of a requestThe AI endpoint reports nothing until it is done, so the scene shows elapsed seconds and a marker that moves, not a percentage. Pretending to know progress would be a lie the operator would learn to distrust.
One list, two sets of cubes
pocketCity.jsrebuild throws away every cube and makes them again from the lists: once for the table, once for the street. It runs only when a list changes, not every frame. switchMode never moves anything: it scales a whole root to nothing.
Zooming about the gold lot
pocketCity.jsScaling a node scales about its own origin, which would slide the gold lot away. Moving to the pivot, scaling, and moving back keeps the pivot fixed. Picking has to see the same zoom: the beam is mapped into the unzoomed build space before the ray–box test.
What you should be able to explain
- Two drawings, one truth. Table and street never disagree because neither stores anything; both are rebuilt from the same lists. Edit on the table, enter the street, and the change is there.
- Hiding by scaling. A root scaled to 0 draws nothing and costs nothing to toggle; the cubes under it are untouched.
- Pivoted scaling.
move(P) scale(k) move(−P)reads right to left on the object: shift so the pivot is at the origin, scale, shift back. The same trick rotates a door about its hinge. - Honest waiting. States are thinking, ready, failed and too-small; each has a colour, and the thinking state animates without claiming a percentage.
Exercises: ① Set the zoom to 2×: which cube's corner stays exactly where it was, and why that one? ② Why does rayInBuildSpace divide the direction by the zoom but not normalise it? ③ Walk through what happens if the AI replies after you have pressed CLEAR.