@bendyline/molen-tooling 0.0.2 → 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 (86) hide show
  1. package/README.md +4 -4
  2. package/dist/capture/harness.js +222 -222
  3. package/dist/capture/worldgen-preview.js +288 -288
  4. package/dist/cli.mjs +162 -10
  5. package/dist/docs-src/guide/3d-model-assets.md +35 -3
  6. package/dist/docs-src/guide/adaptive-performance.md +4 -0
  7. package/dist/docs-src/guide/agent-loop.md +6 -6
  8. package/dist/docs-src/guide/aircraft.md +28 -7
  9. package/dist/docs-src/guide/ambient-life.md +389 -0
  10. package/dist/docs-src/guide/audio.md +247 -0
  11. package/dist/docs-src/guide/browser-mount.md +8 -1
  12. package/dist/docs-src/guide/building-interiors.md +5 -4
  13. package/dist/docs-src/guide/capability-authoring.md +5 -0
  14. package/dist/docs-src/guide/determinism.md +35 -27
  15. package/dist/docs-src/guide/earth-view.md +492 -0
  16. package/dist/docs-src/guide/entities.md +9 -1
  17. package/dist/docs-src/guide/examples.md +6 -2
  18. package/dist/docs-src/guide/figures.md +3 -0
  19. package/dist/docs-src/guide/game-samples.md +22 -5
  20. package/dist/docs-src/guide/graphics-performance.md +40 -8
  21. package/dist/docs-src/guide/input.md +9 -0
  22. package/dist/docs-src/guide/markers.md +55 -0
  23. package/dist/docs-src/guide/materials.md +10 -3
  24. package/dist/docs-src/guide/navigation.md +150 -0
  25. package/dist/docs-src/guide/project.md +1 -1
  26. package/dist/docs-src/guide/quickstart.md +2 -2
  27. package/dist/docs-src/guide/recognizable-places.md +3 -2
  28. package/dist/docs-src/guide/scripting.md +4 -2
  29. package/dist/docs-src/guide/sky.md +16 -0
  30. package/dist/docs-src/guide/source-bundles.md +0 -1
  31. package/dist/docs-src/guide/structure-library.md +2 -2
  32. package/dist/docs-src/guide/surface-rendering.md +4 -3
  33. package/dist/docs-src/guide/terrain.md +52 -2
  34. package/dist/docs-src/guide/vehicles.md +32 -10
  35. package/dist/docs-src/guide/worldgen.md +3 -3
  36. package/dist/docs-src/llms.txt +14 -5
  37. package/dist/docs-src/schemas/README.md +4 -0
  38. package/dist/docs-src/schemas/archive-set.md +175 -0
  39. package/dist/docs-src/schemas/components.md +1634 -2
  40. package/dist/docs-src/schemas/matgraph.md +6 -0
  41. package/dist/docs-src/schemas/scene.md +105 -0
  42. package/dist/docs-src/schemas/soundbank.md +251 -0
  43. package/dist/docs-src/schemas/structure-placements.md +496 -0
  44. package/dist/docs-src/schemas/terrain-package.md +120 -0
  45. package/dist/docs-src/schemas/transport-network.md +351 -0
  46. package/dist/index.d.mts +49 -2
  47. package/dist/index.mjs +81 -4
  48. package/dist/{mcp-AOfIp89b.mjs → mcp-BtuworIW.mjs} +88 -3
  49. package/dist/{ops-C4BvDgP-.mjs → ops-DMGcWoL2.mjs} +1204 -93
  50. package/dist/templates/city-courier/README.md +14 -1
  51. package/dist/templates/city-courier/delivery-run.replay.json +151 -151
  52. package/dist/templates/city-courier/gen/molen-types.ts +223 -5
  53. package/dist/templates/city-courier/package.json +2 -0
  54. package/dist/templates/city-courier/scene.json +142 -246
  55. package/dist/templates/city-courier/scripts/game.ts +7 -15
  56. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +252 -16
  57. package/dist/templates/city-courier/src/audio.ts +96 -0
  58. package/dist/templates/city-courier/src/game-shell.css +8 -0
  59. package/dist/templates/city-courier/src/main.ts +3 -0
  60. package/dist/templates/city-courier/src/worker.ts +3 -1
  61. package/dist/templates/city-courier/test/headless.test.ts +3 -2
  62. package/dist/templates/data-viz/README.md +1 -1
  63. package/dist/templates/index.json +22 -1
  64. package/dist/templates/skybound/README.md +13 -0
  65. package/dist/templates/skybound/first-leap.replay.json +152 -152
  66. package/dist/templates/skybound/gen/molen-types.ts +223 -5
  67. package/dist/templates/skybound/package.json +1 -0
  68. package/dist/templates/skybound/scene.json +40 -0
  69. package/dist/templates/skybound/scripts/game.ts +8 -5
  70. package/dist/templates/skybound/scripts/molen-scripts.d.ts +248 -5
  71. package/dist/templates/skybound/src/audio.ts +96 -0
  72. package/dist/templates/skybound/src/game-shell.css +8 -0
  73. package/dist/templates/skybound/src/main.ts +3 -0
  74. package/dist/templates/skybound/test/headless.test.ts +1 -1
  75. package/dist/templates/terrain-flyover/README.md +2 -2
  76. package/dist/templates/top-down-arena/README.md +15 -2
  77. package/dist/templates/top-down-arena/arena-skirmish.replay.json +152 -152
  78. package/dist/templates/top-down-arena/package.json +1 -0
  79. package/dist/templates/top-down-arena/scene.json +20 -0
  80. package/dist/templates/top-down-arena/scripts/combat.ts +1 -0
  81. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +248 -5
  82. package/dist/templates/top-down-arena/src/audio.ts +96 -0
  83. package/dist/templates/top-down-arena/src/gen/molen-types.ts +223 -5
  84. package/dist/templates/top-down-arena/src/main.ts +3 -0
  85. package/dist/templates/top-down-arena/test/headless.test.ts +1 -1
  86. package/package.json +13 -12
@@ -0,0 +1,351 @@
1
+ # Transport network (`molen/transport-network@1`)
2
+
3
+ Roads, railways and paths ambient NPCs move on, for scenes without streamed map tiles. Ways that share a vertex, cross at the same grade or end on one another connect.
4
+
5
+ ## Example
6
+
7
+ ```json
8
+ {
9
+ "format": "molen/transport-network@1",
10
+ "name": "crossroads",
11
+ "drivingSide": "right",
12
+ "ways": [
13
+ {
14
+ "id": "main",
15
+ "class": "road",
16
+ "subclass": "primary",
17
+ "points": [
18
+ [
19
+ -200,
20
+ 0
21
+ ],
22
+ [
23
+ 200,
24
+ 0
25
+ ]
26
+ ],
27
+ "lanes": 4
28
+ },
29
+ {
30
+ "id": "cross",
31
+ "class": "road",
32
+ "subclass": "residential",
33
+ "points": [
34
+ [
35
+ 0,
36
+ -200
37
+ ],
38
+ [
39
+ 0,
40
+ 200
41
+ ]
42
+ ]
43
+ },
44
+ {
45
+ "id": "tram",
46
+ "class": "rail",
47
+ "subclass": "tram",
48
+ "points": [
49
+ [
50
+ -200,
51
+ 30
52
+ ],
53
+ [
54
+ 200,
55
+ 30
56
+ ]
57
+ ]
58
+ }
59
+ ],
60
+ "stations": [
61
+ {
62
+ "id": "central",
63
+ "at": [
64
+ 0,
65
+ 30
66
+ ],
67
+ "kind": "rail"
68
+ }
69
+ ],
70
+ "signals": [
71
+ {
72
+ "at": [
73
+ 0,
74
+ 0
75
+ ],
76
+ "kind": "light"
77
+ }
78
+ ]
79
+ }
80
+ ```
81
+
82
+ ## JSON Schema
83
+
84
+ ```json
85
+ {
86
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
87
+ "type": "object",
88
+ "properties": {
89
+ "format": {
90
+ "type": "string",
91
+ "const": "molen/transport-network@1",
92
+ "description": "Format envelope; always 'molen/transport-network@1'."
93
+ },
94
+ "name": {
95
+ "type": "string"
96
+ },
97
+ "origin": {
98
+ "anyOf": [
99
+ {
100
+ "type": "object",
101
+ "properties": {
102
+ "latitude": {
103
+ "type": "number"
104
+ },
105
+ "longitude": {
106
+ "type": "number"
107
+ }
108
+ },
109
+ "required": [
110
+ "latitude",
111
+ "longitude"
112
+ ],
113
+ "additionalProperties": false
114
+ },
115
+ {
116
+ "type": "object",
117
+ "properties": {
118
+ "x": {
119
+ "type": "number"
120
+ },
121
+ "z": {
122
+ "type": "number"
123
+ }
124
+ },
125
+ "required": [
126
+ "x",
127
+ "z"
128
+ ],
129
+ "additionalProperties": false
130
+ }
131
+ ],
132
+ "description": "Where the network came from (geographic anchor of a baked network)."
133
+ },
134
+ "drivingSide": {
135
+ "type": "string",
136
+ "enum": [
137
+ "right",
138
+ "left"
139
+ ],
140
+ "description": "Traffic side (default 'right')."
141
+ },
142
+ "sidewalks": {
143
+ "type": "boolean",
144
+ "description": "Infer sidewalks along streets that have no mapped paths nearby (default false)."
145
+ },
146
+ "ways": {
147
+ "type": "array",
148
+ "items": {
149
+ "type": "object",
150
+ "properties": {
151
+ "id": {
152
+ "type": "string",
153
+ "minLength": 1,
154
+ "description": "Optional stable id."
155
+ },
156
+ "class": {
157
+ "type": "string",
158
+ "enum": [
159
+ "road",
160
+ "rail",
161
+ "path",
162
+ "air"
163
+ ],
164
+ "description": "What moves on it."
165
+ },
166
+ "subclass": {
167
+ "type": "string",
168
+ "description": "motorway, trunk, primary, secondary, tertiary, residential, service; rail/tram; crossing."
169
+ },
170
+ "points": {
171
+ "minItems": 2,
172
+ "type": "array",
173
+ "items": {
174
+ "anyOf": [
175
+ {
176
+ "minItems": 2,
177
+ "maxItems": 2,
178
+ "type": "array",
179
+ "items": {
180
+ "type": "number"
181
+ }
182
+ },
183
+ {
184
+ "minItems": 3,
185
+ "maxItems": 3,
186
+ "type": "array",
187
+ "items": {
188
+ "type": "number"
189
+ }
190
+ }
191
+ ]
192
+ },
193
+ "description": "[x, z] or [x, y, z] points in scene metres (y = road surface height)."
194
+ },
195
+ "oneway": {
196
+ "type": "boolean",
197
+ "description": "Traffic only in point order."
198
+ },
199
+ "lanes": {
200
+ "type": "integer",
201
+ "exclusiveMinimum": 0,
202
+ "maximum": 9007199254740991,
203
+ "description": "Total lanes across both directions."
204
+ },
205
+ "width": {
206
+ "type": "number",
207
+ "exclusiveMinimum": 0,
208
+ "description": "Carriageway width in metres."
209
+ },
210
+ "layer": {
211
+ "type": "integer",
212
+ "minimum": -9007199254740991,
213
+ "maximum": 9007199254740991,
214
+ "description": "Grade: different layers never connect mid-way."
215
+ },
216
+ "speed": {
217
+ "type": "number",
218
+ "exclusiveMinimum": 0,
219
+ "description": "Design speed in m/s."
220
+ },
221
+ "bridge": {
222
+ "type": "boolean"
223
+ },
224
+ "tunnel": {
225
+ "type": "boolean"
226
+ },
227
+ "name": {
228
+ "type": "string"
229
+ }
230
+ },
231
+ "required": [
232
+ "class",
233
+ "points"
234
+ ],
235
+ "additionalProperties": false
236
+ },
237
+ "description": "Roads, railways and paths."
238
+ },
239
+ "stations": {
240
+ "type": "array",
241
+ "items": {
242
+ "type": "object",
243
+ "properties": {
244
+ "id": {
245
+ "type": "string",
246
+ "minLength": 1
247
+ },
248
+ "at": {
249
+ "minItems": 2,
250
+ "maxItems": 2,
251
+ "type": "array",
252
+ "items": {
253
+ "type": "number"
254
+ },
255
+ "description": "[x, z]; projected onto the nearest rail (rail) or footway (bus)."
256
+ },
257
+ "kind": {
258
+ "type": "string",
259
+ "enum": [
260
+ "rail",
261
+ "bus"
262
+ ]
263
+ },
264
+ "dwell": {
265
+ "type": "number",
266
+ "exclusiveMinimum": 0,
267
+ "description": "Dwell time in seconds."
268
+ }
269
+ },
270
+ "required": [
271
+ "id",
272
+ "at",
273
+ "kind"
274
+ ],
275
+ "additionalProperties": false
276
+ },
277
+ "description": "Stops trains (and buses) serve."
278
+ },
279
+ "signals": {
280
+ "type": "array",
281
+ "items": {
282
+ "type": "object",
283
+ "properties": {
284
+ "at": {
285
+ "minItems": 2,
286
+ "maxItems": 2,
287
+ "type": "array",
288
+ "items": {
289
+ "type": "number"
290
+ }
291
+ },
292
+ "kind": {
293
+ "type": "string",
294
+ "enum": [
295
+ "stop",
296
+ "yield",
297
+ "light"
298
+ ]
299
+ }
300
+ },
301
+ "required": [
302
+ "at",
303
+ "kind"
304
+ ],
305
+ "additionalProperties": false
306
+ },
307
+ "description": "Junction controls: a light signalises the junction nearest the point; a stop or yield sign makes the junction arm nearest the point give way."
308
+ },
309
+ "aerodromes": {
310
+ "type": "array",
311
+ "items": {
312
+ "type": "object",
313
+ "properties": {
314
+ "id": {
315
+ "type": "string",
316
+ "minLength": 1
317
+ },
318
+ "at": {
319
+ "minItems": 2,
320
+ "maxItems": 2,
321
+ "type": "array",
322
+ "items": {
323
+ "type": "number"
324
+ }
325
+ },
326
+ "heading": {
327
+ "type": "number",
328
+ "description": "Runway heading in radians about +Y (0 = +Z)."
329
+ },
330
+ "length": {
331
+ "type": "number",
332
+ "exclusiveMinimum": 0,
333
+ "description": "Runway length in metres (default 2500)."
334
+ }
335
+ },
336
+ "required": [
337
+ "id",
338
+ "at"
339
+ ],
340
+ "additionalProperties": false
341
+ },
342
+ "description": "Runways aircraft approach and depart."
343
+ }
344
+ },
345
+ "required": [
346
+ "format",
347
+ "ways"
348
+ ],
349
+ "additionalProperties": false
350
+ }
351
+ ```
package/dist/index.d.mts CHANGED
@@ -7,6 +7,42 @@ import { ResolvedTypes, World, WorldSetup } from "@bendyline/molen-kernel";
7
7
  import { PackSet } from "@bendyline/molen-pack";
8
8
  import { AssertionResult, ComponentDiff, RecordedEvent } from "@bendyline/molen-kernel/testing";
9
9
  import { PMTiles } from "pmtiles";
10
+ //#region src/frame-stats.d.ts
11
+ /** A rectangle as fractions of the frame (0 to 1), so a check reads the same at any size. */
12
+ interface FrameRegion {
13
+ x: number;
14
+ y: number;
15
+ width: number;
16
+ height: number;
17
+ }
18
+ interface FrameStatsOptions {
19
+ /** Measure only this part of the frame. The background is still the whole frame's. */
20
+ region?: FrameRegion;
21
+ /** Channel difference above which a pixel counts as content, not background (default 24). */
22
+ tolerance?: number;
23
+ }
24
+ interface FrameStats {
25
+ width: number;
26
+ height: number;
27
+ /** The frame's most common color, taken as its backdrop: the clear color or an even sky. */
28
+ background: [number, number, number];
29
+ /** Fraction of the measured pixels that differ from the background by more than `tolerance`. */
30
+ coverage: number;
31
+ /** Distinct colors among the measured pixels, each channel quantized to 32 levels. */
32
+ colors: number;
33
+ /** Mean color of the measured pixels. */
34
+ mean: [number, number, number];
35
+ /** Mean of (r + g + b) / 3 over the measured pixels, 0-255. */
36
+ luminance: number;
37
+ }
38
+ /**
39
+ * Measure a rendered frame without a reference image: how much of it is content, how varied it
40
+ * is, and its mean color, for the whole frame or a region. Checks built on these (the frame is not
41
+ * blank, the model covers its part of the view, a lit room is brighter than an unlit one) hold on
42
+ * any machine, where a pixel comparison needs a reference recorded on the machine that compares.
43
+ */
44
+ declare function frameStats(path: string, options?: FrameStatsOptions): Promise<FrameStats>;
45
+ //#endregion
10
46
  //#region src/golden.d.ts
11
47
  interface ImageDiff {
12
48
  match: boolean;
@@ -44,8 +80,12 @@ interface ImportAssetInput {
44
80
  path: string;
45
81
  /** Asset id (default: slugged filename). Dotted ids fall under namespace reservations. */
46
82
  id?: string;
47
- /** Output assets root (default: <project dir>/assets, else ./assets). */
83
+ /** Output assets root; explicit overrides retain the <root>/<dotted-id-as-path> layout. */
48
84
  outDir?: string;
85
+ /** Exact bundle directory, relative to cwd when not absolute. Mutually exclusive with outDir.
86
+ * Without either override, reimports preserve the project-registered asset directory; new
87
+ * assets use <project dir>/assets/<dotted-id-as-path> (or ./assets without a project). */
88
+ assetDir?: string;
49
89
  /** Also extract a whole-asset collision trimesh into collision.bin. */
50
90
  trimesh?: boolean;
51
91
  /** Skip the normalize pass (dedup/prune/weld/quantize). */
@@ -1024,6 +1064,13 @@ interface SimulateOutput {
1024
1064
  notices?: ValidationIssue[];
1025
1065
  /** The pack content the world was built from (project.json `packs`, MOLEN_PACKS). */
1026
1066
  content?: ContentIdentity;
1067
+ /** Ambient life at the final tick, when the scene has an `ambient` block. */
1068
+ ambient?: {
1069
+ agents: Record<string, number>;
1070
+ spawned: number;
1071
+ despawned: number;
1072
+ lanes: number;
1073
+ };
1027
1074
  /** Set when something failed before running (bad scene, etc.). */
1028
1075
  error?: string;
1029
1076
  }
@@ -1292,4 +1339,4 @@ declare function schemaToTsType(schema: unknown, indent?: string): string;
1292
1339
  //#region src/index.d.ts
1293
1340
  declare const TOOLING_PACKAGE = "@bendyline/molen-tooling";
1294
1341
  //#endregion
1295
- export { ASSET_INDEX_FILE, type ApplyUvPaintInput, type ApplyUvPaintOutput, type AssetShotInput, type AssetShotOutput, type CameraSpec, type CheckTypesOutput, type DiffSnapshotsInput, type DiffSnapshotsOutput, type DocHit, type DriveAction, type DriveFrame, type DriveInput, type DriveOutput, type ExperiencePlayAction, type ExperiencePlayDiagnostic, type ExperiencePlayFrame, type ExperiencePlayInput, type ExperiencePlayOutput, type ExperiencePlayScenario, type ExportFramesInput, type ExportFramesOutput, type GenerateTypesInput, type GenerateTypesOutput, type GetComponentOutput, type GetSchemaOutput, type GoldenOptions, type GoldenResult, type ImageDiff, type ImportAssetInput, type ImportAssetOutput, type InspectAssetInput, type InspectAssetOutput, type ListAssetsOutput, type ListTemplatesOutput, type ListTypesOutput, type LoadSceneOptions, type LoadedScene, OPS_CATALOG, type OpDescriptor, type OpParam, type PackAssetInput, type PackAssetOutput, type PackTextureMode, type PackedAsset, type PackedTexture, type ProjectContext, type ProjectInfoInput, type ProjectInfoOutput, type RasterizeInput, type RasterizeOutput, type RenderStats, type ReserveNamespaceInput, type ReserveNamespaceOutput, type RunReplayInput, type RunReplayOutput, type ScaffoldInput, type ScaffoldOutput, type ScreenshotInput, type ScreenshotOutput, type ScriptDiagnostic, type SearchDocsInput, type SearchDocsOutput, type SimWatchHandle, type SimWatchInput, type SimulateInput, type SimulateOutput, type StageAssetsInput, type StageAssetsOutput, type StagedAsset, TOOLING_PACKAGE, type TemplateEntry, type TestTypesInput, type TestTypesOutput, type TypeTestResult, type ValidateInput, type ValidateOutput, type WorldgenBakeInput, type WorldgenBakeOutput, type WorldgenPreviewInput, type WorldgenPreviewOutput, type WorldgenStatsInput, type WorldgenStatsOutput, applyUvPaintOp, assetFileIndex, bakeWorldgen, buildContentPack, checkScripts, checkTypesOp, compareGolden, describeOps, diffImages, diffSnapshots, driveScene, exportFrames, extractContentPack, fetchContentPack, findProjectFile, formatOp, generateTypes, getComponentOp, getSchemaOp, importAsset, inspectAsset, inspectContentPack, lineupBatchDoc, listAssets, listComponentsOp, listSchemasOp, listTemplates, listTypes, loadProject, loadSceneDocument, loadSetupLike, loadStylePackFromDisk, locateDocsRoot, packAsset, parseExperiencePlayScenario, playExperience, previewWorldgen, projectInfo, rasterizeMaterial, registerExperiencePlaySchema, renderTypesModule, reserveNamespace, runReplayFile, runSimulation, scaffoldExperience, schemaToTsType, screenshotAsset, screenshotScene, searchDocs, simWatch, stageAssets, testTypes, updateProjectFile, validateAsset, verifyContentPack, worldgenStats };
1342
+ export { ASSET_INDEX_FILE, type ApplyUvPaintInput, type ApplyUvPaintOutput, type AssetShotInput, type AssetShotOutput, type CameraSpec, type CheckTypesOutput, type DiffSnapshotsInput, type DiffSnapshotsOutput, type DocHit, type DriveAction, type DriveFrame, type DriveInput, type DriveOutput, type ExperiencePlayAction, type ExperiencePlayDiagnostic, type ExperiencePlayFrame, type ExperiencePlayInput, type ExperiencePlayOutput, type ExperiencePlayScenario, type ExportFramesInput, type ExportFramesOutput, type FrameRegion, type FrameStats, type FrameStatsOptions, type GenerateTypesInput, type GenerateTypesOutput, type GetComponentOutput, type GetSchemaOutput, type GoldenOptions, type GoldenResult, type ImageDiff, type ImportAssetInput, type ImportAssetOutput, type InspectAssetInput, type InspectAssetOutput, type ListAssetsOutput, type ListTemplatesOutput, type ListTypesOutput, type LoadSceneOptions, type LoadedScene, OPS_CATALOG, type OpDescriptor, type OpParam, type PackAssetInput, type PackAssetOutput, type PackTextureMode, type PackedAsset, type PackedTexture, type ProjectContext, type ProjectInfoInput, type ProjectInfoOutput, type RasterizeInput, type RasterizeOutput, type RenderStats, type ReserveNamespaceInput, type ReserveNamespaceOutput, type RunReplayInput, type RunReplayOutput, type ScaffoldInput, type ScaffoldOutput, type ScreenshotInput, type ScreenshotOutput, type ScriptDiagnostic, type SearchDocsInput, type SearchDocsOutput, type SimWatchHandle, type SimWatchInput, type SimulateInput, type SimulateOutput, type StageAssetsInput, type StageAssetsOutput, type StagedAsset, TOOLING_PACKAGE, type TemplateEntry, type TestTypesInput, type TestTypesOutput, type TypeTestResult, type ValidateInput, type ValidateOutput, type WorldgenBakeInput, type WorldgenBakeOutput, type WorldgenPreviewInput, type WorldgenPreviewOutput, type WorldgenStatsInput, type WorldgenStatsOutput, applyUvPaintOp, assetFileIndex, bakeWorldgen, buildContentPack, checkScripts, checkTypesOp, compareGolden, describeOps, diffImages, diffSnapshots, driveScene, exportFrames, extractContentPack, fetchContentPack, findProjectFile, formatOp, frameStats, generateTypes, getComponentOp, getSchemaOp, importAsset, inspectAsset, inspectContentPack, lineupBatchDoc, listAssets, listComponentsOp, listSchemasOp, listTemplates, listTypes, loadProject, loadSceneDocument, loadSetupLike, loadStylePackFromDisk, locateDocsRoot, packAsset, parseExperiencePlayScenario, playExperience, previewWorldgen, projectInfo, rasterizeMaterial, registerExperiencePlaySchema, renderTypesModule, reserveNamespace, runReplayFile, runSimulation, scaffoldExperience, schemaToTsType, screenshotAsset, screenshotScene, searchDocs, simWatch, stageAssets, testTypes, updateProjectFile, validateAsset, verifyContentPack, worldgenStats };
package/dist/index.mjs CHANGED
@@ -1,8 +1,85 @@
1
- import { $ as assetFileIndex, A as inspectContentPack, B as OPS_CATALOG, C as checkTypesOp, D as buildContentPack, E as reserveNamespace, G as ASSET_INDEX_FILE, H as formatOp, I as exportFrames, K as stageAssets, L as driveScene, M as generateTypes, N as renderTypesModule, O as extractContentPack, Q as listAssets, R as locateDocsRoot, S as rasterizeMaterial, T as projectInfo, U as checkScripts, V as describeOps, W as schemaToTsType, X as packAsset, Z as inspectAsset, a as lineupBatchDoc, at as updateProjectFile, b as diffSnapshots, c as validateAsset, ct as registerExperiencePlaySchema, d as runSimulation, et as importAsset, f as screenshotScene, g as listSchemasOp, h as listComponentsOp, i as bakeWorldgen, it as loadSetupLike, j as verifyContentPack, k as fetchContentPack, l as applyUvPaintOp, m as getSchemaOp, n as worldgenStats, nt as loadProject, o as loadStylePackFromDisk, ot as parseExperiencePlayScenario, p as getComponentOp, q as screenshotAsset, r as previewWorldgen, rt as loadSceneDocument, s as simWatch, st as playExperience, tt as findProjectFile, u as testTypes, v as scaffoldExperience, w as listTypes, x as runReplayFile, y as listTemplates, z as searchDocs } from "./ops-C4BvDgP-.mjs";
1
+ import { A as inspectContentPack, B as searchDocs, C as checkTypesOp, D as buildContentPack, E as reserveNamespace, G as schemaToTsType, H as describeOps, L as exportFrames, N as generateTypes, O as extractContentPack, P as renderTypesModule, R as driveScene, S as rasterizeMaterial, T as projectInfo, U as formatOp, V as OPS_CATALOG, W as checkScripts, X as stageAssets, Y as ASSET_INDEX_FILE, Z as screenshotAsset, a as lineupBatchDoc, at as findProjectFile, b as diffSnapshots, c as validateAsset, ct as loadSetupLike, d as runSimulation, dt as playExperience, et as packAsset, f as screenshotScene, ft as registerExperiencePlaySchema, g as listSchemasOp, h as listComponentsOp, i as bakeWorldgen, it as importAsset, j as verifyContentPack, k as fetchContentPack, l as applyUvPaintOp, lt as updateProjectFile, m as getSchemaOp, n as worldgenStats, nt as listAssets, o as loadStylePackFromDisk, ot as loadProject, p as getComponentOp, r as previewWorldgen, rt as assetFileIndex, s as simWatch, st as loadSceneDocument, tt as inspectAsset, u as testTypes, ut as parseExperiencePlayScenario, v as scaffoldExperience, w as listTypes, x as runReplayFile, y as listTemplates, z as locateDocsRoot } from "./ops-DMGcWoL2.mjs";
2
2
  import { access, copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import { PNG } from "pngjs";
3
4
  import { dirname } from "node:path";
4
5
  import pixelmatch from "pixelmatch";
5
- import { PNG } from "pngjs";
6
+ //#region src/frame-stats.ts
7
+ const quantize = (r, g, b) => r >> 3 << 10 | g >> 3 << 5 | b >> 3;
8
+ /**
9
+ * Measure a rendered frame without a reference image: how much of it is content, how varied it
10
+ * is, and its mean color, for the whole frame or a region. Checks built on these (the frame is not
11
+ * blank, the model covers its part of the view, a lit room is brighter than an unlit one) hold on
12
+ * any machine, where a pixel comparison needs a reference recorded on the machine that compares.
13
+ */
14
+ async function frameStats(path, options = {}) {
15
+ const { width, height, data } = PNG.sync.read(await readFile(path));
16
+ const histogram = /* @__PURE__ */ new Map();
17
+ for (let i = 0; i < data.length; i += 4) {
18
+ const key = quantize(data[i] ?? 0, data[i + 1] ?? 0, data[i + 2] ?? 0);
19
+ histogram.set(key, (histogram.get(key) ?? 0) + 1);
20
+ }
21
+ let backgroundKey = 0;
22
+ let best = -1;
23
+ for (const [key, count] of histogram) if (count > best) {
24
+ best = count;
25
+ backgroundKey = key;
26
+ }
27
+ const background = [
28
+ (backgroundKey >> 10 << 3) + 4,
29
+ ((backgroundKey >> 5 & 31) << 3) + 4,
30
+ ((backgroundKey & 31) << 3) + 4
31
+ ];
32
+ const region = options.region ?? {
33
+ x: 0,
34
+ y: 0,
35
+ width: 1,
36
+ height: 1
37
+ };
38
+ const x0 = Math.max(0, Math.floor(region.x * width));
39
+ const y0 = Math.max(0, Math.floor(region.y * height));
40
+ const x1 = Math.min(width, Math.ceil((region.x + region.width) * width));
41
+ const y1 = Math.min(height, Math.ceil((region.y + region.height) * height));
42
+ const tolerance = options.tolerance ?? 24;
43
+ const colors = /* @__PURE__ */ new Set();
44
+ let content = 0;
45
+ let count = 0;
46
+ const sum = [
47
+ 0,
48
+ 0,
49
+ 0
50
+ ];
51
+ for (let y = y0; y < y1; y++) for (let x = x0; x < x1; x++) {
52
+ const i = (y * width + x) * 4;
53
+ const r = data[i] ?? 0;
54
+ const g = data[i + 1] ?? 0;
55
+ const b = data[i + 2] ?? 0;
56
+ sum[0] += r;
57
+ sum[1] += g;
58
+ sum[2] += b;
59
+ colors.add(quantize(r, g, b));
60
+ if (Math.max(Math.abs(r - background[0]), Math.abs(g - background[1]), Math.abs(b - background[2])) > tolerance) content++;
61
+ count++;
62
+ }
63
+ const mean = count === 0 ? [
64
+ 0,
65
+ 0,
66
+ 0
67
+ ] : [
68
+ sum[0] / count,
69
+ sum[1] / count,
70
+ sum[2] / count
71
+ ];
72
+ return {
73
+ width,
74
+ height,
75
+ background,
76
+ coverage: count === 0 ? 0 : content / count,
77
+ colors: colors.size,
78
+ mean,
79
+ luminance: (mean[0] + mean[1] + mean[2]) / 3
80
+ };
81
+ }
82
+ //#endregion
6
83
  //#region src/golden.ts
7
84
  async function exists(p) {
8
85
  try {
@@ -61,7 +138,7 @@ async function compareGolden(candidatePath, goldenPath, diffPath, opts = {}) {
61
138
  if (!await exists(goldenPath)) return {
62
139
  ok: false,
63
140
  created: false,
64
- reason: `no committed golden at ${goldenPath}; the candidate is at ${candidatePath}. Record one with UPDATE_GOLDENS=1 (locally that produces a candidate only — the authoritative refresh is the "Update goldens" workflow, which records in the pinned CI container).`
141
+ reason: `no committed golden at ${goldenPath}; the candidate is at ${candidatePath}. Record one with UPDATE_GOLDENS=1 on the kind of machine that compares: software rendering differs between machines.`
65
142
  };
66
143
  const result = await diffImages(goldenPath, candidatePath, diffPath, opts.maxDiffRatio);
67
144
  return {
@@ -75,4 +152,4 @@ async function compareGolden(candidatePath, goldenPath, diffPath, opts = {}) {
75
152
  //#region src/index.ts
76
153
  const TOOLING_PACKAGE = "@bendyline/molen-tooling";
77
154
  //#endregion
78
- export { ASSET_INDEX_FILE, OPS_CATALOG, TOOLING_PACKAGE, applyUvPaintOp, assetFileIndex, bakeWorldgen, buildContentPack, checkScripts, checkTypesOp, compareGolden, describeOps, diffImages, diffSnapshots, driveScene, exportFrames, extractContentPack, fetchContentPack, findProjectFile, formatOp, generateTypes, getComponentOp, getSchemaOp, importAsset, inspectAsset, inspectContentPack, lineupBatchDoc, listAssets, listComponentsOp, listSchemasOp, listTemplates, listTypes, loadProject, loadSceneDocument, loadSetupLike, loadStylePackFromDisk, locateDocsRoot, packAsset, parseExperiencePlayScenario, playExperience, previewWorldgen, projectInfo, rasterizeMaterial, registerExperiencePlaySchema, renderTypesModule, reserveNamespace, runReplayFile, runSimulation, scaffoldExperience, schemaToTsType, screenshotAsset, screenshotScene, searchDocs, simWatch, stageAssets, testTypes, updateProjectFile, validateAsset, verifyContentPack, worldgenStats };
155
+ export { ASSET_INDEX_FILE, OPS_CATALOG, TOOLING_PACKAGE, applyUvPaintOp, assetFileIndex, bakeWorldgen, buildContentPack, checkScripts, checkTypesOp, compareGolden, describeOps, diffImages, diffSnapshots, driveScene, exportFrames, extractContentPack, fetchContentPack, findProjectFile, formatOp, frameStats, generateTypes, getComponentOp, getSchemaOp, importAsset, inspectAsset, inspectContentPack, lineupBatchDoc, listAssets, listComponentsOp, listSchemasOp, listTemplates, listTypes, loadProject, loadSceneDocument, loadSetupLike, loadStylePackFromDisk, locateDocsRoot, packAsset, parseExperiencePlayScenario, playExperience, previewWorldgen, projectInfo, rasterizeMaterial, registerExperiencePlaySchema, renderTypesModule, reserveNamespace, runReplayFile, runSimulation, scaffoldExperience, schemaToTsType, screenshotAsset, screenshotScene, searchDocs, simWatch, stageAssets, testTypes, updateProjectFile, validateAsset, verifyContentPack, worldgenStats };
@@ -1,4 +1,4 @@
1
- import { A as inspectContentPack, C as checkTypesOp, D as buildContentPack, E as reserveNamespace, F as listFigurePresets, H as formatOp, I as exportFrames, K as stageAssets, L as driveScene, M as generateTypes, O as extractContentPack, P as previewFigure, Q as listAssets, S as rasterizeMaterial, T as projectInfo, U as checkScripts, V as describeOps, X as packAsset, Y as formatPacked, Z as inspectAsset, _ as loadComponentRegistry, b as diffSnapshots, c as validateAsset, d as runSimulation, et as importAsset, f as screenshotScene, g as listSchemasOp, h as listComponentsOp, i as bakeWorldgen, j as verifyContentPack, k as fetchContentPack, l as applyUvPaintOp, m as getSchemaOp, n as worldgenStats, p as getComponentOp, q as screenshotAsset, r as previewWorldgen, st as playExperience, u as testTypes, v as scaffoldExperience, w as listTypes, x as runReplayFile, y as listTemplates, z as searchDocs } from "./ops-C4BvDgP-.mjs";
1
+ import { $ as formatPacked, A as inspectContentPack, B as searchDocs, C as checkTypesOp, D as buildContentPack, E as reserveNamespace, F as previewFigure, H as describeOps, I as listFigurePresets, J as checkSoundbank, K as planAudio, L as exportFrames, M as bakeNetwork, N as generateTypes, O as extractContentPack, R as driveScene, S as rasterizeMaterial, T as projectInfo, U as formatOp, W as checkScripts, X as stageAssets, Z as screenshotAsset, _ as loadComponentRegistry, b as diffSnapshots, c as validateAsset, d as runSimulation, dt as playExperience, et as packAsset, f as screenshotScene, g as listSchemasOp, h as listComponentsOp, i as bakeWorldgen, it as importAsset, j as verifyContentPack, k as fetchContentPack, l as applyUvPaintOp, m as getSchemaOp, n as worldgenStats, nt as listAssets, p as getComponentOp, q as importSound, r as previewWorldgen, tt as inspectAsset, u as testTypes, v as scaffoldExperience, w as listTypes, x as runReplayFile, y as listTemplates } from "./ops-DMGcWoL2.mjs";
2
2
  import { mkdtemp, readFile, rm } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  import { z } from "zod";
@@ -167,7 +167,7 @@ function createMcpServer() {
167
167
  }, async (args) => {
168
168
  const r = await runReplayFile(args);
169
169
  if (r.error !== void 0) return text(r.error, true);
170
- return text(r.report ?? (r.ok ? "✓ replay matches" : "✖ replay diverged"), !r.ok);
170
+ return text(r.report ?? (r.ok ? "✓ replay matches" : "× replay diverged"), !r.ok);
171
171
  });
172
172
  server.registerTool("apply_uv_paint", {
173
173
  title: "Apply UV paint",
@@ -469,6 +469,27 @@ function createMcpServer() {
469
469
  if (!r.ok) return text(r.error ?? "worldgen bake failed", true);
470
470
  return text(JSON.stringify(r, null, 2));
471
471
  });
472
+ server.registerTool("network_bake", {
473
+ title: "Bake a transport network",
474
+ description: "Bake the roads, railways and paths of a local terrain package into a molen/transport-network@1 document (recentred on the area, origin recorded) for ambient traffic in scenes without map tiles.",
475
+ inputSchema: {
476
+ packagePath: z.string(),
477
+ tile: z.string().optional(),
478
+ radius: z.number().int().nonnegative().optional(),
479
+ bbox: z.array(z.number()).length(4).optional(),
480
+ classes: z.array(z.enum([
481
+ "road",
482
+ "rail",
483
+ "path"
484
+ ])).optional(),
485
+ outPath: z.string(),
486
+ heights: z.boolean().optional()
487
+ }
488
+ }, async (args) => {
489
+ const r = await bakeNetwork(args);
490
+ if (!r.ok) return text(r.error ?? "network bake failed", true);
491
+ return text(JSON.stringify(r, null, 2));
492
+ });
472
493
  server.registerTool("worldgen_stats", {
473
494
  title: "Worldgen tile stats",
474
495
  description: "Generate one real terrain-package tile in Node and report counts, footprint and roof histograms, sizes, timings, and determinism; optionally dump the adapted batch document.",
@@ -503,7 +524,7 @@ function createMcpServer() {
503
524
  }, async (args) => {
504
525
  const r = await testTypes(args);
505
526
  if (r.error !== void 0) return text(r.error, true);
506
- return text((r.results ?? []).map((t) => `${t.ok ? "✓" : "✖"} ${t.id}${t.error !== void 0 ? ` — ${t.error}` : ""}${t.issues !== void 0 ? ` — ${t.issues.map((i) => i.message).join("; ")}` : ""}`).join("\n") || "(no types registered)", !r.ok);
527
+ return text((r.results ?? []).map((t) => `${t.ok ? "✓" : "×"} ${t.id}${t.error !== void 0 ? ` — ${t.error}` : ""}${t.issues !== void 0 ? ` — ${t.issues.map((i) => i.message).join("; ")}` : ""}`).join("\n") || "(no types registered)", !r.ok);
507
528
  });
508
529
  server.registerTool("import_asset", {
509
530
  title: "Import asset",
@@ -512,6 +533,7 @@ function createMcpServer() {
512
533
  path: z.string(),
513
534
  id: z.string().optional(),
514
535
  outDir: z.string().optional(),
536
+ assetDir: z.string().optional(),
515
537
  trimesh: z.boolean().optional(),
516
538
  optimize: z.boolean().optional(),
517
539
  projectPath: z.string().optional(),
@@ -645,6 +667,69 @@ function createMcpServer() {
645
667
  if (!r.ok) return text(r.error ?? "pack fetch failed", true);
646
668
  return text([...(r.packs ?? []).map((pack) => `${pack.id}@${pack.version} -> ${r.outDir}/${pack.file} (${pack.size} bytes)`), r.projectPath !== void 0 ? `pinned in ${r.projectPath}` : "no project.json to pin in"].join("\n"));
647
669
  });
670
+ server.registerTool("plan_audio", {
671
+ title: "Plan a scene's audio",
672
+ description: "Run a scene headlessly and list the sounds it would play: looping voices with start/stop ticks, peak gain and pitch range, one-shots by tick, audio.* script events, plus unknown sound ids and signals. Sound banks come from bankPaths or the project's packs (provides.soundbank). Returns the text timeline followed by the JSON report.",
673
+ inputSchema: {
674
+ scenePath: z.string(),
675
+ ticks: z.number().int().positive(),
676
+ bankPaths: z.array(z.string()).optional(),
677
+ commandsPath: z.string().optional(),
678
+ setupModule: z.string().optional(),
679
+ listener: z.string().optional(),
680
+ mode: z.string().optional(),
681
+ weather: z.string().optional(),
682
+ daylight: z.number().min(0).max(1).optional(),
683
+ projectPath: z.string().optional()
684
+ }
685
+ }, async (args) => {
686
+ const r = await planAudio(args);
687
+ if (r.error !== void 0) return text(r.error, true);
688
+ const { timeline, ...report } = r;
689
+ return text(`${timeline}\n\n${JSON.stringify(report, null, 2)}`, !r.ok);
690
+ });
691
+ server.registerTool("import_sound", {
692
+ title: "Import a sound",
693
+ description: "Add an audio clip to a molen/soundbank@1 file: copy it beside the bank, hash it, probe its duration, record license and provenance (source url, site, author, or prompt + generator). append adds a variation to an existing sound id. Rejects a license the bank policy does not allow.",
694
+ inputSchema: {
695
+ file: z.string(),
696
+ id: z.string(),
697
+ bankPath: z.string(),
698
+ license: z.string(),
699
+ source: z.string().optional(),
700
+ site: z.string().optional(),
701
+ author: z.string().optional(),
702
+ prompt: z.string().optional(),
703
+ generator: z.string().optional(),
704
+ description: z.string().optional(),
705
+ loop: z.boolean().optional(),
706
+ loopStart: z.number().nonnegative().optional(),
707
+ loopEnd: z.number().nonnegative().optional(),
708
+ bus: z.string().optional(),
709
+ gain: z.number().nonnegative().optional(),
710
+ durationS: z.number().positive().optional(),
711
+ append: z.boolean().optional(),
712
+ copyTo: z.string().optional()
713
+ }
714
+ }, async (args) => {
715
+ const r = await importSound(args);
716
+ const notes = r.warnings.map((w) => `! ${w}`).join("\n");
717
+ if (!r.ok) return text([notes, r.error ?? "import failed"].filter(Boolean).join("\n"), true);
718
+ return text([
719
+ notes,
720
+ `${r.id}: ${r.clip} -> ${r.bankPath}`,
721
+ JSON.stringify(r.entry, null, 2)
722
+ ].filter(Boolean).join("\n"));
723
+ });
724
+ server.registerTool("check_soundbank", {
725
+ title: "Check a sound bank",
726
+ description: "Check a molen/soundbank@1 file and every clip it names: files present, hashes unchanged since import, durations and loop points consistent, provenance recorded. Returns issues and a license summary as JSON.",
727
+ inputSchema: { bankPath: z.string() }
728
+ }, async (args) => {
729
+ const r = await checkSoundbank(args);
730
+ if (r.error !== void 0) return text(r.error, true);
731
+ return text(JSON.stringify(r, null, 2), !r.ok);
732
+ });
648
733
  server.registerTool("list_assets", {
649
734
  title: "List assets",
650
735
  description: "List the assets registered in the surrounding project.",