@bendyline/molen-tooling 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE.md +15 -0
- package/README.md +91 -0
- package/dist/capture/THIRD-PARTY-NOTICES.md +223 -0
- package/dist/capture/basis/LICENSE.txt +55 -0
- package/dist/capture/basis/basis_transcoder.js +19 -0
- package/dist/capture/basis/basis_transcoder.wasm +0 -0
- package/dist/capture/capture.html +15 -0
- package/dist/capture/harness.js +4671 -0
- package/dist/capture/worldgen-preview.html +15 -0
- package/dist/capture/worldgen-preview.js +4617 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +1276 -0
- package/dist/docs-src/guide/3d-art-guidelines.md +157 -0
- package/dist/docs-src/guide/3d-model-assets.md +286 -0
- package/dist/docs-src/guide/adaptive-performance.md +89 -0
- package/dist/docs-src/guide/agent-loop.md +156 -0
- package/dist/docs-src/guide/aircraft.md +225 -0
- package/dist/docs-src/guide/browser-mount.md +185 -0
- package/dist/docs-src/guide/building-interiors.md +175 -0
- package/dist/docs-src/guide/capability-authoring.md +69 -0
- package/dist/docs-src/guide/determinism.md +285 -0
- package/dist/docs-src/guide/entities.md +47 -0
- package/dist/docs-src/guide/examples.md +58 -0
- package/dist/docs-src/guide/experience-playback.md +57 -0
- package/dist/docs-src/guide/figures.md +164 -0
- package/dist/docs-src/guide/game-samples.md +100 -0
- package/dist/docs-src/guide/graphics-performance.md +167 -0
- package/dist/docs-src/guide/input.md +205 -0
- package/dist/docs-src/guide/materials.md +125 -0
- package/dist/docs-src/guide/project.md +157 -0
- package/dist/docs-src/guide/quickstart.md +63 -0
- package/dist/docs-src/guide/recognizable-places.md +158 -0
- package/dist/docs-src/guide/rendering-backends.md +231 -0
- package/dist/docs-src/guide/scripting.md +330 -0
- package/dist/docs-src/guide/sky.md +192 -0
- package/dist/docs-src/guide/source-bundles.md +42 -0
- package/dist/docs-src/guide/structure-library.md +114 -0
- package/dist/docs-src/guide/surface-rendering.md +203 -0
- package/dist/docs-src/guide/terrain.md +389 -0
- package/dist/docs-src/guide/three-surface.md +70 -0
- package/dist/docs-src/guide/vehicle-interiors.md +126 -0
- package/dist/docs-src/guide/vehicles.md +110 -0
- package/dist/docs-src/guide/weather.md +123 -0
- package/dist/docs-src/guide/worldgen.md +434 -0
- package/dist/docs-src/llms.txt +129 -0
- package/dist/docs-src/schemas/README.md +36 -0
- package/dist/docs-src/schemas/archstyle.md +2340 -0
- package/dist/docs-src/schemas/assert.md +169 -0
- package/dist/docs-src/schemas/asset.md +543 -0
- package/dist/docs-src/schemas/business-catalog.md +162 -0
- package/dist/docs-src/schemas/cameratrack.md +132 -0
- package/dist/docs-src/schemas/command.md +112 -0
- package/dist/docs-src/schemas/components.md +5826 -0
- package/dist/docs-src/schemas/delta.md +204 -0
- package/dist/docs-src/schemas/experience-play.md +452 -0
- package/dist/docs-src/schemas/figure.md +290 -0
- package/dist/docs-src/schemas/interior-catalog.md +230 -0
- package/dist/docs-src/schemas/keyframe.md +314 -0
- package/dist/docs-src/schemas/landmark-catalog.md +56 -0
- package/dist/docs-src/schemas/landmark.md +293 -0
- package/dist/docs-src/schemas/matgraph.md +1163 -0
- package/dist/docs-src/schemas/pack-index.md +82 -0
- package/dist/docs-src/schemas/pack-source.md +139 -0
- package/dist/docs-src/schemas/pack.md +225 -0
- package/dist/docs-src/schemas/pixelgrid.md +108 -0
- package/dist/docs-src/schemas/prefab.md +106 -0
- package/dist/docs-src/schemas/project.md +271 -0
- package/dist/docs-src/schemas/region-atlas.md +612 -0
- package/dist/docs-src/schemas/replay.md +807 -0
- package/dist/docs-src/schemas/scatter.md +541 -0
- package/dist/docs-src/schemas/scene.md +1152 -0
- package/dist/docs-src/schemas/source-bundle.md +266 -0
- package/dist/docs-src/schemas/stylepack.md +420 -0
- package/dist/docs-src/schemas/terrain-package.md +731 -0
- package/dist/docs-src/schemas/terrain.md +313 -0
- package/dist/docs-src/schemas/types.md +218 -0
- package/dist/docs-src/schemas/uvpaint.md +149 -0
- package/dist/docs-src/schemas/worldgen-batch.md +743 -0
- package/dist/index.d.mts +1271 -0
- package/dist/index.mjs +78 -0
- package/dist/mcp-BFnCWrg0.mjs +796 -0
- package/dist/ops-BGxhSP6w.mjs +7246 -0
- package/package.json +96 -0
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
# Worldgen: styled buildings from outlines, props from land labels
|
|
2
|
+
|
|
3
|
+
`@bendyline/molen-worldgen` turns any outline into a styled building and any labeled polygon into
|
|
4
|
+
deterministic prop placements. It knows nothing about maps: give it an outline in meters, a few
|
|
5
|
+
opaque labels, a style, and a stable identity, and it returns typed-array mesh buffers. The
|
|
6
|
+
sibling package `@bendyline/molen-worldgen-earth` is the binding that feeds it real map data: it
|
|
7
|
+
adapts `molen/terrain-semantics@1` tiles (Protomaps / OpenStreetMap footprints and land use) into
|
|
8
|
+
those requests, resolves regional looks from a lon/lat atlas, and plugs the result into the terrain
|
|
9
|
+
streamer as tile layers. A dungeon generator and the Earth renderer call the same functions.
|
|
10
|
+
|
|
11
|
+
## 1. The two layers
|
|
12
|
+
|
|
13
|
+
The [default structure library](structure-library.md) contains 120 resizable structures in 13
|
|
14
|
+
taxonomies and 45 shared materials. The world explorer's `/structures.html` model sheet renders
|
|
15
|
+
every entry and provides dimension, texture and detail controls.
|
|
16
|
+
|
|
17
|
+
For enterable buildings and lazy ground-floor furnishings, see [Building interiors](building-interiors.md).
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
@bendyline/molen-worldgen world-agnostic core
|
|
21
|
+
/kernel formats, footprint analysis, roofs and walls, batch generator, GLB encoder, seeds
|
|
22
|
+
/client buffers to three.js meshes, instanced boxes, style-pack loader
|
|
23
|
+
|
|
24
|
+
@bendyline/molen-worldgen-earth Earth binding (terrain-semantics, OSM classes, lon/lat)
|
|
25
|
+
/kernel molen/region-atlas@1, tile adapter, tile-edge ownership, budgets by quality
|
|
26
|
+
/client TerrainSemanticTileRenderer implementations, atlas loader
|
|
27
|
+
|
|
28
|
+
content/worldgen the shipped looks (styles, scatter rules), the molen.worldgen.default pack
|
|
29
|
+
content/earth world.atlas.json (which style applies where) and the business catalog, molen.earth
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The npm packages carry code only. The default looks are content packs (`molen/pack@1` zips) built
|
|
33
|
+
from the repository's `content/` directories; an app loads them from wherever it hosts them.
|
|
34
|
+
|
|
35
|
+
The core package has no terrain dependency and a test forbids map vocabulary in its sources. Core
|
|
36
|
+
inputs are `BuildingRequest` (identity, labels, outline, optional height/levels/minHeight) and
|
|
37
|
+
`ScatterRequest` (labeled polygons, exclusions, an anchor frame, a keep fraction). Outputs are
|
|
38
|
+
`MeshBuffers` (positions, normals, uvs, 8-bit colors, indices, material groups) and
|
|
39
|
+
`PlacementSet`s (10 floats per instance: position, yaw, scale, tint).
|
|
40
|
+
|
|
41
|
+
## 2. Quick start
|
|
42
|
+
|
|
43
|
+
World explorer, real data:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
pnpm --filter @bendyline/molen-examples-world-explorer dev
|
|
47
|
+
# open / styled Sammamish buildings in the Human mode
|
|
48
|
+
# open /?synthetic=1&lineup=1 one building of every footprint class along a road
|
|
49
|
+
# open /?style=none today's flat extrusions (no pack)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
From code, one building from one outline, no map involved:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { openPack } from '@bendyline/molen-pack';
|
|
56
|
+
import { createBuildingObject, createVertexColorMaterialSet } from '@bendyline/molen-worldgen/client';
|
|
57
|
+
import { resolveStylePackDocuments } from '@bendyline/molen-worldgen/kernel';
|
|
58
|
+
|
|
59
|
+
// The default style pack, from wherever the app hosts it.
|
|
60
|
+
const styles = await openPack('/packs/molen.worldgen.default.zip');
|
|
61
|
+
const pack = await resolveStylePackDocuments(await styles.readJson('stylepack.json'), (path) =>
|
|
62
|
+
styles.readJson(path),
|
|
63
|
+
);
|
|
64
|
+
const style = pack.archstyles['molen.worldgen.fantasy.hall'];
|
|
65
|
+
const hall = createBuildingObject(
|
|
66
|
+
{ identity: 'room:hall-1', labels: ['hall'], outline: [[0, 0], [24, 0], [24, 10], [0, 10]], levels: 2 },
|
|
67
|
+
style,
|
|
68
|
+
{ name: pack.root.name, version: pack.root.version },
|
|
69
|
+
{ materials: createVertexColorMaterialSet() },
|
|
70
|
+
);
|
|
71
|
+
viewer.renderer.worldRoot.add(hall);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Headless, in Node, the same thing produces buffers you can hash or encode:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { encodeGlb, generateWorldgenBatch } from '@bendyline/molen-worldgen/kernel';
|
|
78
|
+
|
|
79
|
+
const out = generateWorldgenBatch({ buildings: [request], pack });
|
|
80
|
+
const glb = encodeGlb(out.buildings); // core glTF 2.0, one primitive per material group
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
From the command line (or the MCP tools of the same names), without writing code. The commands
|
|
84
|
+
need a style pack: pass `--pack` (a content pack zip, a pack source directory, or a
|
|
85
|
+
`stylepack.json`), list one in the project's `packs`, or set `MOLEN_PACKS`. In this repository:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
export MOLEN_PACKS=content/worldgen:content/earth
|
|
89
|
+
molen worldgen preview --out preview.png --angles 4 # the lineup of every shape class
|
|
90
|
+
molen worldgen preview my.archstyle.json --out preview.png # a style file, injected into the pack
|
|
91
|
+
molen worldgen bake content/worldgen/fixtures/fantasy-hall.batch.json --out assets --id hall
|
|
92
|
+
molen worldgen bake --outline "0,0;18,0;18,9;10,9;10,14;0,14" --style molen.worldgen.fantasy.hall --out assets --id keep
|
|
93
|
+
molen worldgen stats examples/world-explorer/public/terrain/sammamish/terrain-package.json --auto --dump tile.batch.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`preview` generates in Node and renders the buffers, props, and scatter in headless Chromium
|
|
97
|
+
from turntable angles (the MCP tool returns the images). `bake` writes a glTF asset with a
|
|
98
|
+
`molen/asset@1` sidecar under an assets root, so a dungeon scene references the hall as a plain
|
|
99
|
+
`gltf` renderable; roof props and scatter are instanced placements and are reported, not baked.
|
|
100
|
+
`stats` opens a real terrain package off disk, generates one tile twice, and reports counts,
|
|
101
|
+
footprint and roof histograms, sizes, timings, and whether both runs hashed the same; `--dump`
|
|
102
|
+
writes the adapted batch (`molen/worldgen-batch@1`, identities of clipped pieces suffixed so
|
|
103
|
+
they stay unique) for `preview` and `bake`. A `molen/worldgen-batch@1` document is the
|
|
104
|
+
interchange: ground (`flat` or `slope`), building requests, optional mapped props and a scatter request, rules,
|
|
105
|
+
and a detail tier. Two example batches live in `content/worldgen/fixtures/`, beside the pack
|
|
106
|
+
source but not packed.
|
|
107
|
+
|
|
108
|
+
## 3. Authoring a look: `molen/archstyle@1`
|
|
109
|
+
|
|
110
|
+
A style is one JSON document under a pack namespace. `molen schema get archstyle` prints the
|
|
111
|
+
full JSON Schema with units on every field; `molen validate styles/x.archstyle.json` reports
|
|
112
|
+
pinpoint errors with did-you-mean hints for palette names. The sections:
|
|
113
|
+
|
|
114
|
+
- `applicability`: which labels and contexts the style is meant for (informational; a pack or
|
|
115
|
+
atlas rule binds it, and a notice fires when a rule and the style disagree).
|
|
116
|
+
- `massing`: floor heights, the `heightFallback` chain used only when a request carries neither
|
|
117
|
+
`height` nor `levels` (ordered `when` rules, last one is a catch-all), how the platform follows
|
|
118
|
+
the ground (`platform-average` keeps within 4 m of the mean, `platform-max` sits on the highest
|
|
119
|
+
point), the exposed foundation, wing decomposition limits, and tower setbacks.
|
|
120
|
+
- `roof`: weighted `choices` among `flat | gable | hip | pyramid | shed | mansard | gambrel`, each
|
|
121
|
+
with a pitch range and optional eligibility (`when: { elongationMin: 1.15 }` keeps gables off
|
|
122
|
+
square plans). Roofs are built per wing: an L becomes two gable wings meeting in a valley.
|
|
123
|
+
Outlines that do not decompose, cut pieces at tile edges, and anything beyond `maxWingSpan` fall
|
|
124
|
+
back to flat (with a parapet when the choice has one) or, for small irregular plans, a skillion.
|
|
125
|
+
- `facade`: bay widths, window rhythm, base bands, and cornice. Windows and trim are generated
|
|
126
|
+
geometry with cell UVs for glass and metric UVs for solid materials.
|
|
127
|
+
- `materials` and `palettes`: one weighted material choice per part (wall, roof, trim, foundation,
|
|
128
|
+
window) and named palettes with HSL jitter. Per-building variation costs nothing: a palette pick
|
|
129
|
+
plus jitter becomes a vertex tint, and metric UVs get a seeded offset.
|
|
130
|
+
- `props`: attachments (chimneys, rooftop units) with anchors, counts, and spacing.
|
|
131
|
+
- `lod.tiers`: which features survive at each detail tier; beyond the last tier the building is an
|
|
132
|
+
instanced tinted box.
|
|
133
|
+
|
|
134
|
+
Every choice is sampled from a named stream of the building seed, so editing the roof section
|
|
135
|
+
never reshuffles the palettes.
|
|
136
|
+
|
|
137
|
+
### Materials, windows, and props
|
|
138
|
+
|
|
139
|
+
A part's `materials` entry lists weighted material references. `palette:#rrggbb` is a flat
|
|
140
|
+
color that lands in the vertex tint (it never costs a mesh group); `matgraph:<pack material id>`
|
|
141
|
+
is a procedural texture document from the pack's `materials` map. Textured parts declare
|
|
142
|
+
`uvScale` (meters per texture repeat); the generator emits UVs already divided by it, so a wall
|
|
143
|
+
material shared by several styles still repeats at each style's scale. With `tint: 'multiply'`
|
|
144
|
+
the sampled palette color multiplies the texture, so pack textures are authored light (the
|
|
145
|
+
default pack asserts a mean luminance of at least 0.55 for every tinted material). Windows use
|
|
146
|
+
`tint: 'none'` and `uv: 'cell'`: every window is one texture repeat.
|
|
147
|
+
|
|
148
|
+
`facade.windows` places windows per bay and floor: `punched` (one window per bay, seeded
|
|
149
|
+
`probabilityPerBay`), `ribbon` (one strip per floor), `grid` (glazing filling the bay), or
|
|
150
|
+
`none`; `groundFloor: 'storefront'` adds ground-floor glazing even when upper windows are
|
|
151
|
+
`none`. Window height caps the storefront glass below a solid wall band; window width controls
|
|
152
|
+
its pane spacing. `facade.bands` adds a
|
|
153
|
+
base band, floor lines, and a cornice from the trim material. Glazing uses surface quads, gated
|
|
154
|
+
by `facade-texture`. The `facade-bands` feature adds raised window surrounds, sills, bounded
|
|
155
|
+
storefront mullions, and projecting bands with exposed upper and lower faces. Structural entrance
|
|
156
|
+
frames remain open at every tier; simplified frames omit depth and hidden faces to conserve the
|
|
157
|
+
geometry budget. Shared linear-filtered worldgen textures use mipmaps and anisotropic filtering.
|
|
158
|
+
|
|
159
|
+
`props` attach pack or builtin models: `roof-ridge` walks the ridge of the dominant wing
|
|
160
|
+
(chimneys), `roof-flat` fills a flat roof with `margin` from every edge (rooftop units),
|
|
161
|
+
`roof-edge` lines the outer edges at the parapet (canales). Prop models are pack assets
|
|
162
|
+
(`assets` map, a `molen/asset@1` sidecar next to `model.glb`); the default pack generates its
|
|
163
|
+
materials and prop models from `scripts/generate-pack.mjs` and the build checks they are current.
|
|
164
|
+
Placements come out of the batch as `props:<model>` placement sets, instanced like scatter.
|
|
165
|
+
|
|
166
|
+
### Building scale and missing measurements
|
|
167
|
+
|
|
168
|
+
Supplied `height` sets the total envelope, including roof and raised clearance. When `levels`
|
|
169
|
+
is also present, it controls the number of storeys: floor spacing fits the available wall height
|
|
170
|
+
instead of deriving extra window rows from a nominal floor height. Without levels, the estimate
|
|
171
|
+
accounts for the taller ground floor and reserved roof space. Budget variants retain the same
|
|
172
|
+
window positions even when they omit the parapet.
|
|
173
|
+
|
|
174
|
+
The default commercial glass texture has one vertical row per generated storey. Untyped buildings
|
|
175
|
+
and low-rise uses with no height or levels default to one or two storeys, independent of footprint
|
|
176
|
+
area; explicitly identified offices retain their taller fallback rules. Big-box retail defaults
|
|
177
|
+
to one tall storey with storefront glazing and solid walls above. These are conservative visual
|
|
178
|
+
defaults, not recovered building measurements. Source heights and levels take precedence.
|
|
179
|
+
|
|
180
|
+
## 4. Seeds and identity
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
building seed: wg1|b|<pack.name>@<pack.version>|<style.id>@<style.version>|<identity>
|
|
184
|
+
aspect seed: <building seed>|massing | roof | facade | palette:<name> | material:<part> | props:<id>
|
|
185
|
+
prop salt: wg1|p|<pack>@<version>|<scatter.id>@<version>|<rule.id> then hashCoord(cellX, cellZ, salt)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The identity is caller-owned and opaque. The Earth binding uses the source feature id (`f:<id>`)
|
|
189
|
+
because tile cutters clip one building into two tiles and the id is the same on both sides; without
|
|
190
|
+
an id it quantizes the centroid to 0.5 projected units (`c:<qx>,<qz>`). Bumping a pack version, a
|
|
191
|
+
style version, or the seed scheme is the only way to re-roll a world.
|
|
192
|
+
|
|
193
|
+
## 5. Placement rules: `molen/scatter@1`
|
|
194
|
+
|
|
195
|
+
A scatter rule set maps land labels to weighted species with density per hectare, clustering noise,
|
|
196
|
+
slope and altitude limits, clearances from roads, buildings, and water, and a keep fraction per
|
|
197
|
+
detail tier. It also carries the surface colors the land-classification layer paints. Rules bind
|
|
198
|
+
builtin procedural species, model ids from the pack, or an imported namespace such as `molen.entities`.
|
|
199
|
+
|
|
200
|
+
The sampler walks a jittered grid anchored to the request frame, not to the batch, so a cell yields
|
|
201
|
+
the same candidate for every caller that covers it: neighbouring tiles never duplicate or miss a
|
|
202
|
+
prop, and a coarser tile shows a nested subset of its children (the keep fraction and every cap
|
|
203
|
+
thin by the same per-cell acceptance draw). Per batch it rasterizes the labeled polygons and the
|
|
204
|
+
exclusions (roads and waterways as ribbons, buildings as dilated rings), then per rule visits only
|
|
205
|
+
the cells under matching polygons, applies clustering noise, slope and altitude limits, picks a
|
|
206
|
+
species by weight, and draws scale, heading, and tint from independent streams of the cell hash.
|
|
207
|
+
Output is one `PlacementSet` per model (stride 10: position, yaw, scale, tint), ordered by cell.
|
|
208
|
+
|
|
209
|
+
On the client, `ModelLibrary.prepare(ref)` turns a glTF scene into one merged vertex-colored
|
|
210
|
+
geometry (material colors baked in, so an authored tree with two materials is one draw), keeps
|
|
211
|
+
builtin primitives (`builtin:tree.conifer`, `builtin:shrub`, `builtin:rock`, ...) for packs
|
|
212
|
+
without assets, and `createInstancedPlacements(set, geometry, material)` uploads a placement set
|
|
213
|
+
as one `InstancedMesh`. The default regional scatter packs use procedural fir, pine, oak, and
|
|
214
|
+
birch (`builtin:tree.conifer.fir|pine`, `builtin:tree.deciduous.oak|birch`), clustered shrubs, and
|
|
215
|
+
irregular rocks. Their opaque crowns, bark, and vertex colors share one geometry and material per
|
|
216
|
+
species: no texture downloads, alpha cards, or per-tree scene objects. Conifers have a closed,
|
|
217
|
+
scalloped crown that conceals the upper trunk; broadleaf crowns use overlapping foliage clumps.
|
|
218
|
+
Tiles below the finest level use cached coarse crowns (132 triangles per conifer, 124 per
|
|
219
|
+
broadleaf tree; 60 per shrub and 20 per rock), sharing the same material and instance transforms.
|
|
220
|
+
The Earth renderer further partitions vegetation into 512-meter cells and switches from near to
|
|
221
|
+
medium to distant geometry as the camera moves. Thresholds are 180 and 650 meters beyond each
|
|
222
|
+
cell’s bounding sphere, with 15% hysteresis to avoid flicker. Distant crowns use 12 triangles for
|
|
223
|
+
conifers and 20 for broadleaf trees. Cells share geometry, materials, and instance buffers across
|
|
224
|
+
levels and can be frustum-culled independently; no per-frame placement uploads are needed.
|
|
225
|
+
`propLod: false` disables this camera LOD, and the explorer exposes `?propLod=0` for comparison.
|
|
226
|
+
The explorer's `AssetCache` still resolves authored GLBs for custom packs and building props.
|
|
227
|
+
|
|
228
|
+
A population's optional `widthScale: { min: 0.8, max: 1.25 }` multiplies X/Z independently of
|
|
229
|
+
its uniform `scale`, allowing tall narrow trees, broad bushy trees, and spreading shrubs in the
|
|
230
|
+
same draw. Width uses its own cell-hash stream, so changing it preserves positions, heights,
|
|
231
|
+
headings, tints, and the subset shared by neighbouring tiles and detail tiers. Omitting it keeps
|
|
232
|
+
uniform scaling. Default vegetation rule sets are version 2 (new planting seeds); architecture
|
|
233
|
+
seeds are unchanged.
|
|
234
|
+
|
|
235
|
+
## 6. Packs: `molen/stylepack@1`
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
content/worldgen/
|
|
239
|
+
stylepack.json name, version (seeds), namespace, id → path maps, defaults, imports
|
|
240
|
+
styles/**/*.archstyle.json
|
|
241
|
+
scatter/*.scatter.json
|
|
242
|
+
materials/, assets/ matgraph documents and prop sidecars (later phases)
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`defaults.rules` is the pack's own ordered style selection (`when` over labels, context, area,
|
|
246
|
+
height presence, elongation, rectangularity) and `defaults.style` closes the chain. Loading a pack
|
|
247
|
+
validates every document and cross-checks ids, material kinds, and model sources; a dangling id
|
|
248
|
+
fails loudly with the candidate list. `resolveStylePackDocuments(root, readDoc)` is the pure
|
|
249
|
+
resolver: give it a content pack's `readJson` and it reads everything from one zip.
|
|
250
|
+
`loadStylePack(baseUrl)` fetches an extracted directory in the browser.
|
|
251
|
+
|
|
252
|
+
## 7. Earth binding: `molen/region-atlas@1`
|
|
253
|
+
|
|
254
|
+
An atlas lists prioritized regions (a lon/lat bbox and/or polygons) with ordered style rules and a
|
|
255
|
+
scatter set, plus a worldwide default chain. Precedence for a building is: region rules, region
|
|
256
|
+
default, atlas default rules, atlas default style, pack rules, pack default style. The region is
|
|
257
|
+
resolved once per tile at its centre; when a tile straddles regions every building resolves at its
|
|
258
|
+
own centroid. Atlas geometry is projected once into the package's world meters, so lookups are
|
|
259
|
+
comparisons.
|
|
260
|
+
|
|
261
|
+
The adapter also decides tile-edge ownership: a footprint that appears complete in two tiles is
|
|
262
|
+
rendered by the tile holding more of it, and a footprint cut by both buffers is rendered piecewise
|
|
263
|
+
with seam walls and a flat roof. Both tiles reach the same verdict from their own copy.
|
|
264
|
+
|
|
265
|
+
Stock Protomaps buildings should be extracted through zoom 15. At zoom 14 and below the
|
|
266
|
+
basemap merges footprints and rounds heights; zoom 15 retains individual features and the
|
|
267
|
+
available unrounded heights. The adapter consumes height, minimum height, and building parts.
|
|
268
|
+
The basemap derives some heights from floor counts, but does not retain raw floor counts, roof
|
|
269
|
+
shape, roof material, or the original building type for ordinary outlines. Missing attributes
|
|
270
|
+
remain estimates; residential land use is evidence of likely use, not a zoning or floor-count
|
|
271
|
+
record.
|
|
272
|
+
|
|
273
|
+
Building context uses several points across the footprint. Mapped land use takes precedence over
|
|
274
|
+
physical cover such as grass or woodland; among overlapping uses, the smaller polygon wins.
|
|
275
|
+
Explicit building classifications override generic labels. Residential context selects residential
|
|
276
|
+
styles even for large or long townhouse footprints, with a conservative two-floor fallback for
|
|
277
|
+
larger footprints. Roof eligibility sees supplied or resolved floor counts: the default residential
|
|
278
|
+
styles prefer pitched roofs through three floors and flat roofs from four upward. The Southwest
|
|
279
|
+
style also allows flat roofs on low buildings. Wide, clipped, or unsuitable footprints can still
|
|
280
|
+
require a flat roof for geometric reasons.
|
|
281
|
+
|
|
282
|
+
### Inferred trees around homes
|
|
283
|
+
|
|
284
|
+
Atlas region bindings and the worldwide default accept `treeFillFactor` from 0 to 1. The
|
|
285
|
+
shipped atlas uses 0.9 in the Pacific Northwest, 0.3 in Japan, and 0 in the Southwest and
|
|
286
|
+
unclassified regions. These are configurable visual priors, not measured canopy percentages
|
|
287
|
+
or a global climate dataset. Fill is resolved at each home's location, including region edges.
|
|
288
|
+
|
|
289
|
+
For complete low-rise footprints of 45–700 m², the Earth adapter adds an irregular yard patch
|
|
290
|
+
roughly 18–26 meters beyond the home. Explicit house classifications qualify; small untyped
|
|
291
|
+
buildings also qualify when land use does not contradict residential use. Known commercial
|
|
292
|
+
buildings, elevated parts, tall buildings, and generalized or source-clipped footprints do not.
|
|
293
|
+
No residential land-use polygon is required. Unknown parcels and driveways cannot be recovered
|
|
294
|
+
from absent data, so this remains an estimate of open space.
|
|
295
|
+
|
|
296
|
+
The patch and its tree acceptance/species/size use a named `yard-trees` stream of the building
|
|
297
|
+
seed. The shared world grid supplies candidate positions: overlapping yards have one stable
|
|
298
|
+
owner per cell, feature ordering does not reshuffle trees, and lowering fill or detail keeps
|
|
299
|
+
surviving instances unchanged. The serialized scatter polygon carries its optional uint32
|
|
300
|
+
`seed`. Existing unseeded scatter retains its previous placements.
|
|
301
|
+
|
|
302
|
+
Mapped woodland, parks, parking, playing fields, farmland, barren ground, and other incompatible
|
|
303
|
+
land cover are cut out before planting. Road, building, water, and mapped-tree exclusions still
|
|
304
|
+
apply, as do slope/altitude limits and instance budgets. Neighboring buffered footprints
|
|
305
|
+
participate even when their building mesh belongs to another tile; trees emit only inside the
|
|
306
|
+
current tile. Coverage still depends on the footprints supplied in the source tile buffer.
|
|
307
|
+
|
|
308
|
+
The dedicated `home_canopy` scatter rule controls species, spacing, setbacks, and detail tiers;
|
|
309
|
+
custom packs opt in by supplying this rule label. Species use the tile's regional scatter set,
|
|
310
|
+
as with other vegetation. House infill runs in scatter-only worker requests and uses the same
|
|
311
|
+
instanced vegetation and camera LOD as forest scatter. No individual tree records are required.
|
|
312
|
+
|
|
313
|
+
A supplied building height is the total ground-to-top envelope, including the roof and any
|
|
314
|
+
minimum height. Roof geometry fits inside it instead of being added above it. Roof props may
|
|
315
|
+
project above that envelope. Parts spatially contained in an outline replace the covered area;
|
|
316
|
+
uncovered areas of the original outline remain. Related pieces receive a shared `groundOutline`
|
|
317
|
+
for fitting their platform to terrain, and raised parts retain their minimum-height clearance.
|
|
318
|
+
Containment is a spatial inference because stock Protomaps does not publish parent relation IDs.
|
|
319
|
+
|
|
320
|
+
## 8. Budgets and quality
|
|
321
|
+
|
|
322
|
+
`worldgenTileBudgetForQuality(quality, levelBelowMax)` caps buildings and vertices per tile.
|
|
323
|
+
Building batches reserve simple architecture before allocating extra detail to the largest
|
|
324
|
+
footprints. The budget fallback preserves the authored footprint, roof shape, and (where the
|
|
325
|
+
active style tier permits them) up to three window columns and two rows per wall, using shared
|
|
326
|
+
vertex-colored materials during reservation. Eligible simplified buildings recover their shared
|
|
327
|
+
textures when material groups fit, even if no geometric detail fits. High admits 24 material
|
|
328
|
+
groups at the finest level, including flat fallback slots. The fallback omits raised window
|
|
329
|
+
surrounds, trim bands, overhangs, separate foundation meshes, and roof
|
|
330
|
+
props. Simplified and coarse buildings extend their walls below the lowest sampled ground,
|
|
331
|
+
keeping roofs and windows level without gaps on downhill sides or extra vertices and draw calls.
|
|
332
|
+
Box fallbacks do the same; intentionally elevated `minHeight` parts retain their clearance.
|
|
333
|
+
`detailedCount` limits eligibility for extra detail; it no longer turns all later buildings into
|
|
334
|
+
boxes. Vertex and material-group caps still apply, with boxes used when the simple geometry
|
|
335
|
+
cannot fit or the requested tier is beyond the style's last tier. Buildings beyond
|
|
336
|
+
`maxBuildings` are still omitted. Quality and detail remain tile-based, not camera-distance
|
|
337
|
+
updates per building.
|
|
338
|
+
|
|
339
|
+
Generation is cooperative: the renderer yields between chunks of both reservation and detail
|
|
340
|
+
work, and aborts when a tile is evicted. The explorer HUD reports buildings, boxes, and generation
|
|
341
|
+
time per tile.
|
|
342
|
+
|
|
343
|
+
Detail tiers come from the level below the finest (tier 0 at the finest level, 1 one level
|
|
344
|
+
below, ...) plus one at economy quality. A style's `lod.tiers` say which features survive each
|
|
345
|
+
tier: roof shape, roof features, facade windows, facade bands, props; beyond the last tier the
|
|
346
|
+
building is a tinted box. `maxMaterialGroups` caps the mesh groups (draw calls) of one batch:
|
|
347
|
+
once a batch would exceed it, later buildings render their textured parts as vertex colors
|
|
348
|
+
(`stats.materialsCollapsed`), so the largest buildings keep their textures first.
|
|
349
|
+
|
|
350
|
+
Scatter is bounded the same way. `maxInstances` caps the props of one batch as a whole (the
|
|
351
|
+
sampler thins uniformly across rules by the same acceptance draw, so a tighter budget is a subset
|
|
352
|
+
of a looser one) and `maxInstancesPerRule` caps one rule. The tile budgets shrink both with the
|
|
353
|
+
detail level: a tile one level below the finest covers four times the area with a fraction of
|
|
354
|
+
the instances, two levels below keeps a sparse hint, and coarser tiles carry no props. Visible
|
|
355
|
+
cells draw only their active LOD; keep `maxPropModels` small because each model needs a draw per
|
|
356
|
+
visible cell. The per-tile placement budgets still bound the resident instance data. Balanced quality
|
|
357
|
+
allows 6,000 nearby placements, 1,200 one level below, and 250 two levels below. Economy uses
|
|
358
|
+
2,200 / 400 / 0; high uses 9,000 / 1,800 / 350. The forest rules fill nearby crowns while
|
|
359
|
+
understory is limited to the finest tier; parks and yards retain lower densities and all
|
|
360
|
+
placements retain road, building, and water clearances.
|
|
361
|
+
|
|
362
|
+
## 9. Wiring it yourself
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
import { loadStylePack } from '@bendyline/molen-worldgen/client';
|
|
366
|
+
import { createRegionResolver, createWorldgenSemanticRenderers, loadRegionAtlas } from '@bendyline/molen-worldgen-earth/client';
|
|
367
|
+
|
|
368
|
+
const { pack } = await loadStylePack('/worldgen/default/');
|
|
369
|
+
const atlas = await loadRegionAtlas('/worldgen-earth/default/world.atlas.json');
|
|
370
|
+
const regions = createRegionResolver(atlas, { metersPerUnit });
|
|
371
|
+
const worldgen = createWorldgenSemanticRenderers(pack, { atlas, regions, metersPerUnit, quality });
|
|
372
|
+
const layers = await createProfiledTerrainPackageSemanticLayers(pkg, {
|
|
373
|
+
baseUrl,
|
|
374
|
+
landcoverLayer: { renderer: worldgen.classification },
|
|
375
|
+
featuresLayer: { renderer: worldgen.humanFeatures },
|
|
376
|
+
});
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## 10. Off the main thread, cached, and queryable
|
|
380
|
+
|
|
381
|
+
`createWorldgenSemanticRenderers` takes a `generator`: by default tiles generate on the calling
|
|
382
|
+
thread in cooperative chunks; `createWorldgenWorkerBridge(worker, { pack, atlas, metersPerUnit })`
|
|
383
|
+
sends each tile (semantics, geometry, a transferable height grid) to a Worker that runs
|
|
384
|
+
`installWorldgenWorker(self)` from `@bendyline/molen-worldgen-earth/worker` and hands back
|
|
385
|
+
transferred buffers; aborting a tile cancels its generation between chunks. Both paths sample
|
|
386
|
+
the ground through the same height grid, so their output is byte-identical (a test asserts it).
|
|
387
|
+
A `cache` (`createWorldgenTileCache`) keeps generated tiles in CPU memory keyed by pack, atlas,
|
|
388
|
+
quality, features, and address, so a tile that leaves and re-enters residency is uploaded, not
|
|
389
|
+
regenerated. The explorer enables this worker by default; `?worker=0` selects the in-thread diagnostic path.
|
|
390
|
+
|
|
391
|
+
Land-cover polygon draping and vertex welding also run in a separate worker in the explorer.
|
|
392
|
+
`createTerrainLandcoverWorkerBridge` (terrain client) supplies the renderer’s `landcoverGenerator`;
|
|
393
|
+
the host’s worker entry calls `installTerrainLandcoverWorker`. It transfers an independent copy of
|
|
394
|
+
the height samples and returns indexed geometry, preserving the rendered terrain grid. Only one
|
|
395
|
+
job runs at a time in this worker; cancelled queued jobs are skipped. Road/parking construction
|
|
396
|
+
also uses a dedicated surface worker in the explorer. Archive decoding, scene assembly, and GPU
|
|
397
|
+
uploads still happen on the main thread.
|
|
398
|
+
|
|
399
|
+
A shared `lodPolicy: ScreenSpaceLodPolicy` enables projected-screen-size LOD for vegetation and
|
|
400
|
+
buildings. Buildings retain their structural faces while distant materials and facade details
|
|
401
|
+
simplify; geometry attributes are shared across spatial cells and levels. `setQuality(preset)`
|
|
402
|
+
changes future generation and queues resident architecture for replacement, one building batch
|
|
403
|
+
at a time. The previous buildings stay visible until their replacements are ready; roads remain
|
|
404
|
+
in place. Preset changes and eviction cancel obsolete replacements. Policy mutations immediately
|
|
405
|
+
affect resident LODs; existing scatter keeps its generation density until reloaded. Generation
|
|
406
|
+
cache keys include effective budgets/tier offsets; `setCacheBudget(bytes)` trims the cache in place.
|
|
407
|
+
See [Adaptive rendering performance](adaptive-performance.md) for the explorer's device feedback
|
|
408
|
+
controller, live terrain budgets and measurement limits.
|
|
409
|
+
|
|
410
|
+
Gameplay can ask what was generated: `createWorldgenIndex(records, placements)` buckets a batch
|
|
411
|
+
(or several tiles, with `add`) and answers `buildingAt(x, z)`, `buildingsNear(x, z, r)`, and
|
|
412
|
+
`propsNear(x, z, r)`; `installWorldgen(world, index)` registers it on a kernel world as a side
|
|
413
|
+
channel (never in world state or its hash) and `worldgenScriptApi(handle)` exposes it to scene
|
|
414
|
+
scripts as `molen.worldgen.*` through `buildWorld`'s `scriptExtensions`.
|
|
415
|
+
|
|
416
|
+
Scenes that are not maps carry a `worldgenBuilding` component (style id, outline in the entity
|
|
417
|
+
frame, holes, height or levels, labels, seed, tier): `createWorldgenEntityLayer(client, { pack })`
|
|
418
|
+
renders every such entity on a live client under its `transform`, rebuilding when the component
|
|
419
|
+
changes and disposing when the entity goes away.
|
|
420
|
+
|
|
421
|
+
## 11. Limits
|
|
422
|
+
|
|
423
|
+
- Inputs include land classes, vector footprints and optional business/prop points; nothing samples imagery. See [recognizable places](recognizable-places.md).
|
|
424
|
+
- Protomaps business identity comes from optional POIs at the finest detail level. Buildings mostly carry `kind: building`; rules lean on footprint metrics, height
|
|
425
|
+
presence, and the surrounding land use. Context is available when land use and buildings share
|
|
426
|
+
one archive (the Sammamish package does).
|
|
427
|
+
- Roofs of clipped tile-edge pieces are flat; secondary wings share the main eave height.
|
|
428
|
+
- Windows are surface quads, not openings; dormers and setbacks are declared in the format but not
|
|
429
|
+
built yet; `wall-any` and `ground-any` prop anchors place nothing yet.
|
|
430
|
+
- Builtin vegetation uses spatially batched distance or screen-space LOD. Custom GLBs retain their authored
|
|
431
|
+
geometry; they need authored LOD assets or simplification before the same reduction is possible.
|
|
432
|
+
- Baked assets hold the building mesh only; props and scatter stay instanced placements.
|
|
433
|
+
- The entity layer places buildings statically (no tweening) and needs prop models prepared
|
|
434
|
+
through a `ModelLibrary` to show roof props.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Molen
|
|
2
|
+
|
|
3
|
+
> A reusable, AI-legible 3D engine for the browser. A deterministic headless kernel plus a
|
|
4
|
+
> three.js rendering client, authored through JSON schemas, a small typed API, and a headless
|
|
5
|
+
> dev loop. This bundle is version-locked to the engine release.
|
|
6
|
+
|
|
7
|
+
Engine version: 0.0.1. three.js peer range: >=0.184.0 <0.187.0 (developed against 0.184.0). Node ≥ 22.13, ESM only.
|
|
8
|
+
|
|
9
|
+
## Start here
|
|
10
|
+
|
|
11
|
+
- [Agent loop](guide/agent-loop.md): the author → validate → simulate → assert → screenshot loop, with copy-paste commands.
|
|
12
|
+
- [Browser experience playback](guide/experience-playback.md): host any built sample, drive real keyboard/pointer navigation, and capture screenshots plus diagnostics.
|
|
13
|
+
- [Projects & types](guide/project.md): project.json, the namespaced entity type registry, reservations, and typed TS authoring (`defineExperience` + `molen types gen`).
|
|
14
|
+
- [Projects & content packs](guide/project.md): content (entity types and models, style packs, catalogs, stars) ships as `molen/pack@1` zip packs, never in npm packages; list them in project.json `packs` or open them with `@bendyline/molen-pack`.
|
|
15
|
+
- [Reusable entities](guide/entities.md): the `molen.entities` content pack (trees, rocks, aircraft, vehicles) and how to bind it through a pack's asset provider.
|
|
16
|
+
- [Scripting](guide/scripting.md): game logic as scene-data scripts (the verb set, `molen.onCommand` for input) or a setup module; `molen types gen` + `molen scripts check` type-check them. Scripts run with the host process's authority — see "Script trust" below.
|
|
17
|
+
- [Determinism](guide/determinism.md): the contract — what reproduces and at what level per subsystem, what breaks it, what `STATE_FORMAT` means for save files and recorded replays, and what is explicitly not promised.
|
|
18
|
+
- [Browser mount](guide/browser-mount.md): `buildWorld` in a Worker + `await mountExperience` on the page; events and state for HUDs.
|
|
19
|
+
- [Input profiles and joysticks](guide/input.md): keyboard/controller remapping, raw axes, walking/driving/flying profiles, analog commands, and optional React controls.
|
|
20
|
+
- [WebGPU and WebGL](guide/rendering-backends.md): the `backend` option ('auto' | 'webgl' | 'webgpu') on the asynchronous client factories, legacy WebGL fallback, compatible materials, and world-explorer comparisons.
|
|
21
|
+
- [Earth and authored skies](guide/sky.md): day/night cycles, geographic Sun/Moon positions and lunar phases, catalog stars, simulation clocks, custom-world palettes, and the sky observatory.
|
|
22
|
+
- [Weather and physical atmosphere](guide/weather.md): independent clouds, precipitation and visibility; profiles, temperature/pressure/wind for simulation and aircraft physics; cloud/rain/snow rendering.
|
|
23
|
+
- [Graphics performance](guide/graphics-performance.md): sparse transforms, static instancing, worker preparation, staged uploads, animation/light policy and terrain transitions.
|
|
24
|
+
- [Quickstart](guide/quickstart.md): zero-to-cubes in Node and the browser.
|
|
25
|
+
- [Terrain and world explorer](guide/terrain.md): fixed-grid and screen-space pyramid streaming,
|
|
26
|
+
projected Earth coordinates, optional semantic tile layers, the installable tiled-world package
|
|
27
|
+
contract, and sample app.
|
|
28
|
+
- [Surface styles and line features](guide/surface-rendering.md): live modern/1910 treatments, roads, parking, intersections, sidewalks, fixtures, and reusable profiles for rail and utility corridors.
|
|
29
|
+
- [Worldgen: styled buildings and scatter](guide/worldgen.md): any outline → a styled building; `worldgenBuilding` component, `molen.worldgen.*` script queries, worker + cache for map tiles
|
|
30
|
+
(footprint analysis, roofs, walls), labeled polygons → deterministic props, style packs, and the
|
|
31
|
+
Earth binding (region atlas, terrain-semantics adapter, tile renderers).
|
|
32
|
+
- [Default structure library](guide/structure-library.md): 120 resizable buildings in 13 taxonomies, 45 shared construction materials, regional placement and the interactive model sheet.
|
|
33
|
+
- [Recognizable places](guide/recognizable-places.md): store identity matching, reusable signs, tenant facades and mapped outdoor props.
|
|
34
|
+
- [Building interiors](guide/building-interiors.md): deterministic layouts by use, real entrances and frontage windows, lazy rendering and walk collision.
|
|
35
|
+
- [3D art guidelines](guide/3d-art-guidelines.md): shared polygonal fidelity, scale, material library, LOD and visual review for static and procedural models.
|
|
36
|
+
- [Materials](guide/materials.md): palette and procedural material-graph textures.
|
|
37
|
+
- [3D model assets](guide/3d-model-assets.md): prompt-to-glTF authoring, PBR texture conventions, import, visual QA, and browser hosting.
|
|
38
|
+
- [Logical source bundles](guide/source-bundles.md): one copyable folder per entity, structure, vehicle, prop, or other authored thing, with all definitions and source files listed in `source.json`.
|
|
39
|
+
- [Components](schemas/components.md): the component vocabulary `molen validate` checks against.
|
|
40
|
+
- [Mountable vehicles](guide/vehicles.md): stable parking entities, driver seats, deterministic vehicle physics, safe exits, and cockpit/chase views.
|
|
41
|
+
- [Aircraft](guide/aircraft.md): P-51D and OH-6 assets, flight physics, cockpit instruments, practice airfield and controls.
|
|
42
|
+
- [Vehicle interiors and model signals](guide/vehicle-interiors.md): model-owned cabins, declarative simulation-to-GLB bindings, script-owned telemetry, and nearby detail loading.
|
|
43
|
+
- [Figures](guide/figures.md): stylized humans, bipeds and quadrupeds: presets and descriptors, canonical rigs and sockets, deterministic gaits, `figureAttachment` accessories, riders, and `molen figure preview`.
|
|
44
|
+
- [Complete game samples](guide/game-samples.md): city driving, first-person dungeon, and platformer; shared follow cameras and XY platform physics.
|
|
45
|
+
- [Examples gallery](guide/examples.md): the shipped demos + capability layers (kinematics,
|
|
46
|
+
character, pathfinding, physics-rapier, terrain) — copy-and-modify starting points.
|
|
47
|
+
|
|
48
|
+
> **Script trust:** a scene manifest's `scripts` are evaluated **in-process** — by the `molen`
|
|
49
|
+
> CLI and the MCP server too — and run with the authority of that process. The SES `Compartment`
|
|
50
|
+
> and its tamed endowments (`Math` without `random`, `Date`/`Intl`/`Promise` shadowed) exist to
|
|
51
|
+
> make simulation deterministic; they are **not** an isolation boundary. Intrinsics are shared and
|
|
52
|
+
> mutable, and the host global is one expression away. Treat a `scene.json` like source code: only
|
|
53
|
+
> run manifests you would run as a program. A host that needs the boundary calls `hardenScripts()`
|
|
54
|
+
> (SES `lockdown()`, process-global) in a Worker or other kernel-only process — see
|
|
55
|
+
> [guide/scripting.md](guide/scripting.md) "Script trust". Path arguments to the CLI and MCP tools
|
|
56
|
+
> are likewise trusted user intent: they are read, written or imported as given, wherever they point.
|
|
57
|
+
|
|
58
|
+
> **Truth rule for agents:** `docs-src/` (this bundle) and `packages/` are the shipped engine.
|
|
59
|
+
> The `docs/` folder is the original *design plan*: historical, not maintained, and it may lag the
|
|
60
|
+
> code — treat it as intent, not fact. `molen docs search` searches this bundle by default (`--design` adds `docs/`,
|
|
61
|
+
> tagged). Repo root has an [AGENTS.md](../AGENTS.md) signpost. Scaffold a starter with `molen new`.
|
|
62
|
+
|
|
63
|
+
## Schema reference (autogenerated)
|
|
64
|
+
|
|
65
|
+
[schemas/README.md](schemas/README.md) — every registered format with its JSON Schema and a
|
|
66
|
+
valid example. That page is generated from the registry `molen validate` checks against, so it is
|
|
67
|
+
never behind; `molen schema list` prints the same set at runtime.
|
|
68
|
+
|
|
69
|
+
## Authoring formats (validate everything before running)
|
|
70
|
+
|
|
71
|
+
All formats carry a `"format": "molen/<kind>@<n>"` (or `"kind"`) envelope and are validated
|
|
72
|
+
with `molen validate <file>`, which prints precise, fixable errors. The shipped specs (JSON
|
|
73
|
+
Schema + example, generated from the registry) live in [schemas/](schemas/README.md):
|
|
74
|
+
|
|
75
|
+
- [Scene manifest](schemas/scene.md) (`molen/scene@3`: entities, prefabs, `commands`, `components`, camera, input, physics, terrain)
|
|
76
|
+
- [Command envelope](schemas/command.md) · [Assertions](schemas/assert.md)
|
|
77
|
+
- [Keyframe](schemas/keyframe.md) · [Delta](schemas/delta.md) · [Replay](schemas/replay.md)
|
|
78
|
+
- [Components](schemas/components.md) — every component with units and axis conventions
|
|
79
|
+
|
|
80
|
+
## The API surface
|
|
81
|
+
|
|
82
|
+
- Script verb set + authoring models: [guide/scripting.md](guide/scripting.md) (shipped truth).
|
|
83
|
+
- Component vocabulary: [schemas/components.md](schemas/components.md) or `molen components`.
|
|
84
|
+
- three.js surface + escape hatch (peer range 0.184–0.186): [guide/three-surface.md](guide/three-surface.md).
|
|
85
|
+
- Writing a capability package: [guide/capability-authoring.md](guide/capability-authoring.md).
|
|
86
|
+
- Kernel & ECS design notes: [02-packages-and-apis.md §3](../docs/02-packages-and-apis.md) (design plan).
|
|
87
|
+
|
|
88
|
+
## Tooling — CLI (`npx molen <cmd>` in a project that installs `@bendyline/molen-tooling`; `node packages/tooling/dist/cli.mjs <cmd>` from a clone)
|
|
89
|
+
|
|
90
|
+
- `molen new <name>` — scaffold a runnable project (project.json + scene + type registry + setup + checks)
|
|
91
|
+
- `molen validate <file> [--kind k] [--project p]` — validate an asset (pinpoint, fixable errors; scene `type` refs resolve through the project)
|
|
92
|
+
- `molen sim run <scene|name> --ticks N [--setup m] [--commands f] [--assert f] [--hash]`
|
|
93
|
+
- `molen asset import <file.glb> [--id <id>] [--trimesh]` · `asset inspect <ref> [--verify]` · `asset list` · `asset shot <ref> --out-dir d [--variant ktx2]`
|
|
94
|
+
- `molen pack build <dir> --out-dir d` · `pack inspect|verify <pack>` · `pack extract <pack> --out-dir d` · `pack fetch <url> [--project p]` — content packs (deterministic zips with a manifest); CLI ops find them via project.json `packs` and `MOLEN_PACKS`
|
|
95
|
+
- `molen asset pack <ref>|--all` — runtime GLB variant (KTX2 textures + mips, 4-8x less GPU memory) · `asset stage --out-dir d [--variant ktx2]` — browser bundle + assets.index.json
|
|
96
|
+
- `molen drive <scene> --actions f --out-dir d [--assert f]` — PLAY a scene: commands in, frames out (deterministic)
|
|
97
|
+
- `molen play <built-app-dir> --scenario f --out-dir d` — PLAY a browser experience: UI inputs in, screenshots/probes/diagnostics out
|
|
98
|
+
- `molen sim watch <scene> --ticks N [...]` — rerun + diff on every file change · `molen types test [ids…]`
|
|
99
|
+
- `molen project info` · `molen types list|check|reserve <ns> --owner <o>|gen [--check]`
|
|
100
|
+
- `molen shot <scene> --out p.png [--ticks N] [--camera x,y,z] [--look x,y,z] [--size WxH] [--terrain d.json --heightmap h.png]`
|
|
101
|
+
- `molen frames <scene> --out-dir d --from N --to M [--step S] [--track f]` — render a PNG sequence
|
|
102
|
+
- `molen replay <fixture> [--setup m] [--record]` — replay; localizes divergence on mismatch
|
|
103
|
+
- `molen diff <a.keyframe.json> <b.keyframe.json>` — component-level keyframe diff
|
|
104
|
+
- `molen material bake <matgraph.json> -o tex.png` — bake a procedural texture
|
|
105
|
+
- `molen uvpaint apply <painted.png> --islands <map.png> -o tex.png` — import a painted UV template
|
|
106
|
+
- `molen schema list | schema get <kind>` · `molen components | component <name>`
|
|
107
|
+
- `molen docs search <query> [-k N] [--design]` · `molen describe [op]`
|
|
108
|
+
- `molen worldgen preview [style.json] [--pack p] [--style id] [--batch f] [--angles N] --out p.png` — generate buildings and render them headlessly · `worldgen bake [batch.json] [--outline "x,z;…" --style id] --out <assets-dir> [--id id]` — bake to a glTF asset + sidecar · `worldgen stats <terrain-package.json> [--tile z/x/y | --auto] [--dump batch.json]` — generate one real tile and report
|
|
109
|
+
- `molen figure preview [descriptor.figure.json] [--preset id[,id]] [--lineup humans|bodies|species|all] [--mode idle|walk|run|sit|jump|fall] [--angles N|review] --out p.png` — render figures headlessly · `figure presets [--json]` — list the shipped presets
|
|
110
|
+
- `molen mcp` — start the MCP server (stdio)
|
|
111
|
+
|
|
112
|
+
## MCP tools (the server mirrors the CLI 1:1; `molen describe` cross-references both)
|
|
113
|
+
|
|
114
|
+
`validate_asset`, `run_simulation`, `screenshot_scene`, `export_frames`, `rasterize_material`,
|
|
115
|
+
`run_replay`, `diff_snapshots`, `apply_uv_paint`, `list_schemas`, `get_schema`, `list_components`,
|
|
116
|
+
`get_component`, `search_docs`, `describe_op`, `new_experience`, `get_project`, `list_types`,
|
|
117
|
+
`check_types`, `reserve_type`, `generate_types`, `import_asset`, `inspect_asset`, `pack_asset`, `stage_assets`,
|
|
118
|
+
`list_assets`, `drive_scene` (returns frames as IMAGES), `play_experience` (plays a built browser app and returns frames as IMAGES), `screenshot_asset` (turntable images),
|
|
119
|
+
`test_types`, `worldgen_preview` (generated buildings as IMAGES), `worldgen_bake`, `worldgen_stats`,
|
|
120
|
+
`figure_preview` (figures as IMAGES), `list_figure_presets`. Call `describe_op` for I/O contracts.
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
## Design reference (for deeper questions)
|
|
124
|
+
|
|
125
|
+
- [Kernel design](../docs/04-kernel-design.md) · [Client design](../docs/05-client-design.md)
|
|
126
|
+
- [Materials & assets](../docs/06-materials-and-assets.md) · [Tooling & testing](../docs/07-tooling-and-testing.md)
|
|
127
|
+
- [Phase plan](../docs/08-phase-plan.md) · [Questions & risks](../docs/09-questions-and-risks.md)
|
|
128
|
+
|
|
129
|
+
- [Adaptive rendering performance](guide/adaptive-performance.md) — device feedback, frame/GPU timing, live terrain budgets, screen-space object LOD and worker boundaries.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Schema reference
|
|
2
|
+
|
|
3
|
+
Autogenerated from the registered schemas (`pnpm docs:gen`; CI runs `pnpm docs:check`).
|
|
4
|
+
|
|
5
|
+
- [Components](components.md) — the component vocabulary (`molen components`)
|
|
6
|
+
- [Architectural style](archstyle.md) — `molen/archstyle@1`
|
|
7
|
+
- [Assertion document](assert.md) — `molen/assert@1`
|
|
8
|
+
- [Asset sidecar](asset.md) — `molen/asset@1`
|
|
9
|
+
- [Business identity catalog](business-catalog.md) — `molen/business-catalog@1`
|
|
10
|
+
- [Camera track](cameratrack.md) — `molen/cameratrack@1`
|
|
11
|
+
- [Command envelope](command.md) — `molen/command@1`
|
|
12
|
+
- [Per-tick delta](delta.md) — `molen/delta@1`
|
|
13
|
+
- [Experience play scenario](experience-play.md) — `molen/experience-play@1`
|
|
14
|
+
- [Figure descriptor](figure.md) — `molen/figure@1`
|
|
15
|
+
- [Interior catalog](interior-catalog.md) — `molen/interior-catalog@1`
|
|
16
|
+
- [Keyframe snapshot](keyframe.md) — `molen/keyframe@1`
|
|
17
|
+
- [Landmark model](landmark.md) — `molen/landmark@1`
|
|
18
|
+
- [Landmark catalog](landmark-catalog.md) — `molen/landmark-catalog@1`
|
|
19
|
+
- [Procedural material graph](matgraph.md) — `molen/matgraph@1`
|
|
20
|
+
- [Content pack manifest](pack.md) — `molen/pack@1`
|
|
21
|
+
- [Content pack index](pack-index.md) — `molen/pack-index@1`
|
|
22
|
+
- [Content pack source](pack-source.md) — `molen/pack-source@1`
|
|
23
|
+
- [Pixel-grid texture](pixelgrid.md) — `molen/pixelgrid@1`
|
|
24
|
+
- [Prefab](prefab.md) — `molen/prefab@1`
|
|
25
|
+
- [Project manifest](project.md) — `molen/project@1`
|
|
26
|
+
- [Region style atlas](region-atlas.md) — `molen/region-atlas@1`
|
|
27
|
+
- [Replay fixture](replay.md) — `molen/replay@1`
|
|
28
|
+
- [Scatter rules](scatter.md) — `molen/scatter@1`
|
|
29
|
+
- [Scene manifest](scene.md) — `molen/scene@3`
|
|
30
|
+
- [Logical source bundle](source-bundle.md) — `molen/source-bundle@1`
|
|
31
|
+
- [Style pack manifest](stylepack.md) — `molen/stylepack@1`
|
|
32
|
+
- [Terrain descriptor](terrain.md) — `molen/terrain@2`
|
|
33
|
+
- [Terrain package manifest](terrain-package.md) — `molen/terrain-package@1`
|
|
34
|
+
- [Entity type registry](types.md) — `molen/types@1`
|
|
35
|
+
- [UV paint sidecar](uvpaint.md) — `molen/uvpaint@1`
|
|
36
|
+
- [Worldgen batch](worldgen-batch.md) — `molen/worldgen-batch@1`
|