@ignifx/editor-host 0.16.0 → 0.18.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/grid.js +32 -5
- package/dist/grid.js.map +1 -1
- package/dist/index.d.ts +79 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +394 -110
- package/dist/index.js.map +1 -1
- package/dist/sprite-game-view.js +132 -0
- package/dist/sprite-game-view.js.map +1 -0
- package/package.json +10 -10
- package/skills/editor-host/SKILL.md +8 -4
|
@@ -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.
|
|
3
|
+
"version": "0.18.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.
|
|
56
|
-
"@ignifx/3d": "0.
|
|
57
|
-
"@ignifx/core": "0.
|
|
58
|
-
"@ignifx/input": "0.
|
|
59
|
-
"@ignifx/physics": "0.
|
|
60
|
-
"@ignifx/physics-2d": "0.
|
|
61
|
-
"@ignifx/vite-plugin": "0.
|
|
55
|
+
"@ignifx/2d": "0.18.0",
|
|
56
|
+
"@ignifx/3d": "0.18.0",
|
|
57
|
+
"@ignifx/core": "0.18.0",
|
|
58
|
+
"@ignifx/input": "0.18.0",
|
|
59
|
+
"@ignifx/physics": "0.18.0",
|
|
60
|
+
"@ignifx/physics-2d": "0.18.0",
|
|
61
|
+
"@ignifx/vite-plugin": "0.18.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@babylonjs/lite": "1.34.0",
|
|
65
65
|
"vite": "^8.2.2",
|
|
66
|
-
"@ignifx/core": "0.
|
|
67
|
-
"@ignifx/vite-plugin": "0.
|
|
66
|
+
"@ignifx/core": "0.18.0",
|
|
67
|
+
"@ignifx/vite-plugin": "0.18.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|
|
70
70
|
"@ignifx/vite-plugin": {
|
|
@@ -3,7 +3,7 @@ name: editor-host
|
|
|
3
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.
|
|
6
|
+
ignifx-version: "0.18.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.
|
|
28
|
+
- Engine: ignifx `0.18.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`.
|
|
@@ -156,6 +156,7 @@ host.dispose();
|
|
|
156
156
|
| `PlayStats`, `isPlayStats` | `playStats`'s `{ fps, frameTimeMs, entityCount, frameCount }`: the newest second of `app.diagnostics` frames, the world's entities |
|
|
157
157
|
| `HostCapability.hotReloadDefaults` | The scene view gives fields the document leaves out their new default after a script's hot reload |
|
|
158
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 |
|
|
159
160
|
| `HostCapability.logRelay`, `isAppErrorData`, `LoggedError` | Both views relay `log` (with the first `Error` a line carries), `hostError` (entity, component, phase, stack) and `hotReloaded` |
|
|
160
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]` |
|
|
161
162
|
| `EditorHostErrorCode` | `IGX-1801` bad origin, `IGX-1802` no window, `IGX-1803` bad option |
|
|
@@ -392,10 +393,13 @@ object `openScene` sends, through `world.loadSceneFile`; `readBack` answers with
|
|
|
392
393
|
- **The grid.** With a canvas the scene host lists the `grid` capability and draws a grid: a
|
|
393
394
|
ground grid at `y = 0` in 3D view mode (depth-tested, centred under the eye, coarser the higher
|
|
394
395
|
the eye, faded out before its edge) and a faint grid over the 2D view (one line per layer pixel
|
|
395
|
-
from zoom 8). `setGrid { visible?, size? }` sets the whole grid each call; a field left out takes
|
|
396
|
+
from zoom 8). `setGrid { visible?, size?, overlay?, height? }` sets the whole grid each call; a field left out takes
|
|
396
397
|
its default (`visible: true`, `size: 1` metre, 0.001 to 1000). The grid starts visible at every
|
|
397
398
|
load, so re-send the editor's state after `ready`. It is never picked or saved, and never in the
|
|
398
|
-
play view; `screenshot` includes it while it is visible.
|
|
399
|
+
play view; `screenshot` includes it while it is visible. With the `gridOverlay` capability,
|
|
400
|
+
`setGrid` also takes `overlay` (default `false`: the 3D grid draws over the scene, fainter, so a
|
|
401
|
+
floor mesh does not hide it) and `height` (default `0`: the 3D grid plane's world y, -100 000 to
|
|
402
|
+
100 000 metres); an older host ignores both.
|
|
399
403
|
- **Live tilemap painting.** With a canvas the scene host lists `tilemapCells` and answers
|
|
400
404
|
`setTilemapCells { asset, layer, cells }`: `cells` are flat `[index, tile, …]` pairs in the
|
|
401
405
|
`.tilemap.json` file's order (row-major, top row first), `layer` a layer name or index. Every
|