@bendyline/molen-tooling 0.0.3 → 0.0.4

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.
Files changed (46) hide show
  1. package/README.md +4 -4
  2. package/dist/capture/harness.js +222 -222
  3. package/dist/capture/worldgen-preview.js +205 -205
  4. package/dist/cli.mjs +54 -2
  5. package/dist/docs-src/guide/aircraft.md +12 -0
  6. package/dist/docs-src/guide/ambient-life.md +389 -0
  7. package/dist/docs-src/guide/browser-mount.md +5 -0
  8. package/dist/docs-src/guide/capability-authoring.md +5 -0
  9. package/dist/docs-src/guide/determinism.md +24 -16
  10. package/dist/docs-src/guide/earth-view.md +60 -12
  11. package/dist/docs-src/guide/entities.md +8 -0
  12. package/dist/docs-src/guide/examples.md +4 -1
  13. package/dist/docs-src/guide/figures.md +3 -0
  14. package/dist/docs-src/guide/game-samples.md +1 -1
  15. package/dist/docs-src/guide/markers.md +4 -1
  16. package/dist/docs-src/guide/navigation.md +6 -0
  17. package/dist/docs-src/guide/surface-rendering.md +4 -3
  18. package/dist/docs-src/guide/terrain.md +7 -0
  19. package/dist/docs-src/guide/vehicles.md +14 -1
  20. package/dist/docs-src/llms.txt +7 -4
  21. package/dist/docs-src/schemas/README.md +1 -0
  22. package/dist/docs-src/schemas/components.md +530 -1
  23. package/dist/docs-src/schemas/scene.md +105 -0
  24. package/dist/docs-src/schemas/transport-network.md +351 -0
  25. package/dist/index.d.mts +44 -1
  26. package/dist/index.mjs +81 -4
  27. package/dist/{mcp-BTVwVKFb.mjs → mcp-BtuworIW.mjs} +22 -1
  28. package/dist/{ops-BPdHodFR.mjs → ops-DMGcWoL2.mjs} +290 -65
  29. package/dist/templates/city-courier/README.md +1 -1
  30. package/dist/templates/city-courier/delivery-run.replay.json +151 -151
  31. package/dist/templates/city-courier/gen/molen-types.ts +82 -2
  32. package/dist/templates/city-courier/package.json +1 -0
  33. package/dist/templates/city-courier/scene.json +99 -282
  34. package/dist/templates/city-courier/scripts/game.ts +2 -14
  35. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +86 -13
  36. package/dist/templates/city-courier/src/worker.ts +3 -1
  37. package/dist/templates/city-courier/test/headless.test.ts +3 -2
  38. package/dist/templates/data-viz/README.md +1 -1
  39. package/dist/templates/index.json +19 -1
  40. package/dist/templates/skybound/gen/molen-types.ts +82 -2
  41. package/dist/templates/skybound/scripts/molen-scripts.d.ts +81 -1
  42. package/dist/templates/terrain-flyover/README.md +2 -2
  43. package/dist/templates/top-down-arena/README.md +1 -1
  44. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +81 -1
  45. package/dist/templates/top-down-arena/src/gen/molen-types.ts +82 -2
  46. package/package.json +13 -12
@@ -55,40 +55,6 @@
55
55
  "required": ["status", "health", "delivered", "total", "seconds", "speed", "message"],
56
56
  "additionalProperties": false
57
57
  }
58
- },
59
- "trafficCar": {
60
- "description": "Traffic route along one north/south street.",
61
- "examples": [
62
- {
63
- "lane": 1.8,
64
- "from": -31,
65
- "to": 31,
66
- "speed": 5,
67
- "start": -26
68
- }
69
- ],
70
- "schema": {
71
- "type": "object",
72
- "properties": {
73
- "lane": {
74
- "type": "number"
75
- },
76
- "from": {
77
- "type": "number"
78
- },
79
- "to": {
80
- "type": "number"
81
- },
82
- "speed": {
83
- "type": "number"
84
- },
85
- "start": {
86
- "type": "number"
87
- }
88
- },
89
- "required": ["lane", "from", "to", "speed", "start"],
90
- "additionalProperties": false
91
- }
92
58
  }
93
59
  },
94
60
  "commands": {
@@ -3120,254 +3086,6 @@
3120
3086
  },
3121
3087
  "prefab": "box"
3122
3088
  },
3123
- {
3124
- "id": "traffic0",
3125
- "components": {
3126
- "transform": {
3127
- "pos": [1.8, 0.55, -26]
3128
- },
3129
- "renderable": {
3130
- "primitive": {
3131
- "size": [1.45, 0.7, 2.6]
3132
- },
3133
- "materialRef": "palette:#df735e"
3134
- },
3135
- "collider": {
3136
- "radius": 1.3,
3137
- "layer": 1,
3138
- "mask": 2
3139
- },
3140
- "kinematicBody": {
3141
- "vel": [0, 0, 5],
3142
- "slide": false
3143
- },
3144
- "trafficCar": {
3145
- "lane": 1.8,
3146
- "from": -32,
3147
- "to": 32,
3148
- "speed": 5,
3149
- "start": -26
3150
- },
3151
- "audioSource": {
3152
- "sound": "vehicle.engine.car",
3153
- "gain": 0.6,
3154
- "pitch": 0.85,
3155
- "spatial": {
3156
- "refDistance": 14,
3157
- "maxDistance": 70
3158
- }
3159
- }
3160
- },
3161
- "prefab": "vehicle"
3162
- },
3163
- {
3164
- "id": "traffic0-roof",
3165
- "components": {
3166
- "transform": {
3167
- "pos": [0, 0, 0]
3168
- },
3169
- "renderable": {
3170
- "primitive": {
3171
- "size": [1.2, 0.4, 1.2]
3172
- },
3173
- "materialRef": "palette:#314756"
3174
- },
3175
- "parent": {
3176
- "id": "traffic0"
3177
- },
3178
- "localTransform": {
3179
- "pos": [0, 0.5, 0],
3180
- "rot": [0, 0, 0, 1]
3181
- }
3182
- },
3183
- "prefab": "box"
3184
- },
3185
- {
3186
- "id": "traffic1",
3187
- "components": {
3188
- "transform": {
3189
- "pos": [-1.8, 0.55, 23]
3190
- },
3191
- "renderable": {
3192
- "primitive": {
3193
- "size": [1.45, 0.7, 2.6]
3194
- },
3195
- "materialRef": "palette:#8ab4be"
3196
- },
3197
- "collider": {
3198
- "radius": 1.3,
3199
- "layer": 1,
3200
- "mask": 2
3201
- },
3202
- "kinematicBody": {
3203
- "vel": [0, 0, -6],
3204
- "slide": false
3205
- },
3206
- "trafficCar": {
3207
- "lane": -1.8,
3208
- "from": -32,
3209
- "to": 32,
3210
- "speed": -6,
3211
- "start": 23
3212
- },
3213
- "audioSource": {
3214
- "sound": "vehicle.engine.car",
3215
- "gain": 0.6,
3216
- "pitch": 0.85,
3217
- "spatial": {
3218
- "refDistance": 14,
3219
- "maxDistance": 70
3220
- }
3221
- }
3222
- },
3223
- "prefab": "vehicle"
3224
- },
3225
- {
3226
- "id": "traffic1-roof",
3227
- "components": {
3228
- "transform": {
3229
- "pos": [0, 0, 0]
3230
- },
3231
- "renderable": {
3232
- "primitive": {
3233
- "size": [1.2, 0.4, 1.2]
3234
- },
3235
- "materialRef": "palette:#314756"
3236
- },
3237
- "parent": {
3238
- "id": "traffic1"
3239
- },
3240
- "localTransform": {
3241
- "pos": [0, 0.5, 0],
3242
- "rot": [0, 0, 0, 1]
3243
- }
3244
- },
3245
- "prefab": "box"
3246
- },
3247
- {
3248
- "id": "traffic2",
3249
- "components": {
3250
- "transform": {
3251
- "pos": [25.8, 0.55, 9]
3252
- },
3253
- "renderable": {
3254
- "primitive": {
3255
- "size": [1.45, 0.7, 2.6]
3256
- },
3257
- "materialRef": "palette:#a9c472"
3258
- },
3259
- "collider": {
3260
- "radius": 1.3,
3261
- "layer": 1,
3262
- "mask": 2
3263
- },
3264
- "kinematicBody": {
3265
- "vel": [0, 0, 5],
3266
- "slide": false
3267
- },
3268
- "trafficCar": {
3269
- "lane": 25.8,
3270
- "from": -32,
3271
- "to": 32,
3272
- "speed": 5,
3273
- "start": 9
3274
- },
3275
- "audioSource": {
3276
- "sound": "vehicle.engine.car",
3277
- "gain": 0.6,
3278
- "pitch": 0.85,
3279
- "spatial": {
3280
- "refDistance": 14,
3281
- "maxDistance": 70
3282
- }
3283
- }
3284
- },
3285
- "prefab": "vehicle"
3286
- },
3287
- {
3288
- "id": "traffic2-roof",
3289
- "components": {
3290
- "transform": {
3291
- "pos": [0, 0, 0]
3292
- },
3293
- "renderable": {
3294
- "primitive": {
3295
- "size": [1.2, 0.4, 1.2]
3296
- },
3297
- "materialRef": "palette:#314756"
3298
- },
3299
- "parent": {
3300
- "id": "traffic2"
3301
- },
3302
- "localTransform": {
3303
- "pos": [0, 0.5, 0],
3304
- "rot": [0, 0, 0, 1]
3305
- }
3306
- },
3307
- "prefab": "box"
3308
- },
3309
- {
3310
- "id": "traffic3",
3311
- "components": {
3312
- "transform": {
3313
- "pos": [-22.2, 0.55, -5]
3314
- },
3315
- "renderable": {
3316
- "primitive": {
3317
- "size": [1.45, 0.7, 2.6]
3318
- },
3319
- "materialRef": "palette:#a699c8"
3320
- },
3321
- "collider": {
3322
- "radius": 1.3,
3323
- "layer": 1,
3324
- "mask": 2
3325
- },
3326
- "kinematicBody": {
3327
- "vel": [0, 0, 6],
3328
- "slide": false
3329
- },
3330
- "trafficCar": {
3331
- "lane": -22.2,
3332
- "from": -32,
3333
- "to": 32,
3334
- "speed": 6,
3335
- "start": -5
3336
- },
3337
- "audioSource": {
3338
- "sound": "vehicle.engine.car",
3339
- "gain": 0.6,
3340
- "pitch": 0.85,
3341
- "spatial": {
3342
- "refDistance": 14,
3343
- "maxDistance": 70
3344
- }
3345
- }
3346
- },
3347
- "prefab": "vehicle"
3348
- },
3349
- {
3350
- "id": "traffic3-roof",
3351
- "components": {
3352
- "transform": {
3353
- "pos": [0, 0, 0]
3354
- },
3355
- "renderable": {
3356
- "primitive": {
3357
- "size": [1.2, 0.4, 1.2]
3358
- },
3359
- "materialRef": "palette:#314756"
3360
- },
3361
- "parent": {
3362
- "id": "traffic3"
3363
- },
3364
- "localTransform": {
3365
- "pos": [0, 0.5, 0],
3366
- "rot": [0, 0, 0, 1]
3367
- }
3368
- },
3369
- "prefab": "box"
3370
- },
3371
3089
  {
3372
3090
  "id": "beacon",
3373
3091
  "components": {
@@ -3469,6 +3187,105 @@
3469
3187
  "slide": true
3470
3188
  }
3471
3189
  }
3190
+ },
3191
+ "npc-car": {
3192
+ "extends": "box",
3193
+ "components": {
3194
+ "renderable": {
3195
+ "primitive": {
3196
+ "size": [1.45, 0.7, 2.6]
3197
+ },
3198
+ "materialRef": "palette:#df735e"
3199
+ },
3200
+ "collider": {
3201
+ "shape": "circle",
3202
+ "radius": 1.3,
3203
+ "layer": 1,
3204
+ "mask": 2
3205
+ },
3206
+ "audioSource": {
3207
+ "sound": "vehicle.engine.car",
3208
+ "gain": 0.6,
3209
+ "pitch": 0.85,
3210
+ "spatial": {
3211
+ "refDistance": 14,
3212
+ "maxDistance": 70
3213
+ }
3214
+ }
3215
+ }
3472
3216
  }
3217
+ },
3218
+ "ambient": {
3219
+ "network": {
3220
+ "format": "molen/transport-network@1",
3221
+ "name": "courier grid",
3222
+ "drivingSide": "right",
3223
+ "ways": [
3224
+ {
3225
+ "id": "avenue-24",
3226
+ "class": "road",
3227
+ "subclass": "residential",
3228
+ "points": [[-24, -35], [-24, 35]],
3229
+ "lanes": 2,
3230
+ "width": 7,
3231
+ "speed": 6
3232
+ },
3233
+ {
3234
+ "id": "street-24",
3235
+ "class": "road",
3236
+ "subclass": "residential",
3237
+ "points": [[-35, -24], [35, -24]],
3238
+ "lanes": 2,
3239
+ "width": 7,
3240
+ "speed": 6
3241
+ },
3242
+ {
3243
+ "id": "avenue0",
3244
+ "class": "road",
3245
+ "subclass": "residential",
3246
+ "points": [[0, -35], [0, 35]],
3247
+ "lanes": 2,
3248
+ "width": 7,
3249
+ "speed": 6
3250
+ },
3251
+ {
3252
+ "id": "street0",
3253
+ "class": "road",
3254
+ "subclass": "residential",
3255
+ "points": [[-35, 0], [35, 0]],
3256
+ "lanes": 2,
3257
+ "width": 7,
3258
+ "speed": 6
3259
+ },
3260
+ {
3261
+ "id": "avenue24",
3262
+ "class": "road",
3263
+ "subclass": "residential",
3264
+ "points": [[24, -35], [24, 35]],
3265
+ "lanes": 2,
3266
+ "width": 7,
3267
+ "speed": 6
3268
+ },
3269
+ {
3270
+ "id": "street24",
3271
+ "class": "road",
3272
+ "subclass": "residential",
3273
+ "points": [[-35, 24], [35, 24]],
3274
+ "lanes": 2,
3275
+ "width": 7,
3276
+ "speed": 6
3277
+ }
3278
+ ]
3279
+ },
3280
+ "observer": "player",
3281
+ "classes": ["car"],
3282
+ "density": {
3283
+ "car": 6
3284
+ },
3285
+ "radius": 60,
3286
+ "templates": {
3287
+ "car": "npc-car"
3288
+ },
3289
+ "seedSalt": "traffic-0"
3473
3290
  }
3474
3291
  }
@@ -1,4 +1,5 @@
1
- // Arcade handling and mission rules. Collision, hierarchy and camera tracking are engine services.
1
+ // Arcade handling and mission rules. Collision, hierarchy, camera tracking and the ambient
2
+ // traffic (the scene's `ambient` block) are engine services.
2
3
  const game = () => molen.get('game', 'courierGame');
3
4
  const update = (data: Partial<MolenCourierGameData>) => molen.patch('game', 'courierGame', data);
4
5
  molen.patchState({
@@ -21,10 +22,6 @@ function reset() {
21
22
  message: 'Deliver the five beacons before time runs out.',
22
23
  });
23
24
  placeBeacon(0);
24
- for (const [id, car] of molen.query('trafficCar')) {
25
- molen.patch(id, 'transform', { pos: [car.lane, 0.55, car.start], teleport: true });
26
- molen.patch(id, 'kinematicBody', { vel: [0, 0, car.speed] });
27
- }
28
25
  }
29
26
  function placeBeacon(index: number) {
30
27
  const point = config.route[index];
@@ -119,13 +116,4 @@ molen.on('tick', () => {
119
116
  molen.emit('delivery', { delivered });
120
117
  if (delivered === g.total) molen.audio.play('sting.win');
121
118
  }
122
- for (const [id, t, car] of molen.query('transform', 'trafficCar')) {
123
- if (t.pos[2] > car.to || t.pos[2] < car.from)
124
- molen.patch(id, 'transform', {
125
- pos: [car.lane, 0.55, car.speed > 0 ? car.from : car.to],
126
- teleport: true,
127
- });
128
- else molen.patch(id, 'transform', { teleport: false });
129
- molen.patch(id, 'kinematicBody', { vel: [0, 0, car.speed] });
130
- }
131
119
  });
@@ -194,6 +194,78 @@ type MolenAircraftStateData = {
194
194
  crashed: boolean;
195
195
  waitingForTerrain: boolean;
196
196
  };
197
+ /** Kernel-owned state of an ambient NPC (car, pedestrian, train car or aircraft): its lane, position along it, speed and routing. Read it; the ambient systems write it. */
198
+ type MolenAmbientAgentData = {
199
+ kind: 'car' | 'pedestrian' | 'train' | 'aircraft';
200
+ type: string;
201
+ color?: string;
202
+ lane: string;
203
+ s: number;
204
+ speed: number;
205
+ prev?: string;
206
+ next?: string;
207
+ seed: number;
208
+ length: number;
209
+ width: number;
210
+ state: 'move' | 'wait' | 'dwell' | 'idle';
211
+ since: number;
212
+ hops: number;
213
+ hidden?: boolean;
214
+ consist?: string;
215
+ carIndex?: number;
216
+ trail?: string[];
217
+ served?: string;
218
+ air?: {
219
+ x: number;
220
+ z: number;
221
+ dx: number;
222
+ dz: number;
223
+ y0: number;
224
+ y1: number;
225
+ length: number;
226
+ };
227
+ spawnedTick: number;
228
+ };
229
+ /** Marks the entity ambient NPCs spawn around (usually the player or camera rig), with optional radius and density overrides. */
230
+ type MolenAmbientObserverData = {
231
+ radius?: number;
232
+ despawnRadius?: number;
233
+ density?: number;
234
+ };
235
+ /** On an entity type: makes it an ambient NPC candidate (car, bus, rail car or aircraft) with dimensions, speeds and spawn weight. */
236
+ type MolenAmbientRoleData = {
237
+ role: 'car' | 'bus' | 'rail' | 'aircraft';
238
+ length?: number;
239
+ width?: number;
240
+ height?: number;
241
+ cruise?: number;
242
+ max?: number;
243
+ weight?: number;
244
+ cars?: number;
245
+ colors?: string[];
246
+ visual?: {
247
+ wheelNodes?: string[];
248
+ frontWheelNodes?: string[];
249
+ paintMaterial?: string;
250
+ wheelRadius?: number;
251
+ wheelbase?: number;
252
+ rotors?: string[];
253
+ gearNodes?: string[];
254
+ };
255
+ };
256
+ /** Kernel-owned ambient bookkeeping on the `$ambient` entity: observer, spawn sequence and policy overrides. */
257
+ type MolenAmbientStateData = {
258
+ observer?: {
259
+ pos?: [number, number, number];
260
+ forward?: [number, number];
261
+ entity?: string;
262
+ setAtTick: number;
263
+ };
264
+ nextSeq: number;
265
+ spawned: number;
266
+ despawned: number;
267
+ policy?: Record<string, unknown>;
268
+ };
197
269
  /** Singleton soundscape rules: bus gains, ambience layers gated on weather/sky/listener signals, music playlist, event → sound mappings and listener footsteps. */
198
270
  type MolenAudioEnvironmentData = {
199
271
  buses?: Record<string, number>;
@@ -722,7 +794,7 @@ type MolenPlatformSolidData = {
722
794
  };
723
795
  /** Client render contract: a primitive, a gltf asset (by project asset id) with optional sub-node, material override, shadows, and clip playback, or a capability-registered kind. */
724
796
  type MolenRenderableData = {
725
- kind: 'primitive' | 'gltf' | 'figure';
797
+ kind: 'primitive' | 'gltf' | 'ambient-vehicle' | 'figure';
726
798
  ref: string;
727
799
  materialRef?: string;
728
800
  primitive?: {
@@ -773,14 +845,6 @@ type MolenTimerData = {
773
845
  repeatEvery?: number;
774
846
  }[];
775
847
  };
776
- /** Traffic route along one north/south street. */
777
- type MolenTrafficCarData = {
778
- lane: number;
779
- from: number;
780
- to: number;
781
- speed: number;
782
- start: number;
783
- };
784
848
  /** World position + orientation. pos is required; rot defaults to identity. */
785
849
  type MolenTransformData = {
786
850
  pos: [number, number, number];
@@ -937,6 +1001,14 @@ interface MolenComponentData {
937
1001
  'aircraftInput': MolenAircraftInputData;
938
1002
  /** Deterministic flight state, including rotor phase and engine spool, preserved by keyframes. */
939
1003
  'aircraftState': MolenAircraftStateData;
1004
+ /** Kernel-owned state of an ambient NPC (car, pedestrian, train car or aircraft): its lane, position along it, speed and routing. Read it; the ambient systems write it. */
1005
+ 'ambientAgent': MolenAmbientAgentData;
1006
+ /** Marks the entity ambient NPCs spawn around (usually the player or camera rig), with optional radius and density overrides. */
1007
+ 'ambientObserver': MolenAmbientObserverData;
1008
+ /** On an entity type: makes it an ambient NPC candidate (car, bus, rail car or aircraft) with dimensions, speeds and spawn weight. */
1009
+ 'ambientRole': MolenAmbientRoleData;
1010
+ /** Kernel-owned ambient bookkeeping on the `$ambient` entity: observer, spawn sequence and policy overrides. */
1011
+ 'ambientState': MolenAmbientStateData;
940
1012
  /** Singleton soundscape rules: bus gains, ambience layers gated on weather/sky/listener signals, music playlist, event → sound mappings and listener footsteps. */
941
1013
  'audioEnvironment': MolenAudioEnvironmentData;
942
1014
  /** Sound emitter on an entity: a sound-bank id, loop/autoplay, gain and pitch driven by signals (vehicleState.speed, listener.distance…), and one-shot triggers. Positional when the entity has a transform. Render-side only; see guide/audio.md. */
@@ -1005,8 +1077,6 @@ interface MolenComponentData {
1005
1077
  'tag': MolenTagData;
1006
1078
  /** Snapshot-safe countdown timers that emit events (one-shot or repeating). Replaces callbacks. */
1007
1079
  'timer': MolenTimerData;
1008
- /** Traffic route along one north/south street. */
1009
- 'trafficCar': MolenTrafficCarData;
1010
1080
  /** World position + orientation. pos is required; rot defaults to identity. */
1011
1081
  'transform': MolenTransformData;
1012
1082
  /** Data-driven value animation over ticks: component + select-style path, lerp with easing. */
@@ -1029,9 +1099,9 @@ type MolenComponentName = keyof MolenComponentData;
1029
1099
  type MolenComponentPatch = { [K in MolenComponentName]?: MolenComponentData[K] };
1030
1100
 
1031
1101
  /** Entity ids declared in the scene. Ids of spawned entities are plain strings. */
1032
- type MolenEntityId = 'audio' | 'beacon' | 'beacon-pillar' | 'block--16--16' | 'block--16--16-entry' | 'block--16--16-roof' | 'block--16--16-window1.5--1.5' | 'block--16--16-window1.5-1.5' | 'block--16--16-window3--1.5' | 'block--16--16-window3-1.5' | 'block--16--8' | 'block--16--8-entry' | 'block--16--8-roof' | 'block--16--8-window1.5--1.5' | 'block--16--8-window1.5-1.5' | 'block--16--8-window3--1.5' | 'block--16--8-window3-1.5' | 'block--16-16' | 'block--16-16-entry' | 'block--16-16-roof' | 'block--16-16-window1.5--1.5' | 'block--16-16-window1.5-1.5' | 'block--16-16-window3--1.5' | 'block--16-16-window3-1.5' | 'block--16-8' | 'block--16-8-entry' | 'block--16-8-roof' | 'block--16-8-window1.5--1.5' | 'block--16-8-window1.5-1.5' | 'block--16-8-window3--1.5' | 'block--16-8-window3-1.5' | 'block--8--16' | 'block--8--16-entry' | 'block--8--16-roof' | 'block--8--16-window1.5--1.5' | 'block--8--16-window1.5-1.5' | 'block--8--16-window3--1.5' | 'block--8--16-window3-1.5' | 'block--8--8' | 'block--8--8-entry' | 'block--8--8-roof' | 'block--8--8-window1.5--1.5' | 'block--8--8-window1.5-1.5' | 'block--8--8-window3--1.5' | 'block--8--8-window3-1.5' | 'block--8-16' | 'block--8-16-entry' | 'block--8-16-roof' | 'block--8-16-window1.5--1.5' | 'block--8-16-window1.5-1.5' | 'block--8-16-window3--1.5' | 'block--8-16-window3-1.5' | 'block--8-8' | 'block--8-8-entry' | 'block--8-8-roof' | 'block--8-8-window1.5--1.5' | 'block--8-8-window1.5-1.5' | 'block--8-8-window3--1.5' | 'block--8-8-window3-1.5' | 'block-16--16' | 'block-16--16-entry' | 'block-16--16-roof' | 'block-16--16-window1.5--1.5' | 'block-16--16-window1.5-1.5' | 'block-16--16-window3--1.5' | 'block-16--16-window3-1.5' | 'block-16--8' | 'block-16--8-entry' | 'block-16--8-roof' | 'block-16--8-window1.5--1.5' | 'block-16--8-window1.5-1.5' | 'block-16--8-window3--1.5' | 'block-16--8-window3-1.5' | 'block-16-16' | 'block-16-16-entry' | 'block-16-16-roof' | 'block-16-16-window1.5--1.5' | 'block-16-16-window1.5-1.5' | 'block-16-16-window3--1.5' | 'block-16-16-window3-1.5' | 'block-16-8' | 'block-16-8-entry' | 'block-16-8-roof' | 'block-16-8-window1.5--1.5' | 'block-16-8-window1.5-1.5' | 'block-16-8-window3--1.5' | 'block-16-8-window3-1.5' | 'block-8--16' | 'block-8--16-entry' | 'block-8--16-roof' | 'block-8--16-window1.5--1.5' | 'block-8--16-window1.5-1.5' | 'block-8--16-window3--1.5' | 'block-8--16-window3-1.5' | 'block-8--8' | 'block-8--8-entry' | 'block-8--8-roof' | 'block-8--8-window1.5--1.5' | 'block-8--8-window1.5-1.5' | 'block-8--8-window3--1.5' | 'block-8--8-window3-1.5' | 'block-8-16' | 'block-8-16-entry' | 'block-8-16-roof' | 'block-8-16-window1.5--1.5' | 'block-8-16-window1.5-1.5' | 'block-8-16-window3--1.5' | 'block-8-16-window3-1.5' | 'block-8-8' | 'block-8-8-entry' | 'block-8-8-roof' | 'block-8-8-window1.5--1.5' | 'block-8-8-window1.5-1.5' | 'block-8-8-window3--1.5' | 'block-8-8-window3-1.5' | 'boundary0' | 'boundary1' | 'boundary2' | 'boundary3' | 'car-cabin' | 'car-stripe' | 'dash-x-24--12' | 'dash-x-24--16' | 'dash-x-24--32' | 'dash-x-24--8' | 'dash-x-24-12' | 'dash-x-24-16' | 'dash-x-24-32' | 'dash-x-24-8' | 'dash-x0--12' | 'dash-x0--16' | 'dash-x0--32' | 'dash-x0--8' | 'dash-x0-12' | 'dash-x0-16' | 'dash-x0-32' | 'dash-x0-8' | 'dash-x24--12' | 'dash-x24--16' | 'dash-x24--32' | 'dash-x24--8' | 'dash-x24-12' | 'dash-x24-16' | 'dash-x24-32' | 'dash-x24-8' | 'dash-z-24--12' | 'dash-z-24--16' | 'dash-z-24--32' | 'dash-z-24--8' | 'dash-z-24-12' | 'dash-z-24-16' | 'dash-z-24-32' | 'dash-z-24-8' | 'dash-z0--12' | 'dash-z0--16' | 'dash-z0--32' | 'dash-z0--8' | 'dash-z0-12' | 'dash-z0-16' | 'dash-z0-32' | 'dash-z0-8' | 'dash-z24--12' | 'dash-z24--16' | 'dash-z24--32' | 'dash-z24--8' | 'dash-z24-12' | 'dash-z24-16' | 'dash-z24-32' | 'dash-z24-8' | 'environment' | 'game' | 'ground' | 'player' | 'road-x-24' | 'road-x0' | 'road-x24' | 'road-z-24' | 'road-z0' | 'road-z24' | 'traffic0' | 'traffic0-roof' | 'traffic1' | 'traffic1-roof' | 'traffic2' | 'traffic2-roof' | 'traffic3' | 'traffic3-roof' | 'wheel-0.8-0.85' | 'wheel-0.80.85' | 'wheel0.8-0.85' | 'wheel0.80.85' | (string & {});
1102
+ type MolenEntityId = 'audio' | 'beacon' | 'beacon-pillar' | 'block--16--16' | 'block--16--16-entry' | 'block--16--16-roof' | 'block--16--16-window1.5--1.5' | 'block--16--16-window1.5-1.5' | 'block--16--16-window3--1.5' | 'block--16--16-window3-1.5' | 'block--16--8' | 'block--16--8-entry' | 'block--16--8-roof' | 'block--16--8-window1.5--1.5' | 'block--16--8-window1.5-1.5' | 'block--16--8-window3--1.5' | 'block--16--8-window3-1.5' | 'block--16-16' | 'block--16-16-entry' | 'block--16-16-roof' | 'block--16-16-window1.5--1.5' | 'block--16-16-window1.5-1.5' | 'block--16-16-window3--1.5' | 'block--16-16-window3-1.5' | 'block--16-8' | 'block--16-8-entry' | 'block--16-8-roof' | 'block--16-8-window1.5--1.5' | 'block--16-8-window1.5-1.5' | 'block--16-8-window3--1.5' | 'block--16-8-window3-1.5' | 'block--8--16' | 'block--8--16-entry' | 'block--8--16-roof' | 'block--8--16-window1.5--1.5' | 'block--8--16-window1.5-1.5' | 'block--8--16-window3--1.5' | 'block--8--16-window3-1.5' | 'block--8--8' | 'block--8--8-entry' | 'block--8--8-roof' | 'block--8--8-window1.5--1.5' | 'block--8--8-window1.5-1.5' | 'block--8--8-window3--1.5' | 'block--8--8-window3-1.5' | 'block--8-16' | 'block--8-16-entry' | 'block--8-16-roof' | 'block--8-16-window1.5--1.5' | 'block--8-16-window1.5-1.5' | 'block--8-16-window3--1.5' | 'block--8-16-window3-1.5' | 'block--8-8' | 'block--8-8-entry' | 'block--8-8-roof' | 'block--8-8-window1.5--1.5' | 'block--8-8-window1.5-1.5' | 'block--8-8-window3--1.5' | 'block--8-8-window3-1.5' | 'block-16--16' | 'block-16--16-entry' | 'block-16--16-roof' | 'block-16--16-window1.5--1.5' | 'block-16--16-window1.5-1.5' | 'block-16--16-window3--1.5' | 'block-16--16-window3-1.5' | 'block-16--8' | 'block-16--8-entry' | 'block-16--8-roof' | 'block-16--8-window1.5--1.5' | 'block-16--8-window1.5-1.5' | 'block-16--8-window3--1.5' | 'block-16--8-window3-1.5' | 'block-16-16' | 'block-16-16-entry' | 'block-16-16-roof' | 'block-16-16-window1.5--1.5' | 'block-16-16-window1.5-1.5' | 'block-16-16-window3--1.5' | 'block-16-16-window3-1.5' | 'block-16-8' | 'block-16-8-entry' | 'block-16-8-roof' | 'block-16-8-window1.5--1.5' | 'block-16-8-window1.5-1.5' | 'block-16-8-window3--1.5' | 'block-16-8-window3-1.5' | 'block-8--16' | 'block-8--16-entry' | 'block-8--16-roof' | 'block-8--16-window1.5--1.5' | 'block-8--16-window1.5-1.5' | 'block-8--16-window3--1.5' | 'block-8--16-window3-1.5' | 'block-8--8' | 'block-8--8-entry' | 'block-8--8-roof' | 'block-8--8-window1.5--1.5' | 'block-8--8-window1.5-1.5' | 'block-8--8-window3--1.5' | 'block-8--8-window3-1.5' | 'block-8-16' | 'block-8-16-entry' | 'block-8-16-roof' | 'block-8-16-window1.5--1.5' | 'block-8-16-window1.5-1.5' | 'block-8-16-window3--1.5' | 'block-8-16-window3-1.5' | 'block-8-8' | 'block-8-8-entry' | 'block-8-8-roof' | 'block-8-8-window1.5--1.5' | 'block-8-8-window1.5-1.5' | 'block-8-8-window3--1.5' | 'block-8-8-window3-1.5' | 'boundary0' | 'boundary1' | 'boundary2' | 'boundary3' | 'car-cabin' | 'car-stripe' | 'dash-x-24--12' | 'dash-x-24--16' | 'dash-x-24--32' | 'dash-x-24--8' | 'dash-x-24-12' | 'dash-x-24-16' | 'dash-x-24-32' | 'dash-x-24-8' | 'dash-x0--12' | 'dash-x0--16' | 'dash-x0--32' | 'dash-x0--8' | 'dash-x0-12' | 'dash-x0-16' | 'dash-x0-32' | 'dash-x0-8' | 'dash-x24--12' | 'dash-x24--16' | 'dash-x24--32' | 'dash-x24--8' | 'dash-x24-12' | 'dash-x24-16' | 'dash-x24-32' | 'dash-x24-8' | 'dash-z-24--12' | 'dash-z-24--16' | 'dash-z-24--32' | 'dash-z-24--8' | 'dash-z-24-12' | 'dash-z-24-16' | 'dash-z-24-32' | 'dash-z-24-8' | 'dash-z0--12' | 'dash-z0--16' | 'dash-z0--32' | 'dash-z0--8' | 'dash-z0-12' | 'dash-z0-16' | 'dash-z0-32' | 'dash-z0-8' | 'dash-z24--12' | 'dash-z24--16' | 'dash-z24--32' | 'dash-z24--8' | 'dash-z24-12' | 'dash-z24-16' | 'dash-z24-32' | 'dash-z24-8' | 'environment' | 'game' | 'ground' | 'player' | 'road-x-24' | 'road-x0' | 'road-x24' | 'road-z-24' | 'road-z0' | 'road-z24' | 'wheel-0.8-0.85' | 'wheel-0.80.85' | 'wheel0.8-0.85' | 'wheel0.80.85' | (string & {});
1033
1103
  /** Prefab names declared in the scene. */
1034
- type MolenPrefabName = 'box' | 'cylinder' | 'sphere' | 'vehicle' | (string & {});
1104
+ type MolenPrefabName = 'box' | 'cylinder' | 'npc-car' | 'sphere' | 'vehicle' | (string & {});
1035
1105
  /** Registry type ids this project declares (`molen.spawnType`). */
1036
1106
  type MolenTypeId = string;
1037
1107
 
@@ -1259,6 +1329,9 @@ interface MolenApi {
1259
1329
  readonly tick: number;
1260
1330
  readonly dt: number;
1261
1331
  readonly math: MolenMath;
1332
+ /** Ambient life: stats / laneAt / agentsNear / setObserver / addRoad / … (see guide/ambient-life.md). Installed as a scripting extension, so its verbs are not checked here. */
1333
+ // biome-ignore lint/suspicious/noExplicitAny: capability signatures are owned by their extensions
1334
+ readonly ambient: Record<string, (...args: any[]) => any>;
1262
1335
  /** Figure verbs: mount / dismount / socket / … (see guide/figures.md). Installed as a scripting extension, so its verbs are not checked here. */
1263
1336
  // biome-ignore lint/suspicious/noExplicitAny: capability signatures are owned by their extensions
1264
1337
  readonly figures: Record<string, (...args: any[]) => any>;
@@ -1,5 +1,7 @@
1
1
  /// <reference lib="webworker" />
2
+ import { ambientCapability } from '@bendyline/molen-ambient/kernel';
2
3
  import { startKernelWorker } from '@bendyline/molen-kernel';
3
4
  import { scene } from './scene';
4
5
 
5
- startKernelWorker({ scene: scene() });
6
+ // The scene's `ambient` block (traffic on the street grid) needs the ambient capability.
7
+ startKernelWorker({ scene: scene(), capabilities: [ambientCapability()] });
@@ -1,3 +1,4 @@
1
+ import { ambientCapability } from '@bendyline/molen-ambient/kernel';
1
2
  import {
2
3
  applyKeyframeTo,
3
4
  buildWorld,
@@ -10,7 +11,7 @@ import type { JsonObject } from '@bendyline/molen-schema';
10
11
  import { describe, expect, it } from 'vitest';
11
12
  import { scene } from '../src/scene';
12
13
 
13
- const build = (): World => buildWorld(scene());
14
+ const build = (): World => buildWorld(scene(), undefined, { capabilities: [ambientCapability()] });
14
15
  function command(w: World, type: string, payload: JsonObject = {}): void {
15
16
  const result = w.submitCommand({
16
17
  kind: 'command',
@@ -37,7 +38,7 @@ describe('city-courier: authored scene + scripts', () => {
37
38
  command(w, 'drive', { dir: [0, -1] });
38
39
  w.stepN(90);
39
40
  expect(stateHash(w)).toBe(
40
- 'sha256:d82352ff8a1969ea1f702d38a963b09efe7b9c6d00a2f067fed247b239451fdb',
41
+ 'sha256:88442f1752f6ba13ea11913128b5ce351dff6f998a98658c7624cafd258effc1',
41
42
  );
42
43
  });
43
44
 
@@ -38,7 +38,7 @@ npm test
38
38
 
39
39
  `test/headless.test.ts` checks one bar per datum, growth over time toward `value * heightScale`, height ordering (taller means bigger), the camera track validating and actually moving, and a **pinned state hash** at 60 ticks alongside run-to-run equality.
40
40
 
41
- In the engine repository, `test/golden/viz.golden.test.ts` is the render half (golden tests stay there; a template copy does not include them): `screenshotScene` at tick 40 from the track's own pose at tick 40, 512x320, asserting seven rendered entities and comparing against the committed `test/golden/__goldens__/viz.png`. It then runs `exportFrames` from tick 0 to 60 in steps of 30 along the same track and asserts three PNGs — the machinima sequence in miniature. There is no replay fixture: nothing here takes commands.
41
+ In the engine repository, `test/golden/viz.golden.test.ts` is the render half (golden tests stay there; a template copy does not include them): `screenshotScene` at tick 40 from the track's own pose at tick 40, 512x320, asserting seven rendered entities and, with `frameStats` rather than a reference image, that the bars cover part of the dark frame in several shades. It then runs `exportFrames` from tick 0 to 60 in steps of 30 along the same track and asserts three PNGs whose first and last frames differ — the machinima sequence in miniature. There is no replay fixture: nothing here takes commands.
42
42
 
43
43
  One wrinkle worth knowing: `src/viz.ts` imports `data.json` without an import attribute, which Vite and Vitest supply and plain Node does not. Passing `--setup src/viz.ts` to `molen sim run` or `molen shot` therefore fails to load the module, which is why the headless render and the frame export run inside Vitest rather than from the CLI.
44
44
 
@@ -187,5 +187,23 @@
187
187
  "replays": ["first-leap.replay.json"],
188
188
  "tests": true
189
189
  }
190
- ]
190
+ ],
191
+ "versions": {
192
+ "@bendyline/molen-ambient": "0.0.4",
193
+ "@bendyline/molen-client": "0.0.4",
194
+ "@bendyline/molen-earth": "0.0.4",
195
+ "@bendyline/molen-entities": "0.0.4",
196
+ "@bendyline/molen-figures": "0.0.4",
197
+ "@bendyline/molen-input-react": "0.0.4",
198
+ "@bendyline/molen-kernel": "0.0.4",
199
+ "@bendyline/molen-materials": "0.0.4",
200
+ "@bendyline/molen-pack": "0.0.4",
201
+ "@bendyline/molen-pathfinding": "0.0.4",
202
+ "@bendyline/molen-physics-rapier": "0.0.4",
203
+ "@bendyline/molen-schema": "0.0.4",
204
+ "@bendyline/molen-terrain": "0.0.4",
205
+ "@bendyline/molen-tooling": "0.0.4",
206
+ "@bendyline/molen-worldgen": "0.0.4",
207
+ "@bendyline/molen-worldgen-earth": "0.0.4"
208
+ }
191
209
  }