medieval-kit/my-registry/README.md
CRT 5db9a1bb19 Add the oak
The first thing in this kit that grew rather than got made, and the first one
built entirely against reference photographs from the start rather than after
three rounds of guessing.

Two references, generated with the same Codex tool the rest of the kit now
uses: one oak in full leaf and the same tree bare. Both of them contradicted
what I was about to build, and the default lowpoly tree -- a tall pole with a
ball on it -- turns out to be wrong in every measurement that matters.

  crown width / tree height     1.32 to 1.43.  An open-grown oak is half again
                                as WIDE as it is tall. Nothing else in this kit
                                is wider than it is tall.
  widest at                     24% of the height. Not halfway up: a quarter,
                                just above the ground, because the lowest limbs
                                are the longest and leave almost horizontally.
  bole runs to                  72% of the height as one continuous stem. It
                                does not fork low into equal leaders, which is
                                what the leafy photograph alone suggested and
                                the winter one disproved.
  bole width / height           0.130 at 2% of the height, 0.073 at 10%. It
                                nearly halves in the bottom tenth and then
                                barely tapers at all for a quarter of the tree.

The taper table in the model is those rows, read off the photograph one at a
time. The limbs SWEEP -- out at a shallow angle, turning up at the end -- which
comes free from bending each limb along its own axis before rotating it into
place, and which cost a correction I had not expected: bending a limb swings
its whole chord up by half the arc, so every limb was arriving 0.21 rad high
and the crown's widest point had climbed to 38%. Aiming low by exactly what the
bend will lift is the fix, and it is a constant.

Measuring is the whole story of this one. `scripts/probe-tree.ts` prints the
four reference numbers off the built geometry the same way they came off the
photographs, plus one a photograph cannot give: how many separate pieces the
crown is in. A crown is one piece. This one was four, then one, then two, then
one again, and the flood fill was right every time my eye was vague.

Four things it caught that looking would not have:

  - Forks throwing DOWNWARD. The rise of a fork is sin(splay) * sin(spin), so
    the sign of the PRODUCT decides it. I constrained the spin and alternated
    the splay, which left every second fork pointing at the floor. The
    measurement said so plainly while the reasoning said the opposite.
  - The crown torn in two, and not where I kept looking. Locating the loose
    piece -- height 10-64%, bearing 228-313, reaching 5.7 m where the main mass
    stopped at 4.5 -- ended four rounds of widening clumps and evening out
    bearings, none of which were the gap. The gap was the MIDDLE: pushing the
    leaves outboard to open the space under the crown had taken the inside out
    with it, and nine lobes hung off a bare hub. The reference's crown is full
    from the bole outward; the clear space is underneath.
  - Occlusion, exonerated. Turning it off entirely changed the clipping by
    nothing at all, which took two minutes and saved a redesign.
  - My own metric, wrong twice. It counted every dark pixel in the crown's box
    and 87% of what it found was the cast shadow, so it read 10.8% clipping on
    a crown that was barely clipping. And it measured the reference by row
    width but our own geometry by twice its radius, which is a different
    quantity on anything that is not symmetric.

Colour is measured too, and the measurement contradicted me again: I was about
to bake a top-to-bottom gradient into the crown, and sampled in three bands the
reference reads 0.362, 0.336, 0.324 -- no gradient at all. What is there is
local, a spread of 0.45 in lightness within one band. Foliage varies leaf to
leaf, not top to bottom. Chasing that 0.45 with tint, mottle and occlusion all
at once put 2.2% of the crown through the floor into pure black against the
reference's 0.19%, which is the straw trap for the third time: a statistic taken
off fine detail cannot be added on top of the machinery that already
reproduces it.

The bark is measured off the WINTER photograph after the summer one gave a
colour 28 degrees too green -- a trunk under a full crown is lit through the
leaves. Low saturation made it worse than the hue did: a nearly neutral colour
takes its hue from its light, and this renderer's blue-grey sky dragged the
rendered bole to hue 119 on a tree whose bark is brown.

Finished: hue 79.6 against 77.9, saturation 0.386 against 0.381, lightness
0.386 against 0.373, 0.00% clipped. Crown 1.325 wide for its height, in one
piece, hanging from 8% where the reference hangs from 11%.

The honest limits. What fills a real winter silhouette is thousands of twigs
and no budget here reaches them, so `leafiness: 0` is a bare tree of LIMBS --
a good dead or winter tree, not a photograph of one. And the crown still
carries more of its width high than the reference does: widest at 50% against
24%, on a reference profile that is nearly flat from 24 to 44 so the peak is
softer than the number sounds.

2310 triangles, inside the kit's 2500 budget, which cost a side off every clump
and a level off every fork -- but not one clump, because the count is what
holds the crown together. 35 models, 31 404 triangles, thirteen material slots,
all checks pass, 0 floating cases, GLB round-trip clean, Conformant.
2026-08-23 12:47:21 +00:00

8.4 KiB

Medieval Kit

A lowpoly medieval model library for Vibe3D and Three.js. Install a prop and you own its source: readable TypeScript in your own tree, not an opaque package boundary.

The whole kit

bunx vibe3d add @medieval-kit/wooden-barrel
bunx vibe3d add @medieval-kit

Configure models.json first so the namespace resolves:

{
  "registries": {
    "@medieval-kit": {
      "source": "npm:@medieval-kit/registry",
      "version": "latest"
    }
  }
}

Models

35 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 hand-written list goes stale on the first model you add, and this one already did once.

Model Category Triangles Parts Size (m) Material slots Animated
wooden-chest Furniture 552 4 0.86×0.51×0.48 oak, iron ✔
wooden-barrel Props 1690 3 0.83×1.05×0.83 oak, iron
wooden-crate Props 1320 3 0.69×0.52×0.55 oak, iron
wooden-bucket Props 439 4 0.31×0.46×0.30 oak, iron
trestle-table Furniture 660 3 1.91×0.74×0.78 oak
wooden-bench Furniture 216 3 1.62×0.45×0.30 oak
wooden-stool Furniture 180 2 0.38×0.43×0.36 oak
pitch-torch Lighting 239 3 0.13×0.70×0.13 oak, char, ember ✔
iron-lantern Lighting 480 4 0.15×0.30×0.17 iron, glass, char, ember ✔
iron-anvil Smithy 256 6 0.54×0.75×0.41 iron, steel, oak
cart-wheel Structure 1136 4 1.04×1.06×0.19 oak, iron
log-pile Props 924 2 0.99×0.58×0.70 oak
hay-bale Props 910 3 1.04×0.42×0.43 straw, cloth
linen-sack Props 342 3 0.34×0.53×0.33 cloth
oak-tankard Props 390 4 0.11×0.16×0.14 oak, iron
straw-broom Tools 1048 3 0.30×1.22×0.30 oak, straw, cloth
bronze-bell Props 1048 4 0.51×0.68×0.36 brass, iron, oak ✔
tavern-sign Props 876 3 0.38×2.29×0.93 oak, iron ✔
wicker-basket Props 2326 3 0.34×0.16×0.35 oak, produce
leather-book Props 440 3 0.20×0.08×0.27 leather, cloth, brass
glass-phial Props 339 3 0.06×0.14×0.06 glass, ember, oak, char
coin-pouch Props 602 3 0.18×0.11×0.16 leather, cloth, brass
wooden-ladder Structure 440 2 0.49×2.20×0.06 oak
wooden-fence Structure 860 2 5.18×1.31×0.31 oak
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-pitchfork Tools 392 3 0.27×1.58×0.15 oak, iron
iron-cauldron Lighting 1134 3 1.09×1.37×1.10 stone, iron, char, ember
hand-cart Structure 2044 4 0.88×1.03×2.60 oak, iron
vegetables Props 1718 2 0.60×0.12×0.59 produce
round-shield Arms 729 3 0.73×0.73×0.17 oak, leather, iron
forge-hearth Smithy 1426 4 2.06×1.78×0.87 stone, char, ember, oak, leather, iron
stone-well Structure 1376 4 1.88×2.00×1.28 stone, oak, iron, cloth
post-mill Structure 1672 4 6.60×7.23×6.98 oak, iron
oak-tree Nature 2310 3 8.57×6.96×9.05 oak, leaf

31 404 triangles in total. The whole kit in one scene costs less than a single mid-complexity character model.

Every model depends on @medieval-kit/core, a shared support item holding the palette, deterministic randomness, and the geometry vocabulary. Pulling a single prop brings it along, so an individually installed crate still looks like it came from the same catalogue as the barrel beside it.

Plain WebGL

This kit does not require WebGPU. It declares capabilities: [] and builds on MeshStandardMaterial and MeshBasicMaterial, so it renders on WebGLRenderer as well as WebGPURenderer.

Configuration

Models are procedural, not baked. Every prop exposes typed fields:

import { createModel } from '@/models/medieval-kit/wooden-barrel/model.ts'

const barrel = createModel({ staveCount: 17, taper: 0.22, seed: 42 })
scene.add(barrel.root)

barrel.configure({ hoopCount: 6 })   // rebuilds geometry inside a stable root
barrel.dispose()

seed is a real field, not a debug knob. Variation is deterministic: the same seed always produces the same prop, so previews, tests, and art direction stay reproducible. Change the seed to get a different barrel from the same model.

Runtime anatomy

Each model follows the Vibe3D protocol:

  • root keeps its object identity for the model's whole lifetime.
  • parts expose stable semantic anchors. Attach your own lights, labels, or gameplay objects to part.anchor — they survive configure(), because only part.content is rebuilt.
  • materials resolve per slot and can be overridden. Materials you supply are borrowed: the model never disposes them.
  • actions and update(delta) carry interactive state. Five models use both — wooden-chest, pitch-torch, iron-lantern, bronze-bell and tavern-sign:
const chest = createModel()
chest.actions.setOpen(true)
chest.update(deltaSeconds)   // the lid eases open, frame-rate independent

const torch = createModel()
torch.actions.setLit(false)
torch.update(deltaSeconds)   // flame flicker and light modulation

A model that never receives update() simply stands still; nothing animates behind your back. Reach for configure() when a user changes a setting; it rebuilds topology and is not cheap. Anything that changes per frame belongs in update().

Material slots

Thirteen slots, and each one exists because a single material could not carry the difference.

Slot What it covers Why it is separate
oak timber —
iron forged iron, oxidised and matte separate from steel: the difference is not in colour but in ROUGHNESS, and vertex colour cannot carry roughness
steel steel polished by use the anvil face, the shovel blade, the pitchfork tines
brass bronze and copper the bell, the coins
straw straw, wicker, broom bristle a bale declaring itself "oak" would be a lie told to the consumer
cloth linen, sackcloth, rope —
leather worked leather —
glass blown glass transparent, depthWrite OFF, DoubleSide
produce fruit and vegetable skin given straw's roughness, an apple would look like dry grass
ember flame MeshBasicMaterial — it does not receive light, it emits
char charcoal and pitch —
leaf living foliage the most matte thing here after stone: any sheen at all and a crown reads as plastic shrubbery, which is the usual failure of a lowpoly tree and is a material setting rather than a modelling one
stone dressed and rubble masonry its colour is close to weathered oak; what separates them at a glance is that stone scatters light completely flat, and roughness is not something vertex colour can carry

ember also acts as a rule in two places: bodies in that slot are skipped entirely while ambient occlusion and mottle are baked. The reason is simple — in an unlit material the vertex colour is the final colour, so darkening it puts the flame out. The rule is attached to the slot itself rather than to a per-model flag, so it cannot be forgotten.

Colour variation lives in the geometry, not in the materials: each of the barrel's 17 staves carries its own tone as vertex colours, and all of them share one material and therefore one draw call.

Building from source

bun build.ts                                  # emit dist/registry.json
bunx vibe3d registry validate dist/registry.json

The build walks models/. A folder containing model.ts becomes a vibe3d:model; any other folder becomes a vibe3d:lib. Registry dependencies are derived from the source — an import from ../core/ makes @medieval-kit/core a dependency automatically, so there is no hand-maintained list to go stale.

drafts/ is deliberately outside that walk: the code is kept in the tree but never reaches the published package. See drafts/README.md.

Released under the MIT License.