Add the wheeled bin, and with it the shared wheel: a tyre and a hub in their own materials, plus the contact radius a polygon needs to actually reach the ground.
This commit is contained in:
parent
87f99a9fee
commit
5975d7e641
11 changed files with 883 additions and 29 deletions
14
PROGRESS.md
14
PROGRESS.md
|
|
@ -209,6 +209,16 @@ 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.
|
||||||
|
|
||||||
|
**A polygonal wheel does not touch the ground at its radius.** A lathed wheel's
|
||||||
|
vertices sit at the radius and its faces are chords, so unless a vertex happens
|
||||||
|
to land at the bottom the lowest point of the tyre is `radius * cos(pi / sides)`
|
||||||
|
-- a millimetre in on a 200 mm wheel at 22 sides. Put the axle at the radius and
|
||||||
|
the whole model hovers by exactly that. `wheelGeometry` now hands back a
|
||||||
|
`contact` radius alongside its two geometries, because every consumer that sits
|
||||||
|
a wheel on the ground needs it and none of them would think to derive it. The
|
||||||
|
new ground check found it the same afternoon it was written, which is the second
|
||||||
|
thing that check has caught.
|
||||||
|
|
||||||
**An array cut to a rectangle inside a frame that is not one.** The fence
|
**An array cut to a rectangle inside a frame that is not one.** The fence
|
||||||
panel's mesh was cut to a single length, and the frame's top corners are
|
panel's mesh was cut to a single length, and the frame's top corners are
|
||||||
radiused: four or five wires at each corner stood proud of the bend, welded to
|
radiused: four or five wires at each corner stood proud of the bend, welded to
|
||||||
|
|
@ -503,13 +513,13 @@ asking GitHub Support to purge actually closes it.
|
||||||
|
|
||||||
## Open
|
## Open
|
||||||
|
|
||||||
- **`contemporary-props`**: 19 of the core 100 modelled, and the build order is
|
- **`contemporary-props`**: 20 of the core 100 modelled, and the build order is
|
||||||
now DOMAIN FIRST. The catalogue's own section 5 argued against spreading the
|
now DOMAIN FIRST. The catalogue's own section 5 argued against spreading the
|
||||||
first hundred across nine domains and named the failure mode: nine domains at
|
first hundred across nine domains and named the failure mode: nine domains at
|
||||||
a third each, with the helper set shaped by whichever got built first. Fifteen
|
a third each, with the helper set shaped by whichever got built first. Fifteen
|
||||||
models in, that had happened -- five street, four kitchen, two tools, one each
|
models in, that had happened -- five street, four kitchen, two tools, one each
|
||||||
of four more -- so the remaining street rows are being finished before
|
of four more -- so the remaining street rows are being finished before
|
||||||
anything else starts. Eight to go after the fence panel. The reasoning is written into `CATALOGUE.md` under
|
anything else starts. Seven to go after the wheeled bin. The reasoning is written into `CATALOGUE.md` under
|
||||||
"Decided: street first"; the short version is that seventeen street objects is
|
"Decided: street first"; the short version is that seventeen street objects is
|
||||||
a scene somebody can assemble, and what carried the medieval kit was one
|
a scene somebody can assemble, and what carried the medieval kit was one
|
||||||
flythrough rather than a model count.
|
flythrough rather than a model count.
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,105 @@ export function latheGeometry(
|
||||||
return finish(sink)
|
return finish(sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A wheel, in the two materials every wheel is made of. */
|
||||||
|
export interface Wheel {
|
||||||
|
/** The tyre, which wants a rubber slot. */
|
||||||
|
readonly tyre: BufferGeometry
|
||||||
|
/** The hub and its spokes, which want a plastic or steel one. */
|
||||||
|
readonly hub: BufferGeometry
|
||||||
|
/**
|
||||||
|
* How far the axle must be off the ground for the wheel to TOUCH it.
|
||||||
|
*
|
||||||
|
* Not the radius. A lathed wheel is a polygon, its vertices sit at the
|
||||||
|
* radius and its faces are chords, so unless a vertex happens to land at the
|
||||||
|
* bottom the lowest point of the tyre is `radius * cos(pi / segments)` --
|
||||||
|
* about a millimetre in on a 200 mm wheel at 22 sides. Put the axle at the
|
||||||
|
* radius and the whole model hovers by that millimetre, which is exactly the
|
||||||
|
* fault the ground check exists to catch and exactly the kind nobody finds
|
||||||
|
* by looking.
|
||||||
|
*/
|
||||||
|
readonly contact: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A road wheel: a tyre on a spoked hub, axle along X, centred on the origin.
|
||||||
|
*
|
||||||
|
* The catalogue calls the wheeled bin "the first appearance of the wheel part",
|
||||||
|
* and the part is written here rather than in that model because four more rows
|
||||||
|
* in three other domains want the same thing: the sack truck and the wheelbarrow
|
||||||
|
* (37 and 38, tools), the shopping trolley (42, retail) and the task chair
|
||||||
|
* (93, office). The castor at row 39 is this plus a swivel fork, not a
|
||||||
|
* different wheel.
|
||||||
|
*
|
||||||
|
* Two geometries out rather than one, because a wheel is two materials and the
|
||||||
|
* kit assigns a slot per part. Returning them merged would mean every consumer
|
||||||
|
* who wanted a red trolley got red tyres.
|
||||||
|
*
|
||||||
|
* The tyre is a lathe rather than a torus: a real one has a flat contact patch
|
||||||
|
* and a shoulder, and a torus reads as a doughnut at every size.
|
||||||
|
*/
|
||||||
|
export function wheelGeometry(options: {
|
||||||
|
readonly radius: number
|
||||||
|
readonly width: number
|
||||||
|
readonly spokes: number
|
||||||
|
readonly tyre: Color
|
||||||
|
readonly hub: Color
|
||||||
|
readonly segments?: number
|
||||||
|
}): Wheel {
|
||||||
|
const { radius: R, width: W, tyre: tyreColour, hub: hubColour } = options
|
||||||
|
const segments = Math.max(12, Math.round(options.segments ?? 22))
|
||||||
|
const spokes = Math.max(3, Math.round(options.spokes))
|
||||||
|
const half = W / 2
|
||||||
|
|
||||||
|
// Built about Y and tipped, for the reason every round thing here is: the
|
||||||
|
// lathe turns about Y and one rotation at the end is cheaper than carrying
|
||||||
|
// an axis through every level.
|
||||||
|
const tyre = latheGeometry([
|
||||||
|
{ y: -half, radius: R * 0.72 },
|
||||||
|
{ y: -half, radius: R * 0.93 },
|
||||||
|
{ y: -half * 0.72, radius: R },
|
||||||
|
{ y: half * 0.72, radius: R },
|
||||||
|
{ y: half, radius: R * 0.93 },
|
||||||
|
{ y: half, radius: R * 0.72 },
|
||||||
|
], segments, [0, 0, 0], tyreColour, { capBottom: false, capTop: false })
|
||||||
|
tyre.rotateZ(Math.PI / 2)
|
||||||
|
|
||||||
|
const hubPieces: BufferGeometry[] = [
|
||||||
|
latheGeometry([
|
||||||
|
{ y: -half * 0.62, radius: R * 0.2 },
|
||||||
|
{ y: -half * 0.62, radius: R * 0.74 },
|
||||||
|
{ y: -half * 0.3, radius: R * 0.76 },
|
||||||
|
{ y: half * 0.3, radius: R * 0.76 },
|
||||||
|
{ y: half * 0.62, radius: R * 0.74 },
|
||||||
|
{ y: half * 0.62, radius: R * 0.2 },
|
||||||
|
], segments, [0, 0, 0], hubColour, { capBottom: false, capTop: false }),
|
||||||
|
// The boss the axle passes through, closed at both ends so the wheel is
|
||||||
|
// not a tube you can see down.
|
||||||
|
latheGeometry([
|
||||||
|
{ y: -half * 0.8, radius: R * 0.2 },
|
||||||
|
{ y: half * 0.8, radius: R * 0.2 },
|
||||||
|
], 12, [0, 0, 0], hubColour, { capBottom: true, capTop: true }),
|
||||||
|
]
|
||||||
|
|
||||||
|
// The spokes, which are the only thing that says a wheel is turning when it
|
||||||
|
// turns: a plain disc at speed looks exactly like a plain disc at rest.
|
||||||
|
for (let i = 0; i < spokes; i += 1) {
|
||||||
|
const a = (i / spokes) * Math.PI * 2
|
||||||
|
const spoke = chamferedBoxGeometry(
|
||||||
|
[R * 0.17, R * 0.5], [R * 0.13, R * 0.5],
|
||||||
|
W * 0.34, R * 0.03, [0, 0, 0], hubColour,
|
||||||
|
)
|
||||||
|
spoke.rotateX(Math.PI / 2)
|
||||||
|
spoke.translate(0, 0, R * 0.47)
|
||||||
|
spoke.rotateY(a)
|
||||||
|
hubPieces.push(spoke)
|
||||||
|
}
|
||||||
|
const hub = mergeColoured(hubPieces)
|
||||||
|
hub.rotateZ(Math.PI / 2)
|
||||||
|
|
||||||
|
return { tyre, hub, contact: R * Math.cos(Math.PI / segments) }
|
||||||
|
}
|
||||||
|
|
||||||
/** How a surface is punched, for `perforate`. */
|
/** How a surface is punched, for `perforate`. */
|
||||||
export interface PerforationPattern {
|
export interface PerforationPattern {
|
||||||
/** Rows of holes up the surface. */
|
/** Rows of holes up the surface. */
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,11 @@ export {
|
||||||
staveGeometry,
|
staveGeometry,
|
||||||
smoothNormals,
|
smoothNormals,
|
||||||
tubeGeometry,
|
tubeGeometry,
|
||||||
|
wheelGeometry,
|
||||||
taperedBoxGeometry,
|
taperedBoxGeometry,
|
||||||
} from './geometry.ts'
|
} from './geometry.ts'
|
||||||
export type { Level, MottleOptions, PerforationPattern, Plan, PlanLevel, RoughenOptions, Section, SheetLevel, Vec3 } from './geometry.ts'
|
export type { Level, MottleOptions, PerforationPattern, Plan, PlanLevel,
|
||||||
|
Wheel, 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'
|
||||||
|
|
|
||||||
15
contemporary-props/models/wheeled-waste-bin/meta.json
Normal file
15
contemporary-props/models/wheeled-waste-bin/meta.json
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"title": "Wheeled Waste Bin",
|
||||||
|
"description": "A 240 litre moulded bin: a tapered ribbed body, a domed lid hinged on the bar across the back, and two wheels on an axle. The kit's first use of the shared wheel part, which comes back as a tyre and a hub in their own materials.",
|
||||||
|
"category": "Street",
|
||||||
|
"tags": ["contemporary", "street", "waste", "procedural"],
|
||||||
|
"controls": {
|
||||||
|
"height": { "type": "number", "label": "Height", "min": 0.7, "max": 1.4, "step": 0.01, "unit": "m" },
|
||||||
|
"width": { "type": "number", "label": "Width", "min": 0.35, "max": 0.9, "step": 0.01, "unit": "m" },
|
||||||
|
"depth": { "type": "number", "label": "Depth", "min": 0.4, "max": 1.1, "step": 0.01, "unit": "m" },
|
||||||
|
"open": { "type": "number", "label": "Lid open", "min": 0, "max": 1, "step": 0.05 },
|
||||||
|
"seed": { "type": "number", "label": "Variation seed", "min": 1, "max": 64, "step": 1 }
|
||||||
|
},
|
||||||
|
"materialSlots": ["plastic", "rubber"],
|
||||||
|
"parts": ["body", "lid", "wheels", "tyres"]
|
||||||
|
}
|
||||||
284
contemporary-props/models/wheeled-waste-bin/model.ts
Normal file
284
contemporary-props/models/wheeled-waste-bin/model.ts
Normal file
|
|
@ -0,0 +1,284 @@
|
||||||
|
/**
|
||||||
|
* @contemporary-props/wheeled-waste-bin
|
||||||
|
*
|
||||||
|
* A tapered ribbed moulding with a hinged lid on an axle, and the catalogue's
|
||||||
|
* thirty-second row: the first appearance of the wheel part. The wheel itself
|
||||||
|
* lives in core rather than here, because four later rows in three other
|
||||||
|
* domains want the same one -- the sack truck and the wheelbarrow in tools, the
|
||||||
|
* shopping trolley in retail, the task chair in the office -- and a wheel
|
||||||
|
* written inside a bin is a wheel each of them rewrites.
|
||||||
|
*
|
||||||
|
* Measured against the 240 litre bin, which is the one on every kerb: 1080 mm
|
||||||
|
* to the top of the lid, 580 across the front, 740 front to back, on 200 mm
|
||||||
|
* wheels. The body tapers about a tenth from its rim to its base, which is not
|
||||||
|
* styling -- it is draft, so the moulding leaves the tool, and it is the reason
|
||||||
|
* these things stack.
|
||||||
|
*
|
||||||
|
* The lid hinges on the axle bar across the back, so its origin is that bar and
|
||||||
|
* nothing else. It also OVERHANGS at the front, which is what makes the lip you
|
||||||
|
* lift it by, and the gussets under the rim are the moulded ribs that stop a
|
||||||
|
* thin-walled box that size from folding when it is tipped.
|
||||||
|
*/
|
||||||
|
import { type BufferGeometry } from 'three'
|
||||||
|
|
||||||
|
import {
|
||||||
|
bakeOcclusion,
|
||||||
|
chamferedBoxGeometry,
|
||||||
|
createKitModel,
|
||||||
|
createTinter,
|
||||||
|
jitter,
|
||||||
|
latheGeometry,
|
||||||
|
mergeColoured,
|
||||||
|
smoothNormals,
|
||||||
|
wheelGeometry,
|
||||||
|
type RuntimeContext,
|
||||||
|
} from '../core/index.ts'
|
||||||
|
|
||||||
|
export interface WasteBinConfig {
|
||||||
|
/** Height to the top of the closed lid (metres). */
|
||||||
|
readonly height: number
|
||||||
|
/** Width across the front (metres). */
|
||||||
|
readonly width: number
|
||||||
|
/** Depth, front to back (metres). */
|
||||||
|
readonly depth: number
|
||||||
|
/** How far the lid is open, 0 shut to 1 back on its hinge. */
|
||||||
|
readonly open: number
|
||||||
|
readonly seed: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const wasteBinDefaults: WasteBinConfig = {
|
||||||
|
height: 1.08,
|
||||||
|
width: 0.58,
|
||||||
|
depth: 0.74,
|
||||||
|
open: 0,
|
||||||
|
seed: 61,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type WasteBinParts = 'body' | 'lid' | 'wheels' | 'tyres'
|
||||||
|
|
||||||
|
export interface WasteBinActions {
|
||||||
|
/** Swings the lid back on its hinge. 1 is fully open. */
|
||||||
|
open(amount?: number): void
|
||||||
|
/** Rolls the wheels. 1 is a full turn. */
|
||||||
|
roll(turns?: number): void
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyOpen(
|
||||||
|
runtime: RuntimeContext<WasteBinConfig, WasteBinParts>,
|
||||||
|
amount: number,
|
||||||
|
): void {
|
||||||
|
// Just past square, which is where a bin lid actually falls to when it is
|
||||||
|
// thrown back: it goes over centre and rests against the body.
|
||||||
|
runtime.parts.lid.anchor.rotation.x = Math.min(1, Math.max(0, amount)) * 1.9
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createModel(overrides: Partial<WasteBinConfig> = {}) {
|
||||||
|
let heldOpen = 0
|
||||||
|
let seenOpen = Number.NaN
|
||||||
|
|
||||||
|
return createKitModel<
|
||||||
|
WasteBinConfig, 'plastic' | 'rubber', WasteBinParts, WasteBinActions
|
||||||
|
>({
|
||||||
|
id: 'wheeled-waste-bin',
|
||||||
|
defaults: wasteBinDefaults,
|
||||||
|
slots: ['plastic', 'rubber'],
|
||||||
|
|
||||||
|
build: ({ config, random }) => {
|
||||||
|
const tint = createTinter(random)
|
||||||
|
const H = Math.min(1.4, Math.max(0.7, config.height))
|
||||||
|
const W = Math.min(0.9, Math.max(0.35, config.width))
|
||||||
|
const D = Math.min(1.1, Math.max(0.4, config.depth))
|
||||||
|
|
||||||
|
// Down from the palette's plastic, which is set for the pale mouldings
|
||||||
|
// most of the kit's plastic is. A municipal bin is a mid grey, and at the
|
||||||
|
// palette's own value the body came out near white and read as a fridge.
|
||||||
|
const shell = tint('plastic', -0.33 + jitter(random, 0.02))
|
||||||
|
const dark = tint('plastic', -0.46, 0.6)
|
||||||
|
|
||||||
|
const wheelR = H * 0.093
|
||||||
|
const lidH = H * 0.085
|
||||||
|
const bodyTop = H - lidH
|
||||||
|
const bodyBase = wheelR * 0.28
|
||||||
|
// A tenth of draft between rim and base, which is what lets the moulding
|
||||||
|
// leave the tool and what makes a rank of these nest.
|
||||||
|
const taper = 0.9
|
||||||
|
|
||||||
|
const bodyPieces: BufferGeometry[] = []
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------- body */
|
||||||
|
bodyPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * taper, D * taper], [W, D],
|
||||||
|
bodyTop - bodyBase, W * 0.075, [0, (bodyTop + bodyBase) / 2, 0], shell,
|
||||||
|
))
|
||||||
|
|
||||||
|
// The rim: a flange right round the top, which is what the lid sits on
|
||||||
|
// and what a lifter's forks catch under.
|
||||||
|
bodyPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * 1.028, D * 1.028], [W * 1.02, D * 1.02],
|
||||||
|
H * 0.03, W * 0.02, [0, bodyTop - H * 0.012, 0], shell,
|
||||||
|
))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The gussets under the rim.
|
||||||
|
*
|
||||||
|
* They are the dark triangles in every photograph of one of these and
|
||||||
|
* they are structural: a thin-walled box 1.1 m tall folds at the rim when
|
||||||
|
* it is tipped, so the moulding carries a rib every 150 mm or so. Left
|
||||||
|
* off, the body reads as a bin bag holder.
|
||||||
|
*/
|
||||||
|
const ribs = Math.max(4, Math.round(W / 0.15) * 2 + Math.round(D / 0.15) * 2)
|
||||||
|
for (let i = 0; i < ribs; i += 1) {
|
||||||
|
const t = (i + 0.5) / ribs
|
||||||
|
// Walk the rim's perimeter, so the ribs sit on all four faces without
|
||||||
|
// four separate loops and without bunching at the corners.
|
||||||
|
const a = t * Math.PI * 2
|
||||||
|
const ex = Math.cos(a)
|
||||||
|
const ez = Math.sin(a)
|
||||||
|
const scale = 1 / Math.max(Math.abs(ex) / (W / 2), Math.abs(ez) / (D / 2))
|
||||||
|
const x = ex * scale
|
||||||
|
const z = ez * scale
|
||||||
|
// Short and broad at the top, tapering to nothing: a gusset, not a
|
||||||
|
// tooth. At three quarters of this length they hung below the rim in a
|
||||||
|
// row and the bin came out fringed.
|
||||||
|
// Measured off the reference at 7% of the body's height, which is
|
||||||
|
// between the two rounds that argued about it: at 7.5% they hung below
|
||||||
|
// the rim like a fringe, at 4.2% the critic called them shallow, and
|
||||||
|
// neither reading was taken from the photograph.
|
||||||
|
const rib = chamferedBoxGeometry(
|
||||||
|
[W * 0.06, W * 0.08], [W * 0.03, W * 0.01],
|
||||||
|
H * 0.06, W * 0.008, [0, 0, 0], dark,
|
||||||
|
)
|
||||||
|
rib.translate(x * 0.985, bodyTop - H * 0.052, z * 0.985)
|
||||||
|
bodyPieces.push(rib)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- lid */
|
||||||
|
/**
|
||||||
|
* A domed lid that OVERHANGS at the front.
|
||||||
|
*
|
||||||
|
* Flush with the body it is a flat cap and there is nothing to lift it
|
||||||
|
* by; the reference's stands proud all round and further at the front,
|
||||||
|
* where the lip is. The dome is two steps rather than a curve because a
|
||||||
|
* blow-moulded lid is exactly that: a flat crown with a shoulder.
|
||||||
|
*/
|
||||||
|
const hingeZ = D * 0.5
|
||||||
|
const lidPieces: BufferGeometry[] = []
|
||||||
|
lidPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * 1.05, D * 1.03], [W * 1.02, D * 1.0],
|
||||||
|
lidH * 0.55, W * 0.03, [0, bodyTop + lidH * 0.275, -D * 0.01], shell,
|
||||||
|
))
|
||||||
|
lidPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * 0.94, D * 0.9], [W * 0.8, D * 0.76],
|
||||||
|
lidH * 0.5, W * 0.035, [0, bodyTop + lidH * 0.72, -D * 0.02], shell,
|
||||||
|
))
|
||||||
|
// The two shoulders running front to back, which every blow-moulded lid
|
||||||
|
// has and which are the only thing breaking a half square metre of flat
|
||||||
|
// grey. They are stiffeners, so they run the long way.
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
lidPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * 0.2, D * 0.72], [W * 0.15, D * 0.66],
|
||||||
|
lidH * 0.22, W * 0.03,
|
||||||
|
[side * W * 0.24, bodyTop + lidH * 0.96, -D * 0.03], shell,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
// The lip at the front, which is the handle.
|
||||||
|
lidPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * 0.5, D * 0.05], [W * 0.44, D * 0.035],
|
||||||
|
lidH * 0.34, W * 0.012,
|
||||||
|
[0, bodyTop + lidH * 0.2, -D * 0.5 - D * 0.012], dark,
|
||||||
|
))
|
||||||
|
|
||||||
|
/* -------------------------------------------------- axle and the wheels */
|
||||||
|
/**
|
||||||
|
* The wheels come from core, and they come as two geometries.
|
||||||
|
*
|
||||||
|
* A wheel is a tyre and a hub in two different materials, and this kit
|
||||||
|
* gives one slot per part -- so the helper hands back both and the model
|
||||||
|
* puts each in its own part. Merged into one, a consumer who recoloured
|
||||||
|
* the bin's plastic would get plastic tyres.
|
||||||
|
*/
|
||||||
|
const wheelX = W * 0.5 - wheelR * 0.42
|
||||||
|
const wheelZ = D * 0.5 - wheelR * 0.85
|
||||||
|
const tyrePieces: BufferGeometry[] = []
|
||||||
|
const hubPieces: BufferGeometry[] = []
|
||||||
|
// Set from the wheel's own contact radius rather than from its nominal
|
||||||
|
// one: see `Wheel.contact`. At the radius the bin hovered a millimetre.
|
||||||
|
let wheelY = wheelR
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
const { tyre, hub, contact } = wheelGeometry({
|
||||||
|
radius: wheelR,
|
||||||
|
width: wheelR * 0.42,
|
||||||
|
spokes: 5,
|
||||||
|
tyre: tint('rubber', jitter(random, 0.02)),
|
||||||
|
// As dark as the tyre nearly. A pale hub on a black tyre reads as a
|
||||||
|
// flat disc stuck to the wheel rather than as a recess in it, which
|
||||||
|
// is what the spokes are there to show.
|
||||||
|
hub: tint('plastic', -0.52, 0.4),
|
||||||
|
})
|
||||||
|
wheelY = contact
|
||||||
|
tyre.translate(side * wheelX, wheelY, wheelZ)
|
||||||
|
hub.translate(side * wheelX, wheelY, wheelZ)
|
||||||
|
tyrePieces.push(tyre)
|
||||||
|
hubPieces.push(hub)
|
||||||
|
}
|
||||||
|
// The axle between them, and the two stub brackets the body carries it on.
|
||||||
|
bodyPieces.push(latheGeometry([
|
||||||
|
{ y: -wheelX, radius: wheelR * 0.13 },
|
||||||
|
{ y: wheelX, radius: wheelR * 0.13 },
|
||||||
|
], 10, [0, 0, 0], dark, { capBottom: false, capTop: false })
|
||||||
|
.rotateZ(Math.PI / 2)
|
||||||
|
.translate(0, wheelY, wheelZ))
|
||||||
|
|
||||||
|
// The hinge bar across the back, which the lid turns on and the handle
|
||||||
|
// a bin is wheeled by.
|
||||||
|
bodyPieces.push(latheGeometry([
|
||||||
|
{ y: -W * 0.46, radius: H * 0.014 },
|
||||||
|
{ y: W * 0.46, radius: H * 0.014 },
|
||||||
|
], 12, [0, 0, 0], dark, { capBottom: true, capTop: true })
|
||||||
|
.rotateZ(Math.PI / 2)
|
||||||
|
// Proud of the lid at the back rather than under it: the hinge bar is
|
||||||
|
// also the handle a bin is wheeled by, and a hinge nobody can see is a
|
||||||
|
// hinge the model does not demonstrate.
|
||||||
|
.translate(0, bodyTop + H * 0.042, hingeZ + H * 0.012))
|
||||||
|
|
||||||
|
bakeOcclusion(bodyPieces, { strength: 0.4 })
|
||||||
|
|
||||||
|
const hinge = [0, bodyTop + H * 0.042, hingeZ + H * 0.012] as const
|
||||||
|
return {
|
||||||
|
body: { slot: 'plastic' as const, geometry: smoothNormals(mergeColoured(bodyPieces), 38) },
|
||||||
|
lid: {
|
||||||
|
slot: 'plastic' as const,
|
||||||
|
geometry: smoothNormals(
|
||||||
|
mergeColoured(lidPieces).translate(-hinge[0], -hinge[1], -hinge[2]), 38,
|
||||||
|
),
|
||||||
|
origin: hinge,
|
||||||
|
},
|
||||||
|
wheels: { slot: 'plastic' as const, geometry: smoothNormals(mergeColoured(hubPieces), 40) },
|
||||||
|
tyres: { slot: 'rubber' as const, geometry: smoothNormals(mergeColoured(tyrePieces), 40) },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: (runtime) => {
|
||||||
|
heldOpen = runtime.getConfig().open
|
||||||
|
seenOpen = heldOpen
|
||||||
|
applyOpen(runtime, heldOpen)
|
||||||
|
return {
|
||||||
|
open: (amount = 1) => { heldOpen = amount; applyOpen(runtime, amount) },
|
||||||
|
roll: (turns = 0.25) => {
|
||||||
|
// The wheels turn about their own axle, which is where both wheel
|
||||||
|
// parts already sit, so one rotation on each is the whole action.
|
||||||
|
for (const name of ['wheels', 'tyres'] as const) {
|
||||||
|
runtime.parts[name].anchor.rotation.x = -turns * Math.PI * 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
update: (_dt, runtime) => {
|
||||||
|
const wanted = runtime.getConfig().open
|
||||||
|
if (wanted !== seenOpen) { seenOpen = wanted; heldOpen = wanted }
|
||||||
|
applyOpen(runtime, heldOpen)
|
||||||
|
},
|
||||||
|
}, 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-04T21:29:23.129Z",
|
"installedAt": "2026-09-04T21:40:13.306Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\core\\geometry.ts",
|
"path": "src\\models\\contemporary-props\\core\\geometry.ts",
|
||||||
"sourceHash": "98188ee830bc2566cd791fdd077021f4539076e58a23bd0075876c5273a8ccb4"
|
"sourceHash": "776ecae69ab547a9e3f98a2a5d669def648fb60d50bfc0f64b23fb290f04178a"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\core\\index.ts",
|
"path": "src\\models\\contemporary-props\\core\\index.ts",
|
||||||
"sourceHash": "38d1152c66c2a72cf293e6b2233fd72b4413ae02ebd0b8409a4db7c4b4cbed82"
|
"sourceHash": "6c6da50bf3727328e634166b5bcdb9deb7a4928e903b8223079b47dd0a857383"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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-04T21:29:23.135Z",
|
"installedAt": "2026-09-04T21:40:13.311Z",
|
||||||
"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-04T21:29:23.137Z",
|
"installedAt": "2026-09-04T21:40:13.312Z",
|
||||||
"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-04T21:29:23.153Z",
|
"installedAt": "2026-09-04T21:40:13.325Z",
|
||||||
"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-04T21:29:23.156Z",
|
"installedAt": "2026-09-04T21:40:13.327Z",
|
||||||
"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-04T21:29:23.161Z",
|
"installedAt": "2026-09-04T21:40:13.332Z",
|
||||||
"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-04T21:29:23.162Z",
|
"installedAt": "2026-09-04T21:40:13.336Z",
|
||||||
"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-04T21:29:23.162Z",
|
"installedAt": "2026-09-04T21:40:13.336Z",
|
||||||
"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-04T21:29:23.158Z",
|
"installedAt": "2026-09-04T21:40:13.329Z",
|
||||||
"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-04T21:29:23.141Z",
|
"installedAt": "2026-09-04T21:40:13.315Z",
|
||||||
"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-04T21:29:23.139Z",
|
"installedAt": "2026-09-04T21:40:13.314Z",
|
||||||
"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-04T21:29:23.151Z",
|
"installedAt": "2026-09-04T21:40:13.323Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\pedestal-basin\\model.ts",
|
"path": "src\\models\\contemporary-props\\pedestal-basin\\model.ts",
|
||||||
|
|
@ -882,7 +882,7 @@
|
||||||
"address": "@contemporary-props/jersey-barrier",
|
"address": "@contemporary-props/jersey-barrier",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-04T21:29:23.142Z",
|
"installedAt": "2026-09-04T21:40:13.316Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\jersey-barrier\\model.ts",
|
"path": "src\\models\\contemporary-props\\jersey-barrier\\model.ts",
|
||||||
|
|
@ -897,7 +897,7 @@
|
||||||
"address": "@contemporary-props/picnic-table",
|
"address": "@contemporary-props/picnic-table",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-04T21:29:23.155Z",
|
"installedAt": "2026-09-04T21:40:13.326Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\picnic-table\\model.ts",
|
"path": "src\\models\\contemporary-props\\picnic-table\\model.ts",
|
||||||
|
|
@ -912,7 +912,7 @@
|
||||||
"address": "@contemporary-props/park-bench",
|
"address": "@contemporary-props/park-bench",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-04T21:29:23.148Z",
|
"installedAt": "2026-09-04T21:40:13.320Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\park-bench\\model.ts",
|
"path": "src\\models\\contemporary-props\\park-bench\\model.ts",
|
||||||
|
|
@ -927,7 +927,7 @@
|
||||||
"address": "@contemporary-props/pavement-sign-board",
|
"address": "@contemporary-props/pavement-sign-board",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-04T21:29:23.149Z",
|
"installedAt": "2026-09-04T21:40:13.322Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\pavement-sign-board\\model.ts",
|
"path": "src\\models\\contemporary-props\\pavement-sign-board\\model.ts",
|
||||||
|
|
@ -942,7 +942,7 @@
|
||||||
"address": "@contemporary-props/lectern",
|
"address": "@contemporary-props/lectern",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-04T21:29:23.144Z",
|
"installedAt": "2026-09-04T21:40:13.318Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\lectern\\model.ts",
|
"path": "src\\models\\contemporary-props\\lectern\\model.ts",
|
||||||
|
|
@ -957,7 +957,7 @@
|
||||||
"address": "@contemporary-props/bike-rack",
|
"address": "@contemporary-props/bike-rack",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-04T21:29:23.132Z",
|
"installedAt": "2026-09-04T21:40:13.308Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\bike-rack\\model.ts",
|
"path": "src\\models\\contemporary-props\\bike-rack\\model.ts",
|
||||||
|
|
@ -972,7 +972,7 @@
|
||||||
"address": "@contemporary-props/cable-drum",
|
"address": "@contemporary-props/cable-drum",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-04T21:29:23.134Z",
|
"installedAt": "2026-09-04T21:40:13.309Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\cable-drum\\model.ts",
|
"path": "src\\models\\contemporary-props\\cable-drum\\model.ts",
|
||||||
|
|
@ -987,7 +987,7 @@
|
||||||
"address": "@contemporary-props/litter-bin",
|
"address": "@contemporary-props/litter-bin",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-04T21:29:23.146Z",
|
"installedAt": "2026-09-04T21:40:13.319Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\litter-bin\\model.ts",
|
"path": "src\\models\\contemporary-props\\litter-bin\\model.ts",
|
||||||
|
|
@ -1002,11 +1002,26 @@
|
||||||
"address": "@contemporary-props/temporary-fence-panel",
|
"address": "@contemporary-props/temporary-fence-panel",
|
||||||
"source": "file:contemporary-props/dist/registry.json",
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-09-04T21:29:23.159Z",
|
"installedAt": "2026-09-04T21:40:13.330Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\contemporary-props\\temporary-fence-panel\\model.ts",
|
"path": "src\\models\\contemporary-props\\temporary-fence-panel\\model.ts",
|
||||||
"sourceHash": "1d9012b186e1afa065709bc62eb3d7f6dee573ab121c3b2bedddee4a8a62a959"
|
"sourceHash": "eccc0a98a328a098fa038acdebf1cb2dca1cf2caf9580dc595d5c05957dd155a"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": [
|
||||||
|
"three@>=0.185.0"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"@contemporary-props/wheeled-waste-bin": {
|
||||||
|
"address": "@contemporary-props/wheeled-waste-bin",
|
||||||
|
"source": "file:contemporary-props/dist/registry.json",
|
||||||
|
"version": "workspace",
|
||||||
|
"installedAt": "2026-09-04T21:40:13.334Z",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"path": "src\\models\\contemporary-props\\wheeled-waste-bin\\model.ts",
|
||||||
|
"sourceHash": "38a3b9dcfc1fcfdcd33954ea002d54e5a503d193dc751331b273e3781162810e"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ import { createModel as createCpBikeRack } from '@/models/contemporary-props/bik
|
||||||
import { createModel as createCpCableDrum } from '@/models/contemporary-props/cable-drum/model.ts'
|
import { createModel as createCpCableDrum } from '@/models/contemporary-props/cable-drum/model.ts'
|
||||||
import { createModel as createCpLitterBin } from '@/models/contemporary-props/litter-bin/model.ts'
|
import { createModel as createCpLitterBin } from '@/models/contemporary-props/litter-bin/model.ts'
|
||||||
import { createModel as createCpFencePanel } from '@/models/contemporary-props/temporary-fence-panel/model.ts'
|
import { createModel as createCpFencePanel } from '@/models/contemporary-props/temporary-fence-panel/model.ts'
|
||||||
|
import { createModel as createCpWasteBin } from '@/models/contemporary-props/wheeled-waste-bin/model.ts'
|
||||||
import { createModel as createCpPavementSign } from '@/models/contemporary-props/pavement-sign-board/model.ts'
|
import { createModel as createCpPavementSign } from '@/models/contemporary-props/pavement-sign-board/model.ts'
|
||||||
import { createModel as createCpLectern } from '@/models/contemporary-props/lectern/model.ts'
|
import { createModel as createCpLectern } from '@/models/contemporary-props/lectern/model.ts'
|
||||||
import cpMetaCeramicVase from '../contemporary-props/models/ceramic-vase/meta.json'
|
import cpMetaCeramicVase from '../contemporary-props/models/ceramic-vase/meta.json'
|
||||||
|
|
@ -87,6 +88,7 @@ import cpMetaBikeRack from '../contemporary-props/models/bike-rack/meta.json'
|
||||||
import cpMetaCableDrum from '../contemporary-props/models/cable-drum/meta.json'
|
import cpMetaCableDrum from '../contemporary-props/models/cable-drum/meta.json'
|
||||||
import cpMetaLitterBin from '../contemporary-props/models/litter-bin/meta.json'
|
import cpMetaLitterBin from '../contemporary-props/models/litter-bin/meta.json'
|
||||||
import cpMetaFencePanel from '../contemporary-props/models/temporary-fence-panel/meta.json'
|
import cpMetaFencePanel from '../contemporary-props/models/temporary-fence-panel/meta.json'
|
||||||
|
import cpMetaWasteBin from '../contemporary-props/models/wheeled-waste-bin/meta.json'
|
||||||
import cpMetaPavementSign from '../contemporary-props/models/pavement-sign-board/meta.json'
|
import cpMetaPavementSign from '../contemporary-props/models/pavement-sign-board/meta.json'
|
||||||
import cpMetaLectern from '../contemporary-props/models/lectern/meta.json'
|
import cpMetaLectern from '../contemporary-props/models/lectern/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'
|
||||||
|
|
@ -310,6 +312,7 @@ const CONTEMPORARY_ORDER = [
|
||||||
'cable-drum',
|
'cable-drum',
|
||||||
'litter-bin',
|
'litter-bin',
|
||||||
'temporary-fence-panel',
|
'temporary-fence-panel',
|
||||||
|
'wheeled-waste-bin',
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
const CONTEMPORARY_FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
const CONTEMPORARY_FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
||||||
|
|
@ -330,6 +333,7 @@ const CONTEMPORARY_FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
||||||
'cable-drum': as(createCpCableDrum),
|
'cable-drum': as(createCpCableDrum),
|
||||||
'litter-bin': as(createCpLitterBin),
|
'litter-bin': as(createCpLitterBin),
|
||||||
'temporary-fence-panel': as(createCpFencePanel),
|
'temporary-fence-panel': as(createCpFencePanel),
|
||||||
|
'wheeled-waste-bin': as(createCpWasteBin),
|
||||||
'pavement-sign-board': as(createCpPavementSign),
|
'pavement-sign-board': as(createCpPavementSign),
|
||||||
'lectern': as(createCpLectern),
|
'lectern': as(createCpLectern),
|
||||||
}
|
}
|
||||||
|
|
@ -352,6 +356,7 @@ const CONTEMPORARY_META: Readonly<Record<string, ModelMetaLike>> = {
|
||||||
'cable-drum': cpMetaCableDrum as ModelMetaLike,
|
'cable-drum': cpMetaCableDrum as ModelMetaLike,
|
||||||
'litter-bin': cpMetaLitterBin as ModelMetaLike,
|
'litter-bin': cpMetaLitterBin as ModelMetaLike,
|
||||||
'temporary-fence-panel': cpMetaFencePanel as ModelMetaLike,
|
'temporary-fence-panel': cpMetaFencePanel as ModelMetaLike,
|
||||||
|
'wheeled-waste-bin': cpMetaWasteBin as ModelMetaLike,
|
||||||
'pavement-sign-board': cpMetaPavementSign as ModelMetaLike,
|
'pavement-sign-board': cpMetaPavementSign as ModelMetaLike,
|
||||||
'lectern': cpMetaLectern as ModelMetaLike,
|
'lectern': cpMetaLectern as ModelMetaLike,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,105 @@ export function latheGeometry(
|
||||||
return finish(sink)
|
return finish(sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A wheel, in the two materials every wheel is made of. */
|
||||||
|
export interface Wheel {
|
||||||
|
/** The tyre, which wants a rubber slot. */
|
||||||
|
readonly tyre: BufferGeometry
|
||||||
|
/** The hub and its spokes, which want a plastic or steel one. */
|
||||||
|
readonly hub: BufferGeometry
|
||||||
|
/**
|
||||||
|
* How far the axle must be off the ground for the wheel to TOUCH it.
|
||||||
|
*
|
||||||
|
* Not the radius. A lathed wheel is a polygon, its vertices sit at the
|
||||||
|
* radius and its faces are chords, so unless a vertex happens to land at the
|
||||||
|
* bottom the lowest point of the tyre is `radius * cos(pi / segments)` --
|
||||||
|
* about a millimetre in on a 200 mm wheel at 22 sides. Put the axle at the
|
||||||
|
* radius and the whole model hovers by that millimetre, which is exactly the
|
||||||
|
* fault the ground check exists to catch and exactly the kind nobody finds
|
||||||
|
* by looking.
|
||||||
|
*/
|
||||||
|
readonly contact: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A road wheel: a tyre on a spoked hub, axle along X, centred on the origin.
|
||||||
|
*
|
||||||
|
* The catalogue calls the wheeled bin "the first appearance of the wheel part",
|
||||||
|
* and the part is written here rather than in that model because four more rows
|
||||||
|
* in three other domains want the same thing: the sack truck and the wheelbarrow
|
||||||
|
* (37 and 38, tools), the shopping trolley (42, retail) and the task chair
|
||||||
|
* (93, office). The castor at row 39 is this plus a swivel fork, not a
|
||||||
|
* different wheel.
|
||||||
|
*
|
||||||
|
* Two geometries out rather than one, because a wheel is two materials and the
|
||||||
|
* kit assigns a slot per part. Returning them merged would mean every consumer
|
||||||
|
* who wanted a red trolley got red tyres.
|
||||||
|
*
|
||||||
|
* The tyre is a lathe rather than a torus: a real one has a flat contact patch
|
||||||
|
* and a shoulder, and a torus reads as a doughnut at every size.
|
||||||
|
*/
|
||||||
|
export function wheelGeometry(options: {
|
||||||
|
readonly radius: number
|
||||||
|
readonly width: number
|
||||||
|
readonly spokes: number
|
||||||
|
readonly tyre: Color
|
||||||
|
readonly hub: Color
|
||||||
|
readonly segments?: number
|
||||||
|
}): Wheel {
|
||||||
|
const { radius: R, width: W, tyre: tyreColour, hub: hubColour } = options
|
||||||
|
const segments = Math.max(12, Math.round(options.segments ?? 22))
|
||||||
|
const spokes = Math.max(3, Math.round(options.spokes))
|
||||||
|
const half = W / 2
|
||||||
|
|
||||||
|
// Built about Y and tipped, for the reason every round thing here is: the
|
||||||
|
// lathe turns about Y and one rotation at the end is cheaper than carrying
|
||||||
|
// an axis through every level.
|
||||||
|
const tyre = latheGeometry([
|
||||||
|
{ y: -half, radius: R * 0.72 },
|
||||||
|
{ y: -half, radius: R * 0.93 },
|
||||||
|
{ y: -half * 0.72, radius: R },
|
||||||
|
{ y: half * 0.72, radius: R },
|
||||||
|
{ y: half, radius: R * 0.93 },
|
||||||
|
{ y: half, radius: R * 0.72 },
|
||||||
|
], segments, [0, 0, 0], tyreColour, { capBottom: false, capTop: false })
|
||||||
|
tyre.rotateZ(Math.PI / 2)
|
||||||
|
|
||||||
|
const hubPieces: BufferGeometry[] = [
|
||||||
|
latheGeometry([
|
||||||
|
{ y: -half * 0.62, radius: R * 0.2 },
|
||||||
|
{ y: -half * 0.62, radius: R * 0.74 },
|
||||||
|
{ y: -half * 0.3, radius: R * 0.76 },
|
||||||
|
{ y: half * 0.3, radius: R * 0.76 },
|
||||||
|
{ y: half * 0.62, radius: R * 0.74 },
|
||||||
|
{ y: half * 0.62, radius: R * 0.2 },
|
||||||
|
], segments, [0, 0, 0], hubColour, { capBottom: false, capTop: false }),
|
||||||
|
// The boss the axle passes through, closed at both ends so the wheel is
|
||||||
|
// not a tube you can see down.
|
||||||
|
latheGeometry([
|
||||||
|
{ y: -half * 0.8, radius: R * 0.2 },
|
||||||
|
{ y: half * 0.8, radius: R * 0.2 },
|
||||||
|
], 12, [0, 0, 0], hubColour, { capBottom: true, capTop: true }),
|
||||||
|
]
|
||||||
|
|
||||||
|
// The spokes, which are the only thing that says a wheel is turning when it
|
||||||
|
// turns: a plain disc at speed looks exactly like a plain disc at rest.
|
||||||
|
for (let i = 0; i < spokes; i += 1) {
|
||||||
|
const a = (i / spokes) * Math.PI * 2
|
||||||
|
const spoke = chamferedBoxGeometry(
|
||||||
|
[R * 0.17, R * 0.5], [R * 0.13, R * 0.5],
|
||||||
|
W * 0.34, R * 0.03, [0, 0, 0], hubColour,
|
||||||
|
)
|
||||||
|
spoke.rotateX(Math.PI / 2)
|
||||||
|
spoke.translate(0, 0, R * 0.47)
|
||||||
|
spoke.rotateY(a)
|
||||||
|
hubPieces.push(spoke)
|
||||||
|
}
|
||||||
|
const hub = mergeColoured(hubPieces)
|
||||||
|
hub.rotateZ(Math.PI / 2)
|
||||||
|
|
||||||
|
return { tyre, hub, contact: R * Math.cos(Math.PI / segments) }
|
||||||
|
}
|
||||||
|
|
||||||
/** How a surface is punched, for `perforate`. */
|
/** How a surface is punched, for `perforate`. */
|
||||||
export interface PerforationPattern {
|
export interface PerforationPattern {
|
||||||
/** Rows of holes up the surface. */
|
/** Rows of holes up the surface. */
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,11 @@ export {
|
||||||
staveGeometry,
|
staveGeometry,
|
||||||
smoothNormals,
|
smoothNormals,
|
||||||
tubeGeometry,
|
tubeGeometry,
|
||||||
|
wheelGeometry,
|
||||||
taperedBoxGeometry,
|
taperedBoxGeometry,
|
||||||
} from './geometry.ts'
|
} from './geometry.ts'
|
||||||
export type { Level, MottleOptions, PerforationPattern, Plan, PlanLevel, RoughenOptions, Section, SheetLevel, Vec3 } from './geometry.ts'
|
export type { Level, MottleOptions, PerforationPattern, Plan, PlanLevel,
|
||||||
|
Wheel, 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'
|
||||||
|
|
|
||||||
|
|
@ -163,11 +163,31 @@ export function createModel(overrides: Partial<FencePanelConfig> = {}) {
|
||||||
const columns = Math.max(4, Math.round(inner / Math.min(0.3, Math.max(0.02, config.pitch))))
|
const columns = Math.max(4, Math.round(inner / Math.min(0.3, Math.max(0.02, config.pitch))))
|
||||||
const wireR = H * 0.0022
|
const wireR = H * 0.0022
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Every wire is cut to the FRAME, not to a rectangle.
|
||||||
|
*
|
||||||
|
* The frame's top corners are radiused and the mesh is not, so wires cut
|
||||||
|
* to one length stand proud of the bend at both ends -- four or five of
|
||||||
|
* them at each corner, sticking out into the air above the tube they are
|
||||||
|
* supposed to be welded to. It is the sort of fault that is invisible
|
||||||
|
* head on and obvious from anywhere else.
|
||||||
|
*
|
||||||
|
* The cut is the arc's own equation, so it follows the corner radius
|
||||||
|
* whatever it is set to.
|
||||||
|
*/
|
||||||
|
const topAt = (x: number): number => {
|
||||||
|
const over = Math.abs(x) - (half - corner)
|
||||||
|
if (over <= 0) return meshHi
|
||||||
|
const drop = corner - Math.sqrt(Math.max(0, corner * corner - over * over))
|
||||||
|
return meshHi - drop
|
||||||
|
}
|
||||||
for (let i = 0; i <= columns; i += 1) {
|
for (let i = 0; i <= columns; i += 1) {
|
||||||
const x = -inner / 2 + (inner / columns) * i
|
const x = -inner / 2 + (inner / columns) * i
|
||||||
|
const hi = topAt(x)
|
||||||
|
if (hi - meshLo <= wireR * 2) continue
|
||||||
panelPieces.push(chamferedBoxGeometry(
|
panelPieces.push(chamferedBoxGeometry(
|
||||||
[wireR * 2, wireR * 2], [wireR * 2, wireR * 2],
|
[wireR * 2, wireR * 2], [wireR * 2, wireR * 2],
|
||||||
meshHi - meshLo, wireR * 0.5, [x, (meshLo + meshHi) / 2, 0], wire,
|
hi - meshLo, wireR * 0.5, [x, (meshLo + hi) / 2, 0], wire,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
for (let i = 0; i < rails; i += 1) {
|
for (let i = 0; i < rails; i += 1) {
|
||||||
|
|
@ -219,6 +239,25 @@ export function createModel(overrides: Partial<FencePanelConfig> = {}) {
|
||||||
)
|
)
|
||||||
block.translate(side * half, footH / 2, 0)
|
block.translate(side * half, footH / 2, 0)
|
||||||
footPieces.push(block)
|
footPieces.push(block)
|
||||||
|
|
||||||
|
// The notches at each end, which every moulded foot has: they are how
|
||||||
|
// a forklift or a hand gets under it, and without them the foot reads
|
||||||
|
// as a bevelled brick.
|
||||||
|
for (const end of [-1, 1]) {
|
||||||
|
footPieces.push(chamferedBoxGeometry(
|
||||||
|
[H * 0.05, footL * 0.16], [H * 0.05, footL * 0.16],
|
||||||
|
footH * 0.55, footH * 0.06,
|
||||||
|
[side * half, footH * 0.28, end * footL * 0.34], tint('rubber', -0.3, 0.3),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
// ...and the moulded recess on the top face either side of the boss.
|
||||||
|
for (const end of [-1, 1]) {
|
||||||
|
footPieces.push(chamferedBoxGeometry(
|
||||||
|
[H * 0.042, footL * 0.2], [H * 0.036, footL * 0.18],
|
||||||
|
footH * 0.12, footH * 0.04,
|
||||||
|
[side * half, footH * 0.96, end * footL * 0.24], tint('rubber', -0.16, 0.3),
|
||||||
|
))
|
||||||
|
}
|
||||||
// The boss the leg goes into, so the leg lands in something rather
|
// The boss the leg goes into, so the leg lands in something rather
|
||||||
// than on it.
|
// than on it.
|
||||||
footPieces.push(chamferedBoxGeometry(
|
footPieces.push(chamferedBoxGeometry(
|
||||||
|
|
|
||||||
284
src/models/contemporary-props/wheeled-waste-bin/model.ts
Normal file
284
src/models/contemporary-props/wheeled-waste-bin/model.ts
Normal file
|
|
@ -0,0 +1,284 @@
|
||||||
|
/**
|
||||||
|
* @contemporary-props/wheeled-waste-bin
|
||||||
|
*
|
||||||
|
* A tapered ribbed moulding with a hinged lid on an axle, and the catalogue's
|
||||||
|
* thirty-second row: the first appearance of the wheel part. The wheel itself
|
||||||
|
* lives in core rather than here, because four later rows in three other
|
||||||
|
* domains want the same one -- the sack truck and the wheelbarrow in tools, the
|
||||||
|
* shopping trolley in retail, the task chair in the office -- and a wheel
|
||||||
|
* written inside a bin is a wheel each of them rewrites.
|
||||||
|
*
|
||||||
|
* Measured against the 240 litre bin, which is the one on every kerb: 1080 mm
|
||||||
|
* to the top of the lid, 580 across the front, 740 front to back, on 200 mm
|
||||||
|
* wheels. The body tapers about a tenth from its rim to its base, which is not
|
||||||
|
* styling -- it is draft, so the moulding leaves the tool, and it is the reason
|
||||||
|
* these things stack.
|
||||||
|
*
|
||||||
|
* The lid hinges on the axle bar across the back, so its origin is that bar and
|
||||||
|
* nothing else. It also OVERHANGS at the front, which is what makes the lip you
|
||||||
|
* lift it by, and the gussets under the rim are the moulded ribs that stop a
|
||||||
|
* thin-walled box that size from folding when it is tipped.
|
||||||
|
*/
|
||||||
|
import { type BufferGeometry } from 'three'
|
||||||
|
|
||||||
|
import {
|
||||||
|
bakeOcclusion,
|
||||||
|
chamferedBoxGeometry,
|
||||||
|
createKitModel,
|
||||||
|
createTinter,
|
||||||
|
jitter,
|
||||||
|
latheGeometry,
|
||||||
|
mergeColoured,
|
||||||
|
smoothNormals,
|
||||||
|
wheelGeometry,
|
||||||
|
type RuntimeContext,
|
||||||
|
} from '../core/index.ts'
|
||||||
|
|
||||||
|
export interface WasteBinConfig {
|
||||||
|
/** Height to the top of the closed lid (metres). */
|
||||||
|
readonly height: number
|
||||||
|
/** Width across the front (metres). */
|
||||||
|
readonly width: number
|
||||||
|
/** Depth, front to back (metres). */
|
||||||
|
readonly depth: number
|
||||||
|
/** How far the lid is open, 0 shut to 1 back on its hinge. */
|
||||||
|
readonly open: number
|
||||||
|
readonly seed: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const wasteBinDefaults: WasteBinConfig = {
|
||||||
|
height: 1.08,
|
||||||
|
width: 0.58,
|
||||||
|
depth: 0.74,
|
||||||
|
open: 0,
|
||||||
|
seed: 61,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type WasteBinParts = 'body' | 'lid' | 'wheels' | 'tyres'
|
||||||
|
|
||||||
|
export interface WasteBinActions {
|
||||||
|
/** Swings the lid back on its hinge. 1 is fully open. */
|
||||||
|
open(amount?: number): void
|
||||||
|
/** Rolls the wheels. 1 is a full turn. */
|
||||||
|
roll(turns?: number): void
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyOpen(
|
||||||
|
runtime: RuntimeContext<WasteBinConfig, WasteBinParts>,
|
||||||
|
amount: number,
|
||||||
|
): void {
|
||||||
|
// Just past square, which is where a bin lid actually falls to when it is
|
||||||
|
// thrown back: it goes over centre and rests against the body.
|
||||||
|
runtime.parts.lid.anchor.rotation.x = Math.min(1, Math.max(0, amount)) * 1.9
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createModel(overrides: Partial<WasteBinConfig> = {}) {
|
||||||
|
let heldOpen = 0
|
||||||
|
let seenOpen = Number.NaN
|
||||||
|
|
||||||
|
return createKitModel<
|
||||||
|
WasteBinConfig, 'plastic' | 'rubber', WasteBinParts, WasteBinActions
|
||||||
|
>({
|
||||||
|
id: 'wheeled-waste-bin',
|
||||||
|
defaults: wasteBinDefaults,
|
||||||
|
slots: ['plastic', 'rubber'],
|
||||||
|
|
||||||
|
build: ({ config, random }) => {
|
||||||
|
const tint = createTinter(random)
|
||||||
|
const H = Math.min(1.4, Math.max(0.7, config.height))
|
||||||
|
const W = Math.min(0.9, Math.max(0.35, config.width))
|
||||||
|
const D = Math.min(1.1, Math.max(0.4, config.depth))
|
||||||
|
|
||||||
|
// Down from the palette's plastic, which is set for the pale mouldings
|
||||||
|
// most of the kit's plastic is. A municipal bin is a mid grey, and at the
|
||||||
|
// palette's own value the body came out near white and read as a fridge.
|
||||||
|
const shell = tint('plastic', -0.33 + jitter(random, 0.02))
|
||||||
|
const dark = tint('plastic', -0.46, 0.6)
|
||||||
|
|
||||||
|
const wheelR = H * 0.093
|
||||||
|
const lidH = H * 0.085
|
||||||
|
const bodyTop = H - lidH
|
||||||
|
const bodyBase = wheelR * 0.28
|
||||||
|
// A tenth of draft between rim and base, which is what lets the moulding
|
||||||
|
// leave the tool and what makes a rank of these nest.
|
||||||
|
const taper = 0.9
|
||||||
|
|
||||||
|
const bodyPieces: BufferGeometry[] = []
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------- body */
|
||||||
|
bodyPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * taper, D * taper], [W, D],
|
||||||
|
bodyTop - bodyBase, W * 0.075, [0, (bodyTop + bodyBase) / 2, 0], shell,
|
||||||
|
))
|
||||||
|
|
||||||
|
// The rim: a flange right round the top, which is what the lid sits on
|
||||||
|
// and what a lifter's forks catch under.
|
||||||
|
bodyPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * 1.028, D * 1.028], [W * 1.02, D * 1.02],
|
||||||
|
H * 0.03, W * 0.02, [0, bodyTop - H * 0.012, 0], shell,
|
||||||
|
))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The gussets under the rim.
|
||||||
|
*
|
||||||
|
* They are the dark triangles in every photograph of one of these and
|
||||||
|
* they are structural: a thin-walled box 1.1 m tall folds at the rim when
|
||||||
|
* it is tipped, so the moulding carries a rib every 150 mm or so. Left
|
||||||
|
* off, the body reads as a bin bag holder.
|
||||||
|
*/
|
||||||
|
const ribs = Math.max(4, Math.round(W / 0.15) * 2 + Math.round(D / 0.15) * 2)
|
||||||
|
for (let i = 0; i < ribs; i += 1) {
|
||||||
|
const t = (i + 0.5) / ribs
|
||||||
|
// Walk the rim's perimeter, so the ribs sit on all four faces without
|
||||||
|
// four separate loops and without bunching at the corners.
|
||||||
|
const a = t * Math.PI * 2
|
||||||
|
const ex = Math.cos(a)
|
||||||
|
const ez = Math.sin(a)
|
||||||
|
const scale = 1 / Math.max(Math.abs(ex) / (W / 2), Math.abs(ez) / (D / 2))
|
||||||
|
const x = ex * scale
|
||||||
|
const z = ez * scale
|
||||||
|
// Short and broad at the top, tapering to nothing: a gusset, not a
|
||||||
|
// tooth. At three quarters of this length they hung below the rim in a
|
||||||
|
// row and the bin came out fringed.
|
||||||
|
// Measured off the reference at 7% of the body's height, which is
|
||||||
|
// between the two rounds that argued about it: at 7.5% they hung below
|
||||||
|
// the rim like a fringe, at 4.2% the critic called them shallow, and
|
||||||
|
// neither reading was taken from the photograph.
|
||||||
|
const rib = chamferedBoxGeometry(
|
||||||
|
[W * 0.06, W * 0.08], [W * 0.03, W * 0.01],
|
||||||
|
H * 0.06, W * 0.008, [0, 0, 0], dark,
|
||||||
|
)
|
||||||
|
rib.translate(x * 0.985, bodyTop - H * 0.052, z * 0.985)
|
||||||
|
bodyPieces.push(rib)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- lid */
|
||||||
|
/**
|
||||||
|
* A domed lid that OVERHANGS at the front.
|
||||||
|
*
|
||||||
|
* Flush with the body it is a flat cap and there is nothing to lift it
|
||||||
|
* by; the reference's stands proud all round and further at the front,
|
||||||
|
* where the lip is. The dome is two steps rather than a curve because a
|
||||||
|
* blow-moulded lid is exactly that: a flat crown with a shoulder.
|
||||||
|
*/
|
||||||
|
const hingeZ = D * 0.5
|
||||||
|
const lidPieces: BufferGeometry[] = []
|
||||||
|
lidPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * 1.05, D * 1.03], [W * 1.02, D * 1.0],
|
||||||
|
lidH * 0.55, W * 0.03, [0, bodyTop + lidH * 0.275, -D * 0.01], shell,
|
||||||
|
))
|
||||||
|
lidPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * 0.94, D * 0.9], [W * 0.8, D * 0.76],
|
||||||
|
lidH * 0.5, W * 0.035, [0, bodyTop + lidH * 0.72, -D * 0.02], shell,
|
||||||
|
))
|
||||||
|
// The two shoulders running front to back, which every blow-moulded lid
|
||||||
|
// has and which are the only thing breaking a half square metre of flat
|
||||||
|
// grey. They are stiffeners, so they run the long way.
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
lidPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * 0.2, D * 0.72], [W * 0.15, D * 0.66],
|
||||||
|
lidH * 0.22, W * 0.03,
|
||||||
|
[side * W * 0.24, bodyTop + lidH * 0.96, -D * 0.03], shell,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
// The lip at the front, which is the handle.
|
||||||
|
lidPieces.push(chamferedBoxGeometry(
|
||||||
|
[W * 0.5, D * 0.05], [W * 0.44, D * 0.035],
|
||||||
|
lidH * 0.34, W * 0.012,
|
||||||
|
[0, bodyTop + lidH * 0.2, -D * 0.5 - D * 0.012], dark,
|
||||||
|
))
|
||||||
|
|
||||||
|
/* -------------------------------------------------- axle and the wheels */
|
||||||
|
/**
|
||||||
|
* The wheels come from core, and they come as two geometries.
|
||||||
|
*
|
||||||
|
* A wheel is a tyre and a hub in two different materials, and this kit
|
||||||
|
* gives one slot per part -- so the helper hands back both and the model
|
||||||
|
* puts each in its own part. Merged into one, a consumer who recoloured
|
||||||
|
* the bin's plastic would get plastic tyres.
|
||||||
|
*/
|
||||||
|
const wheelX = W * 0.5 - wheelR * 0.42
|
||||||
|
const wheelZ = D * 0.5 - wheelR * 0.85
|
||||||
|
const tyrePieces: BufferGeometry[] = []
|
||||||
|
const hubPieces: BufferGeometry[] = []
|
||||||
|
// Set from the wheel's own contact radius rather than from its nominal
|
||||||
|
// one: see `Wheel.contact`. At the radius the bin hovered a millimetre.
|
||||||
|
let wheelY = wheelR
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
const { tyre, hub, contact } = wheelGeometry({
|
||||||
|
radius: wheelR,
|
||||||
|
width: wheelR * 0.42,
|
||||||
|
spokes: 5,
|
||||||
|
tyre: tint('rubber', jitter(random, 0.02)),
|
||||||
|
// As dark as the tyre nearly. A pale hub on a black tyre reads as a
|
||||||
|
// flat disc stuck to the wheel rather than as a recess in it, which
|
||||||
|
// is what the spokes are there to show.
|
||||||
|
hub: tint('plastic', -0.52, 0.4),
|
||||||
|
})
|
||||||
|
wheelY = contact
|
||||||
|
tyre.translate(side * wheelX, wheelY, wheelZ)
|
||||||
|
hub.translate(side * wheelX, wheelY, wheelZ)
|
||||||
|
tyrePieces.push(tyre)
|
||||||
|
hubPieces.push(hub)
|
||||||
|
}
|
||||||
|
// The axle between them, and the two stub brackets the body carries it on.
|
||||||
|
bodyPieces.push(latheGeometry([
|
||||||
|
{ y: -wheelX, radius: wheelR * 0.13 },
|
||||||
|
{ y: wheelX, radius: wheelR * 0.13 },
|
||||||
|
], 10, [0, 0, 0], dark, { capBottom: false, capTop: false })
|
||||||
|
.rotateZ(Math.PI / 2)
|
||||||
|
.translate(0, wheelY, wheelZ))
|
||||||
|
|
||||||
|
// The hinge bar across the back, which the lid turns on and the handle
|
||||||
|
// a bin is wheeled by.
|
||||||
|
bodyPieces.push(latheGeometry([
|
||||||
|
{ y: -W * 0.46, radius: H * 0.014 },
|
||||||
|
{ y: W * 0.46, radius: H * 0.014 },
|
||||||
|
], 12, [0, 0, 0], dark, { capBottom: true, capTop: true })
|
||||||
|
.rotateZ(Math.PI / 2)
|
||||||
|
// Proud of the lid at the back rather than under it: the hinge bar is
|
||||||
|
// also the handle a bin is wheeled by, and a hinge nobody can see is a
|
||||||
|
// hinge the model does not demonstrate.
|
||||||
|
.translate(0, bodyTop + H * 0.042, hingeZ + H * 0.012))
|
||||||
|
|
||||||
|
bakeOcclusion(bodyPieces, { strength: 0.4 })
|
||||||
|
|
||||||
|
const hinge = [0, bodyTop + H * 0.042, hingeZ + H * 0.012] as const
|
||||||
|
return {
|
||||||
|
body: { slot: 'plastic' as const, geometry: smoothNormals(mergeColoured(bodyPieces), 38) },
|
||||||
|
lid: {
|
||||||
|
slot: 'plastic' as const,
|
||||||
|
geometry: smoothNormals(
|
||||||
|
mergeColoured(lidPieces).translate(-hinge[0], -hinge[1], -hinge[2]), 38,
|
||||||
|
),
|
||||||
|
origin: hinge,
|
||||||
|
},
|
||||||
|
wheels: { slot: 'plastic' as const, geometry: smoothNormals(mergeColoured(hubPieces), 40) },
|
||||||
|
tyres: { slot: 'rubber' as const, geometry: smoothNormals(mergeColoured(tyrePieces), 40) },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: (runtime) => {
|
||||||
|
heldOpen = runtime.getConfig().open
|
||||||
|
seenOpen = heldOpen
|
||||||
|
applyOpen(runtime, heldOpen)
|
||||||
|
return {
|
||||||
|
open: (amount = 1) => { heldOpen = amount; applyOpen(runtime, amount) },
|
||||||
|
roll: (turns = 0.25) => {
|
||||||
|
// The wheels turn about their own axle, which is where both wheel
|
||||||
|
// parts already sit, so one rotation on each is the whole action.
|
||||||
|
for (const name of ['wheels', 'tyres'] as const) {
|
||||||
|
runtime.parts[name].anchor.rotation.x = -turns * Math.PI * 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
update: (_dt, runtime) => {
|
||||||
|
const wanted = runtime.getConfig().open
|
||||||
|
if (wanted !== seenOpen) { seenOpen = wanted; heldOpen = wanted }
|
||||||
|
applyOpen(runtime, heldOpen)
|
||||||
|
},
|
||||||
|
}, overrides)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue