@vgai/engine 0.5.25 → 0.5.26
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/adapter/adapter-module.d.ts +10 -9
- package/dist/adapter/adapter-module.d.ts.map +1 -1
- package/dist/adapter/adapter-module.js +9 -10
- package/dist/adapter/binding.d.ts +4 -2
- package/dist/adapter/binding.d.ts.map +1 -1
- package/dist/adapter/binding.js +1 -1
- package/dist/adapter/index.d.ts +2 -2
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/adapter/index.js +1 -1
- package/dist/adapter/ingest/structural-ids.d.ts +1 -1
- package/dist/adapter/ingest/structural-ids.js +1 -1
- package/dist/adapter/root-adapter.d.ts +31 -9
- package/dist/adapter/root-adapter.d.ts.map +1 -1
- package/dist/adapter/root-seam-contract.d.ts +6 -1
- package/dist/adapter/root-seam-contract.d.ts.map +1 -1
- package/dist/adapter/root-seam-contract.js +2 -1
- package/dist/adapter/system-adapter.d.ts +10 -0
- package/dist/adapter/system-adapter.d.ts.map +1 -1
- package/dist/ai/navigation.d.ts +11 -0
- package/dist/ai/navigation.d.ts.map +1 -1
- package/dist/ai/navigation.js +11 -0
- package/dist/canvas-react/pixi-react-root-factory.d.ts.map +1 -1
- package/dist/canvas-react/pixi-react-root-factory.js +12 -3
- package/dist/pixi/authoring.d.ts +3 -3
- package/dist/pixi/authoring.d.ts.map +1 -1
- package/dist/pixi/authoring.js +2 -2
- package/dist/runtime/create-runtime.d.ts +12 -11
- package/dist/runtime/create-runtime.d.ts.map +1 -1
- package/dist/runtime/create-runtime.js +16 -15
- package/dist/runtime/game.d.ts +10 -12
- package/dist/runtime/game.d.ts.map +1 -1
- package/dist/runtime/game.js +12 -15
- package/dist/runtime/render-control.d.ts.map +1 -1
- package/dist/runtime/render-control.js +6 -1
- package/package.json +1 -1
- package/src/adapter/adapter-module.ts +12 -13
- package/src/adapter/binding.ts +4 -2
- package/src/adapter/index.ts +3 -1
- package/src/adapter/ingest/structural-ids.ts +1 -1
- package/src/adapter/root-adapter.ts +31 -9
- package/src/adapter/root-seam-contract.ts +4 -3
- package/src/adapter/system-adapter.ts +10 -0
- package/src/ai/navigation.ts +24 -0
- package/src/canvas-react/pixi-react-root-factory.tsx +17 -3
- package/src/pixi/authoring.ts +3 -3
- package/src/runtime/create-runtime.ts +27 -26
- package/src/runtime/game.ts +21 -30
- package/src/runtime/render-control.ts +6 -1
package/dist/pixi/authoring.js
CHANGED
|
@@ -583,7 +583,7 @@ export class AuthoringAdapter2D {
|
|
|
583
583
|
* it into the in-memory overlay so a later `serializeOverlay()`/save preserves it
|
|
584
584
|
* and a later `refresh()` re-applies it again. Ids absent from the current tree
|
|
585
585
|
* are skipped (orphaned, not an error) — the 2D analog of
|
|
586
|
-
* `
|
|
586
|
+
* `ThreeAuthoringAdapter.applyOverlay` (T3.2 slice 3). Used both for the initial
|
|
587
587
|
* reload (constructor `opts.overlay`) and for `PersistenceProvider.applyExternal`
|
|
588
588
|
* (re-apply a changed overlay file without a full remount).
|
|
589
589
|
*/
|
|
@@ -614,7 +614,7 @@ export class AuthoringAdapter2D {
|
|
|
614
614
|
this.applyOverride(id, ov);
|
|
615
615
|
this.dirty = true;
|
|
616
616
|
}
|
|
617
|
-
/** Clear the dirty flag after a successful save (mirrors
|
|
617
|
+
/** Clear the dirty flag after a successful save (mirrors ThreeAuthoringAdapter). */
|
|
618
618
|
markClean() {
|
|
619
619
|
this.dirty = false;
|
|
620
620
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RootDeclaration } from '../adapter/binding';
|
|
2
2
|
import type { DomHostContext } from '../adapter/host-context';
|
|
3
|
-
import type {
|
|
3
|
+
import type { MountedCanvasRoot, MountedReactRoot, MountedThreeRoot, RootAdapter } from '../adapter/root-adapter';
|
|
4
4
|
import { type Game, type GameInternal, type RootInstance } from './game';
|
|
5
5
|
import type { PlaytestContext } from './playtest';
|
|
6
6
|
/**
|
|
@@ -23,22 +23,23 @@ export interface RegisterRootOptions {
|
|
|
23
23
|
readonly declaration?: RootDeclaration | undefined;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Register a canvas world onto the Game shell — the
|
|
26
|
+
* Register a canvas world onto the Game shell — the canvas analog of
|
|
27
27
|
* {@link registerThreeRoot}. `adapter` is the seam's own
|
|
28
28
|
* `RootAdapter<'canvas'>`; `RootInstance.adapter` itself only needs `.id`
|
|
29
29
|
* (`AdapterHandle`, `runtime/game.ts`), so this passes through with zero cast.
|
|
30
|
-
*
|
|
30
|
+
* The substrate root remains opaque here; the editor dispatches from the
|
|
31
|
+
* mount's explicit `substrate.name` declaration.
|
|
31
32
|
*/
|
|
32
|
-
export declare function
|
|
33
|
+
export declare function registerCanvasRoot(game: GameInternal, adapter: RootAdapter<'canvas'>, mounted: MountedCanvasRoot, opts?: RegisterRootOptions): RootInstance;
|
|
33
34
|
/**
|
|
34
35
|
* Register a React world onto the Game shell — the DOM
|
|
35
|
-
* analog of {@link registerThreeRoot}/{@link
|
|
36
|
+
* analog of {@link registerThreeRoot}/{@link registerCanvasRoot}. A react
|
|
36
37
|
* world has no `frame` hooks (react's own
|
|
37
38
|
* `createRoot` schedules its commits; `GameInternal.runFrame` correctly
|
|
38
39
|
* leaves a world with no `frame` untouched by its opaque-`update` fallback
|
|
39
40
|
* too, since `MountedReactGame` declares no `update`). `adapter` is typed
|
|
40
41
|
* as the real {@link ReactRootAdapter} shape (same reasoning as
|
|
41
|
-
* `
|
|
42
|
+
* `registerCanvasRoot`'s doc comment above) — `RootInstance.adapter` only
|
|
42
43
|
* needs `.id`, so this passes through with zero cast.
|
|
43
44
|
*/
|
|
44
45
|
export declare function registerReactRoot(game: GameInternal, adapter: RootAdapter<'dom'>, mounted: MountedReactRoot, container: HTMLElement, opts?: RegisterRootOptions): RootInstance;
|
|
@@ -83,10 +84,10 @@ export interface ThreeRootMountSpec extends RootMountSpecBase {
|
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
85
86
|
* `adapter` is the SEAM's `RootAdapter<'canvas'>` — a canvas root's mount
|
|
86
|
-
* honestly returns
|
|
87
|
+
* honestly returns a `MountedCanvasRoot`, and naming the real contract
|
|
87
88
|
* here is what keeps the resolver cast-free.
|
|
88
89
|
*/
|
|
89
|
-
export interface
|
|
90
|
+
export interface CanvasRootMountSpec extends RootMountSpecBase {
|
|
90
91
|
readonly kind: 'canvas';
|
|
91
92
|
readonly adapter: RootAdapter<'canvas'>;
|
|
92
93
|
}
|
|
@@ -114,7 +115,7 @@ export interface PixiRootMountSpec extends RootMountSpecBase {
|
|
|
114
115
|
* `kind`/`container` satisfy `MountedReactRoot` (`adapter/
|
|
115
116
|
* root-adapter.ts`) — `container` is the SAME `DomHostContext.container` the
|
|
116
117
|
* adapter's `mount` was handed (identity matters, mirroring `threeScene()`/
|
|
117
|
-
* `
|
|
118
|
+
* `canvasRoot()`'s "same instance the adapter mounted" contract); every
|
|
118
119
|
* `ReactRootAdapter` implementer echoes it back here so `mounted` alone
|
|
119
120
|
* (with no separately-threaded `container`) satisfies the union
|
|
120
121
|
* `RootInstanceInit.mounted`/`RootInstance.mounted` with zero cast.
|
|
@@ -137,13 +138,13 @@ export interface ReactRootAdapter extends RootAdapter<'dom'> {
|
|
|
137
138
|
readonly id: string;
|
|
138
139
|
mount(host: DomHostContext): Promise<MountedReactGame>;
|
|
139
140
|
}
|
|
140
|
-
/** Same reasoning as {@link
|
|
141
|
+
/** Same reasoning as {@link CanvasRootMountSpec} above: the seam's
|
|
141
142
|
* `RootAdapter<'dom'>` is what a DOM root actually guarantees. */
|
|
142
143
|
export interface ReactRootMountSpec extends RootMountSpecBase {
|
|
143
144
|
readonly kind: 'dom';
|
|
144
145
|
readonly adapter: RootAdapter<'dom'>;
|
|
145
146
|
}
|
|
146
|
-
export type RootMountSpec = ThreeRootMountSpec |
|
|
147
|
+
export type RootMountSpec = ThreeRootMountSpec | CanvasRootMountSpec | ReactRootMountSpec;
|
|
147
148
|
/**
|
|
148
149
|
* Mount N adapter roots (three + canvas + react)
|
|
149
150
|
* on ONE `Game`, stacked in `container` per D5 §1.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/create-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuC,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,KAAK,EAAqB,cAAc,EAAoB,MAAM,yBAAyB,CAAC;AACnG,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"create-runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/create-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuC,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,KAAK,EAAqB,cAAc,EAAoB,MAAM,yBAAyB,CAAC;AACnG,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAEhB,gBAAgB,EAChB,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AAQjC,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,QAAQ,CAAC;AAEhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE,mBAAmB,GACzB,YAAY,CAsBd;AAED,wEAAwE;AACxE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;CACpD;AAyBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,I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AC;KACvD,GACD,SAAS,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,IAAI,IAAI,CAAC;IACb,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;IACf,IAAI,IAAI,IAAI,CAAC;IACb;gDAC4C;IAC5C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjE;iEAC6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAExF"}
|
|
@@ -51,13 +51,14 @@ function bindRoot(game, declaration, adapter, mounted, pausable) {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* Register a canvas world onto the Game shell — the
|
|
54
|
+
* Register a canvas world onto the Game shell — the canvas analog of
|
|
55
55
|
* {@link registerThreeRoot}. `adapter` is the seam's own
|
|
56
56
|
* `RootAdapter<'canvas'>`; `RootInstance.adapter` itself only needs `.id`
|
|
57
57
|
* (`AdapterHandle`, `runtime/game.ts`), so this passes through with zero cast.
|
|
58
|
-
*
|
|
58
|
+
* The substrate root remains opaque here; the editor dispatches from the
|
|
59
|
+
* mount's explicit `substrate.name` declaration.
|
|
59
60
|
*/
|
|
60
|
-
export function
|
|
61
|
+
export function registerCanvasRoot(game, adapter, mounted, opts) {
|
|
61
62
|
const id = opts?.id ?? 'main';
|
|
62
63
|
const pausable = opts?.pausable ?? true;
|
|
63
64
|
const world = createRootInstance({
|
|
@@ -66,7 +67,7 @@ export function registerPixiRoot(game, adapter, mounted, opts) {
|
|
|
66
67
|
pausable,
|
|
67
68
|
adapter,
|
|
68
69
|
mounted,
|
|
69
|
-
|
|
70
|
+
canvasRoot: mounted.substrate.root,
|
|
70
71
|
binding: bindRoot(game, opts?.declaration, { surface: 'canvas', adapter }, mounted, pausable),
|
|
71
72
|
});
|
|
72
73
|
game.registerRoot(world);
|
|
@@ -74,13 +75,13 @@ export function registerPixiRoot(game, adapter, mounted, opts) {
|
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
76
77
|
* Register a React world onto the Game shell — the DOM
|
|
77
|
-
* analog of {@link registerThreeRoot}/{@link
|
|
78
|
+
* analog of {@link registerThreeRoot}/{@link registerCanvasRoot}. A react
|
|
78
79
|
* world has no `frame` hooks (react's own
|
|
79
80
|
* `createRoot` schedules its commits; `GameInternal.runFrame` correctly
|
|
80
81
|
* leaves a world with no `frame` untouched by its opaque-`update` fallback
|
|
81
82
|
* too, since `MountedReactGame` declares no `update`). `adapter` is typed
|
|
82
83
|
* as the real {@link ReactRootAdapter} shape (same reasoning as
|
|
83
|
-
* `
|
|
84
|
+
* `registerCanvasRoot`'s doc comment above) — `RootInstance.adapter` only
|
|
84
85
|
* needs `.id`, so this passes through with zero cast.
|
|
85
86
|
*/
|
|
86
87
|
export function registerReactRoot(game, adapter, mounted, container, opts) {
|
|
@@ -169,7 +170,7 @@ function disposeMountedRoot(entry, container) {
|
|
|
169
170
|
/** Mount one three `RootMountSpec` (canvas + renderer construction, per
|
|
170
171
|
* D5 §1/§4, then `registerThreeRoot`). Split out of
|
|
171
172
|
* `createRootsGameRuntime` purely to keep that function's own branching
|
|
172
|
-
* simple — see `
|
|
173
|
+
* simple — see `mountOneCanvasRoot` for the canvas sibling. */
|
|
173
174
|
async function mountOneThreeRoot(spec, ctx) {
|
|
174
175
|
const { game, canvas, w, h, dpr, isBottom, headless, assets, antialias } = ctx;
|
|
175
176
|
const renderer = headless
|
|
@@ -230,7 +231,7 @@ async function mountOneThreeRoot(spec, ctx) {
|
|
|
230
231
|
};
|
|
231
232
|
}
|
|
232
233
|
/** Mount one canvas `RootMountSpec` (via its own `CanvasHostContext`, per D5
|
|
233
|
-
* §1/§3/§4, then `
|
|
234
|
+
* §1/§3/§4, then `registerCanvasRoot`) — the canvas sibling of
|
|
234
235
|
* `mountOneThreeRoot` above.
|
|
235
236
|
*
|
|
236
237
|
* Unlike `mountOneThreeRoot`, this needs no explicit `canvas.style.width`/
|
|
@@ -247,7 +248,7 @@ async function mountOneThreeRoot(spec, ctx) {
|
|
|
247
248
|
* already calls `session.resize()` unconditionally right after mount, so
|
|
248
249
|
* this never surfaces as a lasting bug the way three' buffer-only resize
|
|
249
250
|
* did (never self-healing, by design — see above). */
|
|
250
|
-
async function
|
|
251
|
+
async function mountOneCanvasRoot(spec, ctx) {
|
|
251
252
|
const { game, canvas, w, h, dpr, headless, isBottom } = ctx;
|
|
252
253
|
const pixiHost = {
|
|
253
254
|
canvas,
|
|
@@ -260,7 +261,7 @@ async function mountOnePixiRoot(spec, ctx) {
|
|
|
260
261
|
preserveDrawingBuffer: true,
|
|
261
262
|
};
|
|
262
263
|
const mounted = await spec.adapter.mount(pixiHost);
|
|
263
|
-
|
|
264
|
+
registerCanvasRoot(game, spec.adapter, mounted, {
|
|
264
265
|
id: spec.id,
|
|
265
266
|
pausable: spec.pausable,
|
|
266
267
|
declaration: spec.declaration,
|
|
@@ -283,7 +284,7 @@ async function mountOnePixiRoot(spec, ctx) {
|
|
|
283
284
|
}
|
|
284
285
|
/**
|
|
285
286
|
* Mount one React `RootMountSpec` — the DOM sibling of
|
|
286
|
-
* `mountOneThreeRoot`/`
|
|
287
|
+
* `mountOneThreeRoot`/`mountOneCanvasRoot`. Unlike its canvas-backed siblings
|
|
287
288
|
* this returns NO `routerEntry`: a react world's DOM-root layer participates in
|
|
288
289
|
* D5's z-order/box stacking (the caller still creates and positions its `<div>`
|
|
289
290
|
* exactly like a canvas — see `createRootsGameRuntime`'s stack-building loop)
|
|
@@ -338,7 +339,7 @@ layer) {
|
|
|
338
339
|
* canvas for three/canvas, a DOM-root `<div>` layer for react — stacked
|
|
339
340
|
* per D5 §1, z-order/ties exactly matching
|
|
340
341
|
* `manifest/load.ts`'s sort, ONE `Game`, and registers every world onto it
|
|
341
|
-
* via `registerThreeRoot`/`
|
|
342
|
+
* via `registerThreeRoot`/`registerCanvasRoot`/`registerReactRoot` — the
|
|
342
343
|
* SAME wiring `test/create-runtime-worlds.test.ts` proves for the
|
|
343
344
|
* three/canvas pair. Worlds MOUNT in `roots` ARRAY order ("manifest
|
|
344
345
|
* declaration order" — the frame/registration axis), independent of
|
|
@@ -387,7 +388,7 @@ function installDefaultRootDevGlobals(game) {
|
|
|
387
388
|
* Mount + register every world spec, in ARRAY (declaration) order — split
|
|
388
389
|
* out of `createRootsGameRuntime` purely to keep that function's own
|
|
389
390
|
* cyclomatic complexity down (E4, same reason `mountOneThreeRoot`/
|
|
390
|
-
* `
|
|
391
|
+
* `mountOneCanvasRoot` are already split out). React roots contribute NO
|
|
391
392
|
* router entry ("DOM layers need no entry in the router's hit-test loop"):
|
|
392
393
|
* their layer's own `pointer-events` discipline handles claim/fall-through
|
|
393
394
|
* natively, with zero router involvement (see `mountOneReactRoot`'s doc
|
|
@@ -414,7 +415,7 @@ async function mountAllRootSpecs(mountSpecs, bottomId, inputs) {
|
|
|
414
415
|
({ mountedEntry, routerEntry } = await mountOneThreeRoot(spec, oneCtx));
|
|
415
416
|
}
|
|
416
417
|
else if (spec.kind === 'canvas') {
|
|
417
|
-
({ mountedEntry, routerEntry } = await
|
|
418
|
+
({ mountedEntry, routerEntry } = await mountOneCanvasRoot(spec, oneCtx));
|
|
418
419
|
}
|
|
419
420
|
else {
|
|
420
421
|
// Exhaustiveness guard (§7.4-2): 'react' was already handled by the
|
|
@@ -636,7 +637,7 @@ async function createRootsGameRuntime(config) {
|
|
|
636
637
|
// --- Mount + register every world, in ARRAY (declaration) order. ---
|
|
637
638
|
// Split out into its own top-level function purely to keep
|
|
638
639
|
// `createRootsGameRuntime`'s own cyclomatic complexity down (E4) — same
|
|
639
|
-
// reason `mountOneThreeRoot`/`
|
|
640
|
+
// reason `mountOneThreeRoot`/`mountOneCanvasRoot` are already split out
|
|
640
641
|
// below.
|
|
641
642
|
let mounted;
|
|
642
643
|
try {
|
package/dist/runtime/game.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* system runner, state bridge, debug registry, clock, and seeded RNG. Each
|
|
5
5
|
* RootInstance retains its own mounted surface and optional capabilities.
|
|
6
6
|
*/
|
|
7
|
-
import type * as PIXI from 'pixi.js';
|
|
8
7
|
import type * as THREE from 'three';
|
|
9
8
|
import type { AdapterSurface as AdapterSurfaceLeaf } from '../adapter/adapter-surface';
|
|
10
9
|
import type { RootBinding } from '../adapter/binding';
|
|
@@ -141,21 +140,20 @@ export interface RootInstance {
|
|
|
141
140
|
* gain — see `AdapterHandle` below. */
|
|
142
141
|
readonly adapter: AdapterHandle;
|
|
143
142
|
/** The live mounted surface — one of `MountedRoot`'s kind-tagged shapes
|
|
144
|
-
* (T7.5; `MountedThreeRoot` for a three world, `
|
|
143
|
+
* (T7.5; `MountedThreeRoot` for a three world, `MountedCanvasRoot` for
|
|
145
144
|
* canvas, `MountedReactRoot` for react). */
|
|
146
145
|
readonly mounted: MountedRoot;
|
|
147
146
|
/** Kind-narrowed accessor: throws a descriptive error when this world is
|
|
148
147
|
* not a three world. */
|
|
149
148
|
threeScene(): THREE.Scene;
|
|
150
|
-
/** Kind-narrowed accessor for canvas roots
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
|
|
154
|
-
pixiStage(): PIXI.Container;
|
|
149
|
+
/** Kind-narrowed accessor for canvas roots: returns the native substrate
|
|
150
|
+
* root the adapter mounted. The host keeps it opaque; a substrate adapter
|
|
151
|
+
* that declared the matching name narrows `T`. */
|
|
152
|
+
canvasRoot<T = unknown>(): T;
|
|
155
153
|
/** Kind-narrowed accessor for DOM roots: returns the
|
|
156
154
|
* DOM-root layer `<div>` the host mounted this world's react tree into
|
|
157
155
|
* (the SAME element passed as `container` to `createRootInstance` —
|
|
158
|
-
* identity matters, mirroring `threeScene()`/`
|
|
156
|
+
* identity matters, mirroring `threeScene()`/`canvasRoot()`'s "same
|
|
159
157
|
* instance the adapter mounted" contract). Throws descriptively for a
|
|
160
158
|
* non-react world, or a react world built without a `container` (see
|
|
161
159
|
* `RootInstanceInit.container`). */
|
|
@@ -234,9 +232,9 @@ export interface RootInstanceInit {
|
|
|
234
232
|
readonly mounted: MountedRoot;
|
|
235
233
|
/** Required when `kind === 'three'` — backs `threeScene()`. */
|
|
236
234
|
readonly scene?: THREE.Scene | undefined;
|
|
237
|
-
/** Required when `kind === 'canvas'` — backs `
|
|
238
|
-
*
|
|
239
|
-
readonly
|
|
235
|
+
/** Required when `kind === 'canvas'` — backs `canvasRoot()`, symmetric with
|
|
236
|
+
* `scene` for three above. */
|
|
237
|
+
readonly canvasRoot?: unknown;
|
|
240
238
|
/** Required when `kind === 'dom'` — backs `reactRoot()` (T6.2 slice 1,
|
|
241
239
|
* symmetric with `scene`/`stage` above): the DOM-root layer `<div>` this
|
|
242
240
|
* world's react tree is mounted into. */
|
|
@@ -253,7 +251,7 @@ export interface RootInstanceInit {
|
|
|
253
251
|
/**
|
|
254
252
|
* Build a `RootInstance` whose kind-narrowed accessors throw descriptively
|
|
255
253
|
* on kind mismatch. This is the one place that builds
|
|
256
|
-
* `threeScene`/`
|
|
254
|
+
* `threeScene`/`canvasRoot`, so every world (however it's constructed, in this
|
|
257
255
|
* slice or later ones) gets identical throw behavior.
|
|
258
256
|
*/
|
|
259
257
|
export declare function createRootInstance(init: RootInstanceInit): RootInstance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../src/runtime/game.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../src/runtime/game.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,KAAK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AS,EAAE,MAAM,GAAG,IAAI,CAAC;IACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0DG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAClD;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,0EAA0E;IAC1E,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAC/B,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C;;;;;;;;;kDAS8C;IAC9C,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,GAAG,YAAY,CAo1Bf"}
|
package/dist/runtime/game.js
CHANGED
|
@@ -27,11 +27,11 @@ const DISPLAY_RATE_PHASES = PHASE_ORDER.filter((phase) => phase === SystemPhase.
|
|
|
27
27
|
/**
|
|
28
28
|
* Build a `RootInstance` whose kind-narrowed accessors throw descriptively
|
|
29
29
|
* on kind mismatch. This is the one place that builds
|
|
30
|
-
* `threeScene`/`
|
|
30
|
+
* `threeScene`/`canvasRoot`, so every world (however it's constructed, in this
|
|
31
31
|
* slice or later ones) gets identical throw behavior.
|
|
32
32
|
*/
|
|
33
33
|
export function createRootInstance(init) {
|
|
34
|
-
const { id, kind, pausable = true, adapter, mounted, scene,
|
|
34
|
+
const { id, kind, pausable = true, adapter, mounted, scene, canvasRoot, container, physics, collisions, physics2d, camera, frame, binding = null, } = init;
|
|
35
35
|
// A three world with no scene has nothing for `threeScene()` to return —
|
|
36
36
|
// fail loudly HERE, at construction, rather than letting `threeScene()`
|
|
37
37
|
// throw its generic "not a three world" message later for a world whose
|
|
@@ -40,12 +40,12 @@ export function createRootInstance(init) {
|
|
|
40
40
|
throw new Error(`RootInstance "${id}" (kind: three): a three world requires a scene — ` +
|
|
41
41
|
'pass `scene` in RootInstanceInit.');
|
|
42
42
|
}
|
|
43
|
-
// Symmetric check for canvas
|
|
44
|
-
// has nothing for `
|
|
43
|
+
// Symmetric check for canvas — a canvas world with no native substrate root
|
|
44
|
+
// has nothing for `canvasRoot()` to return; fail loudly here, at
|
|
45
45
|
// construction, same as the three/scene check above.
|
|
46
|
-
if (kind === 'canvas' &&
|
|
47
|
-
throw new Error(`RootInstance "${id}" (kind: canvas): a canvas world requires a
|
|
48
|
-
'pass `
|
|
46
|
+
if (kind === 'canvas' && (canvasRoot === undefined || canvasRoot === null)) {
|
|
47
|
+
throw new Error(`RootInstance "${id}" (kind: canvas): a canvas world requires a native substrate root — ` +
|
|
48
|
+
'pass `canvasRoot` in RootInstanceInit.');
|
|
49
49
|
}
|
|
50
50
|
// Symmetric check for react (T6.2 slice 1) — a react world with no
|
|
51
51
|
// container has nothing for `reactRoot()` to return; fail loudly here,
|
|
@@ -111,21 +111,18 @@ export function createRootInstance(init) {
|
|
|
111
111
|
}
|
|
112
112
|
return scene;
|
|
113
113
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// with no `stage`, symmetric with `threeScene()`'s `scene` guard.
|
|
118
|
-
if (kind !== 'canvas' || !stage) {
|
|
119
|
-
throw new Error(`RootInstance "${id}" (kind: ${kind}): pixiStage() requested but this world is not ` +
|
|
114
|
+
canvasRoot() {
|
|
115
|
+
if (kind !== 'canvas' || canvasRoot === undefined || canvasRoot === null) {
|
|
116
|
+
throw new Error(`RootInstance "${id}" (kind: ${kind}): canvasRoot() requested but this world is not ` +
|
|
120
117
|
'a canvas world');
|
|
121
118
|
}
|
|
122
|
-
return
|
|
119
|
+
return canvasRoot;
|
|
123
120
|
},
|
|
124
121
|
reactRoot() {
|
|
125
122
|
// The `!container` branch a react world could hit here is now
|
|
126
123
|
// unreachable (T6.2 slice 1): construction above throws for
|
|
127
124
|
// `kind === 'dom'` with no `container`, symmetric with
|
|
128
|
-
// `threeScene()`/`
|
|
125
|
+
// `threeScene()`/`canvasRoot()`'s guards.
|
|
129
126
|
if (kind !== 'dom' || !container) {
|
|
130
127
|
throw new Error(`RootInstance "${id}" (kind: ${kind}): reactRoot() requested but this world is not ` +
|
|
131
128
|
'a react world');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-control.d.ts","sourceRoot":"","sources":["../../src/runtime/render-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,KAAK,EAAQ,YAAY,EAAkB,MAAM,QAAQ,CAAC;AAGjE;;;;uEAIuE;AACvE,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,gBAAgB,GAAG,OAAO,CAAC;AAEnE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;iDAEiD;AACjD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAA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D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD;;;;;yBAKqB;IACrB,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACnD;;;;;;;;;OASG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;;;;;OAOG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtD;AAED;;mEAEmE;AACnE,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAEpF;AAiND;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,2BAA2B,GAChC,iBAAiB,GAAG,SAAS,CA+D/B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CASlF"}
|
|
@@ -159,7 +159,12 @@ function countRoots(game) {
|
|
|
159
159
|
counts.push({ id: world.id, kind: world.kind, ...countRootGraph(world.threeScene()) });
|
|
160
160
|
}
|
|
161
161
|
else if (world.kind === 'canvas') {
|
|
162
|
-
|
|
162
|
+
// Node counting is a substrate projection, not a surface fact. Pixi's
|
|
163
|
+
// native tree exposes `children`; other canvas substrates are omitted
|
|
164
|
+
// until their adapter declares an honest counter.
|
|
165
|
+
if (world.mounted.kind === 'canvas' && world.mounted.substrate.name === 'pixi') {
|
|
166
|
+
counts.push({ id: world.id, kind: world.kind, ...countRootGraph(world.canvasRoot()) });
|
|
167
|
+
}
|
|
163
168
|
}
|
|
164
169
|
}
|
|
165
170
|
return counts;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@vgai/engine",
|
|
3
3
|
"author": "Volter AI, Inc.",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.5.
|
|
5
|
+
"version": "0.5.26",
|
|
6
6
|
"description": "Readable TypeScript game engine and universal host for Three.js, PixiJS, and React games.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"game-engine",
|
|
@@ -51,13 +51,12 @@ import { WRITE_ANCHOR_KINDS, type WriteAnchorKind } from './authoring';
|
|
|
51
51
|
// ---------------------------------------------------------------------------
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* The
|
|
55
|
-
* (
|
|
56
|
-
*
|
|
57
|
-
* library serves the region; the host binds the implementation.
|
|
54
|
+
* The native substrate serving a region. A surface is only the host-provided
|
|
55
|
+
* medium (`canvas`); this declaration is what distinguishes Pixi, Babylon and
|
|
56
|
+
* Phaser without runtime sniffing.
|
|
58
57
|
*/
|
|
59
|
-
export const
|
|
60
|
-
export type
|
|
58
|
+
export const SUBSTRATE_NAMES = ['three', 'pixi', 'dom', 'babylon', 'phaser'] as const;
|
|
59
|
+
export type SubstrateName = (typeof SUBSTRATE_NAMES)[number];
|
|
61
60
|
|
|
62
61
|
/**
|
|
63
62
|
* A region's WORLD BASIS — which axis points up, and where its ground sits.
|
|
@@ -100,8 +99,8 @@ export interface AdapterRegion {
|
|
|
100
99
|
readonly id: string;
|
|
101
100
|
/** What the host hands this root. */
|
|
102
101
|
readonly surface: AdapterSurface;
|
|
103
|
-
/**
|
|
104
|
-
readonly
|
|
102
|
+
/** Native substrate, by name. */
|
|
103
|
+
readonly substrate: SubstrateName;
|
|
105
104
|
/**
|
|
106
105
|
* Dialect writer, by name (`r3f`, `jsx`, `pixi-react`, …) — the truth
|
|
107
106
|
* family's source writer for this region. `null` states outright that the
|
|
@@ -223,7 +222,7 @@ const AdapterRegionSchema = z
|
|
|
223
222
|
.object({
|
|
224
223
|
id: z.string().min(1).describe('Manifest root id this region grades'),
|
|
225
224
|
surface: z.enum(['three', 'canvas', 'dom']).describe('Render surface the host hands this root'),
|
|
226
|
-
|
|
225
|
+
substrate: z.enum(SUBSTRATE_NAMES).describe('Native substrate serving this region, by name'),
|
|
227
226
|
dialect: z
|
|
228
227
|
.string()
|
|
229
228
|
.min(1)
|
|
@@ -412,13 +411,13 @@ export function unmatchedRegionIncludeIds(
|
|
|
412
411
|
function derivedRegion(root: ResolvedAdapterRoot): AdapterRegion {
|
|
413
412
|
const surface = root.surface;
|
|
414
413
|
const firstParty = root.adapter.type === 'builtin';
|
|
415
|
-
const
|
|
414
|
+
const substrate: SubstrateName = surface === 'canvas' ? 'pixi' : surface;
|
|
416
415
|
const basis = NATIVE_REGION_BASIS;
|
|
417
416
|
if (!firstParty) {
|
|
418
417
|
return {
|
|
419
418
|
id: root.id,
|
|
420
419
|
surface,
|
|
421
|
-
|
|
420
|
+
substrate,
|
|
422
421
|
dialect: null,
|
|
423
422
|
anchors: ['live-only'] as const,
|
|
424
423
|
basis,
|
|
@@ -428,7 +427,7 @@ function derivedRegion(root: ResolvedAdapterRoot): AdapterRegion {
|
|
|
428
427
|
return {
|
|
429
428
|
id: root.id,
|
|
430
429
|
surface,
|
|
431
|
-
|
|
430
|
+
substrate,
|
|
432
431
|
dialect: 'jsx',
|
|
433
432
|
anchors: ['source-prop', 'source-structure'] as const,
|
|
434
433
|
basis,
|
|
@@ -437,7 +436,7 @@ function derivedRegion(root: ResolvedAdapterRoot): AdapterRegion {
|
|
|
437
436
|
return {
|
|
438
437
|
id: root.id,
|
|
439
438
|
surface,
|
|
440
|
-
|
|
439
|
+
substrate,
|
|
441
440
|
dialect: surface === 'three' ? 'r3f' : 'pixi-react',
|
|
442
441
|
anchors: ['source-prop', 'source-structure', 'construction-literal'] as const,
|
|
443
442
|
basis,
|
package/src/adapter/binding.ts
CHANGED
|
@@ -226,7 +226,9 @@ export type EntryStaticSurface =
|
|
|
226
226
|
/** Everything the hosted build's bundle map carries for one root. */
|
|
227
227
|
export interface BundledEntrySubset {
|
|
228
228
|
/** The entry's default-exported world component. */
|
|
229
|
-
readonly default
|
|
229
|
+
readonly default?: unknown;
|
|
230
|
+
/** An imperative canvas entry's explicit root adapter. */
|
|
231
|
+
readonly adapter?: unknown;
|
|
230
232
|
readonly debug?: unknown;
|
|
231
233
|
readonly systems?: unknown;
|
|
232
234
|
readonly components?: unknown;
|
|
@@ -361,7 +363,7 @@ export interface RootDeclaration {
|
|
|
361
363
|
*
|
|
362
364
|
* The two callback members are the one exception to "the same reference", and
|
|
363
365
|
* deliberately: `subscribe`/`observeTransforms` are METHODS on their adapter
|
|
364
|
-
* (`
|
|
366
|
+
* (`three-authoring-adapter` reads `this.store` inside `subscribe`), so a
|
|
365
367
|
* bare property read would hand the caller a function whose `this` is the
|
|
366
368
|
* observation binding. They are bound to the authoring adapter that owns them —
|
|
367
369
|
* the same function over the same receiver, with nothing interposed. They are
|
package/src/adapter/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Adapter interfaces — the seams the engine host and the editor DEPEND ON.
|
|
3
3
|
*
|
|
4
4
|
* host → RootAdapter ← { r3fRootFactory-built adapters, IngestRootAdapter, … }
|
|
5
|
-
* editor → AuthoringAdapter ← {
|
|
5
|
+
* editor → AuthoringAdapter ← { ThreeAuthoringAdapter, ReactRootAuthoringAdapter, … }
|
|
6
6
|
* game → SystemAdapters (physics/networking/navigation/audio/camera/debug)
|
|
7
7
|
*
|
|
8
8
|
* The first-party Rapier/Colyseus stack is ONE implementer of these
|
|
@@ -111,6 +111,8 @@ export type {
|
|
|
111
111
|
ThreeHostContext,
|
|
112
112
|
} from './host-context';
|
|
113
113
|
export type {
|
|
114
|
+
MountedCanvasRoot,
|
|
115
|
+
MountedCanvasSubstrate,
|
|
114
116
|
MountedPixiRoot,
|
|
115
117
|
MountedReactRoot,
|
|
116
118
|
MountedRoot,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Structural identity — the deterministic id scheme (and the small material
|
|
3
|
-
* reflection helper that rides along with it) the editor's
|
|
3
|
+
* reflection helper that rides along with it) the editor's three authoring
|
|
4
4
|
* adapter uses to address the objects of a world whose source carries no
|
|
5
5
|
* serve-time identity stamps
|
|
6
6
|
* (`packages/editor/src/projection/three.ts`, `structuralIdentity`).
|
|
@@ -48,7 +48,7 @@ export interface RootStateObserver {
|
|
|
48
48
|
/**
|
|
49
49
|
* Everything a mounted world provides except its render surface. Tagged
|
|
50
50
|
* mounted-root variants carry their native surface fields: a Three scene and
|
|
51
|
-
* camera, a
|
|
51
|
+
* camera, a declared canvas substrate root, or a DOM container.
|
|
52
52
|
*/
|
|
53
53
|
export interface MountedRootBase {
|
|
54
54
|
/**
|
|
@@ -116,12 +116,34 @@ export interface MountedThreeRoot extends MountedRootBase {
|
|
|
116
116
|
readonly rendererConfig?: WorldRendererConfig | undefined;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
|
|
119
|
+
/**
|
|
120
|
+
* A canvas substrate's native root, carried without teaching the universal
|
|
121
|
+
* host that substrate's API. The declaration is explicit — editor substrate
|
|
122
|
+
* adapters dispatch on `name`; they never infer a library from object shape.
|
|
123
|
+
*/
|
|
124
|
+
export interface MountedCanvasSubstrate<T = unknown> {
|
|
125
|
+
readonly name: string;
|
|
126
|
+
readonly root: T;
|
|
127
|
+
/** The substrate's own module namespace when authoring needs constructors
|
|
128
|
+
* (for example Babylon's native GizmoManager). Omitted when the projection
|
|
129
|
+
* only needs the root itself, as Pixi's does. */
|
|
130
|
+
readonly api?: unknown;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** A live, mounted canvas world. The host owns the canvas and lifecycle; the
|
|
134
|
+
* mounted root states which native substrate inhabits it and hands that
|
|
135
|
+
* substrate's root through opaquely. */
|
|
136
|
+
export interface MountedCanvasRoot extends MountedRootBase {
|
|
123
137
|
readonly kind: 'canvas';
|
|
124
|
-
|
|
138
|
+
/** The same host-owned canvas passed to `mount`. */
|
|
139
|
+
readonly canvas: HTMLCanvasElement;
|
|
140
|
+
readonly substrate: MountedCanvasSubstrate;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Pixi's substrate-narrowed mounted shape. This is an implementer type, not
|
|
144
|
+
* the host contract: generic canvas hosts depend on {@link MountedCanvasRoot}. */
|
|
145
|
+
export interface MountedPixiRoot extends MountedCanvasRoot {
|
|
146
|
+
readonly substrate: MountedCanvasSubstrate<Container> & { readonly name: 'pixi' };
|
|
125
147
|
}
|
|
126
148
|
|
|
127
149
|
/** A live, mounted react world (T6.2) — the react analog of
|
|
@@ -134,7 +156,7 @@ export interface MountedReactRoot extends MountedRootBase {
|
|
|
134
156
|
}
|
|
135
157
|
|
|
136
158
|
/** Every kind of live, mounted world. */
|
|
137
|
-
export type MountedRoot = MountedThreeRoot |
|
|
159
|
+
export type MountedRoot = MountedThreeRoot | MountedCanvasRoot | MountedReactRoot;
|
|
138
160
|
|
|
139
161
|
/** Map a {@link AdapterSurface} to its mounted-world shape — lets generic
|
|
140
162
|
* code over
|
|
@@ -142,7 +164,7 @@ export type MountedRoot = MountedThreeRoot | MountedPixiRoot | MountedReactRoot;
|
|
|
142
164
|
export type MountedRootFor<K extends AdapterSurface> = K extends 'three'
|
|
143
165
|
? MountedThreeRoot
|
|
144
166
|
: K extends 'canvas'
|
|
145
|
-
?
|
|
167
|
+
? MountedCanvasRoot
|
|
146
168
|
: K extends 'dom'
|
|
147
169
|
? MountedReactRoot
|
|
148
170
|
: never;
|
|
@@ -162,7 +184,7 @@ export type MountedRootFor<K extends AdapterSurface> = K extends 'three'
|
|
|
162
184
|
* The `= 'three'` default is type-level only: an author who writes bare
|
|
163
185
|
* `RootAdapter` for
|
|
164
186
|
* a pixi root gets a compile error on `mount`'s return type, because
|
|
165
|
-
* `MountedRootFor<'three'>` demands `scene`/`camera` a `
|
|
187
|
+
* `MountedRootFor<'three'>` demands `scene`/`camera` a `MountedCanvasRoot` has
|
|
166
188
|
* not got.
|
|
167
189
|
*/
|
|
168
190
|
export interface RootAdapter<K extends AdapterSurface = 'three'> {
|