@ignifx/editor-host 0.19.0 → 0.21.0

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as isEditorOrigin, t as EditorHostErrorCode } from "./error-codes.js";
2
- import { Camera, Component, CoreErrorCode, IgnifxError, Light, Phase, RENDERING_SETTINGS_SECTION, SCENE_ASSET_TYPE, SCENE_FILE_FORMAT, SCENE_FORMAT_VERSION, Script, Transform, VERSION, addComponentFromRecord, canonicalizeNumber, clamp, createApp, createFrameSample, createRay, createSceneAsset, decodeProps, decodeValue, degToRad, describeRegisteredSchemas, describeSchemas, describeSettings, encodeProps, encodeValue, instanceComponentAt, instanceEntityAt, instantiateScene, isIgnifxError, loadSceneDependencies, parseOverridePath, serializeEntity, serializeScene, settingsJsonSchema, toJsonSchema, transformSchema, validateSceneFile } from "@ignifx/core";
2
+ import { Camera, Component, CoreErrorCode, EDITOR_ONLY_METADATA_KEY, Environment, IgnifxError, Light, LightProbeVolume, Mat4, MeshAsset, MeshRenderer, Phase, RENDERING_SETTINGS_SECTION, SCENE_ASSET_TYPE, SCENE_FILE_FORMAT, SCENE_FORMAT_VERSION, Script, Transform, VERSION, addComponentFromRecord, assetRef, bakeLightProbes, canonicalizeNumber, clamp, createApp, createFrameSample, createRay, createSceneAsset, decodeProps, decodeValue, degToRad, describeRegisteredSchemas, describeSchemas, describeSettings, encodeProps, encodeValue, instanceComponentAt, instanceEntityAt, instantiateScene, isIgnifxError, loadSceneDependencies, parseOverridePath, serializeEntity, serializeScene, settingsJsonSchema, toJsonSchema, transformSchema, validateSceneFile, writeLightProbeFile } from "@ignifx/core";
3
3
  import { addToScene, attachPositionGizmoToNode, attachRotationGizmoToNode, attachScaleGizmoToNode, createLines, createPositionGizmo, createRotationGizmo, createScaleGizmo, isGizmoDragging, isGizmoInteracting, isGizmoPickPending, onBeforeRender, setPositionGizmoLocalCoordinates, setRotationGizmoLocalCoordinates, setScaleGizmoLocalCoordinates } from "@babylonjs/lite";
4
4
  //#region src/protocol/rpc.ts
5
5
  /**
@@ -187,8 +187,9 @@ const HostKind = {
187
187
  * The play controls send `"heartbeat"`, `"playControls"`, `"logRelay"` and `"queryRuntime"`, plus
188
188
  * `"screenshot"` when the game has a canvas and `"sendInput"` when it has `app.input`. The scene
189
189
  * host sends `"heartbeat"` and whichever of `"gizmos"`, `"screenshot"`, `"viewMode2d"`,
190
- * `"pick2d"`, `"gameView"`, `"gameViewOnDemand"`, `"gameViewSize"`, `"gameView2d"`, `"thumbnails"`,
191
- * `"grid"`, `"tilemapCells"`, `"editorLines"` and `"spriteAnimation"` it supports; every
190
+ * `"pick2d"`, `"pickRect"`, `"gameView"`, `"gameViewOnDemand"`, `"gameViewSize"`, `"gameView2d"`,
191
+ * `"thumbnails"`, `"thumbnailMaterials"`, `"thumbnailAtlases"`, `"thumbnailTextures"`, `"grid"`,
192
+ * `"gridOverlay"`, `"tilemapCells"`, `"editorLines"` and `"spriteAnimation"` it supports; every
192
193
  * `SceneMethod` not tied to one of them is required of a 0.3 scene host.
193
194
  *
194
195
  * @public
@@ -217,6 +218,12 @@ const HostCapability = {
217
218
  */
218
219
  pick2d: "pick2d",
219
220
  /**
221
+ * The scene host answers `pickRect`: the document entities whose drawn bounds, projected to the
222
+ * view, a rectangle of the view covers (a box selection). Additive in 0.3; without it, the scene
223
+ * host answers `pickRect` with `RpcErrorCode.methodNotFound`.
224
+ */
225
+ pickRect: "pickRect",
226
+ /**
220
227
  * The host relays the app's reports: `log` lines with the first `Error` each carries, a
221
228
  * `hostError` with `AppErrorData` (entity, component, phase, stack) for every `app.onError`
222
229
  * report, and `hotReloaded` with each error's stack. The scene view sends them as scene
@@ -275,6 +282,26 @@ const HostCapability = {
275
282
  */
276
283
  thumbnails: "thumbnails",
277
284
  /**
285
+ * The scene host's `renderThumbnail` also renders materials (`.material.json`, or a reference
286
+ * typed `"material"`): the material on a sphere under the thumbnail lighting. Listed only with
287
+ * `thumbnails`. Additive in 0.3; without it, a material answers `RpcErrorCode.invalidParams`.
288
+ */
289
+ thumbnailMaterials: "thumbnailMaterials",
290
+ /**
291
+ * The scene host's `renderThumbnail` also renders sprite atlases (`.atlas.json`, or a reference
292
+ * typed `"spriteatlas"`): the atlas's whole image fitted in the square on a transparent
293
+ * background. Listed only with `thumbnails`. Additive in 0.3; without it, an atlas answers
294
+ * `RpcErrorCode.invalidParams`.
295
+ */
296
+ thumbnailAtlases: "thumbnailAtlases",
297
+ /**
298
+ * The scene host's `renderThumbnail` also renders images (`.png`, `.jpg`, `.jpeg`, `.webp`, or
299
+ * a reference typed `"texture"`), fitted in the square on a transparent background; `.gif`,
300
+ * `.avif` and `.bmp` answer `RpcErrorCode.invalidParams`. Listed only with `thumbnails`.
301
+ * Additive in 0.3; without it, an image answers `RpcErrorCode.invalidParams`.
302
+ */
303
+ thumbnailTextures: "thumbnailTextures",
304
+ /**
278
305
  * The scene host draws a grid in the view and answers `setGrid`: a ground grid at `y = 0` in 3D
279
306
  * view mode and a unit grid (a pixel grid when zoomed in) over the 2D view. From engine ask E31
280
307
  * (additive in 0.3); without it, the scene host answers `setGrid` with
@@ -307,7 +334,15 @@ const HostCapability = {
307
334
  * (additive in 0.3); without it, the scene host answers `sampleSpriteAnimation` with
308
335
  * `RpcErrorCode.methodNotFound`.
309
336
  */
310
- spriteAnimation: "spriteAnimation"
337
+ spriteAnimation: "spriteAnimation",
338
+ /**
339
+ * The scene host answers `bakeLightProbes` and `cancelBake` and sends `bakeProgress`
340
+ * (`LightProbeBakeMethod`): it bakes a `LightProbeVolume` from its live edit-mode world (prefab
341
+ * instances, models, lights, the environment's sky) and answers the `.probes.json` document for
342
+ * the editor to write. Additive in 0.3; without it, the host answers both with
343
+ * `RpcErrorCode.methodNotFound`.
344
+ */
345
+ bakeLightProbes: "bakeLightProbes"
311
346
  };
312
347
  /**
313
348
  * The longest string, in UTF-16 code units, the editor accepts from a host in `ready` (the engine
@@ -1125,6 +1160,11 @@ const SceneMethod = {
1125
1160
  frame: "frame",
1126
1161
  /** Asks which entity is under a point of the view, without selecting it. Answers {@link PickResult}. */
1127
1162
  pick: "pick",
1163
+ /**
1164
+ * Asks which entities a rectangle of the view covers, for a box selection, without selecting
1165
+ * them. Needs `HostCapability.pickRect`. Answers {@link PickRectResult}. Additive in 0.3.
1166
+ */
1167
+ pickRect: "pickRect",
1128
1168
  /** Captures the view as an image. Needs `HostCapability.screenshot`. Answers {@link ScreenshotResult}. */
1129
1169
  screenshot: "screenshot",
1130
1170
  /** Describes every registered component's schema. Answers {@link SchemaSet}. */
@@ -1336,6 +1376,23 @@ const PickUnit = {
1336
1376
  backing: "backing"
1337
1377
  };
1338
1378
  /**
1379
+ * How `pickRect` matches an entity's projected bounds against the rectangle.
1380
+ *
1381
+ * @public
1382
+ */
1383
+ const PickRectMode = {
1384
+ /** The entity counts when its projected bounds overlap the rectangle at all. */
1385
+ intersect: "intersect",
1386
+ /** The entity counts only when its projected bounds lie wholly inside the rectangle. */
1387
+ contain: "contain"
1388
+ };
1389
+ /**
1390
+ * The most entities a `pickRect` answer lists; past it the answer sets `truncated`.
1391
+ *
1392
+ * @public
1393
+ */
1394
+ const PICK_RECT_MAX_ENTITIES = 2e3;
1395
+ /**
1339
1396
  * The image formats of a `screenshot`.
1340
1397
  *
1341
1398
  * @public
@@ -1621,6 +1678,28 @@ function isPickResult(value) {
1621
1678
  return (entity === null || isUidString(entity)) && (point === null || isNumberTuple(point, 3)) && (distance === null || isNonNegative(distance)) && optionalField(value, "ray", isPickRay) && optionalField(value, "plane", (plane) => isNumberTuple(plane, 3));
1622
1679
  }
1623
1680
  /**
1681
+ * Checks the parameters of `pickRect`.
1682
+ *
1683
+ * @param value - The received `params`.
1684
+ * @returns True for four finite corner coordinates, a known unit and, when present, a known mode.
1685
+ *
1686
+ * @public
1687
+ */
1688
+ function isPickRectParams(value) {
1689
+ return isRecord(value) && isFiniteNumber(value["x0"]) && isFiniteNumber(value["y0"]) && isFiniteNumber(value["x1"]) && isFiniteNumber(value["y1"]) && isOneOf(PickUnit, value["unit"]) && optionalField(value, "mode", (mode) => isOneOf(PickRectMode, mode));
1690
+ }
1691
+ /**
1692
+ * Checks the result of `pickRect`.
1693
+ *
1694
+ * @param value - The received `result`.
1695
+ * @returns True for at most {@link PICK_RECT_MAX_ENTITIES} uids and a boolean `truncated`.
1696
+ *
1697
+ * @public
1698
+ */
1699
+ function isPickRectResult(value) {
1700
+ return isRecord(value) && Array.isArray(value["entities"]) && value["entities"].length <= 2e3 && isArrayOf(value["entities"], isUidString) && isBoolean(value["truncated"]);
1701
+ }
1702
+ /**
1624
1703
  * Tells whether a value is a screenshot side: a whole number from 1 to {@link SCREENSHOT_MAX_SIZE}.
1625
1704
  *
1626
1705
  * @param value - The value to test.
@@ -2044,8 +2123,8 @@ const RenderViewMethod = {
2044
2123
  */
2045
2124
  gameViewFrame: "gameViewFrame",
2046
2125
  /**
2047
- * Renders one model or prefab asset on its own and answers the image: {@link ThumbnailResult}.
2048
- * It runs beside the one-at-a-time queue of the other methods, so a thumbnail never holds them
2126
+ * Renders one model or prefab asset on its own (and, with the matching capabilities, a material,
2127
+ * a sprite atlas or an image) and answers the image: {@link ThumbnailResult}. It runs beside the one-at-a-time queue of the other methods, so a thumbnail never holds them
2049
2128
  * up; thumbnails are answered in the order they were asked for.
2050
2129
  */
2051
2130
  renderThumbnail: "renderThumbnail"
@@ -2217,6 +2296,301 @@ function protocolVersionIsCompatible(a, b) {
2217
2296
  return a.major !== 0 || a.minor === b.minor;
2218
2297
  }
2219
2298
  //#endregion
2299
+ //#region src/protocol/light-probe-bake.ts
2300
+ /**
2301
+ * Protocol 0.3, additive: a light-probe bake run by the scene host, over the world it already has —
2302
+ * prefab instances expanded, models loaded, lights with their `bakeMode`, the environment — rather
2303
+ * than over a trimmed copy of the scene file. The host answers the `.probes.json` document; the
2304
+ * editor writes the file and points the volume at it. Progress arrives as notifications, and a bake
2305
+ * is cancelled by request or by any change to the document.
2306
+ */
2307
+ /**
2308
+ * Editor → scene host: the light-probe bake methods, answered after `ready`.
2309
+ *
2310
+ * @remarks
2311
+ * A host lists `HostCapability.bakeLightProbes` when it answers them; one that does not answers
2312
+ * `RpcErrorCode.methodNotFound`. Both run beside the one-at-a-time queue of the other methods:
2313
+ * the bake reads the world in a slot of the host's queue, then traces in slices while the queue
2314
+ * goes on, so the view keeps answering `applyOps`, `pick` and the rest. A document change the host
2315
+ * handles after the bake has read the world cancels it (`cancelled`, cause `sceneChanged`): a bake
2316
+ * never mixes the old world with the new, but it may start before a change sent just ahead of it.
2317
+ *
2318
+ * @public
2319
+ */
2320
+ const LightProbeBakeMethod = {
2321
+ /**
2322
+ * Bakes one `LightProbeVolume` and answers {@link BakeLightProbesResult} when it is done. Fails
2323
+ * with `RpcErrorCode.noScene` while no scene is open, and otherwise with the code and the
2324
+ * {@link BakeFailureData} that `BakeFailureReason` lists.
2325
+ */
2326
+ bakeLightProbes: "bakeLightProbes",
2327
+ /**
2328
+ * Cancels the running or pending bake, if any; answers {@link CancelBakeResult}. The bake then
2329
+ * fails as `cancelled` (cause `cancelBake`), a pending one without running. Takes `{}` or no
2330
+ * parameters.
2331
+ */
2332
+ cancelBake: "cancelBake"
2333
+ };
2334
+ /**
2335
+ * Scene host → editor: the light-probe bake notifications.
2336
+ *
2337
+ * @public
2338
+ */
2339
+ const LightProbeBakeNotification = {
2340
+ /**
2341
+ * How far the running bake is: {@link BakeProgressParams}. At most one per
2342
+ * {@link BAKE_PROGRESS_INTERVAL_MS}; the first comes once the first probe is baked. The answer to
2343
+ * `bakeLightProbes` follows the last one.
2344
+ */
2345
+ bakeProgress: "bakeProgress" };
2346
+ /**
2347
+ * The shortest time between two `bakeProgress` notifications, in milliseconds (ten a second).
2348
+ *
2349
+ * @public
2350
+ */
2351
+ const BAKE_PROGRESS_INTERVAL_MS = 100;
2352
+ /**
2353
+ * The distance between probes when a request gives neither `counts` nor `spacing`, in metres.
2354
+ *
2355
+ * @public
2356
+ */
2357
+ const BAKE_DEFAULT_SPACING = 2;
2358
+ /**
2359
+ * The smallest `spacing` a request may give, in metres.
2360
+ *
2361
+ * @public
2362
+ */
2363
+ const BAKE_SPACING_MIN = .05;
2364
+ /**
2365
+ * The largest `spacing` a request may give, in metres.
2366
+ *
2367
+ * @public
2368
+ */
2369
+ const BAKE_SPACING_MAX = 1e3;
2370
+ /**
2371
+ * The most probes along X (the `.probes.json` format's limit).
2372
+ *
2373
+ * @public
2374
+ */
2375
+ const BAKE_MAX_COUNT_X = 1024;
2376
+ /**
2377
+ * The most probes in one Y × Z slice (the `.probes.json` format's limit).
2378
+ *
2379
+ * @public
2380
+ */
2381
+ const BAKE_MAX_COUNT_YZ = 4096;
2382
+ /**
2383
+ * The most probes one bake traces. With coefficients rounded to {@link BAKE_COEFFICIENT_DIGITS}
2384
+ * significant digits and bounded by {@link BAKE_MAX_COEFFICIENT}, the largest `probes` document is
2385
+ * under 3 MiB of JSON, inside the editor's 4 MiB message limits.
2386
+ *
2387
+ * @public
2388
+ */
2389
+ const BAKE_MAX_PROBES = 16384;
2390
+ /**
2391
+ * The significant digits each answered coefficient is rounded to; a coefficient below `1e-6` in
2392
+ * magnitude is answered as `0`.
2393
+ *
2394
+ * @public
2395
+ */
2396
+ const BAKE_COEFFICIENT_DIGITS = 6;
2397
+ /**
2398
+ * The largest coefficient magnitude a bake answers. A bake whose probes exceed it (lights or a sky
2399
+ * of absurd intensity) fails as `outOfRange` rather than writing a grid no renderer can use.
2400
+ *
2401
+ * @public
2402
+ */
2403
+ const BAKE_MAX_COEFFICIENT = 0xe8d4a51000;
2404
+ /**
2405
+ * The largest magnitude of a sky channel or harmonic a request may give.
2406
+ *
2407
+ * @public
2408
+ */
2409
+ const BAKE_MAX_SKY = 1e6;
2410
+ /**
2411
+ * The longest `volume` uid a request may give, in UTF-16 code units.
2412
+ *
2413
+ * @public
2414
+ */
2415
+ const BAKE_MAX_UID_LENGTH = 128;
2416
+ /**
2417
+ * The most rays per probe (`bakeLightProbes`' own limit).
2418
+ *
2419
+ * @public
2420
+ */
2421
+ const BAKE_MAX_RAYS = 4096;
2422
+ /**
2423
+ * The most skips an answer lists; the count in `stats.skipped` is never cut.
2424
+ *
2425
+ * @public
2426
+ */
2427
+ const BAKE_MAX_SKIPS = 256;
2428
+ /**
2429
+ * Why `bakeLightProbes` failed, in its error's `data.reason`, with the error code each comes with:
2430
+ *
2431
+ * - `unknownEntity` (`RpcErrorCode.unknownEntity`): `volume` names no entity of the open scene;
2432
+ * - `notAVolume` (`RpcErrorCode.invalidParams`): the entity has no `LightProbeVolume`;
2433
+ * - `invalidGrid` (`RpcErrorCode.invalidParams`): the grid (from `counts` or `spacing`) is more
2434
+ * than a `.probes.json` holds (X ≤ {@link BAKE_MAX_COUNT_X}, Y × Z ≤ {@link BAKE_MAX_COUNT_YZ}) or
2435
+ * more than {@link BAKE_MAX_PROBES}, or the volume's transform is not finite;
2436
+ * - `outOfRange` (`RpcErrorCode.invalidRequest`): a baked coefficient is not finite or above
2437
+ * {@link BAKE_MAX_COEFFICIENT} (a light of absurd intensity);
2438
+ * - `busy` (`RpcErrorCode.invalidRequest`): a bake is running; cancel it or wait;
2439
+ * - `cancelled` (`RpcErrorCode.invalidRequest`): `cancelBake`, or a change to the document, stopped
2440
+ * it (`data.cause`).
2441
+ *
2442
+ * @public
2443
+ */
2444
+ const BakeFailureReason = {
2445
+ unknownEntity: "unknownEntity",
2446
+ notAVolume: "notAVolume",
2447
+ invalidGrid: "invalidGrid",
2448
+ outOfRange: "outOfRange",
2449
+ busy: "busy",
2450
+ cancelled: "cancelled"
2451
+ };
2452
+ /**
2453
+ * What stopped a cancelled bake: `cancelBake`, or a change to the open document (`openScene`,
2454
+ * `closeScene`, `applyOps`, `setTilemapCells`, an asset reload that rebuilt instances, or a hot
2455
+ * reload's new defaults), since a bake must not mix the old world with the new.
2456
+ *
2457
+ * @public
2458
+ */
2459
+ const BakeCancelCause = {
2460
+ cancelBake: "cancelBake",
2461
+ sceneChanged: "sceneChanged"
2462
+ };
2463
+ /**
2464
+ * Tells whether a value is a sky number: finite, at most {@link BAKE_MAX_SKY} in magnitude.
2465
+ *
2466
+ * @param value - The value to test.
2467
+ * @returns True for a number in range.
2468
+ */
2469
+ function isSkyNumber(value) {
2470
+ return isFiniteNumber(value) && Math.abs(value) <= 1e6;
2471
+ }
2472
+ /**
2473
+ * Tells whether a value is a colour with `r`, `g`, `b` and, when present, `a` in sky range.
2474
+ *
2475
+ * @param value - The value to test.
2476
+ * @returns True for a colour.
2477
+ */
2478
+ function isBakeColor(value) {
2479
+ return isRecord(value) && isSkyNumber(value["r"]) && isSkyNumber(value["g"]) && isSkyNumber(value["b"]) && optionalField(value, "a", isFiniteNumber);
2480
+ }
2481
+ /**
2482
+ * Checks a sky.
2483
+ *
2484
+ * @param value - The value to test.
2485
+ * @returns True for a colour, a gradient of three colours, or 27 harmonics, every channel finite and
2486
+ * at most {@link BAKE_MAX_SKY} in magnitude.
2487
+ *
2488
+ * @public
2489
+ */
2490
+ function isBakeSky(value) {
2491
+ if (!isRecord(value)) return false;
2492
+ const kind = value["kind"];
2493
+ if (kind === void 0) return isBakeColor(value);
2494
+ if (kind === "gradient") return isBakeColor(value["sky"]) && isBakeColor(value["horizon"]) && isBakeColor(value["ground"]);
2495
+ const coefficients = value["coefficients"];
2496
+ return kind === "sh9" && isNumberTuple(coefficients, 27) && Array.isArray(coefficients) && coefficients.every((coefficient) => isSkyNumber(coefficient));
2497
+ }
2498
+ /**
2499
+ * Tells whether a value is three probe counts: whole numbers from 1. The format's and the bake's
2500
+ * limits are the host's to check, as `invalidGrid`.
2501
+ *
2502
+ * @param value - The value to test.
2503
+ * @returns True for three whole numbers from 1.
2504
+ */
2505
+ function isBakeCounts(value) {
2506
+ return Array.isArray(value) && value.length === 3 && value.every((count) => Number.isSafeInteger(count) && Number(count) >= 1);
2507
+ }
2508
+ /**
2509
+ * Checks the parameters of `bakeLightProbes`.
2510
+ *
2511
+ * @param value - The received `params`.
2512
+ * @returns True for a volume uid of at most {@link BAKE_MAX_UID_LENGTH} and, when given, whole counts
2513
+ * from 1 or a spacing (not both), a direct-light
2514
+ * rule, a sky or `null`, rays and a ray length in range.
2515
+ *
2516
+ * @public
2517
+ */
2518
+ function isBakeLightProbesParams(value) {
2519
+ return isRecord(value) && isUidString(value["volume"]) && value["volume"].length <= 128 && !(value["counts"] !== void 0 && value["spacing"] !== void 0) && optionalField(value, "counts", isBakeCounts) && optionalField(value, "spacing", (spacing) => isFiniteNumber(spacing) && spacing >= .05 && spacing <= 1e3) && optionalField(value, "directLight", (rule) => rule === "include" || rule === "exclude") && optionalField(value, "sky", (sky) => sky === null || isBakeSky(sky)) && optionalField(value, "rays", (rays) => Number.isSafeInteger(rays) && Number(rays) >= 1 && Number(rays) <= 4096) && optionalField(value, "maxDistance", (distance) => isFiniteNumber(distance) && distance > 0);
2520
+ }
2521
+ /**
2522
+ * Checks the parameters of `bakeProgress`.
2523
+ *
2524
+ * @param value - The received `params`.
2525
+ * @returns True for a volume uid and `0 ≤ done ≤ total`, whole numbers.
2526
+ *
2527
+ * @public
2528
+ */
2529
+ function isBakeProgressParams(value) {
2530
+ if (!isRecord(value) || !isUidString(value["volume"])) return false;
2531
+ const done = value["done"];
2532
+ const total = value["total"];
2533
+ return Number.isSafeInteger(done) && Number.isSafeInteger(total) && Number(done) >= 0 && Number(done) <= Number(total);
2534
+ }
2535
+ /**
2536
+ * Tells whether a value is one skip.
2537
+ *
2538
+ * @param value - The value to test.
2539
+ * @returns True for four strings.
2540
+ */
2541
+ function isBakeSkip(value) {
2542
+ return isRecord(value) && isString(value["entity"]) && isString(value["uid"]) && isString(value["component"]) && isString(value["reason"]);
2543
+ }
2544
+ /**
2545
+ * Checks the result of `bakeLightProbes`.
2546
+ *
2547
+ * @param value - The received `result`.
2548
+ * @returns True for a `.probes.json` document, whole-number stats, at most {@link BAKE_MAX_SKIPS}
2549
+ * skips and a sky source.
2550
+ *
2551
+ * @public
2552
+ */
2553
+ function isBakeLightProbesResult(value) {
2554
+ if (!isRecord(value) || !isJsonObject(value["probes"]) || value["probes"]["format"] !== "ignifx-probes") return false;
2555
+ const stats = value["stats"];
2556
+ const skips = value["skips"];
2557
+ const sky = value["sky"];
2558
+ return isRecord(stats) && Number.isSafeInteger(stats["probes"]) && Number.isSafeInteger(stats["triangles"]) && Number.isSafeInteger(stats["skipped"]) && isFiniteNumber(stats["ms"]) && Array.isArray(skips) && skips.length <= 256 && skips.every((skip) => isBakeSkip(skip)) && (sky === "request" || sky === "environment" || sky === "none");
2559
+ }
2560
+ /**
2561
+ * Checks the result of `cancelBake`.
2562
+ *
2563
+ * @param value - The received `result`.
2564
+ * @returns True for `{ cancelled: boolean }`.
2565
+ *
2566
+ * @public
2567
+ */
2568
+ function isCancelBakeResult(value) {
2569
+ return isRecord(value) && typeof value["cancelled"] === "boolean";
2570
+ }
2571
+ /**
2572
+ * Checks the `data` of a failed `bakeLightProbes`.
2573
+ *
2574
+ * @param value - The received error `data`.
2575
+ * @returns True for a known reason and, when present, a known cause.
2576
+ *
2577
+ * @public
2578
+ */
2579
+ function isBakeFailureData(value) {
2580
+ return isRecord(value) && Object.values(BakeFailureReason).some((reason) => reason === value["reason"]) && optionalField(value, "cause", (cause) => Object.values(BakeCancelCause).some((known) => known === cause));
2581
+ }
2582
+ /**
2583
+ * Checks the parameters of `cancelBake`.
2584
+ *
2585
+ * @param value - The received `params`.
2586
+ * @returns True for none, or an empty object.
2587
+ *
2588
+ * @public
2589
+ */
2590
+ function isCancelBakeParams(value) {
2591
+ return value === void 0 || isRecord(value) && Object.keys(value).length === 0;
2592
+ }
2593
+ //#endregion
2220
2594
  //#region src/channel.ts
2221
2595
  /**
2222
2596
  * The host half of an editor channel: accepts the `MessagePort` the editor posts to the view's
@@ -2719,6 +3093,70 @@ function relayAppReports(app, sink) {
2719
3093
  };
2720
3094
  }
2721
3095
  //#endregion
3096
+ //#region src/lite/drawn-meshes.ts
3097
+ /**
3098
+ * The render scene's drawn meshes for `pickRect`: each visible mesh's local bounds and world matrix,
3099
+ * with the entity node it hangs under. The projection and the tests are plain arithmetic in
3100
+ * `../scene/rect-pick.ts`; only this walk touches Lite (`CONSTITUTION.md` §3.4).
3101
+ */
3102
+ /**
3103
+ * A node's parent. Lite types it as a bare world-matrix provider, so it is followed by identity only.
3104
+ *
3105
+ * @param node - The node.
3106
+ * @returns The parent, or `null` at a root.
3107
+ */
3108
+ function parentNode$1(node) {
3109
+ const parent = Reflect.get(node, "parent");
3110
+ return typeof parent === "object" && parent !== null ? parent : null;
3111
+ }
3112
+ /**
3113
+ * Lists the visible, pickable meshes of the render scene that hang under one of the given nodes, each with
3114
+ * the nearest such node's value. A `Model` parents its glTF root with a bare `parent` assignment, so
3115
+ * the walk follows `parent` up from each mesh rather than `children` down. Meshes marked with core's
3116
+ * `EDITOR_ONLY_METADATA_KEY` (the host's grid and lines) are skipped.
3117
+ *
3118
+ * @param handles - The app's Lite handles (`app.lite`).
3119
+ * @param owners - The nodes to attribute meshes to (an entity's `transform.lite`), and their values.
3120
+ * @returns The meshes, in the render scene's order.
3121
+ */
3122
+ function drawnMeshes(handles, owners) {
3123
+ const memo = /* @__PURE__ */ new Map();
3124
+ const ownerOf = (start) => {
3125
+ const walked = [];
3126
+ let found = null;
3127
+ for (let node = start; node !== null; node = parentNode$1(node)) {
3128
+ const known = memo.get(node);
3129
+ if (known !== void 0) {
3130
+ found = known;
3131
+ break;
3132
+ }
3133
+ walked.push(node);
3134
+ const value = owners.get(node);
3135
+ if (value !== void 0) {
3136
+ found = value;
3137
+ break;
3138
+ }
3139
+ }
3140
+ for (const node of walked) memo.set(node, found);
3141
+ return found;
3142
+ };
3143
+ const result = [];
3144
+ for (const mesh of handles.scene.meshes) {
3145
+ const min = mesh.boundMin;
3146
+ const max = mesh.boundMax;
3147
+ if (min === void 0 || max === void 0 || mesh.visible === false || mesh.pickable === false) continue;
3148
+ if (mesh.metadata?.[EDITOR_ONLY_METADATA_KEY] === true) continue;
3149
+ const owner = ownerOf(mesh);
3150
+ if (owner !== null) result.push({
3151
+ owner,
3152
+ min,
3153
+ max,
3154
+ world: mesh.worldMatrix
3155
+ });
3156
+ }
3157
+ return result;
3158
+ }
3159
+ //#endregion
2722
3160
  //#region src/lite/gizmos.ts
2723
3161
  /**
2724
3162
  * The scene view's overlay: Babylon Lite's position, rotation and scale gizmos and the selection
@@ -4695,6 +5133,42 @@ function boundsOf2D(app, entities) {
4695
5133
  return box;
4696
5134
  }
4697
5135
  /**
5136
+ * Every drawn 2D rectangle of a scene instance, for `pickRect` in 2D view mode: each synced
5137
+ * sprite's quad and each loaded tilemap's extent, with the entity that carries it. A disabled
5138
+ * component, or one on an inactive entity, draws nothing and is left out, as the 2D click pick
5139
+ * never reaches it.
5140
+ *
5141
+ * @param app - The app whose registry names the 2D classes.
5142
+ * @param scene - The scene instance.
5143
+ * @returns The rectangles; none without `@ignifx/2d`.
5144
+ */
5145
+ function drawnBoxes2D(app, scene) {
5146
+ const result = [];
5147
+ const sprite = componentTypeOf(app, SPRITE_RENDERER_TYPE);
5148
+ for (const component of sprite === null ? [] : app.world.components(sprite)) {
5149
+ if (component.entity.scene !== scene || !component.isEnabledInHierarchy || !isSpriteLike(component)) continue;
5150
+ const { min, max } = component.bounds;
5151
+ if (max.x > min.x && max.y > min.y) result.push({
5152
+ entity: component.entity,
5153
+ box: {
5154
+ minX: min.x,
5155
+ minY: min.y,
5156
+ maxX: max.x,
5157
+ maxY: max.y
5158
+ }
5159
+ });
5160
+ }
5161
+ const tilemap = componentTypeOf(app, TILEMAP_TYPE);
5162
+ for (const component of tilemap === null ? [] : app.world.components(tilemap)) {
5163
+ const box = component.entity.scene === scene && component.isEnabledInHierarchy && isTilemapLike$1(component) ? tilemapBox(component) : null;
5164
+ if (box !== null) result.push({
5165
+ entity: component.entity,
5166
+ box
5167
+ });
5168
+ }
5169
+ return result;
5170
+ }
5171
+ /**
4698
5172
  * A tilemap's world rectangle: from its entity's origin, its widest and tallest layer in cells.
4699
5173
  *
4700
5174
  * @param map - The tilemap.
@@ -5793,6 +6267,474 @@ function screenGridPlacement(view, size) {
5793
6267
  };
5794
6268
  }
5795
6269
  //#endregion
6270
+ //#region src/scene/light-probe-baker.ts
6271
+ /**
6272
+ * `bakeLightProbes` (`LightProbeBakeMethod`): the scene host bakes a `LightProbeVolume` with core's
6273
+ * `bakeLightProbes` over its live edit-mode world, so the bake traces what the view shows — prefab
6274
+ * instance members, models (read from their drawn meshes under a GPU), lights with their
6275
+ * `bakeMode`, transforms with their rotations — and the environment's diffuse harmonics as the sky.
6276
+ * The host writes no file: the answer carries the `.probes.json` document.
6277
+ *
6278
+ * The pure parts (the grid for a volume, the progress throttle, the sky from Lite's harmonics) are
6279
+ * exported for the Node tests.
6280
+ */
6281
+ /**
6282
+ * The probes along one axis of a box for a spacing: one for a flat side, else at least two (on the
6283
+ * box's faces) and enough that neighbours are at most `spacing` apart. The editor's own planner
6284
+ * (`probeGridForVolume`) does the same.
6285
+ *
6286
+ * @param size - The box's side, in metres.
6287
+ * @param spacing - The largest distance between probes.
6288
+ * @returns The axis.
6289
+ */
6290
+ function axisForSpacing(size, spacing) {
6291
+ if (!(size > 1e-6)) return {
6292
+ count: 1,
6293
+ cell: 1
6294
+ };
6295
+ const count = Math.max(2, Math.ceil(size / spacing - 1e-9) + 1);
6296
+ return {
6297
+ count,
6298
+ cell: size / (count - 1)
6299
+ };
6300
+ }
6301
+ /**
6302
+ * The probes along one axis of a box for a count: one at the centre, else spread face to face.
6303
+ *
6304
+ * @param size - The box's side, in metres.
6305
+ * @param count - How many probes.
6306
+ * @returns The axis.
6307
+ */
6308
+ function axisForCount(size, count) {
6309
+ if (count === 1) return {
6310
+ count,
6311
+ cell: 1
6312
+ };
6313
+ return {
6314
+ count,
6315
+ cell: Math.max(size, 1e-6) / (count - 1)
6316
+ };
6317
+ }
6318
+ /**
6319
+ * The grid for a volume: the volume entity's box (centred on its world position, its world scale
6320
+ * as the size in metres, axis-aligned), with the request's counts or spacing.
6321
+ *
6322
+ * @param world - The volume entity's world matrix, column-major.
6323
+ * @param request - The request's `counts` or `spacing`.
6324
+ * @param request.counts - Probes along X, Y and Z.
6325
+ * @param request.spacing - The largest distance between probes, in metres.
6326
+ * @returns The grid, or why it cannot be baked.
6327
+ */
6328
+ function bakeGridForVolume(world, request) {
6329
+ const at = (index) => world[index] ?? 0;
6330
+ const size = [
6331
+ Math.hypot(at(0), at(1), at(2)),
6332
+ Math.hypot(at(4), at(5), at(6)),
6333
+ Math.hypot(at(8), at(9), at(10))
6334
+ ];
6335
+ const centre = [
6336
+ at(12),
6337
+ at(13),
6338
+ at(14)
6339
+ ];
6340
+ if (![...size, ...centre].every(Number.isFinite)) return { problem: "The volume's transform is not finite." };
6341
+ const counts = request.counts;
6342
+ const [x, y, z] = size.map((side, axis) => counts === void 0 ? axisForSpacing(side, request.spacing ?? 2) : axisForCount(side, counts[axis] ?? 1));
6343
+ if (x === void 0 || y === void 0 || z === void 0) return { problem: "The grid has no axes." };
6344
+ const shape = `A ${String(x.count)} × ${String(y.count)} × ${String(z.count)} grid`;
6345
+ if (x.count > 1024 || y.count * z.count > 4096) return { problem: `${shape} is more than a .probes.json holds (X at most ${String(BAKE_MAX_COUNT_X)}, Y × Z at most ${String(BAKE_MAX_COUNT_YZ)}).` };
6346
+ if (x.count * y.count * z.count > 16384) return { problem: `${shape} is more than ${String(BAKE_MAX_PROBES)} probes.` };
6347
+ const first = (axis, index) => (centre[index] ?? 0) - (axis.count === 1 ? 0 : axis.cell * (axis.count - 1) / 2);
6348
+ return {
6349
+ origin: {
6350
+ x: first(x, 0),
6351
+ y: first(y, 1),
6352
+ z: first(z, 2)
6353
+ },
6354
+ cellSize: {
6355
+ x: x.cell,
6356
+ y: y.cell,
6357
+ z: z.cell
6358
+ },
6359
+ counts: {
6360
+ x: x.count,
6361
+ y: y.count,
6362
+ z: z.count
6363
+ }
6364
+ };
6365
+ }
6366
+ /**
6367
+ * Lets progress through at most once per interval: the first report at once, then one whenever the
6368
+ * interval has passed since the last one let through.
6369
+ */
6370
+ var ProgressThrottle = class {
6371
+ #intervalMs;
6372
+ #now;
6373
+ #emit;
6374
+ #last = Number.NEGATIVE_INFINITY;
6375
+ /**
6376
+ * Creates the throttle.
6377
+ *
6378
+ * @param intervalMs - The shortest time between two reports let through.
6379
+ * @param now - The clock, in milliseconds.
6380
+ * @param emit - Receives each report let through.
6381
+ */
6382
+ constructor(intervalMs, now, emit) {
6383
+ this.#intervalMs = intervalMs;
6384
+ this.#now = now;
6385
+ this.#emit = emit;
6386
+ }
6387
+ /**
6388
+ * Reports progress; it goes through when the interval has passed.
6389
+ *
6390
+ * @param done - Probes baked.
6391
+ * @param total - Probes in all.
6392
+ */
6393
+ report(done, total) {
6394
+ const now = this.#now();
6395
+ if (now - this.#last < this.#intervalMs) return;
6396
+ this.#last = now;
6397
+ this.#emit(done, total);
6398
+ }
6399
+ };
6400
+ /** The real SH basis constants for bands 0–2, in the order of `LightProbeBakeSkyHarmonics`. */
6401
+ const SH_BASIS = [
6402
+ .2820947917738781,
6403
+ .4886025119029199,
6404
+ .4886025119029199,
6405
+ .4886025119029199,
6406
+ 1.0925484305920792,
6407
+ 1.0925484305920792,
6408
+ .31539156525252005,
6409
+ 1.0925484305920792,
6410
+ .5462742152960396
6411
+ ];
6412
+ /** The clamped-cosine convolution per band, over π: 1, 2/3 and 1/4. */
6413
+ const LAMBERT_OVER_PI = [
6414
+ 1,
6415
+ 2 / 3,
6416
+ 2 / 3,
6417
+ 2 / 3,
6418
+ 1 / 4,
6419
+ 1 / 4,
6420
+ 1 / 4,
6421
+ 1 / 4,
6422
+ 1 / 4
6423
+ ];
6424
+ /**
6425
+ * Turns an installed environment's diffuse harmonics, as Lite holds them, into a radiance sky for
6426
+ * the bake.
6427
+ *
6428
+ * @remarks
6429
+ * Lite's PBR shader (`lib/material/pbr/fragments/ibl-fragment.js`) lights a surface of normal `N`
6430
+ * with `Σ Pᵢ·bᵢ(N')`: `Pᵢ` the nine pre-scaled harmonics (`EnvironmentTextures.sphericalHarmonics`,
6431
+ * 36 floats in stride 4: `L00, L1-1, L10, L11, L2-2, L2-1, L20, L21, L22`), `bᵢ` the polynomials
6432
+ * `1, y, z, x, xy, yz, 3z²−1, zx, x²−y²`, and `N' = rotateY(N, envRotationY)`. That sum is the
6433
+ * outgoing radiance of a white Lambertian surface. The bake's sky is incident radiance
6434
+ * `Σ cᵢ·Kᵢ·bᵢ(d)`, so `cᵢ = Qᵢ / (Kᵢ·Aₗ/π)`, with `Qᵢ` the shader's polynomial turned into world
6435
+ * axes (the rotation folded in) and `Aₗ/π` the band's cosine convolution: a uniform environment
6436
+ * then bakes to the same `c0` the shader shows.
6437
+ *
6438
+ * @param preScaled - Lite's 36 floats.
6439
+ * @param rotation - The environment's Y rotation, in radians (`Environment.rotation` in degrees, converted).
6440
+ * @returns The sky, or `null` when the harmonics are not 36 finite numbers.
6441
+ */
6442
+ function skyFromPreScaledHarmonics(preScaled, rotation) {
6443
+ if (preScaled.length < 36 || !Number.isFinite(rotation)) return null;
6444
+ const c = Math.cos(rotation);
6445
+ const s = Math.sin(rotation);
6446
+ const coefficients = Array.from({ length: 27 }, () => 0);
6447
+ for (let channel = 0; channel < 3; channel += 1) {
6448
+ const p = (term) => preScaled[term * 4 + channel] ?? NaN;
6449
+ const q = [
6450
+ p(0),
6451
+ p(1),
6452
+ c * p(2) + s * p(3),
6453
+ -s * p(2) + c * p(3),
6454
+ c * p(4) - s * p(5),
6455
+ s * p(4) + c * p(5),
6456
+ (c * c - s * s / 2) * p(6) + s * c / 2 * p(7) + s * s / 2 * p(8),
6457
+ -6 * s * c * p(6) + (c * c - s * s) * p(7) + 2 * s * c * p(8),
6458
+ 3 * s * s / 2 * p(6) - s * c / 2 * p(7) + (1 + c * c) / 2 * p(8)
6459
+ ];
6460
+ for (let term = 0; term < 9; term += 1) coefficients[term * 3 + channel] = (q[term] ?? 0) / ((SH_BASIS[term] ?? 1) * (LAMBERT_OVER_PI[term] ?? 1));
6461
+ }
6462
+ return coefficients.every(Number.isFinite) ? {
6463
+ kind: "sh9",
6464
+ coefficients
6465
+ } : null;
6466
+ }
6467
+ /**
6468
+ * The sky of the open document's environment: the first enabled `Environment` in it whose
6469
+ * installed asset has Lite harmonics (only under a GPU).
6470
+ *
6471
+ * @param app - The scene view's app.
6472
+ * @param scene - The open document.
6473
+ * @returns The sky, or `null`.
6474
+ */
6475
+ function environmentSky(app, scene) {
6476
+ for (const environment of app.world.components(Environment)) {
6477
+ if (!environment.isEnabledInHierarchy || environment.entity.scene !== scene) continue;
6478
+ const harmonics = environment.installed?.lite.textures?.sphericalHarmonics;
6479
+ if (harmonics !== void 0) return skyFromPreScaledHarmonics(harmonics, environment.rotation * Math.PI / 180);
6480
+ }
6481
+ return null;
6482
+ }
6483
+ /** The reason an aborted bake rejects with. */
6484
+ var BakeCancelled = class extends Error {
6485
+ /** What cancelled it. */
6486
+ bakeCause;
6487
+ /**
6488
+ * Creates the reason.
6489
+ *
6490
+ * @param cause - What cancelled the bake.
6491
+ */
6492
+ constructor(cause) {
6493
+ super(`The bake was cancelled (${cause}).`);
6494
+ this.name = "BakeCancelled";
6495
+ this.bakeCause = cause;
6496
+ }
6497
+ };
6498
+ /**
6499
+ * A failure with {@link BakeFailureData}.
6500
+ *
6501
+ * @param code - The error code.
6502
+ * @param message - What went wrong.
6503
+ * @param data - Why.
6504
+ * @returns The failure.
6505
+ */
6506
+ function bakeFailure(code, message, data) {
6507
+ return new RpcFailure(code, message, data);
6508
+ }
6509
+ /**
6510
+ * Rounds the baked coefficients for the answer: {@link BAKE_COEFFICIENT_DIGITS} significant digits,
6511
+ * `0` below `1e-6` in magnitude.
6512
+ *
6513
+ * @param coefficients - The baked coefficients.
6514
+ * @returns The rounded ones, or `null` when one is not finite or above {@link BAKE_MAX_COEFFICIENT}.
6515
+ */
6516
+ function answerCoefficients(coefficients) {
6517
+ const out = [];
6518
+ for (const value of coefficients) {
6519
+ if (!Number.isFinite(value) || Math.abs(value) > 0xe8d4a51000) return null;
6520
+ out.push(Math.abs(value) < 1e-6 ? 0 : Number(value.toPrecision(6)) + 0);
6521
+ }
6522
+ return out;
6523
+ }
6524
+ /** Runs one bake at a time over the scene view's world. */
6525
+ var LightProbeBaker = class {
6526
+ #notify;
6527
+ #now;
6528
+ #running = null;
6529
+ #pending = null;
6530
+ /**
6531
+ * Creates the baker.
6532
+ *
6533
+ * @param notify - Sends a notification to the editor.
6534
+ * @param now - The clock, in milliseconds.
6535
+ */
6536
+ constructor(notify, now = () => performance.now()) {
6537
+ this.#notify = notify;
6538
+ this.#now = now;
6539
+ }
6540
+ /**
6541
+ * Whether a bake is pending or running.
6542
+ *
6543
+ * @returns True from a reservation to the bake's end.
6544
+ */
6545
+ get busy() {
6546
+ return this.#running !== null || this.#pending !== null;
6547
+ }
6548
+ /**
6549
+ * Reserves the baker for a request whose queue slot is still to run, so `cancelBake` can cancel it
6550
+ * before it starts and a second request is `busy` at once.
6551
+ *
6552
+ * @returns The reservation, for {@link LightProbeBaker.start}.
6553
+ * @throws RpcFailure `busy` while a bake is pending or running.
6554
+ */
6555
+ reserve() {
6556
+ if (this.busy) throw busyFailure();
6557
+ const pending = { cancelled: false };
6558
+ this.#pending = pending;
6559
+ return pending;
6560
+ }
6561
+ /**
6562
+ * Checks the request and starts the bake. Everything the bake reads of the world — meshes, models,
6563
+ * lights, transforms, the environment — is read before this returns (core reads the world once,
6564
+ * before its first yield), so it must run in the host's queue.
6565
+ *
6566
+ * @param app - The scene view's app.
6567
+ * @param scene - The open document, or `null`.
6568
+ * @param params - The request's parameters.
6569
+ * @param pending - The reservation, from {@link LightProbeBaker.reserve}; released here.
6570
+ * @returns The started bake.
6571
+ * @throws RpcFailure as `BakeFailureReason` lists, `InvalidParamsError` for bad parameters,
6572
+ * `RpcErrorCode.noScene` with no document.
6573
+ */
6574
+ start(app, scene, params, pending) {
6575
+ try {
6576
+ if (pending.cancelled) throw toFailure$1(new BakeCancelled(BakeCancelCause.cancelBake));
6577
+ return this.#start(app, scene, params);
6578
+ } finally {
6579
+ if (this.#pending === pending) this.#pending = null;
6580
+ }
6581
+ }
6582
+ /**
6583
+ * {@link LightProbeBaker.start}, once the reservation stands.
6584
+ *
6585
+ * @param app - The scene view's app.
6586
+ * @param scene - The open document, or `null`.
6587
+ * @param params - The request's parameters.
6588
+ * @returns The started bake.
6589
+ */
6590
+ #start(app, scene, params) {
6591
+ if (!isBakeLightProbesParams(params)) throw new InvalidParamsError("bakeLightProbes takes { volume: uid, counts?: [x, y, z] | spacing?: metres, directLight?: \"include\" | \"exclude\", sky?, rays?, maxDistance? }.");
6592
+ if (scene === null) throw new RpcFailure(RpcErrorCode.noScene, "No scene is open; send \"openScene\" before \"bakeLightProbes\".");
6593
+ if (this.#running !== null) throw busyFailure();
6594
+ const entity = app.world.getEntity(params.volume);
6595
+ if (entity === null || entity.scene !== scene) throw bakeFailure(RpcErrorCode.unknownEntity, `The open scene has no entity ${params.volume}.`, { reason: BakeFailureReason.unknownEntity });
6596
+ if (entity.getComponent(LightProbeVolume) === null) throw bakeFailure(RpcErrorCode.invalidParams, `${entity.name} has no LightProbeVolume.`, { reason: BakeFailureReason.notAVolume });
6597
+ const grid = bakeGridForVolume(entity.transform.worldMatrix, params);
6598
+ if ("problem" in grid) throw bakeFailure(RpcErrorCode.invalidParams, grid.problem, { reason: BakeFailureReason.invalidGrid });
6599
+ const { sky, source } = this.#sky(app, scene, params);
6600
+ const controller = new AbortController();
6601
+ const started = this.#now();
6602
+ const volume = params.volume;
6603
+ const throttle = new ProgressThrottle(100, this.#now, (done, total) => {
6604
+ const progress = {
6605
+ volume,
6606
+ done,
6607
+ total
6608
+ };
6609
+ this.#notify(LightProbeBakeNotification.bakeProgress, progress);
6610
+ });
6611
+ this.#running = controller;
6612
+ let baking;
6613
+ try {
6614
+ baking = bakeLightProbes(app.world, {
6615
+ ...grid,
6616
+ ...params.rays === void 0 ? {} : { rays: params.rays },
6617
+ ...params.maxDistance === void 0 ? {} : { maxDistance: params.maxDistance },
6618
+ ...params.directLight === void 0 ? {} : { directLight: params.directLight },
6619
+ ...sky === null ? {} : { sky },
6620
+ signal: controller.signal,
6621
+ onProgress: (done, total) => {
6622
+ throttle.report(done, total);
6623
+ }
6624
+ });
6625
+ } catch (error) {
6626
+ this.#running = null;
6627
+ throw toFailure$1(error);
6628
+ }
6629
+ return { finished: baking.then((baked) => {
6630
+ this.#end(controller);
6631
+ const coefficients = answerCoefficients(baked.data.coefficients);
6632
+ if (coefficients === null) throw bakeFailure(RpcErrorCode.invalidRequest, `The bake gave a coefficient that is not finite or above ${String(BAKE_MAX_COEFFICIENT)}: a light or the sky is far too bright.`, { reason: BakeFailureReason.outOfRange });
6633
+ return {
6634
+ probes: writeLightProbeFile({
6635
+ ...baked.data,
6636
+ coefficients
6637
+ }),
6638
+ stats: {
6639
+ probes: grid.counts.x * grid.counts.y * grid.counts.z,
6640
+ triangles: baked.triangles,
6641
+ skipped: baked.skipped,
6642
+ ms: Math.round(this.#now() - started)
6643
+ },
6644
+ skips: baked.skips.slice(0, 256).map((skip) => ({
6645
+ entity: skip.entity,
6646
+ uid: skip.uid,
6647
+ component: skip.component,
6648
+ reason: skip.reason
6649
+ })),
6650
+ sky: source
6651
+ };
6652
+ }, (error) => {
6653
+ this.#end(controller);
6654
+ throw toFailure$1(error);
6655
+ }) };
6656
+ }
6657
+ /**
6658
+ * Cancels the running bake, if any, or with `cancelBake` the pending one. A document change leaves
6659
+ * a pending bake alone: it has not read the world yet, and will read the changed one.
6660
+ *
6661
+ * @param cause - What cancels it.
6662
+ * @returns Whether one was cancelled.
6663
+ */
6664
+ cancel(cause) {
6665
+ const running = this.#running;
6666
+ if (running === null) {
6667
+ const pending = this.#pending;
6668
+ if (pending === null || pending.cancelled || cause !== BakeCancelCause.cancelBake) return false;
6669
+ pending.cancelled = true;
6670
+ return true;
6671
+ }
6672
+ this.#running = null;
6673
+ running.abort(new BakeCancelled(cause));
6674
+ return true;
6675
+ }
6676
+ /** Cancels the running bake; the host is going away. */
6677
+ dispose() {
6678
+ this.cancel(BakeCancelCause.sceneChanged);
6679
+ }
6680
+ /**
6681
+ * Forgets a bake that ended, unless another has started since.
6682
+ *
6683
+ * @param controller - The bake's controller.
6684
+ */
6685
+ #end(controller) {
6686
+ if (this.#running === controller) this.#running = null;
6687
+ }
6688
+ /**
6689
+ * The sky a request bakes with, and where it came from.
6690
+ *
6691
+ * @param app - The app.
6692
+ * @param scene - The open document.
6693
+ * @param params - The request.
6694
+ * @returns The sky (`null` for black) and its source.
6695
+ */
6696
+ #sky(app, scene, params) {
6697
+ if (params.sky === null) return {
6698
+ sky: null,
6699
+ source: "none"
6700
+ };
6701
+ if (params.sky !== void 0) return {
6702
+ sky: params.sky,
6703
+ source: "request"
6704
+ };
6705
+ const fromEnvironment = environmentSky(app, scene);
6706
+ return fromEnvironment === null ? {
6707
+ sky: null,
6708
+ source: "none"
6709
+ } : {
6710
+ sky: fromEnvironment,
6711
+ source: "environment"
6712
+ };
6713
+ }
6714
+ };
6715
+ /**
6716
+ * The failure of a request made while a bake is pending or running.
6717
+ *
6718
+ * @returns The failure.
6719
+ */
6720
+ function busyFailure() {
6721
+ return bakeFailure(RpcErrorCode.invalidRequest, "A light-probe bake is already running; cancel it or wait.", { reason: BakeFailureReason.busy });
6722
+ }
6723
+ /**
6724
+ * Turns what a bake threw into the method's failure.
6725
+ *
6726
+ * @param error - What it threw: a cancellation, a refused option, or a bug.
6727
+ * @returns The failure to answer with.
6728
+ */
6729
+ function toFailure$1(error) {
6730
+ if (error instanceof BakeCancelled) return bakeFailure(RpcErrorCode.invalidRequest, error.message, {
6731
+ reason: BakeFailureReason.cancelled,
6732
+ cause: error.bakeCause
6733
+ });
6734
+ if (isIgnifxError(error) && error.code === CoreErrorCode.invalidLightProbeBake) return new InvalidParamsError(error.message, { code: error.code });
6735
+ return error;
6736
+ }
6737
+ //#endregion
5796
6738
  //#region src/scene/held-references.ts
5797
6739
  /**
5798
6740
  * What instance members outside a subtree that is about to be rebuilt hold in it: the reference
@@ -6709,6 +7651,205 @@ async function removeOverride(context, op) {
6709
7651
  });
6710
7652
  }
6711
7653
  //#endregion
7654
+ //#region src/scene/rect-pick.ts
7655
+ /**
7656
+ * The arithmetic of `pickRect` that needs no GPU: the rectangle in backing-store pixels, a box's
7657
+ * corners projected through a camera's matrices (clipped at the camera plane), a 2D box projected
7658
+ * through the 2D editor camera, and the intersect and contain tests. Each is a pure function, so
7659
+ * the headless tests check it directly.
7660
+ */
7661
+ /**
7662
+ * How far in front of the camera plane, in clip-space `w`, a point must be to project. A box that
7663
+ * crosses the plane is cut there, so its rectangle grows toward the screen's edge but stays finite.
7664
+ */
7665
+ const MIN_CLIP_W = 1e-5;
7666
+ /** The twelve edges of a box, as pairs of corner indices (bit 0 x, bit 1 y, bit 2 z). */
7667
+ const BOX_EDGES = [
7668
+ [0, 1],
7669
+ [2, 3],
7670
+ [4, 5],
7671
+ [6, 7],
7672
+ [0, 2],
7673
+ [1, 3],
7674
+ [4, 6],
7675
+ [5, 7],
7676
+ [0, 4],
7677
+ [1, 5],
7678
+ [2, 6],
7679
+ [3, 7]
7680
+ ];
7681
+ /**
7682
+ * Converts `pickRect`'s corners to a backing-store rectangle, ordered and clipped to the canvas.
7683
+ *
7684
+ * @param params - The corners and their unit.
7685
+ * @param surface - The canvas's sizes.
7686
+ * @returns The rectangle, or `null` when it lies wholly outside the canvas.
7687
+ */
7688
+ function rectInBackingPixels(params, surface) {
7689
+ const sx = params.unit === PickUnit.backing ? 1 : surface.width / surface.clientWidth;
7690
+ const sy = params.unit === PickUnit.backing ? 1 : surface.height / surface.clientHeight;
7691
+ const minX = Math.max(0, Math.min(params.x0, params.x1) * sx);
7692
+ const minY = Math.max(0, Math.min(params.y0, params.y1) * sy);
7693
+ const maxX = Math.min(surface.width, Math.max(params.x0, params.x1) * sx);
7694
+ const maxY = Math.min(surface.height, Math.max(params.y0, params.y1) * sy);
7695
+ return minX > maxX || minY > maxY ? null : {
7696
+ minX,
7697
+ minY,
7698
+ maxX,
7699
+ maxY
7700
+ };
7701
+ }
7702
+ /**
7703
+ * Applies a column-major matrix to a point (`w = 1`).
7704
+ *
7705
+ * @param m - The matrix.
7706
+ * @param x - The point's x.
7707
+ * @param y - The point's y.
7708
+ * @param z - The point's z.
7709
+ * @param out - Receives `[x, y, z, w]`.
7710
+ */
7711
+ function transform(m, x, y, z, out) {
7712
+ out[0] = (m[0] ?? 0) * x + (m[4] ?? 0) * y + (m[8] ?? 0) * z + (m[12] ?? 0);
7713
+ out[1] = (m[1] ?? 0) * x + (m[5] ?? 0) * y + (m[9] ?? 0) * z + (m[13] ?? 0);
7714
+ out[2] = (m[2] ?? 0) * x + (m[6] ?? 0) * y + (m[10] ?? 0) * z + (m[14] ?? 0);
7715
+ out[3] = (m[3] ?? 0) * x + (m[7] ?? 0) * y + (m[11] ?? 0) * z + (m[15] ?? 0);
7716
+ }
7717
+ /**
7718
+ * Projects a box through a camera: its 8 corners go through the world matrix (when given), the
7719
+ * view matrix and the projection, as `Camera.worldToScreen` does. Corners behind the camera plane
7720
+ * are dropped and the edges that cross it are cut at it, so a box partly behind the camera covers
7721
+ * only what is in front.
7722
+ *
7723
+ * @param box - The box's `min` and `max` corners, in the space `world` maps from.
7724
+ * @param world - The box's world matrix, or `null` when `box` is already in world space.
7725
+ * @param view - The camera's view matrix.
7726
+ * @param projection - The camera's projection matrix.
7727
+ * @param width - The view's backing-store width.
7728
+ * @param height - The view's backing-store height.
7729
+ * @returns The projected box, or `null` when all of it is behind the camera.
7730
+ */
7731
+ function projectBox(box, world, view, projection, width, height) {
7732
+ const corners = [];
7733
+ const scratch = [
7734
+ 0,
7735
+ 0,
7736
+ 0,
7737
+ 0
7738
+ ];
7739
+ const eye = [
7740
+ 0,
7741
+ 0,
7742
+ 0,
7743
+ 0
7744
+ ];
7745
+ for (let corner = 0; corner < 8; corner += 1) {
7746
+ let x = (corner & 1) === 0 ? box.min[0] ?? 0 : box.max[0] ?? 0;
7747
+ let y = (corner & 2) === 0 ? box.min[1] ?? 0 : box.max[1] ?? 0;
7748
+ let z = (corner & 4) === 0 ? box.min[2] ?? 0 : box.max[2] ?? 0;
7749
+ if (world !== null) {
7750
+ transform(world, x, y, z, scratch);
7751
+ [x, y, z] = [
7752
+ scratch[0] ?? 0,
7753
+ scratch[1] ?? 0,
7754
+ scratch[2] ?? 0
7755
+ ];
7756
+ }
7757
+ transform(view, x, y, z, eye);
7758
+ const clip = [
7759
+ 0,
7760
+ 0,
7761
+ 0,
7762
+ 0
7763
+ ];
7764
+ transform(projection, eye[0] ?? 0, eye[1] ?? 0, eye[2] ?? 0, clip);
7765
+ corners.push(clip);
7766
+ }
7767
+ let minX = Number.POSITIVE_INFINITY;
7768
+ let minY = Number.POSITIVE_INFINITY;
7769
+ let maxX = Number.NEGATIVE_INFINITY;
7770
+ let maxY = Number.NEGATIVE_INFINITY;
7771
+ const take = (clip) => {
7772
+ const w = clip[3] ?? 1;
7773
+ const sx = ((clip[0] ?? 0) / w + 1) * .5 * width;
7774
+ const sy = (1 - (clip[1] ?? 0) / w) * .5 * height;
7775
+ minX = Math.min(minX, sx);
7776
+ minY = Math.min(minY, sy);
7777
+ maxX = Math.max(maxX, sx);
7778
+ maxY = Math.max(maxY, sy);
7779
+ };
7780
+ let clipped = false;
7781
+ for (const clip of corners) if ((clip[3] ?? 0) > MIN_CLIP_W) take(clip);
7782
+ else clipped = true;
7783
+ if (clipped) for (const [a, b] of BOX_EDGES) {
7784
+ const p = corners[a] ?? scratch;
7785
+ const q = corners[b] ?? scratch;
7786
+ const pw = p[3] ?? 0;
7787
+ const qw = q[3] ?? 0;
7788
+ if (pw > MIN_CLIP_W !== qw > MIN_CLIP_W) {
7789
+ const t = (MIN_CLIP_W - pw) / (qw - pw);
7790
+ take(p.map((value, index) => value + ((q[index] ?? 0) - value) * t));
7791
+ }
7792
+ }
7793
+ if (!Number.isFinite(minX)) return null;
7794
+ return {
7795
+ rect: {
7796
+ minX,
7797
+ minY,
7798
+ maxX,
7799
+ maxY
7800
+ },
7801
+ clipped
7802
+ };
7803
+ }
7804
+ /**
7805
+ * Projects a 2D world rectangle through the 2D editor camera: the inverse of `screenToWorld2D`.
7806
+ *
7807
+ * @param view - What the 2D camera shows.
7808
+ * @param box - The rectangle, in metres, +Y up.
7809
+ * @returns Its screen rectangle, in backing-store pixels.
7810
+ */
7811
+ function projectBox2D(view, box) {
7812
+ const scale = view.zoom * view.pixelsPerUnit;
7813
+ return {
7814
+ minX: (box.minX - view.centerX) * scale + view.widthPx / 2,
7815
+ maxX: (box.maxX - view.centerX) * scale + view.widthPx / 2,
7816
+ minY: view.heightPx / 2 - (box.maxY - view.centerY) * scale,
7817
+ maxY: view.heightPx / 2 - (box.minY - view.centerY) * scale
7818
+ };
7819
+ }
7820
+ /**
7821
+ * Tells whether a projected box matches the selection rectangle.
7822
+ *
7823
+ * @param box - The projected box.
7824
+ * @param rect - The selection rectangle.
7825
+ * @param mode - `"intersect"`: any overlap; `"contain"`: wholly inside, and wholly in front of the camera.
7826
+ * @returns True when it matches.
7827
+ */
7828
+ function rectMatches(box, rect, mode) {
7829
+ const b = box.rect;
7830
+ if (mode === PickRectMode.contain) return !box.clipped && b.minX >= rect.minX && b.maxX <= rect.maxX && b.minY >= rect.minY && b.maxY <= rect.maxY;
7831
+ return b.minX <= rect.maxX && b.maxX >= rect.minX && b.minY <= rect.maxY && b.maxY >= rect.minY;
7832
+ }
7833
+ /**
7834
+ * Grows a projected box to take in another.
7835
+ *
7836
+ * @param a - The box so far, or `undefined`.
7837
+ * @param b - The one to take in.
7838
+ * @returns Their union; clipped when either is.
7839
+ */
7840
+ function unionProjected(a, b) {
7841
+ if (a === void 0) return b;
7842
+ return {
7843
+ rect: {
7844
+ minX: Math.min(a.rect.minX, b.rect.minX),
7845
+ minY: Math.min(a.rect.minY, b.rect.minY),
7846
+ maxX: Math.max(a.rect.maxX, b.rect.maxX),
7847
+ maxY: Math.max(a.rect.maxY, b.rect.maxY)
7848
+ },
7849
+ clipped: a.clipped || b.clipped
7850
+ };
7851
+ }
7852
+ //#endregion
6712
7853
  //#region src/scene/sample-animation.ts
6713
7854
  /**
6714
7855
  * `sampleAnimation`: the scene view poses an entity's `Animator` at one point of one state, through
@@ -6826,7 +7967,7 @@ function schemaSet(app, hidden) {
6826
7967
  const schema = type === Transform ? transformSchema() : registry.describe(type).schema ?? {};
6827
7968
  schemas[typeId] = {
6828
7969
  ...description,
6829
- extends: registeredAncestors(registry, type),
7970
+ extends: registeredAncestors(registry, type, hidden),
6830
7971
  propsSchema: toJsonSchema(schema)
6831
7972
  };
6832
7973
  }
@@ -6844,14 +7985,18 @@ function schemaSet(app, hidden) {
6844
7985
  *
6845
7986
  * @param registry - The app's component registry.
6846
7987
  * @param type - The described class.
7988
+ * @param hidden - The host's own type ids, which the set leaves out and so never lists here.
6847
7989
  * @returns The ancestors' type ids, the class itself excluded; empty when none is registered.
6848
7990
  */
6849
- function registeredAncestors(registry, type) {
7991
+ function registeredAncestors(registry, type, hidden) {
6850
7992
  const ids = [];
6851
7993
  const ancestors = registry.describe(type).ancestors;
6852
7994
  for (let index = 1; index < ancestors.length; index += 1) {
6853
7995
  const ancestor = ancestors[index];
6854
- if (ancestor !== void 0 && registry.isRegistered(ancestor)) ids.push(registry.requireTypeId(ancestor));
7996
+ if (ancestor !== void 0 && registry.isRegistered(ancestor)) {
7997
+ const id = registry.requireTypeId(ancestor);
7998
+ if (!hidden.has(id)) ids.push(id);
7999
+ }
6855
8000
  }
6856
8001
  return ids;
6857
8002
  }
@@ -6932,8 +8077,9 @@ function settingsSet(app) {
6932
8077
  //#endregion
6933
8078
  //#region src/scene/thumbnails.ts
6934
8079
  /**
6935
- * `renderThumbnail` (engine ask E8): a model or prefab rendered on its own, in a second app the
6936
- * host keeps for the purpose, through `app.renderer.renderToTexture`.
8080
+ * `renderThumbnail` (engine ask E8): a model, prefab or material rendered on its own, in a second
8081
+ * app the host keeps for the purpose, through `app.renderer.renderToTexture`; a sprite atlas or an
8082
+ * image drawn from its decoded image, fitted in the square on a transparent background.
6937
8083
  *
6938
8084
  * The stage is a separate app on a 1x1 `OffscreenCanvas`, built from the project's own options, so
6939
8085
  * a thumbnail never shows the open document, never lights it, and is never lit by it. It is
@@ -6964,27 +8110,99 @@ const VIEW_DIRECTION = {
6964
8110
  y: .45,
6965
8111
  z: -.7
6966
8112
  };
8113
+ /** The sphere a material is shown on: its diameter, in metres, and its segments. */
8114
+ const MATERIAL_SPHERE = {
8115
+ diameter: 1,
8116
+ segments: 48
8117
+ };
8118
+ /** The extensions of the images a browser decodes, which an address alone is typed `texture` by. */
8119
+ const IMAGE_EXTENSIONS = [
8120
+ ".png",
8121
+ ".jpg",
8122
+ ".jpeg",
8123
+ ".webp"
8124
+ ];
8125
+ /** The URL prefixes an atlas's `image` is fetched verbatim with, as `@ignifx/2d`'s loader does. */
8126
+ const ABSOLUTE_PREFIXES = [
8127
+ "/",
8128
+ "http://",
8129
+ "https://",
8130
+ "blob:",
8131
+ "data:"
8132
+ ];
6967
8133
  /**
6968
- * Types the requested asset.
8134
+ * Types the requested asset: by its reference's `type` when it has one, else by its extension.
6969
8135
  *
6970
8136
  * @param params - Checked parameters.
6971
8137
  * @returns The address and what it is.
6972
- * @throws InvalidParamsError for an asset that is neither a model nor a prefab.
8138
+ * @throws InvalidParamsError for an asset of a type the host does not render.
6973
8139
  */
6974
8140
  function thumbnailSubject(params) {
6975
8141
  const asset = params.asset;
6976
8142
  const address = typeof asset === "string" ? asset : asset.$asset;
6977
8143
  const type = typeof asset === "string" ? void 0 : asset.type;
6978
8144
  const lower = address.toLowerCase();
6979
- if (type === "model" || type === void 0 && (lower.endsWith(".glb") || lower.endsWith(".gltf"))) return {
6980
- address,
6981
- kind: "model"
8145
+ const byType = {
8146
+ model: "model",
8147
+ scene: "prefab",
8148
+ prefab: "prefab",
8149
+ material: "material",
8150
+ spriteatlas: "atlas",
8151
+ texture: "texture"
6982
8152
  };
6983
- if (type === "scene" || type === "prefab" || type === void 0 && (lower.endsWith(".prefab.json") || lower.endsWith(".scene.json"))) return {
8153
+ const isImage = IMAGE_EXTENSIONS.some((extension) => lower.endsWith(extension));
8154
+ let kind;
8155
+ if (type !== void 0) {
8156
+ kind = byType[type];
8157
+ if (kind === "texture" && !isImage) kind = void 0;
8158
+ } else if (lower.endsWith(".glb") || lower.endsWith(".gltf")) kind = "model";
8159
+ else if (lower.endsWith(".prefab.json") || lower.endsWith(".scene.json")) kind = "prefab";
8160
+ else if (lower.endsWith(".material.json")) kind = "material";
8161
+ else if (lower.endsWith(".atlas.json")) kind = "atlas";
8162
+ else if (isImage) kind = "texture";
8163
+ if (kind === void 0) throw new InvalidParamsError(`renderThumbnail renders models (.glb, .gltf), prefabs (.prefab.json), materials (.material.json), sprite atlases (.atlas.json) and images (${IMAGE_EXTENSIONS.join(", ")}); ${address} is none of them.`);
8164
+ return {
6984
8165
  address,
6985
- kind: "prefab"
8166
+ kind
8167
+ };
8168
+ }
8169
+ /**
8170
+ * The URL of a sprite atlas's image, as `@ignifx/2d`'s loader resolves it: a root-relative or
8171
+ * absolute reference is a URL, fetched as it is; anything else is an address relative to the
8172
+ * atlas's own, resolved through the asset service.
8173
+ *
8174
+ * @param resolveUrl - `app.assets.resolveUrl`.
8175
+ * @param atlasAddress - The atlas document's address.
8176
+ * @param image - Its `image` reference.
8177
+ * @returns The URL to fetch.
8178
+ */
8179
+ function atlasImageUrl(resolveUrl, atlasAddress, image) {
8180
+ if (ABSOLUTE_PREFIXES.some((prefix) => image.startsWith(prefix))) return image;
8181
+ const cut = atlasAddress.lastIndexOf("/");
8182
+ const joined = cut < 0 ? image : `${atlasAddress.slice(0, cut)}/${image}`;
8183
+ const segments = [];
8184
+ for (const segment of joined.split("/")) if (segment === "..") segments.pop();
8185
+ else if (segment !== "" && segment !== ".") segments.push(segment);
8186
+ return resolveUrl(segments.join("/"));
8187
+ }
8188
+ /**
8189
+ * Fits an image in a square: as large as it goes, its aspect kept, centred.
8190
+ *
8191
+ * @param width - The image's width, in pixels.
8192
+ * @param height - The image's height, in pixels.
8193
+ * @param side - The square's side, in pixels.
8194
+ * @returns Where to draw it.
8195
+ */
8196
+ function fitInSquare(width, height, side) {
8197
+ const scale = width > 0 && height > 0 ? Math.min(side / width, side / height) : 0;
8198
+ const w = width * scale;
8199
+ const h = height * scale;
8200
+ return {
8201
+ x: (side - w) / 2,
8202
+ y: (side - h) / 2,
8203
+ width: w,
8204
+ height: h
6986
8205
  };
6987
- throw new InvalidParamsError(`renderThumbnail renders models (.glb, .gltf) and prefabs (.prefab.json); ${address} is neither.`);
6988
8206
  }
6989
8207
  /**
6990
8208
  * The one-entity scene file that shows a subject.
@@ -7041,6 +8259,8 @@ function thumbnailScene(address, kind) {
7041
8259
  /** Renders thumbnails on a stage app of their own. */
7042
8260
  var ThumbnailRenderer = class {
7043
8261
  #createApp;
8262
+ #resolveUrl;
8263
+ #fetch;
7044
8264
  #stage = null;
7045
8265
  #texture = null;
7046
8266
  #loads = 0;
@@ -7053,9 +8273,13 @@ var ThumbnailRenderer = class {
7053
8273
  * Keeps the factory; nothing is created until the first thumbnail.
7054
8274
  *
7055
8275
  * @param createApp - Creates the stage app from the project's options, unstarted.
8276
+ * @param resolveUrl - Resolves an asset address to the URL to fetch, for atlases and images.
8277
+ * @param fetchAsset - The `fetch` the project's assets are read through, for atlases and images.
7056
8278
  */
7057
- constructor(createApp) {
8279
+ constructor(createApp, resolveUrl, fetchAsset) {
7058
8280
  this.#createApp = createApp;
8281
+ this.#resolveUrl = resolveUrl;
8282
+ this.#fetch = fetchAsset;
7059
8283
  }
7060
8284
  /**
7061
8285
  * `renderThumbnail`: loads the asset alone on the stage, frames it, renders it and encodes it.
@@ -7077,30 +8301,86 @@ var ThumbnailRenderer = class {
7077
8301
  async #render(params) {
7078
8302
  if (!isRenderThumbnailParams(params)) throw new InvalidParamsError("renderThumbnail takes { asset: address | { $asset, type? }, size?: 1 to 1024, format: \"png\" | \"jpeg\", quality? }.");
7079
8303
  const { address, kind } = thumbnailSubject(params);
7080
- const { app, camera } = await (this.#stage ??= this.#open());
8304
+ const size = params.size ?? 128;
8305
+ const quality = params.quality ?? DEFAULT_JPEG_QUALITY;
8306
+ if (kind === "atlas" || kind === "texture") {
8307
+ const url = kind === "texture" ? this.#resolveUrl(address) : await this.#atlasImage(address);
8308
+ return {
8309
+ dataUrl: await drawImageThumbnail(this.#fetch, url, size, params.format, quality),
8310
+ width: size,
8311
+ height: size
8312
+ };
8313
+ }
8314
+ const stage = await (this.#stage ??= this.#open());
8315
+ const { app } = stage;
7081
8316
  this.#loads += 1;
8317
+ if (kind === "material") {
8318
+ const material = await app.assets.loadAsync(assetRef(address, "material"));
8319
+ const scene = app.world.createScene(`__ignifx_thumbnail__/${String(this.#loads)}`);
8320
+ try {
8321
+ stage.sphere ??= MeshAsset.sphere(app, MATERIAL_SPHERE);
8322
+ app.world.createEntity("Thumbnail", { scene }).addComponent(MeshRenderer, {
8323
+ mesh: stage.sphere,
8324
+ materials: [material]
8325
+ });
8326
+ return await this.#shoot(stage, scene, params.format, size, quality);
8327
+ } finally {
8328
+ await app.world.unloadScene(scene);
8329
+ material.release();
8330
+ }
8331
+ }
7082
8332
  const instance = await app.world.loadSceneFile(thumbnailScene(address, kind), {
7083
8333
  address: `__ignifx_thumbnail__/${String(this.#loads)}.scene.json`,
7084
8334
  mode: "single"
7085
8335
  });
7086
8336
  try {
7087
- frameCamera(camera, await settledBounds(app, instance, () => this.#isLoading));
7088
- await nextFrame();
7089
- const size = params.size ?? 128;
7090
- const texture = this.#textureOf(app, size * SUPERSAMPLE);
7091
- await app.renderer.renderToTexture(camera, texture, { maxWaitMs: 20 });
7092
- return {
7093
- dataUrl: await encodeCapture(await texture.readPixels(), {
7094
- width: size,
7095
- height: size
7096
- }, params.format, params.quality ?? DEFAULT_JPEG_QUALITY),
7097
- width: size,
7098
- height: size
7099
- };
8337
+ return await this.#shoot(stage, instance, params.format, size, quality);
7100
8338
  } finally {
7101
8339
  await app.world.unloadScene(instance);
7102
8340
  }
7103
8341
  }
8342
+ /**
8343
+ * Waits for a subject on the stage to settle, frames it, renders it and encodes it.
8344
+ *
8345
+ * @param stage - The stage.
8346
+ * @param subject - The scene instance that holds the subject.
8347
+ * @param format - The image format.
8348
+ * @param size - The image's side.
8349
+ * @param quality - The JPEG quality.
8350
+ * @returns The image.
8351
+ */
8352
+ async #shoot(stage, subject, format, size, quality) {
8353
+ const { app, camera } = stage;
8354
+ const bounds = await settledBounds(app, subject, () => this.#isLoading);
8355
+ for (let frame = 0; frame < MAX_SETTLE_FRAMES && this.#isLoading; frame += 1) await nextFrame();
8356
+ frameCamera(camera, bounds);
8357
+ await nextFrame();
8358
+ const texture = this.#textureOf(app, size * SUPERSAMPLE);
8359
+ await app.renderer.renderToTexture(camera, texture, { maxWaitMs: 20 });
8360
+ return {
8361
+ dataUrl: await encodeCapture(await texture.readPixels(), {
8362
+ width: size,
8363
+ height: size
8364
+ }, format, quality),
8365
+ width: size,
8366
+ height: size
8367
+ };
8368
+ }
8369
+ /**
8370
+ * Reads a sprite atlas document and resolves its image's URL.
8371
+ *
8372
+ * @param address - The atlas's address.
8373
+ * @returns The image's URL.
8374
+ * @throws Error when the document cannot be fetched or names no image.
8375
+ */
8376
+ async #atlasImage(address) {
8377
+ const response = await this.#fetch(this.#resolveUrl(address), { cache: "no-cache" });
8378
+ if (!response.ok) throw new Error(`renderThumbnail could not read the atlas ${address}: HTTP ${String(response.status)}.`);
8379
+ const document = await response.json();
8380
+ const image = typeof document === "object" && document !== null ? Reflect.get(document, "image") : null;
8381
+ if (typeof image !== "string" || image === "") throw new Error(`renderThumbnail could not render the atlas ${address}: it names no image.`);
8382
+ return atlasImageUrl(this.#resolveUrl, address, image);
8383
+ }
7104
8384
  /** Disposes the stage app, now or once it has been created. */
7105
8385
  dispose() {
7106
8386
  this.#isDisposed = true;
@@ -7144,7 +8424,8 @@ var ThumbnailRenderer = class {
7144
8424
  if (this.#isDisposed) app.dispose();
7145
8425
  return {
7146
8426
  app,
7147
- camera
8427
+ camera,
8428
+ sphere: null
7148
8429
  };
7149
8430
  }
7150
8431
  /**
@@ -7164,6 +8445,40 @@ var ThumbnailRenderer = class {
7164
8445
  }
7165
8446
  };
7166
8447
  /**
8448
+ * Draws an image fitted in a square on a transparent background (a JPEG's shows black) and
8449
+ * encodes it. An image smaller than the square is enlarged without smoothing, so pixel art stays
8450
+ * crisp.
8451
+ *
8452
+ * @param fetchAsset - The `fetch` to read it with.
8453
+ * @param url - The image's URL.
8454
+ * @param size - The square's side, in pixels.
8455
+ * @param format - The image format.
8456
+ * @param quality - The JPEG quality.
8457
+ * @returns The data URL.
8458
+ * @throws Error when the image cannot be fetched or decoded.
8459
+ */
8460
+ async function drawImageThumbnail(fetchAsset, url, size, format, quality) {
8461
+ const response = await fetchAsset(url, { cache: "no-cache" });
8462
+ if (!response.ok) throw new Error(`renderThumbnail could not read the image ${url}: HTTP ${String(response.status)}.`);
8463
+ const bitmap = await createImageBitmap(await response.blob());
8464
+ try {
8465
+ const canvas = new OffscreenCanvas(size, size);
8466
+ const context = canvas.getContext("2d");
8467
+ if (context === null) throw new Error("This browser has no 2D canvas to draw the thumbnail with.");
8468
+ const fit = fitInSquare(bitmap.width, bitmap.height, size);
8469
+ context.imageSmoothingEnabled = fit.width < bitmap.width;
8470
+ context.imageSmoothingQuality = "high";
8471
+ context.drawImage(bitmap, fit.x, fit.y, fit.width, fit.height);
8472
+ const type = format === "png" ? "image/png" : "image/jpeg";
8473
+ return await encodeBlob(await canvas.convertToBlob(format === "png" ? { type } : {
8474
+ type,
8475
+ quality
8476
+ }), type);
8477
+ } finally {
8478
+ bitmap.close();
8479
+ }
8480
+ }
8481
+ /**
7167
8482
  * Waits one animation frame.
7168
8483
  *
7169
8484
  * @returns A promise that settles in the next frame callback.
@@ -7387,9 +8702,17 @@ var SceneHost = class {
7387
8702
  methods;
7388
8703
  /**
7389
8704
  * The methods the channel runs beside its queue: `renderThumbnail`, which renders on a stage app
7390
- * of its own, never reads the document, and can take a couple of seconds.
7391
- */
7392
- unqueued = /* @__PURE__ */ new Set([RenderViewMethod.renderThumbnail]);
8705
+ * of its own, never reads the document, and can take a couple of seconds; `bakeLightProbes`,
8706
+ * which reads the world in a queue slot of its own and then traces beside the queue; and
8707
+ * `cancelBake`, which must not wait behind the requests a bake lets through.
8708
+ */
8709
+ unqueued = /* @__PURE__ */ new Set([
8710
+ RenderViewMethod.renderThumbnail,
8711
+ LightProbeBakeMethod.bakeLightProbes,
8712
+ LightProbeBakeMethod.cancelBake
8713
+ ]);
8714
+ /** The light-probe bake, with `HostCapability.bakeLightProbes`. */
8715
+ #baker;
7393
8716
  #notify;
7394
8717
  #app = null;
7395
8718
  #mirror = null;
@@ -7462,6 +8785,7 @@ var SceneHost = class {
7462
8785
  if (has(HostCapability.spriteAnimation)) methods.set(SceneMethod.sampleSpriteAnimation, (params) => this.#sampleSpriteAnimation(params));
7463
8786
  if (has(HostCapability.gizmos)) methods.set(SceneMethod.setGizmo, (params) => this.#setGizmo(params));
7464
8787
  if (has(HostCapability.screenshot)) methods.set(SceneMethod.screenshot, async (params) => this.#screenshot(params));
8788
+ if (has(HostCapability.pickRect)) methods.set(SceneMethod.pickRect, (params) => this.#pickRect(params));
7465
8789
  if (has(HostCapability.gameView)) {
7466
8790
  methods.set(RenderViewMethod.setGameView, (params) => {
7467
8791
  this.#requireMirror(RenderViewMethod.setGameView);
@@ -7474,19 +8798,43 @@ var SceneHost = class {
7474
8798
  });
7475
8799
  }
7476
8800
  const createThumbnailApp = options.createThumbnailApp;
7477
- this.#thumbnails = has(HostCapability.thumbnails) && createThumbnailApp !== void 0 ? new ThumbnailRenderer(createThumbnailApp) : null;
8801
+ this.#thumbnails = has(HostCapability.thumbnails) && createThumbnailApp !== void 0 ? new ThumbnailRenderer(createThumbnailApp, (address) => this.#requireApp().assets.resolveUrl(address), options.fetchAsset ?? (async (input, init) => fetch(input, init))) : null;
7478
8802
  const thumbnails = this.#thumbnails;
7479
8803
  if (thumbnails !== null) methods.set(RenderViewMethod.renderThumbnail, async (params) => {
7480
8804
  this.#requireMirror(RenderViewMethod.renderThumbnail);
7481
8805
  return thumbnails.render(params);
7482
8806
  });
7483
8807
  if (has(HostCapability.grid)) methods.set(SceneMethod.setGrid, (params) => this.#setGrid(params));
8808
+ this.#baker = has(HostCapability.bakeLightProbes) ? new LightProbeBaker(options.notify) : null;
8809
+ const baker = this.#baker;
8810
+ if (baker !== null) {
8811
+ methods.set(LightProbeBakeMethod.bakeLightProbes, async (params) => {
8812
+ const mirror = this.#requireMirror(LightProbeBakeMethod.bakeLightProbes);
8813
+ const app = this.#requireApp();
8814
+ const pending = baker.reserve();
8815
+ return (await this.#serial(() => ({ bake: baker.start(app, mirror.scene, params, pending) }))).bake.finished;
8816
+ });
8817
+ methods.set(LightProbeBakeMethod.cancelBake, (params) => {
8818
+ this.#requireMirror(LightProbeBakeMethod.cancelBake);
8819
+ if (!isCancelBakeParams(params)) throw new InvalidParamsError("cancelBake takes {} or no parameters.");
8820
+ return { cancelled: baker.cancel(BakeCancelCause.cancelBake) };
8821
+ });
8822
+ }
7484
8823
  if (has(HostCapability.tilemapCells)) methods.set(SceneMethod.setTilemapCells, (params) => this.#setTilemapCells(params));
7485
8824
  if (has(HostCapability.editorLines)) {
7486
8825
  methods.set(SceneMethod.setEditorLines, (params) => this.#setEditorLines(params));
7487
8826
  methods.set(SceneMethod.clearEditorLines, (params) => this.#clearEditorLines(params));
7488
8827
  }
7489
- this.methods = new Map([...methods].map(([name, handler]) => [name, this.unqueued.has(name) ? handler : async (params) => this.#serial(() => handler(params))]));
8828
+ const changesDocument = /* @__PURE__ */ new Set([
8829
+ SceneMethod.openScene,
8830
+ SceneMethod.closeScene,
8831
+ SceneMethod.applyOps,
8832
+ SceneMethod.setTilemapCells
8833
+ ]);
8834
+ this.methods = new Map([...methods].map(([name, handler]) => [name, this.unqueued.has(name) ? handler : async (params) => this.#serial(() => {
8835
+ if (changesDocument.has(name)) this.#sceneChanged();
8836
+ return handler(params);
8837
+ })]));
7490
8838
  }
7491
8839
  /**
7492
8840
  * The persistent scene instance that holds the host's own objects, such as the editor camera.
@@ -7632,6 +8980,7 @@ var SceneHost = class {
7632
8980
  return this.#serial(async () => {
7633
8981
  const index = handle.type === "scene" ? mirror.index() : null;
7634
8982
  const roots = index === null ? [] : instancesOf(app, index, address);
8983
+ if (roots.length > 0) this.#sceneChanged();
7635
8984
  const entities = await this.#rebuildInstances(app, mirror, roots, address, { address });
7636
8985
  this.#setSelection(this.#selection);
7637
8986
  const params = {
@@ -7685,6 +9034,7 @@ var SceneHost = class {
7685
9034
  const mirror = this.#mirror;
7686
9035
  const index = mirror?.index() ?? null;
7687
9036
  if (app === null || mirror === null || index === null) return;
9037
+ this.#sceneChanged();
7688
9038
  applyDefaults(app, mirror, index, changed, (component, typeId, error) => {
7689
9039
  const params = {
7690
9040
  code: isIgnifxError(error) ? error.code : null,
@@ -7721,6 +9071,11 @@ var SceneHost = class {
7721
9071
  this.#view = null;
7722
9072
  this.#gameView.dispose();
7723
9073
  this.#thumbnails?.dispose();
9074
+ this.#baker?.dispose();
9075
+ }
9076
+ /** Cancels a running bake: the document is about to change. */
9077
+ #sceneChanged() {
9078
+ this.#baker?.cancel(BakeCancelCause.sceneChanged);
7724
9079
  }
7725
9080
  /**
7726
9081
  * `openScene`: replaces the open document with the editor's file.
@@ -7871,6 +9226,85 @@ var SceneHost = class {
7871
9226
  return this.#pickAt(params);
7872
9227
  }
7873
9228
  /**
9229
+ * `pickRect`: which document entities a rectangle of the view covers. Changes nothing.
9230
+ *
9231
+ * @param params - `{ x0, y0, x1, y1, unit, mode? }`.
9232
+ * @returns The entities in document order, capped, and whether the cap cut the list.
9233
+ */
9234
+ #pickRect(params) {
9235
+ const mirror = this.#requireMirror(SceneMethod.pickRect);
9236
+ if (!isPickRectParams(params)) throw new InvalidParamsError("pickRect takes { x0, y0, x1, y1, unit: \"css\" | \"backing\", mode?: \"intersect\" | \"contain\" }.");
9237
+ const none = {
9238
+ entities: [],
9239
+ truncated: false
9240
+ };
9241
+ const canvas = this.#canvas;
9242
+ const index = mirror.index();
9243
+ const scene = mirror.scene;
9244
+ if (canvas === null || index === null || scene === null) return none;
9245
+ const rect = rectInBackingPixels(params, viewSurfaceOf(canvas));
9246
+ if (rect === null) return none;
9247
+ const boxes = this.#projectedBoxes(index.entities, scene, canvas.width, canvas.height);
9248
+ const mode = params.mode ?? PickRectMode.intersect;
9249
+ const entities = [];
9250
+ let truncated = false;
9251
+ for (const uid of index.entities.keys()) {
9252
+ const box = boxes.get(uid);
9253
+ if (box === void 0 || !rectMatches(box, rect, mode)) continue;
9254
+ if (entities.length === 2e3) {
9255
+ truncated = true;
9256
+ break;
9257
+ }
9258
+ entities.push(uid);
9259
+ }
9260
+ return {
9261
+ entities,
9262
+ truncated
9263
+ };
9264
+ }
9265
+ /**
9266
+ * Each document entity's drawn bounds, projected to the view: the meshes under it through the
9267
+ * editor camera (a mesh inside an instance counts for the instance root) and, in 2D view mode,
9268
+ * its sprites and tilemaps through the 2D editor camera. A `"sprite"`-mode 2D project in 2D view
9269
+ * mode projects no meshes, as its pick does not.
9270
+ *
9271
+ * @param entities - The document entities, by uid.
9272
+ * @param scene - The document's scene instance.
9273
+ * @param width - The view's backing-store width.
9274
+ * @param height - The view's backing-store height.
9275
+ * @returns The projected box of each entity that draws something on screen or off it.
9276
+ */
9277
+ #projectedBoxes(entities, scene, width, height) {
9278
+ const app = this.#requireApp();
9279
+ const boxes = /* @__PURE__ */ new Map();
9280
+ const camera2D = this.#viewMode === ViewMode.twoD ? this.#camera2D : null;
9281
+ if (camera2D !== null) {
9282
+ const view = camera2D.view();
9283
+ for (const { entity, box } of drawnBoxes2D(app, scene)) {
9284
+ const uid = this.#mirror?.documentEntityOf(entity)?.uid;
9285
+ if (uid !== void 0) {
9286
+ const projected = {
9287
+ rect: projectBox2D(view, box),
9288
+ clipped: false
9289
+ };
9290
+ boxes.set(uid, unionProjected(boxes.get(uid), projected));
9291
+ }
9292
+ }
9293
+ if (twoDServiceOf(app)?.mode === "sprite") return boxes;
9294
+ }
9295
+ const eye = this.#eye;
9296
+ if (eye === null) return boxes;
9297
+ const viewMatrix = eye.getViewMatrix(new Mat4()).elements;
9298
+ const projection = eye.getProjectionMatrix(new Mat4()).elements;
9299
+ const owners = /* @__PURE__ */ new Map();
9300
+ for (const [uid, entity] of entities) if (!entity.isDestroyed) owners.set(entity.transform.lite, uid);
9301
+ for (const mesh of drawnMeshes(app.lite, owners)) {
9302
+ const projected = projectBox(mesh, mesh.world, viewMatrix, projection, width, height);
9303
+ if (projected !== null) boxes.set(mesh.owner, unionProjected(boxes.get(mesh.owner), projected));
9304
+ }
9305
+ return boxes;
9306
+ }
9307
+ /**
7874
9308
  * `screenshot`: the view as an image, without the gizmo and the outline.
7875
9309
  *
7876
9310
  * @param params - `{ width?, height?, format, quality? }`.
@@ -8466,23 +9900,31 @@ async function startEditorHost(options) {
8466
9900
  HostCapability.screenshot,
8467
9901
  HostCapability.viewMode2d,
8468
9902
  HostCapability.pick2d,
9903
+ HostCapability.pickRect,
8469
9904
  HostCapability.logRelay,
8470
9905
  HostCapability.hotReloadDefaults,
8471
9906
  HostCapability.gameView,
8472
9907
  HostCapability.gameViewOnDemand,
8473
9908
  HostCapability.gameViewSize,
8474
9909
  HostCapability.gameView2d,
8475
- ...canRenderThumbnails(options) ? [HostCapability.thumbnails] : [],
9910
+ ...canRenderThumbnails(options) ? [
9911
+ HostCapability.thumbnails,
9912
+ HostCapability.thumbnailMaterials,
9913
+ HostCapability.thumbnailAtlases,
9914
+ HostCapability.thumbnailTextures
9915
+ ] : [],
8476
9916
  HostCapability.grid,
8477
9917
  HostCapability.gridOverlay,
8478
9918
  HostCapability.tilemapCells,
8479
9919
  HostCapability.editorLines,
8480
- HostCapability.spriteAnimation
9920
+ HostCapability.spriteAnimation,
9921
+ HostCapability.bakeLightProbes
8481
9922
  ] : [
8482
9923
  HostCapability.heartbeat,
8483
9924
  HostCapability.logRelay,
8484
9925
  HostCapability.hotReloadDefaults,
8485
- HostCapability.spriteAnimation
9926
+ HostCapability.spriteAnimation,
9927
+ HostCapability.bakeLightProbes
8486
9928
  ];
8487
9929
  let channel = null;
8488
9930
  const scene = new SceneHost({
@@ -8490,7 +9932,8 @@ async function startEditorHost(options) {
8490
9932
  notify: (method, params) => {
8491
9933
  channel?.notify(method, params);
8492
9934
  },
8493
- createThumbnailApp: async () => createThumbnailApp(options)
9935
+ createThumbnailApp: async () => createThumbnailApp(options),
9936
+ ...options.assets?.fetch === void 0 ? {} : { fetchAsset: options.assets.fetch }
8494
9937
  });
8495
9938
  const opened = openChannel({
8496
9939
  target: resolveMessageTarget(options.messageTarget),
@@ -9313,6 +10756,6 @@ function listenForEditorPlayControls(options) {
9313
10756
  };
9314
10757
  }
9315
10758
  //#endregion
9316
- export { ApplyOpFailureCode, COLLIDER_OUTLINES_MAX_ENTITIES, COLLIDER_OUTLINES_MAX_NUMBERS, DEFAULT_HEARTBEAT_INTERVAL_MS, EDITOR_CONNECT_MESSAGE_TYPE, EDITOR_LINES_MAX_ID_LENGTH, EDITOR_LINES_MAX_NUMBERS, EDITOR_LINES_MAX_SETS, EditorHostErrorCode, GAME_VIEW_DEFAULT_SIZE, GAME_VIEW_MAX_SIZE, GRID_MAX_HEIGHT, GRID_MAX_SIZE, GRID_MIN_SIZE, GizmoMode, GizmoSpace, HOST_LIST_MAX_LENGTH, HOST_TEXT_MAX_LENGTH, HandshakeMethod, HostCapability, HostKind, HostNotification, JSON_RPC_VERSION, PROTOCOL_VERSION, PickUnit, PlayMethod, PlayNotification, PlayPhase, QUERY_RUNTIME_MAX_COMPONENTS, QUERY_RUNTIME_MAX_JSON_LENGTH, QUERY_RUNTIME_MAX_KEYS, QUERY_RUNTIME_MAX_STRING_LENGTH, RenderViewMethod, RpcErrorCode, SAMPLE_ANIMATION_MAX_NAME_LENGTH, SAMPLE_ANIMATION_MAX_PARAMETERS, SCREENSHOT_MAX_SIZE, SEND_INPUT_MAX_EVENTS, SceneMethod, SceneNotification, SceneOpKind, ScreenshotFormat, THUMBNAIL_DEFAULT_SIZE, THUMBNAIL_MAX_SIZE, TILEMAP_CELLS_MAX_NUMBERS, TRANSFORM_DRAGGING_INTERVAL_MS, ViewMode, isAppErrorData, isApplyOpsParams, isApplyOpsResult, isAssetReloadedParams, isClearEditorLinesParams, isColliderOutlineRecord, isColliderOutlineSet, isEditorConnectMessage, isEditorOrigin, isEntitySelection, isFrameParams, isGameViewFrameParams, isGameViewFrameResult, isGameViewState, isHostErrorParams, isHotReloadedParams, isIncompatibleProtocolData, isInvalidSceneFileData, isJsonObject, isJsonValue, isLogParams, isOpenSceneParams, isOpenSceneResult, isPickParams, isPickResult, isPlayState, isPlayStateReport, isPlayStats, isProtocolVersion, isQueryRuntimeParams, isQueryRuntimeResult, isReadBackParams, isReadBackResult, isReadyResult, isRenderThumbnailParams, isRpcMessage, isSampleAnimationParams, isSampleAnimationResult, isSampleSpriteAnimationParams, isSampleSpriteAnimationResult, isSceneFile, isSceneFileAssetRef, isSceneFileComponent, isSceneFileEntity, isSceneFileInstance, isSceneFileOverride, isSceneFileTransform, isSceneIssue, isSceneOp, isSceneOpenedParams, isSchemaSet, isScreenshotParams, isScreenshotResult, isSendInputEvent, isSendInputParams, isSendInputResult, isSetAnimateMaterialsParams, isSetEditorLinesParams, isSetGameViewParams, isSetGizmoParams, isSetGridParams, isSetTilemapCellsParams, isSetTilemapCellsResult, isSetViewModeParams, isSettingsSet, isThumbnailResult, isTransformDraggedParams, isTransformDraggingParams, listenForEditorPlayControls, protocolVersionIsCompatible, startEditorHost, startEditorPlayControls };
10759
+ export { ApplyOpFailureCode, BAKE_COEFFICIENT_DIGITS, BAKE_DEFAULT_SPACING, BAKE_MAX_COEFFICIENT, BAKE_MAX_COUNT_X, BAKE_MAX_COUNT_YZ, BAKE_MAX_PROBES, BAKE_MAX_RAYS, BAKE_MAX_SKIPS, BAKE_MAX_SKY, BAKE_MAX_UID_LENGTH, BAKE_PROGRESS_INTERVAL_MS, BAKE_SPACING_MAX, BAKE_SPACING_MIN, BakeCancelCause, BakeFailureReason, COLLIDER_OUTLINES_MAX_ENTITIES, COLLIDER_OUTLINES_MAX_NUMBERS, DEFAULT_HEARTBEAT_INTERVAL_MS, EDITOR_CONNECT_MESSAGE_TYPE, EDITOR_LINES_MAX_ID_LENGTH, EDITOR_LINES_MAX_NUMBERS, EDITOR_LINES_MAX_SETS, EditorHostErrorCode, GAME_VIEW_DEFAULT_SIZE, GAME_VIEW_MAX_SIZE, GRID_MAX_HEIGHT, GRID_MAX_SIZE, GRID_MIN_SIZE, GizmoMode, GizmoSpace, HOST_LIST_MAX_LENGTH, HOST_TEXT_MAX_LENGTH, HandshakeMethod, HostCapability, HostKind, HostNotification, JSON_RPC_VERSION, LightProbeBakeMethod, LightProbeBakeNotification, PICK_RECT_MAX_ENTITIES, PROTOCOL_VERSION, PickRectMode, PickUnit, PlayMethod, PlayNotification, PlayPhase, QUERY_RUNTIME_MAX_COMPONENTS, QUERY_RUNTIME_MAX_JSON_LENGTH, QUERY_RUNTIME_MAX_KEYS, QUERY_RUNTIME_MAX_STRING_LENGTH, RenderViewMethod, RpcErrorCode, SAMPLE_ANIMATION_MAX_NAME_LENGTH, SAMPLE_ANIMATION_MAX_PARAMETERS, SCREENSHOT_MAX_SIZE, SEND_INPUT_MAX_EVENTS, SceneMethod, SceneNotification, SceneOpKind, ScreenshotFormat, THUMBNAIL_DEFAULT_SIZE, THUMBNAIL_MAX_SIZE, TILEMAP_CELLS_MAX_NUMBERS, TRANSFORM_DRAGGING_INTERVAL_MS, ViewMode, isAppErrorData, isApplyOpsParams, isApplyOpsResult, isAssetReloadedParams, isBakeFailureData, isBakeLightProbesParams, isBakeLightProbesResult, isBakeProgressParams, isBakeSky, isCancelBakeParams, isCancelBakeResult, isClearEditorLinesParams, isColliderOutlineRecord, isColliderOutlineSet, isEditorConnectMessage, isEditorOrigin, isEntitySelection, isFrameParams, isGameViewFrameParams, isGameViewFrameResult, isGameViewState, isHostErrorParams, isHotReloadedParams, isIncompatibleProtocolData, isInvalidSceneFileData, isJsonObject, isJsonValue, isLogParams, isOpenSceneParams, isOpenSceneResult, isPickParams, isPickRectParams, isPickRectResult, isPickResult, isPlayState, isPlayStateReport, isPlayStats, isProtocolVersion, isQueryRuntimeParams, isQueryRuntimeResult, isReadBackParams, isReadBackResult, isReadyResult, isRenderThumbnailParams, isRpcMessage, isSampleAnimationParams, isSampleAnimationResult, isSampleSpriteAnimationParams, isSampleSpriteAnimationResult, isSceneFile, isSceneFileAssetRef, isSceneFileComponent, isSceneFileEntity, isSceneFileInstance, isSceneFileOverride, isSceneFileTransform, isSceneIssue, isSceneOp, isSceneOpenedParams, isSchemaSet, isScreenshotParams, isScreenshotResult, isSendInputEvent, isSendInputParams, isSendInputResult, isSetAnimateMaterialsParams, isSetEditorLinesParams, isSetGameViewParams, isSetGizmoParams, isSetGridParams, isSetTilemapCellsParams, isSetTilemapCellsResult, isSetViewModeParams, isSettingsSet, isThumbnailResult, isTransformDraggedParams, isTransformDraggingParams, listenForEditorPlayControls, protocolVersionIsCompatible, startEditorHost, startEditorPlayControls };
9317
10760
 
9318
10761
  //# sourceMappingURL=index.js.map