@vgai/engine 0.5.14 → 0.5.16
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 +228 -17
- package/dist/adapter/adapter-module.d.ts.map +1 -1
- package/dist/adapter/adapter-module.js +224 -42
- package/dist/adapter/authoring-seam-contract.d.ts +530 -0
- package/dist/adapter/authoring-seam-contract.d.ts.map +1 -0
- package/dist/adapter/authoring-seam-contract.js +162 -0
- package/dist/adapter/authoring.d.ts +237 -50
- package/dist/adapter/authoring.d.ts.map +1 -1
- package/dist/adapter/authoring.js +2 -1
- package/dist/adapter/entrypoint-selection-source.d.ts +35 -0
- package/dist/adapter/entrypoint-selection-source.d.ts.map +1 -0
- package/dist/adapter/entrypoint-selection-source.js +151 -0
- package/dist/adapter/finders/scenes-from-entrypoint-selection.d.ts +7 -1
- package/dist/adapter/finders/scenes-from-entrypoint-selection.d.ts.map +1 -1
- package/dist/adapter/finders/scenes-from-entrypoint-selection.js +142 -21
- package/dist/adapter/first-party-systems.d.ts +13 -3
- package/dist/adapter/first-party-systems.d.ts.map +1 -1
- package/dist/adapter/first-party-systems.js +10 -3
- package/dist/adapter/index.d.ts +7 -2
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/adapter/index.js +4 -0
- package/dist/adapter/ingest/contract-system-adapters.d.ts +1 -1
- package/dist/adapter/ingest/contract-system-adapters.d.ts.map +1 -1
- package/dist/adapter/ingest/contract-system-adapters.js +13 -25
- package/dist/adapter/ingest/game-contract-seams.d.ts +214 -0
- package/dist/adapter/ingest/game-contract-seams.d.ts.map +1 -0
- package/dist/adapter/ingest/game-contract-seams.js +62 -0
- package/dist/adapter/ingest/game-contract.d.ts +5 -3
- package/dist/adapter/ingest/game-contract.d.ts.map +1 -1
- package/dist/adapter/ingest/game-contract.js +4 -1
- package/dist/adapter/ingest/merge-debug-adapters.d.ts +52 -0
- package/dist/adapter/ingest/merge-debug-adapters.d.ts.map +1 -0
- package/dist/adapter/ingest/merge-debug-adapters.js +141 -0
- package/dist/adapter/ingest/observation-debug-adapter.d.ts +56 -0
- package/dist/adapter/ingest/observation-debug-adapter.d.ts.map +1 -0
- package/dist/adapter/ingest/observation-debug-adapter.js +131 -0
- package/dist/adapter/ingest/scene-capture.d.ts +38 -13
- package/dist/adapter/ingest/scene-capture.d.ts.map +1 -1
- package/dist/adapter/ingest/scene-capture.js +101 -24
- package/dist/adapter/ingest/visible-capture-window.d.ts +22 -5
- package/dist/adapter/ingest/visible-capture-window.d.ts.map +1 -1
- package/dist/adapter/ingest/visible-capture-window.js +46 -7
- package/dist/adapter/native-debug-module.d.ts +43 -0
- package/dist/adapter/native-debug-module.d.ts.map +1 -0
- package/dist/adapter/native-debug-module.js +230 -0
- package/dist/adapter/object3d-authoring-subject.d.ts +32 -0
- package/dist/adapter/object3d-authoring-subject.d.ts.map +1 -0
- package/dist/adapter/object3d-authoring-subject.js +25 -0
- package/dist/adapter/root-adapter.d.ts +21 -56
- package/dist/adapter/root-adapter.d.ts.map +1 -1
- package/dist/adapter/root-adapter.js +4 -20
- package/dist/adapter/root-seam-contract.d.ts +124 -0
- package/dist/adapter/root-seam-contract.d.ts.map +1 -0
- package/dist/adapter/root-seam-contract.js +36 -0
- package/dist/adapter/seam-evidence.d.ts +118 -0
- package/dist/adapter/seam-evidence.d.ts.map +1 -0
- package/dist/adapter/seam-evidence.js +231 -0
- package/dist/adapter/setup-three-root-adapter.d.ts +2 -3
- package/dist/adapter/setup-three-root-adapter.d.ts.map +1 -1
- package/dist/adapter/setup-three-root-adapter.js +2 -3
- package/dist/adapter/system-adapter.d.ts +6 -1
- package/dist/adapter/system-adapter.d.ts.map +1 -1
- package/dist/adapter/system-seam-contract.d.ts +354 -0
- package/dist/adapter/system-seam-contract.d.ts.map +1 -0
- package/dist/adapter/system-seam-contract.js +95 -0
- package/dist/animation/xstate-animation-binding.d.ts +6 -0
- package/dist/animation/xstate-animation-binding.d.ts.map +1 -1
- package/dist/animation/xstate-animation-binding.js +142 -4
- package/dist/asset-formats/collider.d.ts +1 -1
- package/dist/asset-formats/mesh.d.ts +2 -2
- package/dist/asset-formats/particles.d.ts +1 -1
- package/dist/canvas-react/engine-bridge.d.ts +6 -6
- package/dist/canvas-react/engine-bridge.d.ts.map +1 -1
- package/dist/canvas-react/engine-bridge.js +2 -2
- package/dist/canvas-react/index.d.ts +2 -2
- package/dist/canvas-react/index.d.ts.map +1 -1
- package/dist/canvas-react/index.js +1 -1
- package/dist/canvas-react/pixi-react-adapter.d.ts +15 -9
- package/dist/canvas-react/pixi-react-adapter.d.ts.map +1 -1
- package/dist/canvas-react/pixi-react-adapter.js +43 -29
- package/dist/canvas-react/pixi-react-root-factory.d.ts.map +1 -1
- package/dist/canvas-react/pixi-react-root-factory.js +4 -0
- package/dist/canvas-react/world-context.d.ts +22 -12
- package/dist/canvas-react/world-context.d.ts.map +1 -1
- package/dist/canvas-react/world-context.js +12 -51
- package/dist/ecs/user-data.d.ts +5 -0
- package/dist/ecs/user-data.d.ts.map +1 -1
- package/dist/ecs/user-data.js +3 -0
- package/dist/input/input-manager.d.ts +49 -0
- package/dist/input/input-manager.d.ts.map +1 -1
- package/dist/input/input-manager.js +127 -0
- package/dist/manifest/schema.d.ts +9 -9
- package/dist/manifest/schema.js +1 -1
- package/dist/pixi/authoring.d.ts.map +1 -1
- package/dist/pixi/authoring.js +220 -1
- package/dist/pixi/ingest.d.ts +2 -1
- package/dist/pixi/ingest.d.ts.map +1 -1
- package/dist/pixi/ingest.js +4 -2
- package/dist/pixi/scene-capture.d.ts +9 -1
- package/dist/pixi/scene-capture.d.ts.map +1 -1
- package/dist/pixi/scene-capture.js +9 -6
- package/dist/render/particles-factory.d.ts +13 -6
- package/dist/render/particles-factory.d.ts.map +1 -1
- package/dist/render/particles-factory.js +6 -3
- package/dist/runtime/create-runtime.d.ts +23 -46
- package/dist/runtime/create-runtime.d.ts.map +1 -1
- package/dist/runtime/create-runtime.js +22 -67
- package/dist/runtime/game.d.ts +29 -71
- package/dist/runtime/game.d.ts.map +1 -1
- package/dist/runtime/game.js +15 -54
- package/dist/runtime/mount-game.d.ts.map +1 -1
- package/dist/runtime/mount-game.js +12 -1
- package/dist/runtime/mount-manifest.d.ts.map +1 -1
- package/dist/runtime/mount-manifest.js +4 -5
- package/dist/runtime/types.d.ts +18 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/setup/setup-renderer.d.ts +3 -4
- package/dist/setup/setup-renderer.d.ts.map +1 -1
- package/dist/setup/setup-renderer.js +3 -4
- package/dist/world3d-react/engine-bridge.d.ts +1 -1
- package/dist/world3d-react/engine-bridge.js +1 -1
- package/dist/world3d-react/r3f-adapter.d.ts +7 -0
- package/dist/world3d-react/r3f-adapter.d.ts.map +1 -1
- package/dist/world3d-react/r3f-adapter.js +50 -21
- package/dist/world3d-react/r3f-root-factory.d.ts.map +1 -1
- package/dist/world3d-react/r3f-root-factory.js +4 -0
- package/dist/world3d-react/world-context.d.ts +9 -3
- package/dist/world3d-react/world-context.d.ts.map +1 -1
- package/dist/world3d-react/world-context.js +5 -18
- package/package.json +1 -1
- package/schemas/engine-capabilities.json +8 -8
- package/schemas/vgai-project.schema.json +1 -1
- package/src/adapter/adapter-module.ts +407 -50
- package/src/adapter/authoring-seam-contract.ts +211 -0
- package/src/adapter/authoring.ts +242 -50
- package/src/adapter/entrypoint-selection-source.ts +159 -0
- package/src/adapter/finders/scenes-from-entrypoint-selection.ts +159 -28
- package/src/adapter/first-party-systems.ts +17 -3
- package/src/adapter/index.ts +51 -1
- package/src/adapter/ingest/contract-system-adapters.ts +26 -30
- package/src/adapter/ingest/game-contract-seams.ts +85 -0
- package/src/adapter/ingest/game-contract.ts +9 -4
- package/src/adapter/ingest/merge-debug-adapters.ts +193 -0
- package/src/adapter/ingest/observation-debug-adapter.ts +158 -0
- package/src/adapter/ingest/scene-capture.ts +126 -23
- package/src/adapter/ingest/visible-capture-window.ts +63 -9
- package/src/adapter/native-debug-module.ts +307 -0
- package/src/adapter/object3d-authoring-subject.ts +50 -0
- package/src/adapter/root-adapter.ts +21 -56
- package/src/adapter/root-seam-contract.ts +56 -0
- package/src/adapter/seam-evidence.ts +336 -0
- package/src/adapter/setup-three-root-adapter.ts +4 -6
- package/src/adapter/system-adapter.ts +6 -1
- package/src/adapter/system-seam-contract.ts +121 -0
- package/src/animation/xstate-animation-binding.ts +151 -4
- package/src/canvas-react/engine-bridge.ts +6 -6
- package/src/canvas-react/index.ts +2 -1
- package/src/canvas-react/pixi-react-adapter.tsx +55 -34
- package/src/canvas-react/pixi-react-root-factory.tsx +4 -0
- package/src/canvas-react/world-context.ts +26 -101
- package/src/ecs/user-data.ts +5 -0
- package/src/input/input-manager.ts +122 -0
- package/src/manifest/schema.ts +1 -1
- package/src/pixi/authoring.ts +236 -1
- package/src/pixi/ingest.ts +9 -2
- package/src/pixi/scene-capture.ts +20 -5
- package/src/render/particles-factory.ts +16 -6
- package/src/runtime/create-runtime.ts +41 -106
- package/src/runtime/game.ts +41 -111
- package/src/runtime/mount-game.ts +19 -1
- package/src/runtime/mount-manifest.ts +4 -5
- package/src/runtime/types.ts +22 -0
- package/src/setup/setup-renderer.ts +3 -4
- package/src/world3d-react/engine-bridge.ts +1 -1
- package/src/world3d-react/r3f-adapter.tsx +64 -24
- package/src/world3d-react/r3f-root-factory.tsx +4 -0
- package/src/world3d-react/world-context.ts +11 -36
|
@@ -1387,8 +1387,8 @@ export declare const ParticlesDescriptorSchema: z.ZodObject<{
|
|
|
1387
1387
|
anisotropy: z.ZodOptional<z.ZodNumber>;
|
|
1388
1388
|
}, z.core.$strip>>;
|
|
1389
1389
|
blending: z.ZodOptional<z.ZodEnum<{
|
|
1390
|
-
additive: "additive";
|
|
1391
1390
|
normal: "normal";
|
|
1391
|
+
additive: "additive";
|
|
1392
1392
|
}>>;
|
|
1393
1393
|
transparent: z.ZodOptional<z.ZodBoolean>;
|
|
1394
1394
|
depthWrite: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
* engine services, `@pixi/react`'s own `useTick` is the per-frame hook, and
|
|
13
13
|
* `useApplication` is the door to the live `Application`.
|
|
14
14
|
*/
|
|
15
|
-
import type {
|
|
15
|
+
import type { CanvasGameContext } from './world-context';
|
|
16
16
|
export interface EngineBridgeValue {
|
|
17
|
-
/** This root's `
|
|
17
|
+
/** This root's `CanvasGameContext` — `input`, `debug`, `random`, `clock`, `game`,
|
|
18
18
|
* `roots`, `systems`, `registerSystemAdapter`. Present so ordinary
|
|
19
19
|
* components can reach engine services with a HOOK (see
|
|
20
20
|
* {@link useGameContext}). */
|
|
21
|
-
readonly ctx?:
|
|
21
|
+
readonly ctx?: CanvasGameContext | undefined;
|
|
22
22
|
}
|
|
23
23
|
export declare const EngineBridge: import("react").Context<EngineBridgeValue | null>;
|
|
24
24
|
/**
|
|
25
|
-
* This canvas root's `
|
|
25
|
+
* This canvas root's `CanvasGameContext`, for use inside any component in the tree.
|
|
26
26
|
*
|
|
27
27
|
* An ordinary component does what a model would write:
|
|
28
28
|
*
|
|
@@ -31,7 +31,7 @@ export declare const EngineBridge: import("react").Context<EngineBridgeValue | n
|
|
|
31
31
|
* const { input } = useGameContext();
|
|
32
32
|
* const ref = useRef<Sprite>(null);
|
|
33
33
|
* useTick(({ deltaMS }) => {
|
|
34
|
-
* if (input
|
|
34
|
+
* if (input?.isPressed('move_right')) ref.current!.x += speed * (deltaMS / 1000);
|
|
35
35
|
* });
|
|
36
36
|
* return <pixiSprite ref={ref} texture={Texture.WHITE} />;
|
|
37
37
|
* }
|
|
@@ -41,5 +41,5 @@ export declare const EngineBridge: import("react").Context<EngineBridgeValue | n
|
|
|
41
41
|
* `createPixiReactAdapter` — absent context is a wiring bug, and a silent
|
|
42
42
|
* `null` would surface as a mystery `undefined` deep in a tick callback.
|
|
43
43
|
*/
|
|
44
|
-
export declare function useGameContext():
|
|
44
|
+
export declare function useGameContext(): CanvasGameContext;
|
|
45
45
|
//# sourceMappingURL=engine-bridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-bridge.d.ts","sourceRoot":"","sources":["../../src/canvas-react/engine-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"engine-bridge.d.ts","sourceRoot":"","sources":["../../src/canvas-react/engine-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,WAAW,iBAAiB;IAChC;;;mCAG+B;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;CAC9C;AAED,eAAO,MAAM,YAAY,mDAAgD,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,IAAI,iBAAiB,CAUlD"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { createContext, useContext } from 'react';
|
|
16
16
|
export const EngineBridge = createContext(null);
|
|
17
17
|
/**
|
|
18
|
-
* This canvas root's `
|
|
18
|
+
* This canvas root's `CanvasGameContext`, for use inside any component in the tree.
|
|
19
19
|
*
|
|
20
20
|
* An ordinary component does what a model would write:
|
|
21
21
|
*
|
|
@@ -24,7 +24,7 @@ export const EngineBridge = createContext(null);
|
|
|
24
24
|
* const { input } = useGameContext();
|
|
25
25
|
* const ref = useRef<Sprite>(null);
|
|
26
26
|
* useTick(({ deltaMS }) => {
|
|
27
|
-
* if (input
|
|
27
|
+
* if (input?.isPressed('move_right')) ref.current!.x += speed * (deltaMS / 1000);
|
|
28
28
|
* });
|
|
29
29
|
* return <pixiSprite ref={ref} texture={Texture.WHITE} />;
|
|
30
30
|
* }
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* - `PixiPrimitive` / `adoptNow` — the canvas surface's `<primitive object={…}>`:
|
|
23
23
|
* render a container the game already owns, and place a spawn in the
|
|
24
24
|
* display tree ahead of the commit that renders it.
|
|
25
|
-
* - `useGameContext()` — this root's `
|
|
25
|
+
* - `useGameContext()` — this root's `CanvasGameContext` (`input`, `debug`,
|
|
26
26
|
* `random`, `clock`, `game`, `roots`) from inside any component in the tree.
|
|
27
27
|
* Behavior in a canvas world is components + hooks, never a class under a
|
|
28
28
|
* string key.
|
|
@@ -38,5 +38,5 @@ export { EngineBridge, type EngineBridgeValue, useGameContext } from './engine-b
|
|
|
38
38
|
export { adoptNow, PixiPrimitive, type PixiPrimitiveProps } from './pixi-primitive';
|
|
39
39
|
export { type CreatePixiReactAdapterOptions, createPixiReactAdapter, } from './pixi-react-adapter';
|
|
40
40
|
export { pixiReactRootFactory, resolveCanvasEntryAdapter } from './pixi-react-root-factory';
|
|
41
|
-
export { type CanvasRootContextOptions, type CanvasRootRuntime, createCanvasRootContext, DEFAULT_INPUT_MAP_PATH, } from './world-context';
|
|
41
|
+
export { type CanvasGameContext, type CanvasRootContextOptions, type CanvasRootRuntime, createCanvasRootContext, DEFAULT_INPUT_MAP_PATH, } from './world-context';
|
|
42
42
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canvas-react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canvas-react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC"}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* - `PixiPrimitive` / `adoptNow` — the canvas surface's `<primitive object={…}>`:
|
|
23
23
|
* render a container the game already owns, and place a spawn in the
|
|
24
24
|
* display tree ahead of the commit that renders it.
|
|
25
|
-
* - `useGameContext()` — this root's `
|
|
25
|
+
* - `useGameContext()` — this root's `CanvasGameContext` (`input`, `debug`,
|
|
26
26
|
* `random`, `clock`, `game`, `roots`) from inside any component in the tree.
|
|
27
27
|
* Behavior in a canvas world is components + hooks, never a class under a
|
|
28
28
|
* string key.
|
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
* this returns a `MountedPixiRoot` (`../adapter/root-adapter.ts`) whose `stage`
|
|
7
7
|
* is the REAL `PIXI.Container` the reconciler renders into.
|
|
8
8
|
*
|
|
9
|
-
* This is the canvas surface's
|
|
9
|
+
* This is the canvas surface's sibling of `world3d-react`'s
|
|
10
10
|
* `createR3FAdapter`, with `@pixi/react` where that one has
|
|
11
|
-
* react-three-fiber.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* react-three-fiber. The explicit factory still supplies the engine context
|
|
12
|
+
* used by the current first-party Canvas examples while their app-owned input
|
|
13
|
+
* and debugger migration remains tracked in `docs/WORK.md`; `useTick` hooks
|
|
14
|
+
* stay registered on Pixi's real ticker throughout that migration.
|
|
15
15
|
*
|
|
16
16
|
* ## The loop contract
|
|
17
17
|
*
|
|
18
18
|
* `Application` is initialized with `autoStart: false` and `sharedTicker:
|
|
19
|
-
* false`, so it owns a ticker that is NEVER started and therefore
|
|
20
|
-
* requests an animation frame. `mounted.update(dt)` is the only thing
|
|
21
|
-
* advances
|
|
22
|
-
* world freeze exactly when the host freezes it, and what makes
|
|
19
|
+
* false`, so it owns a native Pixi ticker that is NEVER started and therefore
|
|
20
|
+
* never requests an animation frame. `mounted.update(dt)` is the only thing
|
|
21
|
+
* that advances that ticker, and it feeds GAME time, not wall time — which is
|
|
22
|
+
* what makes the world freeze exactly when the host freezes it, and what makes
|
|
23
23
|
* `game.waitSimTime` work in a hidden tab (a hidden tab has no rAF; the engine
|
|
24
24
|
* loop's own catch-up still calls `update`, and Pixi has no independent clock
|
|
25
25
|
* to disagree with it).
|
|
@@ -50,6 +50,12 @@ export interface CreatePixiReactAdapterOptions {
|
|
|
50
50
|
* actions). A missing/invalid map degrades loudly without failing the
|
|
51
51
|
* mount — see `world-context.ts`. */
|
|
52
52
|
readonly inputMapPath?: string | null | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Transitional compatibility for component trees that still consume the
|
|
55
|
+
* engine context. Native trees opt out once their input, observation and
|
|
56
|
+
* debugger state are application-owned.
|
|
57
|
+
*/
|
|
58
|
+
readonly engineRuntime?: boolean | undefined;
|
|
53
59
|
/**
|
|
54
60
|
* Extra `Application.init` options merged UNDER this adapter's own — e.g.
|
|
55
61
|
* `{ antialias: false }`, `{ roundPixels: true }`. The loop-critical ones
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixi-react-adapter.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-react-adapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,KAAK,EAAe,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,
|
|
1
|
+
{"version":3,"file":"pixi-react-adapter.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-react-adapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,KAAK,EAAe,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,EAA2B,KAAK,SAAS,EAA8B,MAAM,OAAO,CAAC;AAC5F,OAAO,KAAK,EAAsC,WAAW,EAAE,MAAM,YAAY,CAAC;AA2BlF,sFAAsF;AACtF,MAAM,WAAW,6BAA6B;IAC5C,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;yDACqD;IACrD,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B;;;;0CAIsC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7C;;;;;;;;OAQG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;CACvE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,6BAA6B,GACrC,WAAW,CAAC,QAAQ,CAAC,CA2MvB"}
|
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
* this returns a `MountedPixiRoot` (`../adapter/root-adapter.ts`) whose `stage`
|
|
7
7
|
* is the REAL `PIXI.Container` the reconciler renders into.
|
|
8
8
|
*
|
|
9
|
-
* This is the canvas surface's
|
|
9
|
+
* This is the canvas surface's sibling of `world3d-react`'s
|
|
10
10
|
* `createR3FAdapter`, with `@pixi/react` where that one has
|
|
11
|
-
* react-three-fiber.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* react-three-fiber. The explicit factory still supplies the engine context
|
|
12
|
+
* used by the current first-party Canvas examples while their app-owned input
|
|
13
|
+
* and debugger migration remains tracked in `docs/WORK.md`; `useTick` hooks
|
|
14
|
+
* stay registered on Pixi's real ticker throughout that migration.
|
|
15
15
|
*
|
|
16
16
|
* ## The loop contract
|
|
17
17
|
*
|
|
18
18
|
* `Application` is initialized with `autoStart: false` and `sharedTicker:
|
|
19
|
-
* false`, so it owns a ticker that is NEVER started and therefore
|
|
20
|
-
* requests an animation frame. `mounted.update(dt)` is the only thing
|
|
21
|
-
* advances
|
|
22
|
-
* world freeze exactly when the host freezes it, and what makes
|
|
19
|
+
* false`, so it owns a native Pixi ticker that is NEVER started and therefore
|
|
20
|
+
* never requests an animation frame. `mounted.update(dt)` is the only thing
|
|
21
|
+
* that advances that ticker, and it feeds GAME time, not wall time — which is
|
|
22
|
+
* what makes the world freeze exactly when the host freezes it, and what makes
|
|
23
23
|
* `game.waitSimTime` work in a hidden tab (a hidden tab has no rAF; the engine
|
|
24
24
|
* loop's own catch-up still calls `update`, and Pixi has no independent clock
|
|
25
25
|
* to disagree with it).
|
|
@@ -36,8 +36,9 @@
|
|
|
36
36
|
*/
|
|
37
37
|
import { createRoot, extend } from '@pixi/react';
|
|
38
38
|
import * as PIXI from 'pixi.js';
|
|
39
|
-
import { createElement, useLayoutEffect } from 'react';
|
|
39
|
+
import { createElement, Fragment, useEffect, useLayoutEffect } from 'react';
|
|
40
40
|
import { WorldProvider } from '../react/world-state';
|
|
41
|
+
import { getDebugRegistry } from '../runtime/debug-registry';
|
|
41
42
|
import { EngineBridge } from './engine-bridge';
|
|
42
43
|
import { createCanvasRootContext } from './world-context';
|
|
43
44
|
/** How long `mount()` waits for the tree's first commit before failing loudly
|
|
@@ -61,18 +62,18 @@ const MOUNTED_CANVASES = new WeakSet();
|
|
|
61
62
|
* `requestAnimationFrame` loop.
|
|
62
63
|
*/
|
|
63
64
|
export function createPixiReactAdapter(options) {
|
|
64
|
-
const { id, content, inputMapPath, applicationOptions } = options;
|
|
65
|
+
const { id, content, inputMapPath, engineRuntime = true, applicationOptions } = options;
|
|
65
66
|
return {
|
|
66
67
|
id,
|
|
67
68
|
async mount(host) {
|
|
68
|
-
const runtime = createCanvasRootContext(host, { id, inputMapPath });
|
|
69
|
-
const bridge = { ctx: runtime.ctx };
|
|
69
|
+
const runtime = engineRuntime ? createCanvasRootContext(host, { id, inputMapPath }) : null;
|
|
70
|
+
const bridge = runtime ? { ctx: runtime.ctx } : null;
|
|
70
71
|
// Actions must exist before any component's first tick reads them — wait
|
|
71
72
|
// for the (never-rejecting) input-map load before the first commit.
|
|
72
|
-
await runtime
|
|
73
|
+
await runtime?.inputMapReady;
|
|
73
74
|
const canvas = host.canvas;
|
|
74
75
|
if (MOUNTED_CANVASES.has(canvas)) {
|
|
75
|
-
runtime
|
|
76
|
+
runtime?.dispose();
|
|
76
77
|
throw new Error(`createPixiReactAdapter: root "${id}" was handed a canvas this lane has already ` +
|
|
77
78
|
'mounted. @pixi/react keys its reconciler roots off the canvas element, so re-using ' +
|
|
78
79
|
'one would resurrect a root whose Application is destroyed. Hand each mount a fresh ' +
|
|
@@ -85,6 +86,10 @@ export function createPixiReactAdapter(options) {
|
|
|
85
86
|
const committed = new Promise((resolve) => {
|
|
86
87
|
resolveCommitted = resolve;
|
|
87
88
|
});
|
|
89
|
+
let resolveEffectsReady;
|
|
90
|
+
const effectsReady = new Promise((resolve) => {
|
|
91
|
+
resolveEffectsReady = resolve;
|
|
92
|
+
});
|
|
88
93
|
let resolveUnmounted;
|
|
89
94
|
const unmounted = new Promise((resolve) => {
|
|
90
95
|
resolveUnmounted = resolve;
|
|
@@ -108,16 +113,23 @@ export function createPixiReactAdapter(options) {
|
|
|
108
113
|
resolveCommitted();
|
|
109
114
|
return resolveUnmounted;
|
|
110
115
|
}, []);
|
|
116
|
+
// This component is the last sibling. Reaching its passive effect
|
|
117
|
+
// means the initial tree's useDebugProvider/useDebugCommand effects
|
|
118
|
+
// have registered, so mount() can truthfully back Play's ack.
|
|
119
|
+
useEffect(resolveEffectsReady, []);
|
|
111
120
|
return null;
|
|
112
121
|
}
|
|
113
|
-
const game = runtime
|
|
122
|
+
const game = runtime?.ctx.game;
|
|
114
123
|
// The React seam every dom root already has — `useWorldState`,
|
|
115
124
|
// `useDebugProvider`/`useDebugCommand`/`useDebugEmit`
|
|
116
125
|
// (`../react/world-state`) — works identically inside a canvas root
|
|
117
126
|
// because a canvas root IS React. `host.game` is genuinely absent in
|
|
118
127
|
// bare/foreign hosts, so the provider is conditional and those hooks
|
|
119
128
|
// stay the inert no-ops they already document themselves to be.
|
|
120
|
-
const
|
|
129
|
+
const world = createElement(Fragment, null, content, createElement(Lifecycle));
|
|
130
|
+
const element = bridge
|
|
131
|
+
? createElement(EngineBridge.Provider, { value: bridge }, game ? createElement(WorldProvider, { game }, world) : world)
|
|
132
|
+
: world;
|
|
121
133
|
const root = createRoot(canvas);
|
|
122
134
|
// The host owns size, dpr, transparency and capture cost; the loop
|
|
123
135
|
// contract owns `autoStart`/`sharedTicker`. Both are applied AFTER the
|
|
@@ -140,7 +152,7 @@ export function createPixiReactAdapter(options) {
|
|
|
140
152
|
// creates the renderer) and only then hands the tree to the reconciler.
|
|
141
153
|
// A crash inside init rejects here, which is the loud failure we want.
|
|
142
154
|
const app = await root.render(element, initOptions);
|
|
143
|
-
runtime
|
|
155
|
+
runtime?.setApplication(app);
|
|
144
156
|
// A reconcile-time crash (e.g. an un-extended component) surfaces as an
|
|
145
157
|
// uncaught window error and the first commit never lands — without this
|
|
146
158
|
// guard `mount()` would await `committed` forever. Convert that class of
|
|
@@ -154,7 +166,7 @@ export function createPixiReactAdapter(options) {
|
|
|
154
166
|
catch {
|
|
155
167
|
/* the world never fully came up; teardown failure must not mask why */
|
|
156
168
|
}
|
|
157
|
-
runtime
|
|
169
|
+
runtime?.dispose();
|
|
158
170
|
reject(new Error(`createPixiReactAdapter: root "${id}" — ${why}`));
|
|
159
171
|
};
|
|
160
172
|
const onError = (event) => fail(`the Pixi tree crashed before its first commit — ${event.message} ` +
|
|
@@ -166,7 +178,7 @@ export function createPixiReactAdapter(options) {
|
|
|
166
178
|
globalThis.removeEventListener?.('error', onError);
|
|
167
179
|
};
|
|
168
180
|
globalThis.addEventListener?.('error', onError);
|
|
169
|
-
void committed.then(() => {
|
|
181
|
+
void Promise.all([committed, effectsReady]).then(() => {
|
|
170
182
|
cleanup();
|
|
171
183
|
resolve();
|
|
172
184
|
});
|
|
@@ -180,24 +192,26 @@ export function createPixiReactAdapter(options) {
|
|
|
180
192
|
app.ticker.lastTime = 0;
|
|
181
193
|
let elapsedMs = 0;
|
|
182
194
|
let disposed = false;
|
|
195
|
+
const registry = host.game ? getDebugRegistry(host.game) : null;
|
|
196
|
+
const systemAdapters = runtime?.systemAdapters ?? (registry ? { debug: registry.adapter } : {});
|
|
183
197
|
return {
|
|
184
198
|
kind: 'canvas',
|
|
185
199
|
// The reconciler's real root container — the same `PIXI.Container`
|
|
186
200
|
// `RootInstance.pixiStage()` hands the editor.
|
|
187
201
|
stage: app.stage,
|
|
188
202
|
drivesOwnLoop: false,
|
|
189
|
-
// Adapter surface:
|
|
190
|
-
//
|
|
191
|
-
|
|
203
|
+
// Adapter surface: the host's shared debug registry. A native component
|
|
204
|
+
// tree registers nothing; its entry-module `debug` export is projected
|
|
205
|
+
// after mount by the shared native adapter.
|
|
206
|
+
systems: systemAdapters,
|
|
192
207
|
update(dt) {
|
|
193
208
|
if (disposed)
|
|
194
209
|
return;
|
|
195
210
|
elapsedMs += dt * 1000;
|
|
196
|
-
//
|
|
197
|
-
// the
|
|
198
|
-
//
|
|
199
|
-
|
|
200
|
-
runtime.systems.run(dt);
|
|
211
|
+
// The optional legacy runtime drains first when explicitly enabled;
|
|
212
|
+
// the native path has none. The real Pixi ticker remains the one
|
|
213
|
+
// scheduler `useTick` observes, and the host only gates/advances it.
|
|
214
|
+
runtime?.systems.run(dt);
|
|
201
215
|
app.ticker.update(elapsedMs);
|
|
202
216
|
},
|
|
203
217
|
resize(width, height) {
|
|
@@ -221,7 +235,7 @@ export function createPixiReactAdapter(options) {
|
|
|
221
235
|
// `removeView` stays false — the canvas belongs to the HOST.
|
|
222
236
|
void root.render(null, initOptions);
|
|
223
237
|
void unmounted.then(() => app.destroy(false, { children: true }));
|
|
224
|
-
runtime
|
|
238
|
+
runtime?.dispose();
|
|
225
239
|
},
|
|
226
240
|
};
|
|
227
241
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixi-react-root-factory.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-react-root-factory.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAUnE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,MAAM,GACb,WAAW,CAAC,QAAQ,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"pixi-react-root-factory.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-react-root-factory.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAUnE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,MAAM,GACb,WAAW,CAAC,QAAQ,CAAC,GAAG,IAAI,CAc9B;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,qBAQlC,CAAC"}
|
|
@@ -53,6 +53,10 @@ export function resolveCanvasEntryAdapter(entryModule, rootId) {
|
|
|
53
53
|
return createPixiReactAdapter({
|
|
54
54
|
id: rootId,
|
|
55
55
|
content: createElement(mod.default),
|
|
56
|
+
// The supported Canvas portfolio still consumes the compatibility
|
|
57
|
+
// context. Removing it belongs to the tracked component-root migration;
|
|
58
|
+
// disabling it here first made every current default-exported game fail
|
|
59
|
+
// to mount before that migration had happened.
|
|
56
60
|
});
|
|
57
61
|
}
|
|
58
62
|
return null;
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* the ONE game-scoped registry (`getDebugRegistry(host.game)`), so a
|
|
12
12
|
* component's effect can `ctx.debug.registerStateProvider(...)` and be
|
|
13
13
|
* visible to `vgai eval`/the editor's debug panels.
|
|
14
|
-
* 2. **`ctx.input` is the game-owned `InputManager
|
|
14
|
+
* 2. **`ctx.input` is the game-owned `InputManager` when a Game hosts the
|
|
15
|
+
* root** (`host.game.input` — the
|
|
15
16
|
* same instance every sibling root shares), and this module registers the
|
|
16
17
|
* per-world debug-registry seams (`setVirtualInputTarget`/
|
|
17
18
|
* `setInputActionsSource`/`setInputTraceSource`) that make `game.input.*`
|
|
@@ -19,13 +20,14 @@
|
|
|
19
20
|
* `DEBUG_INPUT_UNAVAILABLE`. The project's input map loads through
|
|
20
21
|
* `Game.loadInputMap` (the game-owned, load-once path every root shares).
|
|
21
22
|
* A missing/unparseable map degrades LOUDLY without failing the mount — a
|
|
22
|
-
* canvas world with no declared actions is legal.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* canvas world with no declared actions is legal. A bare/foreign mount
|
|
24
|
+
* receives `null`, visibly in the type, rather than a throwing getter.
|
|
25
|
+
* 3. **Absent subsystems are absent from the type.** A canvas world builds no
|
|
26
|
+
* THREE scene/camera, Rapier world, composer, first-party audio/particles/
|
|
27
|
+
* debug-draw, or Three-flavoured `AssetCache`. Its explicit
|
|
28
|
+
* {@link CanvasGameContext} cannot name those fields, so misuse fails at
|
|
29
|
+
* the call site during typechecking instead of from a throwing getter at
|
|
30
|
+
* runtime.
|
|
29
31
|
*
|
|
30
32
|
* The Pixi handles themselves are deliberately NOT re-exposed here: a component
|
|
31
33
|
* reaches the live `Application` (and therefore `app.stage`, `app.renderer`,
|
|
@@ -36,8 +38,9 @@
|
|
|
36
38
|
import type { Application } from 'pixi.js';
|
|
37
39
|
import type { CanvasHostContext } from '../adapter';
|
|
38
40
|
import type { SystemAdapters } from '../adapter/system-adapter';
|
|
41
|
+
import type { SimClock } from '../core/sim-clock';
|
|
39
42
|
import { createSystemRunner } from '../core/system-runner';
|
|
40
|
-
import type {
|
|
43
|
+
import type { ComponentContextBase } from '../runtime/types';
|
|
41
44
|
/** The conventional input-map location every scaffolded project ships. Shared
|
|
42
45
|
* verbatim with the three lane — a project has ONE input map, whatever surface
|
|
43
46
|
* reads it. */
|
|
@@ -55,12 +58,19 @@ export interface CanvasRootContextOptions {
|
|
|
55
58
|
*/
|
|
56
59
|
readonly inputMapPath?: string | null | undefined;
|
|
57
60
|
}
|
|
61
|
+
/** The engine services a Canvas component genuinely receives. Pixi's own
|
|
62
|
+
* `useApplication()` and `Assets` remain the doors to rendering and assets.
|
|
63
|
+
* `disposeAfter` is excluded because it accepts a `THREE.Object3D`; Canvas
|
|
64
|
+
* code schedules `displayObject.destroy()` with `clock.after()` instead. */
|
|
65
|
+
export type CanvasGameContext = ComponentContextBase & {
|
|
66
|
+
readonly clock: Omit<SimClock, 'disposeAfter'>;
|
|
67
|
+
};
|
|
58
68
|
/** What {@link createCanvasRootContext} returns — the engine runtime one canvas
|
|
59
69
|
* world owns, plus the wiring hooks the adapter's `mount()` drives. */
|
|
60
70
|
export interface CanvasRootRuntime {
|
|
61
|
-
/** The
|
|
62
|
-
*
|
|
63
|
-
readonly ctx:
|
|
71
|
+
/** The explicit Canvas context this world's components read through
|
|
72
|
+
* `useGameContext`. See {@link CanvasGameContext}. */
|
|
73
|
+
readonly ctx: CanvasGameContext;
|
|
64
74
|
/** The world-local phase runner `mount().update(dt)` ticks. */
|
|
65
75
|
readonly systems: ReturnType<typeof createSystemRunner>;
|
|
66
76
|
/** The mounted world's `SystemAdapters` bag (`mounted.systems`) —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world-context.d.ts","sourceRoot":"","sources":["../../src/canvas-react/world-context.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"world-context.d.ts","sourceRoot":"","sources":["../../src/canvas-react/world-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAM3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;gBAEgB;AAChB,eAAO,MAAM,sBAAsB,qCAAqC,CAAC;AAEzE,MAAM,WAAW,wBAAwB;IACvC;6BACyB;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACnD;AAED;;;4EAG4E;AAC5E,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAAG;IACrD,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;CAChD,CAAC;AAEF;wEACwE;AACxE,MAAM,WAAW,iBAAiB;IAChC;2DACuD;IACvD,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;IACxD;6EACyE;IACzE,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC;qEACiE;IACjE,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC;gFAC4E;IAC5E,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC,6EAA6E;IAC7E,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC;;8CAE0C;IAC1C,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,wBAAwB,GAChC,iBAAiB,CAwInB"}
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* the ONE game-scoped registry (`getDebugRegistry(host.game)`), so a
|
|
12
12
|
* component's effect can `ctx.debug.registerStateProvider(...)` and be
|
|
13
13
|
* visible to `vgai eval`/the editor's debug panels.
|
|
14
|
-
* 2. **`ctx.input` is the game-owned `InputManager
|
|
14
|
+
* 2. **`ctx.input` is the game-owned `InputManager` when a Game hosts the
|
|
15
|
+
* root** (`host.game.input` — the
|
|
15
16
|
* same instance every sibling root shares), and this module registers the
|
|
16
17
|
* per-world debug-registry seams (`setVirtualInputTarget`/
|
|
17
18
|
* `setInputActionsSource`/`setInputTraceSource`) that make `game.input.*`
|
|
@@ -19,13 +20,14 @@
|
|
|
19
20
|
* `DEBUG_INPUT_UNAVAILABLE`. The project's input map loads through
|
|
20
21
|
* `Game.loadInputMap` (the game-owned, load-once path every root shares).
|
|
21
22
|
* A missing/unparseable map degrades LOUDLY without failing the mount — a
|
|
22
|
-
* canvas world with no declared actions is legal.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* canvas world with no declared actions is legal. A bare/foreign mount
|
|
24
|
+
* receives `null`, visibly in the type, rather than a throwing getter.
|
|
25
|
+
* 3. **Absent subsystems are absent from the type.** A canvas world builds no
|
|
26
|
+
* THREE scene/camera, Rapier world, composer, first-party audio/particles/
|
|
27
|
+
* debug-draw, or Three-flavoured `AssetCache`. Its explicit
|
|
28
|
+
* {@link CanvasGameContext} cannot name those fields, so misuse fails at
|
|
29
|
+
* the call site during typechecking instead of from a throwing getter at
|
|
30
|
+
* runtime.
|
|
29
31
|
*
|
|
30
32
|
* The Pixi handles themselves are deliberately NOT re-exposed here: a component
|
|
31
33
|
* reaches the live `Application` (and therefore `app.stage`, `app.renderer`,
|
|
@@ -41,24 +43,6 @@ import { createDebugRegistry, getDebugRegistry, } from '../runtime/debug-registr
|
|
|
41
43
|
* verbatim with the three lane — a project has ONE input map, whatever surface
|
|
42
44
|
* reads it. */
|
|
43
45
|
export const DEFAULT_INPUT_MAP_PATH = '/inputmaps/default.inputmap.json';
|
|
44
|
-
/** Install a throwing getter for a `GameContext` field this world genuinely
|
|
45
|
-
* does not build — a component reaching for it fails LOUDLY at its own call
|
|
46
|
-
* site, naming the limitation, instead of reading `undefined` and breaking
|
|
47
|
-
* somewhere downstream. Non-enumerable so spreads/serialization of the ctx
|
|
48
|
-
* never trip it. */
|
|
49
|
-
function defineAbsentCtxField(target, worldId, key, why) {
|
|
50
|
-
Object.defineProperty(target, key, {
|
|
51
|
-
configurable: true,
|
|
52
|
-
enumerable: false,
|
|
53
|
-
get() {
|
|
54
|
-
throw new Error(`canvas world "${worldId}": ctx.${key} is not available — ${why} ` +
|
|
55
|
-
'(A canvas world ctx provides: input, systems, clock, debug, random, game, roots, ' +
|
|
56
|
-
"registerSystemAdapter. The Pixi runtime itself comes from @pixi/react's " +
|
|
57
|
-
'useApplication() — app.stage, app.renderer, app.ticker — and assets from Pixi`s own ' +
|
|
58
|
-
'Assets.)');
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
46
|
/**
|
|
63
47
|
* Build the engine runtime for one canvas world from a `CanvasHostContext`.
|
|
64
48
|
* React-free on purpose: everything here is plain engine wiring the adapter
|
|
@@ -76,6 +60,7 @@ export function createCanvasRootContext(host, options) {
|
|
|
76
60
|
let app = null;
|
|
77
61
|
const ctxRaw = {
|
|
78
62
|
systems,
|
|
63
|
+
input: host.game?.input ?? null,
|
|
79
64
|
registerSystemAdapter: (kind, adapter) => {
|
|
80
65
|
// biome-ignore lint/suspicious/noExplicitAny: same per-key record write the three lane performs; correct by construction
|
|
81
66
|
systemAdapters[kind] = adapter;
|
|
@@ -113,7 +98,7 @@ export function createCanvasRootContext(host, options) {
|
|
|
113
98
|
'`container.destroy({ children: true })`, scheduled with `clock.after(seconds, ...)`.');
|
|
114
99
|
},
|
|
115
100
|
});
|
|
116
|
-
|
|
101
|
+
ctxRaw['clock'] = clock;
|
|
117
102
|
// --- ctx.input + the debug-registry input seams — the game-owned
|
|
118
103
|
// InputManager, polled by the game-scoped runner each frame; this world
|
|
119
104
|
// registers the per-world seams so `game.input.*` (virtual input) and the
|
|
@@ -122,7 +107,6 @@ export function createCanvasRootContext(host, options) {
|
|
|
122
107
|
if (host.game) {
|
|
123
108
|
const game = host.game;
|
|
124
109
|
const input = game.input;
|
|
125
|
-
ctxRaw['input'] = input;
|
|
126
110
|
debugRegistry.setInputActionsSource(id, () => input.actionNames().map((name) => ({ name, valueType: input.getActionValueType(name) })));
|
|
127
111
|
debugRegistry.setInputTraceSource(id, () => {
|
|
128
112
|
const raw = input.getInputTrace();
|
|
@@ -159,29 +143,6 @@ export function createCanvasRootContext(host, options) {
|
|
|
159
143
|
});
|
|
160
144
|
}
|
|
161
145
|
}
|
|
162
|
-
else {
|
|
163
|
-
defineAbsentCtxField(ctxRaw, id, 'input', 'input is game-owned and this mount has no Game host (host.game is absent — bare ' +
|
|
164
|
-
'harness/foreign host); mount through the vgai host to get the shared InputManager.');
|
|
165
|
-
}
|
|
166
|
-
// --- Loud absence for everything a canvas world genuinely does not build. ---
|
|
167
|
-
const threeWhy = 'a canvas world renders through PixiJS and owns no THREE scene graph; the world root is ' +
|
|
168
|
-
"the Pixi stage, reached with @pixi/react's useApplication().app.stage.";
|
|
169
|
-
defineAbsentCtxField(ctxRaw, id, 'scene', threeWhy);
|
|
170
|
-
defineAbsentCtxField(ctxRaw, id, 'camera', threeWhy);
|
|
171
|
-
defineAbsentCtxField(ctxRaw, id, 'sceneIndex', 'the live scene index walks a THREE.Scene; a canvas world has none (walk the Pixi display ' +
|
|
172
|
-
'tree from useApplication().app.stage instead).');
|
|
173
|
-
const rapierWhy = 'canvas worlds do not build the first-party Rapier runtime; drive physics from inside the ' +
|
|
174
|
-
'tree with the 2D physics library of your choice.';
|
|
175
|
-
defineAbsentCtxField(ctxRaw, id, 'rapierWorld', rapierWhy);
|
|
176
|
-
defineAbsentCtxField(ctxRaw, id, 'rapier', rapierWhy);
|
|
177
|
-
defineAbsentCtxField(ctxRaw, id, 'physics', rapierWhy);
|
|
178
|
-
defineAbsentCtxField(ctxRaw, id, 'collisions', rapierWhy);
|
|
179
|
-
defineAbsentCtxField(ctxRaw, id, 'assets', 'the canvas host context carries no AssetCache (that cache is a GLTF/texture loader ' +
|
|
180
|
-
"resolving THREE objects); load textures/spritesheets with Pixi's own `Assets`.");
|
|
181
|
-
defineAbsentCtxField(ctxRaw, id, 'composer', 'a canvas world has no postprocessing EffectComposer; use Pixi filters on a Container.');
|
|
182
|
-
defineAbsentCtxField(ctxRaw, id, 'audio', 'canvas worlds build no first-party audio context; use Web Audio directly (or @pixi/sound).');
|
|
183
|
-
defineAbsentCtxField(ctxRaw, id, 'particles', 'canvas worlds build no three.quarks particle runtime; use a Pixi particle container.');
|
|
184
|
-
defineAbsentCtxField(ctxRaw, id, 'debugDraw', 'canvas worlds build no debug-draw helper; draw into a Pixi `Graphics` in the tree.');
|
|
185
146
|
return {
|
|
186
147
|
ctx,
|
|
187
148
|
systems,
|
package/dist/ecs/user-data.d.ts
CHANGED
|
@@ -111,12 +111,15 @@
|
|
|
111
111
|
* JSX props for renderer/editor integration.
|
|
112
112
|
* - `constraints` — live project-owned spatial constraints projected
|
|
113
113
|
* into the shared Inspector and viewport.
|
|
114
|
+
* - `authoringSubject` — transient identity/inspection for an ecosystem-native
|
|
115
|
+
* subject represented by an Object3D proxy.
|
|
114
116
|
* - `splineControlPoint` — index of a spline control-point drag handle.
|
|
115
117
|
* - `vcDirIdx` — view-cube face direction index (0=+X,1=-X,2=+Y,...).
|
|
116
118
|
*/
|
|
117
119
|
import type * as THREE from 'three';
|
|
118
120
|
import type { ParticleSystem } from 'three.quarks';
|
|
119
121
|
import type { ConstraintMark } from '../adapter/constraint';
|
|
122
|
+
import type { Object3DAuthoringSubjectMark } from '../adapter/object3d-authoring-subject';
|
|
120
123
|
import type { RapierEditableBody } from '../adapter/rapier-physics-adapter';
|
|
121
124
|
import type { ReflectionProbeMark } from '../adapter/reflection-probe';
|
|
122
125
|
import type { AnimationRuntimeInspection } from '../animation/runtime-inspection';
|
|
@@ -174,6 +177,7 @@ export interface UserDataSchema {
|
|
|
174
177
|
skeletonEnabled: boolean;
|
|
175
178
|
envObject: boolean;
|
|
176
179
|
constraints: readonly ConstraintMark[];
|
|
180
|
+
authoringSubject: Object3DAuthoringSubjectMark;
|
|
177
181
|
reflectionProbe: ReflectionProbeMark;
|
|
178
182
|
vcDirIdx: number;
|
|
179
183
|
/** W1a navmesh path-probe preview polyline: the routed waypoints, mirrored
|
|
@@ -231,6 +235,7 @@ export declare const UserDataKeys: {
|
|
|
231
235
|
readonly skeletonEnabled: "skeletonEnabled";
|
|
232
236
|
readonly envObject: "envObject";
|
|
233
237
|
readonly constraints: "constraints";
|
|
238
|
+
readonly authoringSubject: "authoringSubject";
|
|
234
239
|
readonly reflectionProbe: "reflectionProbe";
|
|
235
240
|
readonly vcDirIdx: "vcDirIdx";
|
|
236
241
|
readonly navPathPoints: "navPathPoints";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-data.d.ts","sourceRoot":"","sources":["../../src/ecs/user-data.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"user-data.d.ts","sourceRoot":"","sources":["../../src/ecs/user-data.ts"],"names":[],"mappings":"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"}
|
package/dist/ecs/user-data.js
CHANGED
|
@@ -111,6 +111,8 @@
|
|
|
111
111
|
* JSX props for renderer/editor integration.
|
|
112
112
|
* - `constraints` — live project-owned spatial constraints projected
|
|
113
113
|
* into the shared Inspector and viewport.
|
|
114
|
+
* - `authoringSubject` — transient identity/inspection for an ecosystem-native
|
|
115
|
+
* subject represented by an Object3D proxy.
|
|
114
116
|
* - `splineControlPoint` — index of a spline control-point drag handle.
|
|
115
117
|
* - `vcDirIdx` — view-cube face direction index (0=+X,1=-X,2=+Y,...).
|
|
116
118
|
*/
|
|
@@ -158,6 +160,7 @@ export const UserDataKeys = {
|
|
|
158
160
|
skeletonEnabled: 'skeletonEnabled',
|
|
159
161
|
envObject: 'envObject',
|
|
160
162
|
constraints: 'constraints',
|
|
163
|
+
authoringSubject: 'authoringSubject',
|
|
161
164
|
reflectionProbe: 'reflectionProbe',
|
|
162
165
|
vcDirIdx: 'vcDirIdx',
|
|
163
166
|
navPathPoints: 'navPathPoints',
|