@ue-too/board 0.9.4 → 0.10.0
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 +66 -2
- package/boardify/index.d.ts +280 -9
- package/camera/base.d.ts +364 -68
- package/camera/camera-edge-auto-input.d.ts +105 -0
- package/camera/camera-mux/animation-and-lock/animation-and-lock.d.ts +316 -14
- package/camera/camera-mux/animation-and-lock/index.d.ts +27 -0
- package/camera/camera-mux/animation-and-lock/pan-control-state-machine.d.ts +143 -60
- package/camera/camera-mux/animation-and-lock/rotation-control-state-machine.d.ts +143 -55
- package/camera/camera-mux/animation-and-lock/zoom-control-state-machine.d.ts +205 -58
- package/camera/camera-mux/index.d.ts +26 -0
- package/camera/camera-mux/interface.d.ts +161 -5
- package/camera/camera-mux/relay.d.ts +79 -16
- package/camera/camera-rig/camera-rig.d.ts +536 -94
- package/camera/camera-rig/index.d.ts +26 -1
- package/camera/camera-rig/pan-handler.d.ts +508 -48
- package/camera/camera-rig/rotation-handler.d.ts +353 -31
- package/camera/camera-rig/zoom-handler.d.ts +369 -32
- package/camera/default-camera.d.ts +173 -26
- package/camera/index.d.ts +20 -0
- package/camera/interface.d.ts +202 -2
- package/camera/update-publisher.d.ts +128 -38
- package/camera/utils/coordinate-conversion.d.ts +323 -26
- package/camera/utils/index.d.ts +22 -0
- package/camera/utils/matrix.d.ts +217 -14
- package/camera/utils/position.d.ts +249 -11
- package/camera/utils/rotation.d.ts +139 -9
- package/camera/utils/zoom.d.ts +72 -4
- package/index.d.ts +37 -0
- package/index.js +2 -4796
- package/index.js.map +39 -38
- package/input-interpretation/index.d.ts +29 -0
- package/input-interpretation/input-orchestrator.d.ts +197 -0
- package/input-interpretation/input-state-machine/index.d.ts +18 -0
- package/input-interpretation/input-state-machine/kmt-input-context.d.ts +191 -38
- package/input-interpretation/input-state-machine/kmt-input-state-machine.d.ts +201 -85
- package/input-interpretation/input-state-machine/touch-input-context.d.ts +76 -10
- package/input-interpretation/input-state-machine/touch-input-state-machine.d.ts +138 -17
- package/input-interpretation/raw-input-parser/index.d.ts +19 -0
- package/input-interpretation/raw-input-parser/vanilla-kmt-event-parser.d.ts +107 -21
- package/input-interpretation/raw-input-parser/vanilla-touch-event-parser.d.ts +71 -8
- package/input-interpretation/raw-input-publisher/index.d.ts +18 -0
- package/input-interpretation/raw-input-publisher/raw-input-publisher.d.ts +133 -37
- package/package.json +3 -3
- package/utils/canvas-position-dimension.d.ts +282 -1
- package/utils/coordinate-conversions/canvas-viewport.d.ts +79 -0
- package/utils/coordinate-conversions/viewport-world.d.ts +101 -0
- package/utils/coordinate-conversions/window-canvas.d.ts +90 -0
- package/utils/coorindate-conversion.d.ts +91 -0
- package/utils/drawing.d.ts +151 -3
- package/utils/index.d.ts +21 -0
- package/utils/observable.d.ts +179 -0
- package/utils/ruler.d.ts +36 -0
- package/utils/zoomlevel-adjustment.d.ts +144 -8
- package/camera/camera-rig/update-batcher/index.d.ts +0 -3
- package/camera/camera-rig/update-batcher/position-update-batcher.d.ts +0 -58
- package/camera/camera-rig/update-batcher/rotation-update-batcher.d.ts +0 -54
- package/camera/camera-rig/update-batcher/zoom-udpate-batcher.d.ts +0 -60
|
@@ -1,50 +1,352 @@
|
|
|
1
|
-
import { CameraMux } from "../interface";
|
|
1
|
+
import { CameraMux, CameraMuxPanOutput, CameraMuxZoomOutput, CameraMuxRotationOutput } from "../interface";
|
|
2
2
|
import { Point } from "@ue-too/math";
|
|
3
3
|
import { ObservableBoardCamera } from "../../interface";
|
|
4
4
|
import { PanControlStateMachine } from "./pan-control-state-machine";
|
|
5
5
|
import { ZoomControlStateMachine } from "./zoom-control-state-machine";
|
|
6
|
-
import { RotateControlStateMachine } from "./rotation-control-state-machine";
|
|
6
|
+
import { RotateControlStateMachine, RotateControlOutputEvent } from "./rotation-control-state-machine";
|
|
7
7
|
import { CameraRig } from "../../camera-rig";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Advanced camera input multiplexer with animation support and input locking via state machines.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This {@link CameraMux} implementation provides sophisticated input flow control using
|
|
13
|
+
* separate state machines for pan, zoom, and rotation. Each state machine can:
|
|
14
|
+
* - Block user input during camera animations
|
|
15
|
+
* - Manage animation playback
|
|
16
|
+
* - Arbitrate between user input and programmatic camera control
|
|
17
|
+
* - Handle transitions between different camera control states
|
|
12
18
|
*
|
|
13
|
-
*
|
|
19
|
+
* **Key features:**
|
|
20
|
+
* - **Animation system**: Support for smooth camera animations (pan-to, zoom-to, rotate-to)
|
|
21
|
+
* - **Input locking**: Automatically block user input during animations
|
|
22
|
+
* - **State-based control**: Each camera operation (pan/zoom/rotate) has its own state machine
|
|
23
|
+
* - **Flexible transitions**: Initiate transitions to interrupt or chain animations
|
|
14
24
|
*
|
|
15
|
-
*
|
|
25
|
+
* **Architecture:**
|
|
26
|
+
* - Three independent state machines: {@link PanControlStateMachine}, {@link ZoomControlStateMachine}, {@link RotateControlStateMachine}
|
|
27
|
+
* - Each state machine decides whether to allow or block input based on current state
|
|
28
|
+
* - State machines receive events and produce output events for camera operations
|
|
29
|
+
*
|
|
30
|
+
* **When to use:**
|
|
31
|
+
* - Applications requiring smooth camera animations (e.g., "focus on object", "zoom to region")
|
|
32
|
+
* - UI where user input should be blocked during programmatic camera movements
|
|
33
|
+
* - Games or interactive experiences with scripted camera sequences
|
|
34
|
+
*
|
|
35
|
+
* **Alternatives:**
|
|
36
|
+
* - Use {@link Relay} for simple passthrough without animation support
|
|
37
|
+
* - Implement custom {@link CameraMux} for different state management approaches
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const camera = new DefaultBoardCamera();
|
|
42
|
+
* const mux = createCameraMuxWithAnimationAndLock(camera);
|
|
43
|
+
*
|
|
44
|
+
* // Start a pan animation - user input will be blocked
|
|
45
|
+
* mux.notifyPanToAnimationInput({ x: 1000, y: 500 });
|
|
46
|
+
*
|
|
47
|
+
* // User tries to pan during animation - will be blocked
|
|
48
|
+
* const result = mux.notifyPanInput({ x: 50, y: 30 });
|
|
49
|
+
* // result.allowPassThrough = false (blocked during animation)
|
|
50
|
+
*
|
|
51
|
+
* // After animation completes, user input allowed again
|
|
52
|
+
* ```
|
|
16
53
|
*
|
|
17
54
|
* @category Input Flow Control
|
|
55
|
+
* @see {@link CameraMux} for the interface definition
|
|
56
|
+
* @see {@link Relay} for simpler passthrough implementation
|
|
57
|
+
* @see {@link createCameraMuxWithAnimationAndLock} for factory function
|
|
18
58
|
*/
|
|
19
59
|
export declare class CameraMuxWithAnimationAndLock implements CameraMux {
|
|
20
60
|
private _panStateMachine;
|
|
21
61
|
private _zoomStateMachine;
|
|
22
62
|
private _rotateStateMachine;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a new camera mux with animation and locking capabilities.
|
|
65
|
+
*
|
|
66
|
+
* @param panStateMachine - State machine controlling pan operations and animations
|
|
67
|
+
* @param zoomStateMachine - State machine controlling zoom operations and animations
|
|
68
|
+
* @param rotateStateMachine - State machine controlling rotation operations and animations
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* Typically created via factory functions like {@link createCameraMuxWithAnimationAndLock}
|
|
72
|
+
* rather than direct instantiation.
|
|
73
|
+
*/
|
|
23
74
|
constructor(panStateMachine: PanControlStateMachine, zoomStateMachine: ZoomControlStateMachine, rotateStateMachine: RotateControlStateMachine);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Initiates a pan animation to a target position.
|
|
77
|
+
*
|
|
78
|
+
* @param target - Target position in world coordinates
|
|
79
|
+
* @returns Pan output indicating whether animation was initiated
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
82
|
+
* This method starts a camera pan animation to the specified world position.
|
|
83
|
+
* The state machine handles:
|
|
84
|
+
* - Starting the animation
|
|
85
|
+
* - Blocking user input during animation
|
|
86
|
+
* - Producing incremental pan deltas each frame
|
|
87
|
+
*
|
|
88
|
+
* The animation continues until the camera reaches the target or is interrupted.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* // Animate camera to world position
|
|
93
|
+
* mux.notifyPanToAnimationInput({ x: 1000, y: 500 });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
notifyPanToAnimationInput(target: Point): CameraMuxPanOutput;
|
|
97
|
+
/**
|
|
98
|
+
* Processes user pan input (implements {@link CameraMux.notifyPanInput}).
|
|
99
|
+
*
|
|
100
|
+
* @param delta - Pan delta in viewport coordinates
|
|
101
|
+
* @returns Output indicating whether pan is allowed
|
|
102
|
+
*
|
|
103
|
+
* @remarks
|
|
104
|
+
* This method is called when the user attempts to pan the camera (e.g., mouse drag).
|
|
105
|
+
* The pan state machine determines whether to allow the input based on current state:
|
|
106
|
+
* - **Allowed**: When in idle state or user control state
|
|
107
|
+
* - **Blocked**: When camera animation is playing
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* // User drags mouse
|
|
112
|
+
* const result = mux.notifyPanInput({ x: 50, y: 30 });
|
|
113
|
+
* if (result.allowPassThrough) {
|
|
114
|
+
* // Apply pan to camera
|
|
115
|
+
* cameraRig.panByViewPort(result.delta);
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
notifyPanInput(delta: Point): CameraMuxPanOutput;
|
|
120
|
+
/**
|
|
121
|
+
* Processes user zoom input (implements {@link CameraMux.notifyZoomInput}).
|
|
122
|
+
*
|
|
123
|
+
* @param delta - Zoom delta (change in zoom level)
|
|
124
|
+
* @param at - Anchor point in viewport coordinates
|
|
125
|
+
* @returns Output indicating whether zoom is allowed
|
|
126
|
+
*
|
|
127
|
+
* @remarks
|
|
128
|
+
* This method is called when the user attempts to zoom (e.g., mouse wheel).
|
|
129
|
+
* The zoom state machine determines whether to allow the input based on current state:
|
|
130
|
+
* - **Allowed**: When in idle state or user control state
|
|
131
|
+
* - **Blocked**: When zoom animation is playing
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* // User scrolls mouse wheel
|
|
136
|
+
* const result = mux.notifyZoomInput(0.1, mousePosition);
|
|
137
|
+
* if (result.allowPassThrough) {
|
|
138
|
+
* // Apply zoom to camera
|
|
139
|
+
* cameraRig.zoomByAt(result.delta, result.anchorPoint);
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
notifyZoomInput(delta: number, at: Point): CameraMuxZoomOutput;
|
|
144
|
+
/**
|
|
145
|
+
* Processes user rotation input (rotate-by variant).
|
|
146
|
+
*
|
|
147
|
+
* @param delta - Rotation delta in radians
|
|
148
|
+
* @returns Output from rotation state machine
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* Delegates to the rotation state machine's rotate-by handler.
|
|
152
|
+
* The state machine determines whether to allow rotation based on current state.
|
|
153
|
+
*/
|
|
154
|
+
notifyRotateByInput(delta: number): import("@ue-too/being").EventResult<import("./rotation-control-state-machine").RotateControlStates, RotateControlOutputEvent>;
|
|
155
|
+
/**
|
|
156
|
+
* Initiates a rotation animation to a target angle.
|
|
157
|
+
*
|
|
158
|
+
* @param target - Target rotation angle in radians
|
|
159
|
+
* @returns Output from rotation state machine
|
|
160
|
+
*
|
|
161
|
+
* @remarks
|
|
162
|
+
* Starts a camera rotation animation to the specified angle.
|
|
163
|
+
* User input will be blocked during the animation.
|
|
164
|
+
*/
|
|
165
|
+
notifyRotateToAnimationInput(target: number): import("@ue-too/being").EventResult<import("./rotation-control-state-machine").RotateControlStates, RotateControlOutputEvent>;
|
|
166
|
+
/**
|
|
167
|
+
* Initiates a zoom animation to a target level at a viewport position.
|
|
168
|
+
*
|
|
169
|
+
* @param targetZoom - Target zoom level
|
|
170
|
+
* @param at - Anchor point in viewport coordinates (defaults to origin)
|
|
171
|
+
*
|
|
172
|
+
* @remarks
|
|
173
|
+
* Starts a zoom animation that zooms to the specified level while keeping
|
|
174
|
+
* the anchor point stationary (zoom-to-cursor behavior).
|
|
175
|
+
* User input will be blocked during the animation.
|
|
176
|
+
*/
|
|
29
177
|
notifyZoomInputAnimation(targetZoom: number, at?: Point): void;
|
|
178
|
+
/**
|
|
179
|
+
* Initiates a zoom animation to a target level at a world position.
|
|
180
|
+
*
|
|
181
|
+
* @param targetZoom - Target zoom level
|
|
182
|
+
* @param at - Anchor point in world coordinates (defaults to origin)
|
|
183
|
+
*
|
|
184
|
+
* @remarks
|
|
185
|
+
* Similar to {@link notifyZoomInputAnimation} but accepts world-space coordinates
|
|
186
|
+
* for the anchor point instead of viewport coordinates.
|
|
187
|
+
*/
|
|
30
188
|
notifyZoomInputAnimationWorld(targetZoom: number, at?: Point): void;
|
|
31
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Processes user rotation input (implements {@link CameraMux.notifyRotationInput}).
|
|
191
|
+
*
|
|
192
|
+
* @param delta - Rotation delta in radians
|
|
193
|
+
* @returns Output indicating whether rotation is allowed
|
|
194
|
+
*
|
|
195
|
+
* @remarks
|
|
196
|
+
* This method is called when the user attempts to rotate the camera.
|
|
197
|
+
* The rotation state machine determines whether to allow the input based on current state:
|
|
198
|
+
* - **Allowed**: When in idle state or user control state
|
|
199
|
+
* - **Blocked**: When rotation animation is playing
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* // User rotates camera
|
|
204
|
+
* const result = mux.notifyRotationInput(0.1);
|
|
205
|
+
* if (result.allowPassThrough) {
|
|
206
|
+
* cameraRig.rotateBy(result.delta);
|
|
207
|
+
* }
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
notifyRotationInput(delta: number): CameraMuxRotationOutput;
|
|
211
|
+
/**
|
|
212
|
+
* Initiates a transition in the pan state machine.
|
|
213
|
+
*
|
|
214
|
+
* @remarks
|
|
215
|
+
* This method forces the pan state machine to transition to its next state.
|
|
216
|
+
* Can be used to interrupt animations or force state changes.
|
|
217
|
+
*/
|
|
32
218
|
initatePanTransition(): void;
|
|
219
|
+
/**
|
|
220
|
+
* Initiates a transition in the zoom state machine.
|
|
221
|
+
*
|
|
222
|
+
* @remarks
|
|
223
|
+
* This method forces the zoom state machine to transition to its next state.
|
|
224
|
+
* Can be used to interrupt animations or force state changes.
|
|
225
|
+
*/
|
|
33
226
|
initateZoomTransition(): void;
|
|
227
|
+
/**
|
|
228
|
+
* Initiates a transition in the rotation state machine.
|
|
229
|
+
*
|
|
230
|
+
* @remarks
|
|
231
|
+
* This method forces the rotation state machine to transition to its next state.
|
|
232
|
+
* Can be used to interrupt animations or force state changes.
|
|
233
|
+
*/
|
|
34
234
|
initateRotateTransition(): void;
|
|
235
|
+
/**
|
|
236
|
+
* Gets the rotation state machine.
|
|
237
|
+
*
|
|
238
|
+
* @returns The rotation state machine instance
|
|
239
|
+
*
|
|
240
|
+
* @remarks
|
|
241
|
+
* Provides direct access to the rotation state machine for advanced control
|
|
242
|
+
* or state inspection.
|
|
243
|
+
*/
|
|
35
244
|
get rotateStateMachine(): RotateControlStateMachine;
|
|
245
|
+
/**
|
|
246
|
+
* Gets the pan state machine.
|
|
247
|
+
*
|
|
248
|
+
* @returns The pan state machine instance
|
|
249
|
+
*
|
|
250
|
+
* @remarks
|
|
251
|
+
* Provides direct access to the pan state machine for advanced control
|
|
252
|
+
* or state inspection.
|
|
253
|
+
*/
|
|
36
254
|
get panStateMachine(): PanControlStateMachine;
|
|
255
|
+
/**
|
|
256
|
+
* Gets the zoom state machine.
|
|
257
|
+
*
|
|
258
|
+
* @returns The zoom state machine instance
|
|
259
|
+
*
|
|
260
|
+
* @remarks
|
|
261
|
+
* Provides direct access to the zoom state machine for advanced control
|
|
262
|
+
* or state inspection.
|
|
263
|
+
*/
|
|
37
264
|
get zoomStateMachine(): ZoomControlStateMachine;
|
|
38
265
|
}
|
|
39
266
|
/**
|
|
40
|
-
*
|
|
267
|
+
* Creates a camera mux with animation and locking capabilities from a camera instance.
|
|
268
|
+
*
|
|
269
|
+
* @param camera - Observable camera to control
|
|
270
|
+
* @returns Configured camera mux with animation support
|
|
271
|
+
*
|
|
272
|
+
* @remarks
|
|
273
|
+
* This factory function creates a complete camera input flow control system with:
|
|
274
|
+
* 1. A default {@link CameraRig} wrapping the provided camera
|
|
275
|
+
* 2. Three state machines (pan, zoom, rotation) for animation control
|
|
276
|
+
* 3. A {@link CameraMuxWithAnimationAndLock} coordinating the state machines
|
|
277
|
+
*
|
|
278
|
+
* **What you get:**
|
|
279
|
+
* - Smooth camera animations (pan-to, zoom-to, rotate-to)
|
|
280
|
+
* - Automatic input blocking during animations
|
|
281
|
+
* - State-based input arbitration
|
|
282
|
+
* - All with sensible default configurations
|
|
283
|
+
*
|
|
284
|
+
* **Use this when:**
|
|
285
|
+
* - You have a camera and want animation support out-of-the-box
|
|
286
|
+
* - You don't need custom camera rig configuration
|
|
287
|
+
* - You want the simplest setup for animated camera control
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* const camera = new DefaultBoardCamera(1920, 1080);
|
|
292
|
+
* const mux = createCameraMuxWithAnimationAndLock(camera);
|
|
293
|
+
*
|
|
294
|
+
* // Start a pan animation
|
|
295
|
+
* mux.notifyPanToAnimationInput({ x: 1000, y: 500 });
|
|
296
|
+
*
|
|
297
|
+
* // User input is blocked during animation
|
|
298
|
+
* const result = mux.notifyPanInput({ x: 50, y: 30 });
|
|
299
|
+
* console.log(result.allowPassThrough); // false during animation
|
|
300
|
+
* ```
|
|
41
301
|
*
|
|
42
302
|
* @category Input Flow Control
|
|
303
|
+
* @see {@link CameraMuxWithAnimationAndLock} for the implementation
|
|
304
|
+
* @see {@link createCameraMuxWithAnimationAndLockWithCameraRig} for custom rig version
|
|
43
305
|
*/
|
|
44
306
|
export declare function createCameraMuxWithAnimationAndLock(camera: ObservableBoardCamera): CameraMux;
|
|
45
307
|
/**
|
|
46
|
-
*
|
|
308
|
+
* Creates a camera mux with animation and locking capabilities from a camera rig.
|
|
309
|
+
*
|
|
310
|
+
* @param cameraRig - Pre-configured camera rig to use
|
|
311
|
+
* @returns Configured camera mux with animation support
|
|
312
|
+
*
|
|
313
|
+
* @remarks
|
|
314
|
+
* Similar to {@link createCameraMuxWithAnimationAndLock} but accepts an existing
|
|
315
|
+
* camera rig instead of creating a default one. Use this when you need:
|
|
316
|
+
* - Custom camera rig configuration
|
|
317
|
+
* - Specific pan/zoom/rotation constraints
|
|
318
|
+
* - Non-default handler pipelines
|
|
319
|
+
* - To share a camera rig between multiple systems
|
|
320
|
+
*
|
|
321
|
+
* **Advantages over camera-only variant:**
|
|
322
|
+
* - Full control over camera rig settings
|
|
323
|
+
* - Ability to configure boundaries, restrictions, clamping
|
|
324
|
+
* - Use custom handler functions
|
|
325
|
+
* - Reuse existing rig instance
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* // Create custom camera rig with specific config
|
|
330
|
+
* const camera = new DefaultBoardCamera(1920, 1080);
|
|
331
|
+
* const rig = new DefaultCameraRig({
|
|
332
|
+
* limitEntireViewPort: true,
|
|
333
|
+
* clampTranslation: true,
|
|
334
|
+
* boundaries: {
|
|
335
|
+
* min: { x: 0, y: 0 },
|
|
336
|
+
* max: { x: 2000, y: 1000 }
|
|
337
|
+
* }
|
|
338
|
+
* }, camera);
|
|
339
|
+
*
|
|
340
|
+
* // Create mux with custom rig
|
|
341
|
+
* const mux = createCameraMuxWithAnimationAndLockWithCameraRig(rig);
|
|
342
|
+
*
|
|
343
|
+
* // Animations respect rig's boundaries and constraints
|
|
344
|
+
* mux.notifyPanToAnimationInput({ x: 3000, y: 1500 });
|
|
345
|
+
* // Camera will be clamped to boundaries during animation
|
|
346
|
+
* ```
|
|
47
347
|
*
|
|
48
348
|
* @category Input Flow Control
|
|
349
|
+
* @see {@link CameraMuxWithAnimationAndLock} for the implementation
|
|
350
|
+
* @see {@link createCameraMuxWithAnimationAndLock} for simpler camera-only version
|
|
49
351
|
*/
|
|
50
352
|
export declare function createCameraMuxWithAnimationAndLockWithCameraRig(cameraRig: CameraRig): CameraMux;
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Animation and input locking module exports.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module provides the {@link CameraMuxWithAnimationAndLock} implementation and its supporting
|
|
6
|
+
* state machines for pan, zoom, and rotation control. Each operation has its own state machine that
|
|
7
|
+
* manages animation playback and input blocking.
|
|
8
|
+
*
|
|
9
|
+
* ## State Machines
|
|
10
|
+
*
|
|
11
|
+
* Each state machine manages three states:
|
|
12
|
+
* - **ACCEPTING_USER_INPUT**: Normal state, accepts user input
|
|
13
|
+
* - **TRANSITION**: Animation/transition state, may block user input
|
|
14
|
+
* - **LOCKED_ON_OBJECT**: Camera locked to follow an object (blocks user input)
|
|
15
|
+
*
|
|
16
|
+
* ## Components
|
|
17
|
+
*
|
|
18
|
+
* - **{@link CameraMuxWithAnimationAndLock}**: Main multiplexer with animation support
|
|
19
|
+
* - **{@link PanControlStateMachine}**: State machine for pan input flow control
|
|
20
|
+
* - **{@link ZoomControlStateMachine}**: State machine for zoom input flow control
|
|
21
|
+
* - **{@link RotateControlStateMachine}**: State machine for rotation input flow control
|
|
22
|
+
*
|
|
23
|
+
* @see {@link CameraMuxWithAnimationAndLock} for the main implementation
|
|
24
|
+
* @see {@link createCameraMuxWithAnimationAndLock} for factory function
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
27
|
+
*/
|
|
1
28
|
export * from "./animation-and-lock";
|
|
2
29
|
export * from "./pan-control-state-machine";
|
|
3
30
|
export * from "./zoom-control-state-machine";
|
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
import { Point } from "@ue-too/math";
|
|
2
2
|
import type { EventReactions, State, BaseContext } from "@ue-too/being";
|
|
3
3
|
import { TemplateState, TemplateStateMachine } from "@ue-too/being";
|
|
4
|
-
import { BoardCamera } from "../../interface";
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* State identifiers for the pan control state machine.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Three states manage pan input and animations:
|
|
9
|
+
* - `ACCEPTING_USER_INPUT`: Normal state, accepts user pan input
|
|
10
|
+
* - `TRANSITION`: Animation/transition state, may block user input
|
|
11
|
+
* - `LOCKED_ON_OBJECT`: Camera locked to follow a specific object/position
|
|
7
12
|
*
|
|
8
13
|
* @category Input Flow Control
|
|
9
14
|
*/
|
|
10
15
|
export type PanControlStates = "ACCEPTING_USER_INPUT" | "TRANSITION" | "LOCKED_ON_OBJECT";
|
|
11
16
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
17
|
+
* Payload for pan-by input events (relative panning).
|
|
14
18
|
* @category Input Flow Control
|
|
15
19
|
*/
|
|
16
20
|
export type PanByInputEventPayload = {
|
|
21
|
+
/** Pan displacement in viewport coordinates */
|
|
17
22
|
diff: Point;
|
|
18
23
|
};
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
25
|
+
* Payload for pan-to input events (absolute panning).
|
|
22
26
|
* @category Input Flow Control
|
|
23
27
|
*/
|
|
24
28
|
export type PanToInputEventPayload = {
|
|
29
|
+
/** Target position to pan to */
|
|
25
30
|
target: Point;
|
|
26
31
|
};
|
|
32
|
+
/** Empty payload for events that don't need data */
|
|
27
33
|
type EmptyPayload = {};
|
|
28
34
|
/**
|
|
29
|
-
*
|
|
35
|
+
* Event payload type mapping for the pan control state machine.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* Maps event names to their payload types. Events include:
|
|
39
|
+
* - User input events (`userPanByInput`, `userPanToInput`)
|
|
40
|
+
* - Transition/animation events (`transitionPanByInput`, `transitionPanToInput`)
|
|
41
|
+
* - Locked object events (`lockedOnObjectPanByInput`, `lockedOnObjectPanToInput`)
|
|
42
|
+
* - Control events (`unlock`, `initateTransition`)
|
|
30
43
|
*
|
|
31
44
|
* @category Input Flow Control
|
|
32
45
|
*/
|
|
@@ -41,97 +54,167 @@ export type PanEventPayloadMapping = {
|
|
|
41
54
|
"initateTransition": EmptyPayload;
|
|
42
55
|
};
|
|
43
56
|
/**
|
|
44
|
-
*
|
|
57
|
+
* Discriminated union of output events from pan control state machine.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* Output events instruct the camera system what pan operation to perform:
|
|
61
|
+
* - `panByViewPort`: Relative pan in viewport coordinates
|
|
62
|
+
* - `panToWorld`: Absolute pan to world position
|
|
63
|
+
* - `none`: No operation (input blocked)
|
|
45
64
|
*
|
|
46
65
|
* @category Input Flow Control
|
|
47
66
|
*/
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
67
|
+
export type PanControlOutputEvent = {
|
|
68
|
+
type: "panByViewPort";
|
|
69
|
+
delta: Point;
|
|
70
|
+
} | {
|
|
71
|
+
type: "panToWorld";
|
|
72
|
+
target: Point;
|
|
73
|
+
} | {
|
|
74
|
+
type: "none";
|
|
75
|
+
};
|
|
56
76
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* A few helper functions are in place to make it easier to use. (user don't have to memorize the event names)
|
|
77
|
+
* Output event type mapping for pan control events.
|
|
78
|
+
* Maps input event names to their corresponding output event types.
|
|
60
79
|
*
|
|
61
80
|
* @category Input Flow Control
|
|
62
81
|
*/
|
|
63
|
-
export
|
|
64
|
-
|
|
82
|
+
export type PanControlOutputMapping = {
|
|
83
|
+
"userPanByInput": PanControlOutputEvent;
|
|
84
|
+
"userPanToInput": PanControlOutputEvent;
|
|
85
|
+
"transitionPanByInput": PanControlOutputEvent;
|
|
86
|
+
"transitionPanToInput": PanControlOutputEvent;
|
|
87
|
+
"lockedOnObjectPanByInput": PanControlOutputEvent;
|
|
88
|
+
"lockedOnObjectPanToInput": PanControlOutputEvent;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* State machine controlling pan input flow and animations.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* This state machine manages the lifecycle of pan operations:
|
|
95
|
+
* - **User input handling**: Accepts or blocks user pan gestures based on state
|
|
96
|
+
* - **Animation control**: Manages smooth pan-to animations
|
|
97
|
+
* - **Object tracking**: Supports locking camera to follow objects
|
|
98
|
+
*
|
|
99
|
+
* **State transitions:**
|
|
100
|
+
* - `ACCEPTING_USER_INPUT` → `TRANSITION`: Start animation (`initateTransition`)
|
|
101
|
+
* - `ACCEPTING_USER_INPUT` → `LOCKED_ON_OBJECT`: Lock to object (`lockedOnObjectPan...`)
|
|
102
|
+
* - `TRANSITION` → `ACCEPTING_USER_INPUT`: User input interrupts animation
|
|
103
|
+
* - `LOCKED_ON_OBJECT` → `ACCEPTING_USER_INPUT`: Unlock (`unlock` event)
|
|
104
|
+
*
|
|
105
|
+
* Helper methods simplify event dispatching without memorizing event names.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const stateMachine = createDefaultPanControlStateMachine(cameraRig);
|
|
110
|
+
*
|
|
111
|
+
* // User pans - accepted in ACCEPTING_USER_INPUT state
|
|
112
|
+
* const result = stateMachine.notifyPanInput({ x: 50, y: 30 });
|
|
113
|
+
*
|
|
114
|
+
* // Start animation - transitions to TRANSITION state
|
|
115
|
+
* stateMachine.notifyPanToAnimationInput({ x: 1000, y: 500 });
|
|
116
|
+
*
|
|
117
|
+
* // User input now blocked while animating
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @category Input Flow Control
|
|
121
|
+
* @see {@link createDefaultPanControlStateMachine} for factory function
|
|
122
|
+
*/
|
|
123
|
+
export declare class PanControlStateMachine extends TemplateStateMachine<PanEventPayloadMapping, BaseContext, PanControlStates, PanControlOutputMapping> {
|
|
124
|
+
constructor(states: Record<PanControlStates, State<PanEventPayloadMapping, BaseContext, PanControlStates, PanControlOutputMapping>>, initialState: PanControlStates, context: BaseContext);
|
|
65
125
|
/**
|
|
66
|
-
*
|
|
126
|
+
* Notifies the state machine of user pan input.
|
|
127
|
+
*
|
|
128
|
+
* @param diff - Pan displacement in viewport coordinates
|
|
129
|
+
* @returns Event handling result with output event
|
|
67
130
|
*
|
|
68
|
-
* @
|
|
131
|
+
* @remarks
|
|
132
|
+
* Dispatches `userPanByInput` event. Accepted in `ACCEPTING_USER_INPUT` and `TRANSITION` states,
|
|
133
|
+
* where it may transition back to `ACCEPTING_USER_INPUT` (user interrupting animation).
|
|
69
134
|
*/
|
|
70
|
-
notifyPanInput(diff: Point):
|
|
135
|
+
notifyPanInput(diff: Point): import("@ue-too/being").EventResult<PanControlStates, PanControlOutputEvent>;
|
|
71
136
|
/**
|
|
72
|
-
*
|
|
137
|
+
* Initiates a pan animation to a target position.
|
|
138
|
+
*
|
|
139
|
+
* @param target - Target position in world coordinates
|
|
140
|
+
* @returns Event handling result
|
|
73
141
|
*
|
|
74
|
-
* @
|
|
142
|
+
* @remarks
|
|
143
|
+
* Dispatches `transitionPanToInput` event, starting a pan animation.
|
|
144
|
+
* Transitions to `TRANSITION` state where animation updates occur.
|
|
75
145
|
*/
|
|
76
|
-
notifyPanToAnimationInput(target: Point):
|
|
146
|
+
notifyPanToAnimationInput(target: Point): import("@ue-too/being").EventResult<PanControlStates, PanControlOutputEvent>;
|
|
77
147
|
/**
|
|
78
|
-
*
|
|
148
|
+
* Initiates transition to `TRANSITION` state.
|
|
79
149
|
*
|
|
80
|
-
* @
|
|
150
|
+
* @remarks
|
|
151
|
+
* Forces state change to begin animation or transition sequence.
|
|
152
|
+
* Called when starting programmatic camera movements.
|
|
81
153
|
*/
|
|
82
154
|
initateTransition(): void;
|
|
83
|
-
set limitEntireViewPort(limit: boolean);
|
|
84
|
-
get limitEntireViewPort(): boolean;
|
|
85
155
|
}
|
|
86
156
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
157
|
+
* State implementation for accepting user pan input (idle/normal state).
|
|
158
|
+
* Accepts user pan input and can transition to animation or locked states.
|
|
89
159
|
* @category Input Flow Control
|
|
90
160
|
*/
|
|
91
|
-
export declare class AcceptingUserInputState extends TemplateState<PanEventPayloadMapping,
|
|
161
|
+
export declare class AcceptingUserInputState extends TemplateState<PanEventPayloadMapping, BaseContext, PanControlStates, PanControlOutputMapping> {
|
|
92
162
|
constructor();
|
|
93
|
-
eventReactions: EventReactions<PanEventPayloadMapping,
|
|
94
|
-
userPanByInputHandler(context:
|
|
95
|
-
userPanToInputHandler(context:
|
|
96
|
-
lockedOnObjectPanByInputHandler(context:
|
|
97
|
-
lockedOnObjectPanToInputHandler(context:
|
|
163
|
+
eventReactions: EventReactions<PanEventPayloadMapping, BaseContext, PanControlStates, PanControlOutputMapping>;
|
|
164
|
+
userPanByInputHandler(context: BaseContext, payload: PanByInputEventPayload): PanControlOutputEvent;
|
|
165
|
+
userPanToInputHandler(context: BaseContext, payload: PanToInputEventPayload): PanControlOutputEvent;
|
|
166
|
+
lockedOnObjectPanByInputHandler(context: BaseContext, payload: PanByInputEventPayload): PanControlOutputEvent;
|
|
167
|
+
lockedOnObjectPanToInputHandler(context: BaseContext, payload: PanToInputEventPayload): PanControlOutputEvent;
|
|
98
168
|
}
|
|
99
169
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
170
|
+
* State implementation for pan animations and transitions.
|
|
171
|
+
* Processes animation updates and allows user input to interrupt.
|
|
102
172
|
* @category Input Flow Control
|
|
103
173
|
*/
|
|
104
|
-
export declare class TransitionState extends TemplateState<PanEventPayloadMapping,
|
|
174
|
+
export declare class TransitionState extends TemplateState<PanEventPayloadMapping, BaseContext, PanControlStates, PanControlOutputMapping> {
|
|
105
175
|
constructor();
|
|
106
|
-
eventReactions: EventReactions<PanEventPayloadMapping,
|
|
107
|
-
userPanByInputHandler(context:
|
|
108
|
-
userPanToInputHandler(context:
|
|
109
|
-
transitionPanByInputHandler(context:
|
|
110
|
-
transitionPanToInputHandler(context:
|
|
111
|
-
lockedOnObjectPanByInputHandler(context:
|
|
112
|
-
lockedOnObjectPanToInputHandler(context:
|
|
176
|
+
eventReactions: EventReactions<PanEventPayloadMapping, BaseContext, PanControlStates, PanControlOutputMapping>;
|
|
177
|
+
userPanByInputHandler(context: BaseContext, payload: PanByInputEventPayload): PanControlOutputEvent;
|
|
178
|
+
userPanToInputHandler(context: BaseContext, payload: PanToInputEventPayload): PanControlOutputEvent;
|
|
179
|
+
transitionPanByInputHandler(context: BaseContext, payload: PanByInputEventPayload): PanControlOutputEvent;
|
|
180
|
+
transitionPanToInputHandler(context: BaseContext, payload: PanToInputEventPayload): PanControlOutputEvent;
|
|
181
|
+
lockedOnObjectPanByInputHandler(context: BaseContext, payload: PanByInputEventPayload): PanControlOutputEvent;
|
|
182
|
+
lockedOnObjectPanToInputHandler(context: BaseContext, payload: PanToInputEventPayload): PanControlOutputEvent;
|
|
113
183
|
}
|
|
114
184
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
185
|
+
* State implementation for camera locked to follow an object.
|
|
186
|
+
* Only accepts locked object pan events until unlocked.
|
|
117
187
|
* @category Input Flow Control
|
|
118
188
|
*/
|
|
119
|
-
export declare class LockedOnObjectState extends TemplateState<PanEventPayloadMapping,
|
|
189
|
+
export declare class LockedOnObjectState extends TemplateState<PanEventPayloadMapping, BaseContext, PanControlStates, PanControlOutputMapping> {
|
|
120
190
|
constructor();
|
|
121
|
-
eventReactions: EventReactions<PanEventPayloadMapping,
|
|
122
|
-
lockedOnObjectPanByInputHandler(context:
|
|
123
|
-
lockedOnObjectPanToInputHandler(context:
|
|
191
|
+
eventReactions: EventReactions<PanEventPayloadMapping, BaseContext, PanControlStates, PanControlOutputMapping>;
|
|
192
|
+
lockedOnObjectPanByInputHandler(context: BaseContext, payload: PanByInputEventPayload): PanControlOutputEvent;
|
|
193
|
+
lockedOnObjectPanToInputHandler(context: BaseContext, payload: PanToInputEventPayload): PanControlOutputEvent;
|
|
124
194
|
}
|
|
125
195
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
196
|
+
* Creates the default set of pan control states.
|
|
197
|
+
* @returns State instances for all pan control states
|
|
128
198
|
* @category Input Flow Control
|
|
129
199
|
*/
|
|
130
|
-
export declare function createDefaultPanControlStates(): Record<PanControlStates, State<PanEventPayloadMapping,
|
|
200
|
+
export declare function createDefaultPanControlStates(): Record<PanControlStates, State<PanEventPayloadMapping, BaseContext, PanControlStates, PanControlOutputMapping>>;
|
|
131
201
|
/**
|
|
132
|
-
*
|
|
202
|
+
* Creates a pan control state machine with default configuration.
|
|
203
|
+
*
|
|
204
|
+
* @param context - Camera rig or context for pan operations
|
|
205
|
+
* @returns Configured pan control state machine starting in `ACCEPTING_USER_INPUT` state
|
|
206
|
+
*
|
|
207
|
+
* @remarks
|
|
208
|
+
* Factory function for creating a pan state machine with sensible defaults.
|
|
209
|
+
* The machine starts in `ACCEPTING_USER_INPUT` state, ready to accept user pan gestures.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const cameraRig = createDefaultCameraRig(camera);
|
|
214
|
+
* const panSM = createDefaultPanControlStateMachine(cameraRig);
|
|
215
|
+
* ```
|
|
133
216
|
*
|
|
134
217
|
* @category Input Flow Control
|
|
135
218
|
*/
|
|
136
|
-
export declare function createDefaultPanControlStateMachine(context:
|
|
219
|
+
export declare function createDefaultPanControlStateMachine(context: BaseContext): PanControlStateMachine;
|
|
137
220
|
export {};
|