Add the A-frame pavement sign on a hinge whose origin is the pin, with a stay that collapses because both its links are driven rather than carried, and fix the support gate that reported it floating.
This commit is contained in:
parent
b305546964
commit
f6ed95ad1c
9 changed files with 829 additions and 21 deletions
20
PROGRESS.md
20
PROGRESS.md
|
|
@ -226,6 +226,20 @@ normal smoothing touches it, because the seam is in the colour rather than the
|
||||||
geometry. Squarer quads are the whole answer -- subdivide the long edges of the
|
geometry. Squarer quads are the whole answer -- subdivide the long edges of the
|
||||||
section as well as stepping the run.
|
section as well as stepping the run.
|
||||||
|
|
||||||
|
**The support gate was lying about anything hinged, and it took a hinged model
|
||||||
|
to find out.** `findFloating` based its occupancy grid on
|
||||||
|
`Box3.setFromObject(root)`, which is the box around each mesh's own box after
|
||||||
|
the world transform -- correct for an axis-aligned part and badly loose for a
|
||||||
|
rotated one. The A-frame sign's panels lean 19 degrees, the bound came out 64 mm
|
||||||
|
below the lowest real vertex, the grid's bottom six rows were therefore empty,
|
||||||
|
and a sign standing flat on the ground was reported as floating 61 mm in the
|
||||||
|
air. `check-model.ts` printed the same inflated figure as the model's height.
|
||||||
|
|
||||||
|
Both now pass `precise` and the whole kit re-verifies unchanged, so nothing was
|
||||||
|
depending on the loose number. Worth keeping in mind that this is the first row
|
||||||
|
whose action moves half the object: every gate written against parts that only
|
||||||
|
translate is worth re-reading the first time one rotates.
|
||||||
|
|
||||||
**Face the camera.** The bench was written with its front at -Z, which is a
|
**Face the camera.** The bench was written with its front at -Z, which is a
|
||||||
sensible drawing convention and means every one of the kit's renders was of
|
sensible drawing convention and means every one of the kit's renders was of
|
||||||
the back of it: the arch, the bolts and the rake were all on the far side.
|
the back of it: the arch, the bolts and the rake were all on the far side.
|
||||||
|
|
@ -423,10 +437,10 @@ asking GitHub Support to purge actually closes it.
|
||||||
|
|
||||||
## Open
|
## Open
|
||||||
|
|
||||||
- **`contemporary-props`**: 13 of the core 100 modelled, and they are the first
|
- **`contemporary-props`**: 14 of the core 100 modelled, and they are the first
|
||||||
rows of the build order rather than thirteen picked at random. The catalogue,
|
rows of the build order rather than fourteen picked at random. The catalogue,
|
||||||
the order, the cuts and the slot argument are in
|
the order, the cuts and the slot argument are in
|
||||||
`contemporary-props/CATALOGUE.md`; row 14 is `pavement-sign-board`.
|
`contemporary-props/CATALOGUE.md`; row 15 is `lectern`.
|
||||||
|
|
||||||
Rows 10 and 11 completed the kit's geometry vocabulary: there are now three
|
Rows 10 and 11 completed the kit's geometry vocabulary: there are now three
|
||||||
ways to make a solid and each is the only reasonable way to make a family.
|
ways to make a solid and each is the only reasonable way to make a family.
|
||||||
|
|
|
||||||
56
contemporary-props/models/pavement-sign-board/meta.json
Normal file
56
contemporary-props/models/pavement-sign-board/meta.json
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
{
|
||||||
|
"title": "A-frame Pavement Sign",
|
||||||
|
"description": "Two framed panels hinged at the top, with a collapsing stay between them and moulded feet on the stiles. The kit's first hinge with a real origin: one number folds the sign flat and keeps it standing on the ground while it does.",
|
||||||
|
"category": "Retail",
|
||||||
|
"tags": [
|
||||||
|
"contemporary",
|
||||||
|
"retail",
|
||||||
|
"street",
|
||||||
|
"procedural"
|
||||||
|
],
|
||||||
|
"controls": {
|
||||||
|
"panel": {
|
||||||
|
"type": "number",
|
||||||
|
"label": "Panel length",
|
||||||
|
"min": 0.5,
|
||||||
|
"max": 1.4,
|
||||||
|
"step": 0.01,
|
||||||
|
"unit": "m"
|
||||||
|
},
|
||||||
|
"width": {
|
||||||
|
"type": "number",
|
||||||
|
"label": "Panel width",
|
||||||
|
"min": 0.35,
|
||||||
|
"max": 1,
|
||||||
|
"step": 0.01,
|
||||||
|
"unit": "m"
|
||||||
|
},
|
||||||
|
"fold": {
|
||||||
|
"type": "number",
|
||||||
|
"label": "Fold",
|
||||||
|
"min": 0,
|
||||||
|
"max": 1,
|
||||||
|
"step": 0.05
|
||||||
|
},
|
||||||
|
"seed": {
|
||||||
|
"type": "number",
|
||||||
|
"label": "Variation seed",
|
||||||
|
"min": 1,
|
||||||
|
"max": 64,
|
||||||
|
"step": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"materialSlots": [
|
||||||
|
"steelPainted",
|
||||||
|
"plastic",
|
||||||
|
"rubber",
|
||||||
|
"stainless"
|
||||||
|
],
|
||||||
|
"parts": [
|
||||||
|
"front",
|
||||||
|
"back",
|
||||||
|
"hinges",
|
||||||
|
"stayFront",
|
||||||
|
"stayBack"
|
||||||
|
]
|
||||||
|
}
|
||||||
350
contemporary-props/models/pavement-sign-board/model.ts
Normal file
350
contemporary-props/models/pavement-sign-board/model.ts
Normal file
|
|
@ -0,0 +1,350 @@
|
||||||
|
/**
|
||||||
|
* @contemporary-props/pavement-sign-board
|
||||||
|
*
|
||||||
|
* The first hinge in the kit with a REAL ORIGIN, on the simplest body that
|
||||||
|
* could carry one, which is what the catalogue puts it fourteenth for.
|
||||||
|
*
|
||||||
|
* Every action before this one turned something small on a body that stayed
|
||||||
|
* put: a handwheel, a lever, a lid. This one moves half the object. That makes
|
||||||
|
* the origin the whole design problem rather than a detail of it, because a
|
||||||
|
* part rotates about its own anchor and nothing else -- so the anchor has to
|
||||||
|
* BE the hinge pin, and the geometry has to be built hanging from it.
|
||||||
|
*
|
||||||
|
* Each panel is therefore modelled in its own space with the pin at the origin
|
||||||
|
* and the board hanging down to -Lp. Not centred, not sitting on the ground:
|
||||||
|
* hanging. `fold` is then one number driving `rotation.x` on two parts and
|
||||||
|
* nothing else, and the closed pose is the open pose with that number at zero.
|
||||||
|
*
|
||||||
|
* The second thing the fold has to do is keep the sign ON THE GROUND. Folding
|
||||||
|
* an A-board makes it taller -- the panels stop leaning -- so an origin fixed
|
||||||
|
* at the open height buries the feet as it closes. The action moves the anchor
|
||||||
|
* up by `Lp cos(angle)` as it goes, which is the same trigonometry the pose is
|
||||||
|
* already made of.
|
||||||
|
*
|
||||||
|
* Measured off the reference against an A1 panel: 900 mm of board on a 620 mm
|
||||||
|
* width, 620 mm of foot spread, which puts the half angle at 19 degrees.
|
||||||
|
*/
|
||||||
|
import { type BufferGeometry } from 'three'
|
||||||
|
|
||||||
|
import {
|
||||||
|
bakeOcclusion,
|
||||||
|
chamferedBoxGeometry,
|
||||||
|
createKitModel,
|
||||||
|
createTinter,
|
||||||
|
latheGeometry,
|
||||||
|
mergeColoured,
|
||||||
|
smoothNormals,
|
||||||
|
} from '../core/index.ts'
|
||||||
|
|
||||||
|
export interface PavementSignConfig {
|
||||||
|
/** Length of a panel down its slope (metres). */
|
||||||
|
readonly panel: number
|
||||||
|
/** Width of a panel (metres). */
|
||||||
|
readonly width: number
|
||||||
|
/** How far the sign is folded, 0 open to 1 flat. */
|
||||||
|
readonly fold: number
|
||||||
|
readonly seed: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const pavementSignDefaults: PavementSignConfig = {
|
||||||
|
panel: 0.95,
|
||||||
|
// An A1 sheet is 594 wide, and the frame is what carries the extra.
|
||||||
|
width: 0.62,
|
||||||
|
fold: 0,
|
||||||
|
seed: 31,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PavementSignParts = 'front' | 'back' | 'hinges' | 'stayFront' | 'stayBack'
|
||||||
|
|
||||||
|
export interface PavementSignActions {
|
||||||
|
/** Folds the sign. 0 open, 1 flat. */
|
||||||
|
fold(amount?: number): void
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Half the splay, off the reference's 900 mm height over 620 mm of spread. */
|
||||||
|
const OPEN = 0.33
|
||||||
|
/** The frame's section through the panel. The stay hangs off its inner face. */
|
||||||
|
const SECTION_T = 0.024
|
||||||
|
/** Where the stay crosses, as a fraction of the panel down from the pin. */
|
||||||
|
const STAY_AT = 0.62
|
||||||
|
/** Half the stay: the open horizontal gap between one panel's face and the centre. */
|
||||||
|
const reachOf = (Lp: number): number =>
|
||||||
|
Lp * STAY_AT * Math.sin(OPEN) - (SECTION_T / 2) * Math.cos(OPEN)
|
||||||
|
|
||||||
|
export function createModel(overrides: Partial<PavementSignConfig> = {}) {
|
||||||
|
return createKitModel<
|
||||||
|
PavementSignConfig,
|
||||||
|
'steelPainted' | 'plastic' | 'rubber' | 'stainless',
|
||||||
|
PavementSignParts, PavementSignActions
|
||||||
|
>({
|
||||||
|
id: 'pavement-sign-board',
|
||||||
|
defaults: pavementSignDefaults,
|
||||||
|
slots: ['steelPainted', 'plastic', 'rubber', 'stainless'],
|
||||||
|
|
||||||
|
build: ({ config, random }) => {
|
||||||
|
const tint = createTinter(random)
|
||||||
|
const Lp = Math.min(1.4, Math.max(0.5, config.panel))
|
||||||
|
const W = Math.min(1, Math.max(0.35, config.width))
|
||||||
|
|
||||||
|
// The extruded section the whole frame is made of: 42 wide, 24 through.
|
||||||
|
const sw = 0.042
|
||||||
|
const st = SECTION_T
|
||||||
|
const halfW = W / 2
|
||||||
|
|
||||||
|
const black = tint('steelPainted', -0.3, 0.35)
|
||||||
|
const white = tint('plastic', 0.16, 0.25)
|
||||||
|
// Warmed off neutral, for the same reason the bench's bolts were: a small
|
||||||
|
// pale fitting on a black frame reads cold unless it is given a hue.
|
||||||
|
const chrome = tint('stainless', -0.02, 0.2).offsetHSL(0, -1, 0).offsetHSL(0.08, 0.08, 0)
|
||||||
|
|
||||||
|
const bar = (
|
||||||
|
x: number, y: number, z: number,
|
||||||
|
dx: number, dy: number, dz: number, colour = black,
|
||||||
|
): BufferGeometry => chamferedBoxGeometry(
|
||||||
|
[dx, dz], [dx, dz], dy, Math.min(dx, dy, dz) * 0.18, [0, 0, 0], colour,
|
||||||
|
).translate(x, y, z)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One panel, hanging from the pin at its own origin.
|
||||||
|
*
|
||||||
|
* Stiles run the full length and the rails sit BETWEEN them, which is
|
||||||
|
* how an extruded frame is actually cut and mitred; run the other way
|
||||||
|
* round the corners read as lapped and the section stops looking like
|
||||||
|
* one length of stock.
|
||||||
|
*/
|
||||||
|
const panel = (facing: number): {
|
||||||
|
frame: BufferGeometry[]
|
||||||
|
board: BufferGeometry[]
|
||||||
|
caps: BufferGeometry[]
|
||||||
|
leaves: BufferGeometry[]
|
||||||
|
} => {
|
||||||
|
const pieces: BufferGeometry[] = []
|
||||||
|
const caps: BufferGeometry[] = []
|
||||||
|
const board: BufferGeometry[] = []
|
||||||
|
const leaves: BufferGeometry[] = []
|
||||||
|
const stileX = halfW - sw / 2
|
||||||
|
const railTop = -sw / 2
|
||||||
|
// The stiles carry on past the bottom rail into the feet, which is the
|
||||||
|
// only thing keeping the frame off wet pavement. Measured off the
|
||||||
|
// reference at a twelfth of the panel. The critic asked for longer
|
||||||
|
// legs and then, on the longer legs, for shorter ones; a real board
|
||||||
|
// stands 70 to 80 mm off the pavement on a 900 mm panel, which is
|
||||||
|
// this, and is between the two things it asked for.
|
||||||
|
const footDrop = Lp * 0.09
|
||||||
|
const railBot = -Lp + footDrop + sw / 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The foot caps sit FLAT, and getting there is the picnic table's leg
|
||||||
|
* problem again in a different coordinate system.
|
||||||
|
*
|
||||||
|
* A cap modelled square to its stile is square to a member leaning 19
|
||||||
|
* degrees, so it meets the pavement on one edge and the sign stands on
|
||||||
|
* four lines. A moulded cap is level. Turning it by the panel's own
|
||||||
|
* angle inside the panel's own space cancels that angle exactly, and
|
||||||
|
* it is made deep enough to swallow the stile's mitred end behind it.
|
||||||
|
*/
|
||||||
|
const capH = Lp * 0.045
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
pieces.push(bar(side * stileX, -Lp / 2, 0, sw, Lp, st))
|
||||||
|
const cap = chamferedBoxGeometry(
|
||||||
|
[sw * 1.12, st * 1.12], [sw * 1.06, st * 1.06], capH, st * 0.12,
|
||||||
|
[0, 0, 0], tint('rubber', -0.04, 0.2),
|
||||||
|
)
|
||||||
|
cap.rotateX(facing * OPEN)
|
||||||
|
cap.translate(side * stileX, -Lp + capH / (2 * Math.cos(OPEN)), 0)
|
||||||
|
caps.push(cap)
|
||||||
|
}
|
||||||
|
pieces.push(bar(0, railTop, 0, W - sw * 2, sw, st))
|
||||||
|
pieces.push(bar(0, railBot, 0, W - sw * 2, sw, st))
|
||||||
|
|
||||||
|
// The insert: a sheet set into the frame's inner face, so the frame
|
||||||
|
// stands proud of it on the outside exactly as the reference's does.
|
||||||
|
const inset = sw * 0.55
|
||||||
|
board.push(bar(
|
||||||
|
0, (railTop + railBot) / 2, facing * (st / 2 - 0.004),
|
||||||
|
W - inset * 2, railTop - railBot - inset * 0.6, 0.005, white,
|
||||||
|
))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A hinge LEAF, and it belongs to the panel it is screwed to.
|
||||||
|
*
|
||||||
|
* Only the knuckle is on the axis; the two leaves turn with their own
|
||||||
|
* panels, which is what a butt hinge is. Built into the fixed part
|
||||||
|
* instead they stay put while the panels swing out from under them.
|
||||||
|
*/
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
leaves.push(bar(
|
||||||
|
side * W * 0.26, -0.019, facing * (st / 2 + 0.0016),
|
||||||
|
W * 0.082, 0.032, 0.003, chrome,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
bakeOcclusion(pieces, { strength: 0.35 })
|
||||||
|
return { frame: pieces, board, caps, leaves }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hinges, and they do NOT move.
|
||||||
|
*
|
||||||
|
* A butt hinge's knuckle is the axis, so it sits on the pin and stays
|
||||||
|
* there through the whole fold while both leaves turn under it. Making
|
||||||
|
* it part of a panel would have it orbit the thing it is supposed to be
|
||||||
|
* the centre of.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* The stay is a REAL LINKAGE, and it took a wrong answer to get there.
|
||||||
|
*
|
||||||
|
* A pavement sign's stay is one bar with a pin in its middle: two links
|
||||||
|
* that go straight when the sign is open and collapse between the panels
|
||||||
|
* when it shuts. The first cut made each link a rigid part of its panel,
|
||||||
|
* on the reasoning that they would overlap harmlessly in the gap. They do
|
||||||
|
* not. With the panels vertical each link points sideways rather than
|
||||||
|
* into any gap, and the folded sign measured 386 mm through a body that
|
||||||
|
* should be 50 mm thick.
|
||||||
|
*
|
||||||
|
* So each link is its own part, hanging along -Y from a pin at its
|
||||||
|
* origin, and the fold drives BOTH its position and its angle: the
|
||||||
|
* anchor rides to wherever its panel's face has carried the pin, and the
|
||||||
|
* link swings to point at the knuckle on the centre plane. The knuckle
|
||||||
|
* is wherever a link of fixed length can reach it, which is the whole of
|
||||||
|
* the arithmetic and the whole of why the thing collapses.
|
||||||
|
*/
|
||||||
|
const reach = reachOf(Lp)
|
||||||
|
const stay = (pin: boolean): BufferGeometry => {
|
||||||
|
/*
|
||||||
|
* Wider and lighter than the frame, and both are about being SEEN.
|
||||||
|
*
|
||||||
|
* Measured, the pair spans the gap exactly: -0.180 to +0.180 with the
|
||||||
|
* pin at zero, panel face to panel face. It was reported missing three
|
||||||
|
* rounds running anyway, because a black bar nine millimetres thick,
|
||||||
|
* in the shadow between two panels, is four pixels of a render. The
|
||||||
|
* geometry never needed changing; what needed changing was whether
|
||||||
|
* anything could tell.
|
||||||
|
*/
|
||||||
|
const link = chamferedBoxGeometry(
|
||||||
|
[0.034, 0.013], [0.034, 0.013], reach, 0.003, [0, 0, 0],
|
||||||
|
tint('steelPainted', -0.12, 0.3),
|
||||||
|
).translate(0, -reach / 2, 0)
|
||||||
|
if (!pin) return link
|
||||||
|
// The pin at the far end, on one link only, because there is one pin
|
||||||
|
// and two links. Without it the pair meets end to end with nothing
|
||||||
|
// marking the joint and reads as a bar that stops halfway across --
|
||||||
|
// which is exactly what the critic saw, on geometry that measured
|
||||||
|
// correct to the millimetre.
|
||||||
|
const boss = latheGeometry([
|
||||||
|
{ y: -0.008, radius: 0.006 },
|
||||||
|
{ y: 0.008, radius: 0.006 },
|
||||||
|
], 10, [0, 0, 0], chrome, { capBottom: true, capTop: true })
|
||||||
|
boss.rotateX(Math.PI / 2)
|
||||||
|
boss.translate(0, -reach, 0)
|
||||||
|
return mergeColoured([link, boss])
|
||||||
|
}
|
||||||
|
|
||||||
|
const hingePieces: BufferGeometry[] = []
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
const knuckle = latheGeometry([
|
||||||
|
{ y: -W * 0.046, radius: 0.008 },
|
||||||
|
{ y: W * 0.046, radius: 0.008 },
|
||||||
|
], 12, [0, 0, 0], chrome, { capBottom: true, capTop: true })
|
||||||
|
knuckle.rotateZ(Math.PI / 2)
|
||||||
|
knuckle.translate(side * W * 0.26, 0.004, 0)
|
||||||
|
hingePieces.push(knuckle)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The insert and the caps ride the panel as EXTRAS rather than as vertex
|
||||||
|
* colours on the frame.
|
||||||
|
*
|
||||||
|
* They are different materials -- a printed sheet and a moulded foot on
|
||||||
|
* an aluminium extrusion -- and a consumer who swaps `steelPainted` for
|
||||||
|
* their own paint should not repaint the sign face with it. An extra
|
||||||
|
* carries its own slot and follows its part through the fold, which is
|
||||||
|
* exactly the relationship these three have.
|
||||||
|
*/
|
||||||
|
const side = (facing: number) => {
|
||||||
|
const { frame, board, caps, leaves } = panel(facing)
|
||||||
|
return {
|
||||||
|
slot: 'steelPainted' as const,
|
||||||
|
geometry: smoothNormals(mergeColoured(frame), 24),
|
||||||
|
origin: [0, Lp * Math.cos(OPEN), 0] as const,
|
||||||
|
extras: [
|
||||||
|
{ slot: 'plastic' as const, geometry: smoothNormals(mergeColoured(board), 30) },
|
||||||
|
{ slot: 'rubber' as const, geometry: smoothNormals(mergeColoured(caps), 24) },
|
||||||
|
{ slot: 'stainless' as const, geometry: smoothNormals(mergeColoured(leaves), 30) },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const stayOrigin = (facing: number): readonly [number, number, number] => {
|
||||||
|
const rot = -facing * OPEN
|
||||||
|
return [
|
||||||
|
0,
|
||||||
|
Lp * Math.cos(OPEN) + -Lp * STAY_AT * Math.cos(rot) - ((-facing * st) / 2) * Math.sin(rot),
|
||||||
|
-Lp * STAY_AT * Math.sin(rot) + ((-facing * st) / 2) * Math.cos(rot),
|
||||||
|
] as const
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
front: side(-1),
|
||||||
|
back: side(1),
|
||||||
|
stayFront: {
|
||||||
|
slot: 'steelPainted' as const,
|
||||||
|
geometry: smoothNormals(stay(true), 24),
|
||||||
|
origin: stayOrigin(-1),
|
||||||
|
},
|
||||||
|
stayBack: {
|
||||||
|
slot: 'steelPainted' as const,
|
||||||
|
geometry: smoothNormals(stay(false), 24),
|
||||||
|
origin: stayOrigin(1),
|
||||||
|
},
|
||||||
|
hinges: {
|
||||||
|
slot: 'stainless' as const,
|
||||||
|
geometry: smoothNormals(mergeColoured(hingePieces), 30),
|
||||||
|
origin: [0, Lp * Math.cos(OPEN), 0] as const,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: ({ parts, getConfig }) => {
|
||||||
|
const set = (amount: number): void => {
|
||||||
|
const t = Math.min(1, Math.max(0, amount))
|
||||||
|
const angle = OPEN * (1 - t)
|
||||||
|
parts.front.anchor.rotation.x = angle
|
||||||
|
parts.back.anchor.rotation.x = -angle
|
||||||
|
// ...and the pin rises as the panels straighten, because a folded
|
||||||
|
// A-board is taller than an open one and an origin left at the open
|
||||||
|
// height buries the feet.
|
||||||
|
const Lp = Math.min(1.4, Math.max(0.5, getConfig().panel))
|
||||||
|
const hingeY = Lp * Math.cos(angle)
|
||||||
|
for (const part of [parts.front, parts.back, parts.hinges]) {
|
||||||
|
part.anchor.position.setY(hingeY)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ...and then the stay follows, which is two numbers per link.
|
||||||
|
*
|
||||||
|
* The pin sits on the panel's inner face `STAY_AT` of the way down, so
|
||||||
|
* where it ENDS UP is the panel's own rotation applied to that point.
|
||||||
|
* The knuckle is on the centre plane at whatever height a link of
|
||||||
|
* fixed length can still reach from there -- which is what makes the
|
||||||
|
* pair go straight when open and hang when shut, with no case
|
||||||
|
* analysis and no clamp.
|
||||||
|
*/
|
||||||
|
const reach = reachOf(Lp)
|
||||||
|
for (const [part, facing] of [[parts.stayFront, -1], [parts.stayBack, 1]] as const) {
|
||||||
|
const rot = -facing * angle
|
||||||
|
const ly = -Lp * STAY_AT
|
||||||
|
const lz = (-facing * SECTION_T) / 2
|
||||||
|
const ay = hingeY + ly * Math.cos(rot) - lz * Math.sin(rot)
|
||||||
|
const az = ly * Math.sin(rot) + lz * Math.cos(rot)
|
||||||
|
part.anchor.position.set(0, ay, az)
|
||||||
|
// Built hanging along -Y, so the angle that points it at the knuckle
|
||||||
|
// is measured from straight down.
|
||||||
|
part.anchor.rotation.x = Math.atan2(az, Math.sqrt(Math.max(0, reach * reach - az * az)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set(getConfig().fold)
|
||||||
|
return { fold: (amount = 1) => { set(amount) } }
|
||||||
|
},
|
||||||
|
}, overrides)
|
||||||
|
}
|
||||||
|
|
@ -677,7 +677,7 @@
|
||||||
"address": "@contemporary-props/core",
|
"address": "@contemporary-props/core",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.186Z",
|
"installedAt": "2026-09-01T23:54:44.902Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\core\\geometry.ts",
|
"path": "src\\models\\contemporary-props\\core\\geometry.ts",
|
||||||
|
|
@ -724,7 +724,7 @@
|
||||||
"address": "@contemporary-props/ceramic-vase",
|
"address": "@contemporary-props/ceramic-vase",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.188Z",
|
"installedAt": "2026-09-01T23:54:44.904Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\ceramic-vase\\model.ts",
|
"path": "src\\models\\contemporary-props\\ceramic-vase\\model.ts",
|
||||||
|
|
@ -739,7 +739,7 @@
|
||||||
"address": "@contemporary-props/coffee-mug",
|
"address": "@contemporary-props/coffee-mug",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.189Z",
|
"installedAt": "2026-09-01T23:54:44.905Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\coffee-mug\\model.ts",
|
"path": "src\\models\\contemporary-props\\coffee-mug\\model.ts",
|
||||||
|
|
@ -754,7 +754,7 @@
|
||||||
"address": "@contemporary-props/pepper-mill",
|
"address": "@contemporary-props/pepper-mill",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.196Z",
|
"installedAt": "2026-09-01T23:54:44.914Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\pepper-mill\\model.ts",
|
"path": "src\\models\\contemporary-props\\pepper-mill\\model.ts",
|
||||||
|
|
@ -769,7 +769,7 @@
|
||||||
"address": "@contemporary-props/stockpot",
|
"address": "@contemporary-props/stockpot",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.199Z",
|
"installedAt": "2026-09-01T23:54:44.916Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\stockpot\\model.ts",
|
"path": "src\\models\\contemporary-props\\stockpot\\model.ts",
|
||||||
|
|
@ -784,7 +784,7 @@
|
||||||
"address": "@contemporary-props/traffic-cone",
|
"address": "@contemporary-props/traffic-cone",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.202Z",
|
"installedAt": "2026-09-01T23:54:44.919Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\traffic-cone\\model.ts",
|
"path": "src\\models\\contemporary-props\\traffic-cone\\model.ts",
|
||||||
|
|
@ -799,7 +799,7 @@
|
||||||
"address": "@contemporary-props/wine-glass",
|
"address": "@contemporary-props/wine-glass",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.203Z",
|
"installedAt": "2026-09-01T23:54:44.920Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\wine-glass\\model.ts",
|
"path": "src\\models\\contemporary-props\\wine-glass\\model.ts",
|
||||||
|
|
@ -814,7 +814,7 @@
|
||||||
"address": "@contemporary-props/kit",
|
"address": "@contemporary-props/kit",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.203Z",
|
"installedAt": "2026-09-01T23:54:44.920Z",
|
||||||
"files": [],
|
"files": [],
|
||||||
"dependencies": []
|
"dependencies": []
|
||||||
},
|
},
|
||||||
|
|
@ -822,7 +822,7 @@
|
||||||
"address": "@contemporary-props/street-bollard",
|
"address": "@contemporary-props/street-bollard",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.200Z",
|
"installedAt": "2026-09-01T23:54:44.918Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\street-bollard\\model.ts",
|
"path": "src\\models\\contemporary-props\\street-bollard\\model.ts",
|
||||||
|
|
@ -837,7 +837,7 @@
|
||||||
"address": "@contemporary-props/gas-cylinder",
|
"address": "@contemporary-props/gas-cylinder",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.192Z",
|
"installedAt": "2026-09-01T23:54:44.908Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\gas-cylinder\\model.ts",
|
"path": "src\\models\\contemporary-props\\gas-cylinder\\model.ts",
|
||||||
|
|
@ -852,7 +852,7 @@
|
||||||
"address": "@contemporary-props/fire-extinguisher",
|
"address": "@contemporary-props/fire-extinguisher",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.190Z",
|
"installedAt": "2026-09-01T23:54:44.907Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\fire-extinguisher\\model.ts",
|
"path": "src\\models\\contemporary-props\\fire-extinguisher\\model.ts",
|
||||||
|
|
@ -867,7 +867,7 @@
|
||||||
"address": "@contemporary-props/pedestal-basin",
|
"address": "@contemporary-props/pedestal-basin",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.195Z",
|
"installedAt": "2026-09-01T23:54:44.913Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\pedestal-basin\\model.ts",
|
"path": "src\\models\\contemporary-props\\pedestal-basin\\model.ts",
|
||||||
|
|
@ -882,7 +882,7 @@
|
||||||
"address": "@contemporary-props/jersey-barrier",
|
"address": "@contemporary-props/jersey-barrier",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.193Z",
|
"installedAt": "2026-09-01T23:54:44.909Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\jersey-barrier\\model.ts",
|
"path": "src\\models\\contemporary-props\\jersey-barrier\\model.ts",
|
||||||
|
|
@ -897,7 +897,7 @@
|
||||||
"address": "@contemporary-props/picnic-table",
|
"address": "@contemporary-props/picnic-table",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.198Z",
|
"installedAt": "2026-09-01T23:54:44.915Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\picnic-table\\model.ts",
|
"path": "src\\models\\contemporary-props\\picnic-table\\model.ts",
|
||||||
|
|
@ -912,7 +912,7 @@
|
||||||
"address": "@contemporary-props/park-bench",
|
"address": "@contemporary-props/park-bench",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-01T19:45:03.194Z",
|
"installedAt": "2026-09-01T23:54:44.910Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\park-bench\\model.ts",
|
"path": "src\\models\\contemporary-props\\park-bench\\model.ts",
|
||||||
|
|
@ -922,6 +922,21 @@
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"three@>=0.185.0"
|
"three@>=0.185.0"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"@contemporary-props/pavement-sign-board": {
|
||||||
|
"address": "@contemporary-props/pavement-sign-board",
|
||||||
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
|
"version": "workspace",
|
||||||
|
"installedAt": "2026-09-01T23:54:44.912Z",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"path": "src\\models\\contemporary-props\\pavement-sign-board\\model.ts",
|
||||||
|
"sourceHash": "4ff1598806e5a049dd1e6d7a286b39bd905992e4d20c11272e6f4c0d32002fa8"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": [
|
||||||
|
"three@>=0.185.0"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,10 @@ model.root.traverse((object) => {
|
||||||
if (slot) slots.add(slot)
|
if (slot) slots.add(slot)
|
||||||
})
|
})
|
||||||
|
|
||||||
const box = new Box3().setFromObject(model.root)
|
// Precise, for the same reason `support.ts` is: the loose bound is the box
|
||||||
|
// around each part's own rotated box, and it reported the A-frame sign 62 mm
|
||||||
|
// taller than its tallest vertex.
|
||||||
|
const box = new Box3().setFromObject(model.root, true)
|
||||||
const extent = box.getSize(new Vector3())
|
const extent = box.getSize(new Vector3())
|
||||||
const support = findFloating(model.root, { resolution: 96 })
|
const support = findFloating(model.root, { resolution: 96 })
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,9 @@ const HINT: Record<string, string> = {
|
||||||
// "cast side frames" is the catalogue's own word for this row, so the metal
|
// "cast side frames" is the catalogue's own word for this row, so the metal
|
||||||
// is the catalogue's call rather than the hint's.
|
// is the catalogue's call rather than the hint's.
|
||||||
'park-bench': 'a municipal park bench: horizontal timber slats on two cast iron end frames, seen from the front and side',
|
'park-bench': 'a municipal park bench: horizontal timber slats on two cast iron end frames, seen from the front and side',
|
||||||
|
// Form only, no material: the catalogue does not name one for this row, and
|
||||||
|
// a hint that invents one decides what the model becomes.
|
||||||
|
'pavement-sign-board': 'an A-frame pavement sign board (sandwich board) standing open, both panels blank, seen from the front and side',
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,20 @@ export function findFloating(root: Object3D, options: SupportOptions = {}): Supp
|
||||||
const mode = options.support ?? 'ground'
|
const mode = options.support ?? 'ground'
|
||||||
|
|
||||||
root.updateMatrixWorld(true)
|
root.updateMatrixWorld(true)
|
||||||
const box = new Box3().setFromObject(root)
|
/*
|
||||||
|
* PRECISE. The flag is the whole difference between this check working and
|
||||||
|
* this check lying about hinged models.
|
||||||
|
*
|
||||||
|
* Without it `setFromObject` takes each mesh's own axis-aligned box and
|
||||||
|
* transforms THAT by the world matrix, so a rotated part contributes the box
|
||||||
|
* around its rotated box. The A-frame sign's panels lean 19 degrees and the
|
||||||
|
* bound came out 64 mm below the lowest real vertex; the occupancy grid is
|
||||||
|
* based at `box.min.y`, so its bottom six rows were empty and the ground
|
||||||
|
* test reported a sign resting flat on the pavement as floating 61 mm in the
|
||||||
|
* air. Every model with a rotated anchor was going to hit this, and from the
|
||||||
|
* fourteenth row on that is most of them.
|
||||||
|
*/
|
||||||
|
const box = new Box3().setFromObject(root, true)
|
||||||
const size = box.getSize(new Vector3())
|
const size = box.getSize(new Vector3())
|
||||||
const extent = Math.max(size.x, size.y, size.z, 1e-4)
|
const extent = Math.max(size.x, size.y, size.z, 1e-4)
|
||||||
const voxel = extent / resolution
|
const voxel = extent / resolution
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ import { createModel as createCpPedestalBasin } from '@/models/contemporary-prop
|
||||||
import { createModel as createCpJerseyBarrier } from '@/models/contemporary-props/jersey-barrier/model.ts'
|
import { createModel as createCpJerseyBarrier } from '@/models/contemporary-props/jersey-barrier/model.ts'
|
||||||
import { createModel as createCpPicnicTable } from '@/models/contemporary-props/picnic-table/model.ts'
|
import { createModel as createCpPicnicTable } from '@/models/contemporary-props/picnic-table/model.ts'
|
||||||
import { createModel as createCpParkBench } from '@/models/contemporary-props/park-bench/model.ts'
|
import { createModel as createCpParkBench } from '@/models/contemporary-props/park-bench/model.ts'
|
||||||
|
import { createModel as createCpPavementSign } from '@/models/contemporary-props/pavement-sign-board/model.ts'
|
||||||
import cpMetaCeramicVase from '../contemporary-props/models/ceramic-vase/meta.json'
|
import cpMetaCeramicVase from '../contemporary-props/models/ceramic-vase/meta.json'
|
||||||
import cpMetaCoffeeMug from '../contemporary-props/models/coffee-mug/meta.json'
|
import cpMetaCoffeeMug from '../contemporary-props/models/coffee-mug/meta.json'
|
||||||
import cpMetaWineGlass from '../contemporary-props/models/wine-glass/meta.json'
|
import cpMetaWineGlass from '../contemporary-props/models/wine-glass/meta.json'
|
||||||
|
|
@ -77,6 +78,7 @@ import cpMetaPedestalBasin from '../contemporary-props/models/pedestal-basin/met
|
||||||
import cpMetaJerseyBarrier from '../contemporary-props/models/jersey-barrier/meta.json'
|
import cpMetaJerseyBarrier from '../contemporary-props/models/jersey-barrier/meta.json'
|
||||||
import cpMetaPicnicTable from '../contemporary-props/models/picnic-table/meta.json'
|
import cpMetaPicnicTable from '../contemporary-props/models/picnic-table/meta.json'
|
||||||
import cpMetaParkBench from '../contemporary-props/models/park-bench/meta.json'
|
import cpMetaParkBench from '../contemporary-props/models/park-bench/meta.json'
|
||||||
|
import cpMetaPavementSign from '../contemporary-props/models/pavement-sign-board/meta.json'
|
||||||
import { createModel as createShield } from '@/models/medieval-kit/round-shield/model.ts'
|
import { createModel as createShield } from '@/models/medieval-kit/round-shield/model.ts'
|
||||||
import { createModel as createForge } from '@/models/medieval-kit/forge-hearth/model.ts'
|
import { createModel as createForge } from '@/models/medieval-kit/forge-hearth/model.ts'
|
||||||
import { createModel as createTrough } from '@/models/medieval-kit/stone-trough/model.ts'
|
import { createModel as createTrough } from '@/models/medieval-kit/stone-trough/model.ts'
|
||||||
|
|
@ -292,7 +294,7 @@ const CONTEMPORARY_ORDER = [
|
||||||
'ceramic-vase', 'coffee-mug', 'wine-glass', 'pepper-mill',
|
'ceramic-vase', 'coffee-mug', 'wine-glass', 'pepper-mill',
|
||||||
'stockpot', 'traffic-cone', 'street-bollard', 'gas-cylinder',
|
'stockpot', 'traffic-cone', 'street-bollard', 'gas-cylinder',
|
||||||
'fire-extinguisher', 'pedestal-basin', 'jersey-barrier',
|
'fire-extinguisher', 'pedestal-basin', 'jersey-barrier',
|
||||||
'picnic-table', 'park-bench',
|
'picnic-table', 'park-bench', 'pavement-sign-board',
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
const CONTEMPORARY_FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
const CONTEMPORARY_FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
||||||
|
|
@ -309,6 +311,7 @@ const CONTEMPORARY_FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
||||||
'jersey-barrier': as(createCpJerseyBarrier),
|
'jersey-barrier': as(createCpJerseyBarrier),
|
||||||
'picnic-table': as(createCpPicnicTable),
|
'picnic-table': as(createCpPicnicTable),
|
||||||
'park-bench': as(createCpParkBench),
|
'park-bench': as(createCpParkBench),
|
||||||
|
'pavement-sign-board': as(createCpPavementSign),
|
||||||
}
|
}
|
||||||
|
|
||||||
const CONTEMPORARY_META: Readonly<Record<string, ModelMetaLike>> = {
|
const CONTEMPORARY_META: Readonly<Record<string, ModelMetaLike>> = {
|
||||||
|
|
@ -325,6 +328,7 @@ const CONTEMPORARY_META: Readonly<Record<string, ModelMetaLike>> = {
|
||||||
'jersey-barrier': cpMetaJerseyBarrier as ModelMetaLike,
|
'jersey-barrier': cpMetaJerseyBarrier as ModelMetaLike,
|
||||||
'picnic-table': cpMetaPicnicTable as ModelMetaLike,
|
'picnic-table': cpMetaPicnicTable as ModelMetaLike,
|
||||||
'park-bench': cpMetaParkBench as ModelMetaLike,
|
'park-bench': cpMetaParkBench as ModelMetaLike,
|
||||||
|
'pavement-sign-board': cpMetaPavementSign as ModelMetaLike,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
350
src/models/contemporary-props/pavement-sign-board/model.ts
Normal file
350
src/models/contemporary-props/pavement-sign-board/model.ts
Normal file
|
|
@ -0,0 +1,350 @@
|
||||||
|
/**
|
||||||
|
* @contemporary-props/pavement-sign-board
|
||||||
|
*
|
||||||
|
* The first hinge in the kit with a REAL ORIGIN, on the simplest body that
|
||||||
|
* could carry one, which is what the catalogue puts it fourteenth for.
|
||||||
|
*
|
||||||
|
* Every action before this one turned something small on a body that stayed
|
||||||
|
* put: a handwheel, a lever, a lid. This one moves half the object. That makes
|
||||||
|
* the origin the whole design problem rather than a detail of it, because a
|
||||||
|
* part rotates about its own anchor and nothing else -- so the anchor has to
|
||||||
|
* BE the hinge pin, and the geometry has to be built hanging from it.
|
||||||
|
*
|
||||||
|
* Each panel is therefore modelled in its own space with the pin at the origin
|
||||||
|
* and the board hanging down to -Lp. Not centred, not sitting on the ground:
|
||||||
|
* hanging. `fold` is then one number driving `rotation.x` on two parts and
|
||||||
|
* nothing else, and the closed pose is the open pose with that number at zero.
|
||||||
|
*
|
||||||
|
* The second thing the fold has to do is keep the sign ON THE GROUND. Folding
|
||||||
|
* an A-board makes it taller -- the panels stop leaning -- so an origin fixed
|
||||||
|
* at the open height buries the feet as it closes. The action moves the anchor
|
||||||
|
* up by `Lp cos(angle)` as it goes, which is the same trigonometry the pose is
|
||||||
|
* already made of.
|
||||||
|
*
|
||||||
|
* Measured off the reference against an A1 panel: 900 mm of board on a 620 mm
|
||||||
|
* width, 620 mm of foot spread, which puts the half angle at 19 degrees.
|
||||||
|
*/
|
||||||
|
import { type BufferGeometry } from 'three'
|
||||||
|
|
||||||
|
import {
|
||||||
|
bakeOcclusion,
|
||||||
|
chamferedBoxGeometry,
|
||||||
|
createKitModel,
|
||||||
|
createTinter,
|
||||||
|
latheGeometry,
|
||||||
|
mergeColoured,
|
||||||
|
smoothNormals,
|
||||||
|
} from '../core/index.ts'
|
||||||
|
|
||||||
|
export interface PavementSignConfig {
|
||||||
|
/** Length of a panel down its slope (metres). */
|
||||||
|
readonly panel: number
|
||||||
|
/** Width of a panel (metres). */
|
||||||
|
readonly width: number
|
||||||
|
/** How far the sign is folded, 0 open to 1 flat. */
|
||||||
|
readonly fold: number
|
||||||
|
readonly seed: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const pavementSignDefaults: PavementSignConfig = {
|
||||||
|
panel: 0.95,
|
||||||
|
// An A1 sheet is 594 wide, and the frame is what carries the extra.
|
||||||
|
width: 0.62,
|
||||||
|
fold: 0,
|
||||||
|
seed: 31,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PavementSignParts = 'front' | 'back' | 'hinges' | 'stayFront' | 'stayBack'
|
||||||
|
|
||||||
|
export interface PavementSignActions {
|
||||||
|
/** Folds the sign. 0 open, 1 flat. */
|
||||||
|
fold(amount?: number): void
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Half the splay, off the reference's 900 mm height over 620 mm of spread. */
|
||||||
|
const OPEN = 0.33
|
||||||
|
/** The frame's section through the panel. The stay hangs off its inner face. */
|
||||||
|
const SECTION_T = 0.024
|
||||||
|
/** Where the stay crosses, as a fraction of the panel down from the pin. */
|
||||||
|
const STAY_AT = 0.62
|
||||||
|
/** Half the stay: the open horizontal gap between one panel's face and the centre. */
|
||||||
|
const reachOf = (Lp: number): number =>
|
||||||
|
Lp * STAY_AT * Math.sin(OPEN) - (SECTION_T / 2) * Math.cos(OPEN)
|
||||||
|
|
||||||
|
export function createModel(overrides: Partial<PavementSignConfig> = {}) {
|
||||||
|
return createKitModel<
|
||||||
|
PavementSignConfig,
|
||||||
|
'steelPainted' | 'plastic' | 'rubber' | 'stainless',
|
||||||
|
PavementSignParts, PavementSignActions
|
||||||
|
>({
|
||||||
|
id: 'pavement-sign-board',
|
||||||
|
defaults: pavementSignDefaults,
|
||||||
|
slots: ['steelPainted', 'plastic', 'rubber', 'stainless'],
|
||||||
|
|
||||||
|
build: ({ config, random }) => {
|
||||||
|
const tint = createTinter(random)
|
||||||
|
const Lp = Math.min(1.4, Math.max(0.5, config.panel))
|
||||||
|
const W = Math.min(1, Math.max(0.35, config.width))
|
||||||
|
|
||||||
|
// The extruded section the whole frame is made of: 42 wide, 24 through.
|
||||||
|
const sw = 0.042
|
||||||
|
const st = SECTION_T
|
||||||
|
const halfW = W / 2
|
||||||
|
|
||||||
|
const black = tint('steelPainted', -0.3, 0.35)
|
||||||
|
const white = tint('plastic', 0.16, 0.25)
|
||||||
|
// Warmed off neutral, for the same reason the bench's bolts were: a small
|
||||||
|
// pale fitting on a black frame reads cold unless it is given a hue.
|
||||||
|
const chrome = tint('stainless', -0.02, 0.2).offsetHSL(0, -1, 0).offsetHSL(0.08, 0.08, 0)
|
||||||
|
|
||||||
|
const bar = (
|
||||||
|
x: number, y: number, z: number,
|
||||||
|
dx: number, dy: number, dz: number, colour = black,
|
||||||
|
): BufferGeometry => chamferedBoxGeometry(
|
||||||
|
[dx, dz], [dx, dz], dy, Math.min(dx, dy, dz) * 0.18, [0, 0, 0], colour,
|
||||||
|
).translate(x, y, z)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One panel, hanging from the pin at its own origin.
|
||||||
|
*
|
||||||
|
* Stiles run the full length and the rails sit BETWEEN them, which is
|
||||||
|
* how an extruded frame is actually cut and mitred; run the other way
|
||||||
|
* round the corners read as lapped and the section stops looking like
|
||||||
|
* one length of stock.
|
||||||
|
*/
|
||||||
|
const panel = (facing: number): {
|
||||||
|
frame: BufferGeometry[]
|
||||||
|
board: BufferGeometry[]
|
||||||
|
caps: BufferGeometry[]
|
||||||
|
leaves: BufferGeometry[]
|
||||||
|
} => {
|
||||||
|
const pieces: BufferGeometry[] = []
|
||||||
|
const caps: BufferGeometry[] = []
|
||||||
|
const board: BufferGeometry[] = []
|
||||||
|
const leaves: BufferGeometry[] = []
|
||||||
|
const stileX = halfW - sw / 2
|
||||||
|
const railTop = -sw / 2
|
||||||
|
// The stiles carry on past the bottom rail into the feet, which is the
|
||||||
|
// only thing keeping the frame off wet pavement. Measured off the
|
||||||
|
// reference at a twelfth of the panel. The critic asked for longer
|
||||||
|
// legs and then, on the longer legs, for shorter ones; a real board
|
||||||
|
// stands 70 to 80 mm off the pavement on a 900 mm panel, which is
|
||||||
|
// this, and is between the two things it asked for.
|
||||||
|
const footDrop = Lp * 0.09
|
||||||
|
const railBot = -Lp + footDrop + sw / 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The foot caps sit FLAT, and getting there is the picnic table's leg
|
||||||
|
* problem again in a different coordinate system.
|
||||||
|
*
|
||||||
|
* A cap modelled square to its stile is square to a member leaning 19
|
||||||
|
* degrees, so it meets the pavement on one edge and the sign stands on
|
||||||
|
* four lines. A moulded cap is level. Turning it by the panel's own
|
||||||
|
* angle inside the panel's own space cancels that angle exactly, and
|
||||||
|
* it is made deep enough to swallow the stile's mitred end behind it.
|
||||||
|
*/
|
||||||
|
const capH = Lp * 0.045
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
pieces.push(bar(side * stileX, -Lp / 2, 0, sw, Lp, st))
|
||||||
|
const cap = chamferedBoxGeometry(
|
||||||
|
[sw * 1.12, st * 1.12], [sw * 1.06, st * 1.06], capH, st * 0.12,
|
||||||
|
[0, 0, 0], tint('rubber', -0.04, 0.2),
|
||||||
|
)
|
||||||
|
cap.rotateX(facing * OPEN)
|
||||||
|
cap.translate(side * stileX, -Lp + capH / (2 * Math.cos(OPEN)), 0)
|
||||||
|
caps.push(cap)
|
||||||
|
}
|
||||||
|
pieces.push(bar(0, railTop, 0, W - sw * 2, sw, st))
|
||||||
|
pieces.push(bar(0, railBot, 0, W - sw * 2, sw, st))
|
||||||
|
|
||||||
|
// The insert: a sheet set into the frame's inner face, so the frame
|
||||||
|
// stands proud of it on the outside exactly as the reference's does.
|
||||||
|
const inset = sw * 0.55
|
||||||
|
board.push(bar(
|
||||||
|
0, (railTop + railBot) / 2, facing * (st / 2 - 0.004),
|
||||||
|
W - inset * 2, railTop - railBot - inset * 0.6, 0.005, white,
|
||||||
|
))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A hinge LEAF, and it belongs to the panel it is screwed to.
|
||||||
|
*
|
||||||
|
* Only the knuckle is on the axis; the two leaves turn with their own
|
||||||
|
* panels, which is what a butt hinge is. Built into the fixed part
|
||||||
|
* instead they stay put while the panels swing out from under them.
|
||||||
|
*/
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
leaves.push(bar(
|
||||||
|
side * W * 0.26, -0.019, facing * (st / 2 + 0.0016),
|
||||||
|
W * 0.082, 0.032, 0.003, chrome,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
bakeOcclusion(pieces, { strength: 0.35 })
|
||||||
|
return { frame: pieces, board, caps, leaves }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hinges, and they do NOT move.
|
||||||
|
*
|
||||||
|
* A butt hinge's knuckle is the axis, so it sits on the pin and stays
|
||||||
|
* there through the whole fold while both leaves turn under it. Making
|
||||||
|
* it part of a panel would have it orbit the thing it is supposed to be
|
||||||
|
* the centre of.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* The stay is a REAL LINKAGE, and it took a wrong answer to get there.
|
||||||
|
*
|
||||||
|
* A pavement sign's stay is one bar with a pin in its middle: two links
|
||||||
|
* that go straight when the sign is open and collapse between the panels
|
||||||
|
* when it shuts. The first cut made each link a rigid part of its panel,
|
||||||
|
* on the reasoning that they would overlap harmlessly in the gap. They do
|
||||||
|
* not. With the panels vertical each link points sideways rather than
|
||||||
|
* into any gap, and the folded sign measured 386 mm through a body that
|
||||||
|
* should be 50 mm thick.
|
||||||
|
*
|
||||||
|
* So each link is its own part, hanging along -Y from a pin at its
|
||||||
|
* origin, and the fold drives BOTH its position and its angle: the
|
||||||
|
* anchor rides to wherever its panel's face has carried the pin, and the
|
||||||
|
* link swings to point at the knuckle on the centre plane. The knuckle
|
||||||
|
* is wherever a link of fixed length can reach it, which is the whole of
|
||||||
|
* the arithmetic and the whole of why the thing collapses.
|
||||||
|
*/
|
||||||
|
const reach = reachOf(Lp)
|
||||||
|
const stay = (pin: boolean): BufferGeometry => {
|
||||||
|
/*
|
||||||
|
* Wider and lighter than the frame, and both are about being SEEN.
|
||||||
|
*
|
||||||
|
* Measured, the pair spans the gap exactly: -0.180 to +0.180 with the
|
||||||
|
* pin at zero, panel face to panel face. It was reported missing three
|
||||||
|
* rounds running anyway, because a black bar nine millimetres thick,
|
||||||
|
* in the shadow between two panels, is four pixels of a render. The
|
||||||
|
* geometry never needed changing; what needed changing was whether
|
||||||
|
* anything could tell.
|
||||||
|
*/
|
||||||
|
const link = chamferedBoxGeometry(
|
||||||
|
[0.034, 0.013], [0.034, 0.013], reach, 0.003, [0, 0, 0],
|
||||||
|
tint('steelPainted', -0.12, 0.3),
|
||||||
|
).translate(0, -reach / 2, 0)
|
||||||
|
if (!pin) return link
|
||||||
|
// The pin at the far end, on one link only, because there is one pin
|
||||||
|
// and two links. Without it the pair meets end to end with nothing
|
||||||
|
// marking the joint and reads as a bar that stops halfway across --
|
||||||
|
// which is exactly what the critic saw, on geometry that measured
|
||||||
|
// correct to the millimetre.
|
||||||
|
const boss = latheGeometry([
|
||||||
|
{ y: -0.008, radius: 0.006 },
|
||||||
|
{ y: 0.008, radius: 0.006 },
|
||||||
|
], 10, [0, 0, 0], chrome, { capBottom: true, capTop: true })
|
||||||
|
boss.rotateX(Math.PI / 2)
|
||||||
|
boss.translate(0, -reach, 0)
|
||||||
|
return mergeColoured([link, boss])
|
||||||
|
}
|
||||||
|
|
||||||
|
const hingePieces: BufferGeometry[] = []
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
const knuckle = latheGeometry([
|
||||||
|
{ y: -W * 0.046, radius: 0.008 },
|
||||||
|
{ y: W * 0.046, radius: 0.008 },
|
||||||
|
], 12, [0, 0, 0], chrome, { capBottom: true, capTop: true })
|
||||||
|
knuckle.rotateZ(Math.PI / 2)
|
||||||
|
knuckle.translate(side * W * 0.26, 0.004, 0)
|
||||||
|
hingePieces.push(knuckle)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The insert and the caps ride the panel as EXTRAS rather than as vertex
|
||||||
|
* colours on the frame.
|
||||||
|
*
|
||||||
|
* They are different materials -- a printed sheet and a moulded foot on
|
||||||
|
* an aluminium extrusion -- and a consumer who swaps `steelPainted` for
|
||||||
|
* their own paint should not repaint the sign face with it. An extra
|
||||||
|
* carries its own slot and follows its part through the fold, which is
|
||||||
|
* exactly the relationship these three have.
|
||||||
|
*/
|
||||||
|
const side = (facing: number) => {
|
||||||
|
const { frame, board, caps, leaves } = panel(facing)
|
||||||
|
return {
|
||||||
|
slot: 'steelPainted' as const,
|
||||||
|
geometry: smoothNormals(mergeColoured(frame), 24),
|
||||||
|
origin: [0, Lp * Math.cos(OPEN), 0] as const,
|
||||||
|
extras: [
|
||||||
|
{ slot: 'plastic' as const, geometry: smoothNormals(mergeColoured(board), 30) },
|
||||||
|
{ slot: 'rubber' as const, geometry: smoothNormals(mergeColoured(caps), 24) },
|
||||||
|
{ slot: 'stainless' as const, geometry: smoothNormals(mergeColoured(leaves), 30) },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const stayOrigin = (facing: number): readonly [number, number, number] => {
|
||||||
|
const rot = -facing * OPEN
|
||||||
|
return [
|
||||||
|
0,
|
||||||
|
Lp * Math.cos(OPEN) + -Lp * STAY_AT * Math.cos(rot) - ((-facing * st) / 2) * Math.sin(rot),
|
||||||
|
-Lp * STAY_AT * Math.sin(rot) + ((-facing * st) / 2) * Math.cos(rot),
|
||||||
|
] as const
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
front: side(-1),
|
||||||
|
back: side(1),
|
||||||
|
stayFront: {
|
||||||
|
slot: 'steelPainted' as const,
|
||||||
|
geometry: smoothNormals(stay(true), 24),
|
||||||
|
origin: stayOrigin(-1),
|
||||||
|
},
|
||||||
|
stayBack: {
|
||||||
|
slot: 'steelPainted' as const,
|
||||||
|
geometry: smoothNormals(stay(false), 24),
|
||||||
|
origin: stayOrigin(1),
|
||||||
|
},
|
||||||
|
hinges: {
|
||||||
|
slot: 'stainless' as const,
|
||||||
|
geometry: smoothNormals(mergeColoured(hingePieces), 30),
|
||||||
|
origin: [0, Lp * Math.cos(OPEN), 0] as const,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: ({ parts, getConfig }) => {
|
||||||
|
const set = (amount: number): void => {
|
||||||
|
const t = Math.min(1, Math.max(0, amount))
|
||||||
|
const angle = OPEN * (1 - t)
|
||||||
|
parts.front.anchor.rotation.x = angle
|
||||||
|
parts.back.anchor.rotation.x = -angle
|
||||||
|
// ...and the pin rises as the panels straighten, because a folded
|
||||||
|
// A-board is taller than an open one and an origin left at the open
|
||||||
|
// height buries the feet.
|
||||||
|
const Lp = Math.min(1.4, Math.max(0.5, getConfig().panel))
|
||||||
|
const hingeY = Lp * Math.cos(angle)
|
||||||
|
for (const part of [parts.front, parts.back, parts.hinges]) {
|
||||||
|
part.anchor.position.setY(hingeY)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ...and then the stay follows, which is two numbers per link.
|
||||||
|
*
|
||||||
|
* The pin sits on the panel's inner face `STAY_AT` of the way down, so
|
||||||
|
* where it ENDS UP is the panel's own rotation applied to that point.
|
||||||
|
* The knuckle is on the centre plane at whatever height a link of
|
||||||
|
* fixed length can still reach from there -- which is what makes the
|
||||||
|
* pair go straight when open and hang when shut, with no case
|
||||||
|
* analysis and no clamp.
|
||||||
|
*/
|
||||||
|
const reach = reachOf(Lp)
|
||||||
|
for (const [part, facing] of [[parts.stayFront, -1], [parts.stayBack, 1]] as const) {
|
||||||
|
const rot = -facing * angle
|
||||||
|
const ly = -Lp * STAY_AT
|
||||||
|
const lz = (-facing * SECTION_T) / 2
|
||||||
|
const ay = hingeY + ly * Math.cos(rot) - lz * Math.sin(rot)
|
||||||
|
const az = ly * Math.sin(rot) + lz * Math.cos(rot)
|
||||||
|
part.anchor.position.set(0, ay, az)
|
||||||
|
// Built hanging along -Y, so the angle that points it at the knuckle
|
||||||
|
// is measured from straight down.
|
||||||
|
part.anchor.rotation.x = Math.atan2(az, Math.sqrt(Math.max(0, reach * reach - az * az)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set(getConfig().fold)
|
||||||
|
return { fold: (amount = 1) => { set(amount) } }
|
||||||
|
},
|
||||||
|
}, overrides)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue