@vgai/engine 0.5.21 → 0.5.23
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 +6 -3
- package/dist/adapter/adapter-module.d.ts.map +1 -1
- package/dist/adapter/adapter-module.js +2 -4
- package/dist/adapter/adapter-surface.d.ts +1 -1
- package/dist/adapter/adapter-surface.js +1 -1
- package/dist/adapter/authoring.d.ts +19 -21
- package/dist/adapter/authoring.d.ts.map +1 -1
- package/dist/adapter/authoring.js +2 -2
- package/dist/adapter/binding.d.ts +341 -0
- package/dist/adapter/binding.d.ts.map +1 -0
- package/dist/adapter/binding.js +148 -0
- package/dist/adapter/colyseus-networking-adapter.d.ts.map +1 -1
- package/dist/adapter/colyseus-networking-adapter.js +23 -4
- package/dist/adapter/entrypoint-selection-readers.d.ts +24 -0
- package/dist/adapter/entrypoint-selection-readers.d.ts.map +1 -0
- package/dist/adapter/entrypoint-selection-readers.js +63 -0
- package/dist/adapter/entrypoint-selection-source.d.ts.map +1 -1
- package/dist/adapter/entrypoint-selection-source.js +1 -44
- package/dist/adapter/finders/scenes-from-entrypoint-selection.d.ts.map +1 -1
- package/dist/adapter/finders/scenes-from-entrypoint-selection.js +1 -52
- package/dist/adapter/host-context.d.ts +46 -15
- package/dist/adapter/host-context.d.ts.map +1 -1
- package/dist/adapter/host-context.js +2 -9
- package/dist/adapter/index.d.ts +11 -12
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/adapter/index.js +9 -10
- package/dist/adapter/ingest/game-contract.d.ts +0 -3
- package/dist/adapter/ingest/game-contract.d.ts.map +1 -1
- package/dist/adapter/ingest/game-contract.js +0 -3
- package/dist/adapter/ingest/scene-capture.d.ts +19 -23
- package/dist/adapter/ingest/scene-capture.d.ts.map +1 -1
- package/dist/adapter/ingest/scene-capture.js +143 -17
- package/dist/adapter/ingest/visible-capture-window.d.ts +34 -0
- package/dist/adapter/ingest/visible-capture-window.d.ts.map +1 -1
- package/dist/adapter/manifest-interpreter.d.ts +59 -0
- package/dist/adapter/manifest-interpreter.d.ts.map +1 -0
- package/dist/adapter/manifest-interpreter.js +50 -0
- package/dist/adapter/native-debug-module.d.ts +71 -3
- package/dist/adapter/native-debug-module.d.ts.map +1 -1
- package/dist/adapter/native-debug-module.js +146 -10
- package/dist/adapter/rapier-physics-adapter.d.ts +31 -1
- package/dist/adapter/rapier-physics-adapter.d.ts.map +1 -1
- package/dist/adapter/rapier-physics-adapter.js +50 -36
- package/dist/adapter/renderer-config.d.ts +3 -3
- package/dist/adapter/renderer-config.js +3 -3
- package/dist/adapter/root-adapter.d.ts +7 -7
- package/dist/adapter/root-adapter.js +4 -4
- package/dist/adapter/system-adapter.d.ts +45 -7
- package/dist/adapter/system-adapter.d.ts.map +1 -1
- package/dist/adapter/system-seam-contract.d.ts +3 -3
- package/dist/adapter/system-seam-contract.js +3 -3
- package/dist/adapter/system-slot.d.ts +168 -0
- package/dist/adapter/system-slot.d.ts.map +1 -0
- package/dist/adapter/system-slot.js +229 -0
- package/dist/adapter/transform.d.ts +11 -1
- package/dist/adapter/transform.d.ts.map +1 -1
- package/dist/ai/navigation.d.ts +17 -1
- package/dist/ai/navigation.d.ts.map +1 -1
- package/dist/ai/navigation.js +26 -5
- package/dist/animation/anim-graph-types.d.ts +11 -3
- package/dist/animation/anim-graph-types.d.ts.map +1 -1
- package/dist/animation/theatre-clock-binding.d.ts +4 -4
- package/dist/animation/theatre-clock-binding.js +4 -4
- package/dist/animation/xstate-animation-binding.d.ts.map +1 -1
- package/dist/animation/xstate-animation-binding.js +2 -2
- package/dist/animation/xstate-animation-meta.d.ts +13 -0
- package/dist/animation/xstate-animation-meta.d.ts.map +1 -1
- package/dist/animation/xstate-animation-meta.js +14 -0
- package/dist/asset-formats/index.d.ts +4 -7
- package/dist/asset-formats/index.d.ts.map +1 -1
- package/dist/asset-formats/index.js +4 -7
- package/dist/asset-formats/render-env.d.ts +5 -8
- package/dist/asset-formats/render-env.d.ts.map +1 -1
- package/dist/asset-formats/render-env.js +3 -6
- package/dist/asset-parse-error.d.ts +2 -5
- package/dist/asset-parse-error.d.ts.map +1 -1
- package/dist/asset-parse-error.js +2 -5
- package/dist/audio/bus-mixer.d.ts +101 -0
- package/dist/audio/bus-mixer.d.ts.map +1 -0
- package/dist/audio/bus-mixer.js +115 -0
- package/dist/canvas-react/index.d.ts +5 -12
- package/dist/canvas-react/index.d.ts.map +1 -1
- package/dist/canvas-react/index.js +5 -12
- package/dist/canvas-react/pixi-react-root-factory.d.ts +34 -21
- package/dist/canvas-react/pixi-react-root-factory.d.ts.map +1 -1
- package/dist/canvas-react/pixi-react-root-factory.js +274 -36
- package/dist/core/countdown-timer.d.ts +118 -0
- package/dist/core/countdown-timer.d.ts.map +1 -0
- package/dist/core/countdown-timer.js +137 -0
- package/dist/core/deferred-commands.d.ts +127 -0
- package/dist/core/deferred-commands.d.ts.map +1 -0
- package/dist/core/deferred-commands.js +132 -0
- package/dist/core/frame-pacing.d.ts +1 -1
- package/dist/core/frame-pacing.js +2 -2
- package/dist/core/game-loop.d.ts +1 -3
- package/dist/core/game-loop.d.ts.map +1 -1
- package/dist/core/game-loop.js +1 -3
- package/dist/core/seeded-random.d.ts +1 -1
- package/dist/core/sim-clock.d.ts +19 -8
- package/dist/core/sim-clock.d.ts.map +1 -1
- package/dist/core/sim-clock.js +18 -7
- package/dist/core/types.d.ts +1 -3
- package/dist/core/types.d.ts.map +1 -1
- package/dist/defaults.d.ts +6 -14
- package/dist/defaults.d.ts.map +1 -1
- package/dist/defaults.js +6 -14
- package/dist/dev/instruments.d.ts +38 -11
- package/dist/dev/instruments.d.ts.map +1 -1
- package/dist/dev/instruments.js +81 -11
- package/dist/dev/register-render-vitals.d.ts +1 -4
- package/dist/dev/register-render-vitals.d.ts.map +1 -1
- package/dist/dev/register-render-vitals.js +1 -4
- package/dist/dev/render-debug-adapter.d.ts +2 -3
- package/dist/dev/render-debug-adapter.d.ts.map +1 -1
- package/dist/dev/render-debug-adapter.js +2 -3
- package/dist/dev/render-vitals.d.ts +3 -3
- package/dist/dev/render-vitals.js +3 -3
- package/dist/dev/webgl-frame-capture.d.ts +1 -1
- package/dist/dev/webgl-frame-capture.js +1 -1
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/input/host-pointer.d.ts +122 -0
- package/dist/input/host-pointer.d.ts.map +1 -0
- package/dist/input/host-pointer.js +160 -0
- package/dist/input/input-manager.d.ts +33 -5
- package/dist/input/input-manager.d.ts.map +1 -1
- package/dist/input/input-manager.js +48 -13
- package/dist/input/rebind-controller.d.ts.map +1 -1
- package/dist/input/rebind-controller.js +6 -8
- package/dist/input/schema.d.ts.map +1 -1
- package/dist/input/schema.js +56 -28
- package/dist/manifest/filename.d.ts.map +1 -1
- package/dist/manifest/filename.js +8 -12
- package/dist/manifest/load.d.ts +10 -10
- package/dist/manifest/load.d.ts.map +1 -1
- package/dist/manifest/load.js +9 -6
- package/dist/manifest/schema.d.ts +17 -21
- package/dist/manifest/schema.d.ts.map +1 -1
- package/dist/manifest/schema.js +45 -35
- package/dist/physics/collider-dimensions.d.ts +8 -12
- package/dist/physics/collider-dimensions.d.ts.map +1 -1
- package/dist/physics/collider-dimensions.js +8 -12
- package/dist/pixi/scene-capture.d.ts +11 -13
- package/dist/pixi/scene-capture.d.ts.map +1 -1
- package/dist/react/world-state.d.ts +1 -1
- package/dist/react/world-state.d.ts.map +1 -1
- package/dist/render/directional-shadow-fit.d.ts +88 -0
- package/dist/render/directional-shadow-fit.d.ts.map +1 -0
- package/dist/render/directional-shadow-fit.js +133 -0
- package/dist/render/environment-capture.d.ts +68 -0
- package/dist/render/environment-capture.d.ts.map +1 -0
- package/dist/render/environment-capture.js +90 -0
- package/dist/render/ibl-override-material.d.ts +97 -0
- package/dist/render/ibl-override-material.d.ts.map +1 -0
- package/dist/render/ibl-override-material.js +114 -0
- package/dist/render/light-camera-factory.d.ts +5 -7
- package/dist/render/light-camera-factory.d.ts.map +1 -1
- package/dist/render/light-camera-factory.js +8 -11
- package/dist/render/material-factory.js +1 -1
- package/dist/render/render-batch-system.d.ts.map +1 -1
- package/dist/render/render-features.d.ts +17 -6
- package/dist/render/render-features.d.ts.map +1 -1
- package/dist/render/render-features.js +0 -28
- package/dist/runtime/create-runtime.d.ts +34 -25
- package/dist/runtime/create-runtime.d.ts.map +1 -1
- package/dist/runtime/create-runtime.js +218 -93
- package/dist/runtime/debug-registry.d.ts +77 -8
- package/dist/runtime/debug-registry.d.ts.map +1 -1
- package/dist/runtime/debug-registry.js +3 -3
- package/dist/runtime/dev-build.d.ts +2 -2
- package/dist/runtime/dev-build.js +2 -2
- package/dist/runtime/game-input-seams.d.ts +51 -0
- package/dist/runtime/game-input-seams.d.ts.map +1 -0
- package/dist/runtime/game-input-seams.js +86 -0
- package/dist/runtime/game.d.ts +104 -40
- package/dist/runtime/game.d.ts.map +1 -1
- package/dist/runtime/game.js +119 -61
- package/dist/runtime/mount-game.d.ts +0 -16
- package/dist/runtime/mount-game.d.ts.map +1 -1
- package/dist/runtime/mount-game.js +26 -41
- package/dist/runtime/mount-manifest.d.ts +22 -14
- package/dist/runtime/mount-manifest.d.ts.map +1 -1
- package/dist/runtime/mount-manifest.js +22 -20
- package/dist/runtime/playtest.d.ts +22 -0
- package/dist/runtime/playtest.d.ts.map +1 -0
- package/dist/runtime/playtest.js +12 -0
- package/dist/runtime/state-bridge.d.ts +2 -3
- package/dist/runtime/state-bridge.d.ts.map +1 -1
- package/dist/runtime/state-bridge.js +1 -0
- package/dist/setup/setup-audio.d.ts +12 -0
- package/dist/setup/setup-audio.d.ts.map +1 -1
- package/dist/setup/setup-audio.js +9 -10
- package/dist/setup/setup-renderer.d.ts +2 -25
- package/dist/setup/setup-renderer.d.ts.map +1 -1
- package/dist/setup/setup-renderer.js +2 -31
- package/dist/world3d-react/index.d.ts +15 -25
- package/dist/world3d-react/index.d.ts.map +1 -1
- package/dist/world3d-react/index.js +15 -25
- package/dist/world3d-react/r3f-root-factory.d.ts +28 -34
- package/dist/world3d-react/r3f-root-factory.d.ts.map +1 -1
- package/dist/world3d-react/r3f-root-factory.js +403 -57
- package/dist/world3d-react/rapier-physics-bridge.d.ts +30 -17
- package/dist/world3d-react/rapier-physics-bridge.d.ts.map +1 -1
- package/dist/world3d-react/rapier-physics-bridge.js +143 -58
- package/package.json +1 -1
- package/schemas/engine-capabilities.json +16 -14
- package/schemas/vgai-project.schema.json +35 -26
- package/src/adapter/adapter-module.ts +2 -4
- package/src/adapter/adapter-surface.ts +1 -1
- package/src/adapter/authoring.ts +19 -21
- package/src/adapter/binding.ts +468 -0
- package/src/adapter/colyseus-networking-adapter.ts +20 -5
- package/src/adapter/entrypoint-selection-readers.ts +66 -0
- package/src/adapter/entrypoint-selection-source.ts +1 -40
- package/src/adapter/finders/scenes-from-entrypoint-selection.ts +1 -48
- package/src/adapter/host-context.ts +45 -15
- package/src/adapter/index.ts +23 -11
- package/src/adapter/ingest/game-contract.ts +0 -3
- package/src/adapter/ingest/scene-capture.ts +190 -39
- package/src/adapter/ingest/visible-capture-window.ts +35 -0
- package/src/adapter/manifest-interpreter.ts +64 -0
- package/src/adapter/native-debug-module.ts +248 -15
- package/src/adapter/rapier-physics-adapter.ts +76 -20
- package/src/adapter/renderer-config.ts +3 -3
- package/src/adapter/root-adapter.ts +7 -7
- package/src/adapter/system-adapter.ts +43 -8
- package/src/adapter/system-seam-contract.ts +3 -3
- package/src/adapter/system-slot.ts +291 -0
- package/src/adapter/transform.ts +18 -1
- package/src/ai/navigation.ts +30 -3
- package/src/animation/anim-graph-types.ts +11 -3
- package/src/animation/theatre-clock-binding.ts +4 -4
- package/src/animation/xstate-animation-binding.ts +2 -2
- package/src/animation/xstate-animation-meta.ts +16 -0
- package/src/asset-formats/index.ts +4 -7
- package/src/asset-formats/render-env.ts +3 -6
- package/src/asset-parse-error.ts +2 -5
- package/src/audio/bus-mixer.ts +161 -0
- package/src/canvas-react/index.ts +5 -21
- package/src/canvas-react/pixi-react-root-factory.tsx +301 -39
- package/src/core/countdown-timer.ts +188 -0
- package/src/core/deferred-commands.ts +174 -0
- package/src/core/frame-pacing.ts +2 -2
- package/src/core/game-loop.ts +1 -3
- package/src/core/seeded-random.ts +1 -1
- package/src/core/sim-clock.ts +19 -8
- package/src/core/types.ts +1 -3
- package/src/defaults.ts +6 -14
- package/src/dev/instruments.ts +108 -11
- package/src/dev/register-render-vitals.ts +1 -4
- package/src/dev/render-debug-adapter.ts +2 -3
- package/src/dev/render-vitals.ts +3 -3
- package/src/dev/webgl-frame-capture.ts +1 -1
- package/src/index.ts +2 -5
- package/src/input/host-pointer.ts +230 -0
- package/src/input/input-manager.ts +49 -13
- package/src/input/input-types.ts +1 -1
- package/src/input/rebind-controller.ts +6 -8
- package/src/input/schema.ts +216 -188
- package/src/manifest/filename.ts +8 -12
- package/src/manifest/load.ts +17 -13
- package/src/manifest/schema.ts +55 -47
- package/src/physics/collider-dimensions.ts +8 -12
- package/src/pixi/scene-capture.ts +12 -15
- package/src/react/world-state.tsx +1 -1
- package/src/render/directional-shadow-fit.ts +156 -0
- package/src/render/environment-capture.ts +102 -0
- package/src/render/ibl-override-material.ts +170 -0
- package/src/render/light-camera-factory.ts +8 -11
- package/src/render/material-factory.ts +1 -1
- package/src/render/render-batch-system.ts +14 -6
- package/src/render/render-features.ts +17 -35
- package/src/runtime/create-runtime.ts +270 -108
- package/src/runtime/debug-registry.ts +84 -8
- package/src/runtime/dev-build.ts +2 -2
- package/src/runtime/game-input-seams.ts +108 -0
- package/src/runtime/game.ts +231 -85
- package/src/runtime/mount-game.ts +31 -57
- package/src/runtime/mount-manifest.ts +47 -36
- package/src/runtime/playtest.ts +22 -0
- package/src/runtime/state-bridge.ts +3 -3
- package/src/setup/setup-audio.ts +21 -11
- package/src/setup/setup-renderer.ts +2 -61
- package/src/world3d-react/index.ts +15 -31
- package/src/world3d-react/r3f-root-factory.tsx +451 -60
- package/src/world3d-react/rapier-physics-bridge.tsx +154 -58
- package/dist/adapter/setup-three-root-adapter.d.ts +0 -86
- package/dist/adapter/setup-three-root-adapter.d.ts.map +0 -1
- package/dist/adapter/setup-three-root-adapter.js +0 -908
- package/dist/animation/clip-map.d.ts +0 -12
- package/dist/animation/clip-map.d.ts.map +0 -1
- package/dist/animation/clip-map.js +0 -31
- package/dist/asset-registry.d.ts +0 -38
- package/dist/asset-registry.d.ts.map +0 -1
- package/dist/asset-registry.js +0 -66
- package/dist/canvas-react/engine-bridge.d.ts +0 -45
- package/dist/canvas-react/engine-bridge.d.ts.map +0 -1
- package/dist/canvas-react/engine-bridge.js +0 -45
- package/dist/canvas-react/pixi-react-adapter.d.ts +0 -77
- package/dist/canvas-react/pixi-react-adapter.d.ts.map +0 -1
- package/dist/canvas-react/pixi-react-adapter.js +0 -294
- package/dist/canvas-react/world-context.d.ts +0 -98
- package/dist/canvas-react/world-context.d.ts.map +0 -1
- package/dist/canvas-react/world-context.js +0 -173
- package/dist/dev/debug-draw.d.ts +0 -24
- package/dist/dev/debug-draw.d.ts.map +0 -1
- package/dist/dev/debug-draw.js +0 -73
- package/dist/render/auto-batcher.d.ts +0 -34
- package/dist/render/auto-batcher.d.ts.map +0 -1
- package/dist/render/auto-batcher.js +0 -140
- package/dist/render/lod.d.ts +0 -13
- package/dist/render/lod.d.ts.map +0 -1
- package/dist/render/lod.js +0 -16
- package/dist/runtime/types.d.ts +0 -303
- package/dist/runtime/types.d.ts.map +0 -1
- package/dist/runtime/types.js +0 -1
- package/dist/world3d-react/engine-bridge.d.ts +0 -47
- package/dist/world3d-react/engine-bridge.d.ts.map +0 -1
- package/dist/world3d-react/engine-bridge.js +0 -73
- package/dist/world3d-react/r3f-adapter.d.ts +0 -58
- package/dist/world3d-react/r3f-adapter.d.ts.map +0 -1
- package/dist/world3d-react/r3f-adapter.js +0 -634
- package/dist/world3d-react/world-context.d.ts +0 -182
- package/dist/world3d-react/world-context.d.ts.map +0 -1
- package/dist/world3d-react/world-context.js +0 -235
- package/src/adapter/setup-three-root-adapter.ts +0 -1032
- package/src/animation/clip-map.ts +0 -34
- package/src/asset-registry.ts +0 -89
- package/src/canvas-react/engine-bridge.ts +0 -59
- package/src/canvas-react/pixi-react-adapter.tsx +0 -356
- package/src/canvas-react/world-context.ts +0 -253
- package/src/dev/debug-draw.ts +0 -80
- package/src/render/auto-batcher.ts +0 -168
- package/src/render/lod.ts +0 -17
- package/src/runtime/types.ts +0 -328
- package/src/world3d-react/engine-bridge.ts +0 -86
- package/src/world3d-react/r3f-adapter.tsx +0 -717
- package/src/world3d-react/world-context.ts +0 -358
package/dist/runtime/types.d.ts
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
import type RAPIER from '@dimforge/rapier3d-compat';
|
|
2
|
-
import type { EffectComposer } from 'postprocessing';
|
|
3
|
-
import type * as THREE from 'three';
|
|
4
|
-
import type { z } from 'zod';
|
|
5
|
-
import type { SystemAdapters } from '../adapter/system-adapter';
|
|
6
|
-
import type { AssetCache } from '../assets';
|
|
7
|
-
import type { SeededRandom } from '../core/seeded-random';
|
|
8
|
-
import type { SimClock } from '../core/sim-clock';
|
|
9
|
-
import type { createSystemRunner } from '../core/system-runner';
|
|
10
|
-
import type { createDebugDraw } from '../dev/debug-draw';
|
|
11
|
-
import type { SceneIndex } from '../ecs/scene-index';
|
|
12
|
-
import type { InputManager } from '../input/input-manager';
|
|
13
|
-
import type { CollisionSystem } from '../physics/collision-system';
|
|
14
|
-
import type { PhysicsRegistry } from '../physics/physics-registry';
|
|
15
|
-
import type { AudioContext as GameAudio } from '../setup/setup-audio';
|
|
16
|
-
import type { ParticlesContext } from '../setup/setup-particles';
|
|
17
|
-
import type { Game, RootInstance } from './game';
|
|
18
|
-
/**
|
|
19
|
-
* The minimal structural shape `ctx.debug.attachRoom` needs from a joined
|
|
20
|
-
* Colyseus room: just enough to send the reserved `__vgai:debugCommand`
|
|
21
|
-
* message and listen for its `__vgai:debugCommandResult` reply. Structural,
|
|
22
|
-
* not a Colyseus type import — the same seam-boundary style every other
|
|
23
|
-
* `DebugCtxSurface` member uses (no wrapper around Colyseus itself, D2).
|
|
24
|
-
* `onMessage`'s return type is `unknown` because Colyseus's own return shape
|
|
25
|
-
* (void in some client versions, an unsubscribe function in others) isn't
|
|
26
|
-
* load-bearing here: the registry calls it defensively (invokes it on detach
|
|
27
|
-
* only if it's actually a function).
|
|
28
|
-
*/
|
|
29
|
-
export interface DebugRoomHandle {
|
|
30
|
-
send(type: string, message?: unknown): void;
|
|
31
|
-
onMessage(type: string, cb: (message: unknown) => void): unknown;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Infers a `registerCommand`/`registerReactCommand`/`useDebugCommand`
|
|
35
|
-
* handler's parameter tuple from its declared Zod `args` tuple (dry-run
|
|
36
|
-
* finding, ledger — "`registerCommand` fn typing forces `unknown[]` casts"):
|
|
37
|
-
* a real `z.ZodTuple` infers its element types (`z.tuple([z.number(),
|
|
38
|
-
* z.string()])` → `(n: number, s: string) => ...`), while omitting `args`
|
|
39
|
-
* (the generic's `undefined` default) resolves to the original permissive
|
|
40
|
-
* `(...args: unknown[]) => ...` shape every command had before this generic
|
|
41
|
-
* existed. That permissive fallback is deliberate, not just a placeholder —
|
|
42
|
-
* it keeps every existing no-schema registration (including ones whose
|
|
43
|
-
* handler reads positional args the runtime never validates, since
|
|
44
|
-
* `invoke()` only parses `args` against a schema when one is declared)
|
|
45
|
-
* compiling byte-for-byte unchanged.
|
|
46
|
-
*/
|
|
47
|
-
export type DebugCommandArgs<T extends z.ZodTuple | undefined = undefined> = T extends z.ZodTuple ? z.infer<T> : unknown[];
|
|
48
|
-
/**
|
|
49
|
-
* The authoring half of the debug/synthetic-player seam — the read/actuate half is
|
|
50
|
-
* `SystemAdapters.DebugAdapter` (`adapter/system-adapter.ts`). Callable from any
|
|
51
|
-
* `init` (one file per new provider/command), or from a react world's
|
|
52
|
-
* `useDebugProvider`/`useDebugCommand`/`useDebugEmit` hooks. Every registration feeds the ONE
|
|
53
|
-
* game-scoped registry (`runtime/debug-registry.ts`) — never a per-world accumulator.
|
|
54
|
-
*/
|
|
55
|
-
export interface DebugCtxSurface {
|
|
56
|
-
/** Register (or replace) a named, JSON-serializable state read. Duplicate
|
|
57
|
-
* names from the SAME world replace + warn once; the SAME name from a
|
|
58
|
-
* DIFFERENT world throws (`DebugError` code `DEBUG_NAME_COLLISION`). */
|
|
59
|
-
registerStateProvider(name: string, fn: () => unknown, opts?: {
|
|
60
|
-
tier?: 'observable' | 'assisted';
|
|
61
|
-
}): void;
|
|
62
|
-
/** Register (or replace) an invokable command. `locus` is REQUIRED once the
|
|
63
|
-
* project declares a Colyseus room (`DebugRegistry.setRoomDeclared`) — a
|
|
64
|
-
* fixture must say whether it mutates authoritative (server) or predicted
|
|
65
|
-
* (client) state.
|
|
66
|
-
*
|
|
67
|
-
* Generic over the declared `args` Zod tuple ({@link DebugCommandArgs}) so
|
|
68
|
-
* `fn`'s parameters INFER from it: `registerCommand('setHp', { args:
|
|
69
|
-
* z.tuple([z.number()]) }, (hp) => ...)` types `hp` as `number` with no
|
|
70
|
-
* cast. Leaving `args` off keeps `fn` typed `(...args: unknown[]) => ...`,
|
|
71
|
-
* same as before this generic existed. */
|
|
72
|
-
registerCommand<T extends z.ZodTuple | undefined = undefined>(name: string, spec: {
|
|
73
|
-
description?: string;
|
|
74
|
-
args?: T;
|
|
75
|
-
locus?: 'client' | 'server';
|
|
76
|
-
}, fn: (...args: DebugCommandArgs<T>) => unknown | Promise<unknown>): void;
|
|
77
|
-
/** Push a tick-stamped event onto the debug event ring (spec §3.3) — the
|
|
78
|
-
* engine stamps `tick`/`simT` at emission, not at read time. */
|
|
79
|
-
emit(event: string, detail?: unknown): void;
|
|
80
|
-
/**
|
|
81
|
-
* Task 2.2 — server-locus command routing (client leg). Call once your
|
|
82
|
-
* game code has joined its Colyseus room, so `locus: 'server'` commands
|
|
83
|
-
* have somewhere to send `__vgai:debugCommand`. Returns a detach function
|
|
84
|
-
* (call on room leave/dispose) — game-scoped, last-attached room wins.
|
|
85
|
-
*/
|
|
86
|
-
attachRoom(room: DebugRoomHandle): () => void;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* All engine subsystems, passed to every game `setup(ctx)` and to each
|
|
90
|
-
* game lifecycle callback.
|
|
91
|
-
*
|
|
92
|
-
* The surface is intentionally split in two:
|
|
93
|
-
*
|
|
94
|
-
* - **Raw libraries** — the actual Three.js / Rapier / postprocessing objects.
|
|
95
|
-
* Call their documented APIs directly; do NOT build wrappers around them.
|
|
96
|
-
* - **Engine handles** — thin VGAI-owned managers that bridge those libraries
|
|
97
|
-
* into the phase-ordered game loop. Reach for these when you need behavior the
|
|
98
|
-
* raw library doesn't provide (physics↔Object3D mapping, system phases, etc.).
|
|
99
|
-
*/
|
|
100
|
-
/** Host-supplied identity for one private play run or coordinated team test.
|
|
101
|
-
* Games may pass `roomKey` as a Colyseus filter/join option; the engine never
|
|
102
|
-
* joins a room or couples this authoring identity to a networking library. */
|
|
103
|
-
export interface PlaytestContext {
|
|
104
|
-
readonly mode: 'private' | 'team';
|
|
105
|
-
readonly id: string;
|
|
106
|
-
readonly roomKey: string;
|
|
107
|
-
readonly revision: number | null;
|
|
108
|
-
readonly participantId: string | null;
|
|
109
|
-
}
|
|
110
|
-
export interface GameContext {
|
|
111
|
-
/** Three.js scene graph root. Add/remove any `Object3D` (meshes, lights,
|
|
112
|
-
* groups) here. This is THE scene — there is no separate engine scene. */
|
|
113
|
-
scene: THREE.Scene;
|
|
114
|
-
/** The single render camera. Move/aim it directly, or (preferred) drive it
|
|
115
|
-
* from game code — see the camera-precedence note below. */
|
|
116
|
-
camera: THREE.PerspectiveCamera;
|
|
117
|
-
/** The Rapier physics `World`. Step/query it, create bodies & colliders via
|
|
118
|
-
* `ctx.rapier`. One shared world for the whole scene. */
|
|
119
|
-
rapierWorld: RAPIER.World;
|
|
120
|
-
/** The Rapier module namespace itself (`RigidBodyDesc`, `ColliderDesc`,
|
|
121
|
-
* `Vector3`, enums, …). Use to construct physics descriptors. */
|
|
122
|
-
rapier: typeof RAPIER;
|
|
123
|
-
/** The `postprocessing` EffectComposer driving the final render. Use to
|
|
124
|
-
* add/remove passes (bloom, vignette, …) or reach the underlying
|
|
125
|
-
* `WebGLRenderer` via `composer.getRenderer()`. */
|
|
126
|
-
composer: EffectComposer;
|
|
127
|
-
/** Keyboard/mouse/gamepad input. Polled once per frame in the `input` phase;
|
|
128
|
-
* read action/axis state inside your `update`. */
|
|
129
|
-
input: InputManager;
|
|
130
|
-
/** Rapier collision-event dispatcher. Register handlers with
|
|
131
|
-
* `collisions.onCollision(...)`; it is drained each `postPhysics`. Prefer a
|
|
132
|
-
* own handler for per-entity sensor logic. */
|
|
133
|
-
collisions: CollisionSystem;
|
|
134
|
-
/** `Object3D ↔ Rapier body/collider` registry (+ collider→Object3D reverse
|
|
135
|
-
* index). Use to find an entity's body/collider, or the entity behind a
|
|
136
|
-
* raw collision. Inside a component, `this.rigidBody`/`this.collider` are
|
|
137
|
-
* pre-resolved from here. */
|
|
138
|
-
physics: PhysicsRegistry;
|
|
139
|
-
/** Procedural audio: master gain, listener, and one-shot/impact helpers.
|
|
140
|
-
* Use for SFX and music; the listener tracks the camera. */
|
|
141
|
-
audio: GameAudio;
|
|
142
|
-
/** three.quarks particle system: the batched renderer + spawn helpers. Use
|
|
143
|
-
* to emit runtime particle effects; declarative scene particles register
|
|
144
|
-
* here automatically. */
|
|
145
|
-
particles: ParticlesContext;
|
|
146
|
-
/** Immediate-mode debug drawing (`line`/`box`/`sphere`/`arrow`). Drawn
|
|
147
|
-
* objects persist until you call `debugDraw.clear()` yourself (the
|
|
148
|
-
* adapter also clears on scene dispose/hot-reload) — nothing clears it
|
|
149
|
-
* automatically per frame. Dev-only visualization — not for shipped
|
|
150
|
-
* visuals. */
|
|
151
|
-
debugDraw: ReturnType<typeof createDebugDraw>;
|
|
152
|
-
/** Shared GLTF/texture cache. Use `assets.loadGLTF(...)` etc. to load+cache
|
|
153
|
-
* models at runtime so repeated loads reuse geometry/material. */
|
|
154
|
-
assets: AssetCache;
|
|
155
|
-
/** The phase-ordered system runner. `systems.add(phase, fn)` registers a
|
|
156
|
-
* per-frame callback. Reserve this for non-gameplay infra (audio mixers,
|
|
157
|
-
* network send); per-entity GAMEPLAY belongs in a `useFrame` hook. */
|
|
158
|
-
systems: ReturnType<typeof createSystemRunner>;
|
|
159
|
-
/**
|
|
160
|
-
* P3 — the SIM-TIME scheduler (`core/sim-clock.ts`). `await ctx.clock.delay(n)`
|
|
161
|
-
* waits `n` seconds of the fixed loop's own time, so it pauses when the game
|
|
162
|
-
* pauses, steps when `Game.play.step()` steps, and reproduces exactly in an
|
|
163
|
-
* offline export; `ctx.clock.after(n, fn)` is the frame-exact synchronous
|
|
164
|
-
* form, and `ctx.clock.disposeAfter(obj, n)` is debris removal. Cancellation
|
|
165
|
-
* is `AbortSignal`.
|
|
166
|
-
*
|
|
167
|
-
* REQUIRED, unlike `debug`/`random` above: every world has a sim clock. When
|
|
168
|
-
* a Game hosts the mount it is the ONE game-scoped clock the fixed loop
|
|
169
|
-
* flushes; a bare harness mount with no Game shell gets a private,
|
|
170
|
-
* mount-local clock that nothing advances (so `now()` stays 0) rather than an
|
|
171
|
-
* absent field.
|
|
172
|
-
*
|
|
173
|
-
* NOT `AnimationClock` (`animation/animation-clock.ts`) — that one is the
|
|
174
|
-
* seekable cinematic playhead and runs backwards. This one is monotonic and
|
|
175
|
-
* never rewinds, which is exactly why a Promise can be bound to it. See
|
|
176
|
-
* `core/sim-clock.ts`'s header.
|
|
177
|
-
*/
|
|
178
|
-
clock: SimClock;
|
|
179
|
-
/** The live scene index for this root (P2 `observe`): tag/entity-id lookup
|
|
180
|
-
* that never traverses, plus the change signals — `entityadded`,
|
|
181
|
-
* `entityremoved`, `tagadded`, `tagremoved`, `attributechanged` — on a plain
|
|
182
|
-
* `EventTarget`, unsubscribed with an `AbortSignal`. Maintained from three's
|
|
183
|
-
* own `childadded`/`childremoved` parent events, so it costs nothing on a
|
|
184
|
-
* frame where nothing changes. See `ecs/scene-index.ts`; the one-shot
|
|
185
|
-
* `ecs/scene-query.ts` walks remain for a single ad-hoc question. */
|
|
186
|
-
sceneIndex: SceneIndex;
|
|
187
|
-
/** Register a game-owned `SystemAdapters` capability (networking,
|
|
188
|
-
* navigation, …) on the mounted game's adapter surface, so the editor's
|
|
189
|
-
* introspection panels (via `getActiveSystems()`) can see it. The engine
|
|
190
|
-
* wires the first-party physics/input/assets/audio entries itself;
|
|
191
|
-
* capabilities the GAME owns (a Colyseus connection, a NavMeshManager)
|
|
192
|
-
* are registered here by the game's setup. Optional capability — absent
|
|
193
|
-
* in contexts that expose no adapter surface (some test harnesses);
|
|
194
|
-
* call as `ctx.registerSystemAdapter?.(…)`.
|
|
195
|
-
*
|
|
196
|
-
* Ordering contract: **game registrations always win** — the engine seeds
|
|
197
|
-
* its first-party entries (physics/input/assets/audio) BEFORE setup()
|
|
198
|
-
* runs, so a game that registers any of those same kinds during its own
|
|
199
|
-
* setup overrides the engine's entry, not the other way around. This also
|
|
200
|
-
* holds across a warm restart (`hotReload`): every kind the outgoing game
|
|
201
|
-
* registered is stripped back to the engine's entry (or absent, for
|
|
202
|
-
* game-only kinds like networking/navigation) before the incoming game's
|
|
203
|
-
* setup runs, so a disposed game's adapter is never left stale on the
|
|
204
|
-
* mounted surface. */
|
|
205
|
-
registerSystemAdapter?<K extends keyof SystemAdapters>(kind: K, adapter: SystemAdapters[K]): void;
|
|
206
|
-
/** The debug/synthetic-player authoring surface — see {@link DebugCtxSurface}.
|
|
207
|
-
* Optional, same absence precedent as `registerSystemAdapter`: present on every
|
|
208
|
-
* first-party mount, absent only in bare test harnesses that build a
|
|
209
|
-
* hand-rolled `ctx`. */
|
|
210
|
-
debug?: DebugCtxSurface;
|
|
211
|
-
/**
|
|
212
|
-
* D15 (T-D15.1) — the game-scoped, named-stream seeded PRNG. `ctx.random()`
|
|
213
|
-
* draws from the `'gameplay'` stream; `ctx.random.stream('vfx')` (or any other
|
|
214
|
-
* name) draws from an INDEPENDENT stream, so a cosmetic/VFX draw can never
|
|
215
|
-
* shift the gameplay draw sequence. Use this instead of raw `Math.random()` for
|
|
216
|
-
* anything a project wants to keep reproducible; `ctx.random` itself always
|
|
217
|
-
* exists and is always internally consistent (same seed ⇒ same sequence)
|
|
218
|
-
* whether or not the project's manifest declares `determinism.seededRandom` —
|
|
219
|
-
* that flag only gates the BOOT-TIME seeding from
|
|
220
|
-
* `manifest.determinism.defaultSeed`/`?vgai-seed=`, the burn-down lint scan,
|
|
221
|
-
* and the dev-mode `Math.random` phase trap (three separate enforcers,
|
|
222
|
-
* `test/gameplay-rng-ban.test.ts` + `runtime/gameplay-rng-trap.ts`), never
|
|
223
|
-
* `ctx.random`'s mere presence. Same absence precedent as `debug` above:
|
|
224
|
-
* present on every first-party mount, optional only for bare test harnesses
|
|
225
|
-
* that build a hand-rolled `ctx`. `reseed(seed)` (future draws only) is
|
|
226
|
-
* `play.seed.set`'s eventual target (T-D15.6, not yet wired).
|
|
227
|
-
*/
|
|
228
|
-
random?: SeededRandom;
|
|
229
|
-
/** The Game root — the loop, the world registry, and game-scoped handles.
|
|
230
|
-
* Absent only in bare test harnesses that construct a partial context (the
|
|
231
|
-
* host always sets it in `createGameRuntime`). Optional so every existing
|
|
232
|
-
* harness that builds a hand-rolled `ctx` object keeps compiling
|
|
233
|
-
* unmodified — the same precedent as `registerSystemAdapter`. */
|
|
234
|
-
game?: Game | undefined;
|
|
235
|
-
/** Alias for `game.roots` — the live, declaration-ordered world registry.
|
|
236
|
-
* Same optionality/absence rule as `game` above. */
|
|
237
|
-
roots?: ReadonlyArray<RootInstance> | undefined;
|
|
238
|
-
/** The host's current private play or Team Test identity. Optional for
|
|
239
|
-
* standalone/custom hosts; networking remains game-owned and direct. */
|
|
240
|
-
playtest?: PlaytestContext | null | undefined;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Services shared by component-authored roots, independent of their render
|
|
244
|
-
* surface. This is deliberately an explicit pick from {@link GameContext}:
|
|
245
|
-
* adding a subsystem to the imperative Three setup context never silently
|
|
246
|
-
* exposes it to R3F or Canvas components.
|
|
247
|
-
*
|
|
248
|
-
* `input` is nullable because it belongs to the optional `Game` host. Normal
|
|
249
|
-
* vgai project mounts always provide it; bare harnesses and foreign hosts do
|
|
250
|
-
* not. Component code therefore sees the absence in its type instead of a
|
|
251
|
-
* getter that first throws from inside a frame callback.
|
|
252
|
-
*
|
|
253
|
-
* `clock` is surface-specific and intentionally absent here. The imperative
|
|
254
|
-
* and R3F clocks can dispose `THREE.Object3D` debris; a Canvas context narrows
|
|
255
|
-
* that Three-only operation away.
|
|
256
|
-
*/
|
|
257
|
-
export type ComponentContextBase = Pick<GameContext, 'systems' | 'debug' | 'random' | 'game' | 'roots' | 'playtest' | 'registerSystemAdapter'> & {
|
|
258
|
-
readonly input: InputManager | null;
|
|
259
|
-
};
|
|
260
|
-
/** Return value from a game setup function. */
|
|
261
|
-
export interface GameCleanup {
|
|
262
|
-
dispose: () => void;
|
|
263
|
-
}
|
|
264
|
-
/** Context passed to setup() when launched from the editor's play mode. */
|
|
265
|
-
export interface EditorPreview {
|
|
266
|
-
/** Editor viewport camera transform — use this as the initial game camera viewpoint. */
|
|
267
|
-
viewportCamera?: {
|
|
268
|
-
position: [number, number, number];
|
|
269
|
-
quaternion: [number, number, number, number];
|
|
270
|
-
};
|
|
271
|
-
/**
|
|
272
|
-
* Which bundled example the static/browser build's project picker wants to
|
|
273
|
-
* run (Adjudication H).
|
|
274
|
-
*
|
|
275
|
-
* Its one former reader — `browser-play-entry.ts`'s whole-bundle `setup()`,
|
|
276
|
-
* which dispatched over the generated `SETUP_BY_EXAMPLE_ID` table — is
|
|
277
|
-
* DELETED. Hosted dispatch is per-root (`ADAPTER_BY_EXAMPLE_ROOT` /
|
|
278
|
-
* `REACT_BY_EXAMPLE_ROOT`, resolved in `adapter-resolver.ts`) and never
|
|
279
|
-
* consults this field; `exampleDispatchFor` still sets it as the marker for
|
|
280
|
-
* "play the project's own shipped game" rather than a `?scene=` override
|
|
281
|
-
* (which sets `assetPrefix` instead — that one IS read, by
|
|
282
|
-
* `SetupThreeRootAdapter`). Every `GameSetupFn` consumer ignores it.
|
|
283
|
-
*/
|
|
284
|
-
exampleId?: string | undefined;
|
|
285
|
-
/**
|
|
286
|
-
* Asset prefix for the static/browser build's GENERIC scene-loader fallback,
|
|
287
|
-
* set INSTEAD of `exampleId` when the editor has a non-default scene of a
|
|
288
|
-
* bundled example open (hosted `?project=<id>&scene=<project-relative>` —
|
|
289
|
-
* Track H): the open scene plays via `sceneData`, but its relative asset
|
|
290
|
-
* refs still live under the example's staged `/examples/<id>/` public root.
|
|
291
|
-
* Ignored whenever `exampleId` is set; undefined ⇒ root prefix `/`.
|
|
292
|
-
*/
|
|
293
|
-
assetPrefix?: string | undefined;
|
|
294
|
-
}
|
|
295
|
-
/** A game setup function: receives engine context, returns cleanup.
|
|
296
|
-
*
|
|
297
|
-
* This is the MOUNT body of the FIRST-PARTY implementer. The host no longer
|
|
298
|
-
* depends on it — the host depends on `RootAdapter` (`@engine/adapter`), and
|
|
299
|
-
* `GameSetupFn` is wrapped into a `SetupThreeRootAdapter` via `fromSetup`.. (The
|
|
300
|
-
* former `RootAdapter` `{ setup, components }` interface lived here; it is
|
|
301
|
-
* superseded by the real adapter interfaces in `@engine/adapter`.) */
|
|
302
|
-
export type GameSetupFn = (ctx: GameContext, editor?: EditorPreview) => Promise<GameCleanup>;
|
|
303
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,CAAC,EAAE,MAA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I,GAAG,SAAS,CAAC;CAC/C;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,WAAW,EACX,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,uBAAuB,CACzF,GAAG;IACF,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF,+CAA+C;AAC/C,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,wFAAwF;IACxF,cAAc,CAAC,EAAE;QACf,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACnC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;KAC9C,CAAC;IACF;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;sEAMsE;AACtE,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/runtime/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@engine/world3d-react` — the React context that carries this R3F world's
|
|
3
|
-
* engine runtime into its fiber tree: the world's `R3FGameContext`, read
|
|
4
|
-
* with {@link useGameContext}.
|
|
5
|
-
*
|
|
6
|
-
* Upstreamed from `examples/r3f-first-party/src/engine-bridge.ts` (R4).
|
|
7
|
-
* The bridge value
|
|
8
|
-
* is built by `createR3FAdapter`'s `mount()` (./r3f-adapter.tsx): a real
|
|
9
|
-
* `createSystemRunner` whose phases the adapter's `update(dt)` runs under the
|
|
10
|
-
* HOST loop — so registered systems tick in engine phase order, pause included
|
|
11
|
-
* (no update while the world is frozen).
|
|
12
|
-
*
|
|
13
|
-
* Behavior in an R3F world is components and hooks: `useGameContext` is how a
|
|
14
|
-
* component reaches engine services.
|
|
15
|
-
*/
|
|
16
|
-
import type { R3FGameContext } from './world-context';
|
|
17
|
-
export interface EngineBridgeValue {
|
|
18
|
-
/** This root's context — `input`, `debug`, `random`, `game`, `roots`, … .
|
|
19
|
-
* Present so ordinary components can reach engine services with a HOOK
|
|
20
|
-
* (see {@link useGameContext}). */
|
|
21
|
-
readonly ctx?: R3FGameContext | undefined;
|
|
22
|
-
}
|
|
23
|
-
export declare const EngineBridge: import("react").Context<EngineBridgeValue | null>;
|
|
24
|
-
/**
|
|
25
|
-
* This R3F root's context, for use inside any component in the tree — an
|
|
26
|
-
* {@link R3FGameContext}, which is exactly the subsystems an R3F world builds.
|
|
27
|
-
* The ones it does not build are absent from the type, so reaching for one is
|
|
28
|
-
* a compile error at the call site; that type's doc comment says what to reach
|
|
29
|
-
* for instead.
|
|
30
|
-
*
|
|
31
|
-
* An ordinary component does what a model would write:
|
|
32
|
-
*
|
|
33
|
-
* ```tsx
|
|
34
|
-
* function Player({ speed = 4.5 }) {
|
|
35
|
-
* const { input } = useGameContext();
|
|
36
|
-
* const ref = useRef<THREE.Group>(null);
|
|
37
|
-
* useFrame((_, dt) => { if (input?.isPressed('move_forward')) … });
|
|
38
|
-
* return <group ref={ref}><PlayerCharacter /></group>;
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* Throws when called outside an R3F root mounted by `createR3FAdapter` —
|
|
43
|
-
* absent context is a wiring bug, and a silent `null` would surface as a
|
|
44
|
-
* mystery `undefined` deep in a frame callback.
|
|
45
|
-
*/
|
|
46
|
-
export declare function useGameContext(): R3FGameContext;
|
|
47
|
-
//# sourceMappingURL=engine-bridge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine-bridge.d.ts","sourceRoot":"","sources":["../../src/world3d-react/engine-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC;;wCAEoC;IACpC,QAAQ,CAAC,GAAG,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;CAC3C;AAED,eAAO,MAAM,YAAY,mDAAgD,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,IAAI,cAAc,CAkC/C"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@engine/world3d-react` — the React context that carries this R3F world's
|
|
3
|
-
* engine runtime into its fiber tree: the world's `R3FGameContext`, read
|
|
4
|
-
* with {@link useGameContext}.
|
|
5
|
-
*
|
|
6
|
-
* Upstreamed from `examples/r3f-first-party/src/engine-bridge.ts` (R4).
|
|
7
|
-
* The bridge value
|
|
8
|
-
* is built by `createR3FAdapter`'s `mount()` (./r3f-adapter.tsx): a real
|
|
9
|
-
* `createSystemRunner` whose phases the adapter's `update(dt)` runs under the
|
|
10
|
-
* HOST loop — so registered systems tick in engine phase order, pause included
|
|
11
|
-
* (no update while the world is frozen).
|
|
12
|
-
*
|
|
13
|
-
* Behavior in an R3F world is components and hooks: `useGameContext` is how a
|
|
14
|
-
* component reaches engine services.
|
|
15
|
-
*/
|
|
16
|
-
import { createContext, useContext } from 'react';
|
|
17
|
-
import { useOptionalGame } from '../react/world-state';
|
|
18
|
-
export const EngineBridge = createContext(null);
|
|
19
|
-
/**
|
|
20
|
-
* This R3F root's context, for use inside any component in the tree — an
|
|
21
|
-
* {@link R3FGameContext}, which is exactly the subsystems an R3F world builds.
|
|
22
|
-
* The ones it does not build are absent from the type, so reaching for one is
|
|
23
|
-
* a compile error at the call site; that type's doc comment says what to reach
|
|
24
|
-
* for instead.
|
|
25
|
-
*
|
|
26
|
-
* An ordinary component does what a model would write:
|
|
27
|
-
*
|
|
28
|
-
* ```tsx
|
|
29
|
-
* function Player({ speed = 4.5 }) {
|
|
30
|
-
* const { input } = useGameContext();
|
|
31
|
-
* const ref = useRef<THREE.Group>(null);
|
|
32
|
-
* useFrame((_, dt) => { if (input?.isPressed('move_forward')) … });
|
|
33
|
-
* return <group ref={ref}><PlayerCharacter /></group>;
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* Throws when called outside an R3F root mounted by `createR3FAdapter` —
|
|
38
|
-
* absent context is a wiring bug, and a silent `null` would surface as a
|
|
39
|
-
* mystery `undefined` deep in a frame callback.
|
|
40
|
-
*/
|
|
41
|
-
export function useGameContext() {
|
|
42
|
-
const bridge = useContext(EngineBridge);
|
|
43
|
-
// Read unconditionally (rules of hooks) — used only to shape the throw below.
|
|
44
|
-
const hostedByGame = useOptionalGame() !== null;
|
|
45
|
-
if (!bridge?.ctx) {
|
|
46
|
-
// NAME THE REAL CAUSE. This throw used to say "check that the component is
|
|
47
|
-
// rendered inside your world entry" — advice a scaffolded game has already
|
|
48
|
-
// followed, because the shape `vgai create` produces (`export default
|
|
49
|
-
// function World()`) mounts as a COMPONENT ROOT and receives no vgai
|
|
50
|
-
// runtime context at all: `r3f-root-factory.tsx` passes
|
|
51
|
-
// `engineRuntime: false` deliberately, so this hook can never resolve
|
|
52
|
-
// there however the component is nested. A world whose first render calls
|
|
53
|
-
// it dies with "fiber crashed before its first commit" and a fix
|
|
54
|
-
// instruction that cannot work. The `Game` in scope tells the two cases
|
|
55
|
-
// apart: present means a vgai-mounted world, absent means no root at all.
|
|
56
|
-
throw new Error(hostedByGame
|
|
57
|
-
? 'useGameContext(): this world mounts as a COMPONENT ROOT (the default-exported ' +
|
|
58
|
-
'shape `vgai create` scaffolds) and receives no vgai runtime context — by design, ' +
|
|
59
|
-
'so nesting cannot fix it. Game-scoped services are on the Game handle instead: ' +
|
|
60
|
-
'`useGame().input` (from @vgai/engine/react/world-state) is the game-owned ' +
|
|
61
|
-
"InputManager the host already loaded this project's input map into and the same " +
|
|
62
|
-
'one `game.input.hold/tap` drives; `useDebugProvider`/`useDebugCommand`/' +
|
|
63
|
-
'`useWorldState` are the state/command doors. If this world genuinely needs the ' +
|
|
64
|
-
'imperative runtime (`ctx.systems`, adapter options like `inputMapPath`), export ' +
|
|
65
|
-
'`adapter = createR3FAdapter({ id, content: <World/> })` from the entry instead of ' +
|
|
66
|
-
'default-exporting the component.'
|
|
67
|
-
: 'useGameContext(): no engine root context and no Game in scope — this component is ' +
|
|
68
|
-
'rendering outside any mounted vgai root (a standalone <Canvas>, a story, or a ' +
|
|
69
|
-
"bare test render). Mount it through your project's three root, or read services " +
|
|
70
|
-
'the component root way (native hooks and project-owned state).');
|
|
71
|
-
}
|
|
72
|
-
return bridge.ctx;
|
|
73
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `createR3FAdapter` — wraps a react-three-fiber tree as a first-party
|
|
3
|
-
* `RootAdapter` so an R3F scene mounts as an ordinary `kind: "three"`
|
|
4
|
-
* world: the engine hands `mount()` a `ThreeHostContext` (ITS OWN renderer +
|
|
5
|
-
* canvas + gated loop, per `../adapter/host-context.ts`); this returns a
|
|
6
|
-
* `MountedThreeRoot` (`../adapter/root-adapter.ts`) whose `scene`/`camera`
|
|
7
|
-
* are fiber's REAL `THREE.Scene`/`THREE.Camera` instances.
|
|
8
|
-
*
|
|
9
|
-
* Upstreamed from `examples/r3f-first-party/src/r3f-adapter.tsx` (R4 — the
|
|
10
|
-
* `@engine/world3d-react` opt-in module, mirroring how `pixi/` is the
|
|
11
|
-
* PixiJS surface's opt-in home). The mount semantics
|
|
12
|
-
* are byte-for-byte the example's live-proven Phase-1 bridge. External adopters
|
|
13
|
-
* (alien-stories-style) keep the exact same calling contract.
|
|
14
|
-
*
|
|
15
|
-
* three.js identity: this module never imports `three` itself for scene objects
|
|
16
|
-
* — fiber's internal `import * as THREE from 'three'` must resolve to the SAME
|
|
17
|
-
* instance the engine's `ThreeHostContext.three` points at, which the importing
|
|
18
|
-
* project guarantees via its Vite `resolve.dedupe: ['three', 'react',
|
|
19
|
-
* 'react-dom']` (see `examples/r3f-first-party/vite.config.ts`).
|
|
20
|
-
*/
|
|
21
|
-
import { type ReactNode } from 'react';
|
|
22
|
-
import type { RootAdapter } from '../adapter';
|
|
23
|
-
import { type WorldRendererConfig } from '../adapter/renderer-config';
|
|
24
|
-
/** What {@link createR3FAdapter} needs to build one `RootAdapter`. */
|
|
25
|
-
export interface CreateR3FAdapterOptions {
|
|
26
|
-
/** Stable id (telemetry/registry/conformance) — `RootAdapter.id`. */
|
|
27
|
-
readonly id: string;
|
|
28
|
-
/** The R3F scene tree to mount — drei helpers, `useFrame` hooks, etc. all
|
|
29
|
-
* work unchanged (design §1.C: "drei works unchanged (it is fiber-context
|
|
30
|
-
* userland)"). */
|
|
31
|
-
readonly content: ReactNode;
|
|
32
|
-
/** Input map loaded through the game-owned `Game.loadInputMap` (load-once
|
|
33
|
-
* across roots). Defaults to the classic adapter's conventional path,
|
|
34
|
-
* `/inputmaps/default.inputmap.json`; `null` opts out (a world with no
|
|
35
|
-
* actions). A missing/invalid map degrades loudly without failing the
|
|
36
|
-
* mount — see `world-context.ts`. */
|
|
37
|
-
readonly inputMapPath?: string | null | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Transitional compatibility for explicit pre-native adapters. The
|
|
40
|
-
* default-export root factory always passes `false`: ordinary R3F trees get
|
|
41
|
-
* no vgai context/provider or private scheduler. Remove this switch with
|
|
42
|
-
* the last explicit legacy adapter migration.
|
|
43
|
-
*/
|
|
44
|
-
readonly engineRuntime?: boolean | undefined;
|
|
45
|
-
/** The colour pipeline this world was AUTHORED for, applied to the host's renderer for the life
|
|
46
|
-
* of the mount and restored on dispose. Omit it (every world here does) to keep the host's own
|
|
47
|
-
* defaults; declare it when the world's colours were picked against a different engine's
|
|
48
|
-
* pipeline — see `../adapter/renderer-config.ts`. */
|
|
49
|
-
readonly renderer?: WorldRendererConfig | undefined;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Build a `RootAdapter` that mounts `options.content` through
|
|
53
|
-
* react-three-fiber, gated entirely by the host's own loop and rendering
|
|
54
|
-
* through the host's own `WebGLRenderer` — never a second renderer, never a
|
|
55
|
-
* second `requestAnimationFrame` loop (design §1.C).
|
|
56
|
-
*/
|
|
57
|
-
export declare function createR3FAdapter(options: CreateR3FAdapterOptions): RootAdapter;
|
|
58
|
-
//# sourceMappingURL=r3f-adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"r3f-adapter.d.ts","sourceRoot":"","sources":["../../src/world3d-react/r3f-adapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAWH,OAAO,EAA2B,KAAK,SAAS,EAAsB,MAAM,OAAO,CAAC;AACpF,OAAO,KAAK,EAAoB,WAAW,EAAoB,MAAM,YAAY,CAAC;AAClF,OAAO,EAA4B,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AA+DhG,sEAAsE;AACtE,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;uBAEmB;IACnB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B;;;;0CAIsC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7C;;;0DAGsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACrD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,WAAW,CA2kB9E"}
|