feat: buildings look like what they are: the storage is a barn, the stable has stalls and horses in a paddock, the workshop wheels and siege engines, the barracks a training yard

The first pass of these models and their helpers in iso.ts went out with 21de409.
This finishes them: shields and stall doors sort in front of their walls, horse
heads look out of the stalls, the headquarters flies the village flag at every
tier, and the workshop shows a frame in the making, then a ram, then a ram and a
catapult, with wheels standing by its door.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Fabian @ Blax Software 2026-10-29 16:42:54 +01:00
parent fa9a7f7f54
commit a920ff566e
1 changed files with 59 additions and 41 deletions

View File

@ -219,6 +219,13 @@ function wallDisc(face: 'x' | 'y', at: number, along: number, zc: number, r: num
return { pts, color, twoSided: true, flat: true, depth } return { pts, color, twoSided: true, flat: true, depth }
} }
/** Faces that must draw over a wall: sorted from `depth` on, in their own front-to-back order. */
function over(faces: Face[], depth: number): Face[] {
const own = faces.map((f) => f.pts.reduce((n, [x, y, z]) => n + x + y + z, 0) / f.pts.length)
const low = Math.min(...own)
return faces.map((f, i) => ({ ...f, depth: depth + own[i]! - low }))
}
/** A beam lying on the ground between two points, or raised to z: a fence rail, a timber. */ /** A beam lying on the ground between two points, or raised to z: a fence rail, a timber. */
function beam([ax, ay]: V2, [bx, by]: V2, z: number, t: number, h: number, color: string): Face[] { function beam([ax, ay]: V2, [bx, by]: V2, z: number, t: number, h: number, color: string): Face[] {
const len = Math.hypot(bx - ax, by - ay) || 1 const len = Math.hypot(bx - ax, by - ay) || 1
@ -291,6 +298,21 @@ function ram(x: number, y: number, k: number, quarters = 0): Face[] {
return shift(turn(faces, quarters), x, y) return shift(turn(faces, quarters), x, y)
} }
/** A siege engine in the making, facing +x: the frame on its wheels, two posts up. */
function frame(x: number, y: number, k: number): Face[] {
return shift(
[
...[-1, 1].flatMap((fx) => [-1, 1].map((fy) => [fx, fy])).flatMap(([fx, fy]) => wheel(fx! * 1.25 * k, fy! * 0.95 * k, 0.6 * k, 'y')),
...box(0, 0, 3.3 * k, 1.5 * k, 0.65 * k, 0.3 * k, C.plank, C.plank),
...post(-1.45 * k, -0.6 * k, 2.2 * k, 0.12 * k),
...post(1.45 * k, -0.6 * k, 2.2 * k, 0.12 * k),
...box(0, -0.6 * k, 3.1 * k, 0.12 * k, 2.1 * k, 0.12 * k, C.wood),
],
x,
y,
)
}
/** A catapult facing +x before `quarters` turns: a wheeled frame, two uprights with a crossbar, the arm with its bucket raised. */ /** A catapult facing +x before `quarters` turns: a wheeled frame, two uprights with a crossbar, the arm with its bucket raised. */
function catapult(x: number, y: number, k: number, quarters = 0): Face[] { function catapult(x: number, y: number, k: number, quarters = 0): Face[] {
const faces: Face[] = [ const faces: Face[] = [
@ -354,13 +376,13 @@ function tent(x: number, y: number, w: number, d: number, h: number, along: 'x'
const y1 = y + d / 2 const y1 = y + d / 2
const flap: V3[] = const flap: V3[] =
along === 'x' along === 'x'
? [[x1 + 0.1, y - d * 0.2, 0], [x1 + 0.1, y + d * 0.2, 0], [x1 + 0.1, y, h * 0.62]] ? [[x1 + 0.1, y - d * 0.27, 0], [x1 + 0.1, y + d * 0.27, 0], [x1 + 0.1, y, h * 0.7]]
: [[x - w * 0.2, y1 + 0.1, 0], [x + w * 0.2, y1 + 0.1, 0], [x, y1 + 0.1, h * 0.62]] : [[x - w * 0.27, y1 + 0.1, 0], [x + w * 0.27, y1 + 0.1, 0], [x, y1 + 0.1, h * 0.7]]
const depth = (along === 'x' ? x1 + y : x + y1) + h / 3 + 0.2 const depth = (along === 'x' ? x1 + y : x + y1) + h / 3 + 0.2
return [ return [
...gable(x - w / 2, y - d / 2, x1, y1, 0, h, along, color, scale(color, 0.9)), ...gable(x - w / 2, y - d / 2, x1, y1, 0, h, along, color, scale(color, 0.9)),
{ pts: flap, color: door ? DOOR : C.dark, twoSided: true, flat: true, depth }, { pts: flap, color: door ? DOOR : C.dark, twoSided: true, flat: true, depth },
...(along === 'x' ? post(x1, y, h * 1.12, w * 0.02) : post(x, y1, h * 1.12, d * 0.02)), ...shift(along === 'x' ? post(x1, y, h * 0.2, w * 0.02) : post(x, y1, h * 0.2, d * 0.02), 0, 0, h * 0.94),
] ]
} }
@ -772,9 +794,9 @@ const models: Record<BuildingType, (s: number, t: number) => Model> = {
faces: [ faces: [
...tent(-s * 0.3, -s * 0.4, s * 0.95, s * 0.7, s * 0.62, 'x', C.canvas, true), ...tent(-s * 0.3, -s * 0.4, s * 0.95, s * 0.7, s * 0.62, 'x', C.canvas, true),
...tent(-s * 0.6, s * 0.42, s * 0.75, s * 0.55, s * 0.5, 'x', C.canvasDark), ...tent(-s * 0.6, s * 0.42, s * 0.75, s * 0.55, s * 0.5, 'x', C.canvasDark),
...weaponRack(s * 0.5, s * 0.55, s, 'x'), ...weaponRack(s * 0.4, s * 0.65, s, 'x'),
...dummy(s * 0.75, -s * 0.05, s), ...dummy(s * 0.8, -s * 0.2, s),
...fire(s * 0.15, s * 0.2, s), ...fire(s * 0.4, s * 0.15, s),
...banner(-s * 0.95, -s * 0.85, s * 1.15, s * 0.45), ...banner(-s * 0.95, -s * 0.85, s * 1.15, s * 0.45),
], ],
height: s * 1.15, height: s * 1.15,
@ -856,12 +878,11 @@ const models: Record<BuildingType, (s: number, t: number) => Model> = {
const y0 = ey + 0.1 const y0 = ey + 0.1
const z0 = h * 0.88 const z0 = h * 0.88
faces.push( faces.push(
...slab( ...over(slab(
[[x - 0.26 * k, y0, z0 - 0.75 * k], [x + 0.26 * k, y0, z0 - 0.75 * k], [x + 0.2 * k, y0 + 1.25 * k, z0 - 1.2 * k], [x - 0.2 * k, y0 + 1.25 * k, z0 - 1.2 * k]], [[x - 0.26 * k, y0, z0 - 0.75 * k], [x + 0.26 * k, y0, z0 - 0.75 * k], [x + 0.2 * k, y0 + 1.25 * k, z0 - 1.2 * k], [x - 0.2 * k, y0 + 1.25 * k, z0 - 1.2 * k]],
[[x - 0.26 * k, y0, z0], [x + 0.26 * k, y0, z0], [x + 0.2 * k, y0 + 1.25 * k, z0 - 0.75 * k], [x - 0.2 * k, y0 + 1.25 * k, z0 - 0.75 * k]], [[x - 0.26 * k, y0, z0], [x + 0.26 * k, y0, z0], [x + 0.2 * k, y0 + 1.25 * k, z0 - 0.75 * k], [x - 0.2 * k, y0 + 1.25 * k, z0 - 0.75 * k]],
coats[(i + 1) % 3]!, coats[(i + 1) % 3]!,
).map((f) => ({ ...f, depth: yDepth + 0.3 + k })), ), yDepth + 0.3),
...pyramid(rect(x, y0 + 0.15 * k, 0.4 * k, 0.2 * k), z0, 0.35 * k, scale(coats[(i + 1) % 3]!, 0.6)).map((f) => ({ ...f, depth: yDepth + 0.4 + k })),
) )
} }
} }
@ -882,32 +903,32 @@ const models: Record<BuildingType, (s: number, t: number) => Model> = {
return { faces, height: s * 1.0 } return { faces, height: s * 1.0 }
}, },
// Where siege engines are made: an open shed with wheels against its back wall and a // Where siege engines are made: wheels stand in a row by the door, timbers lie ready.
// frame on the floor, timbers outside; then a ram under the roof; then a stone hall // An open shed with a wheeled frame in the making first, then a ram ready in front,
// with a catapult in front. // then a stone hall with a ram and a catapult.
workshop(s, t) { workshop(s, t) {
const shed = (x0: number, y0: number, x1: number, y1: number, h: number, roof: string): Face[] => { const shed = (x0: number, y0: number, x1: number, y1: number, h: number, roof: string): Face[] => {
const back = scale(C.plank, 0.9) const inside = scale(C.plank, 0.55)
return [ return [
plane(rect((x0 + x1) / 2, (y0 + y1) / 2, x1 - x0, y1 - y0).map(([x, y]): V3 => [x, y, 0.5]), C.soil), plane(rect((x0 + x1) / 2, (y0 + y1) / 2, x1 - x0, y1 - y0).map(([x, y]): V3 => [x, y, 0.5]), C.soil),
plane([[x0, y0, 0], [x1, y0, 0], [x1, y0, h], [x0, y0, h]], back), plane([[x0, y0, 0], [x1, y0, 0], [x1, y0, h], [x0, y0, h]], inside),
plane([[x0, y0, 0], [x0, y1, 0], [x0, y1, h], [x0, y0, h]], scale(back, 0.9)), plane([[x0, y0, 0], [x0, y1, 0], [x0, y1, h], [x0, y0, h]], scale(inside, 0.9)),
...[x0, (x0 + x1) / 2, x1].flatMap((x) => [...post(x, y1, h, s * 0.04), ...post(x, y0, h, s * 0.04)]), ...[x0, (x0 + x1) / 2, x1].flatMap((x) => [...post(x, y1, h, s * 0.045), ...post(x, y0, h, s * 0.045)]),
...post(x1, (y0 + y1) / 2, h, s * 0.04), ...post(x1, (y0 + y1) / 2, h, s * 0.045),
...gable(x0 - s * 0.06, y0 - s * 0.06, x1 + s * 0.06, y1 + s * 0.06, h, s * 0.32, 'x', roof, C.wood), ...gable(x0 - s * 0.06, y0 - s * 0.06, x1 + s * 0.06, y1 + s * 0.06, h, s * 0.3, 'x', roof, C.wood),
] ]
} }
const leaning = (x: number, y: number) => [...wheel(x, y, s * 0.15, 'y'), ...wheel(x + s * 0.26, y, s * 0.15, 'y')] /** Finished wheels standing in a row along y, faces to the viewer. */
const wheels = (x: number, y: number, n: number) => Array.from({ length: n }, (_, i) => wheel(x, y + i * s * 0.34, s * 0.17, 'x')).flat()
if (t === 1) { if (t === 1) {
return { return {
faces: [ faces: [
...shed(-s * 0.8, -s * 0.8, s * 0.5, s * 0.1, s * 0.55, C.thatch), ...shed(-s * 0.9, -s * 0.9, s * 0.2, -s * 0.15, s * 0.62, C.thatch),
...leaning(-s * 0.55, -s * 0.66), ...wheel(-s * 0.55, -s * 0.78, s * 0.2, 'y'),
...box(-s * 0.1, -s * 0.3, s * 0.5, s * 0.22, s * 0.1, s * 0.06, C.wood, C.plank), ...wheel(-s * 0.15, -s * 0.78, s * 0.2, 'y'),
...wheel(-s * 0.25, -s * 0.15, s * 0.12, 'y'), ...frame(s * 0.05, s * 0.35, s * 0.15),
...timbers(-s * 0.2, s * 0.6, s), ...wheels(s * 0.75, -s * 0.6, 2),
...wheel(s * 0.75, s * 0.25, s * 0.15, 'x'), ...timbers(-s * 0.5, s * 0.6, s),
...box(s * 0.8, -s * 0.4, s * 0.4, s * 0.2, 0, s * 0.2, C.wood, C.plank),
], ],
height: s * 0.95, height: s * 0.95,
} }
@ -915,28 +936,25 @@ const models: Record<BuildingType, (s: number, t: number) => Model> = {
if (t === 2) { if (t === 2) {
return { return {
faces: [ faces: [
...house(-s * 0.95, -s * 0.85, s * 0.5, s * 0.5, s * 0.5, s * 0.25, C.stone, C.slate), ...shed(-s * 0.95, -s * 0.95, s * 0.35, -s * 0.15, s * 0.68, C.shingle),
...box(-s * 0.95, -s * 0.85, s * 0.12, s * 0.12, s * 0.6, s * 0.4, C.stoneDark), ...wheel(-s * 0.65, -s * 0.83, s * 0.2, 'y'),
...shed(-s * 0.65, -s * 0.85, s * 0.75, s * 0.05, s * 0.62, C.shingle), ...wheel(-s * 0.25, -s * 0.83, s * 0.2, 'y'),
...leaning(-s * 0.45, -s * 0.72), ...frame(-s * 0.3, -s * 0.45, s * 0.13),
...leaning(s * 0.15, -s * 0.72), ...ram(s * 0.05, s * 0.4, s * 0.16),
...ram(s * 0.05, -s * 0.35, s * 0.11), ...wheels(s * 0.8, -s * 0.75, 3),
...timbers(-s * 0.3, s * 0.6, s, 3), ...timbers(-s * 0.65, s * 0.55, s, 3),
...wheel(s * 0.75, s * 0.45, s * 0.15, 'x'),
...wheel(s * 0.75, s * 0.2, s * 0.15, 'x'),
], ],
height: s * 1.05, height: s * 1.05,
} }
} }
return { return {
faces: [ faces: [
...house(-s * 0.35, -s * 0.6, s * 1.3, s * 0.75, s * 0.65, s * 0.4, C.stone, C.slate), ...house(-s * 0.3, -s * 0.62, s * 1.35, s * 0.72, s * 0.62, s * 0.42, C.stone, C.slate),
...box(-s * 0.85, -s * 0.85, s * 0.14, s * 0.14, s * 0.75, s * 0.5, C.stoneDark), ...box(-s * 0.85, -s * 0.85, s * 0.14, s * 0.14, s * 0.75, s * 0.5, C.stoneDark),
...ram(-s * 0.45, s * 0.3, s * 0.11), ...ram(-s * 0.45, s * 0.42, s * 0.15),
...catapult(s * 0.55, s * 0.15, s * 0.12), ...catapult(s * 0.62, s * 0.25, s * 0.15),
...timbers(s * 0.05, s * 0.85, s, 3), ...wheels(s * 0.85, -s * 0.85, 2),
...wheel(s * 0.75, -s * 0.55, s * 0.15, 'x'), ...timbers(-s * 0.1, s * 0.92, s, 2),
...wheel(s * 0.75, -s * 0.3, s * 0.15, 'x'),
], ],
height: s * 1.2, height: s * 1.2,
} }