Show the contemporary kit in the inspector, by letting a catalogue entry belong to whichever registry wrote it.
This commit is contained in:
parent
d63d4911c6
commit
bb4896eca6
6 changed files with 524 additions and 202 deletions
|
|
@ -677,11 +677,11 @@
|
||||||
"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-08-28T13:01:08.200Z",
|
"installedAt": "2026-08-31T23:16:37.833Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\core\\geometry.ts",
|
"path": "src\\models\\contemporary-props\\core\\geometry.ts",
|
||||||
"sourceHash": "00ec2d2b459c909612841820f0afd2db97dc85729baec695493f6ec609178fbc"
|
"sourceHash": "a1b202f3ecdb6a0b614e1867702a965e9def1f4cdeaaaaa88b050f616eed9941"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\core\\index.ts",
|
"path": "src\\models\\contemporary-props\\core\\index.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-08-28T13:01:08.203Z",
|
"installedAt": "2026-08-31T23:16:37.836Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\ceramic-vase\\model.ts",
|
"path": "src\\models\\contemporary-props\\ceramic-vase\\model.ts",
|
||||||
|
|
@ -739,11 +739,11 @@
|
||||||
"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-08-28T13:01:08.204Z",
|
"installedAt": "2026-08-31T23:16:37.838Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\coffee-mug\\model.ts",
|
"path": "src\\models\\contemporary-props\\coffee-mug\\model.ts",
|
||||||
"sourceHash": "3ac9a507c369cb4c3a3badb53f818a2b8e985560da690108923692431b74e39e"
|
"sourceHash": "04c6a4c1b4f07727cf0b608ad833fef48f937ab19b3ba42348c1aa752c6c438d"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|
@ -754,11 +754,11 @@
|
||||||
"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-08-28T13:01:08.206Z",
|
"installedAt": "2026-08-31T23:16:37.839Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\pepper-mill\\model.ts",
|
"path": "src\\models\\contemporary-props\\pepper-mill\\model.ts",
|
||||||
"sourceHash": "132dd1816b7c74badc307d3b9d05fff0c0c9754508e740145a50e568ff34b1ff"
|
"sourceHash": "756e07f3dbb7641623cb4dcd3ad8c560ffe6c00b685afa8c7d08c69cb6b5d14d"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|
@ -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-08-28T13:01:08.209Z",
|
"installedAt": "2026-08-31T23:16:37.841Z",
|
||||||
"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-08-28T13:01:08.211Z",
|
"installedAt": "2026-08-31T23:16:37.844Z",
|
||||||
"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-08-28T13:01:08.215Z",
|
"installedAt": "2026-08-31T23:16:37.846Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\wine-glass\\model.ts",
|
"path": "src\\models\\contemporary-props\\wine-glass\\model.ts",
|
||||||
|
|
@ -814,9 +814,24 @@
|
||||||
"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-08-28T13:01:08.215Z",
|
"installedAt": "2026-08-31T23:16:37.846Z",
|
||||||
"files": [],
|
"files": [],
|
||||||
"dependencies": []
|
"dependencies": []
|
||||||
|
},
|
||||||
|
"@contemporary-props/street-bollard": {
|
||||||
|
"address": "@contemporary-props/street-bollard",
|
||||||
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
|
"version": "workspace",
|
||||||
|
"installedAt": "2026-08-31T23:16:37.843Z",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"path": "src\\models\\contemporary-props\\street-bollard\\model.ts",
|
||||||
|
"sourceHash": "7d6c63eec032363b49fab295cfc4ad7d0b0aed4e610aca54436c781d851ea552"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": [
|
||||||
|
"three@>=0.185.0"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
101
src/catalog.ts
101
src/catalog.ts
|
|
@ -48,6 +48,23 @@ import { createModel as createWell } from '@/models/medieval-kit/stone-well/mode
|
||||||
import { createModel as createCauldron } from '@/models/medieval-kit/iron-cauldron/model.ts'
|
import { createModel as createCauldron } from '@/models/medieval-kit/iron-cauldron/model.ts'
|
||||||
import { createModel as createCart } from '@/models/medieval-kit/hand-cart/model.ts'
|
import { createModel as createCart } from '@/models/medieval-kit/hand-cart/model.ts'
|
||||||
import { createModel as createVeg } from '@/models/medieval-kit/vegetables/model.ts'
|
import { createModel as createVeg } from '@/models/medieval-kit/vegetables/model.ts'
|
||||||
|
|
||||||
|
// --- @contemporary-props. Its metadata is a sidecar per model rather than
|
||||||
|
// one shared record, so it is imported as JSON rather than read off a map.
|
||||||
|
import { createModel as createCpCeramicVase } from '@/models/contemporary-props/ceramic-vase/model.ts'
|
||||||
|
import { createModel as createCpCoffeeMug } from '@/models/contemporary-props/coffee-mug/model.ts'
|
||||||
|
import { createModel as createCpWineGlass } from '@/models/contemporary-props/wine-glass/model.ts'
|
||||||
|
import { createModel as createCpPepperMill } from '@/models/contemporary-props/pepper-mill/model.ts'
|
||||||
|
import { createModel as createCpStockpot } from '@/models/contemporary-props/stockpot/model.ts'
|
||||||
|
import { createModel as createCpTrafficCone } from '@/models/contemporary-props/traffic-cone/model.ts'
|
||||||
|
import { createModel as createCpStreetBollard } from '@/models/contemporary-props/street-bollard/model.ts'
|
||||||
|
import cpMetaCeramicVase from '../contemporary-props/models/ceramic-vase/meta.json'
|
||||||
|
import cpMetaCoffeeMug from '../contemporary-props/models/coffee-mug/meta.json'
|
||||||
|
import cpMetaWineGlass from '../contemporary-props/models/wine-glass/meta.json'
|
||||||
|
import cpMetaPepperMill from '../contemporary-props/models/pepper-mill/meta.json'
|
||||||
|
import cpMetaStockpot from '../contemporary-props/models/stockpot/meta.json'
|
||||||
|
import cpMetaTrafficCone from '../contemporary-props/models/traffic-cone/meta.json'
|
||||||
|
import cpMetaStreetBollard from '../contemporary-props/models/street-bollard/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'
|
||||||
|
|
@ -226,10 +243,72 @@ const ACTIONS: Readonly<Record<string, (model: KitModel) => { label(): string; r
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function entryFor(id: string): Entry {
|
/**
|
||||||
const meta = MODEL_META[id]
|
* The second kit, kept apart from the first on purpose.
|
||||||
if (!meta) throw new Error(`no MODEL_META entry for ${id}`)
|
*
|
||||||
const factory = FACTORIES[id]
|
* Nothing is shared but the viewer: different palette, different vocabulary,
|
||||||
|
* different century. Holding both in one map would mean one namespace for two
|
||||||
|
* kits and a lookup that cannot say which one an id belongs to.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* What the viewer needs out of a model's metadata, whichever kit wrote it.
|
||||||
|
*
|
||||||
|
* The medieval kit types this precisely in its own `meta.ts`; the contemporary
|
||||||
|
* one is JSON and arrives untyped. Structural is the honest description: the
|
||||||
|
* catalogue only reads these fields and neither kit's extra ones concern it.
|
||||||
|
*/
|
||||||
|
interface ModelMetaLike {
|
||||||
|
readonly title: string
|
||||||
|
readonly description: string
|
||||||
|
readonly controls: Readonly<Record<string, {
|
||||||
|
label: string; min: number; max: number; step: number; unit?: string
|
||||||
|
}>>
|
||||||
|
readonly materialSlots: readonly string[]
|
||||||
|
readonly parts: readonly string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const CONTEMPORARY_ORDER = [
|
||||||
|
'ceramic-vase', 'coffee-mug', 'wine-glass', 'pepper-mill',
|
||||||
|
'stockpot', 'traffic-cone', 'street-bollard',
|
||||||
|
] as const
|
||||||
|
|
||||||
|
const CONTEMPORARY_FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
||||||
|
'ceramic-vase': as(createCpCeramicVase),
|
||||||
|
'coffee-mug': as(createCpCoffeeMug),
|
||||||
|
'wine-glass': as(createCpWineGlass),
|
||||||
|
'pepper-mill': as(createCpPepperMill),
|
||||||
|
'stockpot': as(createCpStockpot),
|
||||||
|
'traffic-cone': as(createCpTrafficCone),
|
||||||
|
'street-bollard': as(createCpStreetBollard),
|
||||||
|
}
|
||||||
|
|
||||||
|
const CONTEMPORARY_META: Readonly<Record<string, ModelMetaLike>> = {
|
||||||
|
'ceramic-vase': cpMetaCeramicVase as ModelMetaLike,
|
||||||
|
'coffee-mug': cpMetaCoffeeMug as ModelMetaLike,
|
||||||
|
'wine-glass': cpMetaWineGlass as ModelMetaLike,
|
||||||
|
'pepper-mill': cpMetaPepperMill as ModelMetaLike,
|
||||||
|
'stockpot': cpMetaStockpot as ModelMetaLike,
|
||||||
|
'traffic-cone': cpMetaTrafficCone as ModelMetaLike,
|
||||||
|
'street-bollard': cpMetaStreetBollard as ModelMetaLike,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One catalogue entry, from whichever kit the model belongs to.
|
||||||
|
*
|
||||||
|
* The namespace and the two maps used to be hard-coded to the medieval kit,
|
||||||
|
* which was correct while there was one. Passing them in is the whole of what
|
||||||
|
* a second registry needed: nothing else in here knows or cares which kit it
|
||||||
|
* is looking at, because both describe themselves the same way.
|
||||||
|
*/
|
||||||
|
function entryFor(
|
||||||
|
id: string,
|
||||||
|
namespace = '@medieval-kit',
|
||||||
|
metaOf: Readonly<Record<string, ModelMetaLike>> = MODEL_META as unknown as Readonly<Record<string, ModelMetaLike>>,
|
||||||
|
factoryOf: Readonly<Record<string, () => KitModel>> = FACTORIES,
|
||||||
|
): Entry {
|
||||||
|
const meta = metaOf[id]
|
||||||
|
if (!meta) throw new Error(`no metadata for ${id}`)
|
||||||
|
const factory = factoryOf[id]
|
||||||
if (!factory) throw new Error(`no factory registration for ${id}`)
|
if (!factory) throw new Error(`no factory registration for ${id}`)
|
||||||
|
|
||||||
const specs: ParamSpec[] = Object.entries(meta.controls).map(([key, control]) => ({
|
const specs: ParamSpec[] = Object.entries(meta.controls).map(([key, control]) => ({
|
||||||
|
|
@ -243,8 +322,8 @@ function entryFor(id: string): Entry {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
namespace: '@medieval-kit',
|
namespace,
|
||||||
address: `@medieval-kit/${id}`,
|
address: `${namespace}/${id}`,
|
||||||
who: meta.description,
|
who: meta.description,
|
||||||
build: () => {
|
build: () => {
|
||||||
const model = factory()
|
const model = factory()
|
||||||
|
|
@ -551,6 +630,12 @@ export const REGISTRIES = [
|
||||||
// 'kit' first: what whoever opens the inspector sees first is the whole kit.
|
// 'kit' first: what whoever opens the inspector sees first is the whole kit.
|
||||||
entries: ['kit', ...MEDIEVAL_ORDER] as readonly string[],
|
entries: ['kit', ...MEDIEVAL_ORDER] as readonly string[],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
namespace: '@contemporary-props',
|
||||||
|
scheme: 'file:',
|
||||||
|
rest: 'contemporary-props/dist/registry.json',
|
||||||
|
entries: [...CONTEMPORARY_ORDER] as readonly string[],
|
||||||
|
},
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -598,4 +683,8 @@ export const CATALOG: Record<string, Entry> = {
|
||||||
},
|
},
|
||||||
kit: kitEntry(),
|
kit: kitEntry(),
|
||||||
...Object.fromEntries(MEDIEVAL_ORDER.map((id) => [id, entryFor(id)])),
|
...Object.fromEntries(MEDIEVAL_ORDER.map((id) => [id, entryFor(id)])),
|
||||||
|
...Object.fromEntries(CONTEMPORARY_ORDER.map((id) => [
|
||||||
|
id,
|
||||||
|
entryFor(id, '@contemporary-props', CONTEMPORARY_META, CONTEMPORARY_FACTORIES),
|
||||||
|
])),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ export interface CoffeeMugConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const coffeeMugDefaults: CoffeeMugConfig = {
|
export const coffeeMugDefaults: CoffeeMugConfig = {
|
||||||
height: 0.095,
|
height: 0.1,
|
||||||
radius: 0.041,
|
radius: 0.041,
|
||||||
// A slight taper. Dead straight is a value in the family, not the default:
|
// A slight taper. Dead straight is a value in the family, not the default:
|
||||||
// most mugs narrow a little toward the foot and it keeps the silhouette
|
// most mugs narrow a little toward the foot and it keeps the silhouette
|
||||||
|
|
@ -106,16 +106,29 @@ export function createModel(overrides: Partial<CoffeeMugConfig> = {}) {
|
||||||
// One profile, up the outside, over the rim, down the bore. A single
|
// One profile, up the outside, over the rim, down the bore. A single
|
||||||
// lathe leaves no coincident faces where an outer and an inner shell
|
// lathe leaves no coincident faces where an outer and an inner shell
|
||||||
// would meet, and the rim thickness falls out of the turn-around.
|
// would meet, and the rim thickness falls out of the turn-around.
|
||||||
|
// The foot's corner radius. A fifth of the mug's radius, which is what
|
||||||
|
// the reference measures and is generous next to anything turned.
|
||||||
|
const foot = R * 0.2
|
||||||
const half = wall / 2
|
const half = wall / 2
|
||||||
const rimY = H - half
|
const rimY = H - half
|
||||||
const rimX = R - half
|
const rimX = R - half
|
||||||
const s45 = half * Math.SQRT1_2
|
const s45 = half * Math.SQRT1_2
|
||||||
const levels: Level[] = [
|
const levels: Level[] = [
|
||||||
// A short chamfer off the table, so the foot has an edge that reads
|
/**
|
||||||
// as trimmed rather than the wall dying into the ground plane.
|
* A ROUNDED foot, not a chamfer.
|
||||||
{ y: 0, radius: F * 0.96 },
|
*
|
||||||
{ y: 0.0035, radius: rOut(0.0035) },
|
* The 3.5 mm bevel that was here read as a trimmed edge, which is
|
||||||
{ y: H * 0.2, radius: rOut(H * 0.2) },
|
* what a thrown pot has and what a slip-cast mug does not: the
|
||||||
|
* reference turns the corner over about a fifth of the radius and
|
||||||
|
* that soft corner is most of why it reads as a mug rather than as a
|
||||||
|
* tube with a lid missing. Sampled at 30 and 60 degrees so the
|
||||||
|
* smoothing takes it as one curve.
|
||||||
|
*/
|
||||||
|
{ y: 0, radius: F - foot },
|
||||||
|
{ y: foot * 0.134, radius: F - foot * 0.5 },
|
||||||
|
{ y: foot * 0.5, radius: F - foot * 0.134 },
|
||||||
|
{ y: foot, radius: rOut(foot) },
|
||||||
|
{ y: H * 0.3, radius: rOut(H * 0.3) },
|
||||||
{ y: H * 0.45, radius: rOut(H * 0.45) },
|
{ y: H * 0.45, radius: rOut(H * 0.45) },
|
||||||
{ y: H * 0.7, radius: rOut(H * 0.7) },
|
{ y: H * 0.7, radius: rOut(H * 0.7) },
|
||||||
{ y: H * 0.88, radius: rOut(H * 0.88) },
|
{ y: H * 0.88, radius: rOut(H * 0.88) },
|
||||||
|
|
@ -148,11 +161,19 @@ export function createModel(overrides: Partial<CoffeeMugConfig> = {}) {
|
||||||
)
|
)
|
||||||
|
|
||||||
/* ----------------------------------------------------------- handle */
|
/* ----------------------------------------------------------- handle */
|
||||||
// Strap section: deeper across (z, along the wall) than radially. Built
|
/**
|
||||||
// square by arcBarGeometry, flattened by a scale before it moves.
|
* Strap section: nearly square, and DEEPER in the plane of the loop.
|
||||||
|
*
|
||||||
|
* It was the other way round, 11.5 mm across the wall against 6 mm
|
||||||
|
* radially, so the widest face of the handle was the one turned toward
|
||||||
|
* anyone looking at the mug from the side. That is a ribbon, and a
|
||||||
|
* handle you could not get a finger round. A real one is close to
|
||||||
|
* square and if anything deeper the way the loop runs, because that is
|
||||||
|
* the direction it has to be stiff in.
|
||||||
|
*/
|
||||||
const scaleT = R / 0.041
|
const scaleT = R / 0.041
|
||||||
const tRad = Math.min(0.0072, Math.max(0.0048, 0.006 * scaleT))
|
const tRad = Math.min(0.0098, Math.max(0.0062, 0.0082 * scaleT))
|
||||||
const widthZ = Math.min(0.0135, Math.max(0.0088, 0.0115 * scaleT))
|
const widthZ = Math.min(0.0092, Math.max(0.0058, 0.0074 * scaleT))
|
||||||
|
|
||||||
// Where the loop leaves the wall.
|
// Where the loop leaves the wall.
|
||||||
const topY = H * 0.78
|
const topY = H * 0.78
|
||||||
|
|
@ -187,11 +208,15 @@ export function createModel(overrides: Partial<CoffeeMugConfig> = {}) {
|
||||||
// body both ends sit at the same depth instead of one floating proud.
|
// body both ends sit at the same depth instead of one floating proud.
|
||||||
const alpha = Math.atan2(-chordX, chordY)
|
const alpha = Math.atan2(-chordX, chordY)
|
||||||
|
|
||||||
|
// Twelve-sided, so the loop has no hard edge running its length. A
|
||||||
|
// square strap's four corners catch light as ridges and no amount of
|
||||||
|
// getting the proportions right stops that reading as a folded ribbon.
|
||||||
const strap = arcBarGeometry(
|
const strap = arcBarGeometry(
|
||||||
rLoop, tRad, -thetaE, thetaE, 22, [0, 0, 0],
|
rLoop, tRad, -thetaE, thetaE, 22, [0, 0, 0],
|
||||||
// The body's own glaze colour: a handle tinted separately shows the
|
// The body's own glaze colour: a handle tinted separately shows the
|
||||||
// join as a colour edge before it shows it as geometry.
|
// join as a colour edge before it shows it as geometry.
|
||||||
glaze.clone(),
|
glaze.clone(),
|
||||||
|
12,
|
||||||
)
|
)
|
||||||
// Flatten to a strap, tilt to the wall, then carry to the wall. Built
|
// Flatten to a strap, tilt to the wall, then carry to the wall. Built
|
||||||
// at the origin in the XY plane, which is already the vertical plane
|
// at the origin in the XY plane, which is already the vertical plane
|
||||||
|
|
|
||||||
|
|
@ -504,6 +504,18 @@ export function arcBarGeometry(
|
||||||
segments: number,
|
segments: number,
|
||||||
centre: Vec3,
|
centre: Vec3,
|
||||||
colour: Color,
|
colour: Color,
|
||||||
|
/**
|
||||||
|
* Sides of the CROSS SECTION. Four, the default, is the square this always
|
||||||
|
* was and reproduces it corner for corner.
|
||||||
|
*
|
||||||
|
* More than four rounds it, and `thickness` goes on meaning the same thing:
|
||||||
|
* the width across the section. A square handle strap has four hard edges
|
||||||
|
* running the length of the loop and they catch the light as ridges, which
|
||||||
|
* is what made a mug handle read as a folded ribbon however well its
|
||||||
|
* proportions were set. A real one is an oval, and an oval is what a
|
||||||
|
* twelve-sided section scaled unevenly gives.
|
||||||
|
*/
|
||||||
|
sides = 4,
|
||||||
): BufferGeometry {
|
): BufferGeometry {
|
||||||
const sink: Sink = { position: [], color: [] }
|
const sink: Sink = { position: [], color: [] }
|
||||||
const h = thickness / 2
|
const h = thickness / 2
|
||||||
|
|
@ -519,21 +531,36 @@ export function arcBarGeometry(
|
||||||
const at = (su: number, sv: number): Vec3 =>
|
const at = (su: number, sv: number): Vec3 =>
|
||||||
[px + sv * h * rx, py + sv * h * ry, cz + su * h]
|
[px + sv * h * rx, py + sv * h * ry, cz + su * h]
|
||||||
// u = the plane normal, v = the radial direction. Since u×v equals the
|
// u = the plane normal, v = the radial direction. Since u×v equals the
|
||||||
// tangent, this ordering is counter-clockwise relative to the sweep direction.
|
// tangent, this ordering is counter-clockwise relative to the sweep
|
||||||
rings.push([at(1, 1), at(-1, 1), at(-1, -1), at(1, -1)])
|
// direction, and the half-step offset is what puts a four-sided section's
|
||||||
|
// corners exactly where the hand-written [1,1] [-1,1] [-1,-1] [1,-1] put
|
||||||
|
// them. `reach` keeps `thickness` meaning the width across: the corner
|
||||||
|
// circle circumscribes the square at four sides and IS the section at
|
||||||
|
// more.
|
||||||
|
const reach = sides === 4 ? Math.SQRT2 : 1
|
||||||
|
const ring: Vec3[] = []
|
||||||
|
for (let j = 0; j < sides; j += 1) {
|
||||||
|
const t = ((j + 0.5) / sides) * Math.PI * 2
|
||||||
|
ring.push(at(Math.cos(t) * reach, Math.sin(t) * reach))
|
||||||
|
}
|
||||||
|
rings.push(ring)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < segments; i += 1) {
|
for (let i = 0; i < segments; i += 1) {
|
||||||
const a = rings[i]!, b = rings[i + 1]!
|
const a = rings[i]!, b = rings[i + 1]!
|
||||||
for (let j = 0; j < 4; j += 1) {
|
for (let j = 0; j < sides; j += 1) {
|
||||||
const k = (j + 1) % 4
|
const k = (j + 1) % sides
|
||||||
quad(sink, a[j]!, a[k]!, b[k]!, b[j]!, colour)
|
quad(sink, a[j]!, a[k]!, b[k]!, b[j]!, colour)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fans rather than quads, because the section is no longer always four
|
||||||
|
// sided. At four they are the same two triangles the quad was.
|
||||||
const first = rings[0]!, last = rings[segments]!
|
const first = rings[0]!, last = rings[segments]!
|
||||||
quad(sink, first[0]!, first[3]!, first[2]!, first[1]!, colour) // start cap
|
for (let j = 1; j < sides - 1; j += 1) {
|
||||||
quad(sink, last[0]!, last[1]!, last[2]!, last[3]!, colour) // end cap
|
tri(sink, first[0]!, first[j + 1]!, first[j]!, colour)
|
||||||
|
tri(sink, last[0]!, last[j]!, last[j + 1]!, colour)
|
||||||
|
}
|
||||||
return finish(sink)
|
return finish(sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,44 @@
|
||||||
/**
|
/**
|
||||||
* @contemporary-props/pepper-mill
|
* @contemporary-props/pepper-mill
|
||||||
*
|
*
|
||||||
* Table pepper mill: the longest profile curve in the kit at the lowest cost,
|
* Table pepper mill: the longest profile in the kit at the lowest cost, and
|
||||||
* and the first radial cut.
|
* the first radial cut.
|
||||||
*
|
*
|
||||||
* The body is one lathe and the whole object is decided by where that curve
|
* SECOND VERSION, and the first one built against a photograph. The first was
|
||||||
* turns. Reading from the table up: a drum for the grinder housing, a turn
|
* a turned baluster: a drum, a cove into a waist, a swell back out and a domed
|
||||||
* inward to the waist, a swell back out to an upper belly that stays narrower
|
* head, with the flutes doing the work of telling you it was not a chess
|
||||||
* than the base, then a quick fall into the neck the cap sits over. The upper
|
* piece. It was a good bottle. What a present-day mill actually is, is a
|
||||||
* belly NARROWER than the base is the load-bearing choice: make them equal and
|
* STRAIGHT tube: one cylinder from the collar to the flat top, a polished
|
||||||
* the silhouette is a baluster, make the top wider and it is a chess queen
|
* steel ring at the base, a band of vertical flutes cut around the middle for
|
||||||
* about to tip over.
|
* grip, a flat top and a small knurled steel knob. There is no waist and there
|
||||||
|
* is no dome, and the profile that has neither is both simpler and right.
|
||||||
*
|
*
|
||||||
* The flutes are what stop it reading as a chess piece even so. A lathe cannot
|
* The flute band is the model's reason for being fourth in the build order:
|
||||||
* cut a groove, so the grip is built the other way round: a radial array of
|
* the catalogue's row for it reads "the flute grip is the first radial cut",
|
||||||
* slim chamfered bars standing a millimetre proud of the waist. Because the
|
* and everything after it that arrays anything around an axis copies what
|
||||||
* waist is the narrowest point of the profile, a straight vertical bar held at
|
* happens here. So the band is not decoration and must not be optional in the
|
||||||
* a fixed radius is proud exactly in the middle and sinks into the body at
|
* sense of being absent by default.
|
||||||
* both ends on its own — no cap, no fade, both ends terminate inside the
|
*
|
||||||
* solid. The proud height is recomputed against the actual profile for every
|
* The band is a RECESS with ribs standing back out of it, not ribs stuck on a
|
||||||
* configuration, so a fat waist under a low bulge cannot push a bar end
|
* plain tube. Two things follow from that and both are visible. The rib ends
|
||||||
* through the surface.
|
* terminate against the step at either end of the recess instead of stopping
|
||||||
|
* in mid-air, which is what a machined flute does. And the ribs stay under the
|
||||||
|
* tube's own radius, so the silhouette of the mill is a clean cylinder and the
|
||||||
|
* flutes read from shading rather than from a bumpy outline.
|
||||||
|
*
|
||||||
|
* Proportions are measured, not chosen: the reference is 3.6 diameters tall,
|
||||||
|
* the steel collar takes the bottom 0.12 of it and the flute band runs from
|
||||||
|
* 0.31 to 0.79 of the tube. The band is nearly half the height, which is far
|
||||||
|
* more than it looks like it should be until it is drawn at anything less.
|
||||||
*
|
*
|
||||||
* Parts: `body` and `cap`. The cap is its own part with its origin at the seat
|
* Parts: `body` and `cap`. The cap is its own part with its origin at the seat
|
||||||
* so `cap.anchor.rotation.y` is the grinding action, and the `twist` action
|
* so `cap.anchor.rotation.y` is the grinding action. A smooth head would turn
|
||||||
* does exactly that. A turned dome is rotationally invisible, so the motion is
|
* invisibly, so the knurl on the knob is what carries the motion.
|
||||||
* carried by the crown: the stainless finial nut is a 6-segment lathe — a hex
|
|
||||||
* acorn — and its facets are what you see move.
|
|
||||||
*/
|
*/
|
||||||
import { type BufferGeometry } from 'three'
|
import { type BufferGeometry } from 'three'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
bakeOcclusion,
|
||||||
chamferedBoxGeometry,
|
chamferedBoxGeometry,
|
||||||
createKitModel,
|
createKitModel,
|
||||||
createTinter,
|
createTinter,
|
||||||
|
|
@ -42,15 +50,15 @@ import {
|
||||||
} from '../core/index.ts'
|
} from '../core/index.ts'
|
||||||
|
|
||||||
export interface PepperMillConfig {
|
export interface PepperMillConfig {
|
||||||
/** Overall height, finial included (metres). */
|
/** Overall height, knob included (metres). */
|
||||||
readonly height: number
|
readonly height: number
|
||||||
/** Radius of the base drum (metres). */
|
/** Radius of the tube (metres). */
|
||||||
readonly baseRadius: number
|
readonly baseRadius: number
|
||||||
/** Waist radius as a fraction of the base radius. */
|
/** How deep the flute band is cut, as a fraction of the radius. */
|
||||||
readonly waist: number
|
readonly bandDepth: number
|
||||||
/** Where the waist sits, as a fraction of the body height. */
|
/** Centre of the flute band, as a fraction of the tube's height. */
|
||||||
readonly waistAt: number
|
readonly bandAt: number
|
||||||
/** Number of grip flutes around the waist. */
|
/** Number of grip flutes around the band. */
|
||||||
readonly flutes: number
|
readonly flutes: number
|
||||||
/** Sides around the revolve. */
|
/** Sides around the revolve. */
|
||||||
readonly segments: number
|
readonly segments: number
|
||||||
|
|
@ -59,14 +67,19 @@ export interface PepperMillConfig {
|
||||||
|
|
||||||
export const pepperMillDefaults: PepperMillConfig = {
|
export const pepperMillDefaults: PepperMillConfig = {
|
||||||
height: 0.23,
|
height: 0.23,
|
||||||
baseRadius: 0.03,
|
// 3.65 diameters tall, which is what the reference measures. The first
|
||||||
// The waist is what separates a mill from a rolling pin. Below ~0.5 it
|
// version was 3.8 and the difference is not the point: the point is that
|
||||||
// reads as an hourglass, above ~0.7 the profile goes straight and the
|
// this one is a tube and that one was a baluster.
|
||||||
// flutes are doing all the work alone.
|
baseRadius: 0.0315,
|
||||||
waist: 0.58,
|
bandDepth: 0.075,
|
||||||
waistAt: 0.5,
|
bandAt: 0.55,
|
||||||
flutes: 16,
|
// The reference carries about forty and forty is wrong here, which is the
|
||||||
segments: 32,
|
// difference between copying a photograph and reading one. At prop scale a
|
||||||
|
// mill is a hundred and fifty pixels wide, half of them facing the camera:
|
||||||
|
// forty ribs is four pixels each and the band turns into a grey smear.
|
||||||
|
// Twenty-two is the same object at the size it is actually seen.
|
||||||
|
flutes: 22,
|
||||||
|
segments: 40,
|
||||||
seed: 23,
|
seed: 23,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,20 +90,6 @@ export interface PepperMillActions {
|
||||||
twist(radians?: number): void
|
twist(radians?: number): void
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Linear read of a lathe profile at an arbitrary height. */
|
|
||||||
function radiusAt(levels: readonly Level[], y: number): number {
|
|
||||||
if (y <= levels[0]!.y) return levels[0]!.radius
|
|
||||||
for (let i = 0; i < levels.length - 1; i += 1) {
|
|
||||||
const a = levels[i]!
|
|
||||||
const b = levels[i + 1]!
|
|
||||||
if (y <= b.y) {
|
|
||||||
const t = (y - a.y) / Math.max(1e-9, b.y - a.y)
|
|
||||||
return a.radius + t * (b.radius - a.radius)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return levels.at(-1)!.radius
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createModel(overrides: Partial<PepperMillConfig> = {}) {
|
export function createModel(overrides: Partial<PepperMillConfig> = {}) {
|
||||||
return createKitModel<PepperMillConfig, 'wood' | 'stainless', PepperMillParts, PepperMillActions>({
|
return createKitModel<PepperMillConfig, 'wood' | 'stainless', PepperMillParts, PepperMillActions>({
|
||||||
id: 'pepper-mill',
|
id: 'pepper-mill',
|
||||||
|
|
@ -102,159 +101,167 @@ export function createModel(overrides: Partial<PepperMillConfig> = {}) {
|
||||||
const H = Math.min(0.45, Math.max(0.12, config.height))
|
const H = Math.min(0.45, Math.max(0.12, config.height))
|
||||||
// The radius is clamped against the height, not just on its own: a mill
|
// The radius is clamped against the height, not just on its own: a mill
|
||||||
// is between roughly two and six diameters tall. Outside that band the
|
// is between roughly two and six diameters tall. Outside that band the
|
||||||
// squat end turns into a jar on a pedestal and the thin end into a
|
// squat end turns into a jar and the thin end into a taper candle.
|
||||||
// taper candle, and both were seen in a render before this clamp.
|
|
||||||
const R = Math.min(H * 0.21, Math.max(H * 0.08, Math.min(0.05, Math.max(0.015, config.baseRadius))))
|
const R = Math.min(H * 0.21, Math.max(H * 0.08, Math.min(0.05, Math.max(0.015, config.baseRadius))))
|
||||||
const segments = Math.max(12, Math.round(config.segments))
|
const segments = Math.max(12, Math.round(config.segments))
|
||||||
const waistFraction = Math.min(0.68, Math.max(0.45, config.waist))
|
const flutes = Math.max(12, Math.min(64, Math.round(config.flutes)))
|
||||||
const waistAt = Math.min(0.6, Math.max(0.42, config.waistAt))
|
const bandDepth = Math.min(0.12, Math.max(0.02, config.bandDepth))
|
||||||
const flutes = Math.max(8, Math.min(28, Math.round(config.flutes)))
|
const bandAt = Math.min(0.72, Math.max(0.38, config.bandAt))
|
||||||
|
|
||||||
// The cap takes the top ~16% of the height and overlaps the neck by a
|
/* ------------------------------------------------------------ layout */
|
||||||
// few millimetres, so the parting line is a step rather than a seam of
|
// Read bottom up, all as fractions of the whole height: the steel collar
|
||||||
// two coplanar rings.
|
// covers the grinder housing, the tube runs to the seat, the cap disc
|
||||||
const bodyH = H * 0.84
|
// sits on the seat and the knob stands on the disc.
|
||||||
const seat = bodyH - 0.004
|
const collarH = H * 0.12
|
||||||
|
const knobH = H * 0.042
|
||||||
|
const capDisc = H * 0.028
|
||||||
|
const seat = H - knobH - capDisc
|
||||||
|
const bodyH = seat
|
||||||
|
|
||||||
const W = R * waistFraction
|
const bandHalf = bodyH * 0.24
|
||||||
const waistY = bodyH * waistAt
|
const bandLo = bodyH * bandAt - bandHalf
|
||||||
// The grip is a band, not a point: the waist holds its radius for a
|
const bandHi = bodyH * bandAt + bandHalf
|
||||||
// stretch so the flutes sit on something, and the cove into and out of
|
const recessR = R * (1 - bandDepth)
|
||||||
// it is what makes the profile a mill rather than a bottle.
|
|
||||||
const bandHalf = bodyH * 0.09
|
|
||||||
// The upper belly is clearly SMALLER than the drum: the masses must
|
|
||||||
// step down going up — drum, belly, head — or the object turns into a
|
|
||||||
// chess bishop. It still follows the waist up when the waist is fat, so
|
|
||||||
// the swell never dips below the flute tops.
|
|
||||||
const upperR = R * Math.max(0.72, waistFraction * 1.08)
|
|
||||||
const upperY = bodyH * 0.74
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------- body */
|
/* -------------------------------------------------------------- tube */
|
||||||
const waistLo = waistY - bandHalf
|
// A step at each end of the recess rather than a ramp: the flutes have
|
||||||
const waistHi = waistY + bandHalf
|
// to stop against something, and on the reference they stop against a
|
||||||
// The shoulder backs off when the waist sits low, so the cove into the
|
// machined shoulder you can see the shadow of.
|
||||||
// grip keeps some run and the drum does not turn into a pedestal.
|
|
||||||
const shoulderY = Math.min(bodyH * 0.3, waistLo - bodyH * 0.08)
|
|
||||||
const drumTop = shoulderY - bodyH * 0.1
|
|
||||||
const bodyLevels: Level[] = [
|
const bodyLevels: Level[] = [
|
||||||
{ y: 0, radius: R * 0.97 },
|
{ y: 0, radius: R },
|
||||||
// Crisp foot, same reasoning as the vase: the profile must leave the
|
{ y: bandLo - 0.0008, radius: R },
|
||||||
// table vertically or the mill looks like it is sinking into it.
|
{ y: bandLo, radius: recessR },
|
||||||
{ y: 0.005, radius: R },
|
{ y: bandHi, radius: recessR },
|
||||||
// The grinder drum: a near-cylinder, because that is the one straight
|
{ y: bandHi + 0.0008, radius: R },
|
||||||
// stretch a mill has and softening it is what turned the first render
|
{ y: bodyH - 0.0012, radius: R },
|
||||||
// into a crayon.
|
// The top edge is broken, not sharp: a tube cut off square catches a
|
||||||
{ y: drumTop, radius: R * 0.985 },
|
// white line along its rim from every angle.
|
||||||
{ y: shoulderY, radius: R * 0.93 },
|
{ y: bodyH, radius: R * 0.988 },
|
||||||
{ y: (shoulderY + waistLo) / 2, radius: ((R * 0.93 + W) / 2) * 1.015 },
|
|
||||||
{ y: waistLo, radius: W * 1.01 },
|
|
||||||
{ y: waistY, radius: W },
|
|
||||||
{ y: waistHi, radius: W * 1.01 },
|
|
||||||
// The rise off the grip band is deliberately quick, so the flute bar
|
|
||||||
// ends go under the surface within a couple of millimetres.
|
|
||||||
{ y: waistHi + (upperY - waistHi) * 0.4, radius: ((W + upperR) / 2) * 1.02 },
|
|
||||||
{ y: upperY, radius: upperR },
|
|
||||||
{ y: bodyH * 0.83, radius: upperR * 0.9 },
|
|
||||||
// The throat: the belly turns in to a short neck the cap's lip steps
|
|
||||||
// out over, so the parting line reads as a groove under the head.
|
|
||||||
{ y: bodyH * 0.91, radius: R * 0.56 },
|
|
||||||
{ y: bodyH, radius: R * 0.52 },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const woodBase = tint('wood', jitter(random, 0.02))
|
const woodBase = tint('wood', jitter(random, 0.02))
|
||||||
const pieces: BufferGeometry[] = [
|
const pieces: BufferGeometry[] = [
|
||||||
latheGeometry(bodyLevels, segments, [0, 0, 0], woodBase, {
|
latheGeometry(bodyLevels, segments, [0, 0, 0], woodBase, {
|
||||||
colourTop: tint('wood', 0.04),
|
colourTop: tint('wood', 0.035),
|
||||||
capBottom: true,
|
capBottom: true,
|
||||||
capTop: true,
|
capTop: true,
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
|
|
||||||
/* ----------------------------------------------------------- flutes */
|
/* ------------------------------------------------------------ flutes */
|
||||||
// Half the vertical span of a flute bar: the grip band plus enough of
|
// The ribs come back out of the recess and stop just under the tube's
|
||||||
// the cove beyond it for the profile to rise over the bar ends.
|
// own flats. Under, not level: a revolve of `segments` sides has its
|
||||||
const fluteHalf = bodyH * 0.13
|
// faces at R·cos(pi/segments), and a rib reaching exactly that height
|
||||||
// How far a bar stands proud of the waist. Capped by the profile: the
|
// fights the flat it is sitting on.
|
||||||
// bar ends must stay under the surface, including the flat-to-flat
|
|
||||||
// shrink of the revolve's polygon.
|
|
||||||
const inscribed = Math.cos(Math.PI / segments)
|
const inscribed = Math.cos(Math.PI / segments)
|
||||||
const endRadius = Math.min(
|
const ribOuter = R * inscribed * 0.99
|
||||||
radiusAt(bodyLevels, waistY - fluteHalf),
|
const ribDepth = Math.max(0.0004, ribOuter - recessR)
|
||||||
radiusAt(bodyLevels, waistY + fluteHalf),
|
// Nearly touching: the grip reads from the narrow dark gaps between the
|
||||||
) * inscribed
|
// ribs, not from the ribs themselves.
|
||||||
const proud = Math.max(0.0005, Math.min(R * 0.04, endRadius - W - 0.0005))
|
// 0.78 of the pitch: wide ribs and narrow grooves, the way a machined
|
||||||
const depth = R * 0.22
|
// grip goes. At 0.66 the lit faces came out narrower than the shadows
|
||||||
// Nearly touching: the grip reads from the narrow dark gaps between
|
// between them and the band read as a picket fence.
|
||||||
// ridges, not from the ridges themselves.
|
const ribWidth = Math.min((2 * Math.PI * recessR) / flutes * 0.78, R * 0.2)
|
||||||
const barWidth = Math.min((2 * Math.PI * W) / flutes * 0.72, R * 0.2)
|
const ribCentre = recessR + ribDepth / 2
|
||||||
const barCentreRadius = W + proud - depth / 2
|
|
||||||
|
|
||||||
for (let i = 0; i < flutes; i += 1) {
|
for (let i = 0; i < flutes; i += 1) {
|
||||||
const angle = (i / flutes) * Math.PI * 2
|
const angle = (i / flutes) * Math.PI * 2
|
||||||
const bar = chamferedBoxGeometry(
|
const rib = chamferedBoxGeometry(
|
||||||
[barWidth, depth],
|
[ribWidth, ribDepth],
|
||||||
[barWidth, depth],
|
[ribWidth, ribDepth],
|
||||||
fluteHalf * 2,
|
bandHi - bandLo,
|
||||||
Math.min(0.0008, barWidth * 0.25),
|
Math.min(0.0005, ribWidth * 0.22),
|
||||||
[0, 0, 0],
|
[0, 0, 0],
|
||||||
// Subtle: the flutes are turned from the same blank as the body,
|
// Turned from the same blank as the tube, so they may not jump in
|
||||||
// so they may not jump in tone. Relief and occlusion carry them.
|
// tone. Relief and occlusion carry them.
|
||||||
tint('wood', jitter(random, 0.015)),
|
tint('wood', jitter(random, 0.012)),
|
||||||
)
|
)
|
||||||
// Built at the origin, turned, then carried out to the waist.
|
rib.rotateY(angle)
|
||||||
bar.rotateY(angle)
|
rib.translate(
|
||||||
bar.translate(Math.sin(angle) * barCentreRadius, waistY, Math.cos(angle) * barCentreRadius)
|
Math.sin(angle) * ribCentre,
|
||||||
pieces.push(bar)
|
(bandLo + bandHi) / 2,
|
||||||
|
Math.cos(angle) * ribCentre,
|
||||||
|
)
|
||||||
|
pieces.push(rib)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------- cap */
|
/**
|
||||||
// Everything below is LOCAL to the seat: the part's origin sits there
|
* Darken what the ribs shade, before anything is merged.
|
||||||
// so rotation.y grinds.
|
*
|
||||||
const capH = H - seat
|
* Vertical ribs on a vertical tube are the one case where relief alone
|
||||||
const domeH = capH * 0.6
|
* does nothing: every rib and every groove between them faces the light
|
||||||
const capLevels: Level[] = [
|
* at the same angle, so a band with a millimetre and a half of real
|
||||||
{ y: 0, radius: R * 0.55 },
|
* relief still rendered as pale stripes. What separates them on the
|
||||||
// The lip rolls out well past the neck so the cap reads as a
|
* reference is not the highlight, it is the dark in the bottom of each
|
||||||
// separate piece that comes off, not a continuation of the profile.
|
* groove. This is the kit's first use of it and it is the reason the
|
||||||
{ y: 0.004, radius: R * 0.6 },
|
* band reads at all.
|
||||||
// The head swells a touch before rounding over: a straight-sided cap
|
*/
|
||||||
// read as a bottle top, and this is the swell that makes it a turban.
|
bakeOcclusion(pieces, { strength: 0.5 })
|
||||||
{ y: domeH * 0.3, radius: R * 0.61 },
|
|
||||||
{ y: domeH * 0.6, radius: R * 0.55 },
|
/* ------------------------------------------------------------ collar */
|
||||||
{ y: domeH * 0.85, radius: R * 0.42 },
|
// Proud of the tube by a hair, which is what makes it read as a ring
|
||||||
{ y: domeH, radius: R * 0.32 },
|
// fitted over the bottom rather than as a painted stripe.
|
||||||
|
const collarLevels: Level[] = [
|
||||||
|
{ y: 0, radius: R * 0.985 },
|
||||||
|
{ y: 0.0012, radius: R * 1.012 },
|
||||||
|
{ y: collarH - 0.0012, radius: R * 1.012 },
|
||||||
|
{ y: collarH, radius: R * 0.998 },
|
||||||
]
|
]
|
||||||
const dome = latheGeometry(capLevels, segments, [0, 0, 0], tint('wood', jitter(random, 0.02)), {
|
pieces.push(latheGeometry(
|
||||||
|
collarLevels, segments, [0, 0, 0],
|
||||||
|
tint('stainless', jitter(random, 0.02), 0.5),
|
||||||
|
{ colourTop: tint('stainless', 0.03, 0.5), capBottom: true },
|
||||||
|
))
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------- cap */
|
||||||
|
// Everything below is LOCAL to the seat: the part's origin sits there so
|
||||||
|
// rotation.y grinds.
|
||||||
|
const discLevels: Level[] = [
|
||||||
|
{ y: 0, radius: R * 0.985 },
|
||||||
|
{ y: 0.0008, radius: R },
|
||||||
|
{ y: capDisc - 0.0012, radius: R },
|
||||||
|
{ y: capDisc, radius: R * 0.988 },
|
||||||
|
]
|
||||||
|
const disc = latheGeometry(discLevels, segments, [0, 0, 0], tint('wood', jitter(random, 0.02)), {
|
||||||
colourTop: tint('wood', 0.05),
|
colourTop: tint('wood', 0.05),
|
||||||
capBottom: true,
|
capBottom: true,
|
||||||
capTop: true,
|
capTop: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
// The crown: a hex acorn, 6 segments on purpose. Its base is sunk into
|
// The knurled knob. Its sides are a radial array too, at a pitch fine
|
||||||
// the dome, its facets are what make the twist visible.
|
// enough to read as knurling rather than as a nut, and it is the only
|
||||||
const nutR = R * 0.22
|
// thing on the mill whose rotation is visible.
|
||||||
const nutLevels: Level[] = [
|
const knobR = R * 0.28
|
||||||
{ y: domeH - 0.003, radius: nutR * 0.72 },
|
const knurl = Math.max(10, Math.round(knobR / R * 40))
|
||||||
{ y: domeH + 0.0008, radius: nutR },
|
const knobLevels: Level[] = [
|
||||||
{ y: capH * 0.87, radius: nutR },
|
{ y: capDisc - 0.002, radius: knobR * 0.55 },
|
||||||
{ y: capH * 0.95, radius: nutR * 0.7 },
|
{ y: capDisc + 0.0015, radius: knobR },
|
||||||
{ y: capH, radius: nutR * 0.36 },
|
{ y: capDisc + knobH * 0.82, radius: knobR },
|
||||||
|
{ y: capDisc + knobH * 0.93, radius: knobR * 0.86 },
|
||||||
|
{ y: capDisc + knobH, radius: knobR * 0.62 },
|
||||||
]
|
]
|
||||||
const nut = latheGeometry(nutLevels, 6, [0, 0, 0], tint('stainless', jitter(random, 0.02), 0.5), {
|
const knob = latheGeometry(
|
||||||
colourTop: tint('stainless', 0.04, 0.5),
|
knobLevels, knurl, [0, 0, 0],
|
||||||
capBottom: true,
|
tint('stainless', jitter(random, 0.02), 0.5),
|
||||||
capTop: true,
|
{ colourTop: tint('stainless', 0.05, 0.5), capBottom: true, capTop: true },
|
||||||
})
|
)
|
||||||
|
|
||||||
// 40 degrees: the revolve and the dome smooth, the foot, the lip, the
|
// 40 degrees: the revolve smooths, and the collar step, the recess
|
||||||
// flute chamfers and the hex facets all turn harder than that and stay
|
// shoulders, the rib chamfers and the knurl facets all turn harder than
|
||||||
// edges.
|
// that and stay edges.
|
||||||
return {
|
return {
|
||||||
body: { slot: 'wood' as const, geometry: smoothNormals(mergeColoured(pieces), 40) },
|
body: {
|
||||||
|
slot: 'wood' as const,
|
||||||
|
geometry: smoothNormals(mergeColoured(pieces.slice(0, pieces.length - 1)), 40),
|
||||||
|
extras: [{
|
||||||
|
slot: 'stainless' as const,
|
||||||
|
geometry: smoothNormals(mergeColoured([pieces[pieces.length - 1]!]), 30),
|
||||||
|
}],
|
||||||
|
},
|
||||||
cap: {
|
cap: {
|
||||||
slot: 'wood' as const,
|
slot: 'wood' as const,
|
||||||
geometry: smoothNormals(mergeColoured([dome]), 40),
|
geometry: smoothNormals(mergeColoured([disc]), 40),
|
||||||
extras: [{ slot: 'stainless' as const, geometry: smoothNormals(mergeColoured([nut]), 30) }],
|
extras: [{ slot: 'stainless' as const, geometry: smoothNormals(mergeColoured([knob]), 30) }],
|
||||||
origin: [0, seat, 0] as const,
|
origin: [0, seat, 0] as const,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
159
src/models/contemporary-props/street-bollard/model.ts
Normal file
159
src/models/contemporary-props/street-bollard/model.ts
Normal file
|
|
@ -0,0 +1,159 @@
|
||||||
|
/**
|
||||||
|
* @contemporary-props/street-bollard
|
||||||
|
*
|
||||||
|
* Cast iron street bollard, and the cheapest possible proof that a profile is
|
||||||
|
* data. It shares no code with the traffic cone and every idea: one radius as
|
||||||
|
* a function of height, turned once, with the bands that read as separate
|
||||||
|
* castings being nothing but y-ranges of the same curve.
|
||||||
|
*
|
||||||
|
* Measured off the reference rather than chosen. It is 8.2 shaft diameters
|
||||||
|
* tall, which is the number that decides whether this is a bollard or a
|
||||||
|
* gatepost, and the pieces stack in fractions of that height:
|
||||||
|
*
|
||||||
|
* 0.000 base flange, 1.63 shaft diameters across
|
||||||
|
* 0.059 skirt, barely proud of the shaft
|
||||||
|
* 0.144 lower bead
|
||||||
|
* 0.185 the shaft, and it is two thirds of the whole thing
|
||||||
|
* 0.869 upper bead, the same casting as the lower one
|
||||||
|
* 0.905 dome
|
||||||
|
*
|
||||||
|
* The two beads are what make it read as cast and not as pipe. They are the
|
||||||
|
* same ring at two heights and the model draws them from one function for that
|
||||||
|
* reason: a bollard whose collars differ is a bollard somebody drew twice.
|
||||||
|
*
|
||||||
|
* The dome is slightly WIDER than the shaft, which looks wrong written down
|
||||||
|
* and is right in front of you. A cap flush with the shaft reads as a tube cut
|
||||||
|
* off and painted; the overhang is what says a separate piece was cast onto
|
||||||
|
* the top of it.
|
||||||
|
*
|
||||||
|
* One part, one slot. There is nothing here that comes off, nothing that
|
||||||
|
* lights, and nothing that moves, and the catalogue asks for no action: it is
|
||||||
|
* row seven precisely because it is the shape and nothing else.
|
||||||
|
*/
|
||||||
|
import { type BufferGeometry } from 'three'
|
||||||
|
|
||||||
|
import {
|
||||||
|
createKitModel,
|
||||||
|
createTinter,
|
||||||
|
jitter,
|
||||||
|
latheGeometry,
|
||||||
|
mergeColoured,
|
||||||
|
smoothNormals,
|
||||||
|
type Level,
|
||||||
|
} from '../core/index.ts'
|
||||||
|
|
||||||
|
export interface StreetBollardConfig {
|
||||||
|
/** Overall height, dome included (metres). */
|
||||||
|
readonly height: number
|
||||||
|
/** Radius of the shaft (metres). */
|
||||||
|
readonly radius: number
|
||||||
|
/** Base flange radius, as a multiple of the shaft's. */
|
||||||
|
readonly flange: number
|
||||||
|
/** How far the beads stand proud of the shaft, as a fraction of its radius. */
|
||||||
|
readonly bead: number
|
||||||
|
/** Sides around the revolve. */
|
||||||
|
readonly segments: number
|
||||||
|
readonly seed: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const streetBollardDefaults: StreetBollardConfig = {
|
||||||
|
height: 0.95,
|
||||||
|
// 8.2 diameters tall. Thicker and it is a gatepost; thinner and it is a
|
||||||
|
// parking post, which is a different object with a different job.
|
||||||
|
radius: 0.058,
|
||||||
|
flange: 1.63,
|
||||||
|
bead: 0.13,
|
||||||
|
// 36, not 28. This kit has no lowpoly budget and a bollard is a plain
|
||||||
|
// cylinder for two thirds of its height, which is exactly the shape where
|
||||||
|
// facets have nothing to hide behind.
|
||||||
|
segments: 36,
|
||||||
|
seed: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StreetBollardParts = 'body'
|
||||||
|
|
||||||
|
export function createModel(overrides: Partial<StreetBollardConfig> = {}) {
|
||||||
|
return createKitModel<StreetBollardConfig, 'steelPainted', StreetBollardParts>({
|
||||||
|
id: 'street-bollard',
|
||||||
|
defaults: streetBollardDefaults,
|
||||||
|
slots: ['steelPainted'],
|
||||||
|
|
||||||
|
build: ({ config, random }) => {
|
||||||
|
const tint = createTinter(random)
|
||||||
|
const H = Math.min(1.4, Math.max(0.5, config.height))
|
||||||
|
// Clamped against the height for the same reason the mill's is: the
|
||||||
|
// proportion is the object, and either end of the slider on its own
|
||||||
|
// produces something with another name.
|
||||||
|
const R = Math.min(H * 0.11, Math.max(H * 0.045, Math.min(0.12, Math.max(0.03, config.radius))))
|
||||||
|
const segments = Math.max(10, Math.round(config.segments))
|
||||||
|
const flangeR = R * Math.min(2.1, Math.max(1.25, config.flange))
|
||||||
|
const beadR = R * (1 + Math.min(0.3, Math.max(0.04, config.bead)))
|
||||||
|
const skirtR = R * 1.05
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One bead, at whatever height it is asked for.
|
||||||
|
*
|
||||||
|
* Written once and called twice because the two collars on a real
|
||||||
|
* bollard come out of the same mould. The profile is sampled at 30 and
|
||||||
|
* 60 degrees so the smoothing reads the ring as round rather than as a
|
||||||
|
* pair of cones meeting at a point.
|
||||||
|
*/
|
||||||
|
const ring = (centre: number, halfH: number): Level[] => [
|
||||||
|
{ y: centre - halfH, radius: R },
|
||||||
|
{ y: centre - halfH * 0.5, radius: R + (beadR - R) * 0.87 },
|
||||||
|
{ y: centre, radius: beadR },
|
||||||
|
{ y: centre + halfH * 0.5, radius: R + (beadR - R) * 0.87 },
|
||||||
|
{ y: centre + halfH, radius: R },
|
||||||
|
]
|
||||||
|
|
||||||
|
const flangeTop = H * 0.059
|
||||||
|
const skirtTop = H * 0.144
|
||||||
|
const loBead = H * 0.1645
|
||||||
|
const hiBead = H * 0.887
|
||||||
|
const beadHalf = H * 0.0205
|
||||||
|
const domeBase = H * 0.905
|
||||||
|
const domeH = H - domeBase
|
||||||
|
|
||||||
|
const levels: Level[] = [
|
||||||
|
// The flange's own edge is turned over, not left square: a plate that
|
||||||
|
// meets the pavement at a sharp corner reads as card.
|
||||||
|
{ y: 0, radius: flangeR - H * 0.004 },
|
||||||
|
{ y: H * 0.004, radius: flangeR },
|
||||||
|
{ y: flangeTop - H * 0.008, radius: flangeR },
|
||||||
|
{ y: flangeTop, radius: skirtR },
|
||||||
|
{ y: skirtTop, radius: skirtR },
|
||||||
|
{ y: skirtTop + H * 0.004, radius: R },
|
||||||
|
...ring(loBead, beadHalf),
|
||||||
|
...ring(hiBead, beadHalf),
|
||||||
|
// The dome. Its widest point is a touch proud of the shaft and sits a
|
||||||
|
// little above the parting line, so the overhang is a lip rather than
|
||||||
|
// a step.
|
||||||
|
{ y: domeBase, radius: R },
|
||||||
|
{ y: domeBase + domeH * 0.1, radius: beadR * 0.97 },
|
||||||
|
{ y: domeBase + domeH * 0.45, radius: R * 0.93 },
|
||||||
|
{ y: domeBase + domeH * 0.75, radius: R * 0.7 },
|
||||||
|
{ y: domeBase + domeH * 0.92, radius: R * 0.42 },
|
||||||
|
{ y: H, radius: R * 0.16 },
|
||||||
|
]
|
||||||
|
|
||||||
|
const iron = tint('steelPainted', jitter(random, 0.02))
|
||||||
|
const pieces: BufferGeometry[] = [
|
||||||
|
latheGeometry(levels, segments, [0, 0, 0], iron, {
|
||||||
|
// Weathering runs the other way to a vessel's: a bollard is washed
|
||||||
|
// clean at the top and dirty at the foot, so the ramp lightens
|
||||||
|
// upward more than a glaze would.
|
||||||
|
colourTop: tint('steelPainted', 0.06),
|
||||||
|
capBottom: true,
|
||||||
|
capTop: true,
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
|
||||||
|
// 35 degrees: the shaft and the dome smooth into one another, and the
|
||||||
|
// flange edge, the skirt step and the bead shoulders all turn harder
|
||||||
|
// than that and stay as edges.
|
||||||
|
return {
|
||||||
|
body: { slot: 'steelPainted' as const, geometry: smoothNormals(mergeColoured(pieces), 35) },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, overrides)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue