A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Refine park models and add before-after park review
SandroMaglione6bf603a0e545
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.mdindex ce36dae..53d5b3e 100644--- a/DEVELOPMENT.md+++ b/DEVELOPMENT.md@@ -263,9 +263,18 @@ The original 2D menu drawings remain in `art.ts` for comparison. The live3D town uses the new geometry, including equipped service workers and curedfish cargo. The game has no audio, so winter music is outside this model work.+Open `/proportion-review.html?collection=parks` for twelve park before/after+comparisons. The original geometry and walker are frozen in+`public/model-review/parks-before.json.gz` at `f4df9d5`; do not regenerate it+from the revised models. `pnpm check:park-models` checks the paired viewer and+captures front, rear and phone views in `output/inkline-3d/parks/`.+Shared furnishings live in `park-furnishings.ts`, and park ground treatments+in `park-ground.ts`. The bench and planted border also serve civic gardens;+road setts and the park simulation rules are unchanged.+Open `/park-lab.html` for a park assembled from 25 cells using the currentpark layout system, with two street entrances. The three retained furnishings-are lamps, fountains and statues. The statue is a simple bust and pedestal;+are framed lanterns, tiered fountains and simple stone busts;`render3d/fountain-effects.ts` supplies moving droplets and impact ripples inthe actual basin. Park rendering in the game, catalogue, map and preview sharesthe same emitter metadata and water renderer. `pnpm check:park` verifies thediff --git a/README.md b/README.mdindex 5dae581..c3a6762 100644--- a/README.md+++ b/README.md@@ -134,6 +134,10 @@ The complete proportion comparison is at `/proportion-review.html`: 36 buildingappearances and nine shared-prop examples, with the approved originals besidethe revised geometry. Both sides share a camera and an unchanged walker.Turn, zoom, choose one scale across the catalogue, or save a comparison PNG.+The park comparison is at `/proportion-review.html?collection=parks`: twelve+before/after views cover furnishings, planting, paths, paving and the assembled+park. The same walker and camera appear on both sides. `/park-lab.html` shows+the revised park with running water.Run `pnpm dev`, then open `/model-review.html?collection=handoff` to turn the models, comparescaffolding as materials arrive, and download their GLBs.diff --git a/package.json b/package.jsonindex 8396b17..d35df21 100644--- a/package.json+++ b/package.json@@ -21,6 +21,7 @@"check:effects": "node scripts/check-house-effects.ts","check:revisions": "node scripts/check-model-revisions.ts","check:park": "node scripts/check-park.ts",+ "check:park-models": "node scripts/check-park-models.ts","look:upgrades": "node scripts/look-upgrades.ts","look:ui": "node scripts/look-ui.ts","test": "node --test \"test/*.test.ts\"",diff --git a/public/model-review/parks-before.json.gz b/public/model-review/parks-before.json.gznew file mode 100644index 0000000..fc8a514Binary files /dev/null and b/public/model-review/parks-before.json.gz differdiff --git a/scripts/check-park-models.ts b/scripts/check-park-models.tsnew file mode 100644index 0000000..d4d2b55--- /dev/null+++ b/scripts/check-park-models.ts@@ -0,0 +1,56 @@+/** Isolated screenshot review, following the repository's check:park workflow. */+import assert from "node:assert/strict"+import { existsSync } from "node:fs"+import { mkdir, writeFile } from "node:fs/promises"+import { chromium } from "playwright"++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}:{})})+const page=await browser.newPage({viewport:{width:1440,height:1100},deviceScaleFactor:1}),errors:string[]=[]+page.on("pageerror",e=>errors.push(e.message));page.on("console",e=>{if(e.type()==="error")errors.push(e.text())})+const output="output/inkline-3d/parks"+await mkdir(output,{recursive:true})+try{+ await page.goto(`${process.env.GAME_BASE_URL??"http://127.0.0.1:5236"}/proportion-review.html?collection=parks`)+ await page.waitForFunction(()=>Boolean((window as any).proportionReview))+ const ids:string[]=await page.evaluate(()=>(window as any).proportionReview.ids)+ assert.equal(ids.length,12)+ assert.match(await page.locator(".footer").innerText(),/f4df9d5/)+ const manifest:Array<{id:string;title:string;note:string;file:string}>=[]+ for(const id of ids){+ await page.getByLabel("Choose model",{exact:true}).selectOption(id)+ assert.equal(await page.evaluate(()=>(window as any).proportionReview.stats().pairs),2)+ const file=`${id}.png`+ await page.locator(".view").screenshot({path:`${output}/${file}`})+ manifest.push({id,title:await page.locator("h2").innerText(),note:await page.locator("#note").innerText(),file})+ await page.getByLabel("Model rotation",{exact:true}).fill("180")+ assert.equal(await page.evaluate(()=>(window as any).proportionReview.stats().yaw),180)+ await page.locator(".view").screenshot({path:`${output}/${id}-rear.png`})+ await page.getByRole("button",{name:"Reset view",exact:true}).click()+ }+ await page.getByLabel("Choose model",{exact:true}).selectOption("park-built")+ await page.getByLabel("View elevation",{exact:true}).selectOption("50")+ await page.locator(".view").screenshot({path:`${output}/park-built-above.png`})+ await page.getByRole("button",{name:"Reset view",exact:true}).click()+ const downloadEvent=page.waitForEvent("download")+ await page.getByRole("button",{name:"Save comparison",exact:true}).click()+ const download=await downloadEvent+ assert.equal(download.suggestedFilename(),"inkline-park-built-before-after.png")+ await download.saveAs(`${output}/download.png`)+ await page.getByLabel("Model group",{exact:true}).selectOption("architecture")+ assert.equal(await page.getByLabel("Choose model",{exact:true}).locator("option").count(),5)+ await page.getByLabel("Find a model",{exact:true}).fill("fountain")+ assert.equal(await page.getByLabel("Choose model",{exact:true}).locator("option").count(),1)+ await page.reload();await page.waitForFunction(()=>Boolean((window as any).proportionReview))+ assert.equal(await page.getByLabel("Choose model",{exact:true}).inputValue(),"park-fountain")+ assert.equal(new URL(page.url()).searchParams.get("collection"),"parks")+ await page.setViewportSize({width:390,height:844})+ for(const id of ["park-lamp","park-statue","park-fountain","park-built"]){+ await page.getByLabel("Choose model",{exact:true}).selectOption(id)+ assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true,`${id}: phone overflow`)+ await page.locator(".view").screenshot({path:`${output}/${id}-phone.png`})+ }+ await writeFile(`${output}/manifest.json`,JSON.stringify(manifest,null,2))+ assert.deepEqual(errors,[])+ console.log(`Verified ${ids.length} park pairs, both sides, rotation, filtering, deep links, download and phone layout; no browser errors`)+}finally{await browser.close()}diff --git a/scripts/snapshot-parks.ts b/scripts/snapshot-parks.tsnew file mode 100644index 0000000..05ff4dd--- /dev/null+++ b/scripts/snapshot-parks.ts@@ -0,0 +1,14 @@+/** Record the approved park geometry before rebuilding the furnishings. */+import { gzipSync } from "node:zlib"+import { mkdir, writeFile } from "node:fs/promises"+import { execFileSync } from "node:child_process"+import { parkReviewModels } from "../src/model-review/park-models.ts"+import { assetById } from "../src/asset-lab/assets.ts"++const revision=execFileSync("git",["rev-parse","HEAD"],{encoding:"utf8"}).trim()+if(revision!=="f4df9d5f9e1ff74552e5a29a3366ec9f541bb3bd")throw new Error("Capture parks from the approved proportion revision")+const data={revision,models:parkReviewModels(),walker:assetById.get("settler-cap")!}+await mkdir("public/model-review",{recursive:true})+const bytes=gzipSync(JSON.stringify(data),{level:9})+await writeFile("public/model-review/parks-before.json.gz",bytes,{flag:"wx"})+console.log(`Frozen ${data.models.length} park examples: ${Math.round(bytes.length/1024)} KB`)diff --git a/src/asset-lab/park-furnishings.ts b/src/asset-lab/park-furnishings.tsnew file mode 100644index 0000000..7edfb87--- /dev/null+++ b/src/asset-lab/park-furnishings.ts@@ -0,0 +1,144 @@+import { U } from "../iso.ts"+import { Drawing, mix, type Vertex } from "./primitives.ts"+import { beam, block, iron, stone, wood } from "./workshops.ts"+import { human } from "./dimensions.ts"++const brass=[0xd7c99d,0xb6a779,0x8f8461] as const+const carved=[0xe7e9df,0xcbd2c5,0xaeb9ac] as const++/** A closed turned profile, including hollow bowls. Rims are drawn separately;+ * the curved body gets a continuous silhouette instead of a wire cage. */+function turned(d:Drawing,u:number,v:number,profile:ReadonlyArray<readonly[number,number]>,colors:readonly[number,number,number]=stone,n=32,width=.55){+ const first=d.asset.faces.length+ const p=(i:number,r:number,z:number):Vertex=>[u+Math.cos(i*Math.PI*2/n)*r*U,v+Math.sin(i*Math.PI*2/n)*r*U,z]+ for(let j=0;j<profile.length-1;j++){+ const [r,z]=profile[j]!,[next,h]=profile[j+1]!+ for(let i=0;i<n;i++){+ const light=.3+.6*Math.max(0,Math.cos((i+.5)*Math.PI*2/n-2.3))+ const color=z===h?colors[0]:mix(colors[2],colors[0],light)+ d.face(r===0?[p(i,0,z),p(i,next,h),p(i+1,next,h)]:next===0?[p(i,r,z),p(i+1,r,z),p(i,0,h)]:[p(i,r,z),p(i+1,r,z),p(i+1,next,h),p(i,next,h)],color,0)+ }+ }+ if(width>0)d.volume(first,width)+}+const rim=(d:Drawing,u:number,v:number,r:number,z:number,width=.5,color=0x687466)=>d.line(Array.from({length:33},(_,i):Vertex=>[u+Math.cos(i*Math.PI/16)*r*U,v+Math.sin(i*Math.PI/16)*r*U,z]),width,color)++export function parkBench(d:Drawing,u:number,v:number){+ // Two braced cast-iron frames support the seat and sloping back.+ for(const x of [-2.65,2.65]){+ for(const y of [-.8,.85]){+ block(d,u+x*U,v+y*U,.22*U,.35*U,0,.35,iron,.4)+ beam(d,[u+x*U,v+y*U,.35],[u+x*U,v+y*.7*U,human.seat],.65,iron)+ }+ beam(d,[u+x*U,v-1.1*U,4.2],[u+x*U,v+1.2*U,4.2],.7,iron)+ beam(d,[u+x*U,v-.7*U,3.5],[u+x*U,v-1.65*U,9.7],.6,iron)+ // Armrest has a supported rise and a small, gently curved top.+ const arm:Vertex[]=[[u+x*U,v+1.05*U,4.7],[u+x*U,v+1.05*U,6.5],[u+x*U,v+.7*U,6.9],[u+x*U,v-1.2*U,6.9]]+ for(let i=0;i<arm.length-1;i++)beam(d,arm[i]!,arm[i+1]!,.55,iron)+ }+ beam(d,[u-2.65*U,v,2],[u+2.65*U,v,2],.65,iron)+ for(const y of [-.9,-.3,.3,.9]){+ block(d,u,v+y*U,3.5*U,.25*U,human.seat,.65,wood,.45)+ for(const x of [-2.65,2.65])d.cylinder(u+x*U,v+y*U,.065*U,5.16,.08,iron[1],iron[0],0,6)+ }+ for(const z of [6.3,7.7,9.1]){+ const back=-1.1-(z-5)*.12+ block(d,u,v+back*U,3.5*U,.16*U,z,.7,wood,.45)+ for(const x of [-2.65,2.65])block(d,u+x*U,v+(back+.17)*U,.06*U,.035*U,z+.25,.15,iron,.15)+ }+}++export function leaf(d:Drawing,u:number,v:number,z:number,angle:number,length=1.2){+ const dx=Math.cos(angle)*length*U,dy=Math.sin(angle)*length*U+ const a:Vertex=[u,v,z],tip:Vertex=[u+dx,v+dy,z+.7],mid:Vertex=[u+dx*.55,v+dy*.55,z+.65]+ d.face([a,[mid[0]-dy*.28,mid[1]+dx*.28,z+.25],tip,mid],0xa8c195,0)+ d.face([a,mid,tip,[mid[0]+dy*.28,mid[1]-dx*.28,z+.25]],0x829e76,0)+}+export function blossom(d:Drawing,u:number,v:number,z:number,color:number,angle=0){+ const h=2.3+(Math.sin(angle*3)+1)*.35+ d.line([[u,v,z],[u,v,z+h]],.35,0x809e70)+ leaf(d,u,v,z+.4,angle,1.1);leaf(d,u,v,z+1,angle+2.5,.8)+ for(let i=0;i<5;i++){+ const a=angle+i*Math.PI*2/5+ d.ellipsoid(u+Math.cos(a)*.42*U,v+Math.sin(a)*.42*U,z+h,.38*U,.38*U,.25,color,0,undefined,6)+ }+ d.ellipsoid(u,v,z+h+.12,.22*U,.22*U,.2,0xd6b66b,0,undefined,6)+}+export function plantedBorder(d:Drawing,u:number,v:number,width=3,color=0xc78374){+ block(d,u,v,width*U,1.3*U,0,.65,[0xa79d84,0xa79d84,0x958b76],0)+ for(const y of [-1.3,1.3])block(d,u,v+y*U,(width+.25)*U,.22*U,0,1.1,stone,.4)+ for(const x of [-width,width])block(d,u+x*U,v,.25*U,1.3*U,0,1.1,stone,.4)+ for(let i=-1;i<=1;i++){+ const x=u+i*width*.62*U+ blossom(d,x,v+Math.sin(i*2)*.3*U,.65,color,i*1.7+1)+ leaf(d,x,v,.7,i+3,1.2)+ }+}++export function parkLamp(d:Drawing,u:number,v:number){+ block(d,u,v,1.25*U,1.25*U,0,.6,stone,.5)+ turned(d,u,v,[[0,.6],[.9,.6],[.9,1],[.65,1.3],[.58,3],[.38,3.5],[.3,5],[.24,21.5],[.48,22],[.48,22.6],[0,22.6]],iron,16,.45)+ for(const x of [-.85,.85])for(const y of [-.85,.85])d.cylinder(u+x*U,v+y*U,.1*U,.6,.2,iron[2],brass[1],0,6)+ // Fluted sleeve, collar and four glass panes beneath a solid weather cap.+ for(let i=0;i<8;i++){+ const t=i*Math.PI/4+ beam(d,[u+Math.cos(t)*.58*U,v+Math.sin(t)*.58*U,1.3],[u+Math.cos(t)*.38*U,v+Math.sin(t)*.38*U,3.5],.18,iron)+ }+ block(d,u,v,1.25*U,1.25*U,22.6,.5,iron,.45)+ const bottom=1.03*U,top=1.38*U,z=23.1,H=28.7+ const ring=(a:number,h:number):Vertex[]=>[[u-a,v-a,h],[u+a,v-a,h],[u+a,v+a,h],[u-a,v+a,h]]+ const lower=ring(bottom,z),upper=ring(top,H)+ for(let i=0;i<4;i++){+ const j=(i+1)%4+ d.face([lower[i]!,lower[j]!,upper[j]!,upper[i]!],i<2?0xe5dbb3:0xf3ebcc,0)+ beam(d,lower[i]!,upper[i]!,.4,iron)+ beam(d,upper[i]!,upper[j]!,.45,iron)+ const a=lower[i]!,b=lower[j]!,c=upper[i]!,e=upper[j]!+ d.line([[(a[0]+b[0])/2,(a[1]+b[1])/2,z],[(c[0]+e[0])/2,(c[1]+e[1])/2,H]],.3,0x7a8473)+ }+ block(d,u,v,.33*U,.33*U,23.1,1.6,brass,.25)+ d.ellipsoid(u,v,25.2,.3*U,.3*U,.9,0xf9f0cf,0,undefined,10)+ const eave=ring(1.7*U,29),peak:Vertex=[u,v,31.2]+ for(let i=0;i<4;i++)d.face([eave[i]!,eave[(i+1)%4]!,peak],iron[i%3]!,0)+ d.line([...eave,eave[0]!],.5)+ d.ellipsoid(u,v,31.5,.23*U,.23*U,.5,brass[1],.3,undefined,10)+}++export function founderStatue(d:Drawing,u:number,v:number){+ // A quiet civic bust: the interest comes from its proportions and planes.+ for(const [half,z,h] of [[4,0,.7],[3.5,.7,.6],[2.65,1.3,7.2],[3.05,8.5,.65]])block(d,u,v,half!*U,half!*U,z!,h!,stone,.55)+ block(d,u,v,1.65*U,1.05*U,9.15,.6,carved,.4)+ const first=d.asset.faces.length,n=8+ const ring=(width:number,depth:number,h:number)=>Array.from({length:n},(_,i):Vertex=>[u+Math.cos(i*Math.PI*2/n)*width*U,v+Math.sin(i*Math.PI*2/n)*depth*U,h])+ const rings=[ring(1.35,.75,9.75),ring(2.85,1.1,14.6),ring(2.55,1.05,16),ring(.65,.6,17.3)]+ for(let j=0;j<rings.length-1;j++)for(let i=0;i<n;i++){+ const next=(i+1)%n+ const color=mix(carved[2],carved[0],.3+.6*Math.max(0,Math.cos((i+.5)*Math.PI*2/n-2.3)))+ d.face([rings[j]![i]!,rings[j]![next]!,rings[j+1]![next]!,rings[j+1]![i]!],color,0)+ }+ d.face([...rings[0]!].reverse(),carved[1],0);d.face(rings.at(-1)!,carved[0],0);d.volume(first,.55)+ d.cylinder(u,v,.55*U,17.3,1.25,carved[1],carved[0],0,12)+ d.ellipsoid(u,v,20.5,1.05*U,.9*U,2.35,carved[1],.55,carved[0],12)+}++export function parkFountain(d:Drawing,u:number,v:number){+ // Concave bowls use explicit rings: the renderer's convex silhouette hull+ // would cover their open interiors with ink.+ turned(d,u,v,[[0,0],[6.3,0],[6.3,.55],[6.6,.75],[6.6,1.2],[6.1,1.5],[6.05,4],[6.4,4.35],[6.4,4.9],[5.25,4.9],[5.1,4.35],[4.95,1.65],[0,1.65]],stone,32,0)+ rim(d,u,v,6.6,1.2,.5);rim(d,u,v,6.4,4.9,.6);rim(d,u,v,5.25,4.9,.5)+ // Coping joints cross the actual rim, without outlining every curved panel.+ for(let i=0;i<16;i++){+ const t=i*Math.PI/8,c=Math.cos(t),s=Math.sin(t)+ d.line([[u+c*5.25*U,v+s*5.25*U,4.92],[u+c*6.4*U,v+s*6.4*U,4.92]],.35,0x9eaa9b)+ }+ d.cylinder(u,v,5.02*U,2.8,.12,0xb6ced1,0xd2e2df,0,32)+ turned(d,u,v,[[0,1.65],[1.8,1.65],[1.8,2.2],[1.25,2.6],[.8,3.2],[.65,7.7],[1.1,8.1],[1.1,8.6],[0,8.6]],carved,24,.5)+ for(let i=0;i<8;i++){+ const t=i*Math.PI/4+ beam(d,[u+Math.cos(t)*.72*U,v+Math.sin(t)*.72*U,3.3],[u+Math.cos(t)*.62*U,v+Math.sin(t)*.62*U,7.6],.18,carved)+ }+ turned(d,u,v,[[0,8.4],[1,8.4],[1.4,9],[2.15,9.7],[2.5,10.5],[2.5,11],[2.18,11],[1.95,10.35],[.8,9.6],[0,9.6]],stone,32,0)+ rim(d,u,v,2.5,11,.5);rim(d,u,v,2.18,11,.4)+ turned(d,u,v,[[0,9.5],[.5,9.5],[.5,11.8],[.75,12.1],[.75,12.5],[.3,13],[0,13]],brass,16,.35)+ ;(d.asset.fountains??=[]).push({origin:[u,v,0],radius:5.02*U,level:2.8,nozzle:13})+}diff --git a/src/asset-lab/park-ground.ts b/src/asset-lab/park-ground.tsnew file mode 100644index 0000000..efa0a0d--- /dev/null+++ b/src/asset-lab/park-ground.ts@@ -0,0 +1,77 @@+import { Drawing, square, type Vertex } from "./primitives.ts"+import { hash } from "./land.ts"+import { block, stone } from "./workshops.ts"+import { blossom, leaf } from "./park-furnishings.ts"++export function parkPaving(d:Drawing,u:number,v:number,z:number){+ d.face(square(u,v,.5,z),0xc7cdbf,0)+ const px=.25,py=.2+ for(let row=Math.floor((v-.5)/py);row<Math.ceil((v+.5)/py);row++){+ const shift=Math.abs(row%2)*px/2+ for(let col=Math.floor((u-.5-shift)/px);col<Math.ceil((u+.5-shift)/px);col++){+ const l=Math.max(u-.5,col*px+shift),r=Math.min(u+.5,(col+1)*px+shift),b=Math.max(v-.5,row*py),t=Math.min(v+.5,(row+1)*py)+ if(r-l<.025||t-b<.025)continue+ const h=hash(col,row),top=h<.25?0xdce1d4:h<.65?0xe6e8dd:0xeeeede+ d.box((l+r)/2,(b+t)/2,(r-l)/2-.004,(t-b)/2-.004,z,.3,top,0xc5cdbd,0xb8c3b4,.3,0x9aa895)+ if(h<.18)d.line([[l+.025,b+.035,z+.31],[l+.055,b+.035,z+.31]],.22,0xb8c1ad)+ }+ }+}++export function turf(d:Drawing,u:number,v:number,z:number,x:number,y:number){+ for(let i=0;i<5;i++){+ const a=u-.4+hash(x*7+i,y*3)*.8,b=v-.4+hash(y*5+i,x*2)*.8+ for(let j=0;j<3;j++){+ const theta=j*2.1+i,h=.55+hash(x+i,y+j)*.65,dx=Math.cos(theta)*.025,dy=Math.sin(theta)*.025+ d.face([[a-dy*.3,b+dx*.3,z+.02],[a+dx*.35,b+dy*.35,z+h],[a+dy*.3,b-dx*.3,z+.02]],j%2?0xa8bf94:0xb6cba2,0)+ }+ }+}++export function flowerPlot(d:Drawing,u:number,v:number,z:number,x:number,y:number){+ block(d,u,v,.32,.32,z,.55,[0xb5aa8d,0xb5aa8d,0x9a947e],0)+ for(const side of [-1,1]){+ block(d,u,v+side*.33,.35,.018,z,1.05,stone,.4)+ block(d,u+side*.33,v,.018,.33,z,1.05,stone,.4)+ for(const offset of [-.17,.17])d.line([[u+offset,v+side*.313,z+1.06],[u+offset,v+side*.348,z+1.06]],.3,0x9ca88f)+ }+ const colors=[0xc78374,0xd2b871,0xb49bc0,0xd6a1a1]+ for(let i=0;i<7;i++){+ const t=i*2.4,r=i===0?0:.14+hash(x+i,y)*.09+ const a=u+Math.cos(t)*r,b=v+Math.sin(t)*r+ const color=colors[Math.floor(hash(x*3+i,y*2)*colors.length)]!+ for(let j=0;j<5;j++)leaf(d,a,b,z+.6,t+j*Math.PI*2/5,1.3)+ for(let j=0;j<3;j++){+ const angle=t+j*Math.PI*2/3+ blossom(d,a+Math.cos(angle)*.037,b+Math.sin(angle)*.037,z+.55,color,angle)+ }+ }+}++/** Edged gravel follows existing path connections. The entrance remains open. */+export function gravelWalk(d:Drawing,u:number,v:number,z:number,joins:ReadonlyArray<{dx:number;dy:number;end:number}>,x:number,y:number){+ const w=.2,gravel=0xe7dfcb+ d.face(square(u,v,w,z+.03),gravel,0)+ for(const {dx,dy,end} of joins){+ const q=(along:number,across:number,h=z+.04):Vertex=>[u+dx*along-dy*across,v+dy*along+dx*across,h]+ if(end>0){+ d.face([q(w,-w),q(end,-w),q(end,w),q(w,w)],gravel,0)+ for(const side of [-1,1]){+ const c=q((w+end)/2,side*(w+.013))+ block(d,c[0],c[1],dx?(end-w)/2:.013,dy?(end-w)/2:.013,z,.55,stone,.3)+ for(let t=w+.13;t<end;t+=.16)d.line([q(t,side*w,z+.56),q(t,side*(w+.026),z+.56)],.25,0x9caa91)+ }+ }else{+ const c=q(w+.013,0)+ block(d,c[0],c[1],dx?.013:w+.026,dy?.013:w+.026,z,.55,stone,.3)+ }+ }+ // Small gravel grains sit on the walking surface, including joined arms.+ for(let i=0;i<15;i++){+ const a=-.46+hash(x*11+i,y*3)*.92,b=-.46+hash(y*7+i,x*2)*.92+ const center=Math.abs(a)<w-.02&&Math.abs(b)<w-.02+ const arm=joins.some(j=>j.end>0&&a*j.dx+b*j.dy>0&&a*j.dx+b*j.dy<j.end-.02&&Math.abs(-a*j.dy+b*j.dx)<w-.03)+ if(!center&&!arm)continue+ d.box(u+a,v+b,.007,.011,z+.04,.13,i%3?0xd3c9b0:0xf0eadb,0xbdb49f,0xb2aa95,0)+ }+}diff --git a/src/asset-lab/town-props.ts b/src/asset-lab/town-props.tsindex a1a64c2..18f3cda 100644--- a/src/asset-lab/town-props.ts+++ b/src/asset-lab/town-props.ts@@ -9,27 +9,13 @@ import { props, type GroundId, type PropId } from "../content.ts"import { cellOf, DIRS, key } from "../grid.ts"import { U } from "../iso.ts"import { hash } from "./land.ts"-import { human } from "./dimensions.ts"-import { Drawing, palette, square, type Vertex } from "./primitives.ts"+import { founderStatue, parkBench, parkFountain, parkLamp, plantedBorder } from "./park-furnishings.ts"+import { flowerPlot, gravelWalk, parkPaving, turf } from "./park-ground.ts"+import { Drawing, square, type Vertex } from "./primitives.ts"-const green = 0xd8e6c9-const leaves = 0xa9c79a-const stone = 0xe4e6e0-const water = 0xc9dde6--export function flowerBed(d: Drawing, u: number, v: number, width = 3, color = 0xc78374) {- d.box(u, v, width * U, 1.2 * U, 0, 2, 0xbac9a4, 0xe4d7bd, 0xd0c2a8, 1)- for (let i = -1; i <= 1; i++) {- const x = u + i * width * U * 0.65- d.ellipsoid(x, v, 3, U, U, 1.2, leaves, 0, undefined, 8)- d.ellipsoid(x, v, 4.2, 0.6 * U, 0.6 * U, 0.7, color, 0.5, undefined, 8)- }-}-export function bench(d: Drawing, u: number, v: number) {- for (const x of [-2.5, 2.5]) d.box(u + x * U, v, 0.4 * U, 1.2 * U, 0, human.seat, palette.ink, palette.ink, palette.ink, 0.75)- for (const y of [-0.7, 0.7]) d.box(u, v + y * U, 3.5 * U, 0.55 * U, human.seat, .65, 0xe9d2a8, 0xd0b58c, 0xb08a5e, 0.75)- for (const z of [7, 9]) d.box(u, v - 1.3 * U, 3.5 * U, 0.35 * U, z, .65, 0xe9d2a8, 0xd0b58c, 0xb08a5e, 0.75)-}+/** Shared seating and planted borders also serve the healer and hospital. */+export const flowerBed = plantedBorder+export const bench = parkBench/** Raised staggered setts share a pitch across neighbouring road cells. */export function setts(d: Drawing, x: number, y: number, half: number, z: number) {const pitch = 0.125@@ -45,58 +31,15 @@ export function setts(d: Drawing, x: number, y: number, half: number, z: number)}}-const figure = (d: Drawing, u: number, v: number) => {- d.box(u, v, 2.4 * U, 2.4 * U, 1.5, 6.5, stone, 0xd5d9d0, 0xbec5bb, 1)- const ring=(width:number,depth:number,z:number):Vertex[]=>[[u-width,v-depth,z],[u+width,v-depth,z],[u+width,v+depth,z],[u-width,v+depth,z]]- const bottom=ring(1.4*U,U,8), shoulders=ring(2.1*U,1.1*U,12.5)- for(let i=0;i<4;i++)d.face([bottom[i]!,bottom[(i+1)%4]!,shoulders[(i+1)%4]!,shoulders[i]!],i<2?0xc9d2c7:0xe2e6dc,1)- d.face(shoulders,0xe2e6dc,1)- d.cylinder(u,v,0.45*U,12.5,1.3,0xc9d2c7,0xc9d2c7,0,8)- d.ellipsoid(u,v,16.5,U,0.9*U,3,0xc9d2c7,0.8,0xe2e6dc,8)-}--/** A simple stone basin. Running water is supplied by the shared effects renderer. */-function fountain(d: Drawing, u: number, v: number) {- const n=16, outer=5.5*U, inner=4.5*U- const ring=(r:number,z:number)=>Array.from({length:n},(_,i):Vertex=>[u+Math.cos(i*Math.PI*2/n)*r,v+Math.sin(i*Math.PI*2/n)*r,z])- d.cylinder(u,v,5.8*U,0,1,0xd5d9d0,stone,1,n)- const low=ring(outer,1),rim=ring(outer,4),inside=ring(inner,4),bed=ring(inner,1)- for(let i=0;i<n;i++){- const j=(i+1)%n- d.face([low[i]!,low[j]!,rim[j]!,rim[i]!],0xd5d9d0,0)- d.face([rim[i]!,rim[j]!,inside[j]!,inside[i]!],stone,0)- d.face([inside[i]!,inside[j]!,bed[j]!,bed[i]!],0xbec5bb,0)- }- // Only the basin rims carry ink; water has no drawn guide curves.- d.line([...rim,rim[0]!],1)- d.line([...inside,inside[0]!],0.75)- d.cylinder(u,v,4.4*U,2.6,0.15,water,0xd8e8ee,0,n)- d.cylinder(u,v,U,2.75,7.5,0xd5d9d0,stone,1,8)- d.cylinder(u,v,1.5*U,10.25,0.75,0xd5d9d0,stone,0.75,8)- ;(d.asset.fountains??=[]).push({origin:[u,v,0],radius:4.4*U,level:2.75,nozzle:11})-}--/** An iron lamp post with a lantern. */-function lamp(d: Drawing, u: number, v: number) {- d.cylinder(u, v, 1.2 * U, 0, 1.5, 0x8d9589, 0xaeb5ab, 1, 8)- d.cylinder(u, v, 0.35 * U, 1.5, 15, palette.ink, palette.ink, 0.75, 6)- d.box(u, v, 1.1 * U, 1.1 * U, 16.5, 4, 0xf6e6a8, 0xf1d98a, 0xe2c46e, 1)- d.box(u, v, 1.5 * U, 1.5 * U, 20.5, 1.2, 0x5b665f, 0x46514b, 0x3d4943, 1)- d.cylinder(u, v, 0.4 * U, 21.7, 1.5, palette.ink, palette.ink, 0.75, 6)-}--/** A park's furnishing on a cell centred on (u, v). */+/** A park furnishing occupies its original single cell. */export function parkProp(d: Drawing, prop: PropId, u: number, v: number) {- if (prop === "lamp") lamp(d, u + 4 * U, v - 4 * U)- else if (prop === "statue") {- d.box(u, v, 3.8 * U, 3.8 * U, 0, 1.5, 0xe9ebe5, 0xd5d9d0, 0xbec5bb, 1)- figure(d, u, v)- } else fountain(d, u, v)+ if (prop === "lamp") parkLamp(d, u + 4 * U, v - 4 * U)+ else if (prop === "statue") founderStatue(d, u, v)+ else parkFountain(d, u, v)}const lawn = 0xdce8cdconst lawnDark = 0xd3e1c2-const gravel = 0xece4d3/*** Parks laid on the ground, cell by cell (by `key`): lawn with its blades,@@ -115,39 +58,23 @@ export function parkAsset(cells: ReadonlyMap<number, ParkCell>, roads: ReadonlySfor (const [k, c] of cells) {const { x, y } = cellOf(k), u = x + 0.5, v = y + 0.5const h = hash(x, y)- if (c.ground === "square") setts(d, u, v, 0.5, z)+ if (c.ground === "square") parkPaving(d, u, v, z)else d.face(square(u, v, 0.5, z), h < 0.5 ? lawn : lawnDark, 0)- if (c.ground === "lawn" || c.ground === "flowers")- for (let i = 0; i < 4; i++) {- const a = u - 0.35 + hash(x * 5 + i, y * 3) * 0.7, b = v - 0.35 + hash(y * 7 + i, x * 2) * 0.7- d.line([[a - 0.03, b, z + 0.02], [a, b, z + 2], [a + 0.03, b, z + 0.02]], 0.75, 0xa9c79a)- }- if (c.ground === "flowers") {- d.face(square(u, v, 0.34, z + 0.03), 0xd9c7a6, 1, 0xb6a27f)- const colors = [0xc78374, 0xd6ba69, 0xb29ac2, 0xe0a0a8]- for (let i = 0; i < 9; i++) {- const a = u + ((i % 3) - 1) * 0.2, b = v + (Math.floor(i / 3) - 1) * 0.2- d.ellipsoid(a, b, 1.2, 1.1 * U, 1.1 * U, 1.3, 0xa9c79a, 0, undefined, 8)- d.ellipsoid(a, b, 2.4, 0.7 * U, 0.7 * U, 0.8, colors[(i + Math.floor(h * 4)) % 4]!, 0.5, undefined, 8)- }- }+ if (c.ground === "lawn" || c.ground === "flowers") turf(d,u,v,z,x,y)+ if (c.ground === "flowers") flowerPlot(d,u,v,z,x,y)if (c.ground === "path") {- // A walk: a square in the middle, and a strip out to each walk or road beside it.- const w = 0.2- d.face(square(u, v, w, z + 0.02), gravel, 0)- const out: Array<Vertex> = []- for (const { x: dx, y: dy } of DIRS) {- const joined = walk(x + dx, y + dy) || roads.has(key(x + dx, y + dy))- const q = (along: number, across: number): Vertex => [u + dx * along - dy * across, v + dy * along + dx * across, z + 0.03]- if (joined) {- const end=roads.has(key(x+dx,y+dy))?0.625:0.5- d.face([q(w, -w), q(end, -w), q(end, w), q(w, w)], gravel, 0)- d.line([q(w, -w), q(end, -w)], 1, 0xc2b79f)- d.line([q(w, w), q(end, w)], 1, 0xc2b79f)- } else d.line([q(w, -w), q(w, w)], 1, 0xc2b79f)- out.push(q(0.1 + hash(x * 3 + dx, y * 3 + dy) * 0.08, 0.05))+ const joins=DIRS.map(({x:dx,y:dy})=>({dx,dy,end:walk(x+dx,y+dy)?0.5:roads.has(key(x+dx,y+dy))?0.625:0}))+ gravelWalk(d,u,v,z,joins,x,y)+ }+ if (c.ground === "lawn" && c.prop === "none" && h < .42) {+ const front=DIRS.find(({x:dx,y:dy})=>walk(x+dx,y+dy)||roads.has(key(x+dx,y+dy)))+ if(front){+ const faces=d.asset.faces.length,strokes=d.asset.strokes.length+ bench(d,0,0)+ const turn=([a,b,H]:Vertex):Vertex=>[u+front.y*a+front.x*b,v-front.x*a+front.y*b,H]+ for(const f of d.asset.faces.slice(faces))f.points=f.points.map(turn)+ for(const s of d.asset.strokes.slice(strokes))s.points=s.points.map(turn)}- for (const p of out) d.line([p, [p[0] + 0.02, p[1], p[2]]], 1, 0xb8ad95)}// A low stone kerb where the park ends.for (const { x: dx, y: dy } of DIRS) {@@ -172,7 +99,7 @@ export function makeParkProp(prop: PropId) {asset.fountains?.forEach(f=>{f.origin=shift(f.origin)})asset.id = `park-${prop}`asset.title = `Park · ${props[prop].title.toLowerCase()}`- asset.note = prop==="statue"?"A simple stone bust on a plain pedestal, readable at the town's scale.":prop==="fountain"?"A stone basin with running water and soft surface ripples.":props[prop].blurb+ asset.note = prop==="statue"?"A simple stone bust with broad carved shoulders, a plain head and a stepped pedestal.":prop==="fountain"?"A moulded stone basin with jointed coping, a fluted stem, upper bowl and running water.":props[prop].blurbasset.category = "land"asset.reference = { type: "none" }asset.footprint = 1diff --git a/src/model-review/park-models.ts b/src/model-review/park-models.tsnew file mode 100644index 0000000..93a0806--- /dev/null+++ b/src/model-review/park-models.ts@@ -0,0 +1,25 @@+import { assetById } from "../asset-lab/assets.ts"+import { Drawing, type InkAsset, type Vertex } from "../asset-lab/primitives.ts"+import { bench, flowerBed, parkAsset } from "../asset-lab/town-props.ts"+import { builtPark } from "../park-lab/park.ts"+import { key } from "../grid.ts"+import type { GroundId } from "../content.ts"++export function parkReviewModels(): InkAsset[] {+ const models=["park-lamp","park-statue","park-fountain"].map(id=>assetById.get(id)!)+ for(const [id,title,draw] of [["park-bench","Park bench",bench],["park-border","Planted border",flowerBed]] as const){+ const d=new Drawing(id,title,"Shared park furnishing, at the unchanged walker scale.")+ draw(d,0,0);d.asset.category="land";d.asset.footprint=1;models.push(d.asset)+ }+ for(const [ground,title] of [["lawn","Lawn & seating"],["flowers","Flower bed"],["path","Gravel path"],["square","Paved square"]] as const satisfies ReadonlyArray<readonly[GroundId,string]>){+ const cells=new Map([[key(0,0),{x:0,y:0,ground,prop:"none" as const}]])+ const roads=ground==="path"||ground==="lawn"?new Set([key(0,1)]):new Set<number>()+ const asset=parkAsset(cells,roads),shift=([u,v,z]:Vertex):Vertex=>[u-.5,v-.5,z]+ models.push({...asset,id:`park-${ground}`,title,footprint:1,faces:asset.faces.map(f=>({...f,points:f.points.map(shift)})),strokes:asset.strokes.map(s=>({...s,points:s.points.map(shift)}))})+ }+ const join=parkAsset(new Map([[key(0,0),{x:0,y:0,ground:"path",prop:"none"}]]),new Set([key(-1,0),key(1,0),key(0,-1),key(0,1)]))+ const shift=([u,v,z]:Vertex):Vertex=>[u-.5,v-.5,z]+ models.push({...join,id:"park-junction",title:"Joined walks",footprint:1,faces:join.faces.map(f=>({...f,points:f.points.map(shift)})),strokes:join.strokes.map(s=>({...s,points:s.points.map(shift)}))})+ models.push(assetById.get("park-sample")!,builtPark())+ return models+}diff --git a/src/model-review/proportions.ts b/src/model-review/proportions.tsindex ae431bd..be5676f 100644--- a/src/model-review/proportions.ts+++ b/src/model-review/proportions.ts@@ -2,9 +2,11 @@ import * as THREE from "three"import { buildAsset, vertex3 } from "../asset-lab/renderer.ts"import type { InkAsset } from "../asset-lab/primitives.ts"import { proportionModels, architectureIds } from "./proportion-models.ts"+import { parkReviewModels } from "./park-models.ts"import "./proportions.css"type Baseline = { revision: string; models: InkAsset[]; walker: InkAsset }+const parksMode=new URLSearchParams(location.search).get("collection")==="parks"const notes: Record<string,string> = {cottage:"A person-sized timber door and taller walls; the one-cell footprint stays the same.",citizen:"Two floors share the same human clearance as the cottage, with windows above the new floor lines.",@@ -48,27 +50,49 @@ const notes: Record<string,string> = {"cart-furniture-4":"The delivery cart keeps its walker-compatible handles; the load uses the revised shared furniture.","barrow-furniture-4":"The barrow retains its own chassis; the load uses the revised shared furniture.","crate-wood":"A smaller generic goods crate; the same change applies to every goods label. Large warehouse loads remain separate.",+ "park-lamp":"A taller cast-iron standard, stepped base and framed glass lantern, with a weather cap and small finial.",+ "park-statue":"A simple stone bust with broad carved shoulders, a plain head and a restrained stepped pedestal.",+ "park-fountain":"A larger moulded stone basin, individual coping stones and a raised bowl around the working nozzle.",+ "park-bench":"Four seat slats, a sloping three-slat back, iron frames and armrests. Seat height remains 4.5 units.",+ "park-border":"Stone edging, inset soil, stems, leaves and individual blossoms, shared with the town's planted borders.",+ "park-lawn":"Short turf and quieter grass tufts; suitable lawn cells beside walks gain occasional benches.",+ "park-flowers":"Raised planting edges and irregular groups of leafy flowers replace the flat square and regular dots.",+ "park-path":"A bordered gravel walk with small stones and clear connections to neighbouring walks and roads.",+ "park-square":"Larger staggered flagstones with thin mortar joints and a low, carefully finished edge.",+ "park-junction":"The gravel and edging join four street approaches without fencing off the entrances.",+ "park-sample":"The same 25-cell layout, with revised furnishings, planting, paving and seating. Park rules and costs are unchanged.",+ "park-built":"The same connected park between two streets, with running water and the revised furnishings at the walker scale.",}const root=document.querySelector<HTMLElement>("#proportions")!root.innerHTML=`<header><div><div class="eyebrow">INKLINE TOWN / PROPORTION STUDY</div><h1>One town. One human scale.</h1><p>Every building and upgrade, plus shared furnishings and construction. The walker is unchanged. Both sides always use the same camera, ground position and zoom.</p></div><div><a href="/model-review.html?collection=handoff">Model catalogue ↗</a><p class="status" id="status">Loading the approved originals…</p></div></header><div class="layout"><aside><input aria-label="Find a model" type="search" placeholder="Find a model…"><select aria-label="Model group"><option value="all">All models</option><option value="architecture">Buildings & homes</option><option value="props">Props & construction</option></select><select aria-label="Choose model"></select><nav aria-label="All comparison models"></nav></aside><section><div class="row"><button id="previous" aria-label="Previous model">←</button><h2></h2><button id="next" aria-label="Next model">→</button></div><p class="meta" id="note"></p><div class="controls"><label>Turn <input aria-label="Model rotation" type="range" min="-180" max="180" value="0"><output>0°</output></label><label>Elevation <select aria-label="View elevation"><option value="30">Game angle</option><option value="0">Eye level</option><option value="50">From above</option></select></label><label>Zoom <input aria-label="Zoom" type="range" min=".7" max="2" step=".1" value="1"></label><label><input type="checkbox" id="town-scale"> One scale across all models</label><button id="reset">Reset view</button><button id="save">Save comparison</button></div><div class="view"><div class="captions"><span>Before · approved</span><span>After · revised</span></div><div class="divider"></div></div><div class="footer"><span id="dimensions"></span><br>Drag to turn both views together. Arrow buttons move through every model. Switch on one town scale to compare building sizes across the catalogue.<br>Before geometry is frozen at <code>a2845b4</code>. Changes are model geometry, not camera scaling.</div></section></div>`const renderer=new THREE.WebGLRenderer({antialias:true,preserveDrawingBuffer:true})+if(parksMode){+ document.title="Inkline Town · Park before / after"+ root.querySelector(".eyebrow")!.textContent="INKLINE TOWN / PARK STUDY"+ root.querySelector("h1")!.textContent="A park worth visiting."+ root.querySelector("header p")!.textContent="Every park furnishing, planting and ground treatment, beside the approved originals. The walker and camera are unchanged."+ const groups=root.querySelectorAll("select[aria-label='Model group'] option")+ groups[1]!.textContent="Furnishings & planting";groups[2]!.textContent="Ground & assembled parks"+ root.querySelector(".footer code")!.textContent="f4df9d5"+ root.querySelector(".footer")!.lastChild!.textContent=". Changes are native model geometry."+}renderer.setPixelRatio(Math.min(devicePixelRatio,2));renderer.setClearColor(0xf0f2ec);renderer.setScissorTest(true)const view=root.querySelector<HTMLElement>(".view")!;view.append(renderer.domElement)const camera=new THREE.OrthographicCamera(-100,100,100,-100,.1,4000)const search=root.querySelector<HTMLInputElement>("input[type=search]")!,group=root.querySelector<HTMLSelectElement>("select[aria-label='Model group']")!,picker=root.querySelector<HTMLSelectElement>("select[aria-label='Choose model']")!,nav=root.querySelector<HTMLElement>("nav")!const rotation=root.querySelector<HTMLInputElement>("input[aria-label='Model rotation']")!,elevation=root.querySelector<HTMLSelectElement>("select[aria-label='View elevation']")!,zoom=root.querySelector<HTMLInputElement>("input[aria-label='Zoom']")!,townScale=root.querySelector<HTMLInputElement>("#town-scale")!const geometryBounds=(a:InkAsset)=>new THREE.Box3().setFromPoints([...a.faces,...a.strokes].flatMap(f=>f.points.map(vertex3)))-let before:Baseline,after=proportionModels(),filtered=after,selected=0,yaw=0,pitch=30,drag:number|null=null+let before:Baseline,after=parksMode?parkReviewModels():proportionModels(),filtered=after,selected=0,yaw=0,pitch=30,drag:number|null=nulllet pair:Array<{scene:THREE.Scene;built:ReturnType<typeof buildAsset>;person:ReturnType<typeof buildAsset>}>=[],bounds=new THREE.Box3()-const clean=(a:InkAsset):InkAsset=>{const {smokeEffect,fountains,effects,...geometry}=a;return geometry}+const clean=(a:InkAsset):InkAsset=>{const {smokeEffect,effects,...geometry}=a;if(!parksMode)delete geometry.fountains;return geometry}function render(){if(!pair.length)returnconst {width,height}=view.getBoundingClientRect(),w=width/2renderer.setSize(width,height,false)const heading=(45+yaw)*Math.PI/180,angle=pitch*Math.PI/180- const box=townScale.checked?new THREE.Box3(new THREE.Vector3(-85,-1,-75),new THREE.Vector3(85,170,85)):bounds+ const box=townScale.checked?(parksMode?new THREE.Box3(new THREE.Vector3(-180,-1,-180),new THREE.Vector3(180,70,180)):new THREE.Box3(new THREE.Vector3(-85,-1,-75),new THREE.Vector3(85,170,85))):boundsconst center=box.getCenter(new THREE.Vector3()),size=box.getSize(new THREE.Vector3())const horizontal=Math.abs(Math.cos(heading))*size.x+Math.abs(Math.sin(heading))*size.zconst vertical=Math.cos(angle)*size.y+Math.abs(Math.sin(angle))*(Math.abs(Math.sin(heading))*size.x+Math.abs(Math.cos(heading))*size.z)@@ -78,7 +102,7 @@ function render(){camera.lookAt(center);camera.updateProjectionMatrix();camera.updateMatrixWorld()pair.forEach(({scene,built,person},i)=>{renderer.setViewport(i*w,0,w,height);renderer.setScissor(i*w,0,w,height)- for(const b of [built,person])b.updateContours(camera)+ for(const b of [built,person]){b.updateContours(camera);b.updateEffects(1.2)}renderer.render(scene,camera)})root.querySelector("output")!.textContent=`${yaw}°`@@ -94,6 +118,7 @@ function select(id:string){const built=buildAsset(clean(asset),{batchFaces:true}),person=buildAsset(before.walker,{batchFaces:true}),scene=new THREE.Scene()person.group.position.copy(personPosition);scene.add(built.group,person.group)bounds.union(geometryBounds(asset));bounds.union(geometryBounds(before.walker).translate(personPosition))+ for(const f of parksMode?asset.fountains??[]:[])bounds.expandByPoint(vertex3([f.origin[0],f.origin[1],f.origin[2]+f.nozzle+7]))pair.push({scene,built,person})}root.querySelector("h2")!.textContent=a.title@@ -102,11 +127,11 @@ function select(id:string){const changed=JSON.stringify([a.faces,a.strokes])!==JSON.stringify([b.faces,b.strokes])root.querySelector("#dimensions")!.textContent=`${changed?"Updated":"Reviewed · retained"} · Geometry height ${top(b).toFixed(1)} → ${top(a).toFixed(1)} · Plot ${a.footprint??1} × ${a.footprint??1} cells · Walker 17.1, unchanged`picker.value=id;nav.querySelectorAll("button").forEach(el=>el.setAttribute("aria-current",String(el.dataset.id===id)))- history.replaceState(null,"",`?model=${id}`);render()+ history.replaceState(null,"",`?${parksMode?"collection=parks&":""}model=${id}`);render()}function filter(){const q=search.value.toLowerCase()- filtered=after.filter(a=>(group.value==="all"||(group.value==="architecture")===architectureIds.includes(a.id))&&`${a.title} ${a.id}`.toLowerCase().includes(q))+ filtered=after.filter(a=>(group.value==="all"||(group.value==="architecture")===(parksMode?["park-lamp","park-statue","park-fountain","park-bench","park-border"].includes(a.id):architectureIds.includes(a.id)))&&`${a.title} ${a.id}`.toLowerCase().includes(q))picker.replaceChildren();nav.replaceChildren()for(const asset of filtered){const option=document.createElement("option");option.value=asset.id;option.textContent=asset.title;picker.append(option)@@ -135,7 +160,7 @@ renderer.domElement.onpointerup=()=>drag=nullnew ResizeObserver(render).observe(view)async function start(){const requested=new URLSearchParams(location.search).get("model")- const response=await fetch("/model-review/proportions-before.json.gz")+ const response=await fetch(`/model-review/${parksMode?"parks":"proportions"}-before.json.gz`)if(!response.ok)throw new Error(`Baseline ${response.status}`)const bytes=await response.arrayBuffer()// Dev servers serve .gz verbatim. Some hosts decompress it automatically.@@ -143,7 +168,7 @@ async function start(){before=JSON.parse(raw[0]===31&&raw[1]===139?await new Response(new Blob([bytes]).stream().pipeThrough(new DecompressionStream("gzip"))).text():new TextDecoder().decode(raw))if(before.models.length!==after.length||after.some(a=>!before.models.some(b=>b.id===a.id)))throw new Error("Comparison catalogue does not match the frozen baseline")filter();if(requested&&after.some(a=>a.id===requested))select(requested)- root.querySelector("#status")!.textContent=`${architectureIds.length} building appearances · ${after.length-architectureIds.length} shared examples`+ root.querySelector("#status")!.textContent=parksMode?"12 park comparisons · unchanged walker":`${architectureIds.length} building appearances · ${after.length-architectureIds.length} shared examples`Object.assign(window,{proportionReview:{ids:after.map(a=>a.id),select,render,capture:()=>renderer.domElement.toDataURL(),stats:()=>({id:picker.value,before:before.revision,yaw,pitch,pairs:pair.length})}})}start().catch(error=>{root.querySelector("#status")!.textContent=String(error);root.querySelector("#status")!.classList.add("error");console.error(error)})diff --git a/src/park-lab/main.ts b/src/park-lab/main.tsindex 5f570b4..4094b4a 100644--- a/src/park-lab/main.ts+++ b/src/park-lab/main.ts@@ -7,7 +7,7 @@ import "./style.css"const assets={park:builtPark(),fountain:assetById.get("park-fountain")!,statue:assetById.get("park-statue")!}type View=keyof typeof assetsconst root=document.querySelector<HTMLElement>("#park-lab")!-root.innerHTML=`<header><a href="/model-review.html?collection=ornaments">Inkline Town · Parks</a><a href="/asset-lab.html?asset=park-sample">Full catalogue ↗</a></header><section class="intro"><h1>A park, piece by piece.</h1><p>Lawn, flower beds and walks connect two street entrances. A quiet fountain and a simple stone bust give the park its centre.</p></section><nav aria-label="Park review views"><button data-view="park" aria-pressed="true">Built park</button><button data-view="fountain" aria-pressed="false">Fountain close-up</button><button data-view="statue" aria-pressed="false">Statue close-up</button></nav><section class="controls"><label>Turn <input aria-label="Park rotation" type="range" min="-180" max="180" value="0"><output>0°</output></label><label>View <select aria-label="Park elevation"><option value="30">Street angle</option><option value="55">From above</option><option value="15">Near the ground</option></select></label><button id="rear">See the back</button><button id="pause">Pause water</button><button id="reset">Reset view</button></section><section class="stage" aria-label="Rendered park"></section><footer><div><h2 id="title"></h2><p id="note"></p></div><span id="summary">25 park cells · 2 entrances · 3 lamps</span></footer>`+root.innerHTML=`<header><a href="/model-review.html?collection=ornaments">Inkline Town · Parks</a><a href="/proportion-review.html?collection=parks&model=park-built">Before / after ↗</a></header><section class="intro"><h1>A park, piece by piece.</h1><p>Lawn, flower beds and walks connect two street entrances. Carved stone, framed lanterns and iron-and-timber seating give the park its character.</p></section><nav aria-label="Park review views"><button data-view="park" aria-pressed="true">Built park</button><button data-view="fountain" aria-pressed="false">Fountain close-up</button><button data-view="statue" aria-pressed="false">Statue close-up</button></nav><section class="controls"><label>Turn <input aria-label="Park rotation" type="range" min="-180" max="180" value="0"><output>0°</output></label><label>View <select aria-label="Park elevation"><option value="30">Street angle</option><option value="55">From above</option><option value="15">Near the ground</option></select></label><button id="rear">See the back</button><button id="pause">Pause water</button><button id="reset">Reset view</button></section><section class="stage" aria-label="Rendered park"></section><footer><div><h2 id="title"></h2><p id="note"></p></div><span id="summary">25 park cells · 2 entrances · 3 lamps</span></footer>`const stage=root.querySelector<HTMLElement>(".stage")!,renderer=new THREE.WebGLRenderer({alpha:true,antialias:true,preserveDrawingBuffer:true}),scene=new THREE.Scene(),camera=new THREE.OrthographicCamera(-100,100,100,-100,0.1,4000)renderer.setPixelRatio(Math.min(devicePixelRatio,2));renderer.setClearColor(0xf0f2ec,0);renderer.outputColorSpace=THREE.SRGBColorSpace;stage.append(renderer.domElement)let view:View="park",yaw=0,pitch=30,time=0,paused=false,last=0,frames=0,built:BuiltAsset|null=null,bounds=new THREE.Box3()@@ -29,7 +29,7 @@ function select(next:View){built?.group.removeFromParent();built?.dispose();view=next;built=buildAsset(assets[view],{batchFaces:true});scene.add(built.group);bounds=new THREE.Box3().setFromObject(built.group)root.querySelectorAll<HTMLButtonElement>("nav button").forEach(b=>b.setAttribute("aria-pressed",String(b.dataset.view===view)))root.querySelector("#title")!.textContent=view==="park"?"Twenty-five cells, one park":view==="fountain"?"Running water":"A founder in stone"- root.querySelector("#note")!.textContent=view==="park"?assets.park.note:view==="fountain"?"Water rises from the column, falls into the basin and makes soft ripples.":"A head, shoulders and pedestal. The silhouette stays clear at the game's scale."+ root.querySelector("#note")!.textContent=view==="park"?assets.park.note:view==="fountain"?"Water rises above a carved upper bowl, falls into the moulded basin and makes soft ripples.":"A quiet stone bust: broad shoulders, a plain head and a stepped pedestal."root.querySelector<HTMLElement>("#summary")!.hidden=view!=="park";draw()history.replaceState(null,"",`?view=${view}`)}diff --git a/src/park-lab/park.ts b/src/park-lab/park.tsindex 6be10a6..f536167 100644--- a/src/park-lab/park.ts+++ b/src/park-lab/park.ts@@ -15,7 +15,7 @@ export function builtPark(): InkAsset {const shift=([u,v,z]:Vertex):Vertex=>[u-30.5,v-30.5,z]return {id:"park-built",title:"A park built cell by cell",category:"land",footprint:7,- note:"Twenty-five cells of lawn, flower beds, gravel walks and paved squares, with two street entrances, three lamps, a fountain and a stone bust.",+ note:"Twenty-five cells of planted lawn, flower beds, edged gravel walks and flagstone squares, with two street entrances, three lanterns, seating, a tiered fountain and a simple stone bust.",faces:[...park.faces,...roads.faces].map(f=>({...f,points:f.points.map(shift)})),strokes:[...park.strokes,...roads.strokes].map(s=>({...s,points:s.points.map(shift)})),fountains:(park.fountains??[]).map(f=>({...f,origin:shift(f.origin)}))diff --git a/test/park-models.test.ts b/test/park-models.test.tsnew file mode 100644index 0000000..2a0c42d--- /dev/null+++ b/test/park-models.test.ts@@ -0,0 +1,55 @@+import assert from "node:assert/strict"+import { test } from "node:test"+import { readFileSync } from "node:fs"+import { gunzipSync } from "node:zlib"+import * as THREE from "three"+import { assetById } from "../src/asset-lab/assets.ts"+import { Drawing, type InkAsset } from "../src/asset-lab/primitives.ts"+import { parkAsset, parkProp } from "../src/asset-lab/town-props.ts"+import { parkReviewModels } from "../src/model-review/park-models.ts"+import { human } from "../src/asset-lab/dimensions.ts"+import { DIRS, key } from "../src/grid.ts"++const baseline=JSON.parse(gunzipSync(readFileSync(new URL("../public/model-review/parks-before.json.gz",import.meta.url))).toString()) as {revision:string;models:InkAsset[];walker:InkAsset}+const points=(a:InkAsset)=>[...a.faces,...a.strokes].flatMap(f=>f.points)+const top=(a:InkAsset)=>Math.max(...points(a).map(p=>p[2]))++test("park comparisons retain the approved originals, plots and unchanged person",()=>{+ assert.equal(baseline.revision,"f4df9d5f9e1ff74552e5a29a3366ec9f541bb3bd")+ const current=parkReviewModels()+ assert.equal(current.length,12)+ assert.deepEqual(current.map(a=>[a.id,a.footprint]),baseline.models.map(a=>[a.id,a.footprint]))+ assert.deepEqual(baseline.walker.faces,assetById.get("settler-cap")!.faces)+ assert.deepEqual(baseline.walker.strokes,assetById.get("settler-cap")!.strokes)+})++test("furnishings stay within one cell and use the town's human scale",()=>{+ for(const prop of ["lamp","statue","fountain"] as const){+ const d=new Drawing(prop,prop,"");parkProp(d,prop,0,0)+ assert.ok(points(d.asset).every(([u,v,z])=>Math.abs(u)<=.5&&Math.abs(v)<=.5&&z>=0),`${prop}: outside plot or underground`)+ }+ const walkerHeight=top(assetById.get("settler-cap")!)+ assert.ok(top(assetById.get("park-lamp")!)>walkerHeight*1.7)+ assert.ok(top(assetById.get("park-lamp")!)<walkerHeight*2.1)+ const bench=parkReviewModels().find(a=>a.id==="park-bench")!+ assert.ok(top(bench)<walkerHeight*.65,"Bench back must sit below a standing adult's shoulders")+ assert.ok(bench.faces.some(f=>f.points.every(p=>Math.abs(p[2]-human.seat-.65)<1e-8)),"Seat surface must retain the shared human seat height")+ const fountain=assetById.get("park-fountain")!,emitter=fountain.fountains![0]!+ assert.ok(emitter.level>0&&emitter.level<5,"Water must sit below the basin coping")+ assert.ok(emitter.nozzle>11&&emitter.nozzle<walkerHeight,"Nozzle clears the upper bowl and stays below a person's head")+ assert.ok(emitter.radius<.5,"Water must stay inside its cell")+})++test("all path and square approaches leave a person-wide opening to every joined road",()=>{+ const roads=new Set(DIRS.map(({x,y})=>key(x,y)))+ for(const ground of ["path","square"] as const){+ const a=parkAsset(new Map([[key(0,0),{x:0,y:0,ground,prop:"none"}]]),roads)+ for(const {x,y} of DIRS)for(const offset of [-.07,0,.07]){+ const origin=new THREE.Vector3(.5-y*offset,.5+x*offset,1),ray=new THREE.Ray(origin,new THREE.Vector3(x,y,0))+ for(const f of a.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)>.65,`${ground}/${x},${y}: road approach blocked`)+ }+ }+ }+})