Skip to content

Prototype the Tower in 3D renderer (draft, do not merge) - #155

Draft
maniator wants to merge 7 commits into
mainfrom
claude/project-thread-fp8hjz
Draft

maniator wants to merge 7 commits into
mainfrom
claude/project-thread-fp8hjz

Conversation

@maniator

Copy link
Copy Markdown
Contributor

What & why

This is the Epic 1 prototype for the 5.x Tower in 3D view, Story 1.1. The plan is in Verticopolis/web#2630 and the issue is Verticopolis/web#2629. The owner picked the free 3D camera from the 2026-11-25 look study and asked for a prototype on draft branches. It stays a draft. Nothing here merges until two things happen: the gate is measured on real devices (Story 1.2), and the owner picks the look (Story 1.3, design sign-off).

It adds a render3d/ subpath. Tower3dView.mount(canvas, { sim, catalog, rules }) draws the tower from the render model as a 3D model you can orbit and zoom:

  • Bands: the rooms, shafts, side walls and roofs merge into one buffer per band of 8 floors. A tower revision rebuilds only the bands whose rooms changed, at most one per frame, and swaps each one in only when it is complete.
  • Moving parts: elevator cars and people are instanced meshes. The crowd is sampled to the tier's cap, nearest the camera first.
  • Light: day, dusk and night follow the clock or a time pinned for the window. At night every room draws unlit in its night colors, so occupied rooms glow and empty ones go dark.
  • Quality: three tiers (Low, Medium, High) step down when the 90th-percentile frame runs over 20 ms for 2 seconds.
  • Looks: every FacilityKind has a look in looks3d.ts, all made in code. A test fails if a kind has none.
  • Camera: an orbit camera with mouse, touch and keyboard input. It never goes behind the back wall or below the ground cut.
  • Gate numbers: stats() reports frame-time percentiles, draw calls and triangles.

Refs Verticopolis/web#2629

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New component or export
  • Visual or audio change (new art, a new look, a new sound)
  • Breaking change to an export
  • Refactor / internal-only (no visible or API change)
  • Docs / tooling

Quality gates

  • npm run typecheck
  • npm run lint
  • npm run format:check (npm run format fixes it)

npm test passes (202 files, 2,387 tests, 20 of them new) and so does npm run build (262 modules).

Versioning

  • Left version alone, or this is a release PR
  • Added a change note with its level under .changes/, or this PR changes nothing the package ships
  • Updated the README where it went stale, or read it and it did not (left for the non-draft PR, once the look is picked)

Complexity

Hot paths and call frequency (tier), sizes, complexity before and after, remaining scans and why, caches kept or replaced (HP-8), invalidation evidence, measurements:

  • Hot paths. Tower3dView.tick runs once per animation frame, and only while the 3D window is open. Nothing here touches the side view's frame loop.
  • Per frame: O(cars) to place cars and O(chosen people) to place people. The crowd choice is held for 500 ms, then re-picked: a filter over crowd.people, plus a sort when the crowd is over the cap.
  • Per tower revision: towerBands is one pass over the units and transports to fingerprint each band. Only the bands whose fingerprint changed are rebuilt, one per frame.
  • Measured on a made-up maxed tower (110 floors, 375-tile lot) in headless Chromium with software GL: 15 bands, 19 to 34 draw calls, about 290k triangles, about 1 ms per band rebuild.
  • Still to measure: real-device frame times are Story 1.2 and need GPUs. The cloud container renders in software, so its frame times mean nothing.
  • Known prototype costs to revisit before any non-draft PR:
    • FrameClock.percentile sorts a copy of up to 2 s of frame times on every frame.
    • The crowd re-pick allocates an index array.

Hot-path record (section 6): not yet. This is a draft prototype, and the review skill runs on the non-draft story PRs.

Screenshots / recordings

None in this description yet: the renders are made in a scratch harness, not the gallery. Day, dusk and night renders of the made-up tower go to the owner with the web preview for the look pick. A gallery page is part of Story 2.x.

Notes for reviewers

  • Draft only, for the gate and the owner's look pick. Do not merge.
  • The web side, the Tower > View in 3D… window, is a separate draft PR. It loads this subpath with a dynamic import, so the 3D code never enters the main bundle or the install precache.
  • three is a regular dependency. A game that never imports render3d/* bundles none of it.

Generated by Claude Code

A render3d/ subpath with Tower3dView: the tower from the render model as a
3D model to orbit and zoom. Rooms, shafts, side walls and roofs merge into
one buffer per band of 8 floors (rebuilt only when the band changes, one per
frame); cars and people are instanced and the crowd is sampled to the tier's
cap. Day, dusk and night follow the clock or a pinned time, with night colors
drawn unlit so occupied rooms glow. Three quality tiers step down on long
frames. three 0.187.0 is the new dependency.

This is the Epic 1 prototype for the 5.x Tower in 3D view; it stays a draft
until the gate is measured and the owner picks the look.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7trapMwkZkC9CZhRUNeK
… from git

Draft-only: npm builds a git dependency only through prepare. This line
comes out before any non-draft PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7trapMwkZkC9CZhRUNeK
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Gallery preview: https://components.verticopolis.com/pr-preview/pr-155/

Built from f6b48a2. It updates when a push changes the package or the gallery, and it goes away with the next gallery deploy after this pull request closes.

…e three's types

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7trapMwkZkC9CZhRUNeK
The far plane was fixed at 1,200 units, and the opening view backs off past
that to fit a wide lot in a tall, narrow canvas, so the whole tower was
clipped and only the sky drew. The far plane now follows the camera's
distance, and the opening view frames the built rooms rather than the empty
lot around them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7trapMwkZkC9CZhRUNeK

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants