@bendyline/molen-tooling 0.0.1 → 0.0.3
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/README.md +22 -4
- package/dist/capture/harness.js +216 -216
- package/dist/capture/worldgen-preview.js +288 -288
- package/dist/cli.mjs +134 -12
- package/dist/docs-src/guide/3d-art-guidelines.md +2 -2
- package/dist/docs-src/guide/3d-model-assets.md +49 -13
- package/dist/docs-src/guide/adaptive-performance.md +4 -0
- package/dist/docs-src/guide/agent-loop.md +6 -6
- package/dist/docs-src/guide/aircraft.md +25 -17
- package/dist/docs-src/guide/audio.md +247 -0
- package/dist/docs-src/guide/browser-mount.md +17 -1
- package/dist/docs-src/guide/building-interiors.md +7 -5
- package/dist/docs-src/guide/determinism.md +27 -22
- package/dist/docs-src/guide/earth-view.md +444 -0
- package/dist/docs-src/guide/entities.md +17 -6
- package/dist/docs-src/guide/examples.md +39 -23
- package/dist/docs-src/guide/experience-playback.md +2 -3
- package/dist/docs-src/guide/game-samples.md +50 -21
- package/dist/docs-src/guide/graphics-performance.md +40 -8
- package/dist/docs-src/guide/input.md +9 -0
- package/dist/docs-src/guide/markers.md +52 -0
- package/dist/docs-src/guide/materials.md +10 -3
- package/dist/docs-src/guide/navigation.md +144 -0
- package/dist/docs-src/guide/project.md +23 -3
- package/dist/docs-src/guide/quickstart.md +39 -30
- package/dist/docs-src/guide/recognizable-places.md +24 -17
- package/dist/docs-src/guide/rendering-backends.md +5 -4
- package/dist/docs-src/guide/scripting.md +8 -4
- package/dist/docs-src/guide/sky.md +26 -9
- package/dist/docs-src/guide/source-bundles.md +0 -1
- package/dist/docs-src/guide/structure-library.md +20 -10
- package/dist/docs-src/guide/terrain.md +51 -6
- package/dist/docs-src/guide/vehicles.md +27 -14
- package/dist/docs-src/guide/worldgen.md +34 -24
- package/dist/docs-src/llms.txt +35 -18
- package/dist/docs-src/schemas/README.md +4 -1
- package/dist/docs-src/schemas/archive-set.md +175 -0
- package/dist/docs-src/schemas/components.md +1104 -1
- package/dist/docs-src/schemas/matgraph.md +6 -0
- package/dist/docs-src/schemas/soundbank.md +251 -0
- package/dist/docs-src/schemas/structure-placements.md +496 -0
- package/dist/docs-src/schemas/terrain-package.md +120 -0
- package/dist/index.d.mts +31 -3
- package/dist/index.mjs +2 -2
- package/dist/{mcp-BFnCWrg0.mjs → mcp-BTVwVKFb.mjs} +78 -4
- package/dist/{ops-BGxhSP6w.mjs → ops-BPdHodFR.mjs} +1181 -61
- package/dist/templates/city-courier/README.md +66 -0
- package/dist/templates/city-courier/checks.json +20 -0
- package/dist/templates/city-courier/commands.json +32 -0
- package/dist/templates/city-courier/delivery-run.replay.json +214 -0
- package/dist/templates/city-courier/gen/molen-types.ts +1016 -0
- package/dist/templates/city-courier/index.html +2 -0
- package/dist/templates/city-courier/package.json +26 -0
- package/dist/templates/city-courier/project.json +8 -0
- package/dist/templates/city-courier/scene.json +3474 -0
- package/dist/templates/city-courier/scripts/game.ts +131 -0
- package/dist/templates/city-courier/scripts/molen-scripts.d.ts +1288 -0
- package/dist/templates/city-courier/scripts/tsconfig.json +16 -0
- package/dist/templates/city-courier/src/audio.ts +96 -0
- package/dist/templates/city-courier/src/game-shell.css +317 -0
- package/dist/templates/city-courier/src/main.ts +84 -0
- package/dist/templates/city-courier/src/scene.ts +17 -0
- package/dist/templates/city-courier/src/vite-env.d.ts +1 -0
- package/dist/templates/city-courier/src/worker.ts +5 -0
- package/dist/templates/city-courier/test/headless.test.ts +95 -0
- package/dist/templates/city-courier/test/playthrough.test.js +52 -0
- package/dist/templates/city-courier/test/replay.test.ts +22 -0
- package/dist/templates/city-courier/tsconfig.json +17 -0
- package/dist/templates/city-courier/vite.config.ts +19 -0
- package/dist/templates/cubes/README.md +51 -0
- package/dist/templates/cubes/index.html +16 -0
- package/dist/templates/cubes/package.json +24 -0
- package/dist/templates/cubes/scene.json +15 -0
- package/dist/templates/cubes/src/cubes.ts +100 -0
- package/dist/templates/cubes/src/main.ts +21 -0
- package/dist/templates/cubes/src/worker.ts +15 -0
- package/dist/templates/cubes/test/headless.test.ts +98 -0
- package/dist/templates/cubes/tsconfig.json +17 -0
- package/dist/templates/cubes/vite.config.ts +17 -0
- package/dist/templates/data-viz/README.md +47 -0
- package/dist/templates/data-viz/camera-track.json +12 -0
- package/dist/templates/data-viz/data.json +9 -0
- package/dist/templates/data-viz/index.html +16 -0
- package/dist/templates/data-viz/package.json +25 -0
- package/dist/templates/data-viz/scene.json +7 -0
- package/dist/templates/data-viz/src/main.ts +39 -0
- package/dist/templates/data-viz/src/viz.ts +91 -0
- package/dist/templates/data-viz/src/worker.ts +12 -0
- package/dist/templates/data-viz/test/headless.test.ts +75 -0
- package/dist/templates/data-viz/tsconfig.json +17 -0
- package/dist/templates/data-viz/vite.config.ts +16 -0
- package/dist/templates/figures-gallery/README.md +46 -0
- package/dist/templates/figures-gallery/index.html +16 -0
- package/dist/templates/figures-gallery/package.json +25 -0
- package/dist/templates/figures-gallery/scene.json +276 -0
- package/dist/templates/figures-gallery/src/main.ts +44 -0
- package/dist/templates/figures-gallery/src/worker.ts +17 -0
- package/dist/templates/figures-gallery/test/headless.test.ts +90 -0
- package/dist/templates/figures-gallery/tsconfig.json +17 -0
- package/dist/templates/figures-gallery/vite.config.ts +17 -0
- package/dist/templates/index.json +191 -0
- package/dist/templates/skybound/README.md +66 -0
- package/dist/templates/skybound/checks.json +24 -0
- package/dist/templates/skybound/commands.json +32 -0
- package/dist/templates/skybound/first-leap.replay.json +224 -0
- package/dist/templates/skybound/gen/molen-types.ts +1016 -0
- package/dist/templates/skybound/index.html +2 -0
- package/dist/templates/skybound/package.json +26 -0
- package/dist/templates/skybound/project.json +8 -0
- package/dist/templates/skybound/scene.json +1777 -0
- package/dist/templates/skybound/scripts/game.ts +122 -0
- package/dist/templates/skybound/scripts/molen-scripts.d.ts +1288 -0
- package/dist/templates/skybound/scripts/tsconfig.json +16 -0
- package/dist/templates/skybound/src/audio.ts +96 -0
- package/dist/templates/skybound/src/game-shell.css +317 -0
- package/dist/templates/skybound/src/main.ts +63 -0
- package/dist/templates/skybound/src/scene.ts +17 -0
- package/dist/templates/skybound/src/vite-env.d.ts +1 -0
- package/dist/templates/skybound/src/worker.ts +5 -0
- package/dist/templates/skybound/test/headless.test.ts +124 -0
- package/dist/templates/skybound/test/playthrough.test.js +38 -0
- package/dist/templates/skybound/test/replay.test.ts +22 -0
- package/dist/templates/skybound/tsconfig.json +17 -0
- package/dist/templates/skybound/vite.config.ts +19 -0
- package/dist/templates/terrain-flyover/README.md +46 -0
- package/dist/templates/terrain-flyover/index.html +16 -0
- package/dist/templates/terrain-flyover/package.json +26 -0
- package/dist/templates/terrain-flyover/src/flyover.ts +23 -0
- package/dist/templates/terrain-flyover/src/main.ts +93 -0
- package/dist/templates/terrain-flyover/terrain.json +15 -0
- package/dist/templates/terrain-flyover/test/headless.test.ts +72 -0
- package/dist/templates/terrain-flyover/tsconfig.json +17 -0
- package/dist/templates/terrain-flyover/vite.config.ts +15 -0
- package/dist/templates/top-down-arena/README.md +65 -0
- package/dist/templates/top-down-arena/arena-skirmish.replay.json +204 -0
- package/dist/templates/top-down-arena/index.html +16 -0
- package/dist/templates/top-down-arena/package.json +26 -0
- package/dist/templates/top-down-arena/project.json +10 -0
- package/dist/templates/top-down-arena/scene.json +182 -0
- package/dist/templates/top-down-arena/scripts/chase.ts +17 -0
- package/dist/templates/top-down-arena/scripts/combat.ts +13 -0
- package/dist/templates/top-down-arena/scripts/control.ts +8 -0
- package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +1258 -0
- package/dist/templates/top-down-arena/scripts/spawner.ts +11 -0
- package/dist/templates/top-down-arena/scripts/tsconfig.json +16 -0
- package/dist/templates/top-down-arena/src/arena.ts +8 -0
- package/dist/templates/top-down-arena/src/audio.ts +96 -0
- package/dist/templates/top-down-arena/src/gen/molen-types.ts +1020 -0
- package/dist/templates/top-down-arena/src/main.ts +34 -0
- package/dist/templates/top-down-arena/src/scene.ts +24 -0
- package/dist/templates/top-down-arena/src/vite-env.d.ts +1 -0
- package/dist/templates/top-down-arena/src/worker.ts +7 -0
- package/dist/templates/top-down-arena/test/headless.test.ts +87 -0
- package/dist/templates/top-down-arena/test/replay.test.ts +22 -0
- package/dist/templates/top-down-arena/tsconfig.json +17 -0
- package/dist/templates/top-down-arena/types/arena.types.json +54 -0
- package/dist/templates/top-down-arena/vite.config.ts +21 -0
- package/package.json +14 -14
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
# Earth view
|
|
2
|
+
|
|
3
|
+
`@bendyline/molen-earth` turns a canvas into an explorable real-world 3D view with one call. It
|
|
4
|
+
composes:
|
|
5
|
+
|
|
6
|
+
- streamed terrain from a `molen/terrain-package@1`;
|
|
7
|
+
- worldgen buildings, street surfaces, trees and parked cars from content packs;
|
|
8
|
+
- orbit, walk and drive navigation;
|
|
9
|
+
- markers placed by latitude/longitude;
|
|
10
|
+
- sky, haze and adaptive quality.
|
|
11
|
+
|
|
12
|
+
You speak latitude and longitude; the view keeps its metric world frame internally.
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import {
|
|
16
|
+
loadEarthContent,
|
|
17
|
+
mountEarthView,
|
|
18
|
+
openPacksFromIndex,
|
|
19
|
+
} from '@bendyline/molen-earth/client';
|
|
20
|
+
|
|
21
|
+
const manifestUrl = new URL('/terrain/terrain-package.json', location.href);
|
|
22
|
+
const terrain = await (await fetch(manifestUrl)).json();
|
|
23
|
+
const content = await loadEarthContent(await openPacksFromIndex('/packs/index.json'));
|
|
24
|
+
|
|
25
|
+
canvas.tabIndex = 0;
|
|
26
|
+
const view = await mountEarthView({
|
|
27
|
+
canvas,
|
|
28
|
+
terrain,
|
|
29
|
+
baseUrl: manifestUrl,
|
|
30
|
+
content,
|
|
31
|
+
camera: { latitude: 47.6205, longitude: -122.3493, range: 1500, heading: 0.8, pitch: 0.55 },
|
|
32
|
+
workers: {
|
|
33
|
+
elevation: () => new Worker(new URL('./elevation.worker.ts', import.meta.url), { type: 'module' }),
|
|
34
|
+
worldgen: () => new Worker(new URL('./worldgen.worker.ts', import.meta.url), { type: 'module' }),
|
|
35
|
+
},
|
|
36
|
+
touchJoystickContainer: canvas.parentElement ?? undefined,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
view.setMarkers([{ id: 'needle', latitude: 47.6205, longitude: -122.3493, image: pinCanvas }]);
|
|
40
|
+
view.on('markerclick', ({ id }) => openArticle(id));
|
|
41
|
+
view.on('camerachange', (camera) => syncMap(camera.latitude, camera.longitude));
|
|
42
|
+
creditsElement.textContent = view.credits.map((credit) => credit.label).join(' · ');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Each worker file is one line, for example `import '@bendyline/molen-earth/workers/elevation';`.
|
|
46
|
+
There are entries for `elevation`, `landcover`, `surface`, `worldgen` and `material`. Any worker
|
|
47
|
+
you omit does its work on the main thread instead.
|
|
48
|
+
|
|
49
|
+
Buildings appear with vertex colors while shared material textures bake in the background.
|
|
50
|
+
Completed textures update the existing materials without regenerating buildings. Terrain detail
|
|
51
|
+
refines in small groups, retaining visible detail during camera turns while replacements load.
|
|
52
|
+
|
|
53
|
+
Metal and glass use a shared procedural sky/ground reflection environment by default. The viewer
|
|
54
|
+
reuses its filtered texture until lighting changes; camera movement does not regenerate it.
|
|
55
|
+
Pass `reflections: false` for the legacy light-only appearance. A host-assigned
|
|
56
|
+
`view.viewer.renderer.scene.environment` takes precedence if you supply your own HDR environment.
|
|
57
|
+
|
|
58
|
+
`touchJoystickContainer` adds an on-screen movement stick while walking or driving. By default it
|
|
59
|
+
appears only on touch devices; pass `touchJoystick: 'always'` to show it everywhere.
|
|
60
|
+
|
|
61
|
+
## Modes
|
|
62
|
+
|
|
63
|
+
- **orbit** (default): the map camera from [camera navigation](navigation.md). `flyTo(target)`
|
|
64
|
+
animates and `jumpTo(target)` moves at once. The target takes `latitude`, `longitude`, and
|
|
65
|
+
optionally `range` in meters, `heading` (a compass bearing in radians) and `pitch` (radians of
|
|
66
|
+
tilt below the horizon).
|
|
67
|
+
- **walk**: `setMode('walk')` drops a walker at the view center. It has capsule collision against
|
|
68
|
+
terrain, buildings and props, WASD or the touch stick to move, mouse-look with pointer lock, and
|
|
69
|
+
Space to jump.
|
|
70
|
+
- **drive**: while walking, press E (or `setMode('drive')`) next to a parked car to get in. W/S
|
|
71
|
+
drive, A/D steer, Space brakes, V switches between cockpit and chase views, and E gets out. Cars
|
|
72
|
+
come from the entities content pack. `message` events explain when entering or leaving is
|
|
73
|
+
blocked, for example "Move closer to the door".
|
|
74
|
+
|
|
75
|
+
Listen for `modechange`. The input profile, clip planes and touch stick follow the mode
|
|
76
|
+
automatically.
|
|
77
|
+
|
|
78
|
+
## Frames and long trips
|
|
79
|
+
|
|
80
|
+
Heights stay in meters. Horizontal distances are exact at the frame latitude and drift by about
|
|
81
|
+
1–1.5% per degree away from it (see [terrain](terrain.md)). The view anchors its frame at the
|
|
82
|
+
starting latitude. After a `flyTo` of more than about a degree north or south, or after panning
|
|
83
|
+
that far, it re-anchors: it rebuilds the terrain stack in a new frame at the destination while
|
|
84
|
+
keeping the viewer, input and markers. With `terrainSource`, a longitude-only trip also checks
|
|
85
|
+
the destination's terrain region. `stats().frameLatitude` reports the current anchor.
|
|
86
|
+
|
|
87
|
+
## Content and packages
|
|
88
|
+
|
|
89
|
+
Without `content` the view still draws terrain, water, roads and extruded buildings. Content packs
|
|
90
|
+
add styled architecture, recognizable businesses, street furniture, trees and drivable cars:
|
|
91
|
+
|
|
92
|
+
- `openPacksFromIndex(indexUrl)` opens `molen.entities`, `molen.worldgen.default`, `molen.earth`,
|
|
93
|
+
`molen.sky` and `molen.sounds` from a pack index you host.
|
|
94
|
+
- `loadEarthContent(packs)` reads them. A missing pack turns its feature off instead of failing.
|
|
95
|
+
|
|
96
|
+
`openPacksFromIndex(indexUrl, ids, fetchImpl)` accepts a host fetch implementation for the index,
|
|
97
|
+
archive opening and subsequent asset requests. Landmark model bytes are loaded as nearby
|
|
98
|
+
placements need them. Large packs require HTTP Range support to retrieve those bytes selectively:
|
|
99
|
+
serve range requests with `206 Partial Content` and a correct `Content-Range` header (expose that
|
|
100
|
+
header through CORS when hosting across origins). A server returning `200 OK` for a range request
|
|
101
|
+
uses the compatible whole-file fallback, which downloads the entire archive before models can
|
|
102
|
+
load. Packs below the small-pack threshold are intentionally fetched in one request.
|
|
103
|
+
|
|
104
|
+
The world-explorer sample builds the worldgen collection as a small style core plus regional
|
|
105
|
+
model archives. All material graphs, style documents, asset sidecars and catalogs remain in
|
|
106
|
+
`molen.worldgen.default`. Its `model-archives` document routes the existing model paths to
|
|
107
|
+
deterministic geohash2 archives, split at a256MiB source-byte budget. Larger individual models
|
|
108
|
+
use isolated archives with a hard512MiB limit. Generic models without a geographic anchor use
|
|
109
|
+
separate shared archives. The public documentation site uses the same builder and route format.
|
|
110
|
+
The build reads and compresses one shard at a time, avoiding the ZIP32 size limit and the
|
|
111
|
+
memory cost of assembling the whole world's models in one archive.
|
|
112
|
+
|
|
113
|
+
`openPacksFromIndex` recognizes the routing document automatically. It opens no regional archive
|
|
114
|
+
until a model is requested, sends its range requests through the same host `fetchImpl`, and
|
|
115
|
+
checks the archive identity and content hash plus each model's SHA-256. Seattle placements
|
|
116
|
+
therefore do not open Chicago's archives. Archive opens are deduplicated; failed opens can be
|
|
117
|
+
retried; idle archive handles and their byte caches are evicted after four open archives.
|
|
118
|
+
Active reads remain pinned. `content.packs.close()` aborts reads and closes all regional handles.
|
|
119
|
+
This is independent of the viewer's GPU model residency and tile unloading.
|
|
120
|
+
|
|
121
|
+
Existing monolithic packs work unchanged. Hosts opening cores from offline storage can call
|
|
122
|
+
`withModelArchives(core, async (id, contentHash, signal) => openYourPack(id, contentHash, signal))`
|
|
123
|
+
before `loadEarthContent`; its optional `maxOpenArchives` controls the idle cache. The wrapper's
|
|
124
|
+
manifest describes the physical core, while `has`, `paths` and reads also expose explicitly
|
|
125
|
+
routed model paths. Ordinary `pack:molen.worldgen.default/...` references continue to resolve.
|
|
126
|
+
The builder publishes the index after all shards and keeps old hash-named archives for viewers
|
|
127
|
+
already using them; deployment storage may retire those versions after its cache lifetime.
|
|
128
|
+
|
|
129
|
+
The terrain package can reference split archive families (`pmtiles-set` sources), or you can pass
|
|
130
|
+
your own transports as `archives.elevation`, `archives.landcover` and `archives.features`. That is
|
|
131
|
+
how a host routes tiles through offline packs or a retrying reader.
|
|
132
|
+
|
|
133
|
+
For a viewer that can travel between separately hosted regions, provide `terrainSource` instead
|
|
134
|
+
of a fixed `terrain`. Molen calls it for the initial camera and after geographic travel. The host
|
|
135
|
+
returns a package manifest plus URLs or archive transports; Molen replaces the terrain stream,
|
|
136
|
+
semantic layers, and local frame while keeping the viewer and navigation alive. A stable `key`
|
|
137
|
+
identifies a region, so returning the same key for a nearby move keeps its resident tiles.
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
const view = await mountEarthView({
|
|
141
|
+
canvas,
|
|
142
|
+
content,
|
|
143
|
+
camera: { latitude: 47.6205, longitude: -122.3493, range: 1500 },
|
|
144
|
+
terrainSource: async ({ latitude, longitude }, signal) => {
|
|
145
|
+
const region = chooseRegion(latitude, longitude);
|
|
146
|
+
const url = new URL(`/terrain/${region}/terrain-package.json`, location.href);
|
|
147
|
+
const response = await fetch(url, { signal });
|
|
148
|
+
if (!response.ok) throw new Error(`Terrain ${region}: HTTP ${response.status}`);
|
|
149
|
+
return { key: region, terrain: await response.json(), baseUrl: url };
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The host can return `archives` in the result to fetch tiles from its own PMTiles service. Keep
|
|
155
|
+
pack attribution visible through `view.credits`, which follows the active terrain source. Listen
|
|
156
|
+
for `terrainchange` to refresh an attribution panel when the package changes. Direct jumps and
|
|
157
|
+
completed flights resolve the destination immediately; manual panning rechecks the host source
|
|
158
|
+
after about five kilometers. A second jump while a region is loading follows the latest target.
|
|
159
|
+
|
|
160
|
+
## Geographic structures and regional styles
|
|
161
|
+
|
|
162
|
+
The Earth pack may provide a `molen/structure-placements@1` document. Each record binds a
|
|
163
|
+
WGS84 `[longitude, latitude]` anchor to an asset ID from the style pack, with an optional
|
|
164
|
+
heading, scale, terrain or sea-level datum, and minimum tile level. The Earth viewer loads the
|
|
165
|
+
catalog with the packs, indexes it by three-character geohash, and draws each `preview` model
|
|
166
|
+
in the terrain tile containing its anchor. `draft` records remain queryable but are not drawn.
|
|
167
|
+
Long structures may supply `bounds: [west, south, east, north]`. Their extent is indexed across
|
|
168
|
+
geohash cells and geometry is clipped to each resident tile, so a bridge end stays visible when
|
|
169
|
+
its center is outside the view. Extended structures use either `datum: 'sea-level'` with an
|
|
170
|
+
absolute `elevation`, or a `terrainReference` with the host sampler described below. Every
|
|
171
|
+
tile must resolve the same model origin, avoiding inconsistent ground samples between tiles.
|
|
172
|
+
`replaceRoads: { length, width, deckHeight?, deckHeights? }` describes a model-local rectangle along +X:
|
|
173
|
+
mapped parallel bridge lines inside it are replaced only after the model loads successfully.
|
|
174
|
+
Outside approach fragments remain procedural. `deckHeight` joins those approaches to the
|
|
175
|
+
model's deck height above its origin, blending back over 100 m; include that margin in `bounds`.
|
|
176
|
+
For sloped decks, use `deckHeights: [negativeXEnd, positiveXEnd]` instead of `deckHeight`.
|
|
177
|
+
Both heights are native model Y and follow the model's Y scale, resolved origin and heading.
|
|
178
|
+
These joins apply to remaining bridge-tagged road fragments, not unrelated ground roads.
|
|
179
|
+
Skewed or curved structures may add `replaceRoads.outline: [[x, z], ...]`, a simple native
|
|
180
|
+
footprint polygon. It replaces the rectangle for suppression, including concave bends;
|
|
181
|
+
parallel road segments outside it remain intact. `length` still locates the two connection
|
|
182
|
+
stations at native X=-length/2 and X=+length/2, Z=0, and `deckHeights` keeps that endpoint order.
|
|
183
|
+
Sunken structures can declare `groundCutout: { outline: [[x, z], ...], basis: 'source evidence' }` on a placement. The simple polygon uses native model metres and follows the same heading and scale as the model. It should bound the ground opening covered by the authored concourse or rim. The terrain pyramid subtracts the polygon from actual elevation and draped ground triangles across tile and LOD boundaries, preserving interpolated heights and surface attributes along its edge. The cutout becomes active only when its successfully loaded structure is visible, and the original ground returns on layer hiding or eviction. Failed or cancelled models leave the ground intact. Heights remain available for anchoring; an opening does not itself author walkable floors or collision.
|
|
184
|
+
|
|
185
|
+
### Bridge elevations and terrain fit
|
|
186
|
+
|
|
187
|
+
With the default `datum: 'terrain'`, a placement's origin Y is the sampled terrain height at
|
|
188
|
+
`anchor` plus `elevation` (default zero). That works for a model authored with its ground contact
|
|
189
|
+
at Y=0. A bridge authored from a riverbed or buried foundation needs a corresponding reference:
|
|
190
|
+
a coarse elevation grid may contain the road surface or smooth the gorge across several pixels.
|
|
191
|
+
Increasing tile zoom cannot recover relief absent from the source elevation data.
|
|
192
|
+
|
|
193
|
+
For a measured model origin, use `datum: 'sea-level'` and set `elevation` to its absolute height
|
|
194
|
+
in the same vertical reference as the host terrain. This bypasses terrain sampling and gives every
|
|
195
|
+
clipped portion of a long bridge the same vertical position. The name `sea-level` selects the
|
|
196
|
+
world's absolute Y frame; it does not convert between EGM96, EGM2008, a local survey datum or an
|
|
197
|
+
ellipsoidal height. The host must perform that conversion before providing the value.
|
|
198
|
+
|
|
199
|
+
For a terrain placement referenced to another point, add
|
|
200
|
+
`terrainReference: { anchor: [longitude, latitude], modelHeight, basis }`. For example, a bank
|
|
201
|
+
at native Y=8 uses `modelHeight: 8`; the model origin becomes the reference elevation minus
|
|
202
|
+
`modelHeight * scaleY`, plus `elevation`. Record the source and meaning of that point in `basis`.
|
|
203
|
+
This field is incompatible with `datum: 'sea-level'`.
|
|
204
|
+
|
|
205
|
+
Hosts can supply `sampleStructureTerrain(coordinate, { entry, signal })` to `mountEarthView`,
|
|
206
|
+
`createEarthWorldgen`, or `createWorldgenSemanticRenderers`. It may return a height or a promise
|
|
207
|
+
and must use the same world height reference as the rendered terrain. Resolve the coordinate
|
|
208
|
+
from its own terrain tile or a surveyed source; honor `signal` when fetching. Returning
|
|
209
|
+
`undefined` means coverage is unavailable: the model remains unloaded and procedural map
|
|
210
|
+
features remain visible. Absolute placements bypass this callback. Without a host callback,
|
|
211
|
+
the renderer samples only a reference inside the current tile, never its clamped edge.
|
|
212
|
+
An extended terrain structure (`bounds` plus `terrainReference`) requires this host callback;
|
|
213
|
+
without it, all its model pieces remain deferred and their procedural fallback stays visible.
|
|
214
|
+
The callback must resolve the same reference height for every clipped tile. A bank reference
|
|
215
|
+
therefore also works when the landmark anchor lies over unknown river elevation cells.
|
|
216
|
+
For loaded terrain, the pyramid stream's `sampleHeight` searches covering resident tiles
|
|
217
|
+
and returns `undefined` when none covers the point. A host that requires guaranteed cross-tile
|
|
218
|
+
references should retrieve those source tiles independently of the current visible tile set.
|
|
219
|
+
|
|
220
|
+
Check the approaches and channel in addition to the model origin. A bridge may have the correct
|
|
221
|
+
height while a host's elevation data still fails to represent its banks. Supply better local
|
|
222
|
+
elevation data through the terrain archives for that case. The reference hook changes model
|
|
223
|
+
placement; it does not modify a smoothed river channel. A `groundCutout` removes covered terrain
|
|
224
|
+
but does not reconstruct riverbanks, water levels, or a riverbed. The source repository includes a
|
|
225
|
+
repeatable real-terrain review: `build-bridge-terrain-evidence.mjs` preserves original Terrarium
|
|
226
|
+
samples, and `test/visual/capture-bridge-terrain.mjs` in the world-explorer example uses the
|
|
227
|
+
production terrain mesher and structure renderer, records approach ray measurements, and checks
|
|
228
|
+
model eviction. `build-copernicus-bridge-evidence.py` and the capture runner's
|
|
229
|
+
`--terrain-set=copernicus` option preserve a separate comparison with Copernicus elevations;
|
|
230
|
+
neither capture set substitutes altered heights to make a bridge fit. These reports are research
|
|
231
|
+
evidence and are excluded from the Earth runtime pack.
|
|
232
|
+
|
|
233
|
+
If `replaceFootprint` is set, a nongeneralized mapped building is suppressed only when the
|
|
234
|
+
anchor falls inside its polygon and the replacement model has loaded. Failed models keep the
|
|
235
|
+
procedural building. An Earth pack without a placement document still loads.
|
|
236
|
+
|
|
237
|
+
For unsurveyed orientation, `orientation: 'mapped'` requires an explicit
|
|
238
|
+
`mapIdentity: { wikidata: 'Q…', maxDistance: 150 }`. The viewer admits that model only after a
|
|
239
|
+
nearby matching building, directed POI, or bridge supplies an orientation. Exact name aliases
|
|
240
|
+
are supported only when the catalog supplies no Wikidata ID. A footprint's longest edge gives
|
|
241
|
+
an undirected axis, not proof of the entrance direction. `lengthAxis: 'x' | 'z'` identifies the
|
|
242
|
+
authored longitudinal axis. Entries with surveyed catalog headings use `orientation: 'fixed'`
|
|
243
|
+
(the default). No matching geometry means no speculative placement for a mapped entry.
|
|
244
|
+
|
|
245
|
+
### Reusable mapped categories
|
|
246
|
+
|
|
247
|
+
An Earth pack can list multiple `provides.structures` documents. Alongside geographic `entries`,
|
|
248
|
+
each document may contain `rules` for deliberately generic assets. The shipped
|
|
249
|
+
`structures/map-rules.json` recognizes windmills and wind turbines from class, subclass, or
|
|
250
|
+
explicit map tags. Unique named landmarks never become arbitrary category replacements.
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"id": "generic.windmill",
|
|
255
|
+
"title": "Smock windmill",
|
|
256
|
+
"asset": "molen.worldgen.structure.map_smock_windmill",
|
|
257
|
+
"match": { "classes": ["windmill"] },
|
|
258
|
+
"dimensions": [23.3, 30.6, 16.5],
|
|
259
|
+
"orientation": "direction",
|
|
260
|
+
"fit": "native",
|
|
261
|
+
"minLevel": 14,
|
|
262
|
+
"maxPerTile": 16,
|
|
263
|
+
"source": "https://wiki.openstreetmap.org/wiki/Tag:man_made%3Dwindmill"
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Match fields are AND conditions; the values within a field are alternatives. Put separate
|
|
268
|
+
rules in priority order for alternative source schemas. `dimensions` are authored X/Y/Z meters
|
|
269
|
+
with the base at Y=0 and front along +Z. `fit: 'footprint'` fits horizontal dimensions to a
|
|
270
|
+
confirmed nongeneralized building; `native` retains authored proportions. Measured heights
|
|
271
|
+
uniformly scale native models, bounded from 0.2 to 5 times native dimensions; footprint fitting
|
|
272
|
+
adjusts the three dimensions independently. Explicit source `direction`
|
|
273
|
+
or compass bearings take priority; otherwise footprints use their longest axis and points
|
|
274
|
+
default north. This default is an estimate, especially for rotatable turbine nacelles.
|
|
275
|
+
Rules with `replaceFootprint: true` can also replace a nongeneralized footprint containing a
|
|
276
|
+
matching POI, after the asset loads. This is useful when a windmill is a POI plus an unclassified
|
|
277
|
+
building outline; the default leaves point features independent of building shells.
|
|
278
|
+
|
|
279
|
+
The renderer admits at most 64 category models per tile and obeys each rule's smaller budget.
|
|
280
|
+
It owns points with half-open tile bounds, deduplicates building/POI pairs and nearby named
|
|
281
|
+
landmarks, samples terrain at each model base, and releases shared model resources on tile
|
|
282
|
+
eviction. Rules require source classification evidence: a cafe with “Windmill” in its name is
|
|
283
|
+
not a windmill. Providers that omit POIs, classifications, or structure tags cannot imply that
|
|
284
|
+
object. The semantic decoder preserves public structure tags and Wikidata IDs when supplied.
|
|
285
|
+
|
|
286
|
+
`content.worldgen.structures.query([west, south, east, north])` returns preview placements in a
|
|
287
|
+
geographic rectangle. Pass `true` as the second argument to include drafts. The default
|
|
288
|
+
catalog and its source notes live in `content/earth/structures/placements.json` in the engine
|
|
289
|
+
repository. Named model sources and previews live in
|
|
290
|
+
`content/worldgen/source/places/<gh2>/<gh3>/<source-key>/`; imported runtime bundles mirror
|
|
291
|
+
that organization under `content/worldgen/assets/places/<gh2>/<gh3>/<source-key>/`.
|
|
292
|
+
Each runtime bundle contains `asset.json`, `model.glb`, and any collision data. Reusable models
|
|
293
|
+
use `assets/reusable/urban/<source-key>/`, `assets/reusable/infrastructure/<source-key>/`, or
|
|
294
|
+
`assets/reusable/map-structures/<source-key>/`. The two geographic folders are geohashes of
|
|
295
|
+
length two and three. New named entries without an organizational anchor start in `places/unlocated/`.
|
|
296
|
+
|
|
297
|
+
`content/worldgen/source/structure-index.json` resolves source keys to authoring directories.
|
|
298
|
+
The runtime mappings are separate: `content/worldgen/project.json` registers stable asset IDs
|
|
299
|
+
to sidecars for tooling, and `content/worldgen/stylepack.json` registers the same IDs for pack
|
|
300
|
+
resolution through `stylePackAssetIndex`. Asset IDs remain unchanged when folders move;
|
|
301
|
+
hosts resolve these mappings instead of deriving a model URL from the dotted ID. Folder
|
|
302
|
+
reference coordinates organize files and do not approve or activate geographic placement.
|
|
303
|
+
The terrain stream queries only cells intersecting resident tiles. Chicago models are not fetched
|
|
304
|
+
while viewing Seattle; a structure model is released from CPU and GPU memory when the last tile
|
|
305
|
+
using it leaves view. Returning to the area loads it again. Draft entries never fetch models.
|
|
306
|
+
|
|
307
|
+
Historical reconstructions use `status: 'historical'` and an `appearance` record:
|
|
308
|
+
|
|
309
|
+
```json
|
|
310
|
+
{
|
|
311
|
+
"kind": "historical",
|
|
312
|
+
"currentWorldEligible": false,
|
|
313
|
+
"representedDate": "1930",
|
|
314
|
+
"validFrom": "1926-01-06",
|
|
315
|
+
"validUntil": "1934-04-01"
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
They remain unloaded in the default view. A host explicitly passes `viewingDate: '1930-01-01'`
|
|
320
|
+
to `mountEarthView`, `createEarthWorldgen`, or `createWorldgenSemanticRenderers` to include
|
|
321
|
+
historical assets for that day. The lower-level index accepts
|
|
322
|
+
`query(bounds, { viewingDate: '1930-01-01' })`. Dates must be valid `YYYY-MM-DD` calendar dates;
|
|
323
|
+
the first bound is inclusive and the last is exclusive. Date selection is independent of the
|
|
324
|
+
system clock and sky simulation. Remount the viewer to change it. Historical assets retain
|
|
325
|
+
geographic tile filtering, deferred loading, fallback on failed loads, and eviction cleanup.
|
|
326
|
+
|
|
327
|
+
This option selects dated landmark appearances. Hosts supply matching historical PMTiles and
|
|
328
|
+
terrain when needed; undated present-day map features and preview landmarks have no inferred
|
|
329
|
+
historical lifetime. For source authoring, combine `appearance` with a
|
|
330
|
+
`geographicProposal.status: 'historical-proposal'` and the usual reviewed ground contact and
|
|
331
|
+
placement evidence. Older historical sources without a complete supported date interval remain
|
|
332
|
+
drafts. Shared placement QA uses `capture-landmark-library.mjs --viewing-date=1930-01-01` and
|
|
333
|
+
records the explicit date in its hash-bound report.
|
|
334
|
+
|
|
335
|
+
Geographic and category models use `StructureModelLibrary`, preserving the authored mesh
|
|
336
|
+
hierarchy, UV coordinates, texture maps, material assignments and PBR parameters. Instances
|
|
337
|
+
share those resources until the last reference is released. Long static models retain their
|
|
338
|
+
UVs, vertex attributes and material groups when clipped at tile edges; textures do not restart
|
|
339
|
+
at each seam. The library accepts static assets: skinned or animated structures require a host
|
|
340
|
+
animation implementation. Procedural scatter continues to use the separate instanced prop path.
|
|
341
|
+
|
|
342
|
+
### Shared architectural surfaces
|
|
343
|
+
|
|
344
|
+
Authored GLB materials can opt into the same texture library as procedural buildings. Set
|
|
345
|
+
the material's glTF `extras.molenSurface` (available as Three.js material `userData.molenSurface`):
|
|
346
|
+
|
|
347
|
+
```json
|
|
348
|
+
{
|
|
349
|
+
"ref": "matgraph:molen.worldgen.material.wood_painted_lap",
|
|
350
|
+
"slot": "wall",
|
|
351
|
+
"uv": "repeats"
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
`encodeGlb` exposes this as `GlbMaterialMeta.sharedSurface`. Author UV0 in texture repeats:
|
|
356
|
+
divide local surface coordinates in meters by the material's `repeatMeters` once during
|
|
357
|
+
authoring. Wood grain must follow the timber; masonry courses remain horizontal. Put color
|
|
358
|
+
variants in vertex colors with a white base-color factor, so white painted wood and green
|
|
359
|
+
painted wood share the same maps and material. Model-specific artwork and special PBR effects
|
|
360
|
+
keep their original unbound materials. GLBs retain portable fallback PBR materials for other
|
|
361
|
+
viewers and ordinary asset previews; the Earth viewer applies shared surfaces explicitly.
|
|
362
|
+
|
|
363
|
+
The default library has 65 procedural surfaces, including brick bonds, stone, timber, painted
|
|
364
|
+
wood, shingles, concrete, metal, plaster, glass and canvas. Its authoring catalog, physical
|
|
365
|
+
repeat sizes, tint variants, swatches and texture audit live in
|
|
366
|
+
`content/worldgen/source/material-library/` in the engine repository. Color variants do not
|
|
367
|
+
duplicate texture images. The current Earth viewer prepares the registered library after the
|
|
368
|
+
first frame and retains it until viewer disposal. Structure eviction releases model geometry
|
|
369
|
+
and private materials while preserving shared surfaces used by other structures. A separate
|
|
370
|
+
on-demand material eviction policy is not yet implemented.
|
|
371
|
+
|
|
372
|
+
Constant roughness and metalness channels use exact numeric factors instead of textures;
|
|
373
|
+
other maps retain their authored pixels. Across the full library this removes 58 texture
|
|
374
|
+
allocations, reducing estimated base-level RGBA8 texel storage from 45.75 to 31.25 MiB.
|
|
375
|
+
These are storage estimates, not measured driver allocations. Alpha-cutout surfaces retain
|
|
376
|
+
linear sampling without mip averaging so small perforations remain open.
|
|
377
|
+
|
|
378
|
+
Hosts composing their own renderer can supply `StructureModelLibrary` with
|
|
379
|
+
`resolveSurface: ({ ref, slot }) => materials.materialFor(slot, ref)` using a
|
|
380
|
+
`createResolvedMaterialSet` instance. Restrict references to the host's registered material
|
|
381
|
+
library and keep it alive until all structure libraries have been disposed. Missing bindings
|
|
382
|
+
or UVs preserve the GLB fallback. A new bake upgrades progressive materials in place without
|
|
383
|
+
rebuilding model geometry.
|
|
384
|
+
|
|
385
|
+
`StructureModelLibrary` preserves host ownership of decoded ImageBitmaps by default. Its
|
|
386
|
+
`ownsImageBitmaps: true` option explicitly transfers ownership, allowing unused
|
|
387
|
+
fallback images to close after shared-material replacement and remaining images to close
|
|
388
|
+
after their last scene is released. A per-scene predicate can transfer ownership selectively.
|
|
389
|
+
The built-in Earth loader opts in only when every image uses an embedded bufferView: these
|
|
390
|
+
decode through fresh blob URLs excluded from Three's cache. Scenes with URI/data-URI images
|
|
391
|
+
retain host ownership, including mixed scenes. A fresh parse alone does not establish ownership
|
|
392
|
+
of images that may come from an external cache.
|
|
393
|
+
|
|
394
|
+
Mapped roads with `bridge: true` receive solid decks, edge barriers and regularly spaced
|
|
395
|
+
supports in the shared terrain surface renderer, including its worker path. Road, rail and
|
|
396
|
+
pedestrian spans follow mapped centerlines and widths; tunnels are omitted. Complete spans
|
|
397
|
+
interpolate between bank heights and connect to adjoining ground roads. Clipped spans use
|
|
398
|
+
estimated terrain clearance (6 m for roads/rail, 3 m for paths); a semantic provider can set
|
|
399
|
+
`deckElevation` to an absolute surveyed height. These are visual approximations: tile data
|
|
400
|
+
does not establish bridge engineering type, navigation clearance, foundations or collision.
|
|
401
|
+
The SR-520 preview replaces the floating section; its approaches use this same fallback.
|
|
402
|
+
|
|
403
|
+
Regional procedural styles are separate from exact structures. The atlas's ordered rules use
|
|
404
|
+
mapped building class, footprint size, context, and known height to choose a style. A rule can
|
|
405
|
+
give weighted variants, sampled from a stable building identity, so a neighborhood has a
|
|
406
|
+
repeatable mix. `suggestStructureStyles(atlas, longitude, latitude, metrics)` from
|
|
407
|
+
`@bendyline/molen-worldgen-earth/kernel` exposes the matching weights and normalized shares for
|
|
408
|
+
inspection. The Pacific Northwest's unmeasured low-rise mix includes wood-sided PNW houses,
|
|
409
|
+
Craftsman, brick Prairie, and Ranch forms; Japan and broader regions have their own rules.
|
|
410
|
+
These regional forms are visual priors, not surveyed attributes of individual buildings.
|
|
411
|
+
|
|
412
|
+
## Credits, quality, lifecycle
|
|
413
|
+
|
|
414
|
+
- `view.credits` holds the package's required attributions, OpenStreetMap first with its link.
|
|
415
|
+
Keep them visible whenever the view is.
|
|
416
|
+
- `quality: 'auto'` adapts terrain budgets, building detail and pixel ratio to measured frame
|
|
417
|
+
times (`stats().qualityLevel`, 0-5). A preset pins the quality.
|
|
418
|
+
- `setPaused(true)` stops rendering while the view is hidden, and `dispose()` releases the GPU
|
|
419
|
+
context, workers and listeners. Mounting is abortable through `signal`.
|
|
420
|
+
|
|
421
|
+
## Sound
|
|
422
|
+
|
|
423
|
+
With the `molen.sounds` pack in `content`, the view plays the Earth soundscape: rain and wind
|
|
424
|
+
from the weather, birds by day and crickets at night, traffic near streets, footsteps while
|
|
425
|
+
walking, and an engine on the car or aircraft you board. Birds, crickets and traffic come from
|
|
426
|
+
the ground, so they fade as the view rises above the terrain and are gone a few hundred meters
|
|
427
|
+
up. Traffic also fades with distance from the nearest street. Sound starts on the first click or
|
|
428
|
+
key press. The `audioready` event fires once it has loaded, and then `view.audio` sets volume,
|
|
429
|
+
mute and bus gains (`view.audio.setBusGain('music', 0)` turns music off).
|
|
430
|
+
|
|
431
|
+
```ts
|
|
432
|
+
const view = await mountEarthView({ canvas, content, terrain, audio: { volume: 0.6, music: false } });
|
|
433
|
+
view.on('audioready', () => view.audio?.setMuted(localStorage.getItem('muted') === '1'));
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Pass `audio: false` to keep the view silent, or `audio: { environment }` to replace the rules.
|
|
437
|
+
The default rules are exported as `EARTH_AUDIO_ENVIRONMENT`, and `createEarthAudio` builds the
|
|
438
|
+
same soundscape for a host that composes its own view. See [Sound and music](audio.md) for the
|
|
439
|
+
rule format.
|
|
440
|
+
|
|
441
|
+
The composing pieces are exported too, for hosts that build their own view: `createEarthWorldgen`,
|
|
442
|
+
`EarthVehicles`, `createEarthSky`/`createEarthFog`, `createEarthAudio`, `earthPerformanceTier` and
|
|
443
|
+
`earthCredits`.
|
|
444
|
+
The [World Explorer](https://molen.dev/play/world-explorer/) sample is built from them.
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
# Reusable entities
|
|
2
2
|
|
|
3
|
-
The `molen.entities` content pack is
|
|
3
|
+
The `molen.entities` content pack is Molen's curated entity collection. It builds on the existing
|
|
4
4
|
`renderable.kind: "gltf"`, `molen/asset@1`, `molen/types@1`, and `molen/project@1` contracts;
|
|
5
5
|
there is no second entity or asset runtime.
|
|
6
6
|
|
|
7
7
|
The initial nature collection contains pine, fir, oak, birch, shrub, and boulder models under the
|
|
8
8
|
stable `molen.entities.*` namespace. Every model is a deterministic texture-free GLB with a
|
|
9
9
|
hash-verified sidecar, meter-scale bounds, a conservative collision hull, and a type definition.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
The npm package `@bendyline/molen-entities` carries only the id lists and helpers, no models or
|
|
11
|
+
type documents. Get the pack itself into a project with:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npx molen pack fetch https://molen.dev/packs/index.json molen.entities
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
That downloads the zip into `packs/` and pins it in project.json's `packs`, so `molen validate`,
|
|
18
|
+
`sim run` and the other ops resolve `molen.entities.*` types (`molen project info` lists them).
|
|
19
|
+
Serve the same zip with your app for the browser. The headless capture ops (`shot`, `drive`,
|
|
20
|
+
`frames`) draw only the models in the project's own `assets` today, so a pack model renders in the
|
|
21
|
+
browser through the asset provider below but not yet in a CLI capture. The pack's
|
|
22
|
+
source is [`content/entities/`](https://github.com/bendyline/molen/tree/main/content/entities) in
|
|
23
|
+
the engine repository, where its gallery scene is both an example and a headless render check.
|
|
13
24
|
|
|
14
25
|
Every concrete thing is authored as a [logical source bundle](source-bundles.md) under
|
|
15
|
-
`content/entities/source/<category>/<thing
|
|
26
|
+
[`content/entities/source/<category>/<thing>/`](https://github.com/bendyline/molen/tree/main/content/entities/source). Its local `source.json` inventories the definition,
|
|
16
27
|
model master or recipe, scripts, textures, sounds, and documentation. The package generator builds
|
|
17
28
|
the aggregate registry and gallery from those bundles; the aggregate files are compatibility and
|
|
18
29
|
runtime outputs, not a second authoring authority.
|
|
@@ -36,7 +47,7 @@ The entity type id and renderable asset ref are identical, such as
|
|
|
36
47
|
In code, read the documents the manifest `provides` as `types` and pass them to
|
|
37
48
|
`createTypeLibrary` from `@bendyline/molen-kernel/content`.
|
|
38
49
|
|
|
39
|
-
|
|
50
|
+
In the engine repository, run `molen asset list` in `content/entities`, `molen types check --project
|
|
40
51
|
content/entities/project.json`, or render `content/entities/scenes/gallery.scene.json` with
|
|
41
52
|
`molen shot`. The package generator is deterministic and its build fails when a checked-in GLB,
|
|
42
53
|
sidecar, types document, project, or gallery scene is stale.
|
|
@@ -1,33 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Samples gallery
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
one demo.
|
|
3
|
+
Every sample is simultaneously a browser demo and a headless regression test, and each one is
|
|
4
|
+
meant to be copied. Three ways in, none of which needs a clone of the engine repository:
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
- **Play** any sample in the browser at [molen.dev/play](https://molen.dev/play/).
|
|
7
|
+
- **Copy** a sample into your own npm project with `--template`. The templates ship inside
|
|
8
|
+
`@bendyline/molen-tooling`, locked to the engine version you install, so they work offline:
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
```sh
|
|
11
|
+
npx @bendyline/molen-tooling new my-game --template skybound
|
|
12
|
+
cd my-game && npm install && npm run dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`molen templates` lists them. A copy keeps whatever the sample has (scene, scripts, commands,
|
|
16
|
+
checks, replay fixture, headless tests), so `npx molen sim run`, `npx molen replay` and
|
|
17
|
+
`npm test` work in it straight away.
|
|
18
|
+
- **Read** the source on [GitHub](https://github.com/bendyline/molen/tree/main/examples).
|
|
19
|
+
|
|
20
|
+
| Sample | Shows | Play | Template |
|
|
12
21
|
|---|---|---|---|
|
|
13
|
-
| Cubes |
|
|
14
|
-
| Data viz |
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
| Figures gallery |
|
|
18
|
-
|
|
|
22
|
+
| Cubes | ~50 spinning/drifting cubes; a `spawn_cube` command; determinism across runs | [play](https://molen.dev/play/cubes/) | `cubes` |
|
|
23
|
+
| Data viz | data-driven entities (one per row) + a camera track | [play](https://molen.dev/play/data-viz/) | `data-viz` |
|
|
24
|
+
| Top-down arena | a complete small game as **pure data**: `scene.json` declares kinematics, the `move` command + WASD input, and four scripts (control/spawner/chaser/combat); no setup module | [play](https://molen.dev/play/top-down-arena/) | `top-down-arena` |
|
|
25
|
+
| Terrain flyover | chunked LOD terrain from a descriptor + deterministic 16-bit heightmap | [play](https://molen.dev/play/terrain-flyover/) | `terrain-flyover` |
|
|
26
|
+
| Figures gallery | a lineup of every figure preset, a body-type sweep, a hat on a head socket and a rider on a horse; `?walk=1` (or the `set_gait` command) animates the gaits in place | [play](https://molen.dev/play/figures-gallery/) | `figures-gallery` |
|
|
27
|
+
| Earth view | the [`mountEarthView`](earth-view.md) facade in one page: real Sammamish terrain, styled buildings, orbit / walk / drive with parked cars, a photo-pin marker and credits (`?mode=walk`, `?lat=&lon=&range=`) | [play](https://molen.dev/play/earth-view/) | [source](https://github.com/bendyline/molen/tree/main/examples/earth-view) |
|
|
28
|
+
| World explorer | streamed Web Mercator terrain with adaptive package LOD, bare / land-classification / human-feature modes, and styled buildings from the default worldgen pack (`?style=`, `?synthetic=1&lineup=1`) | [play](https://molen.dev/play/world-explorer/) | [source](https://github.com/bendyline/molen/tree/main/examples/world-explorer) |
|
|
19
29
|
|
|
20
30
|
## Playable game samples
|
|
21
31
|
|
|
22
32
|
[Three complete games, one authoring path](game-samples.md) explains the shared infrastructure.
|
|
23
33
|
|
|
24
|
-
| Game |
|
|
25
|
-
|
|
26
|
-
| City Courier |
|
|
27
|
-
| The Lantern Vault |
|
|
28
|
-
| Skybound |
|
|
34
|
+
| Game | Demonstrates | Play | Template |
|
|
35
|
+
|---|---|---|---|
|
|
36
|
+
| City Courier | Arcade driving, traffic, five deliveries, damage, a time limit and restart | [play](https://molen.dev/play/city-courier/) | `city-courier` |
|
|
37
|
+
| The Lantern Vault | First-person exploration, melee rolls, inventory, a locked gate and victory | [play](https://molen.dev/play/lantern-dungeon/) | [source](https://github.com/bendyline/molen/tree/main/examples/lantern-dungeon) |
|
|
38
|
+
| Skybound | Side-scrolling jumps, one-way ledges, seeds, stomps, hazards and checkpoints | [play](https://molen.dev/play/skybound/) | `skybound` |
|
|
39
|
+
|
|
40
|
+
Each includes a command-only victory regression (`test/playthrough.test.js`) that proves the game
|
|
41
|
+
is winnable without a browser.
|
|
29
42
|
|
|
30
|
-
|
|
43
|
+
World Explorer and The Lantern Vault are not templates. They carry content (terrain tiles and 28
|
|
44
|
+
GLB models), and npm packages never include content. Their scenes and code are still the best
|
|
45
|
+
reference for streaming and for a glTF asset pipeline, so read them on GitHub.
|
|
31
46
|
|
|
32
47
|
## Capability layers used
|
|
33
48
|
|
|
@@ -53,6 +68,7 @@ Each includes a command-only victory regression and a real-browser gameplay test
|
|
|
53
68
|
|
|
54
69
|
## Start from scratch
|
|
55
70
|
|
|
56
|
-
`molen new <name>` scaffolds a runnable experience (scene with
|
|
57
|
-
setup + commands + checks + a Vite browser app) that already
|
|
58
|
-
and mounts in a page ([browser-mount.md](browser-mount.md)).
|
|
71
|
+
`molen new <name>` without `--template` scaffolds a minimal runnable experience (scene with
|
|
72
|
+
camera/input/commands + scripts + setup + commands + checks + a Vite browser app) that already
|
|
73
|
+
runs the [agent loop](agent-loop.md) and mounts in a page ([browser-mount.md](browser-mount.md)).
|
|
74
|
+
Then iterate.
|
|
@@ -5,9 +5,8 @@ experience, performs player-like inputs, and leaves screenshots plus diagnostics
|
|
|
5
5
|
inspect.
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
--out-dir .artifacts/world-explorer
|
|
8
|
+
npm run build # your app's static build, e.g. Vite's dist/
|
|
9
|
+
npx molen play dist --scenario walkthrough.play.json --out-dir .artifacts/walkthrough
|
|
11
10
|
```
|
|
12
11
|
|
|
13
12
|
The host uses an ephemeral localhost port and supports HTTP byte ranges, so PMTiles and other
|