A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Add carpenter and civic milestone models with reusable building works
SandroMaglionea2845b4f537d
diff --git a/README.md b/README.mdindex 07d48a4..3c01f60 100644--- a/README.md+++ b/README.md@@ -127,7 +127,26 @@ colour of what it makes and keeps its work in its yard: a log pile, a silo,a pen of sheep, a striped market stall. Trees, rocks, water, and roads aredifferent on every cell.-+++The carpenter and building upgrades can be inspected in the model review.+Run `pnpm dev`, then open `/model-review.html?collection=handoff` to turn the models, compare+scaffolding as materials arrive, and download their GLBs.++The civic milestones have their own comparison at+`/model-review.html?collection=milestones`. The guildhall's clock tower,+steep roof and guild banners give way to the city hall's domed centre,+lower wings and columned entrance.++++`/model-review.html?collection=works` shows one reusable construction+scaffold on six building forms. Plot size, building height and delivered+share determine its bays, platforms, ladders and supplies.++++diff --git a/docs/pr20-models.md b/docs/pr20-models.mdnew file mode 100644index 0000000..78d6742--- /dev/null+++ b/docs/pr20-models.md@@ -0,0 +1,66 @@+# PR #20 model handoff++Run `pnpm dev --host 127.0.0.1 --port 5236`, then open+`http://127.0.0.1:5236/model-review.html?collection=handoff`.+Rotation, elevation, PNG sheets and individual GLB exports work in this+view. The models use the same close framing as the other building collections.++The carpenter is an open timber workshop with a boarded store door,+28-pixel eaves and a 38-pixel ridge, matching the bakery and weaver. Its bench, vice, tools, sawhorse,+plank bearers, chairs and chest stay inside the original two-cell plot.+It has no flue or smoke emitter. Furniture uses the same chair and chest+geometry in the work yard and on delivery carts.++The civic milestones have full models in `src/asset-lab/civic.ts`. The+guildhall is a steep-roofed guild house with a prominent clock tower,+balcony, dormers and guild banners. The city hall has lower wings, corner+pavilions, a columned portico, ceremonial stair and large ribbed dome with+a lantern. Compare all three civic stages at+`/model-review.html?collection=milestones`, using one camera scale.+The original town hall remains unchanged. Civic surface bounds use their+own eave heights, and marker heights are cached from their actual geometry.+The original town hall flag is hidden on the full civic upgrade models.++The depot gantry, ovenworks flue, masonry derrick, estate dovecote and hay+shelter, and fire brigade pump and hose cart extend their existing models. The depot and+ovenworks additions turn with their road-facing work yards. The fire+brigade equips the yard rather than adding a second floating bell.++The other original base buildings, market hall and church keep their existing+geometry and height. The new upgrade structures use that established+building scale. The earlier height adapters and house/walker reference+scenes were removed. A town-wide proportion pass is deferred.++Construction uses `scaffoldAsset(size, height, share)` from+`src/asset-lab/scaffolding.ts`. It has no building-kind branches or model+lookup. Modular timber bays, two working platforms, an access ladder,+canvas screens and supply piles fit inside the plot. Central bays on all+four sides remain clear at ground level. One generator covers every+building kind, with progress quantized into 24 steps in the live view.+`/model-review.html?collection=works` shows three delivery stages and six+different building forms. Geometry is retained because it reads as a+worksite without requiring a bespoke construction asset for each building.+Repeated members use solid faces and economical outlines.+The review map has an upgrade annex; temporary+construction examples were moved away from the carpenter's plot.++The Anatomy Asset skill was read as an external reference, without local+installation. Its solid parts, connected supports and purposeful detail+informed the models. Geometry remains native `Drawing` data.++Validation commands are `pnpm typecheck`, `pnpm test`, `pnpm check`,+`pnpm assets:build`, and the browser workflows `check:models`,+`check:revisions`, `check:phone`, `check:effects`, `check:park`,+`check:browser` and `look:upgrades`, with `GAME_BASE_URL` set to the server.+The economy hand playtest and optional v8 save fixture from the original+handoff are outside this model pass.++The current revision passes typecheck, build, all 115 tests, the model gallery+and revision browser checks, and export/reimport of all 236 GLBs.+Both civic upgrades complete through the real upgrade command. The live+upgrade and phone menu/portrait checks also pass without+browser errors. Effects and park checks passed in the earlier model pass. The full game+browser check still times out at `scripts/check-browser.ts:72`, waiting+for the first settlers. The identical timeout was reproduced on the+untouched PR head `e610f70`, with no browser errors and the preceding+selection, road, home and building placement checks passing.diff --git a/docs/screenshots/sheet-buildings.webp b/docs/screenshots/sheet-buildings.webpindex 62e6921..b86d5ef 100644Binary files a/docs/screenshots/sheet-buildings.webp and b/docs/screenshots/sheet-buildings.webp differdiff --git a/docs/screenshots/sheet-civic.webp b/docs/screenshots/sheet-civic.webpnew file mode 100644index 0000000..b6f44e5Binary files /dev/null and b/docs/screenshots/sheet-civic.webp differdiff --git a/docs/screenshots/sheet-upgrades.webp b/docs/screenshots/sheet-upgrades.webpnew file mode 100644index 0000000..89daa66Binary files /dev/null and b/docs/screenshots/sheet-upgrades.webp differdiff --git a/docs/screenshots/sheet-works.webp b/docs/screenshots/sheet-works.webpnew file mode 100644index 0000000..7c87a20Binary files /dev/null and b/docs/screenshots/sheet-works.webp differdiff --git a/scripts/check-town-models.ts b/scripts/check-town-models.tsindex e38b175..4eecd82 100644--- a/scripts/check-town-models.ts+++ b/scripts/check-town-models.ts@@ -4,6 +4,7 @@ import assert from "node:assert/strict"import { existsSync } from "node:fs"import { mkdir, writeFile } from "node:fs/promises"import { chromium } from "playwright"+import { kindIds } from "../src/content.ts"const executablePath = process.env.BROWSER_EXECUTABLE_PATH ?? ["/Applications/Brave Browser.app/Contents/MacOS/Brave Browser", "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"].find(existsSync)const browser = await chromium.launch({ headless: true, ...(executablePath ? { executablePath } : {}) })@@ -14,7 +15,7 @@ page.on("console", e => { if (e.type() === "error") errors.push(e.text()) })page.on("response", r => { if (r.status() >= 400) errors.push(`${r.status()} ${r.url()}`) })const output = "output/inkline-3d/town-review"await mkdir(output, { recursive: true })-const groups = ["All buildings", "Final refinements", "Trade buildings", "Workshop batch", "Review fixes", "Buildings", "Parks", "Homes & neighbourhoods", "Winter", "Ruins", "People & cargo", "Building condition", "Upgrades & worked faces"]+const groups = ["Civic milestones", "Reusable building works", "PR #20 · new models", "All buildings", "Final refinements", "Trade buildings", "Workshop batch", "Review fixes", "Buildings", "Parks", "Homes & neighbourhoods", "Winter", "Ruins", "People & cargo", "Building condition", "Upgrades & worked faces"]const captureSheet = async () => {const previous = await page.locator("#sheet-link").getAttribute("href")await page.getByRole("button", { name: "Save model sheet", exact: true }).click()@@ -42,7 +43,7 @@ try {await page.screenshot({ path: `${output}/${collection}-page.png` })await page.getByRole("button", { name: "See the back", exact: true }).click()assert.equal(await page.locator("output").textContent(), "180°")- if (["town", "rural", "workshops", "trades"].includes(collection)) {+ if (["milestones", "works", "handoff", "town", "rural", "workshops", "trades"].includes(collection)) {const rear = await captureSheet()await writeFile(`${output}/${collection}-rear.png`, Buffer.from(rear.split(",")[1]!, "base64"))}@@ -54,7 +55,7 @@ try {console.log(`ok ${collection}: ${await page.locator(".model-view").count()} models, rotation, elevation, PNG export`)}await page.setViewportSize({ width: 390, height: 844 })- for (const [group, count, name] of [["All buildings", 25, "town"], ["Final refinements", 9, "rural"]] as const) {+ for (const [group, count, name] of [["Civic milestones", 3, "milestones"], ["Reusable building works", 9, "works"], ["PR #20 · new models", 14, "handoff"], ["All buildings", kindIds.length + 2, "town"], ["Final refinements", 9, "rural"]] as const) {await page.getByRole("button", { name: group, exact: true }).click()assert.equal(await page.locator(".model-view").count(), count)assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, `${group}: phone preview must fit`)diff --git a/scripts/look-upgrades.ts b/scripts/look-upgrades.tsindex 981abc5..313bc38 100644--- a/scripts/look-upgrades.ts+++ b/scripts/look-upgrades.ts@@ -8,8 +8,10 @@*/import { chromium } from "playwright"import { mkdir } from "node:fs/promises"+import { existsSync } from "node:fs"+import assert from "node:assert/strict"-const executable = process.env.BROWSER_EXECUTABLE_PATH+const executable = process.env.BROWSER_EXECUTABLE_PATH ?? ["/Applications/Brave Browser.app/Contents/MacOS/Brave Browser", "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"].find(existsSync)const browser = await chromium.launch({ headless: true, ...(executable ? { executablePath: executable } : {}) })const page = await browser.newPage({ viewport: { width: 1440, height: 1000 }, deviceScaleFactor: 1 })const out = process.env.OUT ?? "output/upgrades"@@ -57,6 +59,36 @@ try {await page.evaluate(() => (window as any).town.advance(90))await page.waitForTimeout(300)await page.screenshot({ path: `${out}/4-guildhall.png` })+ assert.equal(await page.evaluate(() => (window as any).town.runtime.snapshot().entities.find((e: any) => e.components["Town/TownHall"]).components["Town/Upgraded"]?.level), 1)+ // Complete the next civic milestone through the actual upgrade command too.+ await page.evaluate(() => {+ const t=(window as any).town,s=t.runtime.snapshot()+ const hall=s.entities.find((e:any)=>e.components["Town/TownHall"])+ Object.assign(hall.components["Town/Inventory"].stock,{planks:120,stone:120,tools:40,cloth:40})+ s.resources["Town/Treasury"].coins=5000+ t.runtime.restore(s)+ })+ await page.evaluate(([x,y])=>(window as any).town.ui.edits.push({type:"upgrade",cell:{x,y}}),[hall.x,hall.y])+ await page.evaluate(()=>(window as any).town.advance(80))+ await page.waitForTimeout(300)+ await page.screenshot({path:`${out}/5-cityhall-works.png`})+ await page.evaluate(()=>(window as any).town.advance(240))+ await page.waitForTimeout(300)+ assert.equal(await page.evaluate(()=>(window as any).town.runtime.snapshot().entities.find((e:any)=>e.components["Town/TownHall"]).components["Town/Upgraded"]?.level),2)+ await page.screenshot({path:`${out}/5-cityhall.png`})+ // The new workshop's actual model portrait and upgrade choices must fit a phone.+ await page.setViewportSize({ width: 390, height: 844 })+ await page.evaluate(() => { (window as any).town.ui.menu = "build" })+ const carpenter = page.locator(".panel .option").filter({ has: page.locator(".name", { hasText: /^carpenter$/i }) })+ await carpenter.scrollIntoViewIfNeeded()+ await carpenter.locator("img").evaluate(async (img: HTMLImageElement) => { if (!img.complete) await new Promise<void>(resolve => img.addEventListener("load", () => resolve(), { once: true })) })+ assert.ok(await carpenter.locator("img").evaluate((img: HTMLImageElement) => img.naturalWidth > 0), "Carpenter portrait must render")+ await page.screenshot({ path: `${out}/5-carpenter-phone.png` })+ const upgrades = page.locator(".panel h3").filter({ hasText: /^upgrades$/i })+ await upgrades.scrollIntoViewIfNeeded()+ assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), "Upgrade menu fits the phone")+ await page.screenshot({ path: `${out}/6-upgrades-phone.png` })+ assert.deepEqual(errors, [])console.log(JSON.stringify({ errors, upgraded: await page.evaluate(() => (window as any).town.runtime.snapshot().entities.find((e: any) => e.components["Town/TownHall"]).components["Town/Upgraded"] ?? null) }))} finally {await browser.close()diff --git a/src/asset-lab/assets.ts b/src/asset-lab/assets.tsindex 32023c6..eb3c990 100644--- a/src/asset-lab/assets.ts+++ b/src/asset-lab/assets.ts@@ -4,7 +4,7 @@ import { kindIds, goodIds, kinds, home, propIds } from "../content.ts"import { withAppearance } from "./appearance.ts"import { groundAsset } from "../render3d/models.ts"import { key } from "../grid.ts"-import { makeBuilding } from "./buildings.ts"+import { makeBuilding, buildingDimensions } from "./buildings.ts"import { house } from "./homes.ts"import { marketHall, church } from "./service-upgrades.ts"import { U } from "../iso.ts"@@ -12,6 +12,7 @@ import { makeTree, makeRock, makeField, makeRoadPatch, makeWater } from "./land.import { personCatalogue, makeCarrier, makeGoods, makeCrate } from "./people.ts"import { makeSite, makeConstruction, makeMarker, makeSmoke, makePlot } from "./construction.ts"import { makeParkProp, makeRuin, makeSamplePark } from "./town-props.ts"+import { upgradeCatalogue } from "./upgrade-catalogue.ts"import { Drawing, mix, pale, square, sides, palette, type InkAsset, type Vertex } from "./primitives.ts"export * from "./primitives.ts"@@ -109,7 +110,7 @@ baseFir.footprint = 1for (const face of baseFir.faces) if (face.contour) face.contourWidth = 1.5approvedAssets.find((asset) => asset.id === "goods")!.category = "cargo"approvedAssets.find((asset) => asset.id === "goods")!.footprint = 2-const additional: Array<InkAsset> = [marketHall(), church()]+const additional: Array<InkAsset> = [marketHall(), church(), ...upgradeCatalogue()]for (const kind of kindIds) if (!approvedAssets.some((asset) => asset.id === kind)) additional.push(makeBuilding(kind))const names = ["terracotta", "slate", "thatch", "moss"]for (const tier of [1, 2] as const)@@ -128,8 +129,8 @@ for (const tier of [1, 2, 3] as const) for (const appearance of ["fine", "poor",additional.push(model)}for (const id of ["granary", "smokehouse", "firewatch", "healer", "hospital", "watchhouse", "builder"] as const) for (const appearance of ["winter", "worn"] as const) {- const kind = kinds[id], base = makeBuilding(id)- const model = withAppearance(base, kind.half * U, kind.roof === "gable" ? 20 : kind.stories * 32, { winter: appearance === "winter", worn: appearance === "worn" })+ const kind = kinds[id], base = makeBuilding(id), dimensions = buildingDimensions(id)+ const model = withAppearance(base, dimensions.half, dimensions.height, { winter: appearance === "winter", worn: appearance === "worn" })model.id = `${id}-${appearance}`; model.title = `${kind.title} · ${appearance}`; model.appearance = appearanceadditional.push(model)}diff --git a/src/asset-lab/buildings.ts b/src/asset-lab/buildings.tsindex e4c6f8e..8871725 100644--- a/src/asset-lab/buildings.ts+++ b/src/asset-lab/buildings.ts@@ -5,6 +5,7 @@ import { finishTownBuilding, townBuildingNotes, institutionDoor, makeQuarry } frimport { isWorkshop, makeWorkshop, workshopSmokeOrigin, townHallEntrance } from "./workshops.ts"import { isTradeYard, makeTradeYard, tradeSmokeOrigin, tradeEntrance, millHoist } from "./trades.ts"import { chapelPorch, hayBands, isRuralDoor, lumberRack, nursery, ruralEntrance, ruralNotes, sheepTrough } from "./rural.ts"+import { makeCarpenter } from "./carpenter.ts"const dresses: Record<KindId, { accent: number; roof?: number; glass?: number }> = {townhall: { accent: 0x8a58a8, glass: 0xf3dca6 },@@ -42,6 +43,7 @@ export interface BuildingOptions {motion?: boolean}export function makeBuilding(id: KindId, options: BuildingOptions = {}) {+ if (id === "carpenter") return makeCarpenter(options)if (isWorkshop(id)) return makeWorkshop(id, options)if (isTradeYard(id)) return makeTradeYard(id, options)if (id === "quarry") return makeQuarry(options)@@ -205,6 +207,7 @@ export function makeBuilding(id: KindId, options: BuildingOptions = {}) {/** Shared by catalogue geometry and working-building emitters. Open yards have no flue. */export function buildingSmokeOrigin(id: KindId, doors?: BuildingOptions["doors"]): Vertex | null {+ if (id === "carpenter") return nullif (isWorkshop(id)) return workshopSmokeOrigin(id, doors)if (isTradeYard(id)) return tradeSmokeOrigin(id, doors)const kind = kinds[id]@@ -215,6 +218,7 @@ export function buildingSmokeOrigin(id: KindId, doors?: BuildingOptions["doors"]/** Presentation dimensions stay separate from simulation footprints and content costs. */export function buildingDimensions(id: KindId) {+ if (id === "carpenter") return { half: 13.5 * U, height: 28, top: 38 }if (isTradeYard(id)) return {half: (id === "warehouse" ? 21 : 13.5) * U,height: id === "fishery" ? 20 : id === "bakery" ? 28 : id === "weaver" ? 30 : 32,@@ -225,7 +229,7 @@ export function buildingDimensions(id: KindId) {return {half: isWorkshop(id) ? 13.5 * U : kind.half * U,height,- top: id === "firewatch" ? 55 : id === "sawmill" ? 36.7 : id === "mine" || id === "smithy" ? 56 : height + topper+ top: id === "quarry" ? 43 : id === "farm" ? 37 : id === "firewatch" ? 55 : id === "sawmill" ? 36.7 : id === "mine" || id === "smithy" ? 56 : height + topper}}diff --git a/src/asset-lab/carpenter.ts b/src/asset-lab/carpenter.tsnew file mode 100644index 0000000..a2bae9b--- /dev/null+++ b/src/asset-lab/carpenter.ts@@ -0,0 +1,77 @@+import { U } from "../iso.ts"+import { Drawing, palette, type Vertex } from "./primitives.ts"+import type { BuildingOptions } from "./buildings.ts"+import { beam, block, iron, orient, post, roof, stone, wood } from "./workshops.ts"+import { chair, chest } from "./furniture.ts"+import { buildStages } from "../art.ts"++/** A roofed bench bay at the back leaves the forecourt open to work. */+export function makeCarpenter(options: BuildingOptions = {}) {+ const d = new Drawing("carpenter", "Carpenter", "A timber workshop with an open bench bay, braced sawhorse, plank rack, hand tools and finished chairs and chest by the entrance.")+ const fit = Math.max(0, Math.min(1, options.fit ?? 1))+ d.asset.category = "buildings"; d.asset.reference = { type: "building", kind: "carpenter" }; d.asset.footprint = 2+ if (options.plate !== false) d.plate(2)+ block(d, 0, 0, 13.5 * U, 13.5 * U, 0, 0.5, stone, 0)+ block(d, 0, -11 * U, 12 * U, 0.5 * U, 0.5, 27.5, stone)+ block(d, -11.5 * U, -6 * U, 0.5 * U, 5 * U, 0.5, 27.5, stone)+ for (const u of [-11 * U, 3 * U, 11 * U]) post(d, u, U, 28, 0.5)+ beam(d, [-11 * U, U, 27.5], [11 * U, U, 27.5], 1.5)+ for (const [u, sign] of [[-11, 1], [3, -1], [11, -1]]) beam(d, [u! * U, U, 21], [(u! + sign! * 2) * U, U, 27.5], 1.1)+ if (fit > 0.4) {+ block(d, 7 * U, -0.1 * U, 3.2 * U, 0.35 * U, 0.5, 26.5, stone)+ const p = (s: number, z: number): Vertex => [(7 + s) * U, 0.3 * U, z]+ d.face([p(-2.5, 0.5), p(2.5, 0.5), p(2.5, 20.5), p(-2.5, 20.5)], wood[1], 0.8)+ for (const x of [-1.25, 0, 1.25]) d.line([p(x, 0.5), p(x, 20.5)], 0.45, wood[2])+ for (const z of [3, 17]) beam(d, p(-2.5, z), p(2.5, z), 0.7)+ d.line([p(1.5, 9), p(1.5, 11)], 0.8, iron[2])+ d.face([[-8 * U, -10.45 * U, 13], [-3 * U, -10.45 * U, 13], [-3 * U, -10.45 * U, 21], [-8 * U, -10.45 * U, 21]], palette.glass, 0.7)+ }+ if (fit > 0) roof(d, 12.8 * U, 6.8 * U, -5.5 * U, 28, 10 * fit, 0x9a6b3f)+ if (fit > 0.75) {+ // Bench, vice and plane under the open bay.+ for (const u of [-8, -2]) for (const v of [-5, -2]) block(d, u * U, v * U, 0.3 * U, 0.3 * U, 0.5, 7.5, wood, 0.5)+ block(d, -5 * U, -3.5 * U, 4 * U, 2 * U, 8, 0.8)+ block(d, -6 * U, -3 * U, 1.2 * U, 0.4 * U, 8.8, 0.7, iron, 0.5)+ block(d, -2 * U, -1.2 * U, 0.7 * U, 0.4 * U, 7, 2.3, iron, 0.5)+ beam(d, [-2 * U, -0.7 * U, 8], [-2 * U, 0.5 * U, 8], 0.6, iron)+ beam(d, [-U, -10.3 * U, 18], [7 * U, -10.3 * U, 18], 0.7)+ for (const u of [1, 4, 6]) {+ beam(d, [u * U, -10 * U, 14], [u * U, -10 * U, 20], 0.5)+ block(d, u * U, -10 * U, 0.7 * U, 0.15 * U, 19.5, 0.7, iron, 0.4)+ }+ for (const v of [6, 10]) {+ beam(d, [-7 * U, v * U, 0.5], [-5 * U, v * U, 7.5], 0.85)+ beam(d, [-3 * U, v * U, 0.5], [-5 * U, v * U, 7.5], 0.85)+ beam(d, [-6 * U, v * U, 4], [-4 * U, v * U, 4], 0.6)+ }+ block(d, -5 * U, 8 * U, 0.6 * U, 4 * U, 7.5, 0.7)+ block(d, -5 * U, 8 * U, 1.6 * U, 5 * U, 8.2, 0.55)+ for (const v of [-9, -3]) block(d, 11.5 * U, v * U, 1.5 * U, 0.5 * U, 0.5, 1)+ for (let i = 0; i < 4; i++) block(d, 11.5 * U, -5.5 * U, 1.2 * U, 4.5 * U, 1.5 + i * 0.7, 0.5, wood, 0.45)+ chest(d, U, 9 * U, 0.5)+ chair(d, 7 * U, 8 * U, 0.5)+ chair(d, 11 * U, 9 * U, 0.5)+ }+ return orient(d.asset, options.doors)+}++/** Posts and rear walls assemble before the roof and workshop fittings. */+export function carpenterConstruction(build: number, share: number | null, doors: BuildingOptions["doors"]) {+ const d = new Drawing("carpenter", "Carpenter · construction", "Open timber frame and supplied planks.")+ const stage = buildStages(build)+ d.asset.footprint = 2+ if (share !== null) for (let i = 0; i < Math.ceil(share * 3); i++) d.crate((9 - i * 3) * U, 10 * U, 0, 0x8f9891)+ if (stage.frame > 0) {+ const top = 28 * stage.frame+ for (const u of [-11 * U, 11 * U]) for (const v of [-11 * U, U]) post(d, u, v, top, Math.min(0.5, top))+ post(d, 3 * U, U, top, Math.min(0.5, top))+ beam(d, [-11 * U, U, top], [11 * U, U, top], 1.5)+ beam(d, [-11 * U, -11 * U, top], [11 * U, -11 * U, top], 1.5)+ }+ if (stage.walls > 0) {+ block(d, 0, 0, 13.5 * U, 13.5 * U, 0, 0.5 * stage.walls, stone, 0)+ block(d, 0, -11 * U, 12 * U, 0.5 * U, 0.5, 27.5 * stage.walls, stone)+ block(d, -11.5 * U, -6 * U, 0.5 * U, 5 * U, 0.5, 27.5 * stage.walls, stone)+ }+ return orient(d.asset, doors)+}diff --git a/src/asset-lab/civic.ts b/src/asset-lab/civic.tsnew file mode 100644index 0000000..d218e29--- /dev/null+++ b/src/asset-lab/civic.ts@@ -0,0 +1,184 @@+import { U } from "../iso.ts"+import { Drawing, mix, pale, sides, type Side, type Vertex } from "./primitives.ts"+import { beam, block, orient, roof, stone } from "./workshops.ts"+import type { BuildingOptions } from "./buildings.ts"++const violet = 0x806397, blue = 0x66859e, gold = [0xe8d5a2, 0xc8ad6d, 0xa78b4e] as const+export const civicEave = (level: number) => level >= 2 ? 80 : 64++function hip(d: Drawing, u: number, v: number, a: number, z: number, rise: number, color: number) {+ const ring: Vertex[] = [[u-a,v-a,z],[u+a,v-a,z],[u+a,v+a,z],[u-a,v+a,z]]+ for (let i=0;i<4;i++) d.face([ring[i]!,ring[(i+1)%4]!,[u,v,z+rise]],pale(color,i>=2?0.6:0.42),0.8)+}++/** Continuous curved panels avoid a stair-stepped highlight on the large dome. */+function dome(d:Drawing) {+ const first=d.asset.faces.length,n=48,rows=12+ const p=(j:number,i:number):Vertex=>{+ const phi=j/rows*Math.PI/2,theta=i/n*Math.PI*2+ return[Math.cos(theta)*Math.cos(phi)*8.8*U,Math.sin(theta)*Math.cos(phi)*8.8*U,94+Math.sin(phi)*26]+ }+ for(let i=0;i<n;i++) {+ const theta=(i+.5)/n*Math.PI*2+ const light=.2+.75*Math.max(0,-.6*Math.cos(theta)+.8*Math.sin(theta))+ const color=mix(pale(blue,.18),pale(blue,.65),light)+ for(let j=0;j<rows;j++)d.face(j===rows-1?[p(j,i),p(j,i+1),p(j+1,i)]:[p(j,i),p(j,i+1),p(j+1,i+1),p(j+1,i)],color,0)+ }+ const ring=Array.from({length:n},(_,i)=>p(0,i))+ d.face([...ring].reverse(),pale(blue,.18),0)+ d.volume(first,.8)+ d.line([...ring,ring[0]!],.8)+}++/** An arched, recessed pane with its stone surround and a rooted mullion. */+function window(d: Drawing, side: Side, a: number, along: number, z: number, width=1.7*U, height=14) {+ const p=(s:number,h:number,out=0.025)=>d.wall(side,a,along+s,h,out)+ d.face([p(-width-.45*U,z-1),p(width+.45*U,z-1),p(width+.45*U,z+height-3),p(0,z+height+1),p(-width-.45*U,z+height-3)],stone[1],0.65)+ d.face([p(-width,z,.04),p(width,z,.04),p(width,z+height-4,.04),p(0,z+height-1,.04),p(-width,z+height-4,.04)],0xd8e3e7,0.65)+ d.line([p(0,z,.05),p(0,z+height-1,.05)],.65)+ d.line([p(-width,z+height*.45,.05),p(width,z+height*.45,.05)],.55)+ beam(d,p(-width-.6*U,z-1,.06),p(width+.6*U,z-1,.06),1,stone)+}++function banner(d: Drawing, u: number, v: number, z: number, color: number) {+ beam(d,[u,v-.8*U,z+1],[u,v+1.8*U,z+1],.8,gold)+ d.face([[u-1.3*U,v+1.8*U,z],[u+1.3*U,v+1.8*U,z],[u+1.3*U,v+1.8*U,z-14],[u,v+1.8*U,z-17],[u-1.3*U,v+1.8*U,z-14]],color,.7)+ d.face([[u,v+1.82*U,z-4],[u+.65*U,v+1.82*U,z-7],[u,v+1.82*U,z-10],[u-.65*U,v+1.82*U,z-7]],gold[0],.5)+}++function entrance(d: Drawing, v: number, half: number, height: number) {+ const p=(u:number,z:number):Vertex=>[u,v+.02,z]+ block(d,0,v+U,half+2*U,U,0,2,stone)+ d.face([p(-half,2),p(half,2),p(half,height),p(0,height+4),p(-half,height)],0xbda683,.8)+ for (const u of [-half-.6*U,half+.6*U]) block(d,u,v+.5*U,.6*U,.5*U,2,height,stone)+ for (const sign of [-1,1]) {+ const x=sign*.7*U+ d.line([p(x,10),p(x,13)],1,gold[2])+ }+ d.line([p(0,2),p(0,height+4)],.7)+ for (const z of [7,height-4]) d.line([p(-half,z),p(half,z)],.6,0x8a6a45)+}++function guildhall(d: Drawing) {+ block(d,0,0,18*U,16*U,0,64,stone,1.4)+ block(d,0,0,18.5*U,16.5*U,0,3,stone)+ // Broad roof ridges run along the hall, with a projecting clock tower.+ roof(d,19*U,17*U,0,64,23,violet)+ for (const side of sides) {+ const a=(side==="left"||side==="backLeft"?16:18)*U+ for (const s of [-11*U,11*U]) {+ window(d,side,a,s,12,1.8*U,15)+ window(d,side,a,s,41,1.8*U,16)+ }+ const p=(s:number,z:number)=>d.wall(side,a,s,z,.04)+ beam(d,p(-a,33),p(a,33),1.6,stone)+ beam(d,p(-a,61),p(a,61),1.8,stone)+ }+ for (const u of [-17*U,17*U]) for (const v of [-15*U,15*U]) block(d,u,v,.75*U,.75*U,0,64,stone)+ // The tower has a foundation, an entrance and a sheltered balcony.+ const v=12.5*U,a=5*U+ block(d,0,v,a,a,0,108,stone,1.3)+ block(d,0,v,5.6*U,5.6*U,79,2.5,stone)+ block(d,0,v,5.6*U,5.6*U,106,2,stone)+ for (const side of sides) {+ const p=(s:number,z:number):Vertex=>{+ const q=d.wall(side,a,s,z,.025);return [q[0],q[1]+v,q[2]]+ }+ // Floor coordinates and pixel-authored heights have different world scales.+ // A 3U horizontal radius needs 3√6 height units to be circular on the wall.+ const radius=3*Math.sqrt(6)+ const clock=(angle:number,r=1)=>p(Math.cos(angle)*3*U*r,94+Math.sin(angle)*radius*r)+ const ring=Array.from({length:33},(_,i)=>clock(i*Math.PI/16))+ d.face(ring,0xf7f5e9,.9)+ d.line([clock(Math.PI/2,.8),p(0,94),clock(0,.73)],1)+ for (const t of [0,Math.PI/2,Math.PI,3*Math.PI/2]) d.line([clock(t,.84),clock(t,.94)],.65)+ }+ hip(d,0,v,6.3*U,108,23,violet)+ d.cylinder(0,v,.45*U,130,6,gold[1],gold[0],.65,12)+ entrance(d,17.5*U,3*U,25)+ for (const u of [-5.5*U,5.5*U]) {+ block(d,u,20.5*U,.65*U,.65*U,2,30,stone)+ beam(d,[u,17.5*U,24],[u,20.5*U,31],1.2,stone)+ }+ block(d,0,19*U,6.3*U,2.2*U,31,1.8,stone)+ for (const u of [-5.5,-3.3,-1.1,1.1,3.3,5.5]) block(d,u*U,21*U,.2*U,.2*U,33,6,stone,.55)+ beam(d,[-6*U,21*U,39],[6*U,21*U,39],.9,stone)+ window(d,"left",17.55*U,0,33,2.2*U,26)+ banner(d,-7.5*U,16.1*U,55,violet)+ banner(d,7.5*U,16.1*U,55,violet)+ // Roof dormers break up the rear ridge as well as the street silhouette.+ for (const sign of [-1,1]) for (const y of [-9*U,2*U]) {+ block(d,sign*10*U,y,2*U,2*U,72,8,stone)+ hip(d,sign*10*U,y,2.7*U,80,6,violet)+ }+}++function cityhall(d: Drawing) {+ // A taller central hall and lower wings replace the single flat block.+ block(d,0,0,10*U,16*U,0,80,stone,1.4)+ for (const u of [-15*U,15*U]) {+ block(d,u,0,5*U,15*U,0,50,stone,1.2)+ block(d,u,0,5.5*U,15.5*U,47,3,stone)+ roof(d,5.5*U,15.5*U,0,50,10,blue,u)+ for (const v of [-11*U,11*U]) {+ block(d,u,v,4.2*U,4.2*U,0,60,stone,1.2)+ block(d,u,v,4.7*U,4.7*U,58,2,stone)+ hip(d,u,v,5*U,60,12,blue)+ d.cylinder(u,v,.45*U,71.5,3.5,gold[1],gold[0],.5,10)+ }+ }+ block(d,0,0,10.7*U,16.7*U,76,4,stone)+ for (const side of sides) {+ const front=side==="left"||side==="backLeft",a=(front?16:20)*U+ for (const s of front?[-15*U,15*U]:[-10*U,0,10*U]) for (const z of [12,35]) window(d,side,front?15.2*U:a,s,z,1.4*U,11)+ if (front) {+ for (const s of [-6*U,0,6*U]) window(d,side,a,s,53,1.5*U,17)+ const p=(s:number,z:number)=>d.wall(side,a,s,z,.04)+ beam(d,p(-10*U,49),p(10*U,49),1.4,stone)+ }+ }+ for (const u of [-9*U,9*U]) for (const v of [-15.5*U,15.5*U]) block(d,u,v,.65*U,.65*U,0,76,stone)+ // A wide ceremonial stair leads into the columned portico.+ for (let i=0;i<4;i++) block(d,0,(21-i*.7)*U,(11-i*.45)*U,(1.5+i*.15)*U,i,1,stone)+ entrance(d,16*U,3.4*U,27)+ for (const u of [-8*U,-4*U,4*U,8*U]) {+ block(d,u,20*U,.85*U,.85*U,4,2,stone)+ d.cylinder(u,20*U,.52*U,6,29,stone[1],stone[0],.7,16)+ block(d,u,20*U,1.05*U,1.05*U,35,2,stone)+ }+ block(d,0,18.7*U,10*U,2.4*U,37,3,stone)+ const back:Vertex[]=[[-10*U,16.3*U,40],[10*U,16.3*U,40],[0,16.3*U,48]],+ front:Vertex[]=[[-10*U,21.1*U,40],[10*U,21.1*U,40],[0,21.1*U,48]]+ d.face(front,stone[0],.8)+ for(let i=0;i<3;i++)d.face([back[i]!,back[(i+1)%3]!,front[(i+1)%3]!,front[i]!],stone[1],.8)+ // A gilt civic crest sits in the pediment instead of a text label.+ d.face([[-1.4*U,21.12*U,42.5],[1.4*U,21.12*U,42.5],[U,21.12*U,45.5],[-U,21.12*U,45.5]],gold[1],.6)+ banner(d,-8.7*U,16.2*U,70,blue)+ banner(d,8.7*U,16.2*U,70,blue)+ // An arcaded drum, broad dome and lantern crown the central block.+ d.cylinder(0,0,8.2*U,80,14,stone[1],stone[0],.8,32)+ for (let i=0;i<12;i++) {+ const t=i*Math.PI/6,c=Math.cos(t),s=Math.sin(t),r=8.24*U,w=1.1*U+ const p=(x:number,z:number):Vertex=>[c*r-s*x,s*r+c*x,z]+ d.face([p(-w,83),p(w,83),p(w,89),p(0,92),p(-w,89)],0xd8e3e7,.65)+ d.line([p(0,83),p(0,92)],.6)+ }+ dome(d)+ // Curved ribs are rooted at the drum and meet beneath the lantern.+ for(let i=0;i<8;i++) {+ const t=i*Math.PI/4+ d.line(Array.from({length:17},(_,j):Vertex=>{const a=j*Math.PI/32;return[Math.cos(t)*Math.cos(a)*8.82*U,Math.sin(t)*Math.cos(a)*8.82*U,94+Math.sin(a)*26.05]}),.6,pale(blue,.1))+ }+ block(d,0,0,2*U,2*U,118,14,stone)+ for(const side of sides)window(d,side,2.03*U,0,121,.7*U,7)+ hip(d,0,0,2.7*U,132,8,blue)+ d.cylinder(0,0,.4*U,139.5,7,gold[1],gold[0],.6,12)+}++export function civicBuilding(level: number, options: BuildingOptions = {}) {+ const city=level>=2,d=new Drawing(city?"cityhall":"guildhall",city?"City hall":"Guildhall",city?"A domed civic palace with lower wings, corner pavilions, a ceremonial stair and columned portico.":"A steep-roofed guild house with a tall clock tower, stone balcony, dormers and hanging guild banners.")+ d.asset.category="buildings";d.asset.reference={type:"building",kind:"townhall"};d.asset.footprint=3+ if(options.plate!==false)d.plate(3)+ if(city)cityhall(d);else guildhall(d)+ return orient(d.asset,options.doors)+}diff --git a/src/asset-lab/construction.ts b/src/asset-lab/construction.tsindex c007b86..bffd9bc 100644--- a/src/asset-lab/construction.ts+++ b/src/asset-lab/construction.ts@@ -2,6 +2,7 @@ import { Drawing, palette, square, type Vertex } from "./primitives.ts"import { buildStages } from "../art.ts"import { kinds, type KindId } from "../content.ts"import { U } from "../iso.ts"+import { buildingDimensions } from "./buildings.ts"export function makeSite(share: number, size = 2) {const d = new Drawing(@@ -43,7 +44,7 @@ export function makeSite(share: number, size = 2) {export function makeConstruction(kindId: KindId, progress: number) {const kind = kinds[kindId],a = kind.half * U,- H = kind.roof === "gable" ? 20 : kind.stories * 32,+ H = buildingDimensions(kindId).height,stage = buildStages(progress)const d = new Drawing(`build-${kindId}-${progress}`,diff --git a/src/asset-lab/furniture.ts b/src/asset-lab/furniture.tsnew file mode 100644index 0000000..8bc5284--- /dev/null+++ b/src/asset-lab/furniture.ts@@ -0,0 +1,18 @@+import { U } from "../iso.ts"+import { Drawing } from "./primitives.ts"+import { block, wood, iron } from "./workshops.ts"++/** Furniture shares its dimensions in the work yard and on delivery carts. */+export function chair(d: Drawing, u: number, v: number, z = 0) {+ for (const x of [-0.7, 0.7]) for (const y of [-0.7, 0.7])+ block(d, u + x * U, v + y * U, 0.15 * U, 0.15 * U, z, y < 0 ? 8.5 : 3.5, wood, 0.45)+ block(d, u, v, U, U, z + 3.5, 0.65, wood, 0.55)+ for (const h of [6, 8]) block(d, u, v - 0.7 * U, 0.7 * U, 0.15 * U, z + h, 0.5, wood, 0.45)+}++export function chest(d: Drawing, u: number, v: number, z = 0) {+ block(d, u, v, 1.8 * U, 1.1 * U, z + 0.35, 3.6, wood, 0.65)+ block(d, u, v, 1.95 * U, 1.25 * U, z + 3.95, 0.7, wood, 0.65)+ for (const x of [-1.2, 1.2]) block(d, u + x * U, v + 1.12 * U, 0.12 * U, 0.06 * U, z + 0.5, 3.4, iron, 0.3)+ block(d, u, v + 1.3 * U, 0.25 * U, 0.08 * U, z + 3.1, 1, iron, 0.4)+}diff --git a/src/asset-lab/people.ts b/src/asset-lab/people.tsindex 3077454..0126708 100644--- a/src/asset-lab/people.ts+++ b/src/asset-lab/people.ts@@ -2,6 +2,7 @@ import { carrierDress, cartLook, residentDress, serviceDress, homeVariant, typeimport { goods, type GoodId } from "../content.ts"import { Drawing, palette, type Vertex } from "./primitives.ts"import { U } from "../iso.ts"+import { chair, chest } from "./furniture.ts"const R = 45.2548export type ServiceRole = "watchman" | "firefighter" | "physician" | "constable" | "builder"@@ -241,15 +242,8 @@ export function drawCargo(d: Drawing, good: GoodId, count: number, u: number, v:d.box(u + 0.03, v, 0.035, 0.018, z + 8, 1.6, 0x8f9891, 0x8f9891, 0x7c857d, 0.75)breakcase "furniture": {- // A chest, and a chair on it (two chairs side by side in a full load).- d.box(u, v, 1.8 * U, 1.1 * U, z, 3, 0xc9965f, 0xb5814c, 0x9a6b3f, 1)- for (const c of n >= 2 ? [-0.8, 0.8] : [0]) {- const y = v + c * U- d.box(u, y, 0.6 * U, 0.6 * U, z + 5, 0.8, 0xe0b27e, 0xc9965f, 0xb5814c, 0.75)- d.box(u - 0.5 * U, y, 0.12 * U, 0.6 * U, z + 5.8, 4, 0xe0b27e, 0xc9965f, 0xb5814c, 0.75)- for (const [a, b] of [[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5], [-0.5, 0.5]] as const)- d.line([[u + a * U, y + b * U, z + 3], [u + a * U, y + b * U, z + 5]], 0.6, 0x8a6a45)- }+ chest(d, u, v, z)+ if (n >= 2) chair(d, u, v, z + 4.65)break}}diff --git a/src/asset-lab/scaffolding.ts b/src/asset-lab/scaffolding.tsnew file mode 100644index 0000000..8680960--- /dev/null+++ b/src/asset-lab/scaffolding.ts@@ -0,0 +1,83 @@+import { U } from "../iso.ts"+import { Drawing, type Vertex } from "./primitives.ts"+import { beam as solidBeam, block as solidBlock, stone, wood } from "./workshops.ts"++// Repeated scaffold members retain solid faces, with one ink edge per edge.+// Outlining every face separately would duplicate the same lines many times.+function block(d:Drawing,u:number,v:number,a:number,b:number,z:number,h:number,colors:readonly[number,number,number]=wood,width=.5) {+ solidBlock(d,u,v,a,b,z,h,colors,0)+ const ring:Vertex[]=[[u-a,v-b,z+h],[u+a,v-b,z+h],[u+a,v+b,z+h],[u-a,v+b,z+h]]+ d.line([...ring,ring[0]!],width)+ for(const [x,y]of ring)d.line([[x,y,z],[x,y,z+h]],width)+}+function beam(d:Drawing,a:Vertex,b:Vertex,width=.65) {+ const first=d.asset.faces.length,lines=d.asset.strokes.length+ solidBeam(d,a,b,width)+ d.asset.strokes.length=lines+ for(const f of d.asset.faces.slice(first,first+4))d.line([f.points[0]!,f.points[3]!],.5)+}+function post(d:Drawing,u:number,v:number,top:number,bottom:number) {+ block(d,u,v,.8*U,.8*U,0,bottom,stone)+ if(top>bottom)block(d,u,v,.4*U,.4*U,bottom,top-bottom)+}++/** One reusable perimeter scaffold. It knows no building kinds or meshes.+ * Open central bays preserve access on every side, regardless of road layout. */+export function scaffoldAsset(size: number, height: number, share: number) {+ const d=new Drawing("scaffold","Building works","Modular timber scaffold with working platforms, access ladder, canvas screens and delivered supplies.")+ const progress=Math.max(0,Math.min(1,share)),s=(size*8-1.8)*U,inner=s-.8*U+ const rise=5+(Math.max(8,height)+5)*progress+ const n=Math.max(4,Math.ceil(2*s/(6*U)/2)*2)+ const stations=Array.from({length:n+1},(_,i)=>-s+2*s*i/n).filter(x=>Math.abs(x)>U)+ const levels:number[]=[]+ const deck=Math.max(2,rise-6)+ for(let z=8;z<deck-1;z+=12)levels.push(z)+ if(!levels.length||deck-levels[levels.length-1]!>2)levels.push(deck)+ const platformLevels=levels.slice(-2)+ for(let side=0;side<4;side++) {+ const p=(along:number,out:number,z:number):Vertex=>{+ switch(side){case 0:return[along,out,z];case 1:return[out,-along,z];case 2:return[-along,-out,z];default:return[-out,along,z]}+ }+ for(const x of stations) {+ const outer=p(x,s,0),inside=p(x,inner,0)+ post(d,outer[0],outer[1],rise,.5)+ // Inner standards give the boards two solid supports.+ block(d,inside[0],inside[1],.22*U,.22*U,.5,Math.max(.1,rise-.5),wood,.5)+ for(const z of levels)beam(d,p(x,inner,z),p(x,s,z),.65)+ }+ for(let i=0;i<stations.length-1;i++) {+ const a=stations[i]!,b=stations[i+1]!,gate=a<0&&b>0+ for(const z of levels) {+ if(gate&&z<24)continue+ beam(d,p(a,s,z),p(b,s,z),.7)+ beam(d,p(a,inner,z),p(b,inner,z),.65)+ if(platformLevels.includes(z)) {+ // Two actual boards, with a narrow seam and a protective top rail.+ for(const t of [.23,.67]) {+ const q=p((a+b)/2,inner+t*U,z+.15)+ block(d,q[0],q[1],(side%2?.18*U:(b-a)/2),(side%2?(b-a)/2:.18*U),z+.15,.5,wood,.45)+ }+ if(z+5<rise)beam(d,p(a,s,z+5),p(b,s,z+5),.55)+ }+ }+ // Diagonal braces stay away from the entrances.+ if(!gate)beam(d,p(a,s,.6),p(b,s,Math.min(rise-1,20)),.65)+ }+ // A canvas panel is tied into one outer bay. It reads as active work at low progress.+ const a=stations[0]!,b=stations[1]!,z=Math.min(8,rise-1)+ if(z>3)d.face([p(a+.3*U,s+.025*U,1.5),p(b-.3*U,s+.025*U,1.5),p(b-.3*U,s+.025*U,z),p(a+.3*U,s+.025*U,z)],0xd6c39a,.5)+ }+ // The ladder rests on a rear bay and meets the highest working platform.+ const a=-s*.8,b=-s*.57+ for(const offset of [-.45*U,.45*U])beam(d,[a+offset,-s,0],[b+offset,-s,deck+.8],.6)+ for(let z=2;z<deck;z+=3) {+ const x=a+(b-a)*z/(deck+.8)+ beam(d,[x-.45*U,-s,z],[x+.45*U,-s,z],.5)+ }+ // Compact corner piles work even when the building fills most of its plot.+ const c=s-1.4*U+ for(let i=0;i<Math.ceil(progress*4);i++)d.crate(c,c,1+i*3.2,0x8f9891,.85*U,3.2)+ for(let i=0;i<Math.ceil(progress*3);i++)block(d,-c,c,1.7*U,.4*U,1+i*.65,.5,wood,.4)+ d.asset.category="construction";d.asset.footprint=size+ return d.asset+}diff --git a/src/asset-lab/upgrade-catalogue.ts b/src/asset-lab/upgrade-catalogue.tsnew file mode 100644index 0000000..e6fac40--- /dev/null+++ b/src/asset-lab/upgrade-catalogue.ts@@ -0,0 +1,36 @@+import { buildingDimensions, makeBuilding } from "./buildings.ts"+import { dressedBuilding, scaffoldAsset } from "./upgrade-dress.ts"+import type { InkAsset } from "./primitives.ts"++export function upgradeCatalogue(): InkAsset[] {+ const upgrades = ([+ ["townhall", 1, "guildhall", "Guildhall", "A steep-roofed guild house with a tall clock tower, stone balcony, dormers and hanging guild banners."],+ ["townhall", 2, "cityhall", "City hall", "A domed civic palace with lower wings, corner pavilions, a ceremonial stair and columned portico."],+ ["warehouse", 1, "depot", "Depot", "A braced gantry spans the cargo apron, with its pulley and load inside the yard."],+ ["bakery", 1, "ovenworks", "Ovenworks", "A second brick flue rises out of the bakehouse behind the open oven."],+ ["quarry", 1, "masonry", "Masonry", "A solid timber derrick and dressed blocks in an open stonecutting yard."],+ ["farm", 1, "estate", "Estate", "A raised dovecote and open hay shelter occupy the farm's spare yard."],+ ["firewatch", 1, "fire-brigade", "Fire brigade", "A hand pump and wheeled hose cart equip the existing bell lookout."]+ ] as const).map(([kind, level, id, title, note]) => ({+ ...dressedBuilding(kind, level, makeBuilding(kind), buildingDimensions(kind).height),+ id, title, note, reference: { type: "none" } as const+ }))+ const stages = [0.15, 0.5, 0.9].map(share => {+ const base = makeBuilding("townhall"), frame = scaffoldAsset(3, buildingDimensions("townhall").height, share)+ return { ...base, id: `upgrade-works-${Math.round(share * 100)}`, title: `Materials delivered · ${Math.round(share * 100)}%`,+ note: "Reusable scaffold bays, working platforms, ladders, canvas screens and incoming supplies.", reference: { type: "none" } as const,+ faces: [...base.faces, ...frame.faces], strokes: [...base.strokes, ...frame.strokes] }+ })+ const examples = ([+ ["carpenter",0,.5], ["warehouse",0,.65], ["quarry",0,.5],+ ["farm",0,.75], ["townhall",1,.5], ["townhall",2,.9]+ ] as const).map(([kind,level,share]) => {+ const base=level?upgrades.find(a=>a.id===(level===1?"guildhall":"cityhall"))!:makeBuilding(kind)+ const height=kind==="townhall"&&level===2?80:buildingDimensions(kind).height+ const frame=scaffoldAsset(base.footprint!,height,share)+ return {...base,id:`works-${kind}-${level}`,title:`${base.title} · works`,+ note:"The same construction generator, using only plot size, height and delivered share.",reference:{type:"none"} as const,+ faces:[...base.faces,...frame.faces],strokes:[...base.strokes,...frame.strokes]}+ })+ return [...upgrades, ...stages, ...examples]+}diff --git a/src/asset-lab/upgrade-dress.ts b/src/asset-lab/upgrade-dress.tsindex 278b2b1..b44a17a 100644--- a/src/asset-lab/upgrade-dress.ts+++ b/src/asset-lab/upgrade-dress.ts@@ -1,134 +1,108 @@-/**- * How a building upgraded where it stands is told apart from the one it- * was (the market hall and the church have models of their own, see- * `service-upgrades.ts`): what the upgrade adds to it, drawn over the- * building's own model and never past its plot. A guildhall's clock tower,- * a city hall's dome, a depot's hoist, an ovenworks' second chimney, a- * masonry's derrick, an estate's dovecote, a fire brigade's bell. And the- * scaffolding that stands inside a building's plot while an upgrade is under- * way, rising with the share of its materials in.- */+/** Supported additions to the existing buildings, inside their plots. */import { U } from "../iso.ts"-import { kinds, type KindId } from "../content.ts"-import { Drawing, palette, square, type InkAsset, type Vertex } from "./primitives.ts"+import type { KindId } from "../content.ts"+import { Drawing, square, type InkAsset } from "./primitives.ts"+import { beam, block, iron, orient, post, roof, stone, wheel, wood } from "./workshops.ts"+import type { BuildingOptions } from "./buildings.ts"+import { civicBuilding } from "./civic.ts"+export { scaffoldAsset } from "./scaffolding.ts"-const brick = { top: 0xd99a7e, left: 0xc77d63, right: 0xb5654a }-const stone = { top: 0xf0f1eb, left: 0xe1e5dc, right: 0xd3d9cf }-const slate = { face: 0x8f9891, shade: 0x6f7872 }-const timber = { top: 0xeee2c8, left: 0xdcc9a8, right: 0xc6b18e }--/** A four-sided roof to a point over (u, v). */-const spire = (d: Drawing, u: number, v: number, a: number, z: number, rise: number, face: number, shade: number) => {- const base: Array<Vertex> = square(u, v, a, z)- for (let i = 0; i < 4; i++) d.face([base[i]!, base[(i + 1) % 4]!, [u, v, z + rise]], i === 2 || i === 3 ? face : shade)+const brick = [0xd99a7e, 0xc77d63, 0xb5654a] as const+const spire = (d: Drawing, u: number, v: number, a: number, z: number, rise: number) => {+ const base = square(u, v, a, z)+ for (let i = 0; i < 4; i++) d.face([base[i]!, base[(i + 1) % 4]!, [u, v, z + rise]], i >= 2 ? 0xb0b9b0 : 0x8f9990, 0.8)}-/** The kinds that can be upgraded and are drawn by dressing their own model (not the market and chapel). */export const dressed = ["townhall", "warehouse", "bakery", "quarry", "farm", "firewatch"] as const satisfies ReadonlyArray<KindId>export type DressedKind = (typeof dressed)[number]export const isDressed = (id: KindId): id is DressedKind => (dressed as ReadonlyArray<KindId>).includes(id)-/** What an upgrade adds, and the height of its highest point (for the marker over it). */-const dress = (id: DressedKind, level: number, eave: number): { readonly asset: InkAsset; readonly top: number } => {+function dress(id: DressedKind, level: number, eave: number): InkAsset {const d = new Drawing(`${id}-upgrade-${level}`, "Upgrade", "")- const plot = kinds[id].size * 8 * Uswitch (id) {case "townhall": {- if (level >= 2) {- // A city hall: a broad drum and a dome over the old roof.- d.box(0, 0, 7 * U, 7 * U, eave, 18, stone.top, stone.left, stone.right)- d.cylinder(0, 0, 6 * U, eave + 18, 10, 0xd3d9cf, 0xf0f1eb, 1, 24)- d.ellipsoid(0, 0, eave + 28, 6 * U, 6 * U, 14, 0xb8c9d6, 1, 0xdfe8ee, 20)- d.cylinder(0, 0, 0.8 * U, eave + 41, 8, 0xb39a61, 0xd5c18b, 0.7, 10)- return { asset: d.asset, top: eave + 50 }- }- // A guildhall: a clock tower on the roof.- d.box(0, 0, 5 * U, 5 * U, eave, 26, stone.top, stone.left, stone.right)- // A clock face on each side the camera sees.- const w = 5.01 * U, c = 2.2 * U, z = eave + 15- d.face([[w, -c, z], [w, c, z], [w, c, z + 8], [w, -c, z + 8]], 0xf7f8f4, 1)- d.face([[-c, w, z], [c, w, z], [c, w, z + 8], [-c, w, z + 8]], 0xf7f8f4, 1)- d.line([[w, 0, z + 4], [w, 0, z + 7]], 1)- d.line([[0, w, z + 4], [1.6 * U, w, z + 4]], 1)- spire(d, 0, 0, 6 * U, eave + 26, 16, slate.face, slate.shade)- return { asset: d.asset, top: eave + 42 }+ return civicBuilding(level, { plate: false })}case "warehouse": {- // A depot: a hoist over the yard, and crates stacked on the roof.- const c = plot - 2 * U- d.line([[c, c, 0], [c, c, eave + 22]], 1.5)- d.line([[c, -c, 0], [c, -c, eave + 22]], 1.5)- d.line([[c, c, eave + 22], [c, -c, eave + 22]], 1.5)- d.line([[c, 0, eave + 22], [c, 0, eave + 8]], 0.8, palette.ink, 0.7)- d.crate(c - 0.5 * U, 0, eave + 2, 0x6e8f36, 1.2 * U, 5)- for (const [u, v, z] of [[-8 * U, -8 * U, eave], [-5 * U, -8 * U, eave], [-8 * U, -5 * U, eave], [-6.5 * U, -6.5 * U, eave + 5]] as const)- d.crate(u, v, z, 0x8a58a8, 1.2 * U, 5)- return { asset: d.asset, top: eave + 26 }+ // A gantry spans the loading apron. Cargo stays in the yard.+ for (const u of [-16 * U, 16 * U]) {+ post(d, u, 18 * U, 52)+ beam(d, [u, 18 * U, 40], [u * 0.72, 18 * U, 51], 1.4)+ }+ beam(d, [-16 * U, 18 * U, 52], [16 * U, 18 * U, 52], 2)+ block(d, 8 * U, 18 * U, 1.3 * U, 0.8 * U, 50.5, 1.5, iron)+ wheel(d, 8 * U, 18 * U, 50, 1.5)+ d.line([[8 * U, 18 * U, 49], [8 * U, 18 * U, 16]], 0.75, wood[2])+ d.crate(8 * U, 18 * U, 8, 0x8a58a8, 1.8 * U, 6)+ d.line([[6.2 * U, 18 * U, 14], [8 * U, 18 * U, 16], [9.8 * U, 18 * U, 14]], 0.75)+ break}case "bakery": {- // An ovenworks: a second, taller brick chimney.- d.box(-6 * U, 5 * U, 1.8 * U, 1.8 * U, 0, eave + 30, brick.top, brick.left, brick.right)- d.box(-6 * U, 5 * U, 2.2 * U, 2.2 * U, eave + 30, 2, brick.top, brick.left, brick.right)- return { asset: d.asset, top: eave + 34 }+ block(d, -3 * U, -3 * U, 1.8 * U, 1.8 * U, 1, 59, brick)+ block(d, -3 * U, -3 * U, 2.2 * U, 2.2 * U, 59, 2, brick)+ d.face(square(-3 * U, -3 * U, 1.4 * U, 61.02), 0x68726c, 0)+ for (const z of [43, 49, 55]) d.line([[-4.8 * U, -1.18 * U, z], [-1.2 * U, -1.18 * U, z]], 0.45, 0x9a654f)+ break}case "quarry": {- // A masonry: a derrick over the pit, and dressed blocks waiting by it.- const c = plot - 2.5 * U- d.line([[c, c, 0], [c, c, 52]], 2)- d.line([[c, c, 50], [-c * 0.4, -c * 0.4, 30]], 1.5)- d.line([[c, c, 0], [c - 4 * U, c, 0], [c, c, 30]], 1, palette.ink, 0.8)- d.line([[-c * 0.4, -c * 0.4, 30], [-c * 0.4, -c * 0.4, 14]], 0.8, palette.ink, 0.7)- for (const [u, v, z] of [[-c, c, 0], [-c + 2.6 * U, c, 0], [-c + 1.3 * U, c, 4]] as const) d.box(u, v, 1.2 * U, 1.2 * U, z, 4, stone.top, stone.left, stone.right, 1)- return { asset: d.asset, top: 56 }+ post(d, 12 * U, 9 * U, 52)+ beam(d, [12 * U, 9 * U, 45], [U, 3 * U, 42], 2)+ beam(d, [12 * U, 9 * U, 23], [3 * U, 4 * U, 42], 1.5)+ beam(d, [8 * U, 12 * U, 0], [12 * U, 9 * U, 28], 1.2)+ d.line([[U, 3 * U, 42], [U, 3 * U, 32]], 0.75, wood[2])+ block(d, U, 3 * U, 1.4 * U, 1.2 * U, 25, 6, stone)+ d.line([[-0.4 * U, 3 * U, 31], [U, 3 * U, 32], [2.4 * U, 3 * U, 31]], 0.75)+ for (const z of [0, 5]) block(d, 12 * U, -5 * U, 1.2 * U, 1.3 * U, z, 5, stone)+ break}case "farm": {- // An estate: a dovecote in a corner of the yard, and a hayrick.- const c = plot - 3 * U- d.box(c, -c, 2.2 * U, 2.2 * U, 0, 22, timber.top, timber.left, timber.right)- spire(d, c, -c, 2.8 * U, 22, 10, slate.face, slate.shade)- d.ellipsoid(-c, c, 0, 3 * U, 3 * U, 10, 0xe6c85a, 1, 0xf1dc8a, 16)- return { asset: d.asset, top: Math.max(eave + 12, 34) }+ // The dovecote is clear of the silo and the hay shelter stays open.+ const u = -18 * U, v = -16 * U+ for (const du of [-1.5 * U, 1.5 * U]) for (const dv of [-1.5 * U, 1.5 * U]) post(d, u + du, v + dv, 15)+ block(d, u, v, 2.2 * U, 2.2 * U, 15, 11, wood)+ spire(d, u, v, 2.8 * U, 26, 7)+ for (const dx of [-U, U]) d.face([[u + dx - 0.4 * U, v + 2.21 * U, 18], [u + dx + 0.4 * U, v + 2.21 * U, 18], [u + dx + 0.4 * U, v + 2.21 * U, 21], [u + dx - 0.4 * U, v + 2.21 * U, 21]], 0x68726c, 0.4)+ beam(d, [u - 2 * U, v + 3 * U, 17.5], [u + 2 * U, v + 3 * U, 17.5], 0.6)+ for (const dx of [-1.5 * U, 1.5 * U]) beam(d, [u + dx, v + 2.2 * U, 20], [u + dx, v + 3 * U, 17.5], 0.45)+ for (const x of [-20, -14]) for (const y of [10, 19]) post(d, x * U, y * U, 16)+ roof(d, 3.8 * U, 5.3 * U, 14.5 * U, 16, 5, 0x8a6a45, -17 * U)+ for (const y of [12, 17]) d.log("u", y * U, -19 * U, -15 * U, 1, 2, 0xe9cf7c, 0xf3e3a8)+ break}case "firewatch": {- // A fire brigade: a bell frame with its bell over the roof.- const z = eave + 26- for (const [u, v] of square(0, 0, 2 * U)) d.line([[u, v, z], [u, v, z + 12]], 1.2)- spire(d, 0, 0, 2.6 * U, z + 12, 6, 0xc4523f, 0xa8432f)- d.ellipsoid(0, 0, z + 4, 1.2 * U, 1.2 * U, 4, 0xb39a61, 1, 0xd5c18b, 12)- return { asset: d.asset, top: z + 20 }+ // Equip the yard rather than floating a second bell above the lookout.+ const u = -11 * U, v = 10 * U+ block(d, u, v, 1.1 * U, 1.1 * U, 0, 1, stone)+ d.cylinder(u, v, 0.5 * U, 1, 8, iron[1], iron[0], 0.6, 12)+ beam(d, [u, v, 8], [u + 2 * U, v, 10], 0.8, iron)+ beam(d, [u, v, 6], [u, v + 1.8 * U, 6], 0.8, iron)+ d.barrel(u, v + 2 * U, U, 0, 3.5, 0xa8c7c1)+ const x = 11 * U, y = 9 * U+ block(d, x, y, 1.5 * U, 3 * U, 2.5, 1.2, wood)+ for (const dx of [-1.8 * U, 1.8 * U]) wheel(d, x + dx, y, 2.5, 2.3)+ beam(d, [x - 1.8 * U, y, 2.5], [x + 1.8 * U, y, 2.5], 0.7, iron)+ for (const dx of [-U, U]) beam(d, [x + dx, y, 3.5], [x + dx, y + 5 * U, 4.5], 0.8)+ for (let i = 0; i < 3; i++) d.cylinder(x, y, 1.25 * U, 3.7 + i * 0.7, 0.55, 0xb6a37a, 0xd4c8a7, 0.45, 16)+ break}}+ return d.asset}-/** A building's own model with its upgrades drawn on: what it looks like at `level`. */-export function dressedBuilding(id: DressedKind, level: number, base: InkAsset, eave: number): InkAsset {- const extra = dress(id, level, eave).asset+export function dressedBuilding(id: DressedKind, level: number, base: InkAsset, eave: number, doors?: BuildingOptions["doors"]): InkAsset {+ if (id === "townhall") return {+ ...civicBuilding(level, { doors: doors ?? {}, plate: base.faces.some(f => f.points.every(p => p[2] < 0)) }), id: `${base.id}-${level}`+ }+ const raw = dress(id, level, eave)+ const extra = id === "warehouse" || id === "bakery" ? orient(raw, doors) : rawreturn { ...base, id: `${base.id}-${level}`, faces: [...base.faces, ...extra.faces], strokes: [...base.strokes, ...extra.strokes] }}--/** The highest point of an upgraded building, for the marker drawn over it. */-export const dressedTop = (id: DressedKind, level: number, eave: number): number => dress(id, level, eave).top--/**- * Scaffolding inside a building's plot while it is upgraded: poles at its- * corners, ledgers and boards rising with the `share` of its materials in,- * and the crates the carriers have brought stacked by them.- */-export function scaffoldAsset(size: number, height: number, share: number): InkAsset {- const d = new Drawing("scaffold", "Scaffolding", ""),- s = (size * 8 - 1.2) * U,- top = height + 8,- rise = Math.max(4, Math.round(top * Math.min(1, share)))- for (const [u, v] of square(0, 0, s)) d.line([[u, v, 0], [u, v, top]], 1.2, 0x8a6a45)- // A ledger every few feet of what is in, and the boards they carry.- for (let z = 6; z <= rise; z += 8) {- d.line([...square(0, 0, s, z), [s, s, z]], 1, 0x8a6a45, 0.9)- d.line([[s, s, z + 0.2], [s, -s, z + 0.2]], 2.2, 0xd5a86c, 0.85)- }- // Diagonal braces on the two faces the camera sees most.- d.line([[s, s, 0], [s, -s, rise]], 0.8, 0x8a6a45, 0.7)- d.line([[s, s, 0], [-s, s, rise]], 0.8, 0x8a6a45, 0.7)- const crates = Math.ceil(Math.min(1, share) * 3)- for (let i = 0; i < crates; i++) d.crate(s - 1.4 * U, s - (1.4 + i * 2.6) * U, 0, 0x8f9891, 1.1 * U, 4)- return d.asset+const tops = new Map<string, number>()+export const dressedTop = (id: DressedKind, level: number, eave: number): number => {+ const key=`${id}/${level}/${eave}`,cached=tops.get(key)+ if(cached!==undefined)return cached+ const a = dress(id, level, eave)+ const top=Math.max(0, ...a.faces.flatMap(f => f.points.map(p => p[2])), ...a.strokes.flatMap(s => s.points.map(p => p[2])))+ tops.set(key,top)+ return top}diff --git a/src/map-lab/map.ts b/src/map-lab/map.tsindex 155495f..f8411f0 100644--- a/src/map-lab/map.ts+++ b/src/map-lab/map.ts@@ -140,6 +140,10 @@ const quarter: Array<[string, number, number]> = [["park-fountain", 11, -8]]for (const [id, x, y] of quarter) place(id, x, y)+// The new upgrade appearances have their own plots, away from working streets.+face([[-20, 32, -0.5], [18, 32, -0.5], [18, 66, -0.5], [-20, 66, -0.5]], 0xf0f2ec, true)+inkAssets.filter(a => a.category === "buildings" && a.reference?.type === "none")+ .forEach((a, i) => place(a.id, -17 + (i % 5) * 7.5, 34 + Math.floor(i / 5) * 6))// The review annex gives seasonal/condition variants their own ground,// keeping them apart from the functioning town streets.face([[-20, 17, -0.5], [18, 17, -0.5], [18, 31, -0.5], [-20, 31, -0.5]], 0xf0f2ec, true)@@ -169,7 +173,7 @@ const people = inkAssets.filter((a) => a.category === "people")people.forEach((a, i) => place(a.id, i < 11 ? -8 + i * 1.4 : -8 + (i - 11), i < 11 ? -2 : 4))inkAssets.filter((a) => a.category === "construction" && a.reference?.type !== "plot" && a.id !== "smoke" && a.id !== "problem-marker")- .forEach((a, i) => place(a.id, 12 + (i % 2) * 3, -11 + Math.floor(i / 2) * 2.1))+ .forEach((a, i) => place(a.id, -17 + (i % 7) * 5, 58 + Math.floor(i / 7) * 5))place("smoke", -2.5, 0.5, 1, true, 56)place("problem-marker", 12, -8.9, 1, true, 35)inkAssets.filter((a) => a.reference?.type === "plot").forEach((a, i) => place(a.id, -12 + (i % 2) * 3, 9.5 + Math.floor(i / 2) * 2.6))@@ -231,6 +235,7 @@ export const districts = {people: { title: "People", x: 0, y: -2, zoom: 7 },cargo: { title: "Cargo yard", x: 7, y: 7, zoom: 4 },forest: { title: "Forest & farms", x: -10, y: -11, zoom: 3.2 },- variants: { title: "Winter & wear", x: -2, y: 21, zoom: 2.3 }+ variants: { title: "Winter & wear", x: -2, y: 21, zoom: 2.3 },+ upgrades: { title: "Upgrades & works", x: -2, y: 37, zoom: 2.3 }} as constexport const testMap = { asset: town, buildings, effects, trees: trees.length + 18, roads: roads.size, coverage: represented.size }diff --git a/src/model-review/handoff.css b/src/model-review/handoff.cssnew file mode 100644index 0000000..d61cf0b--- /dev/null+++ b/src/model-review/handoff.css@@ -0,0 +1,3 @@+.grid.handoff{grid-template-columns:repeat(2,minmax(0,1fr))}+.handoff .model-view{height:330px}+@media(max-width:700px){.grid.handoff{grid-template-columns:1fr}.handoff .model-view{height:290px}}diff --git a/src/model-review/main.ts b/src/model-review/main.tsindex ab15f06..6a2ec2d 100644--- a/src/model-review/main.ts+++ b/src/model-review/main.ts@@ -4,8 +4,12 @@ import { buildAsset, exportAsset } from "../asset-lab/renderer.ts"import { kindIds } from "../content.ts"import { ruralIds } from "../asset-lab/rural.ts"import "./style.css"+import "./handoff.css"const families = {+ milestones: { title: "Civic milestones", ids: ["townhall", "guildhall", "cityhall"] },+ works: { title: "Reusable building works", ids: ["upgrade-works-15", "upgrade-works-50", "upgrade-works-90", "works-carpenter-0", "works-warehouse-0", "works-quarry-0", "works-farm-0", "works-townhall-1", "works-townhall-2"] },+ handoff: { title: "PR #20 · new models", ids: ["carpenter", "guildhall", "cityhall", "depot", "ovenworks", "masonry", "estate", "fire-brigade", "market-hall", "church", "upgrade-works-15", "upgrade-works-50", "upgrade-works-90", "cart-furniture-4"] },town: { title: "All buildings", ids: [...kindIds, "market-hall", "church"] },rural: { title: "Final refinements", ids: ruralIds },trades: { title: "Trade buildings", ids: ["mill", "warehouse", "fishery", "bakery", "weaver", "watchhouse"] },@@ -16,12 +20,15 @@ const families = {homes: { title: "Homes & neighbourhoods", ids: ["cottage", "citizen", "townhouse", "cottage-fine", "citizen-fine", "townhouse-fine", "cottage-poor", "citizen-worn", "townhouse-worn"] },winter: { title: "Winter", ids: ["cottage-winter", "citizen-winter", "townhouse-winter", "granary-winter", "smokehouse-winter", "firewatch-winter", "healer-winter", "hospital-winter", "watchhouse-winter", "builder-winter"] },hazards: { title: "Ruins", ids: ["ruin-burnt-1", "ruin-collapsed-1", "ruin-derelict-1"] },- people: { title: "People & cargo", ids: ["service-watchman", "service-firefighter", "service-physician", "service-constable", "service-builder", "goods-smoked", "cart-smoked-4", "barrow-smoked-4"] },+ people: { title: "People & cargo", ids: ["service-watchman", "service-firefighter", "service-physician", "service-constable", "service-builder", "goods-smoked", "cart-smoked-4", "barrow-smoked-4", "goods-furniture", "cart-furniture-4", "barrow-furniture-4"] },wear: { title: "Building condition", ids: ["granary-worn", "smokehouse-worn", "firewatch-worn", "healer-worn", "hospital-worn", "watchhouse-worn", "builder-worn"] },upgrades: { title: "Upgrades & worked faces", ids: ["market", "market-hall", "chapel", "church", "stone-full", "stone-quarried", "stone-worked", "ore-full", "ore-quarried", "ore-worked"] }} as consttype Family = keyof typeof familiesconst introductions: Partial<Record<Family, { heading: string; eyebrow: string; description: string; aside: string }>> = {+ milestones: { heading: "A town's<br>great occasions.", eyebrow: "Town hall · Guildhall · City hall", description: "A familiar town hall becomes a steep-roofed guild house with a clock tower and balcony, then a domed civic palace with a ceremonial stair, colonnade and lower wings. These three views share one camera scale.", aside: "3 civic milestones<br>Original three-cell plot<br><span>Distinct silhouettes,<br>stonework and civic colour.</span>" },+ works: { heading: "One scaffold.<br>Every workplace.", eyebrow: "Reusable construction geometry", description: "The same modular scaffold on a civic hall, open workshop, warehouse, quarry and farm. Plot size, building height and delivered share are its only inputs. Central bays stay open on every side.", aside: "1 shared generator<br>6 different building forms<br><span>Platforms, access ladders,<br>canvas screens and supplies.</span>" },+ handoff: { heading: "New work.<br>The same ink.", eyebrow: "PR #20 · Carpenter and upgrades", description: "An open carpenter's workshop, civic towers and additions to the town's working yards. Turn the models to inspect their tools and supports, then compare them with the existing building collections.", aside: "1 new workshop<br>9 upgrade appearances<br><span>Plus scaffold progress<br>and furniture deliveries.</span>" },town: { heading: "The whole town.<br>The same ink.", eyebrow: "The complete building collection", description: "Every building kind, plus the market hall and church. Compare their silhouettes, turn the collection, and open any building for a closer look.", aside: `${kindIds.length} building kinds<br>2 upgraded buildings<br><span>Work yards, homes for trades,<br>stores and town services.</span>` },rural: { heading: "Small things.<br>A better town.", eyebrow: "The final building pass", description: "Timber entrances, nursery beds, farm details, a quieter chapel and a connected fire-watch lookout. Inspect all nine refinements together.", aside: "9 refined buildings<br>Original plots<br><span>Connected structures,<br>clear entrances and useful yards.</span>" },workshops: { heading: "Room to work.<br>The same ink.", eyebrow: "The first building batch", description: "Open work yards around real tools, and a civic entrance for the town hall. Turn the models to inspect their working space.", aside: "4 revised buildings<br>3 open work yards<br><span>Original plots, pale surfaces,<br>fine ink and purposeful tools.</span>" },@@ -71,6 +78,7 @@ function select(next: Family) {if (sheetUrl) URL.revokeObjectURL(sheetUrl)sheetUrl = ""; root.querySelector<HTMLAnchorElement>("#sheet-link")!.hidden = truefamily = next; models.forEach(m => m.built.dispose()); models = []; grid.replaceChildren()+ grid.classList.toggle("handoff", family === "handoff")const intro = introductions[family] ?? { heading: "New places.<br>The same ink.", eyebrow: "A town with a little more life", description: "Inspect the models together, turn them around, then open any one for a closer look.", aside: "7 buildings<br>3 park furnishings<br>3 home tiers<br><span>Plus people, hazards, paving,<br>snow and signs of wear.</span>" }root.querySelector(".intro h1")!.innerHTML = intro.headingroot.querySelector(".eyebrow")!.textContent = intro.eyebrow@@ -91,6 +99,11 @@ function select(next: Family) {a.href = url; a.download = `inkline-${id}.glb`; a.click(); setTimeout(() => URL.revokeObjectURL(url), 1000)}}+ if (family === "milestones") {+ const bounds = new THREE.Box3()+ for (const model of models) bounds.union(new THREE.Box3().setFromObject(model.built.group))+ for (const model of models) { bounds.getCenter(model.center); bounds.getSize(model.size) }+ }nav.querySelectorAll("button").forEach(b => { b.setAttribute("aria-pressed", String(b.dataset.family === next)) })history.replaceState(null, "", `?collection=${next}`); render()}@@ -102,7 +115,7 @@ elevation.onchange = () => { pitch = Number(elevation.value); render() }root.querySelector<HTMLButtonElement>("#rear")!.onclick = () => { yaw = yaw === 180 ? 0 : 180; render() }root.querySelector<HTMLButtonElement>("#reset")!.onclick = () => { yaw = 0; pitch = 30; elevation.value = "30"; render() }root.querySelector<HTMLButtonElement>("#sheet")!.onclick = () => {- const canvas = document.createElement("canvas"), ctx = canvas.getContext("2d")!, columns = 3, width = 400, height = 350+ const canvas = document.createElement("canvas"), ctx = canvas.getContext("2d")!, columns = family === "handoff" ? 2 : 3, width = family === "handoff" ? 600 : 400, height = 350canvas.width = columns * width; canvas.height = 100 + Math.ceil(models.length / columns) * heightctx.fillStyle = "#f0f2ec"; ctx.fillRect(0, 0, canvas.width, canvas.height)ctx.fillStyle = "#3d4943"; ctx.font = "30px Georgia"; ctx.fillText(`Inkline Town / ${families[family].title}`, 30, 48)diff --git a/src/render3d/models.ts b/src/render3d/models.tsindex 9737831..13f6c96 100644--- a/src/render3d/models.ts+++ b/src/render3d/models.ts@@ -13,6 +13,8 @@ import { isWorkshop, workshopConstruction } from "../asset-lab/workshops.ts"import { isTradeYard, tradeConstruction } from "../asset-lab/trades.ts"import { serviceBuilding, upgradeHeights, type ServiceKind } from "../asset-lab/service-upgrades.ts"import { dressedBuilding, dressedTop, isDressed, scaffoldAsset } from "../asset-lab/upgrade-dress.ts"+import { carpenterConstruction } from "../asset-lab/carpenter.ts"+import { civicEave } from "../asset-lab/civic.ts"export { scaffoldAsset }export type DoorSet = Record<Side, boolean>@@ -69,7 +71,7 @@ export function constructionAsset(size: number, half: number, height: number, bu}/** The height a building of a kind is drawn to its eaves at its level of upgrades (see `upgradeHeights`). */export const buildingHeight = (id: KindId, level = 0) =>- level > 0 && isUpgradable(id) ? upgradeHeights[id].eave : buildingDimensions(id).height+ level > 0 && id === "townhall" ? civicEave(level) : level > 0 && isUpgradable(id) ? upgradeHeights[id].eave : buildingDimensions(id).height/** Its highest point, for the marker over it. */export const buildingTop = (id: KindId, level = 0) =>level > 0 && isUpgradable(id) ? upgradeHeights[id].top : level > 0 && isDressed(id) ? Math.max(buildingDimensions(id).top, dressedTop(id, level, buildingDimensions(id).height)) : buildingDimensions(id).top@@ -82,14 +84,15 @@ export function buildingAsset(id: KindId, build: number, share: number | null, dif (build < 0.78) return isWorkshop(id)? workshopConstruction(id, build, share, doors): isTradeYard(id) ? tradeConstruction(id, build, share, doors)- : constructionAsset(kind.size, kind.half, kind.roof === "gable" ? 20 : kind.stories * 32, build, share)- // An upgraded building is only ever a standing one: the upgrade is paid and done at once.+ : id === "carpenter" ? carpenterConstruction(build, share, doors)+ : constructionAsset(kind.size, kind.half, buildingDimensions(id).height, build, share)+ // Completed upgrades use their final model; works are drawn separately.if (upgraded && isUpgradable(id)) return withAppearance(serviceBuilding(id, 2, { plate: false, doors }), kind.half * U, buildingHeight(id, level), appearance)const dimensions = buildingDimensions(id)const own = makeBuilding(id, { doors, open, fit: stage.fit, plate: false, motion: false } satisfies BuildingOptions)// Any other upgrade is the building's own model with what the upgrade adds drawn on (see `upgrade-dress.ts`).- const asset = upgraded && isDressed(id) && build >= 1 ? dressedBuilding(id, level, own, dimensions.height) : own- return build >= 1 ? withAppearance(asset, dimensions.half, dimensions.height, appearance) : asset+ const asset = upgraded && isDressed(id) && build >= 1 ? dressedBuilding(id, level, own, dimensions.height, doors) : own+ return build >= 1 ? withAppearance(asset, dimensions.half, buildingHeight(id, level), appearance) : asset}export function homeAsset(tier: Tier, n: number, build: number, share: number | null, doors: DoorSet, appearance: Appearance = {}) {if (build < 0.78) return constructionAsset(1, home.half + (tier >= 2 ? 1 : 0), home.tiers[tier].height, build, share)diff --git a/src/render3d/views.ts b/src/render3d/views.tsindex c7fe8b8..690a323 100644--- a/src/render3d/views.ts+++ b/src/render3d/views.ts@@ -136,7 +136,7 @@ export class BuildingView extends WorldView {const works = look.works ?? nullthis.scaffold.root.visible = works !== null && build >= 1if (works !== null && build >= 1) {- const step = Math.round(works * 6) / 6, height = buildingHeight(this.kindId, level)+ const step = Math.round(works * 24) / 24, height = buildingHeight(this.kindId, level)this.scaffold.use(`scaffold/${kind.size}/${height}/${step}`, () => scaffoldAsset(kind.size, height, step))}this.plate.use(`plate/${kind.size}/${build}`, () => plateAsset(kind.size, build))@@ -164,7 +164,7 @@ export class BuildingView extends WorldView {this.effects?.set(build>=1?state:surfaceState());this.effects?.update(performance.now()/1000)this.shade = 0xffffff// The market hall has no flag of its own: the flag stays on the tier 1 market.- this.motion.root.visible = look.build >= 1 && !serviceModel && (kind.topper === "flag" || kind.topper === "sails")+ this.motion.root.visible = look.build >= 1 && !serviceModel && !(upgraded && this.kindId === "townhall") && (kind.topper === "flag" || kind.topper === "sails")if (kind.topper === "flag") {this.wave += dt * (look.working ? 6 : 3)this.motion.use("flag/" + this.kindId, () => makeFlag(this.kindId))diff --git a/test/render3d.test.ts b/test/render3d.test.tsindex 26e6690..55cae9d 100644--- a/test/render3d.test.ts+++ b/test/render3d.test.ts@@ -11,6 +11,7 @@ import { ModelHandle, ModelPool } from "../src/render3d/pool.ts"import { assetById } from "../src/asset-lab/assets.ts"import { surfaceState, hazardStrength } from "../src/render3d/surface-state.ts"import { StructureEffects } from "../src/render3d/structure-effects.ts"+import { vertex3 } from "../src/asset-lab/renderer.ts"function valid(asset: InkAsset) {for (const face of asset.faces) {@@ -46,13 +47,13 @@ test("live service upgrades retain their taller models and material bounds besidassert.equal(upgraded.effects?.height, upgradeHeights[id].eave)assert.equal(upgraded.effects?.state.snow, 1)}- for (const [id, height] of [["bakery", 28], ["weaver", 30], ["fishery", 20]] as const)+ for (const [id, height] of [["bakery", 28], ["weaver", 30], ["fishery", 20], ["carpenter", 28]] as const)assert.equal(buildingHeight(id), height, `${id}: public height must follow the revised model`)})-test("every other upgrade keeps its building's own model, adds to it inside its plot, and stands taller", () => {- for (const id of dressed) for (const level of id === "townhall" ? [1, 2] : [1]) {- const doors = { ...noDoors, right: true }+test("workplace and civic upgrades stay inside their plots in every orientation and retain marker clearance", () => {+ for (const id of dressed) for (const level of id === "townhall" ? [1, 2] : [1]) for (const side of Object.keys(noDoors)) {+ const doors = { ...noDoors, [side]: true }const base = buildingAsset(id, 1, null, doors, 1), up = buildingAsset(id, 1, null, doors, 1, {}, level)valid(up)const plot = kinds[id].size * 8 * U + 1e-9@@ -60,6 +61,54 @@ test("every other upgrade keeps its building's own model, adds to it inside itsassert.ok(reach(up) <= plot, `${id}/${level}: the upgrade reaches past its plot (${reach(up)} > ${plot})`)assert.ok(up.faces.length + up.strokes.length > base.faces.length + base.strokes.length, `${id}/${level}: nothing is added`)assert.ok(buildingTop(id, level) >= buildingTop(id, 0), `${id}/${level}: its marker sinks`)+ const actualTop = Math.max(...up.faces.flatMap(f => f.points.map(p => p[2])), ...up.strokes.flatMap(s => s.points.map(p => p[2])))+ assert.ok(buildingTop(id, level) + 0.1 >= actualTop, `${id}/${level}: marker bounds miss geometry (${actualTop})`)+ }+})++test("civic milestones have progressively taller silhouettes, road-facing entrances and correct surface bounds", () => {+ let previous=buildingTop("townhall")+ for(const level of [1,2]) {+ assert.ok(buildingTop("townhall",level)>previous+5,"Each civic milestone must change the skyline")+ previous=buildingTop("townhall",level)+ for(const side of Object.keys(noDoors)) {+ const asset=buildingAsset("townhall",1,null,{...noDoors,[side]:true},1,{winter:true},level)+ const door=asset.faces.find(f=>f.color===0xbda683)!+ assert.ok(door,"A civic milestone needs a visible entrance")+ const u=door.points.reduce((n,p)=>n+p[0],0)/door.points.length,v=door.points.reduce((n,p)=>n+p[1],0)/door.points.length+ assert.equal(Math.abs(u)>Math.abs(v)?u>0?"right":"backRight":v>0?"left":"backLeft",side)+ assert.equal(asset.effects?.height,buildingHeight("townhall",level))+ assert.equal(asset.effects?.state.snow,1)+ }+ }+})++test("guildhall clock faces are circular in world space on every tower wall", () => {+ for (const side of Object.keys(noDoors)) {+ const asset=buildingAsset("townhall",1,null,{...noDoors,[side]:true},1,{},1)+ const clocks=asset.faces.filter(face=>face.color===0xf7f5e9)+ assert.equal(clocks.length,4)+ for (const face of clocks) {+ const points=face.points.slice(0,-1).map(vertex3)+ const center=points.reduce((sum,p)=>sum.add(p),new THREE.Vector3()).divideScalar(points.length)+ const radius=points[0]!.distanceTo(center)+ assert.ok(points.every(p=>Math.abs(p.distanceTo(center)-radius)<1e-8),`${side}: squashed clock face`)+ }+ }+})++test("the same scaffold fits every building footprint and leaves all four central approaches clear", () => {+ for(const id of kindIds)for(const share of [0,.15,.5,.9,1]) {+ const size=kinds[id].size,asset=scaffoldAsset(size,buildingHeight(id),share),half=size/2+ valid(asset)+ assert.ok([...asset.faces,...asset.strokes].flatMap(p=>p.points).every(p=>Math.abs(p[0])<=half&&Math.abs(p[1])<=half),id)+ for(const [u,v,du,dv]of [[0,half+.1,0,-1],[half+.1,0,-1,0],[0,-half-.1,0,1],[-half-.1,0,1,0]]) {+ const origin=new THREE.Vector3(u,v,6),ray=new THREE.Ray(origin,new THREE.Vector3(du,dv,0))+ for(const f of asset.faces)for(let i=1;i<f.points.length-1;i++) {+ const hit=ray.intersectTriangle(new THREE.Vector3(...f.points[0]!),new THREE.Vector3(...f.points[i]!),new THREE.Vector3(...f.points[i+1]!),false,new THREE.Vector3())+ assert.ok(!hit||hit.distanceTo(origin)>.6,`${id}/${share}: scaffold blocks a central entrance`)+ }+ }}})