Add the concrete traffic barrier on the published section, and with it an extrusion for the constant-section family: a half-lap end at both ends, drainage cut by a second section rather than painted on, and a stepped run so the concrete has somewhere to vary.
This commit is contained in:
parent
0f5ddac950
commit
107055ebb3
10 changed files with 929 additions and 21 deletions
35
PROGRESS.md
35
PROGRESS.md
|
|
@ -209,6 +209,23 @@ is `latheGeometry`'s and always was: walk from the bottom of the outer wall
|
||||||
upward. Write the profile whichever way round reads best and reverse it at the
|
upward. Write the profile whichever way round reads best and reverse it at the
|
||||||
call site.
|
call site.
|
||||||
|
|
||||||
|
**Vertex-colour mottle needs vertices, and a long prism cannot have the right
|
||||||
|
ones.** The barrier is two metres of one cross-section, so the only direction
|
||||||
|
its surface can vary in is its length, and one octave of noise along a line is
|
||||||
|
stripes. Chasing the reference's aggregate speckle with a fine cell produced a
|
||||||
|
barrier that looked like brushed sheet metal; the cell has to be several rings
|
||||||
|
wide and the amount has to stay low, and what comes out is tonal drift across a
|
||||||
|
pour rather than aggregate. Aggregate is a texture. This kit does not have
|
||||||
|
textures, and three of the critic's rounds asked for one.
|
||||||
|
|
||||||
|
The related trap is cheaper to fix and was invisible until it was named: a flat
|
||||||
|
quad whose four corners carry four mottle values shows its **diagonal**, because
|
||||||
|
the interpolation does not match across the split. It reads as a broad
|
||||||
|
triangular facet on a surface that is genuinely one plane, and no amount of
|
||||||
|
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
|
||||||
|
section as well as stepping the run.
|
||||||
|
|
||||||
**The kit's own check camera never looks into anything.** `renderObject` frames
|
**The kit's own check camera never looks into anything.** `renderObject` frames
|
||||||
by bounding box, so a tall object gets a low camera, and the basin's tap hole,
|
by bounding box, so a tall object gets a low camera, and the basin's tap hole,
|
||||||
overflow and waste -- all three verified in place by measurement -- do not appear
|
overflow and waste -- all three verified in place by measurement -- do not appear
|
||||||
|
|
@ -382,10 +399,20 @@ asking GitHub Support to purge actually closes it.
|
||||||
|
|
||||||
## Open
|
## Open
|
||||||
|
|
||||||
- **`contemporary-props`**: 10 of the core 100 modelled, and they are the first
|
- **`contemporary-props`**: 11 of the core 100 modelled, and they are the first
|
||||||
rows of the build order rather than ten picked at random. The catalogue, the
|
rows of the build order rather than eleven picked at random. The catalogue,
|
||||||
order, the cuts and the slot argument are in
|
the order, the cuts and the slot argument are in
|
||||||
`contemporary-props/CATALOGUE.md`; row 11 is `jersey-barrier`.
|
`contemporary-props/CATALOGUE.md`; row 12 is `picnic-table`.
|
||||||
|
|
||||||
|
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.
|
||||||
|
`latheGeometry` for anything round. `planSweepGeometry` for anything whose
|
||||||
|
plan is not a circle but whose profile varies with height -- sanitary ware,
|
||||||
|
cushions. `extrudeGeometry` for anything with a constant section and an
|
||||||
|
arbitrary length -- barriers, kerbs, skirting, rail, plank stock. All three
|
||||||
|
take their profile walked in the SAME direction, from the bottom of the outer
|
||||||
|
wall upward or counter-clockwise seen from +Z, and all three punish getting
|
||||||
|
it backwards the same way.
|
||||||
|
|
||||||
Row 10 changed its own catalogue entry. It was budgeted at "two lathes making
|
Row 10 changed its own catalogue entry. It was budgeted at "two lathes making
|
||||||
an hourglass" and a lathe cannot make it: every basin in use now is a D in
|
an hourglass" and a lathe cannot make it: every basin in use now is a D in
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,121 @@ export function latheGeometry(
|
||||||
return finish(sink)
|
return finish(sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A closed section for `extrudeGeometry`: points in the XY plane, in metres.
|
||||||
|
*
|
||||||
|
* COUNTER-CLOCKWISE seen from +Z, which is the direction the section is
|
||||||
|
* extruded along. That is not a convention chosen here, it is the one the rest
|
||||||
|
* of the file already turns at, and getting it backwards produces a solid whose
|
||||||
|
* every face points inward -- which renders as a torn surface rather than as
|
||||||
|
* anything recognisable as a winding fault.
|
||||||
|
*/
|
||||||
|
export type Section = readonly (readonly [number, number])[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a fixed cross-section along the Z axis: the third way of making a solid
|
||||||
|
* in this kit, after the lathe and the plan sweep.
|
||||||
|
*
|
||||||
|
* Each of the three is the only reasonable way to build a different family.
|
||||||
|
* A lathe is for anything round. A plan sweep is for anything whose plan is not
|
||||||
|
* a circle but whose profile still varies with height -- sanitary ware, seat
|
||||||
|
* cushions. This is for anything whose SECTION IS CONSTANT and whose length is
|
||||||
|
* arbitrary: barriers, kerbs, skirting, extruded aluminium, rails, gutters,
|
||||||
|
* plank stock. The catalogue has a lot of those, and every one of them is the
|
||||||
|
* same six lines with a different polyline.
|
||||||
|
*
|
||||||
|
* Two limits, both real and both cheap to live with:
|
||||||
|
*
|
||||||
|
* 1. The caps are fans from the section's CENTROID, so a section that is not
|
||||||
|
* star-shaped about its own centroid gets a cap with folded triangles in it.
|
||||||
|
* Every extruded thing in the catalogue is star-shaped; a C-channel would
|
||||||
|
* not be, and would want two extrusions instead of one.
|
||||||
|
* 2. The section is constant. A tapered run is a plan sweep turned on its side,
|
||||||
|
* not a job for this.
|
||||||
|
*
|
||||||
|
* `colourTop` shades by HEIGHT rather than along the run, because that is what
|
||||||
|
* every other generator here does and what makes a row of these look like one
|
||||||
|
* material rather than a gradient down the road.
|
||||||
|
*/
|
||||||
|
export function extrudeGeometry(
|
||||||
|
section: Section,
|
||||||
|
length: number,
|
||||||
|
centre: Vec3,
|
||||||
|
colour: Color,
|
||||||
|
options: {
|
||||||
|
readonly capStart?: boolean
|
||||||
|
readonly capEnd?: boolean
|
||||||
|
readonly colourTop?: Color
|
||||||
|
/**
|
||||||
|
* Rings along the run. 1 is a single span end to end.
|
||||||
|
*
|
||||||
|
* It exists for the mottle. Surface variation in this kit is written into
|
||||||
|
* VERTEX COLOURS, so it can only appear where there are vertices, and a
|
||||||
|
* two-metre barrier extruded in one step has none between its ends: the
|
||||||
|
* concrete slot is set to the heaviest mottle in the palette and the model
|
||||||
|
* came out flat as paper. Stepping the run gives the noise somewhere to
|
||||||
|
* live. It costs nothing else -- the section is constant, so every extra
|
||||||
|
* ring is the same ring again.
|
||||||
|
*/
|
||||||
|
readonly steps?: number
|
||||||
|
} = {},
|
||||||
|
): BufferGeometry {
|
||||||
|
if (section.length < 3) throw new Error('extrudeGeometry needs a section of at least three points')
|
||||||
|
const sink: Sink = { position: [], color: [] }
|
||||||
|
const { capStart = true, capEnd = true } = options
|
||||||
|
const steps = Math.max(1, Math.round(options.steps ?? 1))
|
||||||
|
const top = options.colourTop ?? colour
|
||||||
|
const [cx, cy, cz] = centre
|
||||||
|
|
||||||
|
let low = Infinity
|
||||||
|
let high = -Infinity
|
||||||
|
for (const [, y] of section) {
|
||||||
|
if (y < low) low = y
|
||||||
|
if (y > high) high = y
|
||||||
|
}
|
||||||
|
const span = high - low
|
||||||
|
const shade = (y: number): Color =>
|
||||||
|
span > 1e-9 ? new Color().copy(colour).lerp(top, (y - low) / span) : colour
|
||||||
|
|
||||||
|
const at = (index: number, z: number): Vec3 => {
|
||||||
|
const [x, y] = section[index % section.length]!
|
||||||
|
return [cx + x, cy + y, cz + z]
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let step = 0; step < steps; step += 1) {
|
||||||
|
const z0 = (step / steps) * length
|
||||||
|
const z1 = ((step + 1) / steps) * length
|
||||||
|
for (let i = 0; i < section.length; i += 1) {
|
||||||
|
const c0 = shade(section[i % section.length]![1])
|
||||||
|
const c1 = shade(section[(i + 1) % section.length]![1])
|
||||||
|
const a = at(i, z0)
|
||||||
|
const b = at(i + 1, z0)
|
||||||
|
const c = at(i + 1, z1)
|
||||||
|
const d = at(i, z1)
|
||||||
|
triShaded(sink, a, b, c, c0, c1, c1)
|
||||||
|
triShaded(sink, a, c, d, c0, c1, c0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (capStart || capEnd) {
|
||||||
|
let mx = 0
|
||||||
|
let my = 0
|
||||||
|
for (const [x, y] of section) { mx += x; my += y }
|
||||||
|
mx /= section.length
|
||||||
|
my /= section.length
|
||||||
|
const middle = shade(my)
|
||||||
|
for (let i = 0; i < section.length; i += 1) {
|
||||||
|
if (capStart) {
|
||||||
|
tri(sink, [cx + mx, cy + my, cz], at(i + 1, 0), at(i, 0), middle)
|
||||||
|
}
|
||||||
|
if (capEnd) {
|
||||||
|
tri(sink, [cx + mx, cy + my, cz + length], at(i, length), at(i + 1, length), middle)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return finish(sink)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A closed plan curve in unit coordinates, for `planSweepGeometry`.
|
* A closed plan curve in unit coordinates, for `planSweepGeometry`.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ export {
|
||||||
boxGeometry,
|
boxGeometry,
|
||||||
chamferedBoxGeometry,
|
chamferedBoxGeometry,
|
||||||
dPlan,
|
dPlan,
|
||||||
|
extrudeGeometry,
|
||||||
dishedSheetGeometry,
|
dishedSheetGeometry,
|
||||||
flipGeometry,
|
flipGeometry,
|
||||||
headGeometry,
|
headGeometry,
|
||||||
|
|
@ -19,7 +20,7 @@ export {
|
||||||
smoothNormals,
|
smoothNormals,
|
||||||
taperedBoxGeometry,
|
taperedBoxGeometry,
|
||||||
} from './geometry.ts'
|
} from './geometry.ts'
|
||||||
export type { Level, MottleOptions, Plan, PlanLevel, RoughenOptions, SheetLevel, Vec3 } from './geometry.ts'
|
export type { Level, MottleOptions, Plan, PlanLevel, RoughenOptions, Section, SheetLevel, Vec3 } from './geometry.ts'
|
||||||
export { bakeOcclusion } from './occlusion.ts'
|
export { bakeOcclusion } from './occlusion.ts'
|
||||||
export type { OcclusionOptions } from './occlusion.ts'
|
export type { OcclusionOptions } from './occlusion.ts'
|
||||||
export { createKitModel } from './kit.ts'
|
export { createKitModel } from './kit.ts'
|
||||||
|
|
|
||||||
42
contemporary-props/models/jersey-barrier/meta.json
Normal file
42
contemporary-props/models/jersey-barrier/meta.json
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"title": "Concrete Traffic Barrier",
|
||||||
|
"description": "A precast jersey barrier on the published New Jersey section: a vertical toe, a shallow face a tyre climbs, a steep face it cannot roll over, drainage openings cut through the base and a tongue-and-pocket end so a run of them keys together.",
|
||||||
|
"category": "Street",
|
||||||
|
"tags": [
|
||||||
|
"contemporary",
|
||||||
|
"street",
|
||||||
|
"traffic",
|
||||||
|
"procedural"
|
||||||
|
],
|
||||||
|
"controls": {
|
||||||
|
"height": {
|
||||||
|
"type": "number",
|
||||||
|
"label": "Height",
|
||||||
|
"min": 0.5,
|
||||||
|
"max": 1.2,
|
||||||
|
"step": 0.01,
|
||||||
|
"unit": "m"
|
||||||
|
},
|
||||||
|
"length": {
|
||||||
|
"type": "number",
|
||||||
|
"label": "Section length",
|
||||||
|
"min": 0.8,
|
||||||
|
"max": 6,
|
||||||
|
"step": 0.1,
|
||||||
|
"unit": "m"
|
||||||
|
},
|
||||||
|
"seed": {
|
||||||
|
"type": "number",
|
||||||
|
"label": "Variation seed",
|
||||||
|
"min": 1,
|
||||||
|
"max": 64,
|
||||||
|
"step": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"materialSlots": [
|
||||||
|
"concrete"
|
||||||
|
],
|
||||||
|
"parts": [
|
||||||
|
"body"
|
||||||
|
]
|
||||||
|
}
|
||||||
294
contemporary-props/models/jersey-barrier/model.ts
Normal file
294
contemporary-props/models/jersey-barrier/model.ts
Normal file
|
|
@ -0,0 +1,294 @@
|
||||||
|
/**
|
||||||
|
* @contemporary-props/jersey-barrier
|
||||||
|
*
|
||||||
|
* The extrusion helper's reference implementation, which is what the catalogue
|
||||||
|
* puts it eleventh for, and the cheapest model in the kit by a distance: the
|
||||||
|
* whole body is one polyline and a length.
|
||||||
|
*
|
||||||
|
* The polyline is not invented. The New Jersey profile is a published shape and
|
||||||
|
* every barrier on every road is a casting of it, so the section here is the
|
||||||
|
* standard one in inches and converted, rather than a curve drawn to look
|
||||||
|
* right. On a 32 inch barrier:
|
||||||
|
*
|
||||||
|
* 0 in 24 in wide the base
|
||||||
|
* 3 in 24 in wide the top of the vertical toe
|
||||||
|
* 13 in 9.75 in the 55 degree face, which is the one a tyre climbs
|
||||||
|
* 32 in 6 in the 84 degree face, and the top
|
||||||
|
*
|
||||||
|
* Those four numbers are the entire reason the shape is recognisable. The lower
|
||||||
|
* face is shallow enough that a car rides up it and comes back down; the upper
|
||||||
|
* one is steep enough that it does not roll. Draw it as a single straight taper
|
||||||
|
* and it is a plinth, not a barrier.
|
||||||
|
*
|
||||||
|
* The end connector is a half lap: the upper half of the casting runs past the
|
||||||
|
* lower at one end and the lower past the upper at the other. A single barrier
|
||||||
|
* is never the object -- they come in runs -- and a run of these placed end to
|
||||||
|
* end at `length` spacing interleaves.
|
||||||
|
*/
|
||||||
|
import { type BufferGeometry } from 'three'
|
||||||
|
|
||||||
|
import {
|
||||||
|
bakeOcclusion,
|
||||||
|
createKitModel,
|
||||||
|
createTinter,
|
||||||
|
extrudeGeometry,
|
||||||
|
jitter,
|
||||||
|
mergeColoured,
|
||||||
|
smoothNormals,
|
||||||
|
type Section,
|
||||||
|
} from '../core/index.ts'
|
||||||
|
|
||||||
|
export interface JerseyBarrierConfig {
|
||||||
|
/** Height of the barrier (metres). */
|
||||||
|
readonly height: number
|
||||||
|
/** Length of the cast section (metres). */
|
||||||
|
readonly length: number
|
||||||
|
readonly seed: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const jerseyBarrierDefaults: JerseyBarrierConfig = {
|
||||||
|
// 32 inches, which is the standard highway height and the one the published
|
||||||
|
// section is dimensioned at.
|
||||||
|
height: 0.81,
|
||||||
|
// Precast sections come at 2, 3 and 6 metres. Two is the one that gets
|
||||||
|
// craned around a works entrance, which is where most of them are seen.
|
||||||
|
length: 2,
|
||||||
|
seed: 7,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type JerseyBarrierParts = 'body'
|
||||||
|
|
||||||
|
export function createModel(overrides: Partial<JerseyBarrierConfig> = {}) {
|
||||||
|
return createKitModel<
|
||||||
|
JerseyBarrierConfig, 'concrete', JerseyBarrierParts, Record<string, never>
|
||||||
|
>({
|
||||||
|
id: 'jersey-barrier',
|
||||||
|
defaults: jerseyBarrierDefaults,
|
||||||
|
slots: ['concrete'],
|
||||||
|
/*
|
||||||
|
* Concrete is the coarsest surface in the palette and this is the largest
|
||||||
|
* flat expanse of it in the kit, so it takes more than the default -- but
|
||||||
|
* at a LARGER cell, not a finer one.
|
||||||
|
*
|
||||||
|
* The obvious reading of the reference is fine aggregate speckle, and the
|
||||||
|
* first attempt chased it with a 50 mm cell. Mottle here is written into
|
||||||
|
* vertex colours, so a cell smaller than the distance between rings is
|
||||||
|
* sampled about once per cell and aliases: the barrier came out with long
|
||||||
|
* smeared bands down it and read as brushed metal. Speckle at that scale
|
||||||
|
* is a texture and this kit does not have textures. What it can carry is
|
||||||
|
* the other half of what concrete looks like -- broad tonal drift across a
|
||||||
|
* pour -- and that wants a cell several rings wide.
|
||||||
|
*
|
||||||
|
* The amount is then held DOWN, because a long constant section can only
|
||||||
|
* vary along its length and one octave of noise on it reads as stripes. At
|
||||||
|
* 0.2 the barrier came out banded like corrugated sheet. This is the point
|
||||||
|
* where more variation is worse than less, and it is a property of the
|
||||||
|
* shape rather than of the setting: nothing else in either kit is two
|
||||||
|
* metres of the same cross-section.
|
||||||
|
*/
|
||||||
|
mottle: { amount: 0.11, cell: 0.32 },
|
||||||
|
|
||||||
|
build: ({ config, random }) => {
|
||||||
|
const tint = createTinter(random)
|
||||||
|
const H = Math.min(1.2, Math.max(0.5, config.height))
|
||||||
|
const L = Math.min(6, Math.max(0.8, config.length))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The section, in fractions of the height, straight off the published
|
||||||
|
* profile: 24, 24, 9.75 and 6 inches of width at 0, 3, 13 and 32 inches
|
||||||
|
* of height, all divided by 32.
|
||||||
|
*
|
||||||
|
* Written as one side and mirrored, because the two faces of a jersey
|
||||||
|
* barrier are the same face and writing them out twice is how they end
|
||||||
|
* up not being.
|
||||||
|
*/
|
||||||
|
const HALF: ReadonlyArray<readonly [number, number]> = [
|
||||||
|
[0.375, 0],
|
||||||
|
[0.375, 0.094],
|
||||||
|
[0.1523, 0.406],
|
||||||
|
// A small flat before the top edge: the casting has an arris rather
|
||||||
|
// than a knife edge, and at prop scale one chamfer is the difference
|
||||||
|
// between concrete and cardboard.
|
||||||
|
[0.0938, 0.978],
|
||||||
|
[0.078, 1],
|
||||||
|
]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ...and every corner of it is ROUNDED, which is not decoration.
|
||||||
|
*
|
||||||
|
* A casting comes out of a mould with radiused arrises -- the reference's
|
||||||
|
* are 20 to 30 mm on an 810 mm barrier -- and a section with mathematical
|
||||||
|
* corners reads as folded card at any size. Each corner is replaced by
|
||||||
|
* two points a radius back along each of its edges, which is a chamfer
|
||||||
|
* rather than a true fillet; across 20 mm nothing can tell, and the
|
||||||
|
* alternative is arcs at every vertex of every extruded thing in the
|
||||||
|
* catalogue.
|
||||||
|
*/
|
||||||
|
const R = 0.022
|
||||||
|
const back = (
|
||||||
|
p: readonly [number, number], to: readonly [number, number],
|
||||||
|
): readonly [number, number] => {
|
||||||
|
const dx = to[0] - p[0]
|
||||||
|
const dy = to[1] - p[1]
|
||||||
|
const len = Math.hypot(dx, dy) || 1
|
||||||
|
const d = Math.min(R, len * 0.45)
|
||||||
|
return [p[0] + (dx / len) * d, p[1] + (dy / len) * d]
|
||||||
|
}
|
||||||
|
const CORNERS: Array<readonly [number, number]> = []
|
||||||
|
for (let i = 0; i < HALF.length; i += 1) {
|
||||||
|
const p = HALF[i]!
|
||||||
|
// The first and last points sit ON the mirror line, so the edge on
|
||||||
|
// that side is the one the mirror supplies: the neighbour there is the
|
||||||
|
// same point with its x negated.
|
||||||
|
const prev = HALF[i - 1] ?? ([-p[0], p[1]] as const)
|
||||||
|
const next = HALF[i + 1] ?? ([-p[0], p[1]] as const)
|
||||||
|
CORNERS.push(back(p, prev), back(p, next))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ...and then the long edges are SUBDIVIDED.
|
||||||
|
*
|
||||||
|
* The two faces of this section are 0.3 of the height each, and a ring
|
||||||
|
* every 6 cm makes them into quads three times longer than they are
|
||||||
|
* wide. A quad is two triangles, its four corners carry four different
|
||||||
|
* mottle values, and the interpolation across the shared diagonal does
|
||||||
|
* not match on both sides of it: the flat faces came out crossed by
|
||||||
|
* broad diagonal facets. Nothing is wrong with the surface -- it is one
|
||||||
|
* plane -- and no amount of normal smoothing will help, because the seam
|
||||||
|
* is in the colour.
|
||||||
|
*
|
||||||
|
* Squarer quads fix it, and half of squarer is the section's job.
|
||||||
|
*/
|
||||||
|
const STEP = 0.075
|
||||||
|
for (let i = CORNERS.length - 1; i > 0; i -= 1) {
|
||||||
|
const a = CORNERS[i - 1]!
|
||||||
|
const b = CORNERS[i]!
|
||||||
|
const len = Math.hypot(b[0] - a[0], b[1] - a[1])
|
||||||
|
const cuts = Math.floor(len / STEP)
|
||||||
|
for (let k = cuts; k >= 1; k -= 1) {
|
||||||
|
const t = k / (cuts + 1)
|
||||||
|
CORNERS.splice(i, 0, [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const widthAt = (y: number): number => {
|
||||||
|
for (let i = 0; i < CORNERS.length - 1; i += 1) {
|
||||||
|
const [x0, y0] = CORNERS[i]!
|
||||||
|
const [x1, y1] = CORNERS[i + 1]!
|
||||||
|
if (y >= y0 && y <= y1) {
|
||||||
|
const t = y1 === y0 ? 0 : (y - y0) / (y1 - y0)
|
||||||
|
return x0 + (x1 - x0) * t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CORNERS.at(-1)![0]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One horizontal band of the section, mirrored and closed.
|
||||||
|
*
|
||||||
|
* `band(0, 1)` is the whole barrier; the two halves are what the end
|
||||||
|
* joint is made of, and a third band with its floor lifted is what the
|
||||||
|
* drainage openings are made of. Counter-clockwise seen from +Z -- up the
|
||||||
|
* right-hand face, across the top, back down the left -- which is the
|
||||||
|
* helper's whole contract and the same direction the plan sweep wanted.
|
||||||
|
*/
|
||||||
|
const band = (from: number, to: number): Section => {
|
||||||
|
const side: Array<readonly [number, number]> = [[widthAt(from), from]]
|
||||||
|
for (const c of CORNERS) if (c[1] > from && c[1] < to) side.push(c)
|
||||||
|
side.push([widthAt(to), to])
|
||||||
|
return [
|
||||||
|
...side.map(([x, y]) => [x * H, y * H] as const),
|
||||||
|
...[...side].reverse().map(([x, y]) => [-x * H, y * H] as const),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const section = band(0, 1)
|
||||||
|
|
||||||
|
const concrete = tint('concrete', jitter(random, 0.02))
|
||||||
|
// Lighter along the top, because the top of a barrier is the face that
|
||||||
|
// never gets splashed.
|
||||||
|
const crest = tint('concrete', 0.05)
|
||||||
|
// One ring every 6 cm, which is what gives the mottle somewhere to sit:
|
||||||
|
// three samples across its cell, where one sample gives smears. See the
|
||||||
|
// helper's `steps`.
|
||||||
|
const ringsPer = (span: number): number => Math.max(1, Math.round(span / 0.06))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The end joint is a HALF LAP, and it is the same joint at both ends.
|
||||||
|
*
|
||||||
|
* The first cut had a spigot on one end and a dark plate standing in for
|
||||||
|
* a pocket on the other, and the plate could not win: dark enough to read
|
||||||
|
* as a hole it became a black panel the size of the end face, light
|
||||||
|
* enough not to and it became a second projecting rib, which is exactly
|
||||||
|
* what the critic called it. A recess drawn in paint is a recess that is
|
||||||
|
* not there.
|
||||||
|
*
|
||||||
|
* A lap is a recess that is there. The upper half of the casting runs
|
||||||
|
* past the lower at one end and the lower past the upper at the other, so
|
||||||
|
* a row of identical barriers interleaves, and each end carries a real
|
||||||
|
* step that is visible from any angle with no shade of grey doing the
|
||||||
|
* work.
|
||||||
|
*/
|
||||||
|
const lap = 0.5
|
||||||
|
// Shallow. The reference's ends are very nearly flush, and the catalogue
|
||||||
|
// still wants a connector, so this is as little as will still read as a
|
||||||
|
// step from across a road: 3 cm on an 81 cm casting.
|
||||||
|
const lapD = H * 0.04
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The drainage openings, and they are REAL openings.
|
||||||
|
*
|
||||||
|
* Water has to cross the line a barrier makes, so every casting has a
|
||||||
|
* pair of holes through the bottom of it; they are the only thing that
|
||||||
|
* breaks the silhouette of an otherwise entirely constant section. The
|
||||||
|
* cheap way to suggest one is a dark patch, and it does not work here,
|
||||||
|
* because a barrier is looked at end on as often as not and a patch has
|
||||||
|
* no daylight behind it.
|
||||||
|
*/
|
||||||
|
// Small, and near the ENDS, which is where the reference's is: a single
|
||||||
|
// slot cut into the bottom edge just in from the corner. Put at the
|
||||||
|
// third points and made twice this size they stopped reading as
|
||||||
|
// openings in a casting and started reading as a shape decision.
|
||||||
|
const notchH = 0.06
|
||||||
|
const gap = (H * 0.16) / L
|
||||||
|
|
||||||
|
interface Span { readonly from: number; readonly to: number; readonly cut: Section }
|
||||||
|
const lapFrac = lapD / L
|
||||||
|
const spans: Span[] = [
|
||||||
|
{ from: 0, to: lapFrac, cut: band(lap, 1) },
|
||||||
|
{ from: lapFrac, to: 0.14 - gap / 2, cut: section },
|
||||||
|
{ from: 0.14 - gap / 2, to: 0.14 + gap / 2, cut: band(notchH, 1) },
|
||||||
|
{ from: 0.14 + gap / 2, to: 0.86 - gap / 2, cut: section },
|
||||||
|
{ from: 0.86 - gap / 2, to: 0.86 + gap / 2, cut: band(notchH, 1) },
|
||||||
|
{ from: 0.86 + gap / 2, to: 1 - lapFrac, cut: section },
|
||||||
|
{ from: 1 - lapFrac, to: 1, cut: band(0, lap) },
|
||||||
|
]
|
||||||
|
|
||||||
|
const pieces: BufferGeometry[] = spans.map((span) => {
|
||||||
|
const length = (span.to - span.from) * L
|
||||||
|
return extrudeGeometry(span.cut, length, [0, 0, span.from * L - L / 2], concrete, {
|
||||||
|
colourTop: crest,
|
||||||
|
steps: ringsPer(length),
|
||||||
|
// Every span is capped at both ends. Between two spans of the same
|
||||||
|
// section that would leave a pair of coincident faces, which is the
|
||||||
|
// trap `latheGeometry` exists to avoid -- but here no two neighbours
|
||||||
|
// share a section, so every one of these caps is a real step that has
|
||||||
|
// to be drawn.
|
||||||
|
capStart: true,
|
||||||
|
capEnd: true,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
bakeOcclusion(pieces, { strength: 0.35 })
|
||||||
|
|
||||||
|
return {
|
||||||
|
body: {
|
||||||
|
slot: 'concrete' as const,
|
||||||
|
// A low crease angle: concrete castings have arrises, and every edge
|
||||||
|
// on this shape is a real one that should stay sharp.
|
||||||
|
geometry: smoothNormals(mergeColoured(pieces), 18),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, overrides)
|
||||||
|
}
|
||||||
|
|
@ -677,15 +677,15 @@
|
||||||
"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-01T00:47:01.784Z",
|
"installedAt": "2026-09-01T01:08:14.719Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\core\\geometry.ts",
|
"path": "src\\models\\contemporary-props\\core\\geometry.ts",
|
||||||
"sourceHash": "389f53cf5d7a8ec142fc0a5dc5233908f378a32fa2c8f45392d2684ea3b8f9f9"
|
"sourceHash": "fd4f7d757baa13d81a02a02b4d1f89caf86c9c3206b07bb925b51b02047c8f33"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\core\\index.ts",
|
"path": "src\\models\\contemporary-props\\core\\index.ts",
|
||||||
"sourceHash": "c01444bdfe01e70820b21aeb3be933794b5a3091944b99dd3b3b77a869fec28a"
|
"sourceHash": "d4eb9cbaa949aed0c6fb6953ccb114635e41ab59a1e4f35cc561056a80969f12"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\core\\kit.ts",
|
"path": "src\\models\\contemporary-props\\core\\kit.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-01T00:47:01.787Z",
|
"installedAt": "2026-09-01T01:08:14.721Z",
|
||||||
"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-01T00:47:01.788Z",
|
"installedAt": "2026-09-01T01:08:14.723Z",
|
||||||
"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-01T00:47:01.795Z",
|
"installedAt": "2026-09-01T01:08:14.731Z",
|
||||||
"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-01T00:47:01.797Z",
|
"installedAt": "2026-09-01T01:08:14.732Z",
|
||||||
"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-01T00:47:01.800Z",
|
"installedAt": "2026-09-01T01:08:14.735Z",
|
||||||
"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-01T00:47:01.802Z",
|
"installedAt": "2026-09-01T01:08:14.737Z",
|
||||||
"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-01T00:47:01.802Z",
|
"installedAt": "2026-09-01T01:08:14.737Z",
|
||||||
"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-01T00:47:01.799Z",
|
"installedAt": "2026-09-01T01:08:14.734Z",
|
||||||
"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-01T00:47:01.792Z",
|
"installedAt": "2026-09-01T01:08:14.726Z",
|
||||||
"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-01T00:47:01.790Z",
|
"installedAt": "2026-09-01T01:08:14.725Z",
|
||||||
"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-01T00:47:01.793Z",
|
"installedAt": "2026-09-01T01:08:14.729Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\pedestal-basin\\model.ts",
|
"path": "src\\models\\contemporary-props\\pedestal-basin\\model.ts",
|
||||||
|
|
@ -877,6 +877,21 @@
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"three@>=0.185.0"
|
"three@>=0.185.0"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"@contemporary-props/jersey-barrier": {
|
||||||
|
"address": "@contemporary-props/jersey-barrier",
|
||||||
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
|
"version": "workspace",
|
||||||
|
"installedAt": "2026-09-01T01:08:14.728Z",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"path": "src\\models\\contemporary-props\\jersey-barrier\\model.ts",
|
||||||
|
"sourceHash": "ec0307934cb5c1a290ab5c715a8bf0373eedf748762055d8097e334b65a2ed5f"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": [
|
||||||
|
"three@>=0.185.0"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ import { createModel as createCpStreetBollard } from '@/models/contemporary-prop
|
||||||
import { createModel as createCpGasCylinder } from '@/models/contemporary-props/gas-cylinder/model.ts'
|
import { createModel as createCpGasCylinder } from '@/models/contemporary-props/gas-cylinder/model.ts'
|
||||||
import { createModel as createCpFireExtinguisher } from '@/models/contemporary-props/fire-extinguisher/model.ts'
|
import { createModel as createCpFireExtinguisher } from '@/models/contemporary-props/fire-extinguisher/model.ts'
|
||||||
import { createModel as createCpPedestalBasin } from '@/models/contemporary-props/pedestal-basin/model.ts'
|
import { createModel as createCpPedestalBasin } from '@/models/contemporary-props/pedestal-basin/model.ts'
|
||||||
|
import { createModel as createCpJerseyBarrier } from '@/models/contemporary-props/jersey-barrier/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'
|
||||||
|
|
@ -71,6 +72,7 @@ import cpMetaStreetBollard from '../contemporary-props/models/street-bollard/met
|
||||||
import cpMetaGasCylinder from '../contemporary-props/models/gas-cylinder/meta.json'
|
import cpMetaGasCylinder from '../contemporary-props/models/gas-cylinder/meta.json'
|
||||||
import cpMetaFireExtinguisher from '../contemporary-props/models/fire-extinguisher/meta.json'
|
import cpMetaFireExtinguisher from '../contemporary-props/models/fire-extinguisher/meta.json'
|
||||||
import cpMetaPedestalBasin from '../contemporary-props/models/pedestal-basin/meta.json'
|
import cpMetaPedestalBasin from '../contemporary-props/models/pedestal-basin/meta.json'
|
||||||
|
import cpMetaJerseyBarrier from '../contemporary-props/models/jersey-barrier/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'
|
||||||
|
|
@ -285,7 +287,7 @@ interface ModelMetaLike {
|
||||||
const CONTEMPORARY_ORDER = [
|
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',
|
'fire-extinguisher', 'pedestal-basin', 'jersey-barrier',
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
const CONTEMPORARY_FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
const CONTEMPORARY_FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
||||||
|
|
@ -299,6 +301,7 @@ const CONTEMPORARY_FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
||||||
'gas-cylinder': as(createCpGasCylinder),
|
'gas-cylinder': as(createCpGasCylinder),
|
||||||
'fire-extinguisher': as(createCpFireExtinguisher),
|
'fire-extinguisher': as(createCpFireExtinguisher),
|
||||||
'pedestal-basin': as(createCpPedestalBasin),
|
'pedestal-basin': as(createCpPedestalBasin),
|
||||||
|
'jersey-barrier': as(createCpJerseyBarrier),
|
||||||
}
|
}
|
||||||
|
|
||||||
const CONTEMPORARY_META: Readonly<Record<string, ModelMetaLike>> = {
|
const CONTEMPORARY_META: Readonly<Record<string, ModelMetaLike>> = {
|
||||||
|
|
@ -312,6 +315,7 @@ const CONTEMPORARY_META: Readonly<Record<string, ModelMetaLike>> = {
|
||||||
'gas-cylinder': cpMetaGasCylinder as ModelMetaLike,
|
'gas-cylinder': cpMetaGasCylinder as ModelMetaLike,
|
||||||
'fire-extinguisher': cpMetaFireExtinguisher as ModelMetaLike,
|
'fire-extinguisher': cpMetaFireExtinguisher as ModelMetaLike,
|
||||||
'pedestal-basin': cpMetaPedestalBasin as ModelMetaLike,
|
'pedestal-basin': cpMetaPedestalBasin as ModelMetaLike,
|
||||||
|
'jersey-barrier': cpMetaJerseyBarrier as ModelMetaLike,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,121 @@ export function latheGeometry(
|
||||||
return finish(sink)
|
return finish(sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A closed section for `extrudeGeometry`: points in the XY plane, in metres.
|
||||||
|
*
|
||||||
|
* COUNTER-CLOCKWISE seen from +Z, which is the direction the section is
|
||||||
|
* extruded along. That is not a convention chosen here, it is the one the rest
|
||||||
|
* of the file already turns at, and getting it backwards produces a solid whose
|
||||||
|
* every face points inward -- which renders as a torn surface rather than as
|
||||||
|
* anything recognisable as a winding fault.
|
||||||
|
*/
|
||||||
|
export type Section = readonly (readonly [number, number])[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a fixed cross-section along the Z axis: the third way of making a solid
|
||||||
|
* in this kit, after the lathe and the plan sweep.
|
||||||
|
*
|
||||||
|
* Each of the three is the only reasonable way to build a different family.
|
||||||
|
* A lathe is for anything round. A plan sweep is for anything whose plan is not
|
||||||
|
* a circle but whose profile still varies with height -- sanitary ware, seat
|
||||||
|
* cushions. This is for anything whose SECTION IS CONSTANT and whose length is
|
||||||
|
* arbitrary: barriers, kerbs, skirting, extruded aluminium, rails, gutters,
|
||||||
|
* plank stock. The catalogue has a lot of those, and every one of them is the
|
||||||
|
* same six lines with a different polyline.
|
||||||
|
*
|
||||||
|
* Two limits, both real and both cheap to live with:
|
||||||
|
*
|
||||||
|
* 1. The caps are fans from the section's CENTROID, so a section that is not
|
||||||
|
* star-shaped about its own centroid gets a cap with folded triangles in it.
|
||||||
|
* Every extruded thing in the catalogue is star-shaped; a C-channel would
|
||||||
|
* not be, and would want two extrusions instead of one.
|
||||||
|
* 2. The section is constant. A tapered run is a plan sweep turned on its side,
|
||||||
|
* not a job for this.
|
||||||
|
*
|
||||||
|
* `colourTop` shades by HEIGHT rather than along the run, because that is what
|
||||||
|
* every other generator here does and what makes a row of these look like one
|
||||||
|
* material rather than a gradient down the road.
|
||||||
|
*/
|
||||||
|
export function extrudeGeometry(
|
||||||
|
section: Section,
|
||||||
|
length: number,
|
||||||
|
centre: Vec3,
|
||||||
|
colour: Color,
|
||||||
|
options: {
|
||||||
|
readonly capStart?: boolean
|
||||||
|
readonly capEnd?: boolean
|
||||||
|
readonly colourTop?: Color
|
||||||
|
/**
|
||||||
|
* Rings along the run. 1 is a single span end to end.
|
||||||
|
*
|
||||||
|
* It exists for the mottle. Surface variation in this kit is written into
|
||||||
|
* VERTEX COLOURS, so it can only appear where there are vertices, and a
|
||||||
|
* two-metre barrier extruded in one step has none between its ends: the
|
||||||
|
* concrete slot is set to the heaviest mottle in the palette and the model
|
||||||
|
* came out flat as paper. Stepping the run gives the noise somewhere to
|
||||||
|
* live. It costs nothing else -- the section is constant, so every extra
|
||||||
|
* ring is the same ring again.
|
||||||
|
*/
|
||||||
|
readonly steps?: number
|
||||||
|
} = {},
|
||||||
|
): BufferGeometry {
|
||||||
|
if (section.length < 3) throw new Error('extrudeGeometry needs a section of at least three points')
|
||||||
|
const sink: Sink = { position: [], color: [] }
|
||||||
|
const { capStart = true, capEnd = true } = options
|
||||||
|
const steps = Math.max(1, Math.round(options.steps ?? 1))
|
||||||
|
const top = options.colourTop ?? colour
|
||||||
|
const [cx, cy, cz] = centre
|
||||||
|
|
||||||
|
let low = Infinity
|
||||||
|
let high = -Infinity
|
||||||
|
for (const [, y] of section) {
|
||||||
|
if (y < low) low = y
|
||||||
|
if (y > high) high = y
|
||||||
|
}
|
||||||
|
const span = high - low
|
||||||
|
const shade = (y: number): Color =>
|
||||||
|
span > 1e-9 ? new Color().copy(colour).lerp(top, (y - low) / span) : colour
|
||||||
|
|
||||||
|
const at = (index: number, z: number): Vec3 => {
|
||||||
|
const [x, y] = section[index % section.length]!
|
||||||
|
return [cx + x, cy + y, cz + z]
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let step = 0; step < steps; step += 1) {
|
||||||
|
const z0 = (step / steps) * length
|
||||||
|
const z1 = ((step + 1) / steps) * length
|
||||||
|
for (let i = 0; i < section.length; i += 1) {
|
||||||
|
const c0 = shade(section[i % section.length]![1])
|
||||||
|
const c1 = shade(section[(i + 1) % section.length]![1])
|
||||||
|
const a = at(i, z0)
|
||||||
|
const b = at(i + 1, z0)
|
||||||
|
const c = at(i + 1, z1)
|
||||||
|
const d = at(i, z1)
|
||||||
|
triShaded(sink, a, b, c, c0, c1, c1)
|
||||||
|
triShaded(sink, a, c, d, c0, c1, c0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (capStart || capEnd) {
|
||||||
|
let mx = 0
|
||||||
|
let my = 0
|
||||||
|
for (const [x, y] of section) { mx += x; my += y }
|
||||||
|
mx /= section.length
|
||||||
|
my /= section.length
|
||||||
|
const middle = shade(my)
|
||||||
|
for (let i = 0; i < section.length; i += 1) {
|
||||||
|
if (capStart) {
|
||||||
|
tri(sink, [cx + mx, cy + my, cz], at(i + 1, 0), at(i, 0), middle)
|
||||||
|
}
|
||||||
|
if (capEnd) {
|
||||||
|
tri(sink, [cx + mx, cy + my, cz + length], at(i, length), at(i + 1, length), middle)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return finish(sink)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A closed plan curve in unit coordinates, for `planSweepGeometry`.
|
* A closed plan curve in unit coordinates, for `planSweepGeometry`.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ export {
|
||||||
boxGeometry,
|
boxGeometry,
|
||||||
chamferedBoxGeometry,
|
chamferedBoxGeometry,
|
||||||
dPlan,
|
dPlan,
|
||||||
|
extrudeGeometry,
|
||||||
dishedSheetGeometry,
|
dishedSheetGeometry,
|
||||||
flipGeometry,
|
flipGeometry,
|
||||||
headGeometry,
|
headGeometry,
|
||||||
|
|
@ -19,7 +20,7 @@ export {
|
||||||
smoothNormals,
|
smoothNormals,
|
||||||
taperedBoxGeometry,
|
taperedBoxGeometry,
|
||||||
} from './geometry.ts'
|
} from './geometry.ts'
|
||||||
export type { Level, MottleOptions, Plan, PlanLevel, RoughenOptions, SheetLevel, Vec3 } from './geometry.ts'
|
export type { Level, MottleOptions, Plan, PlanLevel, RoughenOptions, Section, SheetLevel, Vec3 } from './geometry.ts'
|
||||||
export { bakeOcclusion } from './occlusion.ts'
|
export { bakeOcclusion } from './occlusion.ts'
|
||||||
export type { OcclusionOptions } from './occlusion.ts'
|
export type { OcclusionOptions } from './occlusion.ts'
|
||||||
export { createKitModel } from './kit.ts'
|
export { createKitModel } from './kit.ts'
|
||||||
|
|
|
||||||
294
src/models/contemporary-props/jersey-barrier/model.ts
Normal file
294
src/models/contemporary-props/jersey-barrier/model.ts
Normal file
|
|
@ -0,0 +1,294 @@
|
||||||
|
/**
|
||||||
|
* @contemporary-props/jersey-barrier
|
||||||
|
*
|
||||||
|
* The extrusion helper's reference implementation, which is what the catalogue
|
||||||
|
* puts it eleventh for, and the cheapest model in the kit by a distance: the
|
||||||
|
* whole body is one polyline and a length.
|
||||||
|
*
|
||||||
|
* The polyline is not invented. The New Jersey profile is a published shape and
|
||||||
|
* every barrier on every road is a casting of it, so the section here is the
|
||||||
|
* standard one in inches and converted, rather than a curve drawn to look
|
||||||
|
* right. On a 32 inch barrier:
|
||||||
|
*
|
||||||
|
* 0 in 24 in wide the base
|
||||||
|
* 3 in 24 in wide the top of the vertical toe
|
||||||
|
* 13 in 9.75 in the 55 degree face, which is the one a tyre climbs
|
||||||
|
* 32 in 6 in the 84 degree face, and the top
|
||||||
|
*
|
||||||
|
* Those four numbers are the entire reason the shape is recognisable. The lower
|
||||||
|
* face is shallow enough that a car rides up it and comes back down; the upper
|
||||||
|
* one is steep enough that it does not roll. Draw it as a single straight taper
|
||||||
|
* and it is a plinth, not a barrier.
|
||||||
|
*
|
||||||
|
* The end connector is a half lap: the upper half of the casting runs past the
|
||||||
|
* lower at one end and the lower past the upper at the other. A single barrier
|
||||||
|
* is never the object -- they come in runs -- and a run of these placed end to
|
||||||
|
* end at `length` spacing interleaves.
|
||||||
|
*/
|
||||||
|
import { type BufferGeometry } from 'three'
|
||||||
|
|
||||||
|
import {
|
||||||
|
bakeOcclusion,
|
||||||
|
createKitModel,
|
||||||
|
createTinter,
|
||||||
|
extrudeGeometry,
|
||||||
|
jitter,
|
||||||
|
mergeColoured,
|
||||||
|
smoothNormals,
|
||||||
|
type Section,
|
||||||
|
} from '../core/index.ts'
|
||||||
|
|
||||||
|
export interface JerseyBarrierConfig {
|
||||||
|
/** Height of the barrier (metres). */
|
||||||
|
readonly height: number
|
||||||
|
/** Length of the cast section (metres). */
|
||||||
|
readonly length: number
|
||||||
|
readonly seed: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const jerseyBarrierDefaults: JerseyBarrierConfig = {
|
||||||
|
// 32 inches, which is the standard highway height and the one the published
|
||||||
|
// section is dimensioned at.
|
||||||
|
height: 0.81,
|
||||||
|
// Precast sections come at 2, 3 and 6 metres. Two is the one that gets
|
||||||
|
// craned around a works entrance, which is where most of them are seen.
|
||||||
|
length: 2,
|
||||||
|
seed: 7,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type JerseyBarrierParts = 'body'
|
||||||
|
|
||||||
|
export function createModel(overrides: Partial<JerseyBarrierConfig> = {}) {
|
||||||
|
return createKitModel<
|
||||||
|
JerseyBarrierConfig, 'concrete', JerseyBarrierParts, Record<string, never>
|
||||||
|
>({
|
||||||
|
id: 'jersey-barrier',
|
||||||
|
defaults: jerseyBarrierDefaults,
|
||||||
|
slots: ['concrete'],
|
||||||
|
/*
|
||||||
|
* Concrete is the coarsest surface in the palette and this is the largest
|
||||||
|
* flat expanse of it in the kit, so it takes more than the default -- but
|
||||||
|
* at a LARGER cell, not a finer one.
|
||||||
|
*
|
||||||
|
* The obvious reading of the reference is fine aggregate speckle, and the
|
||||||
|
* first attempt chased it with a 50 mm cell. Mottle here is written into
|
||||||
|
* vertex colours, so a cell smaller than the distance between rings is
|
||||||
|
* sampled about once per cell and aliases: the barrier came out with long
|
||||||
|
* smeared bands down it and read as brushed metal. Speckle at that scale
|
||||||
|
* is a texture and this kit does not have textures. What it can carry is
|
||||||
|
* the other half of what concrete looks like -- broad tonal drift across a
|
||||||
|
* pour -- and that wants a cell several rings wide.
|
||||||
|
*
|
||||||
|
* The amount is then held DOWN, because a long constant section can only
|
||||||
|
* vary along its length and one octave of noise on it reads as stripes. At
|
||||||
|
* 0.2 the barrier came out banded like corrugated sheet. This is the point
|
||||||
|
* where more variation is worse than less, and it is a property of the
|
||||||
|
* shape rather than of the setting: nothing else in either kit is two
|
||||||
|
* metres of the same cross-section.
|
||||||
|
*/
|
||||||
|
mottle: { amount: 0.11, cell: 0.32 },
|
||||||
|
|
||||||
|
build: ({ config, random }) => {
|
||||||
|
const tint = createTinter(random)
|
||||||
|
const H = Math.min(1.2, Math.max(0.5, config.height))
|
||||||
|
const L = Math.min(6, Math.max(0.8, config.length))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The section, in fractions of the height, straight off the published
|
||||||
|
* profile: 24, 24, 9.75 and 6 inches of width at 0, 3, 13 and 32 inches
|
||||||
|
* of height, all divided by 32.
|
||||||
|
*
|
||||||
|
* Written as one side and mirrored, because the two faces of a jersey
|
||||||
|
* barrier are the same face and writing them out twice is how they end
|
||||||
|
* up not being.
|
||||||
|
*/
|
||||||
|
const HALF: ReadonlyArray<readonly [number, number]> = [
|
||||||
|
[0.375, 0],
|
||||||
|
[0.375, 0.094],
|
||||||
|
[0.1523, 0.406],
|
||||||
|
// A small flat before the top edge: the casting has an arris rather
|
||||||
|
// than a knife edge, and at prop scale one chamfer is the difference
|
||||||
|
// between concrete and cardboard.
|
||||||
|
[0.0938, 0.978],
|
||||||
|
[0.078, 1],
|
||||||
|
]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ...and every corner of it is ROUNDED, which is not decoration.
|
||||||
|
*
|
||||||
|
* A casting comes out of a mould with radiused arrises -- the reference's
|
||||||
|
* are 20 to 30 mm on an 810 mm barrier -- and a section with mathematical
|
||||||
|
* corners reads as folded card at any size. Each corner is replaced by
|
||||||
|
* two points a radius back along each of its edges, which is a chamfer
|
||||||
|
* rather than a true fillet; across 20 mm nothing can tell, and the
|
||||||
|
* alternative is arcs at every vertex of every extruded thing in the
|
||||||
|
* catalogue.
|
||||||
|
*/
|
||||||
|
const R = 0.022
|
||||||
|
const back = (
|
||||||
|
p: readonly [number, number], to: readonly [number, number],
|
||||||
|
): readonly [number, number] => {
|
||||||
|
const dx = to[0] - p[0]
|
||||||
|
const dy = to[1] - p[1]
|
||||||
|
const len = Math.hypot(dx, dy) || 1
|
||||||
|
const d = Math.min(R, len * 0.45)
|
||||||
|
return [p[0] + (dx / len) * d, p[1] + (dy / len) * d]
|
||||||
|
}
|
||||||
|
const CORNERS: Array<readonly [number, number]> = []
|
||||||
|
for (let i = 0; i < HALF.length; i += 1) {
|
||||||
|
const p = HALF[i]!
|
||||||
|
// The first and last points sit ON the mirror line, so the edge on
|
||||||
|
// that side is the one the mirror supplies: the neighbour there is the
|
||||||
|
// same point with its x negated.
|
||||||
|
const prev = HALF[i - 1] ?? ([-p[0], p[1]] as const)
|
||||||
|
const next = HALF[i + 1] ?? ([-p[0], p[1]] as const)
|
||||||
|
CORNERS.push(back(p, prev), back(p, next))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ...and then the long edges are SUBDIVIDED.
|
||||||
|
*
|
||||||
|
* The two faces of this section are 0.3 of the height each, and a ring
|
||||||
|
* every 6 cm makes them into quads three times longer than they are
|
||||||
|
* wide. A quad is two triangles, its four corners carry four different
|
||||||
|
* mottle values, and the interpolation across the shared diagonal does
|
||||||
|
* not match on both sides of it: the flat faces came out crossed by
|
||||||
|
* broad diagonal facets. Nothing is wrong with the surface -- it is one
|
||||||
|
* plane -- and no amount of normal smoothing will help, because the seam
|
||||||
|
* is in the colour.
|
||||||
|
*
|
||||||
|
* Squarer quads fix it, and half of squarer is the section's job.
|
||||||
|
*/
|
||||||
|
const STEP = 0.075
|
||||||
|
for (let i = CORNERS.length - 1; i > 0; i -= 1) {
|
||||||
|
const a = CORNERS[i - 1]!
|
||||||
|
const b = CORNERS[i]!
|
||||||
|
const len = Math.hypot(b[0] - a[0], b[1] - a[1])
|
||||||
|
const cuts = Math.floor(len / STEP)
|
||||||
|
for (let k = cuts; k >= 1; k -= 1) {
|
||||||
|
const t = k / (cuts + 1)
|
||||||
|
CORNERS.splice(i, 0, [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const widthAt = (y: number): number => {
|
||||||
|
for (let i = 0; i < CORNERS.length - 1; i += 1) {
|
||||||
|
const [x0, y0] = CORNERS[i]!
|
||||||
|
const [x1, y1] = CORNERS[i + 1]!
|
||||||
|
if (y >= y0 && y <= y1) {
|
||||||
|
const t = y1 === y0 ? 0 : (y - y0) / (y1 - y0)
|
||||||
|
return x0 + (x1 - x0) * t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CORNERS.at(-1)![0]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One horizontal band of the section, mirrored and closed.
|
||||||
|
*
|
||||||
|
* `band(0, 1)` is the whole barrier; the two halves are what the end
|
||||||
|
* joint is made of, and a third band with its floor lifted is what the
|
||||||
|
* drainage openings are made of. Counter-clockwise seen from +Z -- up the
|
||||||
|
* right-hand face, across the top, back down the left -- which is the
|
||||||
|
* helper's whole contract and the same direction the plan sweep wanted.
|
||||||
|
*/
|
||||||
|
const band = (from: number, to: number): Section => {
|
||||||
|
const side: Array<readonly [number, number]> = [[widthAt(from), from]]
|
||||||
|
for (const c of CORNERS) if (c[1] > from && c[1] < to) side.push(c)
|
||||||
|
side.push([widthAt(to), to])
|
||||||
|
return [
|
||||||
|
...side.map(([x, y]) => [x * H, y * H] as const),
|
||||||
|
...[...side].reverse().map(([x, y]) => [-x * H, y * H] as const),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const section = band(0, 1)
|
||||||
|
|
||||||
|
const concrete = tint('concrete', jitter(random, 0.02))
|
||||||
|
// Lighter along the top, because the top of a barrier is the face that
|
||||||
|
// never gets splashed.
|
||||||
|
const crest = tint('concrete', 0.05)
|
||||||
|
// One ring every 6 cm, which is what gives the mottle somewhere to sit:
|
||||||
|
// three samples across its cell, where one sample gives smears. See the
|
||||||
|
// helper's `steps`.
|
||||||
|
const ringsPer = (span: number): number => Math.max(1, Math.round(span / 0.06))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The end joint is a HALF LAP, and it is the same joint at both ends.
|
||||||
|
*
|
||||||
|
* The first cut had a spigot on one end and a dark plate standing in for
|
||||||
|
* a pocket on the other, and the plate could not win: dark enough to read
|
||||||
|
* as a hole it became a black panel the size of the end face, light
|
||||||
|
* enough not to and it became a second projecting rib, which is exactly
|
||||||
|
* what the critic called it. A recess drawn in paint is a recess that is
|
||||||
|
* not there.
|
||||||
|
*
|
||||||
|
* A lap is a recess that is there. The upper half of the casting runs
|
||||||
|
* past the lower at one end and the lower past the upper at the other, so
|
||||||
|
* a row of identical barriers interleaves, and each end carries a real
|
||||||
|
* step that is visible from any angle with no shade of grey doing the
|
||||||
|
* work.
|
||||||
|
*/
|
||||||
|
const lap = 0.5
|
||||||
|
// Shallow. The reference's ends are very nearly flush, and the catalogue
|
||||||
|
// still wants a connector, so this is as little as will still read as a
|
||||||
|
// step from across a road: 3 cm on an 81 cm casting.
|
||||||
|
const lapD = H * 0.04
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The drainage openings, and they are REAL openings.
|
||||||
|
*
|
||||||
|
* Water has to cross the line a barrier makes, so every casting has a
|
||||||
|
* pair of holes through the bottom of it; they are the only thing that
|
||||||
|
* breaks the silhouette of an otherwise entirely constant section. The
|
||||||
|
* cheap way to suggest one is a dark patch, and it does not work here,
|
||||||
|
* because a barrier is looked at end on as often as not and a patch has
|
||||||
|
* no daylight behind it.
|
||||||
|
*/
|
||||||
|
// Small, and near the ENDS, which is where the reference's is: a single
|
||||||
|
// slot cut into the bottom edge just in from the corner. Put at the
|
||||||
|
// third points and made twice this size they stopped reading as
|
||||||
|
// openings in a casting and started reading as a shape decision.
|
||||||
|
const notchH = 0.06
|
||||||
|
const gap = (H * 0.16) / L
|
||||||
|
|
||||||
|
interface Span { readonly from: number; readonly to: number; readonly cut: Section }
|
||||||
|
const lapFrac = lapD / L
|
||||||
|
const spans: Span[] = [
|
||||||
|
{ from: 0, to: lapFrac, cut: band(lap, 1) },
|
||||||
|
{ from: lapFrac, to: 0.14 - gap / 2, cut: section },
|
||||||
|
{ from: 0.14 - gap / 2, to: 0.14 + gap / 2, cut: band(notchH, 1) },
|
||||||
|
{ from: 0.14 + gap / 2, to: 0.86 - gap / 2, cut: section },
|
||||||
|
{ from: 0.86 - gap / 2, to: 0.86 + gap / 2, cut: band(notchH, 1) },
|
||||||
|
{ from: 0.86 + gap / 2, to: 1 - lapFrac, cut: section },
|
||||||
|
{ from: 1 - lapFrac, to: 1, cut: band(0, lap) },
|
||||||
|
]
|
||||||
|
|
||||||
|
const pieces: BufferGeometry[] = spans.map((span) => {
|
||||||
|
const length = (span.to - span.from) * L
|
||||||
|
return extrudeGeometry(span.cut, length, [0, 0, span.from * L - L / 2], concrete, {
|
||||||
|
colourTop: crest,
|
||||||
|
steps: ringsPer(length),
|
||||||
|
// Every span is capped at both ends. Between two spans of the same
|
||||||
|
// section that would leave a pair of coincident faces, which is the
|
||||||
|
// trap `latheGeometry` exists to avoid -- but here no two neighbours
|
||||||
|
// share a section, so every one of these caps is a real step that has
|
||||||
|
// to be drawn.
|
||||||
|
capStart: true,
|
||||||
|
capEnd: true,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
bakeOcclusion(pieces, { strength: 0.35 })
|
||||||
|
|
||||||
|
return {
|
||||||
|
body: {
|
||||||
|
slot: 'concrete' as const,
|
||||||
|
// A low crease angle: concrete castings have arrises, and every edge
|
||||||
|
// on this shape is a real one that should stay sharp.
|
||||||
|
geometry: smoothNormals(mergeColoured(pieces), 18),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, overrides)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue