@skewedaspect/sage 0.9.6 → 0.10.0-beta.2

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.
Files changed (74) hide show
  1. package/dist/behaviors/sound.d.ts +12 -127
  2. package/dist/classes/debugConsole.d.ts +1 -0
  3. package/dist/classes/gameEngine.d.ts +31 -46
  4. package/dist/classes/gameLevel.d.ts +21 -12
  5. package/dist/classes/level.d.ts +24 -29
  6. package/dist/entities/constants.d.ts +1 -0
  7. package/dist/entities/defineEntity.d.ts +17 -0
  8. package/dist/entities/entityPicking.d.ts +15 -0
  9. package/dist/entities/meshConfig.d.ts +14 -0
  10. package/dist/entities/nodeEntity.d.ts +43 -0
  11. package/dist/entities/nodePool.d.ts +8 -0
  12. package/dist/entities/nodeSimulation.d.ts +30 -0
  13. package/dist/entities/nodeSimulationContext.d.ts +17 -0
  14. package/dist/entities/standardMeshSource.d.ts +8 -0
  15. package/dist/events/payloads.d.ts +0 -42
  16. package/dist/events/types.d.ts +2 -23
  17. package/dist/input/actionContext.d.ts +13 -0
  18. package/dist/input/actionRegistry.d.ts +7 -0
  19. package/dist/input/binding.d.ts +33 -0
  20. package/dist/input/bindings/delta.d.ts +23 -0
  21. package/dist/input/bindings/toggle.d.ts +25 -0
  22. package/dist/input/bindings/trigger.d.ts +23 -0
  23. package/dist/input/bindings/value.d.ts +26 -0
  24. package/dist/input/configuration.d.ts +15 -0
  25. package/dist/input/deliverAction.d.ts +4 -0
  26. package/dist/input/deviceReader.d.ts +5 -0
  27. package/dist/input/deviceReaders/gamepad.d.ts +9 -0
  28. package/dist/input/deviceReaders/keyboard.d.ts +8 -0
  29. package/dist/input/deviceReaders/mouse.d.ts +9 -0
  30. package/dist/input/deviceState.d.ts +24 -0
  31. package/dist/input/inputCapture.d.ts +21 -0
  32. package/dist/input/resolveBinding.d.ts +4 -0
  33. package/dist/interfaces/game.d.ts +21 -5
  34. package/dist/interfaces/level.d.ts +21 -3
  35. package/dist/managers/asset.d.ts +17 -3
  36. package/dist/managers/game.d.ts +15 -5
  37. package/dist/managers/input.d.ts +31 -51
  38. package/dist/managers/level.d.ts +20 -4
  39. package/dist/managers/outline.d.ts +4 -4
  40. package/dist/managers/simulationSave.d.ts +38 -0
  41. package/dist/{postProcessingFrameGraph-CaMgQzR-.js → postProcessingFrameGraph-C3Og4kaS.js} +34 -26
  42. package/dist/postProcessingFrameGraph-C3Og4kaS.js.map +1 -0
  43. package/dist/sage.d.ts +54 -16
  44. package/dist/sage.es.js +1868 -2424
  45. package/dist/sage.es.js.map +1 -1
  46. package/dist/sage.umd.js +1 -1
  47. package/dist/sage.umd.js.map +1 -1
  48. package/dist/utils/bounds.d.ts +11 -0
  49. package/dist/utils/physics.d.ts +4 -1
  50. package/package.json +29 -66
  51. package/LICENSE +0 -21
  52. package/Readme.md +0 -73
  53. package/dist/behaviors/index.d.ts +0 -2
  54. package/dist/behaviors/stateMachine.d.ts +0 -76
  55. package/dist/classes/bindings/toggle.d.ts +0 -116
  56. package/dist/classes/bindings/trigger.d.ts +0 -81
  57. package/dist/classes/bindings/value.d.ts +0 -104
  58. package/dist/classes/entity.d.ts +0 -332
  59. package/dist/classes/input/gamepad.d.ts +0 -94
  60. package/dist/classes/input/keyboard.d.ts +0 -66
  61. package/dist/classes/input/mouse.d.ts +0 -91
  62. package/dist/classes/input/readers/gamepad.d.ts +0 -73
  63. package/dist/classes/input/readers/keyboard.d.ts +0 -56
  64. package/dist/classes/input/readers/mouse.d.ts +0 -41
  65. package/dist/interfaces/action.d.ts +0 -22
  66. package/dist/interfaces/binding.d.ts +0 -123
  67. package/dist/interfaces/entity.d.ts +0 -97
  68. package/dist/interfaces/input.d.ts +0 -180
  69. package/dist/managers/binding.d.ts +0 -233
  70. package/dist/managers/entity.d.ts +0 -264
  71. package/dist/managers/save.d.ts +0 -75
  72. package/dist/postProcessingFrameGraph-CaMgQzR-.js.map +0 -1
  73. package/dist/utils/entityProxy.d.ts +0 -2
  74. package/dist/utils/raycast.d.ts +0 -26
@@ -1,332 +0,0 @@
1
- import { TransformNode } from '@babylonjs/core';
2
- import { GameEntityBehaviorConstructor } from "../interfaces/entity.d.ts";
3
- import { Destroyable } from "../interfaces/lifecycle.d.ts";
4
- import { ColliderDebugConfig } from "../managers/colliderDebug.d.ts";
5
- import { GameEvent, GameEventBus } from "./eventBus.d.ts";
6
- import { GameEngine } from "./gameEngine.d.ts";
7
- /**
8
- * Result of a request sent to an entity's behaviors.
9
- * `success: true` means a behavior handled the request and returned a value.
10
- * `success: false` means no behavior handled it, or a behavior threw an error.
11
- */
12
- export type RequestResult<T> = {
13
- success: true;
14
- value: T;
15
- } | {
16
- success: false;
17
- error: string;
18
- };
19
- /**
20
- * Narrow interface for entity-to-manager messaging delegation.
21
- * Avoids a circular import between entity.ts and managers/entity.ts.
22
- */
23
- interface EntityMessenger {
24
- send(target: string, type: string, payload?: unknown, senderID?: string): Promise<void>;
25
- request<T>(target: string, type: string, payload?: unknown, senderID?: string): Promise<RequestResult<T>>;
26
- }
27
- /**
28
- * Options for attaching a behavior at a specific position.
29
- * Only one positioning option should be specified.
30
- */
31
- export interface AttachBehaviorOptions {
32
- /** Insert before behavior of this class */
33
- before?: GameEntityBehaviorConstructor;
34
- /** Insert after behavior of this class */
35
- after?: GameEntityBehaviorConstructor;
36
- /** Insert at specific index (0-based, clamped to valid range) */
37
- at?: number;
38
- }
39
- /**
40
- * Minimal entity surface exposed to behaviors, preventing them from accessing internals like
41
- * subscription management or behavior ordering.
42
- */
43
- interface SimpleGameEntity<EntityState extends object = object> {
44
- id: string;
45
- type: string;
46
- name?: string;
47
- node?: TransformNode;
48
- state: EntityState;
49
- eventBus: GameEventBus;
50
- tags: ReadonlySet<string>;
51
- send(target: string, type: string, payload?: unknown): Promise<void>;
52
- request<T>(target: string, type: string, payload?: unknown): Promise<RequestResult<T>>;
53
- }
54
- /**
55
- * Base class for game entity behaviors. Subclass this to define how an entity reacts to events
56
- * and updates each frame. Multiple behaviors can be attached to a single entity; event processing
57
- * order matches the attachment order.
58
- */
59
- export declare abstract class GameEntityBehavior<RequiredState extends object = object> {
60
- abstract name: string;
61
- abstract eventSubscriptions: string[];
62
- protected entity: SimpleGameEntity<RequiredState> | null;
63
- $emit(event: GameEvent): void;
64
- /**
65
- * Emits an entity:state-changed event to notify UI or other observers of state changes.
66
- * Call this after making significant state changes that external systems should know about.
67
- *
68
- * @param state - Optional state to include in the event. If omitted, uses current entity state.
69
- * @param changes - Optional record of specific changes made (alternative to full state).
70
- */
71
- $emitStateChanged(state?: object, changes?: Record<string, unknown>): void;
72
- /**
73
- * Sets the entity for this behavior.
74
- * @param entity
75
- */
76
- $setEntity(entity: SimpleGameEntity<RequiredState> | null): void;
77
- abstract processEvent(event: GameEvent, state: RequiredState): Promise<boolean> | boolean;
78
- /**
79
- * Handles a direct request sent to this entity. Return a value to respond,
80
- * or `undefined` to pass the request to the next behavior.
81
- *
82
- * @param event - The request event (type, payload, senderID, targetID)
83
- * @param state - Current entity state
84
- */
85
- processRequest?(event: GameEvent, state: RequiredState): Promise<unknown> | unknown | undefined;
86
- update?(dt: number, state: RequiredState): void;
87
- destroy?(): Promise<void>;
88
- /**
89
- * Called when the entity is attached to a scene node.
90
- * Override to perform initialization that requires the node (physics, spatial audio, etc.)
91
- *
92
- * The scene is accessible via `node.getScene()`.
93
- *
94
- * @param node - The TransformNode (typically a Mesh) the entity is attached to.
95
- * @param gameEngine - The game engine instance for accessing managers and engines.
96
- */
97
- onNodeAttached?(node: TransformNode, gameEngine: GameEngine): void;
98
- /**
99
- * Called when the entity is detached from its scene node.
100
- * Override to clean up node-dependent resources.
101
- */
102
- onNodeDetached?(): void;
103
- /**
104
- * Called when the entity is recycled from an object pool.
105
- * Override to reset behavior-specific state that isn't covered by entity state reset.
106
- * Distinct from onNodeDetached — this signals a full lifecycle reset.
107
- *
108
- * @param state - The freshly reset entity state.
109
- */
110
- onReset?(state: RequiredState): void;
111
- }
112
- /**
113
- * Base class for game entities. Owns a set of behaviors, manages event subscriptions
114
- * (reference-counted per event type), and delegates lifecycle calls to its behaviors.
115
- */
116
- export declare class GameEntity<EntityState extends object = object> implements SimpleGameEntity<EntityState>, Destroyable {
117
- /** The unique identifier of the entity (16-char hex string). */
118
- readonly id: string;
119
- readonly type: string;
120
- /** Optional human-readable name for the entity. */
121
- readonly name?: string;
122
- /**
123
- * The scene node this entity is attached to (if any).
124
- * When attached, the entity controls this node's behavior.
125
- * Use EntityManager.attachToNode() / detachFromNode() to modify.
126
- */
127
- readonly node?: TransformNode;
128
- /** Child entities in the hierarchy. */
129
- readonly children: GameEntity[];
130
- /** Parent entity in the hierarchy, or null if this is a root entity. */
131
- readonly parent: GameEntity | null;
132
- state: EntityState;
133
- /** Array of behaviors attached to the entity. Order determines event processing priority. */
134
- behaviors: GameEntityBehavior[];
135
- eventBus: GameEventBus;
136
- private _gameEngine;
137
- private _entityManager;
138
- private _tags;
139
- private subscriptions;
140
- /**
141
- * Creates an instance of GameEntity.
142
- * @param type
143
- * @param eventBus
144
- * @param initialState
145
- * @param behaviors - Attached in order; order determines event processing priority.
146
- * @param name
147
- */
148
- constructor(type: string, eventBus: GameEventBus, initialState: EntityState, behaviors: GameEntityBehaviorConstructor[], name?: string);
149
- /**
150
- * Read-only access to the entity's tags.
151
- */
152
- get tags(): ReadonlySet<string>;
153
- /**
154
- * Checks if the entity has a specific tag.
155
- * @param tag
156
- */
157
- hasTag(tag: string): boolean;
158
- /**
159
- * Internal method for EntityManager to add a tag.
160
- * @param tag
161
- */
162
- $addTag(tag: string): void;
163
- /**
164
- * Internal method for EntityManager to remove a tag.
165
- * @param tag
166
- */
167
- $removeTag(tag: string): boolean;
168
- /**
169
- * Find a direct child node by name.
170
- * @param name
171
- */
172
- getChildNode(name: string): TransformNode | undefined;
173
- /**
174
- * Find a descendant node by path (e.g., "armature/hand/finger").
175
- * @param path - Slash-separated path of node names.
176
- */
177
- findNode(path: string): TransformNode | undefined;
178
- /**
179
- * Internal method for EntityManager to attach entity to a node.
180
- * Do not call directly - use EntityManager.attachToNode() instead.
181
- * @param node
182
- * @param gameEngine
183
- * @internal
184
- */
185
- $attachToNode(node: TransformNode, gameEngine: GameEngine): void;
186
- /**
187
- * Internal method for EntityManager to detach entity from its node.
188
- * Do not call directly - use EntityManager.detachFromNode() instead.
189
- * @internal
190
- */
191
- $detachFromNode(): void;
192
- /**
193
- * Add this entity to a named outline layer for visual highlighting.
194
- * Requires the entity to be attached to a node in a level with outlines configured.
195
- *
196
- * @param layerName - The name of the outline layer (must exist on the current level)
197
- */
198
- highlight(layerName: string): void;
199
- /**
200
- * Remove this entity from an outline layer, or from all layers if no name given.
201
- *
202
- * @param layerName - Specific layer to remove from, or omit to remove from all
203
- */
204
- unhighlight(layerName?: string): void;
205
- /**
206
- * Shows collider debug visualization for this entity's physics nodes.
207
- *
208
- * Overloads:
209
- * - `showCollider()` — show all colliders, default color
210
- * - `showCollider(true)` — show all colliders, default color (config-driven)
211
- * - `showCollider('#ff0000')` — show all colliders with a specific color
212
- * - `showCollider('head')` — show a specific collider by node name
213
- * - `showCollider('head', '#ff0000')` — show a specific collider by name with color
214
- * - `showCollider({ head: '#ff0000', body: false })` — per-collider control
215
- */
216
- showCollider(configOrNameOrColor?: ColliderDebugConfig, color?: string): void;
217
- /**
218
- * Hides collider debug visualization for this entity's physics nodes.
219
- *
220
- * - `hideCollider()` — hide all colliders
221
- * - `hideCollider('head')` — hide a specific collider by node name
222
- */
223
- hideCollider(name?: string): void;
224
- private _getPhysicsNodes;
225
- /**
226
- * Adds a child entity to this entity's hierarchy.
227
- * Sets the child's parent to this entity. If both entities have nodes, parents the child's node.
228
- * @param child
229
- */
230
- $addChild(child: GameEntity): void;
231
- /**
232
- * Removes a child entity from this entity's hierarchy.
233
- * Clears the child's parent reference. If the child has a node, detaches it.
234
- * @param child
235
- */
236
- $removeChild(child: GameEntity): void;
237
- /**
238
- * Sets the entity manager reference for cross-entity messaging.
239
- * Called by the EntityManager after entity creation.
240
- * @param manager
241
- * @internal
242
- */
243
- $setEntityManager(manager: EntityMessenger): void;
244
- /**
245
- * Sends a fire-and-forget event directly to a specific entity's behaviors, bypassing the event bus.
246
- * If the target matches this entity's own ID, dispatches locally.
247
- *
248
- * @param target - Entity ID or name
249
- * @param type - Event type string
250
- * @param payload - Optional event payload
251
- */
252
- send(target: string, type: string, payload?: unknown): Promise<void>;
253
- /**
254
- * Sends a request to a specific entity's behaviors and returns the first response.
255
- * If the target matches this entity's own ID, dispatches locally.
256
- *
257
- * @param target - Entity ID or name
258
- * @param type - Request type string
259
- * @param payload - Optional request payload
260
- */
261
- request<T>(target: string, type: string, payload?: unknown): Promise<RequestResult<T>>;
262
- /**
263
- * Sends a fire-and-forget event directly to this entity's own behaviors.
264
- *
265
- * @param type - Event type string
266
- * @param payload - Optional event payload
267
- * @internal
268
- */
269
- $send(type: string, payload?: unknown, senderID?: string): Promise<void>;
270
- /**
271
- * Sends a request to this entity's own behaviors and returns the first response.
272
- *
273
- * @param type - Request type string
274
- * @param payload - Optional request payload
275
- * @internal
276
- */
277
- $request<T>(type: string, payload?: unknown, senderID?: string): Promise<RequestResult<T>>;
278
- /**
279
- * Resets the entity for object pool recycling.
280
- * Restores state and tags to defaults, detaches from node, notifies behaviors, and resets children.
281
- * @param defaultState - Default state from the entity definition
282
- * @param defaultTags - Default tags from the entity definition
283
- */
284
- $reset(defaultState: object, defaultTags: string[]): void;
285
- /**
286
- * Processes a game event by passing it to the entity's behaviors.
287
- * @param event
288
- */
289
- $processEvent(event: GameEvent): Promise<void>;
290
- /**
291
- * Updates the entity by calling the update method of its behaviors.
292
- * @param dt - Seconds elapsed since the last update.
293
- */
294
- $update(dt: number): void;
295
- /**
296
- * Destroys the entity by calling the destroy method of its behaviors and unsubscribing from all events.
297
- */
298
- $destroy(): Promise<void>;
299
- /**
300
- * Finds the index of a behavior by its constructor.
301
- * @param behaviorClass
302
- */
303
- private findBehaviorIndex;
304
- /**
305
- * Checks if a behavior of the given class is attached.
306
- * @param behaviorClass
307
- */
308
- hasBehavior(behaviorClass: GameEntityBehaviorConstructor): boolean;
309
- /**
310
- * Gets a behavior by its constructor.
311
- * @param behaviorClass
312
- */
313
- getBehavior<T extends GameEntityBehavior>(behaviorClass: new () => T): T | undefined;
314
- /**
315
- * Attaches a behavior to the entity.
316
- * Without options, appends to the end (most common case).
317
- * With options, inserts at the specified position.
318
- *
319
- * @param behavior
320
- * @param options
321
- * @throws If the behavior is already attached.
322
- * @throws If 'before' or 'after' target is not found.
323
- * @throws If more than one positioning option is specified.
324
- */
325
- attachBehavior(behavior: GameEntityBehavior, options?: AttachBehaviorOptions): void;
326
- /**
327
- * Detaches a behavior from the entity by its constructor.
328
- * @param behaviorClass
329
- */
330
- detachBehavior(behaviorClass: GameEntityBehaviorConstructor): boolean;
331
- }
332
- export {};
@@ -1,94 +0,0 @@
1
- import { GamepadDevice, GamepadInputState } from "../../interfaces/input.d.ts";
2
- /**
3
- * Callback type for gamepad device connection events
4
- */
5
- export type GamepadDeviceCallback = (device: GamepadDevice) => void;
6
- /**
7
- * Callback type for gamepad input events
8
- */
9
- export type GamepadInputCallback = (device: GamepadDevice, state: GamepadInputState) => void;
10
- /**
11
- * Responsible for tracking gamepad state and notifying subscribers of changes.
12
- */
13
- export declare class GamepadInputPlugin {
14
- private _gamepadDevices;
15
- private _buttonStates;
16
- private _axesStates;
17
- private _onDeviceConnected?;
18
- private _onDeviceDisconnected?;
19
- private _onInputChanged?;
20
- /**
21
- * Create a new GamepadInputPlugin
22
- */
23
- constructor();
24
- /**
25
- * Register a callback for device connected events
26
- *
27
- * @param callback
28
- */
29
- onDeviceConnected(callback: GamepadDeviceCallback): void;
30
- /**
31
- * Register a callback for device disconnected events
32
- *
33
- * @param callback
34
- */
35
- onDeviceDisconnected(callback: GamepadDeviceCallback): void;
36
- /**
37
- * Register a callback for input changed events
38
- *
39
- * @param callback
40
- */
41
- onInputChanged(callback: GamepadInputCallback): void;
42
- /**
43
- * Get all connected gamepad devices
44
- */
45
- getDevices(): GamepadDevice[];
46
- /**
47
- * Get all connected gamepad states
48
- */
49
- getStates(): Record<number, GamepadInputState>;
50
- /**
51
- * Get a specific gamepad device by index
52
- *
53
- * @param index
54
- */
55
- getDevice(index: number): GamepadDevice | null;
56
- /**
57
- * Get a specific gamepad state by index
58
- *
59
- * @param index
60
- */
61
- getState(index: number): GamepadInputState | null;
62
- /**
63
- * Poll for gamepad state updates - call this in your game loop
64
- */
65
- pollGamepads(): void;
66
- /**
67
- * Tears down the gamepad resource access and cleans up event listeners
68
- */
69
- $teardown(): Promise<void>;
70
- /**
71
- * Set up gamepad event listeners
72
- */
73
- private _setupGamepadEvents;
74
- /**
75
- * Handle gamepad connected event
76
- */
77
- private _handleGamepadConnected;
78
- /**
79
- * Handle gamepad disconnected event
80
- */
81
- private _handleGamepadDisconnected;
82
- /**
83
- * Notify subscribers of device connected event
84
- */
85
- private _notifyDeviceConnected;
86
- /**
87
- * Notify subscribers of device disconnected event
88
- */
89
- private _notifyDeviceDisconnected;
90
- /**
91
- * Notify subscribers of input changed event
92
- */
93
- private _notifyInputChanged;
94
- }
@@ -1,66 +0,0 @@
1
- import { KeyboardDevice, KeyboardInputState } from "../../interfaces/input.d.ts";
2
- /**
3
- * Callback type for keyboard device connection events
4
- */
5
- export type KeyboardDeviceCallback = (device: KeyboardDevice) => void;
6
- /**
7
- * Callback type for keyboard input events
8
- */
9
- export type KeyboardInputCallback = (device: KeyboardDevice, state: KeyboardInputState) => void;
10
- /**
11
- * Responsible for tracking keyboard state and notifying subscribers of changes.
12
- */
13
- export declare class KeyboardInputPlugin {
14
- private _keyboardDevice;
15
- private _keysState;
16
- private _onDeviceConnected?;
17
- private _onInputChanged?;
18
- /**
19
- * Create a new KeyboardInputPlugin
20
- */
21
- constructor();
22
- /**
23
- * Register a callback for device connected events
24
- *
25
- * @param callback
26
- */
27
- onDeviceConnected(callback: KeyboardDeviceCallback): void;
28
- /**
29
- * Register a callback for input changed events
30
- *
31
- * @param callback
32
- */
33
- onInputChanged(callback: KeyboardInputCallback): void;
34
- /**
35
- * Get the current keyboard state
36
- */
37
- getState(): KeyboardInputState;
38
- /**
39
- * Get the keyboard device
40
- */
41
- getDevice(): KeyboardDevice;
42
- /**
43
- * Tears down the keyboard resource access and cleans up event listeners
44
- */
45
- $teardown(): Promise<void>;
46
- /**
47
- * Set up keyboard event listeners
48
- */
49
- private _setupKeyboardEvents;
50
- /**
51
- * Handle keyboard key down events
52
- */
53
- private _handleKeyDown;
54
- /**
55
- * Handle keyboard key up events
56
- */
57
- private _handleKeyUp;
58
- /**
59
- * Notify subscribers of device connected event
60
- */
61
- private _notifyDeviceConnected;
62
- /**
63
- * Notify subscribers of input changed event
64
- */
65
- private _notifyInputChanged;
66
- }
@@ -1,91 +0,0 @@
1
- import { MouseDevice, MouseInputState } from "../../interfaces/input.d.ts";
2
- /**
3
- * Callback type for mouse device connection events
4
- */
5
- export type MouseDeviceCallback = (device: MouseDevice) => void;
6
- /**
7
- * Callback type for mouse input events
8
- */
9
- export type MouseInputCallback = (device: MouseDevice, state: MouseInputState) => void;
10
- /**
11
- * Responsible for tracking mouse state and notifying subscribers of changes.
12
- */
13
- export declare class MouseInputPlugin {
14
- private _targetElement;
15
- private _mouseDevice;
16
- private _buttonState;
17
- private _axesState;
18
- private _position;
19
- private _wheelState;
20
- private _onDeviceConnected?;
21
- private _onInputChanged?;
22
- /**
23
- * Create a new MouseInputPlugin
24
- *
25
- * @param targetElement - DOM element to attach mouse listeners to (defaults to document.body)
26
- */
27
- constructor(targetElement?: HTMLElement);
28
- /**
29
- * Register a callback for device connected events
30
- *
31
- * @param callback
32
- */
33
- onDeviceConnected(callback: MouseDeviceCallback): void;
34
- /**
35
- * Register a callback for input changed events
36
- *
37
- * @param callback
38
- */
39
- onInputChanged(callback: MouseInputCallback): void;
40
- /**
41
- * Get the current mouse state
42
- */
43
- getState(): MouseInputState;
44
- /**
45
- * Get the mouse device
46
- */
47
- getDevice(): MouseDevice;
48
- /**
49
- * Tears down the mouse resource access and cleans up event listeners
50
- */
51
- $teardown(): Promise<void>;
52
- /**
53
- * Set up pointer and wheel event listeners. We use pointer events instead of mouse events
54
- * because BabylonJS calls preventDefault() on pointerdown, which suppresses the
55
- * corresponding mousedown/mouseup per the Pointer Events spec.
56
- */
57
- private _setupMouseEvents;
58
- /**
59
- * Handle pointer down events (mouse buttons)
60
- */
61
- private _handlePointerDown;
62
- /**
63
- * Handle pointer up events (mouse buttons)
64
- */
65
- private _handlePointerUp;
66
- /**
67
- * Handle pointer move events (mouse position)
68
- */
69
- private _handlePointerMove;
70
- /**
71
- * Handle mouse wheel events.
72
- *
73
- * The wheel is a pulse, not a level: the browser reports a delta per notch and never reports "stopped scrolling".
74
- * So each event notifies twice — once carrying the deltas, once carrying zeros. Without that trailing zero,
75
- * `emitOnChange` value bindings swallow every notch after the first (consecutive notches report identical deltas),
76
- * trigger bindings never see a falling edge to re-arm on, and `getState()` latches the last scroll forever.
77
- */
78
- private _handleMouseWheel;
79
- /**
80
- * Notify subscribers of the current wheel state, attributed to the wheel event that produced it
81
- */
82
- private _notifyWheelState;
83
- /**
84
- * Notify subscribers of device connected event
85
- */
86
- private _notifyDeviceConnected;
87
- /**
88
- * Notify subscribers of input changed event
89
- */
90
- private _notifyInputChanged;
91
- }
@@ -1,73 +0,0 @@
1
- import { DeviceValueReader, GamepadValueReaderDefinition, InputState } from "../../../interfaces/input.d.ts";
2
- /**
3
- * Types of gamepad input sources
4
- */
5
- export type GamepadSourceType = 'button' | 'axis';
6
- /**
7
- * Options for configuring a gamepad value reader
8
- */
9
- export interface GamepadReaderOptions {
10
- /**
11
- * Whether to use the analog value instead of boolean pressed state for buttons
12
- */
13
- useAnalogValue?: boolean;
14
- /**
15
- * Deadzone value (0.0 - 1.0) for analog axes
16
- * Input values below this threshold will be treated as 0
17
- */
18
- deadzone?: number;
19
- /**
20
- * Whether to invert the axis values
21
- */
22
- invert?: boolean;
23
- }
24
- /**
25
- * Reads values from gamepad input states
26
- */
27
- export declare class GamepadValueReader implements DeviceValueReader {
28
- /**
29
- * Whether this reader targets a button or analog axis.
30
- */
31
- readonly sourceType: GamepadSourceType;
32
- /**
33
- * Identifies the specific button or axis (e.g. "button-0", "axis-1")
34
- */
35
- readonly sourceKey: string;
36
- /**
37
- * When true, returns the pressure-sensitive float value instead of boolean pressed state for buttons.
38
- */
39
- private readonly useAnalogValue;
40
- /**
41
- * Axis values below this threshold are treated as 0 (default 10%)
42
- */
43
- private readonly deadzone;
44
- /**
45
- * Multiplies axis values by -1 when true
46
- */
47
- private readonly invert;
48
- /**
49
- * Creates a new GamepadValueReader
50
- *
51
- * @param sourceType
52
- * @param sourceKey - e.g. "button-0", "axis-1"
53
- * @param options
54
- */
55
- constructor(sourceType: GamepadSourceType, sourceKey: string, options?: GamepadReaderOptions);
56
- /**
57
- * Gets the value of the input source. Returns undefined for non-gamepad input states.
58
- *
59
- * @param state
60
- */
61
- getValue(state: InputState): boolean | number | undefined;
62
- /**
63
- * Creates a GamepadValueReader from a colon-delimited string (e.g. "button:0", "axis:1")
64
- *
65
- * @param sourceTypeString
66
- * @param options
67
- */
68
- static fromString(sourceTypeString: string, options?: GamepadReaderOptions): GamepadValueReader;
69
- /**
70
- * Returns a JSON-serializable representation of this gamepad value reader.
71
- */
72
- toJSON(): GamepadValueReaderDefinition;
73
- }