Add the post mill
The largest thing in the kit, and the one whose name is its whole design: the entire body -- millstones, gearing, miller and all -- is balanced on one massive vertical post and turns bodily on it, so the sails can be pointed into whatever wind there is. The miller does that by walking the tail ladder round, which is why the ladder is not a way up but a lever, and why it reaches so far behind the mill. Four parts, in the order the thing is built: `trestle` (two cross-trees, the post standing on them, four quarter-bars), `body` (the boarded buck and its pitched roof), `sails` (a windshaft leaving the front gable, with its own origin so `setTurning` spins it alone), and `ladder`. `setTurning`, `setAngle` and `update` drive the sails at about ten revolutions a minute -- a working mill turns slowly, not in the blur people draw. The sails are where the triangles went, and deliberately. A sail is not a blade, it is a LATTICE the miller dresses with canvas according to the wind. Drawn solid the silhouette is wrong in the one place everyone looks, so the bars are modelled and the budget is taken from the buck's boarding, which reads perfectly well as vertex colour. 1 516 triangles. Four faults on the way in, all found by measuring rather than by looking: The roof pitches were built `slope * 2` long and tilted by the complement of the roof angle, which made two panels 2.79 m across a building 1.80 m wide, standing up like the covers of an open book. Each pitch covers half a roof, and the tilt is measured from the horizontal because `chamferedBoxGeometry` takes an X-Z footprint. The rails of the tail ladder were tilted the wrong way round. `run` is positive -- the head sits at a larger z than the foot -- so rotating by `-lean` laid the rails along the opposite diagonal to the one the rungs were placed on. They crossed near the middle and diverged towards the ends, and the bounding box looked correct the whole time because the translation put the ladder where it belonged and only its internals were wrong. The support audit found it as loose rungs, and found it only at the small end of the height slider, where the voxel grid is fine enough not to bridge the gap: the joint was never real at any size. Fixing the ladder's foot, which sat 0.10 m below the cross-trees so the mill hovered above whatever it was placed on, then displaced the rails perpendicular to their own axis by almost exactly a rung's half-depth -- correcting the rails alone was worse than not correcting at all. Rails and rungs now share one lift. And the lowest sail tip came within 0.27 m of the ground, which reads as a mill about to plough its own field. 28 models, 20 523 triangles, all checks pass, 0 floating cases, GLB round-trip clean, Conformant at 30 items, build clean.
This commit is contained in:
parent
6c2e5bbeca
commit
d159acfd97
8 changed files with 935 additions and 31 deletions
BIN
media/kit.png
BIN
media/kit.png
Binary file not shown.
|
Before Width: | Height: | Size: 344 KiB After Width: | Height: | Size: 350 KiB |
|
|
@ -67,7 +67,7 @@
|
||||||
"address": "@medieval-kit/wooden-barrel",
|
"address": "@medieval-kit/wooden-barrel",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.197Z",
|
"installedAt": "2026-08-23T05:59:27.359Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-barrel\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-barrel\\model.ts",
|
||||||
|
|
@ -82,7 +82,7 @@
|
||||||
"address": "@medieval-kit/core",
|
"address": "@medieval-kit/core",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.176Z",
|
"installedAt": "2026-08-23T05:59:27.330Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\core\\geometry.ts",
|
"path": "src\\models\\medieval-kit\\core\\geometry.ts",
|
||||||
|
|
@ -129,7 +129,7 @@
|
||||||
"address": "@medieval-kit/wooden-crate",
|
"address": "@medieval-kit/wooden-crate",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.202Z",
|
"installedAt": "2026-08-23T05:59:27.366Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-crate\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-crate\\model.ts",
|
||||||
|
|
@ -144,7 +144,7 @@
|
||||||
"address": "@medieval-kit/kit",
|
"address": "@medieval-kit/kit",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.209Z",
|
"installedAt": "2026-08-23T05:59:27.375Z",
|
||||||
"files": [],
|
"files": [],
|
||||||
"dependencies": []
|
"dependencies": []
|
||||||
},
|
},
|
||||||
|
|
@ -152,7 +152,7 @@
|
||||||
"address": "@medieval-kit/iron-anvil",
|
"address": "@medieval-kit/iron-anvil",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.184Z",
|
"installedAt": "2026-08-23T05:59:27.340Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\iron-anvil\\model.ts",
|
"path": "src\\models\\medieval-kit\\iron-anvil\\model.ts",
|
||||||
|
|
@ -167,7 +167,7 @@
|
||||||
"address": "@medieval-kit/wooden-bucket",
|
"address": "@medieval-kit/wooden-bucket",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.199Z",
|
"installedAt": "2026-08-23T05:59:27.363Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-bucket\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-bucket\\model.ts",
|
||||||
|
|
@ -182,7 +182,7 @@
|
||||||
"address": "@medieval-kit/wooden-fence",
|
"address": "@medieval-kit/wooden-fence",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.203Z",
|
"installedAt": "2026-08-23T05:59:27.367Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-fence\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-fence\\model.ts",
|
||||||
|
|
@ -197,7 +197,7 @@
|
||||||
"address": "@medieval-kit/wooden-hoe",
|
"address": "@medieval-kit/wooden-hoe",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.204Z",
|
"installedAt": "2026-08-23T05:59:27.369Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-hoe\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-hoe\\model.ts",
|
||||||
|
|
@ -212,7 +212,7 @@
|
||||||
"address": "@medieval-kit/wooden-ladder",
|
"address": "@medieval-kit/wooden-ladder",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.205Z",
|
"installedAt": "2026-08-23T05:59:27.370Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-ladder\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-ladder\\model.ts",
|
||||||
|
|
@ -227,7 +227,7 @@
|
||||||
"address": "@medieval-kit/wooden-pitchfork",
|
"address": "@medieval-kit/wooden-pitchfork",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.206Z",
|
"installedAt": "2026-08-23T05:59:27.371Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-pitchfork\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-pitchfork\\model.ts",
|
||||||
|
|
@ -242,7 +242,7 @@
|
||||||
"address": "@medieval-kit/wooden-shovel",
|
"address": "@medieval-kit/wooden-shovel",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.208Z",
|
"installedAt": "2026-08-23T05:59:27.373Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-shovel\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-shovel\\model.ts",
|
||||||
|
|
@ -257,7 +257,7 @@
|
||||||
"address": "@medieval-kit/wooden-stool",
|
"address": "@medieval-kit/wooden-stool",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.209Z",
|
"installedAt": "2026-08-23T05:59:27.375Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-stool\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-stool\\model.ts",
|
||||||
|
|
@ -272,7 +272,7 @@
|
||||||
"address": "@medieval-kit/cart-wheel",
|
"address": "@medieval-kit/cart-wheel",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.180Z",
|
"installedAt": "2026-08-23T05:59:27.334Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\cart-wheel\\model.ts",
|
"path": "src\\models\\medieval-kit\\cart-wheel\\model.ts",
|
||||||
|
|
@ -287,7 +287,7 @@
|
||||||
"address": "@medieval-kit/log-pile",
|
"address": "@medieval-kit/log-pile",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.189Z",
|
"installedAt": "2026-08-23T05:59:27.346Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\log-pile\\model.ts",
|
"path": "src\\models\\medieval-kit\\log-pile\\model.ts",
|
||||||
|
|
@ -302,7 +302,7 @@
|
||||||
"address": "@medieval-kit/trestle-table",
|
"address": "@medieval-kit/trestle-table",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.194Z",
|
"installedAt": "2026-08-23T05:59:27.356Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\trestle-table\\model.ts",
|
"path": "src\\models\\medieval-kit\\trestle-table\\model.ts",
|
||||||
|
|
@ -317,7 +317,7 @@
|
||||||
"address": "@medieval-kit/wooden-chest",
|
"address": "@medieval-kit/wooden-chest",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.201Z",
|
"installedAt": "2026-08-23T05:59:27.364Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-chest\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-chest\\model.ts",
|
||||||
|
|
@ -332,7 +332,7 @@
|
||||||
"address": "@medieval-kit/hay-bale",
|
"address": "@medieval-kit/hay-bale",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.183Z",
|
"installedAt": "2026-08-23T05:59:27.339Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\hay-bale\\model.ts",
|
"path": "src\\models\\medieval-kit\\hay-bale\\model.ts",
|
||||||
|
|
@ -347,7 +347,7 @@
|
||||||
"address": "@medieval-kit/pitch-torch",
|
"address": "@medieval-kit/pitch-torch",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.191Z",
|
"installedAt": "2026-08-23T05:59:27.349Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\pitch-torch\\model.ts",
|
"path": "src\\models\\medieval-kit\\pitch-torch\\model.ts",
|
||||||
|
|
@ -362,7 +362,7 @@
|
||||||
"address": "@medieval-kit/wooden-bench",
|
"address": "@medieval-kit/wooden-bench",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.198Z",
|
"installedAt": "2026-08-23T05:59:27.361Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wooden-bench\\model.ts",
|
"path": "src\\models\\medieval-kit\\wooden-bench\\model.ts",
|
||||||
|
|
@ -377,7 +377,7 @@
|
||||||
"address": "@medieval-kit/linen-sack",
|
"address": "@medieval-kit/linen-sack",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.188Z",
|
"installedAt": "2026-08-23T05:59:27.345Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\linen-sack\\model.ts",
|
"path": "src\\models\\medieval-kit\\linen-sack\\model.ts",
|
||||||
|
|
@ -392,7 +392,7 @@
|
||||||
"address": "@medieval-kit/oak-tankard",
|
"address": "@medieval-kit/oak-tankard",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.190Z",
|
"installedAt": "2026-08-23T05:59:27.347Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\oak-tankard\\model.ts",
|
"path": "src\\models\\medieval-kit\\oak-tankard\\model.ts",
|
||||||
|
|
@ -407,7 +407,7 @@
|
||||||
"address": "@medieval-kit/straw-broom",
|
"address": "@medieval-kit/straw-broom",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.192Z",
|
"installedAt": "2026-08-23T05:59:27.353Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\straw-broom\\model.ts",
|
"path": "src\\models\\medieval-kit\\straw-broom\\model.ts",
|
||||||
|
|
@ -422,7 +422,7 @@
|
||||||
"address": "@medieval-kit/bronze-bell",
|
"address": "@medieval-kit/bronze-bell",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.178Z",
|
"installedAt": "2026-08-23T05:59:27.332Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\bronze-bell\\model.ts",
|
"path": "src\\models\\medieval-kit\\bronze-bell\\model.ts",
|
||||||
|
|
@ -437,7 +437,7 @@
|
||||||
"address": "@medieval-kit/iron-lantern",
|
"address": "@medieval-kit/iron-lantern",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.186Z",
|
"installedAt": "2026-08-23T05:59:27.342Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\iron-lantern\\model.ts",
|
"path": "src\\models\\medieval-kit\\iron-lantern\\model.ts",
|
||||||
|
|
@ -452,7 +452,7 @@
|
||||||
"address": "@medieval-kit/tavern-sign",
|
"address": "@medieval-kit/tavern-sign",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.193Z",
|
"installedAt": "2026-08-23T05:59:27.354Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\tavern-sign\\model.ts",
|
"path": "src\\models\\medieval-kit\\tavern-sign\\model.ts",
|
||||||
|
|
@ -467,7 +467,7 @@
|
||||||
"address": "@medieval-kit/coin-pouch",
|
"address": "@medieval-kit/coin-pouch",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.181Z",
|
"installedAt": "2026-08-23T05:59:27.335Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\coin-pouch\\model.ts",
|
"path": "src\\models\\medieval-kit\\coin-pouch\\model.ts",
|
||||||
|
|
@ -482,7 +482,7 @@
|
||||||
"address": "@medieval-kit/glass-phial",
|
"address": "@medieval-kit/glass-phial",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.182Z",
|
"installedAt": "2026-08-23T05:59:27.337Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\glass-phial\\model.ts",
|
"path": "src\\models\\medieval-kit\\glass-phial\\model.ts",
|
||||||
|
|
@ -497,7 +497,7 @@
|
||||||
"address": "@medieval-kit/leather-book",
|
"address": "@medieval-kit/leather-book",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.187Z",
|
"installedAt": "2026-08-23T05:59:27.343Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\leather-book\\model.ts",
|
"path": "src\\models\\medieval-kit\\leather-book\\model.ts",
|
||||||
|
|
@ -512,7 +512,7 @@
|
||||||
"address": "@medieval-kit/wicker-basket",
|
"address": "@medieval-kit/wicker-basket",
|
||||||
"source": "file:my-registry/dist/registry.json",
|
"source": "file:my-registry/dist/registry.json",
|
||||||
"version": "workspace",
|
"version": "workspace",
|
||||||
"installedAt": "2026-08-23T05:09:14.195Z",
|
"installedAt": "2026-08-23T05:59:27.358Z",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"path": "src\\models\\medieval-kit\\wicker-basket\\model.ts",
|
"path": "src\\models\\medieval-kit\\wicker-basket\\model.ts",
|
||||||
|
|
@ -522,6 +522,21 @@
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"three@>=0.185.0"
|
"three@>=0.185.0"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"@medieval-kit/post-mill": {
|
||||||
|
"address": "@medieval-kit/post-mill",
|
||||||
|
"source": "file:my-registry/dist/registry.json",
|
||||||
|
"version": "workspace",
|
||||||
|
"installedAt": "2026-08-23T05:59:27.351Z",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"path": "src\\models\\medieval-kit\\post-mill\\model.ts",
|
||||||
|
"sourceHash": "f7404c896166861bf20d2dd758c65eaf0f1c20c506cfafdc092612172c0110fd"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": [
|
||||||
|
"three@>=0.185.0"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ Configure `models.json` first so the namespace resolves:
|
||||||
|
|
||||||
## Models
|
## Models
|
||||||
|
|
||||||
27 models and one shared lib. Addresses are `@medieval-kit/<id>`. This table is
|
28 models and one shared lib. Addresses are `@medieval-kit/<id>`. This table is
|
||||||
generated from the models themselves with `bun scripts/catalog-table.ts` — a
|
generated from the models themselves with `bun scripts/catalog-table.ts` — a
|
||||||
hand-written list goes stale on the first model you add, and this one already
|
hand-written list goes stale on the first model you add, and this one already
|
||||||
did once.
|
did once.
|
||||||
|
|
@ -60,8 +60,9 @@ did once.
|
||||||
| `wooden-hoe` | Tools | 394 | 3 | 0.23×1.23×0.33 | oak, iron, steel | |
|
| `wooden-hoe` | Tools | 394 | 3 | 0.23×1.23×0.33 | oak, iron, steel | |
|
||||||
| `wooden-shovel` | Tools | 496 | 3 | 0.27×1.20×0.08 | oak, iron | |
|
| `wooden-shovel` | Tools | 496 | 3 | 0.27×1.20×0.08 | oak, iron | |
|
||||||
| `wooden-pitchfork` | Tools | 392 | 3 | 0.27×1.58×0.15 | oak, iron | |
|
| `wooden-pitchfork` | Tools | 392 | 3 | 0.27×1.58×0.15 | oak, iron | |
|
||||||
|
| `post-mill` | Structure | 1516 | 4 | 6.60×7.22×6.98 | oak, iron | |
|
||||||
|
|
||||||
**19 007 triangles** in total. The whole kit in one scene costs less than a
|
**20 523 triangles** in total. The whole kit in one scene costs less than a
|
||||||
single mid-complexity character model.
|
single mid-complexity character model.
|
||||||
|
|
||||||
Every model depends on `@medieval-kit/core`, a shared support item holding the
|
Every model depends on `@medieval-kit/core`, a shared support item holding the
|
||||||
|
|
|
||||||
|
|
@ -450,6 +450,24 @@ export const MODEL_META: Readonly<Record<string, ModelMeta>> = {
|
||||||
materialSlots: ['oak'],
|
materialSlots: ['oak'],
|
||||||
parts: ['rails', 'rungs'],
|
parts: ['rails', 'rungs'],
|
||||||
},
|
},
|
||||||
|
'post-mill': {
|
||||||
|
title: 'Post Mill',
|
||||||
|
description:
|
||||||
|
'Medieval post mill: the whole timber body turns on one massive post, with four lattice sails and the tail ladder it is turned by.',
|
||||||
|
category: 'Structure',
|
||||||
|
tags: ['medieval', 'lowpoly', 'structure', 'procedural', 'landmark'],
|
||||||
|
controls: {
|
||||||
|
height: { type: 'number', label: 'Height to ridge', min: 3.5, max: 9, step: 0.1, unit: 'm' },
|
||||||
|
sailSpan: { type: 'number', label: 'Sail span', min: 4, max: 11, step: 0.1, unit: 'm' },
|
||||||
|
sailBars: { type: 'number', label: 'Bars per sail', min: 3, max: 14, step: 1 },
|
||||||
|
sailWidth: { type: 'number', label: 'Sail width', min: 0.08, max: 0.28, step: 0.005 },
|
||||||
|
ladderRungs: { type: 'number', label: 'Ladder rungs', min: 5, max: 20, step: 1 },
|
||||||
|
spin: { type: 'number', label: 'Sail angle', min: 0, max: 6.28, step: 0.02, unit: 'rad' },
|
||||||
|
seed: { type: 'number', label: 'Variation seed', min: 1, max: 64, step: 1 },
|
||||||
|
},
|
||||||
|
materialSlots: ['oak', 'iron'],
|
||||||
|
parts: ['trestle', 'body', 'sails', 'ladder'],
|
||||||
|
},
|
||||||
'wooden-fence': {
|
'wooden-fence': {
|
||||||
title: 'Wooden Fence',
|
title: 'Wooden Fence',
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
430
my-registry/models/post-mill/model.ts
Normal file
430
my-registry/models/post-mill/model.ts
Normal file
|
|
@ -0,0 +1,430 @@
|
||||||
|
/**
|
||||||
|
* @medieval-kit/post-mill
|
||||||
|
*
|
||||||
|
* A post mill: the medieval windmill, and the largest thing in this kit.
|
||||||
|
*
|
||||||
|
* The name is the whole design. The entire body — millstones, gearing, miller
|
||||||
|
* and all — is balanced on ONE massive vertical post and turns bodily on it, so
|
||||||
|
* that the sails can be pointed into whatever wind there is. The miller does
|
||||||
|
* that by walking the tail ladder round, which is why the ladder is not a way
|
||||||
|
* up but a lever, and why it reaches so far behind the mill.
|
||||||
|
*
|
||||||
|
* That gives the model its four parts and the order they have to be built in:
|
||||||
|
*
|
||||||
|
* - `trestle` — two cross-trees laid on the ground, the post standing on
|
||||||
|
* them, and four quarter-bars bracing post to cross-tree. Nothing is
|
||||||
|
* fastened to the ground: a post mill stands on its own weight, and the
|
||||||
|
* cross-trees are what stop it walking off.
|
||||||
|
* - `body` — the buck, a boarded timber box with a pitched roof, sitting on
|
||||||
|
* the post's crown.
|
||||||
|
* - `sails` — four lattice sails on a windshaft that leaves the front gable
|
||||||
|
* tilted a little upwards. This part has its own origin at the shaft, so
|
||||||
|
* `setTurning` can spin it without moving anything else.
|
||||||
|
* - `ladder` — the tail ladder, from the back of the buck down to the ground
|
||||||
|
* well behind it.
|
||||||
|
*
|
||||||
|
* The sails are the reason the triangle count is where it is. A sail is not a
|
||||||
|
* blade, it is a LATTICE: a whip with a frame beside it and a run of bars
|
||||||
|
* across, which the miller dresses with canvas according to the wind. Drawn as
|
||||||
|
* a solid blade the silhouette is wrong in the one place everybody looks, so
|
||||||
|
* the bars are modelled and the budget is spent there rather than on the
|
||||||
|
* boarding of the buck, which reads perfectly well as vertex colour.
|
||||||
|
*/
|
||||||
|
import { Color, type BufferGeometry } from 'three'
|
||||||
|
|
||||||
|
import {
|
||||||
|
boxGeometry,
|
||||||
|
chamferedBoxGeometry,
|
||||||
|
createKitModel,
|
||||||
|
createTinter,
|
||||||
|
jitter,
|
||||||
|
mergeColoured,
|
||||||
|
taperedBoxGeometry,
|
||||||
|
} from '../core/index.ts'
|
||||||
|
|
||||||
|
export interface PostMillConfig {
|
||||||
|
/** Height to the ridge of the roof (metres). Sails reach past it. */
|
||||||
|
readonly height: number
|
||||||
|
/** Sail span, tip to tip (metres). */
|
||||||
|
readonly sailSpan: number
|
||||||
|
/** Bars across each sail. */
|
||||||
|
readonly sailBars: number
|
||||||
|
/** Width of the lattice beside each whip, as a fraction of the sail's length. */
|
||||||
|
readonly sailWidth: number
|
||||||
|
/** Rungs in the tail ladder. */
|
||||||
|
readonly ladderRungs: number
|
||||||
|
/** Current sail angle (radians). */
|
||||||
|
readonly spin: number
|
||||||
|
readonly seed: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const postMillDefaults: PostMillConfig = {
|
||||||
|
height: 6.2,
|
||||||
|
// The lowest sail tip has to clear the ground. At 7.4 against a 6.2 m mill
|
||||||
|
// it came down to within 0.27 m of it, which reads as a mill about to plough
|
||||||
|
// its own field; the reference leaves roughly a tenth of the height.
|
||||||
|
sailSpan: 6.6,
|
||||||
|
// The lattice is what says "windmill" at any distance, and nine bars over a
|
||||||
|
// 3.3 m sail spaces them like ladder rungs. The reference reads as a fine
|
||||||
|
// grid.
|
||||||
|
sailBars: 13,
|
||||||
|
sailWidth: 0.17,
|
||||||
|
ladderRungs: 13,
|
||||||
|
spin: 0,
|
||||||
|
seed: 43,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PostMillParts = 'trestle' | 'body' | 'sails' | 'ladder'
|
||||||
|
|
||||||
|
export interface PostMillActions {
|
||||||
|
/** Starts or stops the sails. */
|
||||||
|
setTurning(on: boolean): void
|
||||||
|
isTurning(): boolean
|
||||||
|
/** Puts the sails at a given angle and stops them there. */
|
||||||
|
setAngle(radians: number): void
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createModel(overrides: Partial<PostMillConfig> = {}) {
|
||||||
|
let turning = false
|
||||||
|
let angle = 0
|
||||||
|
|
||||||
|
return createKitModel<PostMillConfig, 'oak' | 'iron', PostMillParts, PostMillActions>({
|
||||||
|
id: 'post-mill',
|
||||||
|
defaults: postMillDefaults,
|
||||||
|
slots: ['oak', 'iron'],
|
||||||
|
|
||||||
|
build: ({ config, random }) => {
|
||||||
|
const tint = createTinter(random)
|
||||||
|
const H = config.height
|
||||||
|
const half = H / 2
|
||||||
|
const floor = -half
|
||||||
|
|
||||||
|
// Heights are fractions of the mill's own height, so every slider keeps
|
||||||
|
// the proportions of the reference rather than stretching one piece.
|
||||||
|
const postTop = floor + H * 0.42
|
||||||
|
const bodyHeight = H * 0.30
|
||||||
|
const bodyBottom = postTop
|
||||||
|
const bodyTop = bodyBottom + bodyHeight
|
||||||
|
const bodyWidth = H * 0.29 // across the sails' axis
|
||||||
|
const bodyDepth = H * 0.34 // along it
|
||||||
|
const ridge = bodyTop + H * 0.13
|
||||||
|
|
||||||
|
// --- Trestle -------------------------------------------------------------
|
||||||
|
const timber: BufferGeometry[] = []
|
||||||
|
const postSide = H * 0.075
|
||||||
|
const treeSpan = H * 0.62
|
||||||
|
const treeSide = H * 0.055
|
||||||
|
|
||||||
|
// Two cross-trees, laid one over the other. They are NOT coplanar: the
|
||||||
|
// upper one rides on top of the lower, which is how they actually sit and
|
||||||
|
// which keeps their faces out of each other.
|
||||||
|
for (const [index, along] of ([0, 1] as const).entries()) {
|
||||||
|
const lower = index === 0
|
||||||
|
const size: [number, number] = along === 0
|
||||||
|
? [treeSpan, treeSide]
|
||||||
|
: [treeSide, treeSpan]
|
||||||
|
timber.push(chamferedBoxGeometry(
|
||||||
|
size,
|
||||||
|
[size[0] * 0.97, size[1] * 0.97],
|
||||||
|
treeSide,
|
||||||
|
treeSide * 0.12,
|
||||||
|
[0, floor + (lower ? treeSide * 0.5 : treeSide * 1.4), 0],
|
||||||
|
tint('oak', lower ? -0.1 : -0.05),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
// The post. Slightly tapered, because it is a whole tree and a tree is.
|
||||||
|
const postBase = floor + treeSide * 1.1
|
||||||
|
const postHeight = postTop - postBase
|
||||||
|
timber.push(taperedBoxGeometry(
|
||||||
|
[postSide * 1.15, postSide * 1.15],
|
||||||
|
[postSide * 0.92, postSide * 0.92],
|
||||||
|
postHeight,
|
||||||
|
[0, postBase + postHeight / 2, 0],
|
||||||
|
tint('oak', -0.02),
|
||||||
|
))
|
||||||
|
|
||||||
|
// Four quarter-bars, one to each arm of the cross-trees. Their feet sit
|
||||||
|
// ON the cross-tree and their heads run INTO the post, so both joints are
|
||||||
|
// overlaps rather than faces meeting.
|
||||||
|
const barFoot = treeSpan * 0.36
|
||||||
|
const barHead = postTop - H * 0.075
|
||||||
|
const barRise = barHead - (floor + treeSide * 1.6)
|
||||||
|
const barLength = Math.hypot(barFoot, barRise)
|
||||||
|
for (let i = 0; i < 4; i += 1) {
|
||||||
|
const a = (i / 4) * Math.PI * 2
|
||||||
|
const bar = chamferedBoxGeometry(
|
||||||
|
[H * 0.036, H * 0.05],
|
||||||
|
[H * 0.03, H * 0.042],
|
||||||
|
barLength * 1.04,
|
||||||
|
H * 0.006,
|
||||||
|
[0, 0, 0],
|
||||||
|
tint('oak', -0.07 + jitter(random, 0.03)),
|
||||||
|
)
|
||||||
|
// Built upright, leaned outwards, then swung to its arm. Rotating about
|
||||||
|
// X leans it in the YZ plane; rotating about Y carries that lean round.
|
||||||
|
bar.rotateX(Math.atan2(barFoot, barRise))
|
||||||
|
bar.rotateY(a)
|
||||||
|
bar.translate(
|
||||||
|
Math.sin(a) * barFoot * 0.5,
|
||||||
|
(floor + treeSide * 1.6 + barHead) / 2,
|
||||||
|
Math.cos(a) * barFoot * 0.5,
|
||||||
|
)
|
||||||
|
timber.push(bar)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crown: the beam the whole body turns on, laid across the post's head.
|
||||||
|
timber.push(chamferedBoxGeometry(
|
||||||
|
[bodyWidth * 1.05, H * 0.07],
|
||||||
|
[bodyWidth * 0.98, H * 0.06],
|
||||||
|
H * 0.05,
|
||||||
|
H * 0.006,
|
||||||
|
[0, postTop - H * 0.012, 0],
|
||||||
|
tint('oak', 0.02),
|
||||||
|
))
|
||||||
|
|
||||||
|
// --- Body ----------------------------------------------------------------
|
||||||
|
const shell: BufferGeometry[] = []
|
||||||
|
shell.push(chamferedBoxGeometry(
|
||||||
|
[bodyWidth, bodyDepth],
|
||||||
|
[bodyWidth * 0.99, bodyDepth * 0.99],
|
||||||
|
bodyHeight,
|
||||||
|
H * 0.008,
|
||||||
|
[0, bodyBottom + bodyHeight / 2, 0],
|
||||||
|
tint('oak', 0.04),
|
||||||
|
tint('oak', -0.03),
|
||||||
|
))
|
||||||
|
|
||||||
|
// Roof: two pitched sheets meeting at a ridge. Built as tapered boxes
|
||||||
|
// leaned in rather than as a prism, so the gable ends stay flat and the
|
||||||
|
// eaves can overhang the walls, which is what keeps rain off boarding.
|
||||||
|
const eave = bodyWidth * 0.62
|
||||||
|
const roofRise = ridge - bodyTop
|
||||||
|
const slope = Math.hypot(eave, roofRise)
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
// `slope`, not `slope * 2`. Each pitch covers HALF the roof: the slope
|
||||||
|
// is already the hypotenuse from ridge to eave. Doubled, the two came
|
||||||
|
// out 2.79 m across a building 1.80 m wide, and the roof stopped being
|
||||||
|
// a roof and became the largest thing in the silhouette.
|
||||||
|
const pitch = chamferedBoxGeometry(
|
||||||
|
[slope * 1.03, bodyDepth * 1.08],
|
||||||
|
[slope * 1.03, bodyDepth * 1.08],
|
||||||
|
H * 0.016,
|
||||||
|
H * 0.004,
|
||||||
|
[0, 0, 0],
|
||||||
|
tint('oak', -0.12),
|
||||||
|
)
|
||||||
|
// The pitch starts as a slab lying FLAT -- `chamferedBoxGeometry` takes
|
||||||
|
// an X-Z footprint and a Y height -- so the tilt is the roof's angle
|
||||||
|
// measured from the horizontal, and it is negative on the +X side so
|
||||||
|
// the eave drops rather than rises. Both earlier attempts used the
|
||||||
|
// complement of this angle, which stood the pitches up like the covers
|
||||||
|
// of an open book.
|
||||||
|
pitch.rotateZ(-side * Math.atan2(roofRise, eave))
|
||||||
|
pitch.translate(side * eave * 0.5, bodyTop + roofRise * 0.5, 0)
|
||||||
|
shell.push(pitch)
|
||||||
|
}
|
||||||
|
// Ridge board, capping the join so the two pitches do not meet in a seam.
|
||||||
|
shell.push(chamferedBoxGeometry(
|
||||||
|
[H * 0.03, bodyDepth * 1.1],
|
||||||
|
[H * 0.024, bodyDepth * 1.1],
|
||||||
|
H * 0.022,
|
||||||
|
H * 0.004,
|
||||||
|
[0, ridge - H * 0.008, 0],
|
||||||
|
tint('oak', -0.16),
|
||||||
|
))
|
||||||
|
|
||||||
|
// The tail gallery: the little platform the ladder arrives at.
|
||||||
|
shell.push(chamferedBoxGeometry(
|
||||||
|
[bodyWidth * 0.92, H * 0.05],
|
||||||
|
[bodyWidth * 0.88, H * 0.045],
|
||||||
|
H * 0.018,
|
||||||
|
H * 0.004,
|
||||||
|
[0, bodyBottom + H * 0.02, -bodyDepth * 0.52],
|
||||||
|
tint('oak', -0.06),
|
||||||
|
))
|
||||||
|
|
||||||
|
// --- Sails ---------------------------------------------------------------
|
||||||
|
// The windshaft leaves the front gable pointing +Z and tilted up a little,
|
||||||
|
// which is what stops the sails striking the body as they come round.
|
||||||
|
const shaftTilt = 0.14
|
||||||
|
const hubZ = bodyDepth * 0.54
|
||||||
|
const hubY = bodyBottom + bodyHeight * 0.72
|
||||||
|
const sailLength = config.sailSpan / 2
|
||||||
|
const hubRadius = H * 0.035
|
||||||
|
const barT = H * 0.014
|
||||||
|
const latticeWidth = sailLength * config.sailWidth
|
||||||
|
const bars = Math.max(2, Math.round(config.sailBars))
|
||||||
|
|
||||||
|
const rig: BufferGeometry[] = []
|
||||||
|
// Windshaft: iron-banded oak, poking out of the gable.
|
||||||
|
rig.push(taperedBoxGeometry(
|
||||||
|
[hubRadius * 2.1, hubRadius * 2.1],
|
||||||
|
[hubRadius * 1.5, hubRadius * 1.5],
|
||||||
|
H * 0.10,
|
||||||
|
[0, 0, H * 0.03],
|
||||||
|
tint('oak', -0.04),
|
||||||
|
))
|
||||||
|
|
||||||
|
for (let i = 0; i < 4; i += 1) {
|
||||||
|
const a = (i / 4) * Math.PI * 2
|
||||||
|
const sail: BufferGeometry[] = []
|
||||||
|
const tone = tint('oak', -0.05 + jitter(random, 0.04))
|
||||||
|
|
||||||
|
// Whip: the spar the whole sail hangs on, running out from the hub.
|
||||||
|
sail.push(boxGeometry(
|
||||||
|
[barT * 1.3, sailLength - hubRadius, barT * 1.6],
|
||||||
|
[0, hubRadius + (sailLength - hubRadius) / 2, 0],
|
||||||
|
new Color(tone),
|
||||||
|
))
|
||||||
|
// The outer rail of the frame, parallel to the whip.
|
||||||
|
sail.push(boxGeometry(
|
||||||
|
[barT * 0.9, (sailLength - hubRadius) * 0.9, barT * 1.1],
|
||||||
|
[latticeWidth, hubRadius + (sailLength - hubRadius) * 0.5, 0],
|
||||||
|
new Color(tint('oak', -0.1)),
|
||||||
|
))
|
||||||
|
// And the bars across. These are the sail: a solid blade would read as
|
||||||
|
// a propeller, and the lattice is what says "windmill" at any distance.
|
||||||
|
for (let b = 0; b < bars; b += 1) {
|
||||||
|
const t = (b + 0.6) / bars
|
||||||
|
sail.push(boxGeometry(
|
||||||
|
[latticeWidth * 1.12, barT * 0.7, barT * 0.9],
|
||||||
|
[latticeWidth * 0.5, hubRadius + (sailLength - hubRadius) * t, 0],
|
||||||
|
new Color(tint('oak', -0.02 + jitter(random, 0.05))),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
const merged = mergeColoured(sail)
|
||||||
|
// Cant: each sail is twisted a few degrees about its own length so it
|
||||||
|
// presents a face to the wind. Without it the four read as a flat cross.
|
||||||
|
merged.rotateY(0.18)
|
||||||
|
merged.rotateZ(a)
|
||||||
|
rig.push(merged)
|
||||||
|
}
|
||||||
|
|
||||||
|
const sails = mergeColoured(rig)
|
||||||
|
// The rig is authored around the hub and the part's origin goes there, so
|
||||||
|
// `setTurning` spins it about the shaft instead of about the model.
|
||||||
|
sails.rotateX(-shaftTilt)
|
||||||
|
|
||||||
|
// --- Ladder --------------------------------------------------------------
|
||||||
|
// Long and shallow: it is the lever the mill is turned with, not a stair.
|
||||||
|
const steps: BufferGeometry[] = []
|
||||||
|
// Long and shallow. The tail ladder is the lever the mill is turned by,
|
||||||
|
// so it reaches well behind: at 0.42 of the height it came down at 47
|
||||||
|
// degrees, which is a staircase. The reference lands much further back.
|
||||||
|
const footZ = -bodyDepth * 0.5 - H * 0.62
|
||||||
|
const headZ = -bodyDepth * 0.52
|
||||||
|
const headY = bodyBottom + H * 0.02
|
||||||
|
const run = headZ - footZ
|
||||||
|
const rise = headY - floor
|
||||||
|
const railLength = Math.hypot(run, rise)
|
||||||
|
const lean = Math.atan2(run, rise)
|
||||||
|
const railGap = bodyWidth * 0.34
|
||||||
|
|
||||||
|
// The whole ladder is lifted by one offset, rails and rungs together.
|
||||||
|
//
|
||||||
|
// The foot has to land ON the ground, level with the cross-trees, and two
|
||||||
|
// things push it under. The rail is built 3% long so it can bury its head
|
||||||
|
// in the gallery, and half of that overrun hangs off the bottom; and once
|
||||||
|
// tilted, the lowest CORNER of its end face drops below that face's
|
||||||
|
// centre by half the rail's depth times sin(lean). Left uncorrected the
|
||||||
|
// ladder sat 0.10 m under the trestle, so the mill's floor was its stair
|
||||||
|
// and the whole thing hovered above whatever it was placed on.
|
||||||
|
//
|
||||||
|
// Correcting only the rails is worse than not correcting at all. The
|
||||||
|
// second term displaces them PERPENDICULAR to their own axis by very
|
||||||
|
// nearly a rung's half-depth, so the rungs -- placed on the original
|
||||||
|
// centre line -- came away from the rails entirely. The support audit
|
||||||
|
// caught that at the small end of the height slider as loose rungs
|
||||||
|
// floating beside the ladder.
|
||||||
|
const railDepth = H * 0.038
|
||||||
|
const liftY = railLength * 0.015 * Math.cos(lean) + (railDepth / 2) * Math.sin(lean)
|
||||||
|
const liftZ = -railLength * 0.015 * Math.sin(lean)
|
||||||
|
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
const rail = chamferedBoxGeometry(
|
||||||
|
[H * 0.022, railDepth],
|
||||||
|
[H * 0.018, H * 0.032],
|
||||||
|
railLength * 1.03,
|
||||||
|
H * 0.004,
|
||||||
|
[0, 0, 0],
|
||||||
|
tint('oak', -0.08),
|
||||||
|
)
|
||||||
|
// +lean, not -lean. `run` is positive -- the ladder's head sits at a
|
||||||
|
// LARGER z than its foot -- and rotateX(+t) carries +Y towards +Z, so
|
||||||
|
// the negative sign laid the rails along the opposite diagonal to the
|
||||||
|
// one the rungs are placed on. The two crossed near the middle and
|
||||||
|
// diverged towards the ends, which is exactly what the support audit
|
||||||
|
// reported: the middle rungs held, the outer ones floated. The bounding
|
||||||
|
// box looked right the whole time, because the translation put the
|
||||||
|
// ladder where it belonged and only its internals were wrong.
|
||||||
|
rail.rotateX(lean)
|
||||||
|
rail.translate(
|
||||||
|
side * railGap,
|
||||||
|
(floor + headY) / 2 + liftY,
|
||||||
|
(footZ + headZ) / 2 + liftZ,
|
||||||
|
)
|
||||||
|
steps.push(rail)
|
||||||
|
}
|
||||||
|
|
||||||
|
const rungs = Math.max(2, Math.round(config.ladderRungs))
|
||||||
|
for (let i = 0; i < rungs; i += 1) {
|
||||||
|
const t = (i + 0.5) / rungs
|
||||||
|
// Spanning PAST both rails, so each rung is housed in them rather than
|
||||||
|
// ending at their inner faces.
|
||||||
|
// The rung is DEEPER than the rail it passes through (0.048 against
|
||||||
|
// 0.038), so its faces stand proud on both sides.
|
||||||
|
//
|
||||||
|
// Made thinner than the rail, a rung that "passes through" it has its
|
||||||
|
// whole surface buried inside the rail's hollow interior, touching
|
||||||
|
// nothing: these are surfaces, not solids. At the default height the
|
||||||
|
// voxel grid was coarse enough to bridge the gap and the support check
|
||||||
|
// passed; shrink the mill to the bottom of the height slider and the
|
||||||
|
// finer grid separated three of the five rungs from the ladder. The
|
||||||
|
// check was right both times -- the joint was never real.
|
||||||
|
const rung = boxGeometry(
|
||||||
|
[railGap * 2 + H * 0.03, H * 0.02, H * 0.048],
|
||||||
|
[0, 0, 0],
|
||||||
|
new Color(tint('oak', -0.03 + jitter(random, 0.04))),
|
||||||
|
)
|
||||||
|
rung.rotateX(lean)
|
||||||
|
rung.translate(0, floor + rise * t + liftY, footZ + run * t + liftZ)
|
||||||
|
steps.push(rung)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
trestle: { slot: 'oak' as const, geometry: mergeColoured(timber) },
|
||||||
|
body: { slot: 'oak' as const, geometry: mergeColoured(shell) },
|
||||||
|
sails: {
|
||||||
|
slot: 'oak' as const,
|
||||||
|
geometry: sails,
|
||||||
|
origin: [0, hubY, hubZ] as const,
|
||||||
|
},
|
||||||
|
ladder: { slot: 'oak' as const, geometry: mergeColoured(steps) },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: ({ parts, getConfig }) => {
|
||||||
|
angle = getConfig().spin
|
||||||
|
parts.sails.anchor.rotation.z = angle
|
||||||
|
return {
|
||||||
|
setTurning: (on) => { turning = on },
|
||||||
|
isTurning: () => turning,
|
||||||
|
setAngle: (radians) => {
|
||||||
|
turning = false
|
||||||
|
angle = radians
|
||||||
|
parts.sails.anchor.rotation.z = angle
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
update: (deltaSeconds, { parts }) => {
|
||||||
|
if (!turning) return
|
||||||
|
// A working post mill turns slowly — on the order of ten revolutions a
|
||||||
|
// minute at the sail tips, not the blur people draw.
|
||||||
|
angle += deltaSeconds * 1.05
|
||||||
|
parts.sails.anchor.rotation.z = angle
|
||||||
|
},
|
||||||
|
}, overrides)
|
||||||
|
}
|
||||||
|
|
@ -49,6 +49,7 @@ import { createModel as createBook } from '@/models/medieval-kit/leather-book/mo
|
||||||
import { createModel as createPhial } from '@/models/medieval-kit/glass-phial/model.ts'
|
import { createModel as createPhial } from '@/models/medieval-kit/glass-phial/model.ts'
|
||||||
import { createModel as createPouch } from '@/models/medieval-kit/coin-pouch/model.ts'
|
import { createModel as createPouch } from '@/models/medieval-kit/coin-pouch/model.ts'
|
||||||
import { createModel as createBasket } from '@/models/medieval-kit/wicker-basket/model.ts'
|
import { createModel as createBasket } from '@/models/medieval-kit/wicker-basket/model.ts'
|
||||||
|
import { createModel as createMill } from '@/models/medieval-kit/post-mill/model.ts'
|
||||||
|
|
||||||
const failures: string[] = []
|
const failures: string[] = []
|
||||||
function expect(label: string, condition: boolean): void {
|
function expect(label: string, condition: boolean): void {
|
||||||
|
|
@ -303,6 +304,10 @@ const CASES: readonly Case[] = [
|
||||||
{ id: 'wooden-ladder', make: as(createLadder), patch: { rungCount: 12 },
|
{ id: 'wooden-ladder', make: as(createLadder), patch: { rungCount: 12 },
|
||||||
parts: 2, ownSlot: 'oak', borrowSlot: 'oak', closed: true,
|
parts: 2, ownSlot: 'oak', borrowSlot: 'oak', closed: true,
|
||||||
variants: [{ rungCount: 3 }, { taper: 0 }] , maxSize: [0.6, 2.4, 0.12] },
|
variants: [{ rungCount: 3 }, { taper: 0 }] , maxSize: [0.6, 2.4, 0.12] },
|
||||||
|
{ id: 'post-mill', make: as(createMill), patch: { sailBars: 12, ladderRungs: 17 },
|
||||||
|
parts: 4, ownSlot: 'oak', borrowSlot: 'iron',
|
||||||
|
variants: [{ sailBars: 3 }, { sailWidth: 0.28 }, { height: 3.5 }],
|
||||||
|
maxSize: [8.2, 9.0, 7.4] },
|
||||||
{ id: 'wooden-fence', make: as(createFence), patch: { sections: 5, railCount: 4 },
|
{ id: 'wooden-fence', make: as(createFence), patch: { sections: 5, railCount: 4 },
|
||||||
parts: 2, ownSlot: 'oak', borrowSlot: 'oak', closed: true,
|
parts: 2, ownSlot: 'oak', borrowSlot: 'oak', closed: true,
|
||||||
variants: [{ sections: 1 }, { railCount: 1 }, { railCount: 4 }, { rough: 0 }, { brace: 0 }] , maxSize: [5.3, 1.5, 0.45] },
|
variants: [{ sections: 1 }, { railCount: 1 }, { railCount: 4 }, { rough: 0 }, { brace: 0 }] , maxSize: [5.3, 1.5, 0.45] },
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import { createModel as createBook } from '@/models/medieval-kit/leather-book/mo
|
||||||
import { createModel as createPhial } from '@/models/medieval-kit/glass-phial/model.ts'
|
import { createModel as createPhial } from '@/models/medieval-kit/glass-phial/model.ts'
|
||||||
import { createModel as createPouch } from '@/models/medieval-kit/coin-pouch/model.ts'
|
import { createModel as createPouch } from '@/models/medieval-kit/coin-pouch/model.ts'
|
||||||
import { createModel as createBasket } from '@/models/medieval-kit/wicker-basket/model.ts'
|
import { createModel as createBasket } from '@/models/medieval-kit/wicker-basket/model.ts'
|
||||||
|
import { createModel as createMill } from '@/models/medieval-kit/post-mill/model.ts'
|
||||||
|
|
||||||
export interface ParamSpec {
|
export interface ParamSpec {
|
||||||
readonly key: string
|
readonly key: string
|
||||||
|
|
@ -147,6 +148,7 @@ const FACTORIES: Readonly<Record<string, () => KitModel>> = {
|
||||||
'glass-phial': as(createPhial),
|
'glass-phial': as(createPhial),
|
||||||
'coin-pouch': as(createPouch),
|
'coin-pouch': as(createPouch),
|
||||||
'wicker-basket': as(createBasket),
|
'wicker-basket': as(createBasket),
|
||||||
|
'post-mill': as(createMill),
|
||||||
'wooden-ladder': as(createLadder),
|
'wooden-ladder': as(createLadder),
|
||||||
'wooden-fence': as(createFence),
|
'wooden-fence': as(createFence),
|
||||||
'wooden-hoe': as(createHoe),
|
'wooden-hoe': as(createHoe),
|
||||||
|
|
@ -299,6 +301,9 @@ const MEDIEVAL_ORDER = [
|
||||||
'wicker-basket', 'leather-book', 'glass-phial', 'coin-pouch',
|
'wicker-basket', 'leather-book', 'glass-phial', 'coin-pouch',
|
||||||
'wooden-ladder', 'wooden-fence',
|
'wooden-ladder', 'wooden-fence',
|
||||||
'wooden-hoe', 'wooden-shovel', 'wooden-pitchfork',
|
'wooden-hoe', 'wooden-shovel', 'wooden-pitchfork',
|
||||||
|
// Last, because it is the landmark: a 6 m mill after a row of hand tools is
|
||||||
|
// the order that makes the scale of it land.
|
||||||
|
'post-mill',
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
// Keep the order list and the factory list from drifting apart: if one gets an
|
// Keep the order list and the factory list from drifting apart: if one gets an
|
||||||
|
|
|
||||||
430
src/models/medieval-kit/post-mill/model.ts
Normal file
430
src/models/medieval-kit/post-mill/model.ts
Normal file
|
|
@ -0,0 +1,430 @@
|
||||||
|
/**
|
||||||
|
* @medieval-kit/post-mill
|
||||||
|
*
|
||||||
|
* A post mill: the medieval windmill, and the largest thing in this kit.
|
||||||
|
*
|
||||||
|
* The name is the whole design. The entire body — millstones, gearing, miller
|
||||||
|
* and all — is balanced on ONE massive vertical post and turns bodily on it, so
|
||||||
|
* that the sails can be pointed into whatever wind there is. The miller does
|
||||||
|
* that by walking the tail ladder round, which is why the ladder is not a way
|
||||||
|
* up but a lever, and why it reaches so far behind the mill.
|
||||||
|
*
|
||||||
|
* That gives the model its four parts and the order they have to be built in:
|
||||||
|
*
|
||||||
|
* - `trestle` — two cross-trees laid on the ground, the post standing on
|
||||||
|
* them, and four quarter-bars bracing post to cross-tree. Nothing is
|
||||||
|
* fastened to the ground: a post mill stands on its own weight, and the
|
||||||
|
* cross-trees are what stop it walking off.
|
||||||
|
* - `body` — the buck, a boarded timber box with a pitched roof, sitting on
|
||||||
|
* the post's crown.
|
||||||
|
* - `sails` — four lattice sails on a windshaft that leaves the front gable
|
||||||
|
* tilted a little upwards. This part has its own origin at the shaft, so
|
||||||
|
* `setTurning` can spin it without moving anything else.
|
||||||
|
* - `ladder` — the tail ladder, from the back of the buck down to the ground
|
||||||
|
* well behind it.
|
||||||
|
*
|
||||||
|
* The sails are the reason the triangle count is where it is. A sail is not a
|
||||||
|
* blade, it is a LATTICE: a whip with a frame beside it and a run of bars
|
||||||
|
* across, which the miller dresses with canvas according to the wind. Drawn as
|
||||||
|
* a solid blade the silhouette is wrong in the one place everybody looks, so
|
||||||
|
* the bars are modelled and the budget is spent there rather than on the
|
||||||
|
* boarding of the buck, which reads perfectly well as vertex colour.
|
||||||
|
*/
|
||||||
|
import { Color, type BufferGeometry } from 'three'
|
||||||
|
|
||||||
|
import {
|
||||||
|
boxGeometry,
|
||||||
|
chamferedBoxGeometry,
|
||||||
|
createKitModel,
|
||||||
|
createTinter,
|
||||||
|
jitter,
|
||||||
|
mergeColoured,
|
||||||
|
taperedBoxGeometry,
|
||||||
|
} from '../core/index.ts'
|
||||||
|
|
||||||
|
export interface PostMillConfig {
|
||||||
|
/** Height to the ridge of the roof (metres). Sails reach past it. */
|
||||||
|
readonly height: number
|
||||||
|
/** Sail span, tip to tip (metres). */
|
||||||
|
readonly sailSpan: number
|
||||||
|
/** Bars across each sail. */
|
||||||
|
readonly sailBars: number
|
||||||
|
/** Width of the lattice beside each whip, as a fraction of the sail's length. */
|
||||||
|
readonly sailWidth: number
|
||||||
|
/** Rungs in the tail ladder. */
|
||||||
|
readonly ladderRungs: number
|
||||||
|
/** Current sail angle (radians). */
|
||||||
|
readonly spin: number
|
||||||
|
readonly seed: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const postMillDefaults: PostMillConfig = {
|
||||||
|
height: 6.2,
|
||||||
|
// The lowest sail tip has to clear the ground. At 7.4 against a 6.2 m mill
|
||||||
|
// it came down to within 0.27 m of it, which reads as a mill about to plough
|
||||||
|
// its own field; the reference leaves roughly a tenth of the height.
|
||||||
|
sailSpan: 6.6,
|
||||||
|
// The lattice is what says "windmill" at any distance, and nine bars over a
|
||||||
|
// 3.3 m sail spaces them like ladder rungs. The reference reads as a fine
|
||||||
|
// grid.
|
||||||
|
sailBars: 13,
|
||||||
|
sailWidth: 0.17,
|
||||||
|
ladderRungs: 13,
|
||||||
|
spin: 0,
|
||||||
|
seed: 43,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PostMillParts = 'trestle' | 'body' | 'sails' | 'ladder'
|
||||||
|
|
||||||
|
export interface PostMillActions {
|
||||||
|
/** Starts or stops the sails. */
|
||||||
|
setTurning(on: boolean): void
|
||||||
|
isTurning(): boolean
|
||||||
|
/** Puts the sails at a given angle and stops them there. */
|
||||||
|
setAngle(radians: number): void
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createModel(overrides: Partial<PostMillConfig> = {}) {
|
||||||
|
let turning = false
|
||||||
|
let angle = 0
|
||||||
|
|
||||||
|
return createKitModel<PostMillConfig, 'oak' | 'iron', PostMillParts, PostMillActions>({
|
||||||
|
id: 'post-mill',
|
||||||
|
defaults: postMillDefaults,
|
||||||
|
slots: ['oak', 'iron'],
|
||||||
|
|
||||||
|
build: ({ config, random }) => {
|
||||||
|
const tint = createTinter(random)
|
||||||
|
const H = config.height
|
||||||
|
const half = H / 2
|
||||||
|
const floor = -half
|
||||||
|
|
||||||
|
// Heights are fractions of the mill's own height, so every slider keeps
|
||||||
|
// the proportions of the reference rather than stretching one piece.
|
||||||
|
const postTop = floor + H * 0.42
|
||||||
|
const bodyHeight = H * 0.30
|
||||||
|
const bodyBottom = postTop
|
||||||
|
const bodyTop = bodyBottom + bodyHeight
|
||||||
|
const bodyWidth = H * 0.29 // across the sails' axis
|
||||||
|
const bodyDepth = H * 0.34 // along it
|
||||||
|
const ridge = bodyTop + H * 0.13
|
||||||
|
|
||||||
|
// --- Trestle -------------------------------------------------------------
|
||||||
|
const timber: BufferGeometry[] = []
|
||||||
|
const postSide = H * 0.075
|
||||||
|
const treeSpan = H * 0.62
|
||||||
|
const treeSide = H * 0.055
|
||||||
|
|
||||||
|
// Two cross-trees, laid one over the other. They are NOT coplanar: the
|
||||||
|
// upper one rides on top of the lower, which is how they actually sit and
|
||||||
|
// which keeps their faces out of each other.
|
||||||
|
for (const [index, along] of ([0, 1] as const).entries()) {
|
||||||
|
const lower = index === 0
|
||||||
|
const size: [number, number] = along === 0
|
||||||
|
? [treeSpan, treeSide]
|
||||||
|
: [treeSide, treeSpan]
|
||||||
|
timber.push(chamferedBoxGeometry(
|
||||||
|
size,
|
||||||
|
[size[0] * 0.97, size[1] * 0.97],
|
||||||
|
treeSide,
|
||||||
|
treeSide * 0.12,
|
||||||
|
[0, floor + (lower ? treeSide * 0.5 : treeSide * 1.4), 0],
|
||||||
|
tint('oak', lower ? -0.1 : -0.05),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
// The post. Slightly tapered, because it is a whole tree and a tree is.
|
||||||
|
const postBase = floor + treeSide * 1.1
|
||||||
|
const postHeight = postTop - postBase
|
||||||
|
timber.push(taperedBoxGeometry(
|
||||||
|
[postSide * 1.15, postSide * 1.15],
|
||||||
|
[postSide * 0.92, postSide * 0.92],
|
||||||
|
postHeight,
|
||||||
|
[0, postBase + postHeight / 2, 0],
|
||||||
|
tint('oak', -0.02),
|
||||||
|
))
|
||||||
|
|
||||||
|
// Four quarter-bars, one to each arm of the cross-trees. Their feet sit
|
||||||
|
// ON the cross-tree and their heads run INTO the post, so both joints are
|
||||||
|
// overlaps rather than faces meeting.
|
||||||
|
const barFoot = treeSpan * 0.36
|
||||||
|
const barHead = postTop - H * 0.075
|
||||||
|
const barRise = barHead - (floor + treeSide * 1.6)
|
||||||
|
const barLength = Math.hypot(barFoot, barRise)
|
||||||
|
for (let i = 0; i < 4; i += 1) {
|
||||||
|
const a = (i / 4) * Math.PI * 2
|
||||||
|
const bar = chamferedBoxGeometry(
|
||||||
|
[H * 0.036, H * 0.05],
|
||||||
|
[H * 0.03, H * 0.042],
|
||||||
|
barLength * 1.04,
|
||||||
|
H * 0.006,
|
||||||
|
[0, 0, 0],
|
||||||
|
tint('oak', -0.07 + jitter(random, 0.03)),
|
||||||
|
)
|
||||||
|
// Built upright, leaned outwards, then swung to its arm. Rotating about
|
||||||
|
// X leans it in the YZ plane; rotating about Y carries that lean round.
|
||||||
|
bar.rotateX(Math.atan2(barFoot, barRise))
|
||||||
|
bar.rotateY(a)
|
||||||
|
bar.translate(
|
||||||
|
Math.sin(a) * barFoot * 0.5,
|
||||||
|
(floor + treeSide * 1.6 + barHead) / 2,
|
||||||
|
Math.cos(a) * barFoot * 0.5,
|
||||||
|
)
|
||||||
|
timber.push(bar)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crown: the beam the whole body turns on, laid across the post's head.
|
||||||
|
timber.push(chamferedBoxGeometry(
|
||||||
|
[bodyWidth * 1.05, H * 0.07],
|
||||||
|
[bodyWidth * 0.98, H * 0.06],
|
||||||
|
H * 0.05,
|
||||||
|
H * 0.006,
|
||||||
|
[0, postTop - H * 0.012, 0],
|
||||||
|
tint('oak', 0.02),
|
||||||
|
))
|
||||||
|
|
||||||
|
// --- Body ----------------------------------------------------------------
|
||||||
|
const shell: BufferGeometry[] = []
|
||||||
|
shell.push(chamferedBoxGeometry(
|
||||||
|
[bodyWidth, bodyDepth],
|
||||||
|
[bodyWidth * 0.99, bodyDepth * 0.99],
|
||||||
|
bodyHeight,
|
||||||
|
H * 0.008,
|
||||||
|
[0, bodyBottom + bodyHeight / 2, 0],
|
||||||
|
tint('oak', 0.04),
|
||||||
|
tint('oak', -0.03),
|
||||||
|
))
|
||||||
|
|
||||||
|
// Roof: two pitched sheets meeting at a ridge. Built as tapered boxes
|
||||||
|
// leaned in rather than as a prism, so the gable ends stay flat and the
|
||||||
|
// eaves can overhang the walls, which is what keeps rain off boarding.
|
||||||
|
const eave = bodyWidth * 0.62
|
||||||
|
const roofRise = ridge - bodyTop
|
||||||
|
const slope = Math.hypot(eave, roofRise)
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
// `slope`, not `slope * 2`. Each pitch covers HALF the roof: the slope
|
||||||
|
// is already the hypotenuse from ridge to eave. Doubled, the two came
|
||||||
|
// out 2.79 m across a building 1.80 m wide, and the roof stopped being
|
||||||
|
// a roof and became the largest thing in the silhouette.
|
||||||
|
const pitch = chamferedBoxGeometry(
|
||||||
|
[slope * 1.03, bodyDepth * 1.08],
|
||||||
|
[slope * 1.03, bodyDepth * 1.08],
|
||||||
|
H * 0.016,
|
||||||
|
H * 0.004,
|
||||||
|
[0, 0, 0],
|
||||||
|
tint('oak', -0.12),
|
||||||
|
)
|
||||||
|
// The pitch starts as a slab lying FLAT -- `chamferedBoxGeometry` takes
|
||||||
|
// an X-Z footprint and a Y height -- so the tilt is the roof's angle
|
||||||
|
// measured from the horizontal, and it is negative on the +X side so
|
||||||
|
// the eave drops rather than rises. Both earlier attempts used the
|
||||||
|
// complement of this angle, which stood the pitches up like the covers
|
||||||
|
// of an open book.
|
||||||
|
pitch.rotateZ(-side * Math.atan2(roofRise, eave))
|
||||||
|
pitch.translate(side * eave * 0.5, bodyTop + roofRise * 0.5, 0)
|
||||||
|
shell.push(pitch)
|
||||||
|
}
|
||||||
|
// Ridge board, capping the join so the two pitches do not meet in a seam.
|
||||||
|
shell.push(chamferedBoxGeometry(
|
||||||
|
[H * 0.03, bodyDepth * 1.1],
|
||||||
|
[H * 0.024, bodyDepth * 1.1],
|
||||||
|
H * 0.022,
|
||||||
|
H * 0.004,
|
||||||
|
[0, ridge - H * 0.008, 0],
|
||||||
|
tint('oak', -0.16),
|
||||||
|
))
|
||||||
|
|
||||||
|
// The tail gallery: the little platform the ladder arrives at.
|
||||||
|
shell.push(chamferedBoxGeometry(
|
||||||
|
[bodyWidth * 0.92, H * 0.05],
|
||||||
|
[bodyWidth * 0.88, H * 0.045],
|
||||||
|
H * 0.018,
|
||||||
|
H * 0.004,
|
||||||
|
[0, bodyBottom + H * 0.02, -bodyDepth * 0.52],
|
||||||
|
tint('oak', -0.06),
|
||||||
|
))
|
||||||
|
|
||||||
|
// --- Sails ---------------------------------------------------------------
|
||||||
|
// The windshaft leaves the front gable pointing +Z and tilted up a little,
|
||||||
|
// which is what stops the sails striking the body as they come round.
|
||||||
|
const shaftTilt = 0.14
|
||||||
|
const hubZ = bodyDepth * 0.54
|
||||||
|
const hubY = bodyBottom + bodyHeight * 0.72
|
||||||
|
const sailLength = config.sailSpan / 2
|
||||||
|
const hubRadius = H * 0.035
|
||||||
|
const barT = H * 0.014
|
||||||
|
const latticeWidth = sailLength * config.sailWidth
|
||||||
|
const bars = Math.max(2, Math.round(config.sailBars))
|
||||||
|
|
||||||
|
const rig: BufferGeometry[] = []
|
||||||
|
// Windshaft: iron-banded oak, poking out of the gable.
|
||||||
|
rig.push(taperedBoxGeometry(
|
||||||
|
[hubRadius * 2.1, hubRadius * 2.1],
|
||||||
|
[hubRadius * 1.5, hubRadius * 1.5],
|
||||||
|
H * 0.10,
|
||||||
|
[0, 0, H * 0.03],
|
||||||
|
tint('oak', -0.04),
|
||||||
|
))
|
||||||
|
|
||||||
|
for (let i = 0; i < 4; i += 1) {
|
||||||
|
const a = (i / 4) * Math.PI * 2
|
||||||
|
const sail: BufferGeometry[] = []
|
||||||
|
const tone = tint('oak', -0.05 + jitter(random, 0.04))
|
||||||
|
|
||||||
|
// Whip: the spar the whole sail hangs on, running out from the hub.
|
||||||
|
sail.push(boxGeometry(
|
||||||
|
[barT * 1.3, sailLength - hubRadius, barT * 1.6],
|
||||||
|
[0, hubRadius + (sailLength - hubRadius) / 2, 0],
|
||||||
|
new Color(tone),
|
||||||
|
))
|
||||||
|
// The outer rail of the frame, parallel to the whip.
|
||||||
|
sail.push(boxGeometry(
|
||||||
|
[barT * 0.9, (sailLength - hubRadius) * 0.9, barT * 1.1],
|
||||||
|
[latticeWidth, hubRadius + (sailLength - hubRadius) * 0.5, 0],
|
||||||
|
new Color(tint('oak', -0.1)),
|
||||||
|
))
|
||||||
|
// And the bars across. These are the sail: a solid blade would read as
|
||||||
|
// a propeller, and the lattice is what says "windmill" at any distance.
|
||||||
|
for (let b = 0; b < bars; b += 1) {
|
||||||
|
const t = (b + 0.6) / bars
|
||||||
|
sail.push(boxGeometry(
|
||||||
|
[latticeWidth * 1.12, barT * 0.7, barT * 0.9],
|
||||||
|
[latticeWidth * 0.5, hubRadius + (sailLength - hubRadius) * t, 0],
|
||||||
|
new Color(tint('oak', -0.02 + jitter(random, 0.05))),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
const merged = mergeColoured(sail)
|
||||||
|
// Cant: each sail is twisted a few degrees about its own length so it
|
||||||
|
// presents a face to the wind. Without it the four read as a flat cross.
|
||||||
|
merged.rotateY(0.18)
|
||||||
|
merged.rotateZ(a)
|
||||||
|
rig.push(merged)
|
||||||
|
}
|
||||||
|
|
||||||
|
const sails = mergeColoured(rig)
|
||||||
|
// The rig is authored around the hub and the part's origin goes there, so
|
||||||
|
// `setTurning` spins it about the shaft instead of about the model.
|
||||||
|
sails.rotateX(-shaftTilt)
|
||||||
|
|
||||||
|
// --- Ladder --------------------------------------------------------------
|
||||||
|
// Long and shallow: it is the lever the mill is turned with, not a stair.
|
||||||
|
const steps: BufferGeometry[] = []
|
||||||
|
// Long and shallow. The tail ladder is the lever the mill is turned by,
|
||||||
|
// so it reaches well behind: at 0.42 of the height it came down at 47
|
||||||
|
// degrees, which is a staircase. The reference lands much further back.
|
||||||
|
const footZ = -bodyDepth * 0.5 - H * 0.62
|
||||||
|
const headZ = -bodyDepth * 0.52
|
||||||
|
const headY = bodyBottom + H * 0.02
|
||||||
|
const run = headZ - footZ
|
||||||
|
const rise = headY - floor
|
||||||
|
const railLength = Math.hypot(run, rise)
|
||||||
|
const lean = Math.atan2(run, rise)
|
||||||
|
const railGap = bodyWidth * 0.34
|
||||||
|
|
||||||
|
// The whole ladder is lifted by one offset, rails and rungs together.
|
||||||
|
//
|
||||||
|
// The foot has to land ON the ground, level with the cross-trees, and two
|
||||||
|
// things push it under. The rail is built 3% long so it can bury its head
|
||||||
|
// in the gallery, and half of that overrun hangs off the bottom; and once
|
||||||
|
// tilted, the lowest CORNER of its end face drops below that face's
|
||||||
|
// centre by half the rail's depth times sin(lean). Left uncorrected the
|
||||||
|
// ladder sat 0.10 m under the trestle, so the mill's floor was its stair
|
||||||
|
// and the whole thing hovered above whatever it was placed on.
|
||||||
|
//
|
||||||
|
// Correcting only the rails is worse than not correcting at all. The
|
||||||
|
// second term displaces them PERPENDICULAR to their own axis by very
|
||||||
|
// nearly a rung's half-depth, so the rungs -- placed on the original
|
||||||
|
// centre line -- came away from the rails entirely. The support audit
|
||||||
|
// caught that at the small end of the height slider as loose rungs
|
||||||
|
// floating beside the ladder.
|
||||||
|
const railDepth = H * 0.038
|
||||||
|
const liftY = railLength * 0.015 * Math.cos(lean) + (railDepth / 2) * Math.sin(lean)
|
||||||
|
const liftZ = -railLength * 0.015 * Math.sin(lean)
|
||||||
|
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
const rail = chamferedBoxGeometry(
|
||||||
|
[H * 0.022, railDepth],
|
||||||
|
[H * 0.018, H * 0.032],
|
||||||
|
railLength * 1.03,
|
||||||
|
H * 0.004,
|
||||||
|
[0, 0, 0],
|
||||||
|
tint('oak', -0.08),
|
||||||
|
)
|
||||||
|
// +lean, not -lean. `run` is positive -- the ladder's head sits at a
|
||||||
|
// LARGER z than its foot -- and rotateX(+t) carries +Y towards +Z, so
|
||||||
|
// the negative sign laid the rails along the opposite diagonal to the
|
||||||
|
// one the rungs are placed on. The two crossed near the middle and
|
||||||
|
// diverged towards the ends, which is exactly what the support audit
|
||||||
|
// reported: the middle rungs held, the outer ones floated. The bounding
|
||||||
|
// box looked right the whole time, because the translation put the
|
||||||
|
// ladder where it belonged and only its internals were wrong.
|
||||||
|
rail.rotateX(lean)
|
||||||
|
rail.translate(
|
||||||
|
side * railGap,
|
||||||
|
(floor + headY) / 2 + liftY,
|
||||||
|
(footZ + headZ) / 2 + liftZ,
|
||||||
|
)
|
||||||
|
steps.push(rail)
|
||||||
|
}
|
||||||
|
|
||||||
|
const rungs = Math.max(2, Math.round(config.ladderRungs))
|
||||||
|
for (let i = 0; i < rungs; i += 1) {
|
||||||
|
const t = (i + 0.5) / rungs
|
||||||
|
// Spanning PAST both rails, so each rung is housed in them rather than
|
||||||
|
// ending at their inner faces.
|
||||||
|
// The rung is DEEPER than the rail it passes through (0.048 against
|
||||||
|
// 0.038), so its faces stand proud on both sides.
|
||||||
|
//
|
||||||
|
// Made thinner than the rail, a rung that "passes through" it has its
|
||||||
|
// whole surface buried inside the rail's hollow interior, touching
|
||||||
|
// nothing: these are surfaces, not solids. At the default height the
|
||||||
|
// voxel grid was coarse enough to bridge the gap and the support check
|
||||||
|
// passed; shrink the mill to the bottom of the height slider and the
|
||||||
|
// finer grid separated three of the five rungs from the ladder. The
|
||||||
|
// check was right both times -- the joint was never real.
|
||||||
|
const rung = boxGeometry(
|
||||||
|
[railGap * 2 + H * 0.03, H * 0.02, H * 0.048],
|
||||||
|
[0, 0, 0],
|
||||||
|
new Color(tint('oak', -0.03 + jitter(random, 0.04))),
|
||||||
|
)
|
||||||
|
rung.rotateX(lean)
|
||||||
|
rung.translate(0, floor + rise * t + liftY, footZ + run * t + liftZ)
|
||||||
|
steps.push(rung)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
trestle: { slot: 'oak' as const, geometry: mergeColoured(timber) },
|
||||||
|
body: { slot: 'oak' as const, geometry: mergeColoured(shell) },
|
||||||
|
sails: {
|
||||||
|
slot: 'oak' as const,
|
||||||
|
geometry: sails,
|
||||||
|
origin: [0, hubY, hubZ] as const,
|
||||||
|
},
|
||||||
|
ladder: { slot: 'oak' as const, geometry: mergeColoured(steps) },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: ({ parts, getConfig }) => {
|
||||||
|
angle = getConfig().spin
|
||||||
|
parts.sails.anchor.rotation.z = angle
|
||||||
|
return {
|
||||||
|
setTurning: (on) => { turning = on },
|
||||||
|
isTurning: () => turning,
|
||||||
|
setAngle: (radians) => {
|
||||||
|
turning = false
|
||||||
|
angle = radians
|
||||||
|
parts.sails.anchor.rotation.z = angle
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
update: (deltaSeconds, { parts }) => {
|
||||||
|
if (!turning) return
|
||||||
|
// A working post mill turns slowly — on the order of ten revolutions a
|
||||||
|
// minute at the sail tips, not the blur people draw.
|
||||||
|
angle += deltaSeconds * 1.05
|
||||||
|
parts.sails.anchor.rotation.z = angle
|
||||||
|
},
|
||||||
|
}, overrides)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue