@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
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host POINTER stream, in the game's own coordinate space — the DOM edge
|
|
3
|
+
* `InputManager`'s touch backends (`setTouchButton` / `setTouchStick`) and any
|
|
4
|
+
* pointer-position read need, and which the manager itself deliberately does
|
|
5
|
+
* not own.
|
|
6
|
+
*
|
|
7
|
+
* `InputManager` listens on `window` for keyboard, mouse and focus, in CLIENT
|
|
8
|
+
* pixels, because an action map is surface-agnostic. A pointer is not: a tap is
|
|
9
|
+
* only meaningful relative to the surface it landed on, and a game's own
|
|
10
|
+
* coordinate space is usually NOT that surface's CSS pixels — a fixed design
|
|
11
|
+
* resolution presented by uniformly scaling and letterboxing is the common
|
|
12
|
+
* case, and a hit-test against a UI rect authored in design pixels has to
|
|
13
|
+
* happen in one space with the pointer. That mapping needs a surface and a
|
|
14
|
+
* design size the manager has no way to know, so it lives here, beside it.
|
|
15
|
+
*
|
|
16
|
+
* What this owns, and nothing more:
|
|
17
|
+
*
|
|
18
|
+
* - **Position** — the last pointer position over the surface, mapped into the
|
|
19
|
+
* design space. `setPosition` is the headless door (a harness or a game
|
|
20
|
+
* command driving the game with no DOM), the same shape as
|
|
21
|
+
* `InputManager.addMouseDelta`: inject through the accumulator the reader
|
|
22
|
+
* already reads, never a synthetic `pointermove`.
|
|
23
|
+
* - **Touches** — a per-frame queue of {@link HostPointerTouch} records with
|
|
24
|
+
* DENSE finger indices, drained by the game's own frame. `pointerId` is the
|
|
25
|
+
* browser's opaque, monotonically growing handle; a touch API that reports
|
|
26
|
+
* "finger 0 and finger 1" wants the lowest free slot, reused the moment a
|
|
27
|
+
* finger lifts, which is what {@link HostPointerTouch.index} is.
|
|
28
|
+
* - **Cursor** — the CSS cursor applied to the surface, because the surface is
|
|
29
|
+
* resolved here and nowhere else.
|
|
30
|
+
*
|
|
31
|
+
* **Gating.** Every listener returns early unless
|
|
32
|
+
* `InputManager.isInputActive()` — the SAME predicate the manager's own
|
|
33
|
+
* `keydown`/`mousemove` listeners pass, so play-mode isolation and window
|
|
34
|
+
* blur suppress pointer position and touches exactly as they suppress a key.
|
|
35
|
+
* The predicate is read from the manager rather than recomposed here
|
|
36
|
+
* (`isEnabled() && isFocused()` written out a second time is how a looser gate
|
|
37
|
+
* drifts in: a blurred or typing tab kept updating a pointer position under
|
|
38
|
+
* exactly that duplication). Text-entry focus is deliberately NOT part of it,
|
|
39
|
+
* matching `onMouseMove` rather than `onKeyDown` — moving a finger is not
|
|
40
|
+
* typing.
|
|
41
|
+
*
|
|
42
|
+
* **Ownership.** Owns its four pointer listeners on the resolved owner, the
|
|
43
|
+
* touch queue and the finger-index table. Shares the `InputManager`, which is
|
|
44
|
+
* the game's and is never mutated here — this reports; what a control DOES
|
|
45
|
+
* with a finger (which rect owns it, whether that becomes a `setTouchButton`)
|
|
46
|
+
* belongs to the UI that draws the control. Teardown is {@link
|
|
47
|
+
* HostPointer.dispose}, and only that: `InputManager.dispose` does not reach
|
|
48
|
+
* these listeners.
|
|
49
|
+
*
|
|
50
|
+
* Headless (no `window`): construction succeeds and binds nothing. Position is
|
|
51
|
+
* whatever {@link HostPointer.setPosition} last wrote, and the touch queue
|
|
52
|
+
* stays empty.
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* Cap on the undrained touch queue. A game that drains every frame cannot
|
|
56
|
+
* reach it — this is the bound for one that never drains at all (a project
|
|
57
|
+
* that reads no touches, on a device that has them), so the queue is a RING:
|
|
58
|
+
* the newest records win and the oldest are dropped.
|
|
59
|
+
*/
|
|
60
|
+
const TOUCH_QUEUE_MAX = 256;
|
|
61
|
+
export function createHostPointer(options) {
|
|
62
|
+
const { input, surface: surfaceOf, designSize } = options;
|
|
63
|
+
let position = designSize
|
|
64
|
+
? { x: designSize.x / 2, y: designSize.y / 2 }
|
|
65
|
+
: { x: 0, y: 0 };
|
|
66
|
+
let cursor = 'default';
|
|
67
|
+
const touches = [];
|
|
68
|
+
/** Browser `pointerId` -> dense finger index, for fingers currently down. */
|
|
69
|
+
const fingerOfPointer = new Map();
|
|
70
|
+
const freeFinger = () => {
|
|
71
|
+
const taken = new Set(fingerOfPointer.values());
|
|
72
|
+
let index = 0;
|
|
73
|
+
while (taken.has(index))
|
|
74
|
+
index += 1;
|
|
75
|
+
return index;
|
|
76
|
+
};
|
|
77
|
+
const queue = (touch) => {
|
|
78
|
+
touches.push(touch);
|
|
79
|
+
if (touches.length > TOUCH_QUEUE_MAX)
|
|
80
|
+
touches.shift();
|
|
81
|
+
};
|
|
82
|
+
const queueTouch = (event, point) => {
|
|
83
|
+
if (event.type === 'pointerdown') {
|
|
84
|
+
const index = freeFinger();
|
|
85
|
+
fingerOfPointer.set(event.pointerId, index);
|
|
86
|
+
queue({ phase: 'start', index, position: point });
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// A move or a release from a pointer that never went down on this surface
|
|
90
|
+
// is not one of our fingers.
|
|
91
|
+
const index = fingerOfPointer.get(event.pointerId);
|
|
92
|
+
if (index === undefined)
|
|
93
|
+
return;
|
|
94
|
+
if (event.type === 'pointerup' || event.type === 'pointercancel') {
|
|
95
|
+
fingerOfPointer.delete(event.pointerId);
|
|
96
|
+
queue({ phase: 'end', index, position: point });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
queue({ phase: 'move', index, position: point });
|
|
100
|
+
};
|
|
101
|
+
/** A client-space event as a point in the design space, via the surface rect
|
|
102
|
+
* the host actually presented it at. */
|
|
103
|
+
const toDesignSpace = (event, rect) => {
|
|
104
|
+
const x = event.clientX - rect.left;
|
|
105
|
+
const y = event.clientY - rect.top;
|
|
106
|
+
if (!designSize)
|
|
107
|
+
return { x, y };
|
|
108
|
+
return { x: (x * designSize.x) / rect.width, y: (y * designSize.y) / rect.height };
|
|
109
|
+
};
|
|
110
|
+
const onPointer = (event) => {
|
|
111
|
+
// The manager's own gate, read from the manager. See this module's header
|
|
112
|
+
// for why it is not recomposed here.
|
|
113
|
+
if (!input.isInputActive())
|
|
114
|
+
return;
|
|
115
|
+
const surface = surfaceOf?.() ?? (event.target instanceof HTMLElement ? event.target : null);
|
|
116
|
+
if (surface === null)
|
|
117
|
+
return;
|
|
118
|
+
const rect = surface.getBoundingClientRect();
|
|
119
|
+
if (rect.width <= 0 || rect.height <= 0)
|
|
120
|
+
return;
|
|
121
|
+
const point = toDesignSpace(event, rect);
|
|
122
|
+
if (event.type === 'pointermove') {
|
|
123
|
+
// Every pointer type moves the position — a stylus and a dragging finger
|
|
124
|
+
// are as much "where the pointer is" as a mouse. Only the TOUCH queue is
|
|
125
|
+
// touch-only.
|
|
126
|
+
position = point;
|
|
127
|
+
surface.style.cursor = cursor;
|
|
128
|
+
}
|
|
129
|
+
// A mouse or a pen is not a finger. A control that answered them here would
|
|
130
|
+
// steal the clicks of a player who cannot see it.
|
|
131
|
+
if (event.pointerType === 'touch')
|
|
132
|
+
queueTouch(event, point);
|
|
133
|
+
};
|
|
134
|
+
const KINDS = ['pointerdown', 'pointermove', 'pointerup', 'pointercancel'];
|
|
135
|
+
const owner = typeof window === 'undefined' ? null : (surfaceOf?.() ?? window);
|
|
136
|
+
if (owner !== null) {
|
|
137
|
+
for (const kind of KINDS)
|
|
138
|
+
owner.addEventListener(kind, onPointer);
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
getPosition() {
|
|
142
|
+
return position;
|
|
143
|
+
},
|
|
144
|
+
setPosition(next) {
|
|
145
|
+
position = { x: next.x, y: next.y };
|
|
146
|
+
},
|
|
147
|
+
takeTouches() {
|
|
148
|
+
return touches.splice(0, touches.length);
|
|
149
|
+
},
|
|
150
|
+
setCursor(next) {
|
|
151
|
+
cursor = next;
|
|
152
|
+
},
|
|
153
|
+
dispose() {
|
|
154
|
+
if (owner === null)
|
|
155
|
+
return;
|
|
156
|
+
for (const kind of KINDS)
|
|
157
|
+
owner.removeEventListener(kind, onPointer);
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -116,7 +116,7 @@ export declare class InputManager {
|
|
|
116
116
|
* action}`) emitted whenever a scheduled entry is discarded because its
|
|
117
117
|
* target tick's input phase never ran. Wired by whoever constructs this
|
|
118
118
|
* `InputManager` with access to a `DebugRegistry`
|
|
119
|
-
* (`
|
|
119
|
+
* (`world3d-react/r3f-root-factory.tsx`, the same seed spot as
|
|
120
120
|
* `setVirtualInputTarget`/`setInputActionsSource`) — `null` (the
|
|
121
121
|
* default) for a bare/headless `InputManager`, in which case a drop
|
|
122
122
|
* stays silent (matching pre-D15/T-D15.5 behavior). */
|
|
@@ -269,14 +269,14 @@ export declare class InputManager {
|
|
|
269
269
|
* already read as inert/zeroed by every getter, matching pre-F1 behavior
|
|
270
270
|
* for a typo'd action name. */
|
|
271
271
|
private assertValueType;
|
|
272
|
-
/** The names of all registered actions (
|
|
273
|
-
*
|
|
272
|
+
/** The names of all registered actions (the `game.input.actions` debug seam
|
|
273
|
+
* enumerates these — `runtime/game-input-seams.ts`). */
|
|
274
274
|
actionNames(): string[];
|
|
275
275
|
/**
|
|
276
276
|
* Poll gamepads and virtual look stick (call at start of frame).
|
|
277
277
|
*
|
|
278
278
|
* `tick` (D15/T-D15.3/.5) — the GAME tick this call services. Pass the
|
|
279
|
-
* live, shared `Game` tick counter here (`
|
|
279
|
+
* live, shared `Game` tick counter here (`world3d-react/r3f-root-factory.tsx` does,
|
|
280
280
|
* via `DebugRegistry.getGameTick()`) so `scheduleActionAtTick`'s numbering
|
|
281
281
|
* never drifts from the actual game tick — the bug an earlier revision of
|
|
282
282
|
* this feature had: an InputManager-LOCAL counter, incremented once per
|
|
@@ -492,6 +492,19 @@ export declare class InputManager {
|
|
|
492
492
|
* constructor). Distinct from {@link isEnabled}, which is the editor's
|
|
493
493
|
* explicit play-mode gate. */
|
|
494
494
|
isFocused(): boolean;
|
|
495
|
+
/**
|
|
496
|
+
* The gate every REAL-DEVICE listener here passes: {@link isEnabled} AND
|
|
497
|
+
* {@link isFocused}. Public because the DOM edge this class deliberately
|
|
498
|
+
* does not own — `host-pointer.ts`, the pointer stream behind the touch
|
|
499
|
+
* backends — must pass the SAME gate, and a caller writing
|
|
500
|
+
* `isEnabled() && isFocused()` out for itself is how a looser one drifts in
|
|
501
|
+
* (a pointer adapter that checked only `isEnabled` kept updating position
|
|
502
|
+
* for a blurred tab). Read it; do not recompose it.
|
|
503
|
+
*
|
|
504
|
+
* Machine input (`setVirtualAction` and the tick-scheduled actuations) is
|
|
505
|
+
* deliberately NOT this gate — see `machineInputActive`.
|
|
506
|
+
*/
|
|
507
|
+
isInputActive(): boolean;
|
|
495
508
|
/** Whether the pointer is currently locked to {@link requestPointerLock}'s
|
|
496
509
|
* element (F2, spec §12 "pointer lock") — tracked via the real
|
|
497
510
|
* `pointerlockchange` event. */
|
|
@@ -545,6 +558,21 @@ export declare class InputManager {
|
|
|
545
558
|
isDeviceGamepadButtonPressed(button: number): boolean;
|
|
546
559
|
isDeviceGamepadButtonJustPressed(button: number): boolean;
|
|
547
560
|
isDeviceGamepadButtonJustReleased(button: number): boolean;
|
|
561
|
+
/**
|
|
562
|
+
* The RAW `Gamepad.axes[axis]` of the first connected pad, gated on `inputActive`.
|
|
563
|
+
*
|
|
564
|
+
* Deliberately un-deadzoned, and it must stay that way. The engine's own stick deadzone lives on
|
|
565
|
+
* the ACTION path (`gamepad_axis` / `gamepad_axis_pair`, default
|
|
566
|
+
* `GAMEPAD_AXIS_DEFAULT_DEADZONE`), where a game declares it and can override it per binding.
|
|
567
|
+
* This door exists for a caller that must apply a DIFFERENT rule — every foreign-engine compat
|
|
568
|
+
* lane does: Unity's `Gamepad.leftStick` carries a `StickDeadzone` processor with its own
|
|
569
|
+
* 0.125/0.925 (`unity-compat/input-system-device.ts` reproduces it), and Godot's `get_axis`
|
|
570
|
+
* has its own. Baking one engine's constants in here would silently give every other lane the
|
|
571
|
+
* wrong feel under its own API name.
|
|
572
|
+
*
|
|
573
|
+
* So: a caller that wants "a stick" wants a deadzone and must say WHOSE. A caller that wants
|
|
574
|
+
* the hardware number calls this.
|
|
575
|
+
*/
|
|
548
576
|
getDeviceGamepadAxis(axis: number): number;
|
|
549
577
|
private firstConnectedGamepadIndex;
|
|
550
578
|
/**
|
|
@@ -792,7 +820,7 @@ export declare class InputManager {
|
|
|
792
820
|
* `'input.schedule.dropped'` (`{tick, action}`) whenever it discards a
|
|
793
821
|
* scheduled entry for a tick whose input phase never ran. Called once by
|
|
794
822
|
* whoever constructs this `InputManager` with a `DebugRegistry` behind it
|
|
795
|
-
* (`
|
|
823
|
+
* (`world3d-react/r3f-root-factory.tsx`), the same seed spot as
|
|
796
824
|
* `setVirtualInputTarget`/`setInputActionsSource` — never called directly
|
|
797
825
|
* by gameplay code. */
|
|
798
826
|
setDebugEmit(fn: ((event: string, detail?: unknown) => void) | null): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-manager.d.ts","sourceRoot":"","sources":["../../src/input/input-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,OAAO,EACR,MAAM,eAAe,CAAC;AA4BvB;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAG,wBAAwB,CAAU;IAClD,QAAQ,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAA;K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D;IACvD,mBAAmB,IAAI,IAAI;IAI3B;;;;;;;;;;;;;;;;;;OAkBG;IACH,oBAAoB,CAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GACjD,IAAI;IAYP;;;;;;4BAMwB;IACxB,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI;IAI1E;;+DAE2D;IAC3D,mBAAmB,IAAI,IAAI;IAM3B;;kCAE8B;IAC9B,kBAAkB,IAAI,IAAI;IAI1B,6DAA6D;IAC7D,gBAAgB,IAAI,OAAO;IAI3B;;;mBAGe;IACf,aAAa,IAAI;QACf,OAAO,EAAE,CAAC,CAAC;QACX,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG;gBAAE,CAAC,EAAE,MAAM,CAAC;gBAAC,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SAAE,EAAE,CAAC;KACjG;IAID,uDAAuD;IACvD,kBAAkB,CAAC,OAAO,EAAE,WAAW;IAWvC;;;;;;;;;;;OAWG;IACH,eAAe;IAYf,+BAA+B;IAC/B,OAAO;CAoBR"}
|
|
@@ -152,10 +152,16 @@ const INPUT_TRACE_CAP = 2000;
|
|
|
152
152
|
* controls. `setTouchButton(sourceId, pressed)` feeds a digital action
|
|
153
153
|
* (edge-tracked like `mouse_button`); `setTouchStick(sourceId, value)`
|
|
154
154
|
* feeds a vector2 action (deadzone-rescaled like a gamepad stick). These
|
|
155
|
-
* are the injectable entry points
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
155
|
+
* are the injectable entry points an on-screen touch UI calls, and they
|
|
156
|
+
* are the UPPER half of the touch story. The LOWER half — the DOM
|
|
157
|
+
* pointer stream itself, as dense finger indices mapped into the game's
|
|
158
|
+
* own design space and gated on `isInputActive()` — is
|
|
159
|
+
* `input/host-pointer.ts` (`createHostPointer`), beside this file; a
|
|
160
|
+
* control drains its `takeTouches()` and calls the setters above.
|
|
161
|
+
* What is deliberately still NOT here is the control layer in between:
|
|
162
|
+
* which rect owns which finger, and how a knob's offset becomes a stick
|
|
163
|
+
* vector, is the shape of the UI drawing the control, so it belongs to
|
|
164
|
+
* that UI and there is no first-party one to generalize from yet.
|
|
159
165
|
* - Focus gating — `blur`/`focus` on `window` (guarded, real DOM only) now
|
|
160
166
|
* drop input the same way `setEnabled(false)` does (flushing held
|
|
161
167
|
* key/mouse/touch-button state) without touching the `enabled` flag the
|
|
@@ -392,7 +398,7 @@ export class InputManager {
|
|
|
392
398
|
// caller never tells `poll()` which tick it's servicing (every existing
|
|
393
399
|
// bare/headless caller — tests, a mount with no `Game` shell behind it —
|
|
394
400
|
// keeps this exact pre-existing behavior, zero regression). The REAL
|
|
395
|
-
// per-world wiring (`
|
|
401
|
+
// per-world wiring (`world3d-react/r3f-root-factory.tsx`) instead passes the
|
|
396
402
|
// shared `Game`-level tick counter into every `poll(tick)` call — this is
|
|
397
403
|
// deliberate: an InputManager-local counter drifts from the actual game
|
|
398
404
|
// tick for a paused/frozen world (its `poll()` isn't called every game
|
|
@@ -422,7 +428,7 @@ export class InputManager {
|
|
|
422
428
|
* action}`) emitted whenever a scheduled entry is discarded because its
|
|
423
429
|
* target tick's input phase never ran. Wired by whoever constructs this
|
|
424
430
|
* `InputManager` with access to a `DebugRegistry`
|
|
425
|
-
* (`
|
|
431
|
+
* (`world3d-react/r3f-root-factory.tsx`, the same seed spot as
|
|
426
432
|
* `setVirtualInputTarget`/`setInputActionsSource`) — `null` (the
|
|
427
433
|
* default) for a bare/headless `InputManager`, in which case a drop
|
|
428
434
|
* stays silent (matching pre-D15/T-D15.5 behavior). */
|
|
@@ -731,8 +737,8 @@ export class InputManager {
|
|
|
731
737
|
`use the getter for '${actual}' instead.`);
|
|
732
738
|
}
|
|
733
739
|
}
|
|
734
|
-
/** The names of all registered actions (
|
|
735
|
-
*
|
|
740
|
+
/** The names of all registered actions (the `game.input.actions` debug seam
|
|
741
|
+
* enumerates these — `runtime/game-input-seams.ts`). */
|
|
736
742
|
actionNames() {
|
|
737
743
|
return [...this.actions.keys()];
|
|
738
744
|
}
|
|
@@ -740,7 +746,7 @@ export class InputManager {
|
|
|
740
746
|
* Poll gamepads and virtual look stick (call at start of frame).
|
|
741
747
|
*
|
|
742
748
|
* `tick` (D15/T-D15.3/.5) — the GAME tick this call services. Pass the
|
|
743
|
-
* live, shared `Game` tick counter here (`
|
|
749
|
+
* live, shared `Game` tick counter here (`world3d-react/r3f-root-factory.tsx` does,
|
|
744
750
|
* via `DebugRegistry.getGameTick()`) so `scheduleActionAtTick`'s numbering
|
|
745
751
|
* never drifts from the actual game tick — the bug an earlier revision of
|
|
746
752
|
* this feature had: an InputManager-LOCAL counter, incremented once per
|
|
@@ -1622,6 +1628,21 @@ export class InputManager {
|
|
|
1622
1628
|
isFocused() {
|
|
1623
1629
|
return this.focused;
|
|
1624
1630
|
}
|
|
1631
|
+
/**
|
|
1632
|
+
* The gate every REAL-DEVICE listener here passes: {@link isEnabled} AND
|
|
1633
|
+
* {@link isFocused}. Public because the DOM edge this class deliberately
|
|
1634
|
+
* does not own — `host-pointer.ts`, the pointer stream behind the touch
|
|
1635
|
+
* backends — must pass the SAME gate, and a caller writing
|
|
1636
|
+
* `isEnabled() && isFocused()` out for itself is how a looser one drifts in
|
|
1637
|
+
* (a pointer adapter that checked only `isEnabled` kept updating position
|
|
1638
|
+
* for a blurred tab). Read it; do not recompose it.
|
|
1639
|
+
*
|
|
1640
|
+
* Machine input (`setVirtualAction` and the tick-scheduled actuations) is
|
|
1641
|
+
* deliberately NOT this gate — see `machineInputActive`.
|
|
1642
|
+
*/
|
|
1643
|
+
isInputActive() {
|
|
1644
|
+
return this.inputActive;
|
|
1645
|
+
}
|
|
1625
1646
|
/** Whether the pointer is currently locked to {@link requestPointerLock}'s
|
|
1626
1647
|
* element (F2, spec §12 "pointer lock") — tracked via the real
|
|
1627
1648
|
* `pointerlockchange` event. */
|
|
@@ -1727,6 +1748,21 @@ export class InputManager {
|
|
|
1727
1748
|
return false;
|
|
1728
1749
|
return this.gamepadButtonsJustUp.has(`${index}:${button}`);
|
|
1729
1750
|
}
|
|
1751
|
+
/**
|
|
1752
|
+
* The RAW `Gamepad.axes[axis]` of the first connected pad, gated on `inputActive`.
|
|
1753
|
+
*
|
|
1754
|
+
* Deliberately un-deadzoned, and it must stay that way. The engine's own stick deadzone lives on
|
|
1755
|
+
* the ACTION path (`gamepad_axis` / `gamepad_axis_pair`, default
|
|
1756
|
+
* `GAMEPAD_AXIS_DEFAULT_DEADZONE`), where a game declares it and can override it per binding.
|
|
1757
|
+
* This door exists for a caller that must apply a DIFFERENT rule — every foreign-engine compat
|
|
1758
|
+
* lane does: Unity's `Gamepad.leftStick` carries a `StickDeadzone` processor with its own
|
|
1759
|
+
* 0.125/0.925 (`unity-compat/input-system-device.ts` reproduces it), and Godot's `get_axis`
|
|
1760
|
+
* has its own. Baking one engine's constants in here would silently give every other lane the
|
|
1761
|
+
* wrong feel under its own API name.
|
|
1762
|
+
*
|
|
1763
|
+
* So: a caller that wants "a stick" wants a deadzone and must say WHOSE. A caller that wants
|
|
1764
|
+
* the hardware number calls this.
|
|
1765
|
+
*/
|
|
1730
1766
|
getDeviceGamepadAxis(axis) {
|
|
1731
1767
|
if (!this.inputActive)
|
|
1732
1768
|
return 0;
|
|
@@ -2075,12 +2111,11 @@ export class InputManager {
|
|
|
2075
2111
|
this.touchStickValues.delete(sourceId);
|
|
2076
2112
|
}
|
|
2077
2113
|
// ==========================================================================
|
|
2078
|
-
//
|
|
2079
|
-
// hollowstone's proven `VirtualInput` (`bot/virtual-input.ts`): a bot drives
|
|
2114
|
+
// Action-level virtual input for a synthetic player: a bot drives
|
|
2080
2115
|
// NAMED ACTIONS (not raw devices), and its contributions join action
|
|
2081
2116
|
// resolution at exactly the same points binding contributions do (see
|
|
2082
2117
|
// isPressed/isJustPressed and collectScalarContributions/
|
|
2083
|
-
// collectVector2Contributions above).
|
|
2118
|
+
// collectVector2Contributions above). The gates are split: virtual input
|
|
2084
2119
|
// passes `machineInputActive` (the editor's `enabled` flag only), while
|
|
2085
2120
|
// human input keeps the full `inputActive` (enabled AND focused) gate — a
|
|
2086
2121
|
// synthetic player must keep playing the shared editor tab while the
|
|
@@ -2275,7 +2310,7 @@ export class InputManager {
|
|
|
2275
2310
|
* `'input.schedule.dropped'` (`{tick, action}`) whenever it discards a
|
|
2276
2311
|
* scheduled entry for a tick whose input phase never ran. Called once by
|
|
2277
2312
|
* whoever constructs this `InputManager` with a `DebugRegistry` behind it
|
|
2278
|
-
* (`
|
|
2313
|
+
* (`world3d-react/r3f-root-factory.tsx`), the same seed spot as
|
|
2279
2314
|
* `setVirtualInputTarget`/`setInputActionsSource` — never called directly
|
|
2280
2315
|
* by gameplay code. */
|
|
2281
2316
|
setDebugEmit(fn) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rebind-controller.d.ts","sourceRoot":"","sources":["../../src/input/rebind-controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rebind-controller.d.ts","sourceRoot":"","sources":["../../src/input/rebind-controller.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEnE,uDAAuD;AACvD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,KAAK,CAAC;AAE3C,MAAM,MAAM,WAAW,GACnB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5E;IACE,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B,GACD;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC;AAErE,qBAAa,gBAAgB;IAGf,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,OAAO,CAAC,KAAK,CAAmC;gBAEnB,KAAK,EAAE,YAAY;IAEhD,QAAQ,IAAI,WAAW;IAIvB;;;;;OAKG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,UAAsB,EAAE,KAAK,SAAI,GAAG,IAAI;IAIzE,oEAAoE;IACpE,MAAM,IAAI,IAAI;IAId;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW;IAa3C;;;;;;;OAOG;IACH,eAAe,IAAI,WAAW;IAQ9B,OAAO,CAAC,KAAK;CAId"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// all, and the React component becomes a thin, mechanically-verifiable
|
|
8
|
-
// wrapper (see the template component's own doc comment).
|
|
1
|
+
// A framework-free rebinding STATE MACHINE over an `InputManager`.
|
|
2
|
+
// Deliberately has no dependency on React (or any UI library): "listen for the
|
|
3
|
+
// next input, surface a conflict, let the caller decide" is the same flow
|
|
4
|
+
// whether the caller is a React panel or a CLI. Keeping the logic here makes
|
|
5
|
+
// it unit-testable with no DOM/JSX at all, and leaves any UI a thin,
|
|
6
|
+
// mechanically-verifiable wrapper.
|
|
9
7
|
//
|
|
10
8
|
// Flow: `listen(actionName)` -> caller captures the next raw input event
|
|
11
9
|
// itself (a keydown, a gamepad poll, a touch tap — capture is inherently
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/input/schema.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/input/schema.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAqN7E;gGACgG;AAChG,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAa1B,CAAC;AAE9B,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CA0B1C,CAAC;AAEZ;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAOjB,CAAC"}
|
package/dist/input/schema.js
CHANGED
|
@@ -34,15 +34,20 @@
|
|
|
34
34
|
// injectPointerPosition) through the SAME deadzone/normalize/combine path
|
|
35
35
|
// real device bindings use.
|
|
36
36
|
import { z } from 'zod';
|
|
37
|
-
const KeyBindingSchema = z
|
|
37
|
+
const KeyBindingSchema = z
|
|
38
|
+
.object({
|
|
38
39
|
type: z.literal('key').describe('Binding kind: a keyboard key (KeyboardEvent.code)'),
|
|
39
40
|
code: z.string().describe('KeyboardEvent.code value, e.g. "KeyW", "Space", "ArrowUp"'),
|
|
40
|
-
})
|
|
41
|
-
|
|
41
|
+
})
|
|
42
|
+
.strict();
|
|
43
|
+
const MouseButtonBindingSchema = z
|
|
44
|
+
.object({
|
|
42
45
|
type: z.literal('mouse_button').describe('Binding kind: a mouse button'),
|
|
43
46
|
button: z.number().describe('MouseEvent.button index (0 = left, 1 = middle, 2 = right)'),
|
|
44
|
-
})
|
|
45
|
-
|
|
47
|
+
})
|
|
48
|
+
.strict();
|
|
49
|
+
const MouseMoveBindingSchema = z
|
|
50
|
+
.object({
|
|
46
51
|
type: z
|
|
47
52
|
.literal('mouse_move')
|
|
48
53
|
.describe('Binding kind: raw mouse movement (F2, spec §12 "Complete Device Backends"). Feeds a ' +
|
|
@@ -55,20 +60,26 @@ const MouseMoveBindingSchema = z.object({
|
|
|
55
60
|
.describe("Radial deadzone magnitude applied only when this binding feeds a 'vector2'-valueType " +
|
|
56
61
|
"action (default 0 — no deadzone; ignored for 'pointerDelta' reads, which are never " +
|
|
57
62
|
'deadzoned).'),
|
|
58
|
-
})
|
|
59
|
-
|
|
63
|
+
})
|
|
64
|
+
.strict();
|
|
65
|
+
const GamepadButtonBindingSchema = z
|
|
66
|
+
.object({
|
|
60
67
|
type: z.literal('gamepad_button').describe('Binding kind: a gamepad face/shoulder button'),
|
|
61
68
|
button: z.number().describe('Standard Gamepad API button index'),
|
|
62
|
-
})
|
|
63
|
-
|
|
69
|
+
})
|
|
70
|
+
.strict();
|
|
71
|
+
const GamepadAxisBindingSchema = z
|
|
72
|
+
.object({
|
|
64
73
|
type: z.literal('gamepad_axis').describe('Binding kind: a single thresholded gamepad axis'),
|
|
65
74
|
axis: z.number().describe('Standard Gamepad API axis index'),
|
|
66
75
|
direction: z
|
|
67
76
|
.enum(['positive', 'negative'])
|
|
68
77
|
.describe('Which side of the deadzone counts as "pressed"'),
|
|
69
78
|
deadzone: z.number().optional().describe('Deadzone magnitude (default 0.15 if omitted)'),
|
|
70
|
-
})
|
|
71
|
-
|
|
79
|
+
})
|
|
80
|
+
.strict();
|
|
81
|
+
const GamepadAxisPairBindingSchema = z
|
|
82
|
+
.object({
|
|
72
83
|
type: z
|
|
73
84
|
.literal('gamepad_axis_pair')
|
|
74
85
|
.describe('Binding kind: a coupled (x, y) gamepad axis pair, e.g. a stick used as a 2D vector ' +
|
|
@@ -78,7 +89,8 @@ const GamepadAxisPairBindingSchema = z.object({
|
|
|
78
89
|
xAxis: z.number().describe('Standard Gamepad API axis index for the X component'),
|
|
79
90
|
yAxis: z.number().describe('Standard Gamepad API axis index for the Y component'),
|
|
80
91
|
deadzone: z.number().optional().describe('Deadzone magnitude (default 0.15 if omitted)'),
|
|
81
|
-
})
|
|
92
|
+
})
|
|
93
|
+
.strict();
|
|
82
94
|
// ---------------------------------------------------------------------------
|
|
83
95
|
// F1 (spec §12) — injected test input bindings. LIVE (real runtime readers in
|
|
84
96
|
// InputManager's getScalar/getVector2/getPointerDelta/getPointerPosition),
|
|
@@ -86,7 +98,8 @@ const GamepadAxisPairBindingSchema = z.object({
|
|
|
86
98
|
// backend: real device kinds F2 adds later feed the same typed-value
|
|
87
99
|
// aggregation path these exercise today.
|
|
88
100
|
// ---------------------------------------------------------------------------
|
|
89
|
-
const TestAxisBindingSchema = z
|
|
101
|
+
const TestAxisBindingSchema = z
|
|
102
|
+
.object({
|
|
90
103
|
type: z
|
|
91
104
|
.literal('test_axis')
|
|
92
105
|
.describe("Binding kind: an injected synthetic scalar value for a 'scalar'-valueType action " +
|
|
@@ -101,8 +114,10 @@ const TestAxisBindingSchema = z.object({
|
|
|
101
114
|
.describe('1D deadzone magnitude applied to the injected raw value before combine (default 0 — no ' +
|
|
102
115
|
'deadzone). Values below it read as 0; values at/above it rescale from 0 (at the ' +
|
|
103
116
|
'deadzone edge) to ±1 (at |raw| = 1), sign preserved.'),
|
|
104
|
-
})
|
|
105
|
-
|
|
117
|
+
})
|
|
118
|
+
.strict();
|
|
119
|
+
const TestVector2BindingSchema = z
|
|
120
|
+
.object({
|
|
106
121
|
type: z
|
|
107
122
|
.literal('test_vector2')
|
|
108
123
|
.describe("Binding kind: an injected synthetic {x,y} value for a 'vector2'-valueType action " +
|
|
@@ -118,8 +133,10 @@ const TestVector2BindingSchema = z.object({
|
|
|
118
133
|
'— no deadzone). Vectors whose magnitude is below it read as {0,0}; at/above it, ' +
|
|
119
134
|
'direction is preserved and magnitude rescales the same way the scalar deadzone does, ' +
|
|
120
135
|
'then the result is clamped to the unit circle (magnitude <= 1).'),
|
|
121
|
-
})
|
|
122
|
-
|
|
136
|
+
})
|
|
137
|
+
.strict();
|
|
138
|
+
const TestPointerDeltaBindingSchema = z
|
|
139
|
+
.object({
|
|
123
140
|
type: z
|
|
124
141
|
.literal('test_pointer_delta')
|
|
125
142
|
.describe("Binding kind: an injected synthetic per-frame {x,y} delta for a 'pointerDelta'-" +
|
|
@@ -128,8 +145,10 @@ const TestPointerDeltaBindingSchema = z.object({
|
|
|
128
145
|
sourceId: z
|
|
129
146
|
.string()
|
|
130
147
|
.describe('Names the injected test source this binding reads (InputManager.injectPointerDelta).'),
|
|
131
|
-
})
|
|
132
|
-
|
|
148
|
+
})
|
|
149
|
+
.strict();
|
|
150
|
+
const TestPointerPositionBindingSchema = z
|
|
151
|
+
.object({
|
|
133
152
|
type: z
|
|
134
153
|
.literal('test_pointer_position')
|
|
135
154
|
.describe("Binding kind: an injected synthetic absolute {x,y} position for a 'pointerPosition'-" +
|
|
@@ -138,7 +157,8 @@ const TestPointerPositionBindingSchema = z.object({
|
|
|
138
157
|
sourceId: z
|
|
139
158
|
.string()
|
|
140
159
|
.describe('Names the injected test source this binding reads (InputManager.injectPointerPosition).'),
|
|
141
|
-
})
|
|
160
|
+
})
|
|
161
|
+
.strict();
|
|
142
162
|
// ---------------------------------------------------------------------------
|
|
143
163
|
// F2 (spec §12 "Complete Device Backends") — touch/virtual-control bindings.
|
|
144
164
|
// LIVE (real runtime readers in InputManager's isPressed/isJustPressed/
|
|
@@ -148,7 +168,8 @@ const TestPointerPositionBindingSchema = z.object({
|
|
|
148
168
|
// touchstart/touchmove/touchend handlers would call (that DOM wiring is a
|
|
149
169
|
// thin adapter at the edge, out of scope here — see input-manager.ts).
|
|
150
170
|
// ---------------------------------------------------------------------------
|
|
151
|
-
const TouchButtonBindingSchema = z
|
|
171
|
+
const TouchButtonBindingSchema = z
|
|
172
|
+
.object({
|
|
152
173
|
type: z
|
|
153
174
|
.literal('touch_button')
|
|
154
175
|
.describe("Binding kind: a virtual on-screen button for a 'digital' action " +
|
|
@@ -158,8 +179,10 @@ const TouchButtonBindingSchema = z.object({
|
|
|
158
179
|
.string()
|
|
159
180
|
.describe('Names the virtual control zone this binding reads (InputManager.setTouchButton) — a ' +
|
|
160
181
|
'touch-UI-chosen id, not a real device index.'),
|
|
161
|
-
})
|
|
162
|
-
|
|
182
|
+
})
|
|
183
|
+
.strict();
|
|
184
|
+
const TouchStickBindingSchema = z
|
|
185
|
+
.object({
|
|
163
186
|
type: z
|
|
164
187
|
.literal('touch_stick')
|
|
165
188
|
.describe("Binding kind: a virtual on-screen analog stick for a 'vector2' action " +
|
|
@@ -174,7 +197,8 @@ const TouchStickBindingSchema = z.object({
|
|
|
174
197
|
.optional()
|
|
175
198
|
.describe('Radial deadzone magnitude applied to the raw {x,y} before combine (default 0 — no ' +
|
|
176
199
|
'deadzone).'),
|
|
177
|
-
})
|
|
200
|
+
})
|
|
201
|
+
.strict();
|
|
178
202
|
/** A single input binding. Every kind listed here is LIVE — F2 (spec §12) closed the last two
|
|
179
203
|
* dead stubs (`mouse_move`/`gamepad_axis_pair`) by giving both real `InputManager` readers. */
|
|
180
204
|
export const InputBindingSchema = z.discriminatedUnion('type', [
|
|
@@ -192,7 +216,8 @@ export const InputBindingSchema = z.discriminatedUnion('type', [
|
|
|
192
216
|
TouchStickBindingSchema,
|
|
193
217
|
]);
|
|
194
218
|
/** An action has a name (the record key) and one or more bindings. */
|
|
195
|
-
export const InputActionSchema = z
|
|
219
|
+
export const InputActionSchema = z
|
|
220
|
+
.object({
|
|
196
221
|
valueType: z
|
|
197
222
|
.enum(['digital', 'scalar', 'vector2', 'pointerDelta', 'pointerPosition'])
|
|
198
223
|
.default('digital')
|
|
@@ -212,7 +237,8 @@ export const InputActionSchema = z.object({
|
|
|
212
237
|
'by summing contributing {x,y} values then clamping to the unit circle. PointerDelta ' +
|
|
213
238
|
'actions sum contributing deltas. PointerPosition actions use the most-recently-' +
|
|
214
239
|
'written contributing source (last-write-wins).'),
|
|
215
|
-
})
|
|
240
|
+
})
|
|
241
|
+
.strict();
|
|
216
242
|
/**
|
|
217
243
|
* The `.inputmap.json` file format (`InputManager.loadMap`).
|
|
218
244
|
*
|
|
@@ -220,9 +246,11 @@ export const InputActionSchema = z.object({
|
|
|
220
246
|
* same convention `2d.version`/`Scene2DSchema` used before T2.3 gave the 3D
|
|
221
247
|
* scene version axis a real reader; see `schema-consumption-map.ts`).
|
|
222
248
|
*/
|
|
223
|
-
export const InputMapFileSchema = z
|
|
249
|
+
export const InputMapFileSchema = z
|
|
250
|
+
.object({
|
|
224
251
|
version: z.number().describe('Input map file format version (RESERVED — no range check yet)'),
|
|
225
252
|
actions: z
|
|
226
253
|
.record(z.string(), InputActionSchema)
|
|
227
254
|
.describe('Named actions, each with a list of bindings (InputManager.loadMap)'),
|
|
228
|
-
})
|
|
255
|
+
})
|
|
256
|
+
.strict();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filename.d.ts","sourceRoot":"","sources":["../../src/manifest/filename.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filename.d.ts","sourceRoot":"","sources":["../../src/manifest/filename.ts"],"names":[],"mappings":"AAkBA,4EAA4E;AAC5E,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,iFAAiF;AACjF,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAE1D,4DAA4D;AAC5D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CASpE"}
|