@bendyline/molen-tooling 0.0.3 → 0.0.5
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 +4 -4
- package/dist/capture/harness.js +231 -231
- package/dist/capture/worldgen-preview.js +206 -206
- package/dist/cli.mjs +54 -2
- package/dist/docs-src/guide/adaptive-performance.md +5 -2
- package/dist/docs-src/guide/aircraft.md +12 -0
- package/dist/docs-src/guide/ambient-life.md +389 -0
- package/dist/docs-src/guide/browser-mount.md +5 -0
- package/dist/docs-src/guide/capability-authoring.md +5 -0
- package/dist/docs-src/guide/determinism.md +24 -16
- package/dist/docs-src/guide/earth-view.md +108 -20
- package/dist/docs-src/guide/entities.md +8 -0
- package/dist/docs-src/guide/examples.md +4 -1
- package/dist/docs-src/guide/figures.md +3 -0
- package/dist/docs-src/guide/game-samples.md +1 -1
- package/dist/docs-src/guide/markers.md +7 -1
- package/dist/docs-src/guide/navigation.md +10 -1
- package/dist/docs-src/guide/sky.md +5 -0
- package/dist/docs-src/guide/surface-rendering.md +7 -4
- package/dist/docs-src/guide/terrain.md +58 -3
- package/dist/docs-src/guide/vehicles.md +14 -1
- package/dist/docs-src/guide/worldgen.md +30 -17
- package/dist/docs-src/llms.txt +7 -4
- package/dist/docs-src/schemas/README.md +1 -0
- package/dist/docs-src/schemas/components.md +530 -1
- package/dist/docs-src/schemas/scene.md +105 -0
- package/dist/docs-src/schemas/terrain-package.md +102 -0
- package/dist/docs-src/schemas/transport-network.md +351 -0
- package/dist/index.d.mts +44 -1
- package/dist/index.mjs +81 -4
- package/dist/{mcp-BTVwVKFb.mjs → mcp-DKm1h9hD.mjs} +22 -1
- package/dist/{ops-BPdHodFR.mjs → ops-DHyZWZUE.mjs} +291 -66
- package/dist/templates/city-courier/README.md +1 -1
- package/dist/templates/city-courier/delivery-run.replay.json +151 -151
- package/dist/templates/city-courier/gen/molen-types.ts +82 -2
- package/dist/templates/city-courier/package.json +1 -0
- package/dist/templates/city-courier/scene.json +99 -282
- package/dist/templates/city-courier/scripts/game.ts +2 -14
- package/dist/templates/city-courier/scripts/molen-scripts.d.ts +86 -13
- package/dist/templates/city-courier/src/worker.ts +3 -1
- package/dist/templates/city-courier/test/headless.test.ts +3 -2
- package/dist/templates/data-viz/README.md +1 -1
- package/dist/templates/index.json +19 -1
- package/dist/templates/skybound/gen/molen-types.ts +82 -2
- package/dist/templates/skybound/scripts/molen-scripts.d.ts +81 -1
- package/dist/templates/terrain-flyover/README.md +2 -2
- package/dist/templates/top-down-arena/README.md +1 -1
- package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +81 -1
- package/dist/templates/top-down-arena/src/gen/molen-types.ts +82 -2
- package/package.json +13 -12
|
@@ -682,6 +682,108 @@ Installable tiled-world package: coordinate space, elevation, optional semantic
|
|
|
682
682
|
"type": "string",
|
|
683
683
|
"const": "protomaps-basemap@1",
|
|
684
684
|
"description": "Attribute profile of the tiles; always 'protomaps-basemap@1' when set."
|
|
685
|
+
},
|
|
686
|
+
"buildingDetail": {
|
|
687
|
+
"type": "object",
|
|
688
|
+
"properties": {
|
|
689
|
+
"source": {
|
|
690
|
+
"anyOf": [
|
|
691
|
+
{
|
|
692
|
+
"type": "object",
|
|
693
|
+
"properties": {
|
|
694
|
+
"kind": {
|
|
695
|
+
"type": "string",
|
|
696
|
+
"const": "pmtiles",
|
|
697
|
+
"description": "Archive kind; always 'pmtiles'."
|
|
698
|
+
},
|
|
699
|
+
"path": {
|
|
700
|
+
"type": "string",
|
|
701
|
+
"minLength": 1,
|
|
702
|
+
"description": "Package-relative path of the PMTiles archive."
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
"required": [
|
|
706
|
+
"kind",
|
|
707
|
+
"path"
|
|
708
|
+
],
|
|
709
|
+
"additionalProperties": false
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"type": "object",
|
|
713
|
+
"properties": {
|
|
714
|
+
"kind": {
|
|
715
|
+
"type": "string",
|
|
716
|
+
"const": "pmtiles",
|
|
717
|
+
"description": "Archive kind; always 'pmtiles'."
|
|
718
|
+
},
|
|
719
|
+
"url": {
|
|
720
|
+
"type": "string",
|
|
721
|
+
"format": "uri",
|
|
722
|
+
"description": "Absolute URL of the PMTiles archive."
|
|
723
|
+
}
|
|
724
|
+
},
|
|
725
|
+
"required": [
|
|
726
|
+
"kind",
|
|
727
|
+
"url"
|
|
728
|
+
],
|
|
729
|
+
"additionalProperties": false
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
"type": "object",
|
|
733
|
+
"properties": {
|
|
734
|
+
"kind": {
|
|
735
|
+
"type": "string",
|
|
736
|
+
"const": "pmtiles-set",
|
|
737
|
+
"description": "Archive kind 'pmtiles-set': a molen/archive-set@1 document naming many archives."
|
|
738
|
+
},
|
|
739
|
+
"path": {
|
|
740
|
+
"type": "string",
|
|
741
|
+
"minLength": 1,
|
|
742
|
+
"description": "Package-relative path of the archive-set document."
|
|
743
|
+
}
|
|
744
|
+
},
|
|
745
|
+
"required": [
|
|
746
|
+
"kind",
|
|
747
|
+
"path"
|
|
748
|
+
],
|
|
749
|
+
"additionalProperties": false
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
"type": "object",
|
|
753
|
+
"properties": {
|
|
754
|
+
"kind": {
|
|
755
|
+
"type": "string",
|
|
756
|
+
"const": "pmtiles-set",
|
|
757
|
+
"description": "Archive kind 'pmtiles-set': a molen/archive-set@1 document naming many archives."
|
|
758
|
+
},
|
|
759
|
+
"url": {
|
|
760
|
+
"type": "string",
|
|
761
|
+
"format": "uri",
|
|
762
|
+
"description": "Absolute URL of the archive-set document."
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
"required": [
|
|
766
|
+
"kind",
|
|
767
|
+
"url"
|
|
768
|
+
],
|
|
769
|
+
"additionalProperties": false
|
|
770
|
+
}
|
|
771
|
+
],
|
|
772
|
+
"description": "Archive holding finer feature tiles read only for building footprints and places."
|
|
773
|
+
},
|
|
774
|
+
"level": {
|
|
775
|
+
"type": "integer",
|
|
776
|
+
"minimum": 0,
|
|
777
|
+
"maximum": 30,
|
|
778
|
+
"description": "The one level the archive is read at (e.g. 15, where Protomaps keeps every building)."
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
"required": [
|
|
782
|
+
"source",
|
|
783
|
+
"level"
|
|
784
|
+
],
|
|
785
|
+
"additionalProperties": false,
|
|
786
|
+
"description": "Optional finer tiles for buildings: basemaps generalize footprints below their last zoom, so coarser feature tiles take their buildings from this level where it has tiles."
|
|
685
787
|
}
|
|
686
788
|
},
|
|
687
789
|
"required": [
|
|
@@ -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;
|
|
@@ -1028,6 +1064,13 @@ interface SimulateOutput {
|
|
|
1028
1064
|
notices?: ValidationIssue[];
|
|
1029
1065
|
/** The pack content the world was built from (project.json `packs`, MOLEN_PACKS). */
|
|
1030
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
|
+
};
|
|
1031
1074
|
/** Set when something failed before running (bad scene, etc.). */
|
|
1032
1075
|
error?: string;
|
|
1033
1076
|
}
|
|
@@ -1296,4 +1339,4 @@ declare function schemaToTsType(schema: unknown, indent?: string): string;
|
|
|
1296
1339
|
//#region src/index.d.ts
|
|
1297
1340
|
declare const TOOLING_PACKAGE = "@bendyline/molen-tooling";
|
|
1298
1341
|
//#endregion
|
|
1299
|
-
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 {
|
|
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-DHyZWZUE.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
|
-
|
|
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
|
|
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 { $ as
|
|
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-DHyZWZUE.mjs";
|
|
2
2
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -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.",
|