@ignifx/editor-host 0.21.0 → 0.22.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/README.md +22 -0
- package/dist/grid.js +1 -1
- package/dist/grid.js.map +1 -1
- package/dist/index.d.ts +26 -26
- package/dist/index.js +61 -63
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/skills/editor-host/SKILL.md +43 -147
- package/skills/editor-host/references/protocol.md +140 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @ignifx/editor-host
|
|
2
|
+
|
|
3
|
+
The part of the ignifx editor that lives inside a project: it runs the project's own engine in the editor's scene view and play view, over a versioned protocol. Game code never calls it, and production builds contain none of it.
|
|
4
|
+
|
|
5
|
+
Part of [ignifx](https://ignifx.com), a code-first TypeScript game engine for WebGPU-capable browsers and Electron. The engine is pre-1.0: minor releases may include breaking changes.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add -D @ignifx/editor-host
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Install the same version as the project's `@ignifx/core`: this package is on the engine's version line, not the editor's. `@ignifx/core` and `@babylonjs/lite` are peers; the `@ignifx/editor-host/vite` entry also needs `@ignifx/vite-plugin` and `vite`.
|
|
14
|
+
The `ignifx` umbrella package does not include it.
|
|
15
|
+
|
|
16
|
+
## Documentation
|
|
17
|
+
|
|
18
|
+
The package ships its guide as an agent skill: `skills/editor-host/SKILL.md` (`node_modules/@ignifx/editor-host/skills/editor-host/SKILL.md` once installed). It covers setup, the main APIs, recipes and gotchas.
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
Apache-2.0 © Astrum Forge Studios
|
package/dist/grid.js
CHANGED
|
@@ -2,7 +2,7 @@ import { EDITOR_ONLY_METADATA_KEY } from "@ignifx/core";
|
|
|
2
2
|
import { addToScene, createGridMaterial, createGround, createPlane, createTexture2DFromPixels, disposeMeshGpu, releaseTexture, removeFromScene, setShaderUniform } from "@babylonjs/lite";
|
|
3
3
|
//#region src/lite/grid.ts
|
|
4
4
|
/**
|
|
5
|
-
* The scene view's grid
|
|
5
|
+
* The scene view's grid, drawn with Babylon Lite's `createGridMaterial`. Every Lite
|
|
6
6
|
* claim here was read from the pinned `@babylonjs/lite` 1.34 `index.d.ts` and
|
|
7
7
|
* `lib/material/grid/grid-material.js`.
|
|
8
8
|
*
|
package/dist/grid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.js","names":[],"sources":["../src/lite/grid.ts"],"sourcesContent":["/**\n * The scene view's grid (engine ask E31), drawn with Babylon Lite's `createGridMaterial`. Every Lite\n * claim here was read from the pinned `@babylonjs/lite` 1.34 `index.d.ts` and\n * `lib/material/grid/grid-material.js`.\n *\n * The host loads this module with `import()` once a scene view has a canvas, so the grid's shader\n * code stays out of the host's first chunk (`CONSTITUTION.md` §2.5).\n */\n\nimport {\n addToScene,\n createGridMaterial,\n createGround,\n createPlane,\n createTexture2DFromPixels,\n disposeMeshGpu,\n releaseTexture,\n removeFromScene,\n setShaderUniform,\n} from \"@babylonjs/lite\";\nimport { EDITOR_ONLY_METADATA_KEY } from \"@ignifx/core\";\nimport type { GridPlacement } from \"../scene/grid.js\";\nimport type { Mesh, SceneContext, ShaderMaterial } from \"@babylonjs/lite\";\nimport type { AppLiteHandles, RenderOverlay } from \"@ignifx/core\";\n\n/** The name of the 3D grid's mesh in the render scene. */\nexport const GRID_MESH_NAME = \"ignifx-editor-grid\";\n\n/** The name of the 2D grid's mesh in the render overlay. */\nexport const SCREEN_GRID_MESH_NAME = \"ignifx-editor-grid-2d\";\n\n/** The name of the 3D grid's mesh in the render overlay, drawn when `setGrid` asks for `overlay`. */\nexport const OVERLAY_GRID_MESH_NAME = \"ignifx-editor-grid-overlay\";\n\n/** How visible the minor lines are next to the major ones, `0..1`. */\nconst MINOR_VISIBILITY = 0.4;\n\n/** The 3D grid's line opacity; below 1, Lite's grid material leaves the space between lines clear. */\nconst GROUND_OPACITY = 0.8;\n\n/** The 3D grid's line opacity over the scene: it hides nothing, so it stays fainter than the depth-tested one. */\nconst OVERLAY_GROUND_OPACITY = 0.5;\n\n/** The 2D grid's line opacity: it draws over the sprites, so it stays faint. */\nconst SCREEN_OPACITY = 0.35;\n\n/** The fade texture's side, in texels. */\nconst FADE_SIZE = 64;\n\n/** The fade starts this far from the centre, as a fraction of the side. */\nconst FADE_START = 0.12;\n\n/** The fade ends this far from the centre: the grid is gone before the square's edge. */\nconst FADE_END = 0.48;\n\n/** The grid of one scene view. */\nexport interface EditorGridView {\n /**\n * Draws the grid where a placement says, or hides it.\n *\n * @param placement - This frame's grid, or `null` to hide it.\n */\n place(placement: GridPlacement | null): void;\n /** Removes the grid's meshes and releases their GPU resources. Calling it again does nothing. */\n dispose(): void;\n}\n\n/** One drawn plane: its mesh, material and the scene that holds it. */\ninterface GridPlane {\n readonly mesh: Mesh;\n readonly material: ShaderMaterial;\n readonly scene: SceneContext;\n readonly opacity: number;\n}\n\n/**\n * Builds the grid of one scene view: a ground plane in the render scene, depth-tested against the\n * document's meshes, the same plane in the render overlay, drawn over them (`setGrid`'s\n * `overlay`), and a screen plane in the render overlay, over the 2D view's sprites.\n *\n * @remarks\n * Lite's grid material works in object space, so each plane is a unit square scaled to the\n * placement's extent, with `gridRatio = step / extent` and `gridOffset = centre / extent`: the lines\n * stay on world multiples of the step wherever the square moves. Neither mesh is pickable, casts\n * shadows or belongs to an entity, so no pick, selection or `readBack` reaches it, and both carry\n * core's `EDITOR_ONLY_METADATA_KEY`, so no render texture (the game view) draws them.\n *\n * @param handles - The app's Lite engine and render scene (`app.lite`).\n * @param overlay - The view's open render overlay; the grid does not own it.\n * @returns The grid, hidden until the first {@link EditorGridView.place}.\n */\nexport function createEditorGrid(handles: AppLiteHandles, overlay: RenderOverlay): EditorGridView {\n const { engine } = handles;\n const fade = createTexture2DFromPixels(engine, radialFade(), FADE_SIZE, FADE_SIZE, {\n minFilter: \"linear\",\n magFilter: \"linear\",\n });\n const ground = makePlane(\n createGround(engine, { width: 1, height: 1, subdivisions: 1 }),\n GRID_MESH_NAME,\n createGridMaterial({\n name: GRID_MESH_NAME,\n lineColor: [0.6, 0.6, 0.6],\n minorUnitVisibility: MINOR_VISIBILITY,\n opacity: GROUND_OPACITY,\n opacityTexture: fade,\n backFaceCulling: false,\n }),\n handles.scene,\n GROUND_OPACITY,\n );\n const overlayGround = makePlane(\n createGround(engine, { width: 1, height: 1, subdivisions: 1 }),\n OVERLAY_GRID_MESH_NAME,\n createGridMaterial({\n name: OVERLAY_GRID_MESH_NAME,\n lineColor: [0.6, 0.6, 0.6],\n minorUnitVisibility: MINOR_VISIBILITY,\n opacity: OVERLAY_GROUND_OPACITY,\n opacityTexture: fade,\n backFaceCulling: false,\n }),\n overlay.lite.scene,\n OVERLAY_GROUND_OPACITY,\n );\n const screen = makePlane(\n createPlane(engine, { size: 1 }),\n SCREEN_GRID_MESH_NAME,\n createGridMaterial({\n name: SCREEN_GRID_MESH_NAME,\n lineColor: [0.75, 0.75, 0.75],\n minorUnitVisibility: MINOR_VISIBILITY,\n opacity: SCREEN_OPACITY,\n backFaceCulling: false,\n }),\n overlay.lite.scene,\n SCREEN_OPACITY,\n );\n let isDisposed = false;\n\n return {\n place(placement: GridPlacement | null): void {\n if (isDisposed) {\n return;\n }\n const isGround = placement?.plane === \"ground\";\n ground.mesh.visible = isGround && !placement.overlay;\n overlayGround.mesh.visible = isGround && placement.overlay;\n screen.mesh.visible = placement?.plane === \"screen\";\n if (placement === null) {\n return;\n }\n const { centerX, centerY, extent } = placement;\n const target = placement.plane === \"screen\" ? screen : placement.overlay ? overlayGround : ground;\n if (placement.plane === \"ground\") {\n target.mesh.position.set(centerX, placement.height, centerY);\n target.mesh.scaling.set(extent, 1, extent);\n setShaderUniform(target.material, \"gridOffset\", [centerX / extent, 0, centerY / extent]);\n } else {\n target.mesh.position.set(centerX, centerY, 0);\n target.mesh.scaling.set(extent, extent, 1);\n setShaderUniform(target.material, \"gridOffset\", [centerX / extent, centerY / extent, 0]);\n }\n setShaderUniform(target.material, \"gridControl\", [\n placement.step / extent,\n placement.majorEvery,\n MINOR_VISIBILITY,\n target.opacity,\n ]);\n },\n dispose(): void {\n if (isDisposed) {\n return;\n }\n isDisposed = true;\n for (const plane of [ground, overlayGround, screen]) {\n removeFromScene(plane.scene, plane.mesh);\n disposeMeshGpu(plane.mesh);\n }\n releaseTexture(fade);\n },\n };\n}\n\n/**\n * Names a grid mesh, gives it its material, keeps it out of picks and shadows, and adds it hidden.\n *\n * @param mesh - The unit square.\n * @param name - The mesh's name.\n * @param material - Its grid material.\n * @param scene - The scene that draws it.\n * @param opacity - The material's line opacity, written back with every placement.\n * @returns The plane.\n */\nfunction makePlane(\n mesh: Mesh,\n name: string,\n material: ShaderMaterial,\n scene: SceneContext,\n opacity: number,\n): GridPlane {\n mesh.name = name;\n mesh.material = material;\n mesh.pickable = false;\n mesh.receiveShadows = false;\n mesh.visible = false;\n // Drawn in the scene view only, never in a render texture such as the Game panel's view.\n mesh.metadata = { ...mesh.metadata, [EDITOR_ONLY_METADATA_KEY]: true };\n addToScene(scene, mesh);\n return { mesh, material, scene, opacity };\n}\n\n/**\n * A square of white texels whose alpha is 1 near the centre and falls smoothly to 0 before the\n * edge, for the grid material's `opacityTexture`.\n *\n * @returns `FADE_SIZE²` RGBA texels.\n */\nfunction radialFade(): Uint8Array {\n const data = new Uint8Array(FADE_SIZE * FADE_SIZE * 4);\n for (let row = 0; row < FADE_SIZE; row += 1) {\n for (let col = 0; col < FADE_SIZE; col += 1) {\n const u = (col + 0.5) / FADE_SIZE - 0.5;\n const v = (row + 0.5) / FADE_SIZE - 0.5;\n const t = Math.min(1, Math.max(0, (Math.hypot(u, v) - FADE_START) / (FADE_END - FADE_START)));\n const alpha = 1 - t * t * (3 - 2 * t);\n const index = (row * FADE_SIZE + col) * 4;\n data[index] = 255;\n data[index +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AQ;AAC1C;;;;;;;AAQA,SAAS,aAAyB;CAChC,MAAM,uBAAO,IAAI,WAAW,KAAyB;CACrD,KAAK,IAAI,MAAM,GAAG,MAAM,WAAW,OAAO,GACxC,KAAK,IAAI,MAAM,GAAG,MAAM,WAAW,OAAO,GAAG;EAC3C,MAAM,KAAK,MAAM,MAAO,YAAY;EACpC,MAAM,KAAK,MAAM,MAAO,YAAY;EACpC,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,GAAG,CAAC,IAAI,cAAe,GAAsB,CAAC;EAC5F,MAAM,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI;EACnC,MAAM,SAAS,MAAM,YAAY,OAAO;EACxC,KAAK,SAAS;EACd,KAAK,QAAQ,KAAK;EAClB,KAAK,QAAQ,KAAK;EAClB,KAAK,QAAQ,KAAK,KAAK,MAAM,QAAQ,GAAG;CAC1C;CAEF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"grid.js","names":[],"sources":["../src/lite/grid.ts"],"sourcesContent":["/**\n * The scene view's grid, drawn with Babylon Lite's `createGridMaterial`. Every Lite\n * claim here was read from the pinned `@babylonjs/lite` 1.34 `index.d.ts` and\n * `lib/material/grid/grid-material.js`.\n *\n * The host loads this module with `import()` once a scene view has a canvas, so the grid's shader\n * code stays out of the host's first chunk (`CONSTITUTION.md` §2.5).\n */\n\nimport {\n addToScene,\n createGridMaterial,\n createGround,\n createPlane,\n createTexture2DFromPixels,\n disposeMeshGpu,\n releaseTexture,\n removeFromScene,\n setShaderUniform,\n} from \"@babylonjs/lite\";\nimport { EDITOR_ONLY_METADATA_KEY } from \"@ignifx/core\";\nimport type { GridPlacement } from \"../scene/grid.js\";\nimport type { Mesh, SceneContext, ShaderMaterial } from \"@babylonjs/lite\";\nimport type { AppLiteHandles, RenderOverlay } from \"@ignifx/core\";\n\n/** The name of the 3D grid's mesh in the render scene. */\nexport const GRID_MESH_NAME = \"ignifx-editor-grid\";\n\n/** The name of the 2D grid's mesh in the render overlay. */\nexport const SCREEN_GRID_MESH_NAME = \"ignifx-editor-grid-2d\";\n\n/** The name of the 3D grid's mesh in the render overlay, drawn when `setGrid` asks for `overlay`. */\nexport const OVERLAY_GRID_MESH_NAME = \"ignifx-editor-grid-overlay\";\n\n/** How visible the minor lines are next to the major ones, `0..1`. */\nconst MINOR_VISIBILITY = 0.4;\n\n/** The 3D grid's line opacity; below 1, Lite's grid material leaves the space between lines clear. */\nconst GROUND_OPACITY = 0.8;\n\n/** The 3D grid's line opacity over the scene: it hides nothing, so it stays fainter than the depth-tested one. */\nconst OVERLAY_GROUND_OPACITY = 0.5;\n\n/** The 2D grid's line opacity: it draws over the sprites, so it stays faint. */\nconst SCREEN_OPACITY = 0.35;\n\n/** The fade texture's side, in texels. */\nconst FADE_SIZE = 64;\n\n/** The fade starts this far from the centre, as a fraction of the side. */\nconst FADE_START = 0.12;\n\n/** The fade ends this far from the centre: the grid is gone before the square's edge. */\nconst FADE_END = 0.48;\n\n/** The grid of one scene view. */\nexport interface EditorGridView {\n /**\n * Draws the grid where a placement says, or hides it.\n *\n * @param placement - This frame's grid, or `null` to hide it.\n */\n place(placement: GridPlacement | null): void;\n /** Removes the grid's meshes and releases their GPU resources. Calling it again does nothing. */\n dispose(): void;\n}\n\n/** One drawn plane: its mesh, material and the scene that holds it. */\ninterface GridPlane {\n readonly mesh: Mesh;\n readonly material: ShaderMaterial;\n readonly scene: SceneContext;\n readonly opacity: number;\n}\n\n/**\n * Builds the grid of one scene view: a ground plane in the render scene, depth-tested against the\n * document's meshes, the same plane in the render overlay, drawn over them (`setGrid`'s\n * `overlay`), and a screen plane in the render overlay, over the 2D view's sprites.\n *\n * @remarks\n * Lite's grid material works in object space, so each plane is a unit square scaled to the\n * placement's extent, with `gridRatio = step / extent` and `gridOffset = centre / extent`: the lines\n * stay on world multiples of the step wherever the square moves. Neither mesh is pickable, casts\n * shadows or belongs to an entity, so no pick, selection or `readBack` reaches it, and both carry\n * core's `EDITOR_ONLY_METADATA_KEY`, so no render texture (the game view) draws them.\n *\n * @param handles - The app's Lite engine and render scene (`app.lite`).\n * @param overlay - The view's open render overlay; the grid does not own it.\n * @returns The grid, hidden until the first {@link EditorGridView.place}.\n */\nexport function createEditorGrid(handles: AppLiteHandles, overlay: RenderOverlay): EditorGridView {\n const { engine } = handles;\n const fade = createTexture2DFromPixels(engine, radialFade(), FADE_SIZE, FADE_SIZE, {\n minFilter: \"linear\",\n magFilter: \"linear\",\n });\n const ground = makePlane(\n createGround(engine, { width: 1, height: 1, subdivisions: 1 }),\n GRID_MESH_NAME,\n createGridMaterial({\n name: GRID_MESH_NAME,\n lineColor: [0.6, 0.6, 0.6],\n minorUnitVisibility: MINOR_VISIBILITY,\n opacity: GROUND_OPACITY,\n opacityTexture: fade,\n backFaceCulling: false,\n }),\n handles.scene,\n GROUND_OPACITY,\n );\n const overlayGround = makePlane(\n createGround(engine, { width: 1, height: 1, subdivisions: 1 }),\n OVERLAY_GRID_MESH_NAME,\n createGridMaterial({\n name: OVERLAY_GRID_MESH_NAME,\n lineColor: [0.6, 0.6, 0.6],\n minorUnitVisibility: MINOR_VISIBILITY,\n opacity: OVERLAY_GROUND_OPACITY,\n opacityTexture: fade,\n backFaceCulling: false,\n }),\n overlay.lite.scene,\n OVERLAY_GROUND_OPACITY,\n );\n const screen = makePlane(\n createPlane(engine, { size: 1 }),\n SCREEN_GRID_MESH_NAME,\n createGridMaterial({\n name: SCREEN_GRID_MESH_NAME,\n lineColor: [0.75, 0.75, 0.75],\n minorUnitVisibility: MINOR_VISIBILITY,\n opacity: SCREEN_OPACITY,\n backFaceCulling: false,\n }),\n overlay.lite.scene,\n SCREEN_OPACITY,\n );\n let isDisposed = false;\n\n return {\n place(placement: GridPlacement | null): void {\n if (isDisposed) {\n return;\n }\n const isGround = placement?.plane === \"ground\";\n ground.mesh.visible = isGround && !placement.overlay;\n overlayGround.mesh.visible = isGround && placement.overlay;\n screen.mesh.visible = placement?.plane === \"screen\";\n if (placement === null) {\n return;\n }\n const { centerX, centerY, extent } = placement;\n const target = placement.plane === \"screen\" ? screen : placement.overlay ? overlayGround : ground;\n if (placement.plane === \"ground\") {\n target.mesh.position.set(centerX, placement.height, centerY);\n target.mesh.scaling.set(extent, 1, extent);\n setShaderUniform(target.material, \"gridOffset\", [centerX / extent, 0, centerY / extent]);\n } else {\n target.mesh.position.set(centerX, centerY, 0);\n target.mesh.scaling.set(extent, extent, 1);\n setShaderUniform(target.material, \"gridOffset\", [centerX / extent, centerY / extent, 0]);\n }\n setShaderUniform(target.material, \"gridControl\", [\n placement.step / extent,\n placement.majorEvery,\n MINOR_VISIBILITY,\n target.opacity,\n ]);\n },\n dispose(): void {\n if (isDisposed) {\n return;\n }\n isDisposed = true;\n for (const plane of [ground, overlayGround, screen]) {\n removeFromScene(plane.scene, plane.mesh);\n disposeMeshGpu(plane.mesh);\n }\n releaseTexture(fade);\n },\n };\n}\n\n/**\n * Names a grid mesh, gives it its material, keeps it out of picks and shadows, and adds it hidden.\n *\n * @param mesh - The unit square.\n * @param name - The mesh's name.\n * @param material - Its grid material.\n * @param scene - The scene that draws it.\n * @param opacity - The material's line opacity, written back with every placement.\n * @returns The plane.\n */\nfunction makePlane(\n mesh: Mesh,\n name: string,\n material: ShaderMaterial,\n scene: SceneContext,\n opacity: number,\n): GridPlane {\n mesh.name = name;\n mesh.material = material;\n mesh.pickable = false;\n mesh.receiveShadows = false;\n mesh.visible = false;\n // Drawn in the scene view only, never in a render texture such as the Game panel's view.\n mesh.metadata = { ...mesh.metadata, [EDITOR_ONLY_METADATA_KEY]: true };\n addToScene(scene, mesh);\n return { mesh, material, scene, opacity };\n}\n\n/**\n * A square of white texels whose alpha is 1 near the centre and falls smoothly to 0 before the\n * edge, for the grid material's `opacityTexture`.\n *\n * @returns `FADE_SIZE²` RGBA texels.\n */\nfunction radialFade(): Uint8Array {\n const data = new Uint8Array(FADE_SIZE * FADE_SIZE * 4);\n for (let row = 0; row < FADE_SIZE; row += 1) {\n for (let col = 0; col < FADE_SIZE; col += 1) {\n const u = (col + 0.5) / FADE_SIZE - 0.5;\n const v = (row + 0.5) / FADE_SIZE - 0.5;\n const t = Math.min(1, Math.max(0, (Math.hypot(u, v) - FADE_START) / (FADE_END - FADE_START)));\n const alpha = 1 - t * t * (3 - 2 * t);\n const index = (row * FADE_SIZE + col) * 4;\n data[index] = 255;\n data[index + 1] = 255;\n data[index + 2] = 255;\n data[index + 3] = Math.round(alpha * 255);\n }\n }\n return data;\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAa,iBAAiB;;AAG9B,MAAa,wBAAwB;;AAGrC,MAAa,yBAAyB;;AAGtC,MAAM,mBAAmB;;AAGzB,MAAM,iBAAiB;;AAGvB,MAAM,yBAAyB;;AAG/B,MAAM,iBAAiB;;AAGvB,MAAM,YAAY;;AAGlB,MAAM,aAAa;;;;;;;;;;;;;;;;;AAyCnB,SAAgB,iBAAiB,SAAyB,SAAwC;CAChG,MAAM,EAAE,WAAW;CACnB,MAAM,OAAO,0BAA0B,QAAQ,WAAW,GAAG,WAAW,WAAW;EACjF,WAAW;EACX,WAAW;CACb,CAAC;CACD,MAAM,SAAS,UACb,aAAa,QAAQ;EAAE,OAAO;EAAG,QAAQ;EAAG,cAAc;CAAE,CAAC,GAC7D,gBACA,mBAAmB;EACjB,MAAM;EACN,WAAW;GAAC;GAAK;GAAK;EAAG;EACzB,qBAAqB;EACrB,SAAS;EACT,gBAAgB;EAChB,iBAAiB;CACnB,CAAC,GACD,QAAQ,OACR,cACF;CACA,MAAM,gBAAgB,UACpB,aAAa,QAAQ;EAAE,OAAO;EAAG,QAAQ;EAAG,cAAc;CAAE,CAAC,GAC7D,wBACA,mBAAmB;EACjB,MAAM;EACN,WAAW;GAAC;GAAK;GAAK;EAAG;EACzB,qBAAqB;EACrB,SAAS;EACT,gBAAgB;EAChB,iBAAiB;CACnB,CAAC,GACD,QAAQ,KAAK,OACb,sBACF;CACA,MAAM,SAAS,UACb,YAAY,QAAQ,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UACP,MACA,MACA,UACA,OACA,SACW;CACX,KAAK,OAAO;CACZ,KAAK,WAAW;CAChB,KAAK,WAAW;CAChB,KAAK,iBAAiB;CACtB,KAAK,UAAU;CAEf,KAAK,WAAW;EAAE,GAAG,KAAK;GAAW,2BAA2B;CAAK;CACrE,WAAW,OAAO,IAAI;CACtB,OAAO;EAAE;EAAM;EAAU;EAAO;CAAQ;AAC1C;;;;;;;AAQA,SAAS,aAAyB;CAChC,MAAM,uBAAO,IAAI,WAAW,KAAyB;CACrD,KAAK,IAAI,MAAM,GAAG,MAAM,WAAW,OAAO,GACxC,KAAK,IAAI,MAAM,GAAG,MAAM,WAAW,OAAO,GAAG;EAC3C,MAAM,KAAK,MAAM,MAAO,YAAY;EACpC,MAAM,KAAK,MAAM,MAAO,YAAY;EACpC,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,GAAG,CAAC,IAAI,cAAe,GAAsB,CAAC;EAC5F,MAAM,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI;EACnC,MAAM,SAAS,MAAM,YAAY,OAAO;EACxC,KAAK,SAAS;EACd,KAAK,QAAQ,KAAK;EAClB,KAAK,QAAQ,KAAK;EAClB,KAAK,QAAQ,KAAK,KAAK,MAAM,QAAQ,GAAG;CAC1C;CAEF,OAAO;AACT"}
|
package/dist/index.d.ts
CHANGED
|
@@ -320,8 +320,8 @@ export declare const HostCapability: {
|
|
|
320
320
|
readonly gizmos: "gizmos";
|
|
321
321
|
/**
|
|
322
322
|
* The host answers `screenshot`: the scene host captures its view, the play controls the game's
|
|
323
|
-
* canvas. The play controls list it
|
|
324
|
-
*
|
|
323
|
+
* canvas. The play controls list it additively in 0.3; without it, the play view answers
|
|
324
|
+
* `screenshot` with `RpcErrorCode.methodNotFound`.
|
|
325
325
|
*/
|
|
326
326
|
readonly screenshot: "screenshot";
|
|
327
327
|
/** The scene host accepts `setViewMode` with `"2d"`: a 2D editor camera and planar gizmos. */
|
|
@@ -353,22 +353,22 @@ export declare const HostCapability: {
|
|
|
353
353
|
*/
|
|
354
354
|
readonly hotReloadDefaults: "hotReloadDefaults";
|
|
355
355
|
/**
|
|
356
|
-
* The play controls answer `queryRuntime`: an entity's live state in the scene format.
|
|
357
|
-
*
|
|
356
|
+
* The play controls answer `queryRuntime`: an entity's live state in the scene format.
|
|
357
|
+
* Additive in 0.3; without it, the play view answers `queryRuntime` with
|
|
358
358
|
* `RpcErrorCode.methodNotFound`.
|
|
359
359
|
*/
|
|
360
360
|
readonly queryRuntime: "queryRuntime";
|
|
361
361
|
/**
|
|
362
362
|
* The play controls answer `sendInput`: synthetic key and pointer events queued into the game's
|
|
363
363
|
* own input system (`app.input` from `@ignifx/input`), never into the editor's window. Listed only
|
|
364
|
-
* when the game has `app.input`.
|
|
365
|
-
*
|
|
364
|
+
* when the game has `app.input`. Additive in 0.3; without it, the play view answers `sendInput`
|
|
365
|
+
* with `RpcErrorCode.methodNotFound`.
|
|
366
366
|
*/
|
|
367
367
|
readonly sendInput: "sendInput";
|
|
368
368
|
/**
|
|
369
369
|
* The scene host answers `setGameView` and `gameViewFrame`: the open scene through its own main
|
|
370
|
-
* camera, rendered beside the editor camera (`RenderViewMethod`).
|
|
371
|
-
*
|
|
370
|
+
* camera, rendered beside the editor camera (`RenderViewMethod`). Additive in 0.3; without it,
|
|
371
|
+
* the host answers both with `RpcErrorCode.methodNotFound`.
|
|
372
372
|
*/
|
|
373
373
|
readonly gameView: "gameView";
|
|
374
374
|
/**
|
|
@@ -391,7 +391,7 @@ export declare const HostCapability: {
|
|
|
391
391
|
readonly gameView2d: "gameView2d";
|
|
392
392
|
/**
|
|
393
393
|
* The scene host answers `renderThumbnail`: a model or prefab asset rendered on its own
|
|
394
|
-
* (`RenderViewMethod`).
|
|
394
|
+
* (`RenderViewMethod`). Additive in 0.3; without it, the host answers it with
|
|
395
395
|
* `RpcErrorCode.methodNotFound`.
|
|
396
396
|
*/
|
|
397
397
|
readonly thumbnails: "thumbnails";
|
|
@@ -417,8 +417,8 @@ export declare const HostCapability: {
|
|
|
417
417
|
readonly thumbnailTextures: "thumbnailTextures";
|
|
418
418
|
/**
|
|
419
419
|
* The scene host draws a grid in the view and answers `setGrid`: a ground grid at `y = 0` in 3D
|
|
420
|
-
* view mode and a unit grid (a pixel grid when zoomed in) over the 2D view.
|
|
421
|
-
*
|
|
420
|
+
* view mode and a unit grid (a pixel grid when zoomed in) over the 2D view. Additive in
|
|
421
|
+
* 0.3; without it, the scene host answers `setGrid` with
|
|
422
422
|
* `RpcErrorCode.methodNotFound`.
|
|
423
423
|
*/
|
|
424
424
|
readonly grid: "grid";
|
|
@@ -444,8 +444,8 @@ export declare const HostCapability: {
|
|
|
444
444
|
readonly editorLines: "editorLines";
|
|
445
445
|
/**
|
|
446
446
|
* The scene host answers `sampleSpriteAnimation`: one frame of a clip on an entity's
|
|
447
|
-
* `SpriteAnimator` (`@ignifx/2d`), for the editor's sprite animation panel.
|
|
448
|
-
*
|
|
447
|
+
* `SpriteAnimator` (`@ignifx/2d`), for the editor's sprite animation panel. Additive in
|
|
448
|
+
* 0.3; without it, the scene host answers `sampleSpriteAnimation` with
|
|
449
449
|
* `RpcErrorCode.methodNotFound`.
|
|
450
450
|
*/
|
|
451
451
|
readonly spriteAnimation: "spriteAnimation";
|
|
@@ -1109,7 +1109,7 @@ interface RemoveOverrideOp {
|
|
|
1109
1109
|
readonly added?: string;
|
|
1110
1110
|
}
|
|
1111
1111
|
/**
|
|
1112
|
-
* One scene op: the closed vocabulary
|
|
1112
|
+
* One scene op: the closed vocabulary, identical to `@ignifx/editor-core`'s `SceneOp`.
|
|
1113
1113
|
*
|
|
1114
1114
|
* @public
|
|
1115
1115
|
*/
|
|
@@ -1206,14 +1206,14 @@ export declare const SceneMethod: {
|
|
|
1206
1206
|
*/
|
|
1207
1207
|
readonly sampleAnimation: "sampleAnimation";
|
|
1208
1208
|
/**
|
|
1209
|
-
* Shows one frame of a clip on an entity's `SpriteAnimator` without playing it
|
|
1210
|
-
*
|
|
1209
|
+
* Shows one frame of a clip on an entity's `SpriteAnimator` without playing it. Needs
|
|
1210
|
+
* `HostCapability.spriteAnimation`. Answers {@link SampleSpriteAnimationResult}. A host from
|
|
1211
1211
|
* before it answers `RpcErrorCode.methodNotFound`. Additive in 0.3.
|
|
1212
1212
|
*/
|
|
1213
1213
|
readonly sampleSpriteAnimation: "sampleSpriteAnimation";
|
|
1214
1214
|
/**
|
|
1215
|
-
* Shows or hides the view's grid and sets its spacing
|
|
1216
|
-
* `
|
|
1215
|
+
* Shows or hides the view's grid and sets its spacing. Needs `HostCapability.grid`. Answers
|
|
1216
|
+
* `null`. Additive in 0.3.
|
|
1217
1217
|
*/
|
|
1218
1218
|
readonly setGrid: "setGrid";
|
|
1219
1219
|
/**
|
|
@@ -1283,7 +1283,7 @@ export declare const SceneNotification: {
|
|
|
1283
1283
|
export type SceneNotification = (typeof SceneNotification)[keyof typeof SceneNotification];
|
|
1284
1284
|
/**
|
|
1285
1285
|
* The fewest milliseconds between two `transformDragging` notifications for the same gesture: at
|
|
1286
|
-
* most 20 a second, which
|
|
1286
|
+
* most 20 a second, which is smooth enough for an inspector to follow a drag.
|
|
1287
1287
|
*
|
|
1288
1288
|
* @public
|
|
1289
1289
|
*/
|
|
@@ -1291,7 +1291,7 @@ export declare const TRANSFORM_DRAGGING_INTERVAL_MS = 50;
|
|
|
1291
1291
|
/**
|
|
1292
1292
|
* The largest width and height, in pixels, of a `screenshot`. A request for more fails with
|
|
1293
1293
|
* `invalidParams`; a request without a size gets the view's own size scaled down to fit. It keeps
|
|
1294
|
-
* an image well under what an MCP client accepts inline
|
|
1294
|
+
* an image well under what an MCP client accepts inline.
|
|
1295
1295
|
*
|
|
1296
1296
|
* @public
|
|
1297
1297
|
*/
|
|
@@ -1610,7 +1610,7 @@ interface FrameParams {
|
|
|
1610
1610
|
readonly entities: readonly string[] | "all";
|
|
1611
1611
|
}
|
|
1612
1612
|
/**
|
|
1613
|
-
* The unit of a `pick` point
|
|
1613
|
+
* The unit of a `pick` point.
|
|
1614
1614
|
*
|
|
1615
1615
|
* @public
|
|
1616
1616
|
*/
|
|
@@ -1847,8 +1847,8 @@ interface SchemaDescription {
|
|
|
1847
1847
|
* `true` for the one component every entity carries itself, `ignifx/Transform`: it is never in a
|
|
1848
1848
|
* scene file's `components` list, an editor neither adds nor removes it, and its fields are the
|
|
1849
1849
|
* entity record's `transform` block, edited whole with the `setTransform` op rather than prop by
|
|
1850
|
-
* prop. Absent on every other entry. A host from before the engine described the transform
|
|
1851
|
-
*
|
|
1850
|
+
* prop. Absent on every other entry. A host from before the engine described the transform
|
|
1851
|
+
* sends no such member.
|
|
1852
1852
|
*/
|
|
1853
1853
|
readonly builtIn?: boolean;
|
|
1854
1854
|
/**
|
|
@@ -1856,7 +1856,7 @@ interface SchemaDescription {
|
|
|
1856
1856
|
* `typeId`), in declaration order. The engine adds each one that is missing whenever the component
|
|
1857
1857
|
* is added, so an editor adds them itself as part of the same command; a component whose class
|
|
1858
1858
|
* extends a required one counts. Absent when the class requires nothing, on file-format entries,
|
|
1859
|
-
* and from a host
|
|
1859
|
+
* and from a host that predates this member.
|
|
1860
1860
|
*/
|
|
1861
1861
|
readonly requires?: readonly (string | null)[];
|
|
1862
1862
|
/**
|
|
@@ -1865,8 +1865,8 @@ interface SchemaDescription {
|
|
|
1865
1865
|
* abstract base, `Component`, `Script`) are left out. The engine counts a component whose class
|
|
1866
1866
|
* extends a required one as present, so an editor treats a `requires` entry as present on an
|
|
1867
1867
|
* entity when one of its components has that type id or lists it here. Empty when the class
|
|
1868
|
-
* extends no registered component; absent on file-format entries and from a host
|
|
1869
|
-
*
|
|
1868
|
+
* extends no registered component; absent on file-format entries and from a host that predates
|
|
1869
|
+
* this member, which an editor treats as unknown, not as none.
|
|
1870
1870
|
*/
|
|
1871
1871
|
readonly extends?: readonly string[];
|
|
1872
1872
|
/**
|
package/dist/index.js
CHANGED
|
@@ -148,7 +148,7 @@ function isEditorConnectMessage(value) {
|
|
|
148
148
|
//#region src/protocol/handshake.ts
|
|
149
149
|
/**
|
|
150
150
|
* The handshake the editor runs with each host it embeds: the scene view (`@ignifx/editor-host`)
|
|
151
|
-
* and the play view (`virtual:ignifx/editor`).
|
|
151
|
+
* and the play view (`virtual:ignifx/editor`).
|
|
152
152
|
*
|
|
153
153
|
* The editor sends `hello`; the host answers with its `ready` result, or with an
|
|
154
154
|
* `RpcErrorCode.incompatibleProtocol` error when `protocolVersionIsCompatible` refuses the
|
|
@@ -206,8 +206,8 @@ const HostCapability = {
|
|
|
206
206
|
gizmos: "gizmos",
|
|
207
207
|
/**
|
|
208
208
|
* The host answers `screenshot`: the scene host captures its view, the play controls the game's
|
|
209
|
-
* canvas. The play controls list it
|
|
210
|
-
*
|
|
209
|
+
* canvas. The play controls list it additively in 0.3; without it, the play view answers
|
|
210
|
+
* `screenshot` with `RpcErrorCode.methodNotFound`.
|
|
211
211
|
*/
|
|
212
212
|
screenshot: "screenshot",
|
|
213
213
|
/** The scene host accepts `setViewMode` with `"2d"`: a 2D editor camera and planar gizmos. */
|
|
@@ -239,22 +239,22 @@ const HostCapability = {
|
|
|
239
239
|
*/
|
|
240
240
|
hotReloadDefaults: "hotReloadDefaults",
|
|
241
241
|
/**
|
|
242
|
-
* The play controls answer `queryRuntime`: an entity's live state in the scene format.
|
|
243
|
-
*
|
|
242
|
+
* The play controls answer `queryRuntime`: an entity's live state in the scene format.
|
|
243
|
+
* Additive in 0.3; without it, the play view answers `queryRuntime` with
|
|
244
244
|
* `RpcErrorCode.methodNotFound`.
|
|
245
245
|
*/
|
|
246
246
|
queryRuntime: "queryRuntime",
|
|
247
247
|
/**
|
|
248
248
|
* The play controls answer `sendInput`: synthetic key and pointer events queued into the game's
|
|
249
249
|
* own input system (`app.input` from `@ignifx/input`), never into the editor's window. Listed only
|
|
250
|
-
* when the game has `app.input`.
|
|
251
|
-
*
|
|
250
|
+
* when the game has `app.input`. Additive in 0.3; without it, the play view answers `sendInput`
|
|
251
|
+
* with `RpcErrorCode.methodNotFound`.
|
|
252
252
|
*/
|
|
253
253
|
sendInput: "sendInput",
|
|
254
254
|
/**
|
|
255
255
|
* The scene host answers `setGameView` and `gameViewFrame`: the open scene through its own main
|
|
256
|
-
* camera, rendered beside the editor camera (`RenderViewMethod`).
|
|
257
|
-
*
|
|
256
|
+
* camera, rendered beside the editor camera (`RenderViewMethod`). Additive in 0.3; without it,
|
|
257
|
+
* the host answers both with `RpcErrorCode.methodNotFound`.
|
|
258
258
|
*/
|
|
259
259
|
gameView: "gameView",
|
|
260
260
|
/**
|
|
@@ -277,7 +277,7 @@ const HostCapability = {
|
|
|
277
277
|
gameView2d: "gameView2d",
|
|
278
278
|
/**
|
|
279
279
|
* The scene host answers `renderThumbnail`: a model or prefab asset rendered on its own
|
|
280
|
-
* (`RenderViewMethod`).
|
|
280
|
+
* (`RenderViewMethod`). Additive in 0.3; without it, the host answers it with
|
|
281
281
|
* `RpcErrorCode.methodNotFound`.
|
|
282
282
|
*/
|
|
283
283
|
thumbnails: "thumbnails",
|
|
@@ -303,8 +303,8 @@ const HostCapability = {
|
|
|
303
303
|
thumbnailTextures: "thumbnailTextures",
|
|
304
304
|
/**
|
|
305
305
|
* The scene host draws a grid in the view and answers `setGrid`: a ground grid at `y = 0` in 3D
|
|
306
|
-
* view mode and a unit grid (a pixel grid when zoomed in) over the 2D view.
|
|
307
|
-
*
|
|
306
|
+
* view mode and a unit grid (a pixel grid when zoomed in) over the 2D view. Additive in
|
|
307
|
+
* 0.3; without it, the scene host answers `setGrid` with
|
|
308
308
|
* `RpcErrorCode.methodNotFound`.
|
|
309
309
|
*/
|
|
310
310
|
grid: "grid",
|
|
@@ -330,8 +330,8 @@ const HostCapability = {
|
|
|
330
330
|
editorLines: "editorLines",
|
|
331
331
|
/**
|
|
332
332
|
* The scene host answers `sampleSpriteAnimation`: one frame of a clip on an entity's
|
|
333
|
-
* `SpriteAnimator` (`@ignifx/2d`), for the editor's sprite animation panel.
|
|
334
|
-
*
|
|
333
|
+
* `SpriteAnimator` (`@ignifx/2d`), for the editor's sprite animation panel. Additive in
|
|
334
|
+
* 0.3; without it, the scene host answers `sampleSpriteAnimation` with
|
|
335
335
|
* `RpcErrorCode.methodNotFound`.
|
|
336
336
|
*/
|
|
337
337
|
spriteAnimation: "spriteAnimation",
|
|
@@ -695,7 +695,7 @@ function isSceneFile(value) {
|
|
|
695
695
|
//#region src/protocol/play.ts
|
|
696
696
|
/**
|
|
697
697
|
* The play view's controls: the methods the editor calls on the project's own game page after the
|
|
698
|
-
* handshake, through `attachEditorPlayControls(app)` from `virtual:ignifx/editor`.
|
|
698
|
+
* handshake, through `attachEditorPlayControls(app)` from `virtual:ignifx/editor`.
|
|
699
699
|
*/
|
|
700
700
|
/**
|
|
701
701
|
* The methods the play view answers after `ready`. `play`, `pause`, `step` and `stop` answer with a
|
|
@@ -984,7 +984,7 @@ function isSendInputResult(value) {
|
|
|
984
984
|
//#endregion
|
|
985
985
|
//#region src/protocol/scene-ops.ts
|
|
986
986
|
/**
|
|
987
|
-
* The scene op vocabulary on the wire: the thirteen ops
|
|
987
|
+
* The scene op vocabulary on the wire: the thirteen ops, exactly as
|
|
988
988
|
* `@ignifx/editor-core` defines them (`packages/editor-core/src/ops.ts`), so a command the editor
|
|
989
989
|
* applied to its document is sent to the host unchanged and MCP's `apply_ops` accepts the same JSON.
|
|
990
990
|
*
|
|
@@ -1117,7 +1117,7 @@ function isSceneOp(value) {
|
|
|
1117
1117
|
//#region src/protocol/scene.ts
|
|
1118
1118
|
/**
|
|
1119
1119
|
* Protocol 0.3: the scene document transport between the editor and the scene view
|
|
1120
|
-
* (`@ignifx/editor-host`).
|
|
1120
|
+
* (`@ignifx/editor-host`).
|
|
1121
1121
|
*
|
|
1122
1122
|
* The editor holds the scene document (`@ignifx/editor-core`) and the host mirrors it into a live
|
|
1123
1123
|
* world: the editor opens the scene with the whole file, then sends every command's ops as it
|
|
@@ -1195,14 +1195,14 @@ const SceneMethod = {
|
|
|
1195
1195
|
*/
|
|
1196
1196
|
sampleAnimation: "sampleAnimation",
|
|
1197
1197
|
/**
|
|
1198
|
-
* Shows one frame of a clip on an entity's `SpriteAnimator` without playing it
|
|
1199
|
-
*
|
|
1198
|
+
* Shows one frame of a clip on an entity's `SpriteAnimator` without playing it. Needs
|
|
1199
|
+
* `HostCapability.spriteAnimation`. Answers {@link SampleSpriteAnimationResult}. A host from
|
|
1200
1200
|
* before it answers `RpcErrorCode.methodNotFound`. Additive in 0.3.
|
|
1201
1201
|
*/
|
|
1202
1202
|
sampleSpriteAnimation: "sampleSpriteAnimation",
|
|
1203
1203
|
/**
|
|
1204
|
-
* Shows or hides the view's grid and sets its spacing
|
|
1205
|
-
* `
|
|
1204
|
+
* Shows or hides the view's grid and sets its spacing. Needs `HostCapability.grid`. Answers
|
|
1205
|
+
* `null`. Additive in 0.3.
|
|
1206
1206
|
*/
|
|
1207
1207
|
setGrid: "setGrid",
|
|
1208
1208
|
/**
|
|
@@ -1260,7 +1260,7 @@ const SceneNotification = {
|
|
|
1260
1260
|
};
|
|
1261
1261
|
/**
|
|
1262
1262
|
* The fewest milliseconds between two `transformDragging` notifications for the same gesture: at
|
|
1263
|
-
* most 20 a second, which
|
|
1263
|
+
* most 20 a second, which is smooth enough for an inspector to follow a drag.
|
|
1264
1264
|
*
|
|
1265
1265
|
* @public
|
|
1266
1266
|
*/
|
|
@@ -1268,7 +1268,7 @@ const TRANSFORM_DRAGGING_INTERVAL_MS = 50;
|
|
|
1268
1268
|
/**
|
|
1269
1269
|
* The largest width and height, in pixels, of a `screenshot`. A request for more fails with
|
|
1270
1270
|
* `invalidParams`; a request without a size gets the view's own size scaled down to fit. It keeps
|
|
1271
|
-
* an image well under what an MCP client accepts inline
|
|
1271
|
+
* an image well under what an MCP client accepts inline.
|
|
1272
1272
|
*
|
|
1273
1273
|
* @public
|
|
1274
1274
|
*/
|
|
@@ -1365,7 +1365,7 @@ const GizmoSpace = {
|
|
|
1365
1365
|
world: "world"
|
|
1366
1366
|
};
|
|
1367
1367
|
/**
|
|
1368
|
-
* The unit of a `pick` point
|
|
1368
|
+
* The unit of a `pick` point.
|
|
1369
1369
|
*
|
|
1370
1370
|
* @public
|
|
1371
1371
|
*/
|
|
@@ -2092,9 +2092,9 @@ function isLogParams(value) {
|
|
|
2092
2092
|
//#endregion
|
|
2093
2093
|
//#region src/protocol/render-views.ts
|
|
2094
2094
|
/**
|
|
2095
|
-
* Protocol 0.3, additive
|
|
2096
|
-
*
|
|
2097
|
-
*
|
|
2095
|
+
* Protocol 0.3, additive: the scene host's second views, rendered through the engine's render
|
|
2096
|
+
* textures. The Game panel's view is the document's own camera rendered beside the editor camera
|
|
2097
|
+
* (`setGameView`, `gameViewFrame`); a thumbnail is an asset rendered on its own
|
|
2098
2098
|
* (`renderThumbnail`). Both answer images in the shape of `screenshot`'s.
|
|
2099
2099
|
*/
|
|
2100
2100
|
/**
|
|
@@ -3165,8 +3165,7 @@ function drawnMeshes(handles, owners) {
|
|
|
3165
3165
|
* This is the only module of the editor host that imports Lite (`CONSTITUTION.md` §3.4). The rest
|
|
3166
3166
|
* of the host reaches it through {@link createEditorView}, which takes and returns ignifx objects
|
|
3167
3167
|
* and plain data. Every Lite claim here was read from the pinned `@babylonjs/lite` 1.34
|
|
3168
|
-
* `index.d.ts
|
|
3169
|
-
* `docs/research/spikes/s0.2-gizmos-and-cameras.md`).
|
|
3168
|
+
* `index.d.ts`, and the behaviours were measured on a device.
|
|
3170
3169
|
*/
|
|
3171
3170
|
/** The three axes of a gizmo. */
|
|
3172
3171
|
const AXES = [
|
|
@@ -3252,11 +3251,11 @@ const MIN_OUTLINE_SIDE = .001;
|
|
|
3252
3251
|
* The gizmos and the outline live in core's render overlay (`app.renderer.openOverlay()`, ADR-0031),
|
|
3253
3252
|
* whose Lite scenes have the shape Lite's gizmo constructors take as a utility layer. Core draws it
|
|
3254
3253
|
* over the finished frame at every MSAA setting; Lite's own utility layer blacks out the scene or
|
|
3255
|
-
* draws nothing in an ignifx app
|
|
3254
|
+
* draws nothing in an ignifx app.
|
|
3256
3255
|
*
|
|
3257
3256
|
* A detached Lite gizmo keeps drawing at its last pose, so a hidden sub-gizmo is collapsed to zero
|
|
3258
|
-
* scale; Lite restores the scale when it is attached again
|
|
3259
|
-
* because Lite's bounding-box gizmo drags whatever is pressed inside it
|
|
3257
|
+
* scale; Lite restores the scale when it is attached again. The outline is a line box,
|
|
3258
|
+
* because Lite's bounding-box gizmo drags whatever is pressed inside it.
|
|
3260
3259
|
*
|
|
3261
3260
|
* @param handles - The app's Lite engine and render scene (`app.lite`).
|
|
3262
3261
|
* @param overlay - An open render overlay of the same app, which the view now owns.
|
|
@@ -3423,7 +3422,7 @@ function parentNode(node) {
|
|
|
3423
3422
|
*
|
|
3424
3423
|
* @remarks
|
|
3425
3424
|
* Walking `node.children` is not enough: a `Model` parents its cloned glTF root with a bare
|
|
3426
|
-
* `parent` assignment, which leaves the entity node's `children` empty
|
|
3425
|
+
* `parent` assignment, which leaves the entity node's `children` empty. So the scene's
|
|
3427
3426
|
* meshes are scanned and kept when their parent chain reaches the node, as Lite's own bounding-box
|
|
3428
3427
|
* gizmo does.
|
|
3429
3428
|
*
|
|
@@ -4453,10 +4452,10 @@ function collectComponents(entity, uids, into) {
|
|
|
4453
4452
|
//#endregion
|
|
4454
4453
|
//#region src/scene/defaults.ts
|
|
4455
4454
|
/**
|
|
4456
|
-
* Defaults that a script's hot reload changes
|
|
4457
|
-
*
|
|
4458
|
-
*
|
|
4459
|
-
*
|
|
4455
|
+
* Defaults that a script's hot reload changes: which fields of which component types took a new
|
|
4456
|
+
* default, and the live world brought in line with the document for them. A field a document
|
|
4457
|
+
* component's record leaves out takes the new default; a field it sets keeps its value; a prefab
|
|
4458
|
+
* instance whose members hold such a field is rebuilt from its prefab, with its overrides
|
|
4460
4459
|
* (`docs/architecture/17-editor-host.md` §6.1).
|
|
4461
4460
|
*/
|
|
4462
4461
|
/** Defaults hold no reference to anything in a file. */
|
|
@@ -4620,7 +4619,7 @@ const CLICK_SLOP_PX$1 = 4;
|
|
|
4620
4619
|
* Left drag orbits, middle drag pans, right drag looks around while W, A, S, D, Q and E fly (Shift
|
|
4621
4620
|
* for speed), the wheel dollies, and a left click is reported to `onClick`. The camera listens in
|
|
4622
4621
|
* the bubble phase, after Lite's gizmo dispatcher has seen the press in the capture phase, and it
|
|
4623
|
-
* yields to the gizmo by the three rules Lite documents for its own controls
|
|
4622
|
+
* yields to the gizmo by the three rules Lite documents for its own controls: no orbit
|
|
4624
4623
|
* starts on a hovered handle, a move is held while the press is still being picked, and an orbit
|
|
4625
4624
|
* stops once a gizmo drag begins.
|
|
4626
4625
|
*/
|
|
@@ -4885,7 +4884,7 @@ const SPRITE_RENDERER_TYPE = "ignifx/SpriteRenderer";
|
|
|
4885
4884
|
const TILEMAP_TYPE = "ignifx/Tilemap";
|
|
4886
4885
|
/**
|
|
4887
4886
|
* The wheel's zoom steps, in screen pixels per layer pixel (`Camera2D.zoom`): with a pixels-per-unit
|
|
4888
|
-
* equal to the art's, a source pixel spans a whole number of screen pixels from 1 up
|
|
4887
|
+
* equal to the art's, a source pixel spans a whole number of screen pixels from 1 up.
|
|
4889
4888
|
*/
|
|
4890
4889
|
const ZOOM_STEPS = [
|
|
4891
4890
|
.125,
|
|
@@ -5330,7 +5329,7 @@ function twoDLayersOf(app) {
|
|
|
5330
5329
|
//#endregion
|
|
5331
5330
|
//#region src/scene/editor-camera-2d.ts
|
|
5332
5331
|
/**
|
|
5333
|
-
* The scene view's 2D editor camera
|
|
5332
|
+
* The scene view's 2D editor camera: a script on the editor camera's entity that, while
|
|
5334
5333
|
* the view is in 2D mode, drives an editor-owned `Camera2D` that outranks the level's, and turns
|
|
5335
5334
|
* the 3D editor camera into a matching orthographic camera looking down +Z at the 2D plane, so
|
|
5336
5335
|
* the gizmo overlay and the 3D picker see what the sprites show. The level's own `Camera2D` is
|
|
@@ -5346,8 +5345,7 @@ const WHEEL_STEP_PX = 50;
|
|
|
5346
5345
|
* @remarks
|
|
5347
5346
|
* Middle drag, right drag, and left drag with Space held pan; the wheel zooms in pixel steps about
|
|
5348
5347
|
* the cursor; a left click is reported to `onClick`. A press on a gizmo handle is left to the
|
|
5349
|
-
* gizmo, by the same rule as the 3D camera
|
|
5350
|
-
* {@link EditorCamera2D.activate}.
|
|
5348
|
+
* gizmo, by the same rule as the 3D camera. It does nothing until {@link EditorCamera2D.activate}.
|
|
5351
5349
|
*/
|
|
5352
5350
|
var EditorCamera2D = class extends Script {
|
|
5353
5351
|
/** The type id; the host leaves it out of the schemas it reports. */
|
|
@@ -5596,8 +5594,8 @@ var EditorCamera2D = class extends Script {
|
|
|
5596
5594
|
//#endregion
|
|
5597
5595
|
//#region src/scene/editor-grid.ts
|
|
5598
5596
|
/**
|
|
5599
|
-
* The scene view's grid
|
|
5600
|
-
*
|
|
5597
|
+
* The scene view's grid: a script on the `Scene Grid` entity of the host's persistent `editor`
|
|
5598
|
+
* scene, which moves the grid with the editor camera every frame.
|
|
5601
5599
|
*/
|
|
5602
5600
|
/**
|
|
5603
5601
|
* Places the view's grid every frame, where {@link EditorGrid.placement} says.
|
|
@@ -5651,8 +5649,8 @@ function viewSurfaceOf(surface) {
|
|
|
5651
5649
|
}
|
|
5652
5650
|
/**
|
|
5653
5651
|
* Converts a `pick` point to the backing-store pixels `app.renderer.pickAsync` takes (protocol 0.3,
|
|
5654
|
-
* "The pick unit rule"
|
|
5655
|
-
*
|
|
5652
|
+
* "The pick unit rule"). This is the host's one conversion: the renderer converts on to the CSS
|
|
5653
|
+
* pixels Lite's picker wants.
|
|
5656
5654
|
*
|
|
5657
5655
|
* @param params - The point and its unit.
|
|
5658
5656
|
* @param surface - The canvas's sizes.
|
|
@@ -5778,8 +5776,8 @@ function snapTo(value, step) {
|
|
|
5778
5776
|
return step > 0 ? Math.round(value / step) * step : value;
|
|
5779
5777
|
}
|
|
5780
5778
|
/**
|
|
5781
|
-
* Snaps a gizmo drag after Lite has applied each move
|
|
5782
|
-
*
|
|
5779
|
+
* Snaps a gizmo drag after Lite has applied each move. The raw, unsnapped value is kept apart from
|
|
5780
|
+
* the node, so the snapped steps do not accumulate rounding.
|
|
5783
5781
|
*/
|
|
5784
5782
|
var DragSnapper = class {
|
|
5785
5783
|
#mode;
|
|
@@ -7891,8 +7889,8 @@ function sampleAnimation(app, mirror, params) {
|
|
|
7891
7889
|
//#endregion
|
|
7892
7890
|
//#region src/scene/sample-sprite-animation.ts
|
|
7893
7891
|
/**
|
|
7894
|
-
* `sampleSpriteAnimation`: the scene view shows one frame of a clip on an entity's
|
|
7895
|
-
*
|
|
7892
|
+
* `sampleSpriteAnimation`: the scene view shows one frame of a clip on an entity's
|
|
7893
|
+
* `SpriteAnimator`, through `@ignifx/2d`'s `SpriteAnimator.sample` and `sampleTime`. The host
|
|
7896
7894
|
* depends on core only, so it finds the `SpriteAnimator` by its type id and calls them by shape.
|
|
7897
7895
|
*/
|
|
7898
7896
|
/** The type id `@ignifx/2d` registers its `SpriteAnimator` under. */
|
|
@@ -7946,7 +7944,7 @@ const COMPONENTS_FORMAT = "components";
|
|
|
7946
7944
|
* neither is titled from its type id. The host's own classes are left out: they are not the
|
|
7947
7945
|
* document's. `ignifx/Transform` is described with core's `transformSchema()` and carries
|
|
7948
7946
|
* `builtIn`: its fields are each entity's `transform` block, edited with `setTransform`, and it is
|
|
7949
|
-
* never added or removed. Each component also carries `extends
|
|
7947
|
+
* never added or removed. Each component also carries `extends`: the registered
|
|
7950
7948
|
* components its class derives from, which count as present for a `requires` entry.
|
|
7951
7949
|
*
|
|
7952
7950
|
* The set is read from the live registry each time, so a hot reload that adds a field or a script
|
|
@@ -8077,9 +8075,9 @@ function settingsSet(app) {
|
|
|
8077
8075
|
//#endregion
|
|
8078
8076
|
//#region src/scene/thumbnails.ts
|
|
8079
8077
|
/**
|
|
8080
|
-
* `renderThumbnail
|
|
8081
|
-
*
|
|
8082
|
-
*
|
|
8078
|
+
* `renderThumbnail`: a model, prefab or material rendered on its own, in a second app the host
|
|
8079
|
+
* keeps for the purpose, through `app.renderer.renderToTexture`; a sprite atlas or an image drawn
|
|
8080
|
+
* from its decoded image, fitted in the square on a transparent background.
|
|
8083
8081
|
*
|
|
8084
8082
|
* The stage is a separate app on a 1x1 `OffscreenCanvas`, built from the project's own options, so
|
|
8085
8083
|
* a thumbnail never shows the open document, never lights it, and is never lit by it. It is
|
|
@@ -9022,10 +9020,10 @@ var SceneHost = class {
|
|
|
9022
9020
|
return rebuilt;
|
|
9023
9021
|
}
|
|
9024
9022
|
/**
|
|
9025
|
-
* Gives the open document the defaults a hot reload changed, where it leaves them out
|
|
9026
|
-
*
|
|
9027
|
-
*
|
|
9028
|
-
*
|
|
9023
|
+
* Gives the open document the defaults a hot reload changed, where it leaves them out: each
|
|
9024
|
+
* document component's omitted fields take the new default, then each prefab instance whose
|
|
9025
|
+
* members hold a changed type is rebuilt from its prefab with its overrides. A component that
|
|
9026
|
+
* throws while taking a default is a `hostError`, and the rest still runs.
|
|
9029
9027
|
*
|
|
9030
9028
|
* @param changed - The changed fields, by type id.
|
|
9031
9029
|
*/
|
|
@@ -10043,8 +10041,8 @@ function appOptions(options) {
|
|
|
10043
10041
|
//#endregion
|
|
10044
10042
|
//#region src/play-input.ts
|
|
10045
10043
|
/**
|
|
10046
|
-
* The play view's `sendInput
|
|
10047
|
-
*
|
|
10044
|
+
* The play view's `sendInput`: synthetic key and pointer events queued into the game's own
|
|
10045
|
+
* `app.input`, the way headless tests drive the engine. The host does not depend on
|
|
10048
10046
|
* `@ignifx/input`: it finds `app.input` by name and calls `simulateEvent` by shape, as it reaches
|
|
10049
10047
|
* `app.twoD` (`./scene/view-2d.ts`). Nothing here dispatches a DOM event or touches the editor.
|
|
10050
10048
|
*/
|
|
@@ -10169,9 +10167,9 @@ var PlayInput = class {
|
|
|
10169
10167
|
//#endregion
|
|
10170
10168
|
//#region src/play-query.ts
|
|
10171
10169
|
/**
|
|
10172
|
-
* The play view's `queryRuntime
|
|
10173
|
-
*
|
|
10174
|
-
*
|
|
10170
|
+
* The play view's `queryRuntime`: one entity of the running game, as the scene format writes it,
|
|
10171
|
+
* read through core's `serializeEntity`, each value capped and the whole answer kept within
|
|
10172
|
+
* `QUERY_RUNTIME_MAX_JSON_LENGTH`.
|
|
10175
10173
|
*/
|
|
10176
10174
|
/** How deep a capped JSON value may nest; deeper values become `null`, as `isJsonValue` allows 256. */
|
|
10177
10175
|
const MAX_JSON_DEPTH = 256;
|