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.
|
||
|---|---|---|
| media | ||
| my-registry | ||
| scripts | ||
| src | ||
| .gitattributes | ||
| .gitignore | ||
| bun.lock | ||
| index.html | ||
| LICENSE | ||
| models.json | ||
| models.lock.json | ||
| package.json | ||
| README.md | ||
| REFERENCE.md | ||
| tsconfig.json | ||
| viewer.html | ||
| vite.config.ts | ||
| vite.viewer.config.ts | ||
medieval-kit
A lowpoly medieval model library for Vibe3D, plus the viewer used to build it.
Vibe3D is a source-first model registry for Three.js: you install the TypeScript that generates a model into your own project rather than depending on an opaque package. This repository holds one such registry.
my-registry/— the@medieval-kitregistry, published to npm as@medieval-kit/registry.src/— a demo app that installs from both@medieval-kitand the first-party@scifi-kit, so the two can be inspected side by side.
Run the viewer
Requires Bun and a browser with WebGPU (the @scifi-kit model
in the demo uses TSL node materials; the medieval kit itself does not).
bun install
bun run registry:build
bun run dev
Open /viewer.html for the model inspector: registry-grouped catalogue, live
triangle counts, configuration sliders wired to configure(), a wireframe
overlay, and per-model GLB download.
Use the kit in your own project
bunx vibe3d init
bunx vibe3d add @medieval-kit/wooden-barrel
See my-registry/README.md for the model list,
configuration fields, and runtime contract.
Export to GLB
bun run export:glb # every model into glb/
bun scripts/export-glb.ts --one wooden-chest
The viewer's download button and this command share one implementation
(src/glb.ts), so they produce byte-identical files. Colour travels as
COLOR_0 vertex data and baseColorFactor stays white — the files carry no
textures at all.
Verify
bun run typecheck
bun run verify # geometry, protocol, metadata, actions
bun run verify:glb # export every model, read it back, compare
bun run render # renders/_sheet.png — actually look at the models
verify runs ~800 browser-free checks against the installed sources: geometry
validity, winding, coplanar-face (z-fighting) detection, bounding-box limits,
stable root and anchor identity across configure(), deterministic seeding,
material ownership, idempotent disposal, action semantics, and agreement
between each model and its published metadata.
Five of those deserve a note, because each was written after a real bug:
- Winding is checked three ways, because no single measure is sufficient.
Bodies of revolution use radial alignment — every radial face on the outer
shell must point away from the axis, measured in height bands. Closed solids
use signed volume:
Σ a·(b×c)/6is positive only when the winding faces outward. And edge balance catches a single flipped face, which signed volume misses — flipping one face took the volume from 0.058 to 0.039, still positive. - Z-fighting is checked by looking for triangles that share a plane, share a normal direction, and overlap in area. Edge contact between neighbouring boards is fine and is not flagged; genuine coplanar overlap is.
- Metadata agreement verifies that every declared control key is a real
config field, that declared part names match the model's actual parts, and —
most importantly — that no mesh uses an undeclared material slot. A missing
declaration is a material the consumer cannot reach through
materials.override(). This check found real drift in four models the day it was added: asteelslot had been used but never declared. - Frame-rate independence for animated models: the same elapsed time is stepped at two different frame rates and the results must agree. A naive lerp fails this.
- Nothing floats. Every check above asks about surfaces, and none of them
can see a piece of a model hanging in the air with nothing under it — a chest
lid separated from its chest passed all of them.
scripts/support.tsvoxelises the model, finds the connected components of occupied space, and requires each one to reach the floor.scripts/audit.tsruns that across the default, both slider extremes, both ends of a sweep, every action and the midpoint of a morph, because a variation must not break what the default gets right. It began at 22 failing cases: the bell and the sign had no supporting structure at all, the lantern was in four pieces, and the ladder's rungs were sized by a formula that disagreed with where its rails actually were.
Every check was mutation-tested: sabotage the code, confirm the check fails, restore, confirm it passes. A passing test is not evidence that it works.
render closed the one gap all of the above left open. Every check was
geometric — triangle counts, winding, coplanarity, bounds. All of them caught
real bugs, and none of them could say "this shovel does not look like a shovel."
The renderer is a small software rasteriser: no browser, no GPU. The shovel was
rewritten a fourth time, the hoe a third and the hay bale a second because of
what those PNGs showed.
Showcase
The viewer can play itself. A tour orbits the whole catalogue on one continuous camera move, morphing each model's parameters as it goes, with the interface hidden so the frame is clean enough to record.
viewer.html?showcase=60
60 s is the default. The tour splits its running time equally between the models, so with 27 of them a 30 s run gives each 1.1 seconds — which is a flyby, not a demonstration. At 60 s each model gets 2.2 s, which is enough for the sweep to read.
Two things make the variation visible rather than merely present. Continuous controls travel the whole usable band every beat instead of two random draws inside it. And every beat is split in half so that the integer controls — stave count, plank count, spokes, rows, tines — can change at the midpoint, where the same dip that hides a model swap hides the rebuild. Those are the parameters a viewer actually notices, and morphing cannot interpolate them, so before the split they were pinned for the whole beat and the tour looked static.
Layout
my-registry/
models/core/ shared palette, RNG, geometry vocabulary, part slots
models/<model-id>/ one procedural model per folder
meta.ts single source for catalogue metadata
build.ts compiles models/ into dist/registry.json
drafts/ kept in the tree, kept out of the build
src/
lib/vibe3d/ Vibe3D contracts installed by `vibe3d init`
models/ installed model source (owned, editable)
viewer.ts the model inspector
glb.ts GLB export, shared by the viewer and the CLI
catalog.ts viewer catalogue, derived from meta.ts
scripts/
verify-model.ts browser-free conformance checks
verify-glb.ts export/re-import round trip
zfight.ts coplanar overlap detection
support.ts voxel connectivity — nothing may float
audit.ts runs the support check across every configuration
render.ts offline software rasteriser → PNG contact sheet
reference-shots.ts one photographic reference per model, for comparison
export-glb.ts batch GLB export
media/ images used by this README
models.json which registries this project resolves
models.lock.json install receipt; `vibe3d diff` compares against it
src/models/ is generated by vibe3d add but committed on purpose: it is the
demo's own source, and keeping it in the tree is what makes vibe3d diff
meaningful.
Released under the MIT License.
