@plasius/gpu-world-generator 0.0.10 → 0.0.12

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/dist/index.cjs CHANGED
@@ -57,13 +57,17 @@ __export(index_exports, {
57
57
  createFractalPrepassRunner: () => createFractalPrepassRunner,
58
58
  createMeshBuilder: () => createMeshBuilder,
59
59
  createPerfMonitor: () => createPerfMonitor,
60
+ createWorldGeneratorRepresentationPlan: () => createWorldGeneratorRepresentationPlan,
60
61
  defaultFieldParams: () => defaultFieldParams,
61
62
  defaultFractalMandelSettings: () => defaultFractalMandelSettings,
63
+ defaultWorldGeneratorWorkerProfile: () => defaultWorldGeneratorWorkerProfile,
62
64
  encodeTerrainParams: () => encodeTerrainParams,
63
65
  fieldWgslUrl: () => fieldWgslUrl,
64
66
  fractalPrepassWgslUrl: () => fractalPrepassWgslUrl,
65
67
  generateHexGrid: () => generateHexGrid,
66
68
  generateTemperateMixedForest: () => generateTemperateMixedForest,
69
+ getWorldGeneratorWorkerManifest: () => getWorldGeneratorWorkerManifest,
70
+ getWorldGeneratorWorkerProfile: () => getWorldGeneratorWorkerProfile,
67
71
  hexAreaFromSide: () => hexAreaFromSide,
68
72
  hexSideFromArea: () => hexSideFromArea,
69
73
  loadFieldWgsl: () => loadFieldWgsl,
@@ -89,7 +93,14 @@ __export(index_exports, {
89
93
  tileKeyFromWorldPosition: () => tileKeyFromWorldPosition,
90
94
  tileKeyToString: () => tileKeyToString,
91
95
  unpackTerrain: () => unpackTerrain,
92
- validateTileAssetPayload: () => validateTileAssetPayload
96
+ validateTileAssetPayload: () => validateTileAssetPayload,
97
+ worldGeneratorDebugOwner: () => worldGeneratorDebugOwner,
98
+ worldGeneratorRepresentationBands: () => worldGeneratorRepresentationBands,
99
+ worldGeneratorRepresentationOutputs: () => worldGeneratorRepresentationOutputs,
100
+ worldGeneratorWorkerManifests: () => worldGeneratorWorkerManifests,
101
+ worldGeneratorWorkerProfileNames: () => worldGeneratorWorkerProfileNames,
102
+ worldGeneratorWorkerProfiles: () => worldGeneratorWorkerProfiles,
103
+ worldGeneratorWorkerQueueClass: () => worldGeneratorWorkerQueueClass
93
104
  });
94
105
  module.exports = __toCommonJS(index_exports);
95
106
 
@@ -1877,6 +1888,751 @@ function createMeshBuilder(sizeOrOptions = 1) {
1877
1888
  }
1878
1889
  };
1879
1890
  }
1891
+
1892
+ // src/worker.ts
1893
+ var worldGeneratorDebugOwner = "world-generator";
1894
+ var worldGeneratorWorkerQueueClass = "voxel";
1895
+ var defaultWorldGeneratorWorkerProfile = "streaming";
1896
+ var worldGeneratorRepresentationBands = Object.freeze([
1897
+ "near",
1898
+ "mid",
1899
+ "far",
1900
+ "horizon"
1901
+ ]);
1902
+ var worldGeneratorRepresentationOutputs = Object.freeze([
1903
+ "liveGeometry",
1904
+ "simplifiedGeometry",
1905
+ "rtProxy",
1906
+ "mergedProxy",
1907
+ "horizonShell"
1908
+ ]);
1909
+ var worldGeneratorRepresentationBandPriorityHints = Object.freeze({
1910
+ near: 400,
1911
+ mid: 300,
1912
+ far: 200,
1913
+ horizon: 100
1914
+ });
1915
+ function assertWorldGeneratorIdentifier(name, value) {
1916
+ if (typeof value !== "string" || value.trim().length === 0) {
1917
+ throw new Error(`${name} must be a non-empty string.`);
1918
+ }
1919
+ return value.trim();
1920
+ }
1921
+ function normalizeWorldGeneratorImportance(name, value) {
1922
+ if (value === "medium" || value === "high" || value === "critical") {
1923
+ return value;
1924
+ }
1925
+ throw new Error(`${name} must be one of: medium, high, critical.`);
1926
+ }
1927
+ function buildWorldGeneratorRepresentationDescriptor(options) {
1928
+ return Object.freeze({
1929
+ id: `${options.chunkId}.${options.band}.${options.output}`,
1930
+ chunkId: options.chunkId,
1931
+ profile: options.profile,
1932
+ band: options.band,
1933
+ output: options.output,
1934
+ rasterMode: options.rasterMode,
1935
+ rtParticipation: options.rtParticipation,
1936
+ shadowRelevance: options.shadowRelevance,
1937
+ refreshCadence: Object.freeze({
1938
+ kind: options.refreshCadence.kind,
1939
+ divisor: options.refreshCadence.divisor
1940
+ }),
1941
+ preservesChunkIdentity: options.preservesChunkIdentity,
1942
+ sourceChunkIds: Object.freeze([options.chunkId]),
1943
+ sourceJobKeys: Object.freeze([...options.sourceJobKeys]),
1944
+ suggestedAllocationIds: Object.freeze([...options.suggestedAllocationIds]),
1945
+ scheduling: Object.freeze({
1946
+ owner: "renderer",
1947
+ queueClass: worldGeneratorWorkerQueueClass,
1948
+ priorityHint: worldGeneratorRepresentationBandPriorityHints[options.band],
1949
+ gameplayImportance: options.gameplayImportance,
1950
+ representationBand: options.band
1951
+ })
1952
+ });
1953
+ }
1954
+ function buildBudgetLevels(jobType, queueClass, levels) {
1955
+ return Object.freeze(
1956
+ levels.map(
1957
+ (level) => Object.freeze({
1958
+ id: level.id,
1959
+ estimatedCostMs: level.estimatedCostMs,
1960
+ config: Object.freeze({
1961
+ maxDispatchesPerFrame: level.config.maxDispatchesPerFrame,
1962
+ maxJobsPerDispatch: level.config.maxJobsPerDispatch,
1963
+ cadenceDivisor: level.config.cadenceDivisor,
1964
+ workgroupScale: level.config.workgroupScale,
1965
+ maxQueueDepth: level.config.maxQueueDepth,
1966
+ metadata: Object.freeze({
1967
+ owner: worldGeneratorDebugOwner,
1968
+ queueClass,
1969
+ jobType,
1970
+ quality: level.id
1971
+ })
1972
+ })
1973
+ })
1974
+ )
1975
+ );
1976
+ }
1977
+ var worldGeneratorWorkerProfileSpecs = {
1978
+ streaming: {
1979
+ description: "Runtime chunk generation DAG for fractal prepass, terrain synthesis, voxel materialization, mesh build, and tile bake.",
1980
+ suggestedAllocationIds: [
1981
+ "world.chunk.field.scratch",
1982
+ "world.chunk.height.buffer",
1983
+ "world.chunk.voxel.buffer",
1984
+ "world.chunk.mesh.buffer"
1985
+ ],
1986
+ jobs: {
1987
+ fractalPrepass: {
1988
+ priority: 4,
1989
+ dependencies: [],
1990
+ domain: "custom",
1991
+ authority: "authoritative",
1992
+ importance: "high",
1993
+ levels: [
1994
+ {
1995
+ id: "fixed",
1996
+ estimatedCostMs: 0.6,
1997
+ config: {
1998
+ maxDispatchesPerFrame: 1,
1999
+ maxJobsPerDispatch: 1,
2000
+ cadenceDivisor: 1,
2001
+ workgroupScale: 1,
2002
+ maxQueueDepth: 32
2003
+ }
2004
+ }
2005
+ ],
2006
+ suggestedAllocationIds: ["world.chunk.field.scratch"]
2007
+ },
2008
+ fieldSynthesis: {
2009
+ priority: 4,
2010
+ dependencies: [],
2011
+ domain: "custom",
2012
+ authority: "authoritative",
2013
+ importance: "critical",
2014
+ levels: [
2015
+ {
2016
+ id: "fixed",
2017
+ estimatedCostMs: 0.9,
2018
+ config: {
2019
+ maxDispatchesPerFrame: 1,
2020
+ maxJobsPerDispatch: 2,
2021
+ cadenceDivisor: 1,
2022
+ workgroupScale: 1,
2023
+ maxQueueDepth: 48
2024
+ }
2025
+ }
2026
+ ],
2027
+ suggestedAllocationIds: ["world.chunk.field.scratch"]
2028
+ },
2029
+ terrainSynthesis: {
2030
+ priority: 5,
2031
+ dependencies: ["fractalPrepass", "fieldSynthesis"],
2032
+ domain: "custom",
2033
+ authority: "authoritative",
2034
+ importance: "critical",
2035
+ levels: [
2036
+ {
2037
+ id: "fixed",
2038
+ estimatedCostMs: 1.4,
2039
+ config: {
2040
+ maxDispatchesPerFrame: 1,
2041
+ maxJobsPerDispatch: 1,
2042
+ cadenceDivisor: 1,
2043
+ workgroupScale: 1,
2044
+ maxQueueDepth: 32
2045
+ }
2046
+ }
2047
+ ],
2048
+ suggestedAllocationIds: ["world.chunk.height.buffer"]
2049
+ },
2050
+ voxelMaterialize: {
2051
+ priority: 3,
2052
+ dependencies: ["terrainSynthesis"],
2053
+ domain: "custom",
2054
+ authority: "non-authoritative-simulation",
2055
+ importance: "high",
2056
+ levels: [
2057
+ {
2058
+ id: "low",
2059
+ estimatedCostMs: 0.8,
2060
+ config: {
2061
+ maxDispatchesPerFrame: 1,
2062
+ maxJobsPerDispatch: 1,
2063
+ cadenceDivisor: 2,
2064
+ workgroupScale: 0.6,
2065
+ maxQueueDepth: 24
2066
+ }
2067
+ },
2068
+ {
2069
+ id: "medium",
2070
+ estimatedCostMs: 1.2,
2071
+ config: {
2072
+ maxDispatchesPerFrame: 1,
2073
+ maxJobsPerDispatch: 2,
2074
+ cadenceDivisor: 1,
2075
+ workgroupScale: 0.8,
2076
+ maxQueueDepth: 32
2077
+ }
2078
+ },
2079
+ {
2080
+ id: "high",
2081
+ estimatedCostMs: 1.8,
2082
+ config: {
2083
+ maxDispatchesPerFrame: 2,
2084
+ maxJobsPerDispatch: 2,
2085
+ cadenceDivisor: 1,
2086
+ workgroupScale: 1,
2087
+ maxQueueDepth: 40
2088
+ }
2089
+ }
2090
+ ],
2091
+ suggestedAllocationIds: ["world.chunk.voxel.buffer"]
2092
+ },
2093
+ meshBuild: {
2094
+ priority: 2,
2095
+ dependencies: ["terrainSynthesis", "voxelMaterialize"],
2096
+ domain: "geometry",
2097
+ authority: "visual",
2098
+ importance: "high",
2099
+ levels: [
2100
+ {
2101
+ id: "low",
2102
+ estimatedCostMs: 0.7,
2103
+ config: {
2104
+ maxDispatchesPerFrame: 1,
2105
+ maxJobsPerDispatch: 1,
2106
+ cadenceDivisor: 2,
2107
+ workgroupScale: 0.6,
2108
+ maxQueueDepth: 16
2109
+ }
2110
+ },
2111
+ {
2112
+ id: "medium",
2113
+ estimatedCostMs: 1.1,
2114
+ config: {
2115
+ maxDispatchesPerFrame: 1,
2116
+ maxJobsPerDispatch: 1,
2117
+ cadenceDivisor: 1,
2118
+ workgroupScale: 0.8,
2119
+ maxQueueDepth: 24
2120
+ }
2121
+ },
2122
+ {
2123
+ id: "high",
2124
+ estimatedCostMs: 1.6,
2125
+ config: {
2126
+ maxDispatchesPerFrame: 2,
2127
+ maxJobsPerDispatch: 2,
2128
+ cadenceDivisor: 1,
2129
+ workgroupScale: 1,
2130
+ maxQueueDepth: 32
2131
+ }
2132
+ }
2133
+ ],
2134
+ suggestedAllocationIds: ["world.chunk.mesh.buffer"]
2135
+ },
2136
+ tileBake: {
2137
+ priority: 2,
2138
+ dependencies: ["terrainSynthesis"],
2139
+ domain: "textures",
2140
+ authority: "non-authoritative-simulation",
2141
+ importance: "medium",
2142
+ levels: [
2143
+ {
2144
+ id: "low",
2145
+ estimatedCostMs: 0.6,
2146
+ config: {
2147
+ maxDispatchesPerFrame: 1,
2148
+ maxJobsPerDispatch: 1,
2149
+ cadenceDivisor: 3,
2150
+ workgroupScale: 0.5,
2151
+ maxQueueDepth: 16
2152
+ }
2153
+ },
2154
+ {
2155
+ id: "medium",
2156
+ estimatedCostMs: 0.9,
2157
+ config: {
2158
+ maxDispatchesPerFrame: 1,
2159
+ maxJobsPerDispatch: 1,
2160
+ cadenceDivisor: 2,
2161
+ workgroupScale: 0.75,
2162
+ maxQueueDepth: 24
2163
+ }
2164
+ },
2165
+ {
2166
+ id: "high",
2167
+ estimatedCostMs: 1.3,
2168
+ config: {
2169
+ maxDispatchesPerFrame: 2,
2170
+ maxJobsPerDispatch: 2,
2171
+ cadenceDivisor: 1,
2172
+ workgroupScale: 1,
2173
+ maxQueueDepth: 32
2174
+ }
2175
+ }
2176
+ ],
2177
+ suggestedAllocationIds: ["world.chunk.height.buffer"]
2178
+ }
2179
+ }
2180
+ },
2181
+ bake: {
2182
+ description: "Offline tile bake DAG for terrain generation, voxel materialization, mesh build, and asset serialization.",
2183
+ suggestedAllocationIds: [
2184
+ "world.bake.field.scratch",
2185
+ "world.bake.height.buffer",
2186
+ "world.bake.mesh.buffer",
2187
+ "world.bake.asset.binary"
2188
+ ],
2189
+ jobs: {
2190
+ fractalPrepass: {
2191
+ priority: 4,
2192
+ dependencies: [],
2193
+ domain: "custom",
2194
+ authority: "authoritative",
2195
+ importance: "high",
2196
+ levels: [
2197
+ {
2198
+ id: "fixed",
2199
+ estimatedCostMs: 0.7,
2200
+ config: {
2201
+ maxDispatchesPerFrame: 1,
2202
+ maxJobsPerDispatch: 1,
2203
+ cadenceDivisor: 1,
2204
+ workgroupScale: 1,
2205
+ maxQueueDepth: 32
2206
+ }
2207
+ }
2208
+ ],
2209
+ suggestedAllocationIds: ["world.bake.field.scratch"]
2210
+ },
2211
+ fieldSynthesis: {
2212
+ priority: 4,
2213
+ dependencies: [],
2214
+ domain: "custom",
2215
+ authority: "authoritative",
2216
+ importance: "critical",
2217
+ levels: [
2218
+ {
2219
+ id: "fixed",
2220
+ estimatedCostMs: 1,
2221
+ config: {
2222
+ maxDispatchesPerFrame: 1,
2223
+ maxJobsPerDispatch: 2,
2224
+ cadenceDivisor: 1,
2225
+ workgroupScale: 1,
2226
+ maxQueueDepth: 48
2227
+ }
2228
+ }
2229
+ ],
2230
+ suggestedAllocationIds: ["world.bake.field.scratch"]
2231
+ },
2232
+ terrainSynthesis: {
2233
+ priority: 5,
2234
+ dependencies: ["fractalPrepass", "fieldSynthesis"],
2235
+ domain: "custom",
2236
+ authority: "authoritative",
2237
+ importance: "critical",
2238
+ levels: [
2239
+ {
2240
+ id: "fixed",
2241
+ estimatedCostMs: 1.6,
2242
+ config: {
2243
+ maxDispatchesPerFrame: 1,
2244
+ maxJobsPerDispatch: 1,
2245
+ cadenceDivisor: 1,
2246
+ workgroupScale: 1,
2247
+ maxQueueDepth: 32
2248
+ }
2249
+ }
2250
+ ],
2251
+ suggestedAllocationIds: ["world.bake.height.buffer"]
2252
+ },
2253
+ voxelMaterialize: {
2254
+ priority: 3,
2255
+ dependencies: ["terrainSynthesis"],
2256
+ domain: "custom",
2257
+ authority: "non-authoritative-simulation",
2258
+ importance: "high",
2259
+ levels: [
2260
+ {
2261
+ id: "low",
2262
+ estimatedCostMs: 0.9,
2263
+ config: {
2264
+ maxDispatchesPerFrame: 1,
2265
+ maxJobsPerDispatch: 1,
2266
+ cadenceDivisor: 2,
2267
+ workgroupScale: 0.6,
2268
+ maxQueueDepth: 24
2269
+ }
2270
+ },
2271
+ {
2272
+ id: "medium",
2273
+ estimatedCostMs: 1.4,
2274
+ config: {
2275
+ maxDispatchesPerFrame: 1,
2276
+ maxJobsPerDispatch: 2,
2277
+ cadenceDivisor: 1,
2278
+ workgroupScale: 0.8,
2279
+ maxQueueDepth: 32
2280
+ }
2281
+ },
2282
+ {
2283
+ id: "high",
2284
+ estimatedCostMs: 2,
2285
+ config: {
2286
+ maxDispatchesPerFrame: 2,
2287
+ maxJobsPerDispatch: 2,
2288
+ cadenceDivisor: 1,
2289
+ workgroupScale: 1,
2290
+ maxQueueDepth: 48
2291
+ }
2292
+ }
2293
+ ],
2294
+ suggestedAllocationIds: ["world.bake.height.buffer"]
2295
+ },
2296
+ meshBuild: {
2297
+ priority: 2,
2298
+ dependencies: ["terrainSynthesis", "voxelMaterialize"],
2299
+ domain: "geometry",
2300
+ authority: "visual",
2301
+ importance: "high",
2302
+ levels: [
2303
+ {
2304
+ id: "low",
2305
+ estimatedCostMs: 0.9,
2306
+ config: {
2307
+ maxDispatchesPerFrame: 1,
2308
+ maxJobsPerDispatch: 1,
2309
+ cadenceDivisor: 2,
2310
+ workgroupScale: 0.6,
2311
+ maxQueueDepth: 16
2312
+ }
2313
+ },
2314
+ {
2315
+ id: "medium",
2316
+ estimatedCostMs: 1.3,
2317
+ config: {
2318
+ maxDispatchesPerFrame: 1,
2319
+ maxJobsPerDispatch: 1,
2320
+ cadenceDivisor: 1,
2321
+ workgroupScale: 0.8,
2322
+ maxQueueDepth: 24
2323
+ }
2324
+ },
2325
+ {
2326
+ id: "high",
2327
+ estimatedCostMs: 1.9,
2328
+ config: {
2329
+ maxDispatchesPerFrame: 2,
2330
+ maxJobsPerDispatch: 2,
2331
+ cadenceDivisor: 1,
2332
+ workgroupScale: 1,
2333
+ maxQueueDepth: 32
2334
+ }
2335
+ }
2336
+ ],
2337
+ suggestedAllocationIds: ["world.bake.mesh.buffer"]
2338
+ },
2339
+ tileBake: {
2340
+ priority: 2,
2341
+ dependencies: ["terrainSynthesis"],
2342
+ domain: "textures",
2343
+ authority: "non-authoritative-simulation",
2344
+ importance: "medium",
2345
+ levels: [
2346
+ {
2347
+ id: "low",
2348
+ estimatedCostMs: 0.8,
2349
+ config: {
2350
+ maxDispatchesPerFrame: 1,
2351
+ maxJobsPerDispatch: 1,
2352
+ cadenceDivisor: 3,
2353
+ workgroupScale: 0.5,
2354
+ maxQueueDepth: 16
2355
+ }
2356
+ },
2357
+ {
2358
+ id: "medium",
2359
+ estimatedCostMs: 1.1,
2360
+ config: {
2361
+ maxDispatchesPerFrame: 1,
2362
+ maxJobsPerDispatch: 1,
2363
+ cadenceDivisor: 2,
2364
+ workgroupScale: 0.75,
2365
+ maxQueueDepth: 24
2366
+ }
2367
+ },
2368
+ {
2369
+ id: "high",
2370
+ estimatedCostMs: 1.5,
2371
+ config: {
2372
+ maxDispatchesPerFrame: 2,
2373
+ maxJobsPerDispatch: 2,
2374
+ cadenceDivisor: 1,
2375
+ workgroupScale: 1,
2376
+ maxQueueDepth: 32
2377
+ }
2378
+ }
2379
+ ],
2380
+ suggestedAllocationIds: ["world.bake.height.buffer"]
2381
+ },
2382
+ assetSerialize: {
2383
+ priority: 1,
2384
+ dependencies: ["meshBuild", "tileBake"],
2385
+ domain: "custom",
2386
+ authority: "non-authoritative-simulation",
2387
+ importance: "medium",
2388
+ levels: [
2389
+ {
2390
+ id: "low",
2391
+ estimatedCostMs: 0.4,
2392
+ config: {
2393
+ maxDispatchesPerFrame: 1,
2394
+ maxJobsPerDispatch: 1,
2395
+ cadenceDivisor: 4,
2396
+ workgroupScale: 0.5,
2397
+ maxQueueDepth: 8
2398
+ }
2399
+ },
2400
+ {
2401
+ id: "medium",
2402
+ estimatedCostMs: 0.7,
2403
+ config: {
2404
+ maxDispatchesPerFrame: 1,
2405
+ maxJobsPerDispatch: 1,
2406
+ cadenceDivisor: 2,
2407
+ workgroupScale: 0.75,
2408
+ maxQueueDepth: 12
2409
+ }
2410
+ },
2411
+ {
2412
+ id: "high",
2413
+ estimatedCostMs: 1,
2414
+ config: {
2415
+ maxDispatchesPerFrame: 2,
2416
+ maxJobsPerDispatch: 2,
2417
+ cadenceDivisor: 1,
2418
+ workgroupScale: 1,
2419
+ maxQueueDepth: 16
2420
+ }
2421
+ }
2422
+ ],
2423
+ suggestedAllocationIds: ["world.bake.asset.binary"]
2424
+ }
2425
+ }
2426
+ }
2427
+ };
2428
+ function buildWorldGeneratorWorkerProfile(name, spec) {
2429
+ return Object.freeze({
2430
+ name,
2431
+ description: spec.description,
2432
+ jobs: Object.freeze(Object.keys(spec.jobs))
2433
+ });
2434
+ }
2435
+ function buildWorldGeneratorWorkerManifestJob(profileName, jobName, spec) {
2436
+ const label = `world-generator.${profileName}.${jobName}`;
2437
+ return Object.freeze({
2438
+ key: jobName,
2439
+ label,
2440
+ worker: Object.freeze({
2441
+ jobType: label,
2442
+ queueClass: worldGeneratorWorkerQueueClass,
2443
+ priority: spec.priority,
2444
+ dependencies: Object.freeze(
2445
+ spec.dependencies.map(
2446
+ (dependency) => `world-generator.${profileName}.${dependency}`
2447
+ )
2448
+ ),
2449
+ schedulerMode: "dag"
2450
+ }),
2451
+ performance: Object.freeze({
2452
+ id: label,
2453
+ jobType: label,
2454
+ queueClass: worldGeneratorWorkerQueueClass,
2455
+ domain: spec.domain,
2456
+ authority: spec.authority,
2457
+ importance: spec.importance,
2458
+ levels: buildBudgetLevels(
2459
+ label,
2460
+ worldGeneratorWorkerQueueClass,
2461
+ spec.levels
2462
+ )
2463
+ }),
2464
+ debug: Object.freeze({
2465
+ owner: worldGeneratorDebugOwner,
2466
+ queueClass: worldGeneratorWorkerQueueClass,
2467
+ jobType: label,
2468
+ tags: Object.freeze(["world-generator", profileName, jobName, spec.domain]),
2469
+ suggestedAllocationIds: Object.freeze([...spec.suggestedAllocationIds])
2470
+ })
2471
+ });
2472
+ }
2473
+ function buildWorldGeneratorWorkerManifest(name, spec) {
2474
+ return Object.freeze({
2475
+ schemaVersion: 1,
2476
+ owner: worldGeneratorDebugOwner,
2477
+ profile: name,
2478
+ description: spec.description,
2479
+ queueClass: worldGeneratorWorkerQueueClass,
2480
+ schedulerMode: "dag",
2481
+ suggestedAllocationIds: Object.freeze([...spec.suggestedAllocationIds]),
2482
+ jobs: Object.freeze(
2483
+ Object.entries(spec.jobs).map(
2484
+ ([jobName, jobSpec]) => buildWorldGeneratorWorkerManifestJob(name, jobName, jobSpec)
2485
+ )
2486
+ )
2487
+ });
2488
+ }
2489
+ var worldGeneratorWorkerProfiles = Object.freeze(
2490
+ Object.fromEntries(
2491
+ Object.entries(worldGeneratorWorkerProfileSpecs).map(([name, spec]) => [
2492
+ name,
2493
+ buildWorldGeneratorWorkerProfile(
2494
+ name,
2495
+ spec
2496
+ )
2497
+ ])
2498
+ )
2499
+ );
2500
+ var worldGeneratorWorkerProfileNames = Object.freeze(
2501
+ Object.keys(worldGeneratorWorkerProfiles)
2502
+ );
2503
+ var worldGeneratorWorkerManifests = Object.freeze(
2504
+ Object.fromEntries(
2505
+ Object.entries(worldGeneratorWorkerProfileSpecs).map(([name, spec]) => [
2506
+ name,
2507
+ buildWorldGeneratorWorkerManifest(
2508
+ name,
2509
+ spec
2510
+ )
2511
+ ])
2512
+ )
2513
+ );
2514
+ function getWorldGeneratorWorkerProfile(name = defaultWorldGeneratorWorkerProfile) {
2515
+ const profile = worldGeneratorWorkerProfiles[name];
2516
+ if (!profile) {
2517
+ const available = worldGeneratorWorkerProfileNames.join(", ");
2518
+ throw new Error(
2519
+ `Unknown world-generator worker profile "${name}". Available: ${available}.`
2520
+ );
2521
+ }
2522
+ return profile;
2523
+ }
2524
+ function getWorldGeneratorWorkerManifest(name = defaultWorldGeneratorWorkerProfile) {
2525
+ const manifest = worldGeneratorWorkerManifests[name];
2526
+ if (!manifest) {
2527
+ const available = worldGeneratorWorkerProfileNames.join(", ");
2528
+ throw new Error(
2529
+ `Unknown world-generator worker profile "${name}". Available: ${available}.`
2530
+ );
2531
+ }
2532
+ return manifest;
2533
+ }
2534
+ function createWorldGeneratorRepresentationPlan(options) {
2535
+ const profile = options.profile ?? defaultWorldGeneratorWorkerProfile;
2536
+ const spec = worldGeneratorWorkerProfileSpecs[profile];
2537
+ if (!spec) {
2538
+ const available = worldGeneratorWorkerProfileNames.join(", ");
2539
+ throw new Error(
2540
+ `Unknown world-generator worker profile "${profile}". Available: ${available}.`
2541
+ );
2542
+ }
2543
+ const chunkId = assertWorldGeneratorIdentifier("chunkId", options.chunkId);
2544
+ const gameplayImportance = normalizeWorldGeneratorImportance(
2545
+ "gameplayImportance",
2546
+ options.gameplayImportance ?? "high"
2547
+ );
2548
+ const highValueAllocations = spec.suggestedAllocationIds;
2549
+ const farFieldAllocations = spec.suggestedAllocationIds.filter(
2550
+ (allocationId) => allocationId.includes("mesh") || allocationId.includes("asset") || allocationId.includes("tile")
2551
+ );
2552
+ const bakeSourceJobKeys = profile === "bake" ? ["meshBuild", "tileBake", "assetSerialize"] : ["meshBuild", "tileBake"];
2553
+ const representations = Object.freeze([
2554
+ buildWorldGeneratorRepresentationDescriptor({
2555
+ profile,
2556
+ chunkId,
2557
+ band: "near",
2558
+ output: "liveGeometry",
2559
+ rasterMode: "full-live",
2560
+ rtParticipation: "full",
2561
+ shadowRelevance: "ray-traced-primary",
2562
+ refreshCadence: { kind: "per-frame", divisor: 1 },
2563
+ preservesChunkIdentity: true,
2564
+ sourceJobKeys: ["meshBuild"],
2565
+ gameplayImportance: gameplayImportance === "medium" ? "high" : gameplayImportance,
2566
+ suggestedAllocationIds: highValueAllocations
2567
+ }),
2568
+ buildWorldGeneratorRepresentationDescriptor({
2569
+ profile,
2570
+ chunkId,
2571
+ band: "mid",
2572
+ output: "simplifiedGeometry",
2573
+ rasterMode: "simplified-live",
2574
+ rtParticipation: "selective",
2575
+ shadowRelevance: "selective-raster",
2576
+ refreshCadence: { kind: "interval", divisor: 2 },
2577
+ preservesChunkIdentity: true,
2578
+ sourceJobKeys: ["meshBuild"],
2579
+ gameplayImportance,
2580
+ suggestedAllocationIds: highValueAllocations
2581
+ }),
2582
+ buildWorldGeneratorRepresentationDescriptor({
2583
+ profile,
2584
+ chunkId,
2585
+ band: "mid",
2586
+ output: "rtProxy",
2587
+ rasterMode: "not-rendered",
2588
+ rtParticipation: "proxy",
2589
+ shadowRelevance: "selective-raster",
2590
+ refreshCadence: { kind: "interval", divisor: 2 },
2591
+ preservesChunkIdentity: true,
2592
+ sourceJobKeys: ["meshBuild", "tileBake"],
2593
+ gameplayImportance,
2594
+ suggestedAllocationIds: highValueAllocations
2595
+ }),
2596
+ buildWorldGeneratorRepresentationDescriptor({
2597
+ profile,
2598
+ chunkId,
2599
+ band: "far",
2600
+ output: "mergedProxy",
2601
+ rasterMode: "proxy",
2602
+ rtParticipation: "proxy",
2603
+ shadowRelevance: "proxy-caster",
2604
+ refreshCadence: { kind: "interval", divisor: 8 },
2605
+ preservesChunkIdentity: true,
2606
+ sourceJobKeys: bakeSourceJobKeys,
2607
+ gameplayImportance: "medium",
2608
+ suggestedAllocationIds: farFieldAllocations.length > 0 ? farFieldAllocations : highValueAllocations
2609
+ }),
2610
+ buildWorldGeneratorRepresentationDescriptor({
2611
+ profile,
2612
+ chunkId,
2613
+ band: "horizon",
2614
+ output: "horizonShell",
2615
+ rasterMode: "horizon-shell",
2616
+ rtParticipation: "disabled",
2617
+ shadowRelevance: "baked-impression",
2618
+ refreshCadence: { kind: "interval", divisor: 60 },
2619
+ preservesChunkIdentity: true,
2620
+ sourceJobKeys: profile === "bake" ? ["tileBake", "assetSerialize"] : ["tileBake"],
2621
+ gameplayImportance: "medium",
2622
+ suggestedAllocationIds: farFieldAllocations.length > 0 ? farFieldAllocations : highValueAllocations
2623
+ })
2624
+ ]);
2625
+ return Object.freeze({
2626
+ schemaVersion: 1,
2627
+ owner: worldGeneratorDebugOwner,
2628
+ profile,
2629
+ chunkId,
2630
+ representations,
2631
+ bands: Object.freeze(
2632
+ [...new Set(representations.map((representation) => representation.band))]
2633
+ )
2634
+ });
2635
+ }
1880
2636
  // Annotate the CommonJS export names for ESM import in node:
1881
2637
  0 && (module.exports = {
1882
2638
  DEFAULT_TILE_SIZE_WORLD,
@@ -1905,13 +2661,17 @@ function createMeshBuilder(sizeOrOptions = 1) {
1905
2661
  createFractalPrepassRunner,
1906
2662
  createMeshBuilder,
1907
2663
  createPerfMonitor,
2664
+ createWorldGeneratorRepresentationPlan,
1908
2665
  defaultFieldParams,
1909
2666
  defaultFractalMandelSettings,
2667
+ defaultWorldGeneratorWorkerProfile,
1910
2668
  encodeTerrainParams,
1911
2669
  fieldWgslUrl,
1912
2670
  fractalPrepassWgslUrl,
1913
2671
  generateHexGrid,
1914
2672
  generateTemperateMixedForest,
2673
+ getWorldGeneratorWorkerManifest,
2674
+ getWorldGeneratorWorkerProfile,
1915
2675
  hexAreaFromSide,
1916
2676
  hexSideFromArea,
1917
2677
  loadFieldWgsl,
@@ -1937,6 +2697,13 @@ function createMeshBuilder(sizeOrOptions = 1) {
1937
2697
  tileKeyFromWorldPosition,
1938
2698
  tileKeyToString,
1939
2699
  unpackTerrain,
1940
- validateTileAssetPayload
2700
+ validateTileAssetPayload,
2701
+ worldGeneratorDebugOwner,
2702
+ worldGeneratorRepresentationBands,
2703
+ worldGeneratorRepresentationOutputs,
2704
+ worldGeneratorWorkerManifests,
2705
+ worldGeneratorWorkerProfileNames,
2706
+ worldGeneratorWorkerProfiles,
2707
+ worldGeneratorWorkerQueueClass
1941
2708
  });
1942
2709
  //# sourceMappingURL=index.cjs.map