@ignifx/editor-host 0.15.0 → 0.17.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.
@@ -0,0 +1,132 @@
1
+ import { createSpriteRenderer, createSurface, disposeSpriteRenderer, disposeSurface, registerSpriteRenderer, renderFrame } from "@babylonjs/lite";
2
+ //#region src/lite/sprite-game-view.ts
3
+ /**
4
+ * The Game panel's view of a 2D scene (`gameViewFrame` through a `Camera2D`): the project's sprite
5
+ * layers drawn by a second Lite sprite renderer into an `OffscreenCanvas` surface of the view's
6
+ * size, each world layer through the level camera's view for that one render. Every Lite claim
7
+ * here was read from the pinned `@babylonjs/lite` 1.34 `index.d.ts` and `lib/sprite/sprite-renderer.js`.
8
+ *
9
+ * - **Why a surface, not a render texture.** A sprite renderer sizes its layers' uniforms from its
10
+ * surface's canvas (`spriteRendererUpdate` reads `getRenderTargetSize(rr._surface)`), so a target
11
+ * redirected with `setSpriteRendererTarget` must be the main canvas's size. A surface of its own
12
+ * (`createSurface` on an `OffscreenCanvas`) has the view's size.
13
+ * - **Built per request.** Each request creates the surface and the renderer, renders that one
14
+ * surface (`renderFrame(engine, 0, [surface])`, which runs no scene and so no ignifx frame), reads
15
+ * it back, and disposes both. A live surface stays in `engine.surfaces`, where every main frame
16
+ * would acquire its texture, and a live renderer keeps its layers' GPU buffers; neither outlives
17
+ * the request. Pipelines are not rebuilt: Lite's sprite pipeline cache is shared by every renderer
18
+ * on the device (`acquireSharedSpriteRendererPipelineCache`, `lib/sprite/sprite-renderer.js`).
19
+ * - **The views are swapped, not copied.** A layer has one `view`, which the main sprite pass reads
20
+ * too. The render is synchronous, so writing the camera's views, rendering and writing the old
21
+ * ones back happens inside one task and the main pass never sees them.
22
+ * - **Read back by the canvas.** `OffscreenCanvas.convertToBlob` copies the canvas's current
23
+ * WebGPU texture after the work already submitted, which is the WebGPU readback path for a canvas.
24
+ *
25
+ * The host loads this module with `import()` the first time a 2D scene's game view renders, so it
26
+ * stays out of the host's first chunk (`CONSTITUTION.md` §2.5).
27
+ */
28
+ /**
29
+ * Tells whether a value is a Lite sprite layer: an object with a `view` holding a `positionPx`.
30
+ *
31
+ * @param value - The value.
32
+ * @returns True for a layer.
33
+ */
34
+ function isSpriteLayer(value) {
35
+ const view = Reflect.get(value, "view");
36
+ return typeof view === "object" && view !== null && Array.isArray(Reflect.get(view, "positionPx"));
37
+ }
38
+ /**
39
+ * Decodes an sRGB channel to linear, for a surface that encodes on write.
40
+ *
41
+ * @param channel - The sRGB value.
42
+ * @returns The linear value.
43
+ */
44
+ function srgbToLinear(channel) {
45
+ return channel <= .04045 ? channel / 12.92 : ((channel + .055) / 1.055) ** 2.4;
46
+ }
47
+ /**
48
+ * Draws sprite layers through their views into an image of a size, on a surface and a renderer
49
+ * that exist only for this call.
50
+ *
51
+ * @param engine - The app's Lite engine (`app.lite.engine`).
52
+ * @param draws - The layers, in draw order, and their views.
53
+ * @param size - The image size and the colour it is cleared to.
54
+ * @param size.width - The image width in pixels.
55
+ * @param size.height - The image height in pixels.
56
+ * @param size.clear - The clear colour, as the project's `rendering.clearColor` reads now.
57
+ * @param type - `"image/png"` or `"image/jpeg"`.
58
+ * @param quality - The JPEG quality, from 0 to 1.
59
+ * @returns The encoded image.
60
+ */
61
+ async function renderSpriteGameView(engine, draws, size, type, quality) {
62
+ const { width, height, clear } = size;
63
+ const layers = [];
64
+ const views = [];
65
+ for (const draw of draws) if (isSpriteLayer(draw.layer)) {
66
+ layers.push(draw.layer);
67
+ views.push(draw);
68
+ }
69
+ const canvas = new OffscreenCanvas(width, height);
70
+ const srgb = engine.format.endsWith("-srgb");
71
+ const surface = createSurface(engine, canvas, {
72
+ msaaSamples: 1,
73
+ srgb
74
+ });
75
+ const decode = (channel) => srgb ? srgbToLinear(channel) : channel;
76
+ try {
77
+ const renderer = createSpriteRenderer(surface, {
78
+ layers,
79
+ clear: true,
80
+ clearValue: {
81
+ r: decode(clear.r),
82
+ g: decode(clear.g),
83
+ b: decode(clear.b),
84
+ a: clear.a
85
+ }
86
+ });
87
+ try {
88
+ const saved = [];
89
+ for (const [index, layer] of layers.entries()) {
90
+ const draw = views[index];
91
+ const view = layer.view;
92
+ saved.push({
93
+ positionPx: [view.positionPx[0], view.positionPx[1]],
94
+ zoom: view.zoom,
95
+ rotation: view.rotation
96
+ });
97
+ if (draw !== void 0) {
98
+ view.positionPx[0] = draw.x;
99
+ view.positionPx[1] = draw.y;
100
+ view.zoom = draw.zoom === 0 ? 1 : draw.zoom;
101
+ view.rotation = draw.rotation;
102
+ }
103
+ }
104
+ registerSpriteRenderer(renderer);
105
+ try {
106
+ renderFrame(engine, 0, [surface]);
107
+ } finally {
108
+ for (const [index, layer] of layers.entries()) {
109
+ const old = saved[index];
110
+ if (old !== void 0) {
111
+ layer.view.positionPx[0] = old.positionPx[0];
112
+ layer.view.positionPx[1] = old.positionPx[1];
113
+ layer.view.zoom = old.zoom;
114
+ layer.view.rotation = old.rotation;
115
+ }
116
+ }
117
+ }
118
+ return await canvas.convertToBlob(type === "image/png" ? { type } : {
119
+ type,
120
+ quality
121
+ });
122
+ } finally {
123
+ disposeSpriteRenderer(renderer);
124
+ }
125
+ } finally {
126
+ disposeSurface(surface);
127
+ }
128
+ }
129
+ //#endregion
130
+ export { renderSpriteGameView };
131
+
132
+ //# sourceMappingURL=sprite-game-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sprite-game-view.js","names":[],"sources":["../src/lite/sprite-game-view.ts"],"sourcesContent":["/**\n * The Game panel's view of a 2D scene (`gameViewFrame` through a `Camera2D`): the project's sprite\n * layers drawn by a second Lite sprite renderer into an `OffscreenCanvas` surface of the view's\n * size, each world layer through the level camera's view for that one render. Every Lite claim\n * here was read from the pinned `@babylonjs/lite` 1.34 `index.d.ts` and `lib/sprite/sprite-renderer.js`.\n *\n * - **Why a surface, not a render texture.** A sprite renderer sizes its layers' uniforms from its\n * surface's canvas (`spriteRendererUpdate` reads `getRenderTargetSize(rr._surface)`), so a target\n * redirected with `setSpriteRendererTarget` must be the main canvas's size. A surface of its own\n * (`createSurface` on an `OffscreenCanvas`) has the view's size.\n * - **Built per request.** Each request creates the surface and the renderer, renders that one\n * surface (`renderFrame(engine, 0, [surface])`, which runs no scene and so no ignifx frame), reads\n * it back, and disposes both. A live surface stays in `engine.surfaces`, where every main frame\n * would acquire its texture, and a live renderer keeps its layers' GPU buffers; neither outlives\n * the request. Pipelines are not rebuilt: Lite's sprite pipeline cache is shared by every renderer\n * on the device (`acquireSharedSpriteRendererPipelineCache`, `lib/sprite/sprite-renderer.js`).\n * - **The views are swapped, not copied.** A layer has one `view`, which the main sprite pass reads\n * too. The render is synchronous, so writing the camera's views, rendering and writing the old\n * ones back happens inside one task and the main pass never sees them.\n * - **Read back by the canvas.** `OffscreenCanvas.convertToBlob` copies the canvas's current\n * WebGPU texture after the work already submitted, which is the WebGPU readback path for a canvas.\n *\n * The host loads this module with `import()` the first time a 2D scene's game view renders, so it\n * stays out of the host's first chunk (`CONSTITUTION.md` §2.5).\n */\n\nimport {\n createSpriteRenderer,\n createSurface,\n disposeSpriteRenderer,\n disposeSurface,\n registerSpriteRenderer,\n renderFrame,\n} from \"@babylonjs/lite\";\nimport type { EngineContext, Sprite2DLayer, Sprite2DView } from \"@babylonjs/lite\";\n\n/** One layer to draw and the view to draw it through. */\nexport interface SpriteLayerDraw {\n /** A Lite `Sprite2DLayer`, as `app.twoD.layers` holds it. */\n readonly layer: object;\n /** The layer-pixel x at the image's top-left. */\n readonly x: number;\n /** The layer-pixel y at the image's top-left. */\n readonly y: number;\n /** Screen pixels per layer pixel. */\n readonly zoom: number;\n /** The view rotation, in radians. */\n readonly rotation: number;\n}\n\n/** A colour, each channel `0..1`, straight sRGB. */\nexport interface SpriteClearColor {\n /** Red. */\n readonly r: number;\n /** Green. */\n readonly g: number;\n /** Blue. */\n readonly b: number;\n /** Opacity. */\n readonly a: number;\n}\n\n/**\n * Tells whether a value is a Lite sprite layer: an object with a `view` holding a `positionPx`.\n *\n * @param value - The value.\n * @returns True for a layer.\n */\nfunction isSpriteLayer(value: object): value is Sprite2DLayer {\n const view: unknown = Reflect.get(value, \"view\");\n return typeof view === \"object\" && view !== null && Array.isArray(Reflect.get(view, \"positionPx\"));\n}\n\n/**\n * Decodes an sRGB channel to linear, for a surface that encodes on write.\n *\n * @param channel - The sRGB value.\n * @returns The linear value.\n */\nfunction srgbToLinear(channel: number): number {\n return channel <= 0.040_45 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;\n}\n\n/**\n * Draws sprite layers through their views into an image of a size, on a surface and a renderer\n * that exist only for this call.\n *\n * @param engine - The app's Lite engine (`app.lite.engine`).\n * @param draws - The layers, in draw order, and their views.\n * @param size - The image size and the colour it is cleared to.\n * @param size.width - The image width in pixels.\n * @param size.height - The image height in pixels.\n * @param size.clear - The clear colour, as the project's `rendering.clearColor` reads now.\n * @param type - `\"image/png\"` or `\"image/jpeg\"`.\n * @param quality - The JPEG quality, from 0 to 1.\n * @returns The encoded image.\n */\nexport async function renderSpriteGameView(\n engine: EngineContext,\n draws: readonly SpriteLayerDraw[],\n size: { readonly width: number; readonly height: number; readonly clear: SpriteClearColor },\n type: string,\n quality: number,\n): Promise<Blob> {\n const { width, height, clear } = size;\n const layers: Sprite2DLayer[] = [];\n const views: SpriteLayerDraw[] = [];\n for (const draw of draws) {\n if (isSpriteLayer(draw.layer)) {\n layers.push(draw.layer);\n views.push(draw);\n }\n }\n const canvas = new OffscreenCanvas(width, height);\n const srgb = engine.format.endsWith(\"-srgb\");\n const surface = createSurface(engine, canvas, { msaaSamples: 1, srgb });\n const decode = (channel: number): number => (srgb ? srgbToLinear(channel) : channel);\n try {\n const renderer = createSpriteRenderer(surface, {\n layers,\n clear: true,\n clearValue: { r: decode(clear.r), g: decode(clear.g), b: decode(clear.b), a: clear.a },\n });\n try {\n const saved: Sprite2DView[] = [];\n for (const [index, layer] of layers.entries()) {\n const draw = views[index];\n const view = layer.view;\n saved.push({ positionPx: [view.positionPx[0], view.positionPx[1]], zoom: view.zoom, rotation: view.rotation });\n if (draw !== undefined) {\n view.positionPx[0] = draw.x;\n view.positionPx[1] = draw.y;\n view.zoom = draw.zoom === 0 ? 1 : draw.zoom;\n view.rotation = draw.rotation;\n }\n }\n registerSpriteRenderer(renderer);\n try {\n renderFrame(engine, 0, [surface]);\n } finally {\n for (const [index, layer] of layers.entries()) {\n const old = saved[index];\n if (old !== undefined) {\n layer.view.positionPx[0] = old.positionPx[0];\n layer.view.positionPx[1] = old.positionPx[1];\n layer.view.zoom = old.zoom;\n layer.view.rotation = old.rotation;\n }\n }\n }\n // Awaited before the surface goes: the copy reads the work submitted above.\n return await canvas.convertToBlob(type === \"image/png\" ? { type } : { type, quality });\n } finally {\n // Also unregisters it from the surface.\n disposeSpriteRenderer(renderer);\n }\n } finally {\n disposeSurface(surface);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,SAAS,cAAc,OAAuC;CAC5D,MAAM,OAAgB,QAAQ,IAAI,OAAO,MAAM;CAC/C,OAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,QAAQ,IAAI,MAAM,YAAY,CAAC;AACnG;;;;;;;AAQA,SAAS,aAAa,SAAyB;CAC7C,OAAO,WAAW,SAAW,UAAU,UAAU,UAAU,QAAS,UAAU;AAChF;;;;;;;;;;;;;;;AAgBA,eAAsB,qBACpB,QACA,OACA,MACA,MACA,SACe;CACf,MAAM,EAAE,OAAO,QAAQ,UAAU;CACjC,MAAM,SAA0B,CAAC;CACjC,MAAM,QAA2B,CAAC;CAClC,KAAK,MAAM,QAAQ,OACjB,IAAI,cAAc,KAAK,KAAK,GAAG;EAC7B,OAAO,KAAK,KAAK,KAAK;EACtB,MAAM,KAAK,IAAI;CACjB;CAEF,MAAM,SAAS,IAAI,gBAAgB,OAAO,MAAM;CAChD,MAAM,OAAO,OAAO,OAAO,SAAS,OAAO;CAC3C,MAAM,UAAU,cAAc,QAAQ,QAAQ;EAAE,aAAa;EAAG;CAAK,CAAC;CACtE,MAAM,UAAU,YAA6B,OAAO,aAAa,OAAO,IAAI;CAC5E,IAAI;EACF,MAAM,WAAW,qBAAqB,SAAS;GAC7C;GACA,OAAO;GACP,YAAY;IAAE,GAAG,OAAO,MAAM,CAAC;IAAG,GAAG,OAAO,MAAM,CAAC;IAAG,GAAG,OAAO,MAAM,CAAC;IAAG,GAAG,MAAM;GAAE;EACvF,CAAC;EACD,IAAI;GACF,MAAM,QAAwB,CAAC;GAC/B,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,GAAG;IAC7C,MAAM,OAAO,MAAM;IACnB,MAAM,OAAO,MAAM;IACnB,MAAM,KAAK;KAAE,YAAY,CAAC,KAAK,WAAW,IAAI,KAAK,WAAW,EAAE;KAAG,MAAM,KAAK;KAAM,UAAU,KAAK;IAAS,CAAC;IAC7G,IAAI,SAAS,KAAA,GAAW;KACtB,KAAK,WAAW,KAAK,KAAK;KAC1B,KAAK,WAAW,KAAK,KAAK;KAC1B,KAAK,OAAO,KAAK,SAAS,IAAI,IAAI,KAAK;KACvC,KAAK,WAAW,KAAK;IACvB;GACF;GACA,uBAAuB,QAAQ;GAC/B,IAAI;IACF,YAAY,QAAQ,GAAG,CAAC,OAAO,CAAC;GAClC,UAAU;IACR,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,GAAG;KAC7C,MAAM,MAAM,MAAM;KAClB,IAAI,QAAQ,KAAA,GAAW;MACrB,MAAM,KAAK,WAAW,KAAK,IAAI,WAAW;MAC1C,MAAM,KAAK,WAAW,KAAK,IAAI,WAAW;MAC1C,MAAM,KAAK,OAAO,IAAI;MACtB,MAAM,KAAK,WAAW,IAAI;KAC5B;IACF;GACF;GAEA,OAAO,MAAM,OAAO,cAAc,SAAS,cAAc,EAAE,KAAK,IAAI;IAAE;IAAM;GAAQ,CAAC;EACvF,UAAU;GAER,sBAAsB,QAAQ;EAChC;CACF,UAAU;EACR,eAAe,OAAO;CACxB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ignifx/editor-host",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "ignifx editor host: runs a project's own engine inside the ignifx editor's scene view and play view, over a versioned protocol.",
5
5
  "keywords": [
6
6
  "ignifx"
@@ -52,19 +52,19 @@
52
52
  "typescript-native": "npm:typescript@7.0.2",
53
53
  "vite": "^8.2.2",
54
54
  "vitest": "^5.0.0",
55
- "@ignifx/2d": "0.15.0",
56
- "@ignifx/3d": "0.15.0",
57
- "@ignifx/core": "0.15.0",
58
- "@ignifx/input": "0.15.0",
59
- "@ignifx/physics": "0.15.0",
60
- "@ignifx/physics-2d": "0.15.0",
61
- "@ignifx/vite-plugin": "0.15.0"
55
+ "@ignifx/2d": "0.17.0",
56
+ "@ignifx/3d": "0.17.0",
57
+ "@ignifx/core": "0.17.0",
58
+ "@ignifx/input": "0.17.0",
59
+ "@ignifx/physics": "0.17.0",
60
+ "@ignifx/physics-2d": "0.17.0",
61
+ "@ignifx/vite-plugin": "0.17.0"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@babylonjs/lite": "1.34.0",
65
65
  "vite": "^8.2.2",
66
- "@ignifx/core": "0.15.0",
67
- "@ignifx/vite-plugin": "0.15.0"
66
+ "@ignifx/core": "0.17.0",
67
+ "@ignifx/vite-plugin": "0.17.0"
68
68
  },
69
69
  "peerDependenciesMeta": {
70
70
  "@ignifx/vite-plugin": {
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: editor-host
3
- description: Connects an ignifx project to the ignifx editor with @ignifx/editor-host: the Vite plugin that serves the editor's scene view from the project's own dev server, the virtual:ignifx/editor play controls a game's main.ts hands its app to (play, pause, step, stop, playState, playStateChanged, playStats, screenshot, queryRuntime, sendInput), and the host half of the editor protocol 0.3 over a MessagePort (hello/ready, heartbeat, and the scene document methods openScene, applyOps, readBack, select, pick, frame, setGizmo, setViewMode, screenshot, getSchemas, describeSettings, setAnimateMaterials, getColliderOutlines, sampleAnimation), including the 2D view mode. Use when wiring a project or template for the editor, when the user mentions @ignifx/editor-host, editorHostPlugin, attachEditorPlayControls, virtual:ignifx/editor, startEditorHost or /__ignifx_editor__/, or when debugging why the editor cannot connect to a view or why the scene view disagrees with the editor's document.
3
+ description: Connects an ignifx project to the ignifx editor with @ignifx/editor-host: the Vite plugin that serves the editor's scene view from the project's own dev server, the virtual:ignifx/editor play controls a game's main.ts hands its app to (play, pause, step, stop, playState, playStateChanged, playStats, screenshot, queryRuntime, sendInput), and the host half of the editor protocol 0.3 over a MessagePort (hello/ready, heartbeat, and the scene document methods openScene, applyOps, readBack, select, pick, frame, setGizmo, setViewMode, screenshot, getSchemas, describeSettings, setAnimateMaterials, getColliderOutlines, sampleAnimation, sampleSpriteAnimation), including the 2D view mode. Use when wiring a project or template for the editor, when the user mentions @ignifx/editor-host, editorHostPlugin, attachEditorPlayControls, virtual:ignifx/editor, startEditorHost or /__ignifx_editor__/, or when debugging why the editor cannot connect to a view or why the scene view disagrees with the editor's document.
4
4
  license: Apache-2.0
5
5
  metadata:
6
- ignifx-version: "0.15.0"
6
+ ignifx-version: "0.17.0"
7
7
  ---
8
8
 
9
9
  # @ignifx/editor-host
@@ -25,7 +25,7 @@ editor's, even though its name starts with `editor-`.
25
25
 
26
26
  ## Environment
27
27
 
28
- - Engine: ignifx `0.15.0`; this package targets `@ignifx/core` `>=0.0.0 <1.0.0`.
28
+ - Engine: ignifx `0.17.0`; this package targets `@ignifx/core` `>=0.0.0 <1.0.0`.
29
29
  - Peers: `@ignifx/core` and `@babylonjs/lite` (the scene view's gizmos); for the `./vite` entry,
30
30
  `@ignifx/vite-plugin` and `vite`.
31
31
  - A development dependency of the project, at the same version as its `@ignifx/core`.
@@ -68,7 +68,9 @@ each view ◀── MessagePort ──▶ editor JSON-RPC 2.0, protocol 0.3
68
68
  connect (window message, origin-checked) → hello → ready → ping/pong, heartbeat
69
69
  scene view: schemasChanged → openScene → applyOps… / readBack / select / pick / frame / setGizmo / screenshot
70
70
  / setViewMode / getSchemas / describeSettings (on request only)
71
- / setAnimateMaterials / getColliderOutlines / sampleAnimation / setGrid (with a canvas)
71
+ / setAnimateMaterials / getColliderOutlines / sampleAnimation / sampleSpriteAnimation
72
+ / setGrid / setTilemapCells
73
+ / setEditorLines / clearEditorLines (with a canvas)
72
74
  ← sceneOpened, selectionChanged, transformDragging/Dragged, hotReloaded, assetReloaded,
73
75
  hostError, log
74
76
  play view: play / pause / step / stop / playState / playStats / screenshot (with a canvas)
@@ -154,6 +156,7 @@ host.dispose();
154
156
  | `PlayStats`, `isPlayStats` | `playStats`'s `{ fps, frameTimeMs, entityCount, frameCount }`: the newest second of `app.diagnostics` frames, the world's entities |
155
157
  | `HostCapability.hotReloadDefaults` | The scene view gives fields the document leaves out their new default after a script's hot reload |
156
158
  | `RenderViewMethod`, `HostCapability.gameView`, `.thumbnails` | `setGameView`/`gameViewFrame`: the document's own camera as an image; `renderThumbnail`: a model or prefab rendered alone |
159
+ | `HostCapability.gameViewOnDemand`, `.gameViewSize`, `.gameView2d` | `gameViewFrame` answers while the host is hidden, takes `width`/`height`, and renders a `Camera2D` scene's sprites |
157
160
  | `HostCapability.logRelay`, `isAppErrorData`, `LoggedError` | Both views relay `log` (with the first `Error` a line carries), `hostError` (entity, component, phase, stack) and `hotReloaded` |
158
161
  | `HOST_TEXT_MAX_LENGTH`, `HOST_LIST_MAX_LENGTH` | The editor's caps on a report's strings (1 MiB) and lists (4096); both views clip to them, a string ending `… [clipped]` |
159
162
  | `EditorHostErrorCode` | `IGX-1801` bad origin, `IGX-1802` no window, `IGX-1803` bad option |
@@ -369,6 +372,13 @@ object `openScene` sends, through `world.loadSceneFile`; `readBack` answers with
369
372
  entity without an `Animator`, or an engine refusal such as an unknown state (`data.code`
370
373
  `IGX-1202`), is `invalidParams`. The host finds `ignifx/Animator` by type id, so a project
371
374
  without `@ignifx/3d` simply has none.
375
+ - **A sprite frame on demand.** Every scene host lists the `spriteAnimation` capability and answers
376
+ `sampleSpriteAnimation { entity, clip, frame }` or `{ entity, clip, time }` (exactly one of the
377
+ two; `time` in seconds) with `{ posed }`: it calls `SpriteAnimator.sample(clip, frame)` or
378
+ `sampleTime(clip, time)` from `@ignifx/2d`, which writes the frame onto the entity's
379
+ `SpriteRenderer` and stops playback there. `posed` is `false` while the animation document or the
380
+ atlas loads. An entity without a `SpriteAnimator`, or an unknown clip (`data.code` `IGX-1108`), is
381
+ `invalidParams`. The host finds `ignifx/SpriteAnimator` by type id, as it does the `Animator`.
372
382
  - **Settings over the protocol.** `describeSettings` answers `{ sections, values }`: core's
373
383
  `describeSettings(app)` with each section's `settingsJsonSchema` entry as `propsSchema`, and the
374
384
  values the app resolved, in the settings form (`{ x, y, z }`, `{ r, g, b, a }`). No notification
@@ -387,6 +397,17 @@ object `openScene` sends, through `world.loadSceneFile`; `readBack` answers with
387
397
  its default (`visible: true`, `size: 1` metre, 0.001 to 1000). The grid starts visible at every
388
398
  load, so re-send the editor's state after `ready`. It is never picked or saved, and never in the
389
399
  play view; `screenshot` includes it while it is visible.
400
+ - **Live tilemap painting.** With a canvas the scene host lists `tilemapCells` and answers
401
+ `setTilemapCells { asset, layer, cells }`: `cells` are flat `[index, tile, …]` pairs in the
402
+ `.tilemap.json` file's order (row-major, top row first), `layer` a layer name or index. Every
403
+ loaded `Tilemap` of the open scene whose `map` is `asset` is written with `Tilemap.setCells`, so
404
+ the view shows the paint at once; the answer is `{ tilemaps, changed }`. The file is not
405
+ written: save it, or a reopen shows the file's cells again.
406
+ - **Editor lines.** With a canvas the scene host lists `editorLines` and draws the editor's own
407
+ line sets over the view in 3D and 2D: `setEditorLines { id, lines, color? }` (six numbers a
408
+ segment, world metres, as `getColliderOutlines` answers; `color` `[r, g, b, a?]`) replaces the
409
+ set `id`, `clearEditorLines { id? }` removes one or all. At most 64 sets of 100 000 segments;
410
+ never picked, saved or drawn in the game view; re-send them after `ready`.
390
411
  - **A changed asset reloads in place, not the view.** The scene view's page hands every
391
412
  `ignifx:asset-changed` event to `host.assetChanged`, which calls `app.assets.reload(address)` for an
392
413
  asset the app has loaded, of type `scene` (a scene or prefab), `model`, `mesh`, `material`,