@ue-too/board 0.9.5 → 0.11.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,31 +1,44 @@
|
|
|
1
1
|
import type { EventReactions, State, BaseContext } from "@ue-too/being";
|
|
2
2
|
import { TemplateState, TemplateStateMachine } from "@ue-too/being";
|
|
3
|
-
import { BoardCamera } from "../../interface";
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* State identifiers for the rotation control state machine.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Three states manage rotation input and animations:
|
|
8
|
+
* - `ACCEPTING_USER_INPUT`: Normal state, accepts user rotation input
|
|
9
|
+
* - `TRANSITION`: Animation/transition state, may block user input
|
|
10
|
+
* - `LOCKED_ON_OBJECT`: Camera locked to follow a specific object rotation
|
|
6
11
|
*
|
|
7
12
|
* @category Input Flow Control
|
|
8
13
|
*/
|
|
9
14
|
export type RotateControlStates = "ACCEPTING_USER_INPUT" | "TRANSITION" | "LOCKED_ON_OBJECT";
|
|
10
15
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
16
|
+
* Payload for rotate-by input events (relative rotation).
|
|
13
17
|
* @category Input Flow Control
|
|
14
18
|
*/
|
|
15
19
|
export type RotateByInputEventPayload = {
|
|
20
|
+
/** Rotation angle delta in radians */
|
|
16
21
|
diff: number;
|
|
17
22
|
};
|
|
18
23
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
24
|
+
* Payload for rotate-to input events (absolute rotation).
|
|
21
25
|
* @category Input Flow Control
|
|
22
26
|
*/
|
|
23
27
|
export type RotateToInputEventPayload = {
|
|
28
|
+
/** Target rotation angle in radians */
|
|
24
29
|
target: number;
|
|
25
30
|
};
|
|
31
|
+
/** Empty payload for events that don't need data */
|
|
26
32
|
type EmptyPayload = {};
|
|
27
33
|
/**
|
|
28
|
-
*
|
|
34
|
+
* Event payload type mapping for the rotation control state machine.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Maps event names to their payload types. Events include:
|
|
38
|
+
* - User input events (`userRotateByInput`, `userRotateToInput`)
|
|
39
|
+
* - Transition/animation events (`transitionRotateByInput`, `transitionRotateToInput`)
|
|
40
|
+
* - Locked object events (`lockedOnObjectRotateByInput`, `lockedOnObjectRotateToInput`)
|
|
41
|
+
* - Control events (`unlock`, `initateTransition`)
|
|
29
42
|
*
|
|
30
43
|
* @category Input Flow Control
|
|
31
44
|
*/
|
|
@@ -40,92 +53,167 @@ export type RotateEventPayloadMapping = {
|
|
|
40
53
|
"initateTransition": EmptyPayload;
|
|
41
54
|
};
|
|
42
55
|
/**
|
|
43
|
-
*
|
|
56
|
+
* Discriminated union of output events from rotation control state machine.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* Output events instruct the camera system what rotation operation to perform:
|
|
60
|
+
* - `rotateBy`: Relative rotation by delta angle
|
|
61
|
+
* - `rotateTo`: Absolute rotation to target angle
|
|
62
|
+
* - `none`: No operation (input blocked)
|
|
44
63
|
*
|
|
45
64
|
* @category Input Flow Control
|
|
46
65
|
*/
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
export type RotateControlOutputEvent = {
|
|
67
|
+
type: "rotateBy";
|
|
68
|
+
delta: number;
|
|
69
|
+
} | {
|
|
70
|
+
type: "rotateTo";
|
|
71
|
+
target: number;
|
|
72
|
+
} | {
|
|
73
|
+
type: "none";
|
|
74
|
+
};
|
|
52
75
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* A few helper functions are in place to make it easier to use. (user don't have to memorize the event names)
|
|
76
|
+
* Output event type mapping for rotation control events.
|
|
77
|
+
* Maps input event names to their corresponding output event types.
|
|
56
78
|
*
|
|
57
79
|
* @category Input Flow Control
|
|
58
80
|
*/
|
|
59
|
-
export
|
|
60
|
-
|
|
81
|
+
export type RotateControlOutputMapping = {
|
|
82
|
+
"userRotateByInput": RotateControlOutputEvent;
|
|
83
|
+
"userRotateToInput": RotateControlOutputEvent;
|
|
84
|
+
"transitionRotateByInput": RotateControlOutputEvent;
|
|
85
|
+
"transitionRotateToInput": RotateControlOutputEvent;
|
|
86
|
+
"lockedOnObjectRotateByInput": RotateControlOutputEvent;
|
|
87
|
+
"lockedOnObjectRotateToInput": RotateControlOutputEvent;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* State machine controlling rotation input flow and animations.
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
* This state machine manages the lifecycle of rotation operations:
|
|
94
|
+
* - **User input handling**: Accepts or blocks user rotation gestures based on state
|
|
95
|
+
* - **Animation control**: Manages smooth rotate-to animations
|
|
96
|
+
* - **Object tracking**: Supports locking camera to follow objects with rotation
|
|
97
|
+
*
|
|
98
|
+
* **State transitions:**
|
|
99
|
+
* - `ACCEPTING_USER_INPUT` → `TRANSITION`: Start animation (`initateTransition`)
|
|
100
|
+
* - `ACCEPTING_USER_INPUT` → `LOCKED_ON_OBJECT`: Lock to object (`lockedOnObjectRotate...`)
|
|
101
|
+
* - `TRANSITION` → `ACCEPTING_USER_INPUT`: User input interrupts animation
|
|
102
|
+
* - `LOCKED_ON_OBJECT` → `ACCEPTING_USER_INPUT`: Unlock (`unlock` event)
|
|
103
|
+
*
|
|
104
|
+
* Helper methods simplify event dispatching without memorizing event names.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const stateMachine = createDefaultRotateControlStateMachine(cameraRig);
|
|
109
|
+
*
|
|
110
|
+
* // User rotates - accepted in ACCEPTING_USER_INPUT state
|
|
111
|
+
* const result = stateMachine.notifyRotateByInput(Math.PI / 4);
|
|
112
|
+
*
|
|
113
|
+
* // Start animation - transitions to TRANSITION state
|
|
114
|
+
* stateMachine.notifyRotateToAnimationInput(Math.PI);
|
|
115
|
+
*
|
|
116
|
+
* // User input now blocked while animating
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @category Input Flow Control
|
|
120
|
+
* @see {@link createDefaultRotateControlStateMachine} for factory function
|
|
121
|
+
*/
|
|
122
|
+
export declare class RotateControlStateMachine extends TemplateStateMachine<RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping> {
|
|
123
|
+
constructor(states: Record<RotateControlStates, State<RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping>>, initialState: RotateControlStates, context: BaseContext);
|
|
61
124
|
/**
|
|
62
|
-
*
|
|
125
|
+
* Notifies the state machine of user rotation input.
|
|
126
|
+
*
|
|
127
|
+
* @param diff - Rotation angle delta in radians
|
|
128
|
+
* @returns Event handling result with output event
|
|
63
129
|
*
|
|
64
|
-
* @
|
|
130
|
+
* @remarks
|
|
131
|
+
* Dispatches `userRotateByInput` event. Accepted in `ACCEPTING_USER_INPUT` and `TRANSITION` states,
|
|
132
|
+
* where it may transition back to `ACCEPTING_USER_INPUT` (user interrupting animation).
|
|
65
133
|
*/
|
|
66
|
-
notifyRotateByInput(diff: number):
|
|
134
|
+
notifyRotateByInput(diff: number): import("@ue-too/being").EventResult<RotateControlStates, RotateControlOutputEvent>;
|
|
67
135
|
/**
|
|
68
|
-
*
|
|
136
|
+
* Initiates a rotation animation to a target angle.
|
|
137
|
+
*
|
|
138
|
+
* @param target - Target rotation angle in radians
|
|
139
|
+
* @returns Event handling result
|
|
69
140
|
*
|
|
70
|
-
* @
|
|
141
|
+
* @remarks
|
|
142
|
+
* Dispatches `transitionRotateToInput` event, starting a rotation animation.
|
|
143
|
+
* Transitions to `TRANSITION` state where animation updates occur.
|
|
71
144
|
*/
|
|
72
|
-
notifyRotateToAnimationInput(target: number):
|
|
145
|
+
notifyRotateToAnimationInput(target: number): import("@ue-too/being").EventResult<RotateControlStates, RotateControlOutputEvent>;
|
|
73
146
|
/**
|
|
74
|
-
*
|
|
147
|
+
* Initiates transition to `TRANSITION` state.
|
|
75
148
|
*
|
|
76
|
-
* @
|
|
149
|
+
* @remarks
|
|
150
|
+
* Forces state change to begin animation or transition sequence.
|
|
151
|
+
* Called when starting programmatic camera movements.
|
|
77
152
|
*/
|
|
78
153
|
initateTransition(): void;
|
|
79
154
|
}
|
|
80
155
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
156
|
+
* State implementation for accepting user rotation input (idle/normal state).
|
|
157
|
+
* Accepts user rotation input and can transition to animation or locked states.
|
|
83
158
|
* @category Input Flow Control
|
|
84
159
|
*/
|
|
85
|
-
export declare class RotationAcceptingUserInputState extends TemplateState<RotateEventPayloadMapping,
|
|
160
|
+
export declare class RotationAcceptingUserInputState extends TemplateState<RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping> {
|
|
86
161
|
constructor();
|
|
87
|
-
eventReactions: EventReactions<RotateEventPayloadMapping,
|
|
88
|
-
userRotateByInputHandler(context:
|
|
89
|
-
userRotateToInputHandler(context:
|
|
90
|
-
lockedOnObjectRotateByInputHandler(context:
|
|
91
|
-
lockedOnObjectRotateToInputHandler(context:
|
|
162
|
+
eventReactions: EventReactions<RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping>;
|
|
163
|
+
userRotateByInputHandler(context: BaseContext, payload: RotateByInputEventPayload): RotateControlOutputEvent;
|
|
164
|
+
userRotateToInputHandler(context: BaseContext, payload: RotateToInputEventPayload): RotateControlOutputEvent;
|
|
165
|
+
lockedOnObjectRotateByInputHandler(context: BaseContext, payload: RotateByInputEventPayload): RotateControlOutputEvent;
|
|
166
|
+
lockedOnObjectRotateToInputHandler(context: BaseContext, payload: RotateToInputEventPayload): RotateControlOutputEvent;
|
|
92
167
|
}
|
|
93
168
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
169
|
+
* State implementation for rotation animations and transitions.
|
|
170
|
+
* Processes animation updates and allows user input to interrupt.
|
|
96
171
|
* @category Input Flow Control
|
|
97
172
|
*/
|
|
98
|
-
export declare class RotationTransitionState extends TemplateState<RotateEventPayloadMapping,
|
|
173
|
+
export declare class RotationTransitionState extends TemplateState<RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping> {
|
|
99
174
|
constructor();
|
|
100
|
-
eventReactions: EventReactions<RotateEventPayloadMapping,
|
|
101
|
-
userRotateByInputHandler(context:
|
|
102
|
-
userRotateToInputHandler(context:
|
|
103
|
-
transitionRotateByInputHandler(context:
|
|
104
|
-
transitionRotateToInputHandler(context:
|
|
105
|
-
lockedOnObjectRotateByInputHandler(context:
|
|
106
|
-
lockedOnObjectRotateToInputHandler(context:
|
|
175
|
+
eventReactions: EventReactions<RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping>;
|
|
176
|
+
userRotateByInputHandler(context: BaseContext, payload: RotateByInputEventPayload): RotateControlOutputEvent;
|
|
177
|
+
userRotateToInputHandler(context: BaseContext, payload: RotateToInputEventPayload): RotateControlOutputEvent;
|
|
178
|
+
transitionRotateByInputHandler(context: BaseContext, payload: RotateByInputEventPayload): RotateControlOutputEvent;
|
|
179
|
+
transitionRotateToInputHandler(context: BaseContext, payload: RotateToInputEventPayload): RotateControlOutputEvent;
|
|
180
|
+
lockedOnObjectRotateByInputHandler(context: BaseContext, payload: RotateByInputEventPayload): RotateControlOutputEvent;
|
|
181
|
+
lockedOnObjectRotateToInputHandler(context: BaseContext, payload: RotateToInputEventPayload): RotateControlOutputEvent;
|
|
107
182
|
}
|
|
108
183
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
184
|
+
* State implementation for camera locked to follow an object rotation.
|
|
185
|
+
* Only accepts locked object rotation events until unlocked.
|
|
111
186
|
* @category Input Flow Control
|
|
112
187
|
*/
|
|
113
|
-
export declare class RotationLockedOnObjectState extends TemplateState<RotateEventPayloadMapping,
|
|
188
|
+
export declare class RotationLockedOnObjectState extends TemplateState<RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping> {
|
|
114
189
|
constructor();
|
|
115
|
-
eventReactions: EventReactions<RotateEventPayloadMapping,
|
|
116
|
-
lockedOnObjectRotateByInputHandler(context:
|
|
117
|
-
lockedOnObjectRotateToInputHandler(context:
|
|
190
|
+
eventReactions: EventReactions<RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping>;
|
|
191
|
+
lockedOnObjectRotateByInputHandler(context: BaseContext, payload: RotateByInputEventPayload): RotateControlOutputEvent;
|
|
192
|
+
lockedOnObjectRotateToInputHandler(context: BaseContext, payload: RotateToInputEventPayload): RotateControlOutputEvent;
|
|
118
193
|
}
|
|
119
194
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
195
|
+
* Creates the default set of rotation control states.
|
|
196
|
+
* @returns State instances for all rotation control states
|
|
122
197
|
* @category Input Flow Control
|
|
123
198
|
*/
|
|
124
|
-
export declare function createDefaultRotateControlStates(): Record<RotateControlStates, State<RotateEventPayloadMapping,
|
|
199
|
+
export declare function createDefaultRotateControlStates(): Record<RotateControlStates, State<RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping>>;
|
|
125
200
|
/**
|
|
126
|
-
*
|
|
201
|
+
* Creates a rotation control state machine with default configuration.
|
|
202
|
+
*
|
|
203
|
+
* @param context - Camera rig or context for rotation operations
|
|
204
|
+
* @returns Configured rotation control state machine starting in `ACCEPTING_USER_INPUT` state
|
|
205
|
+
*
|
|
206
|
+
* @remarks
|
|
207
|
+
* Factory function for creating a rotation state machine with sensible defaults.
|
|
208
|
+
* The machine starts in `ACCEPTING_USER_INPUT` state, ready to accept user rotation gestures.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const cameraRig = createDefaultCameraRig(camera);
|
|
213
|
+
* const rotateSM = createDefaultRotateControlStateMachine(cameraRig);
|
|
214
|
+
* ```
|
|
127
215
|
*
|
|
128
216
|
* @category Input Flow Control
|
|
129
217
|
*/
|
|
130
|
-
export declare function createDefaultRotateControlStateMachine(context:
|
|
218
|
+
export declare function createDefaultRotateControlStateMachine(context: BaseContext): RotateControlStateMachine;
|
|
131
219
|
export {};
|
|
@@ -2,47 +2,62 @@ import type { State, EventReactions, BaseContext } from "@ue-too/being";
|
|
|
2
2
|
import { TemplateState, TemplateStateMachine } from "@ue-too/being";
|
|
3
3
|
import { Point } from "@ue-too/math";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* State identifiers for the zoom control state machine.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Three states manage zoom input and animations:
|
|
9
|
+
* - `ACCEPTING_USER_INPUT`: Normal state, accepts user zoom input
|
|
10
|
+
* - `TRANSITION`: Animation/transition state, may block user input
|
|
11
|
+
* - `LOCKED_ON_OBJECT`: Camera locked to follow a specific object with zoom
|
|
6
12
|
*
|
|
7
13
|
* @category Input Flow Control
|
|
8
14
|
*/
|
|
9
15
|
export type ZoomControlStates = "ACCEPTING_USER_INPUT" | "TRANSITION" | "LOCKED_ON_OBJECT";
|
|
10
16
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
17
|
+
* Payload for zoom-by-at input events (relative zoom around a point).
|
|
13
18
|
* @category Input Flow Control
|
|
14
19
|
*/
|
|
15
20
|
export type ZoomByAtInputPayload = {
|
|
21
|
+
/** Zoom delta amount (multiplier) */
|
|
16
22
|
deltaZoom: number;
|
|
23
|
+
/** Anchor point for zoom operation */
|
|
17
24
|
anchorPoint: Point;
|
|
18
25
|
};
|
|
19
26
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
27
|
+
* Payload for zoom-to-at input events (absolute zoom to target around a point).
|
|
22
28
|
* @category Input Flow Control
|
|
23
29
|
*/
|
|
24
30
|
export type ZoomToAtInputPayload = {
|
|
31
|
+
/** Target zoom level */
|
|
25
32
|
targetZoom: number;
|
|
33
|
+
/** Anchor point for zoom operation */
|
|
26
34
|
anchorPoint: Point;
|
|
27
35
|
};
|
|
28
36
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
37
|
+
* Payload for zoom-by input events (relative zoom without anchor).
|
|
31
38
|
* @category Input Flow Control
|
|
32
39
|
*/
|
|
33
40
|
export type ZoomByPayload = {
|
|
41
|
+
/** Zoom delta amount (multiplier) */
|
|
34
42
|
deltaZoom: number;
|
|
35
43
|
};
|
|
36
44
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
45
|
+
* Payload for zoom-to input events (absolute zoom to target level).
|
|
39
46
|
* @category Input Flow Control
|
|
40
47
|
*/
|
|
41
48
|
export type ZoomToPayload = {
|
|
49
|
+
/** Target zoom level */
|
|
42
50
|
targetZoom: number;
|
|
43
51
|
};
|
|
44
52
|
/**
|
|
45
|
-
*
|
|
53
|
+
* Event payload type mapping for the zoom control state machine.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Maps event names to their payload types. Events include:
|
|
57
|
+
* - User input events (`userZoomByAtInput`, `userZoomToAtInput`)
|
|
58
|
+
* - Transition/animation events (`transitionZoomByAtInput`, `transitionZoomToAtInput`, etc.)
|
|
59
|
+
* - Locked object events (`lockedOnObjectZoomByAtInput`, `lockedOnObjectZoomToAtInput`)
|
|
60
|
+
* - Control events (`unlock`, `initiateTransition`)
|
|
46
61
|
*
|
|
47
62
|
* @category Input Flow Control
|
|
48
63
|
*/
|
|
@@ -60,84 +75,216 @@ export type ZoomEventPayloadMapping = {
|
|
|
60
75
|
"initiateTransition": {};
|
|
61
76
|
};
|
|
62
77
|
/**
|
|
63
|
-
*
|
|
78
|
+
* Discriminated union of output events from zoom control state machine.
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* Output events instruct the camera system what zoom operation to perform:
|
|
82
|
+
* - `zoomByAt`: Relative zoom around anchor point
|
|
83
|
+
* - `zoomToAt`: Absolute zoom to target level around anchor point
|
|
84
|
+
* - `zoomBy`: Relative zoom without anchor
|
|
85
|
+
* - `zoomTo`: Absolute zoom to target level without anchor
|
|
86
|
+
* - `zoomByAtWorld`: Relative zoom around world anchor point
|
|
87
|
+
* - `zoomToAtWorld`: Absolute zoom to target level around world anchor point
|
|
88
|
+
* - `none`: No operation (input blocked)
|
|
64
89
|
*
|
|
65
90
|
* @category Input Flow Control
|
|
66
91
|
*/
|
|
67
|
-
export
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
92
|
+
export type ZoomControlOutputEvent = {
|
|
93
|
+
type: "zoomByAt";
|
|
94
|
+
deltaZoom: number;
|
|
95
|
+
anchorPoint: Point;
|
|
96
|
+
} | {
|
|
97
|
+
type: "zoomToAt";
|
|
98
|
+
targetZoom: number;
|
|
99
|
+
anchorPoint: Point;
|
|
100
|
+
} | {
|
|
101
|
+
type: "zoomBy";
|
|
102
|
+
deltaZoom: number;
|
|
103
|
+
} | {
|
|
104
|
+
type: "zoomTo";
|
|
105
|
+
targetZoom: number;
|
|
106
|
+
} | {
|
|
107
|
+
type: "zoomByAtWorld";
|
|
108
|
+
deltaZoom: number;
|
|
109
|
+
anchorPoint: Point;
|
|
110
|
+
} | {
|
|
111
|
+
type: "zoomToAtWorld";
|
|
112
|
+
targetZoom: number;
|
|
113
|
+
anchorPoint: Point;
|
|
114
|
+
} | {
|
|
115
|
+
type: "none";
|
|
116
|
+
};
|
|
75
117
|
/**
|
|
76
|
-
*
|
|
118
|
+
* Output event type mapping for zoom control events.
|
|
119
|
+
* Maps input event names to their corresponding output event types.
|
|
77
120
|
*
|
|
78
121
|
* @category Input Flow Control
|
|
79
122
|
*/
|
|
80
|
-
export
|
|
123
|
+
export type ZoomControlOutputMapping = {
|
|
124
|
+
"userZoomByAtInput": ZoomControlOutputEvent;
|
|
125
|
+
"userZoomToAtInput": ZoomControlOutputEvent;
|
|
126
|
+
"transitionZoomByAtInput": ZoomControlOutputEvent;
|
|
127
|
+
"transitionZoomToAtInput": ZoomControlOutputEvent;
|
|
128
|
+
"transitionZoomByAtCenterInput": ZoomControlOutputEvent;
|
|
129
|
+
"transitionZoomToAtCenterInput": ZoomControlOutputEvent;
|
|
130
|
+
"transitionZoomToAtWorldInput": ZoomControlOutputEvent;
|
|
131
|
+
"lockedOnObjectZoomByAtInput": ZoomControlOutputEvent;
|
|
132
|
+
"lockedOnObjectZoomToAtInput": ZoomControlOutputEvent;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* State implementation for accepting user zoom input (idle/normal state).
|
|
136
|
+
* Accepts user zoom input and can transition to animation or locked states.
|
|
137
|
+
* @category Input Flow Control
|
|
138
|
+
*/
|
|
139
|
+
export declare class ZoomAcceptingUserInputState extends TemplateState<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping> {
|
|
81
140
|
private _eventReactions;
|
|
82
|
-
get eventReactions(): EventReactions<ZoomEventPayloadMapping,
|
|
83
|
-
userZoomByAtInput(context:
|
|
84
|
-
userZoomToAtInput(context:
|
|
141
|
+
get eventReactions(): EventReactions<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping>;
|
|
142
|
+
userZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["userZoomByAtInput"]): ZoomControlOutputEvent;
|
|
143
|
+
userZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["userZoomToAtInput"]): ZoomControlOutputEvent;
|
|
85
144
|
}
|
|
86
145
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
146
|
+
* State implementation for zoom animations and transitions.
|
|
147
|
+
* Processes animation updates and allows user input to interrupt.
|
|
89
148
|
* @category Input Flow Control
|
|
90
149
|
*/
|
|
91
|
-
export declare class ZoomTransitionState extends TemplateState<ZoomEventPayloadMapping,
|
|
150
|
+
export declare class ZoomTransitionState extends TemplateState<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping> {
|
|
92
151
|
constructor();
|
|
93
152
|
private _eventReactions;
|
|
94
|
-
get eventReactions(): EventReactions<ZoomEventPayloadMapping,
|
|
95
|
-
lockedOnObjectZoomByAtInput(context:
|
|
96
|
-
lockedOnObjectZoomToAtInput(context:
|
|
97
|
-
userZoomByAtInput(context:
|
|
98
|
-
userZoomToAtInput(context:
|
|
99
|
-
transitionZoomByAtInput(context:
|
|
100
|
-
transitionZoomByAtCenterInput(context:
|
|
101
|
-
transitionZoomToAtInput(context:
|
|
102
|
-
transitionZoomToAtCenterInput(context:
|
|
103
|
-
transitionZoomToAtWorldInput(context:
|
|
153
|
+
get eventReactions(): EventReactions<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping>;
|
|
154
|
+
lockedOnObjectZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["lockedOnObjectZoomByAtInput"]): ZoomControlOutputEvent;
|
|
155
|
+
lockedOnObjectZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["lockedOnObjectZoomToAtInput"]): ZoomControlOutputEvent;
|
|
156
|
+
userZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["userZoomByAtInput"]): ZoomControlOutputEvent;
|
|
157
|
+
userZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["userZoomToAtInput"]): ZoomControlOutputEvent;
|
|
158
|
+
transitionZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["transitionZoomByAtInput"]): ZoomControlOutputEvent;
|
|
159
|
+
transitionZoomByAtCenterInput(context: BaseContext, payload: ZoomEventPayloadMapping["transitionZoomByAtCenterInput"]): ZoomControlOutputEvent;
|
|
160
|
+
transitionZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["transitionZoomToAtInput"]): ZoomControlOutputEvent;
|
|
161
|
+
transitionZoomToAtCenterInput(context: BaseContext, payload: ZoomEventPayloadMapping["transitionZoomToAtCenterInput"]): ZoomControlOutputEvent;
|
|
162
|
+
transitionZoomToAtWorldInput(context: BaseContext, payload: ZoomEventPayloadMapping["transitionZoomToAtWorldInput"]): ZoomControlOutputEvent;
|
|
104
163
|
}
|
|
105
164
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
165
|
+
* State implementation for camera locked to follow an object with zoom.
|
|
166
|
+
* Accepts locked object zoom events and user input to unlock.
|
|
108
167
|
* @category Input Flow Control
|
|
109
168
|
*/
|
|
110
|
-
export declare class ZoomLockedOnObjectState extends TemplateState<ZoomEventPayloadMapping,
|
|
169
|
+
export declare class ZoomLockedOnObjectState extends TemplateState<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping> {
|
|
111
170
|
constructor();
|
|
112
171
|
private _eventReactions;
|
|
113
|
-
get eventReactions(): EventReactions<ZoomEventPayloadMapping,
|
|
114
|
-
lockedOnObjectZoomByAtInput(context:
|
|
115
|
-
lockedOnObjectZoomToAtInput(context:
|
|
116
|
-
userZoomByAtInput(context:
|
|
117
|
-
userZoomToAtInput(context:
|
|
172
|
+
get eventReactions(): EventReactions<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping>;
|
|
173
|
+
lockedOnObjectZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["lockedOnObjectZoomByAtInput"]): ZoomControlOutputEvent;
|
|
174
|
+
lockedOnObjectZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["lockedOnObjectZoomToAtInput"]): ZoomControlOutputEvent;
|
|
175
|
+
userZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["userZoomByAtInput"]): ZoomControlOutputEvent;
|
|
176
|
+
userZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping["userZoomToAtInput"]): ZoomControlOutputEvent;
|
|
118
177
|
}
|
|
119
178
|
/**
|
|
120
|
-
*
|
|
179
|
+
* State machine controlling zoom input flow and animations.
|
|
180
|
+
*
|
|
181
|
+
* @remarks
|
|
182
|
+
* This state machine manages the lifecycle of zoom operations:
|
|
183
|
+
* - **User input handling**: Accepts or blocks user zoom gestures based on state
|
|
184
|
+
* - **Animation control**: Manages smooth zoom-to animations
|
|
185
|
+
* - **Object tracking**: Supports locking camera to follow objects with zoom
|
|
186
|
+
*
|
|
187
|
+
* **State transitions:**
|
|
188
|
+
* - `ACCEPTING_USER_INPUT` → `TRANSITION`: Start animation (`initiateTransition`)
|
|
189
|
+
* - `ACCEPTING_USER_INPUT` → `LOCKED_ON_OBJECT`: Lock to object (`lockedOnObjectZoom...`)
|
|
190
|
+
* - `TRANSITION` → `ACCEPTING_USER_INPUT`: User input interrupts animation
|
|
191
|
+
* - `LOCKED_ON_OBJECT` → `ACCEPTING_USER_INPUT`: User input unlocks
|
|
192
|
+
*
|
|
193
|
+
* Helper methods simplify event dispatching without memorizing event names.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const stateMachine = createDefaultZoomControlStateMachine(cameraRig);
|
|
198
|
+
*
|
|
199
|
+
* // User zooms - accepted in ACCEPTING_USER_INPUT state
|
|
200
|
+
* const result = stateMachine.notifyZoomByAtInput(1.2, { x: 400, y: 300 });
|
|
201
|
+
*
|
|
202
|
+
* // Start animation - transitions to TRANSITION state
|
|
203
|
+
* stateMachine.notifyZoomToAtWorldInput(2.0, { x: 1000, y: 500 });
|
|
204
|
+
*
|
|
205
|
+
* // User input now may interrupt animation
|
|
206
|
+
* ```
|
|
121
207
|
*
|
|
122
208
|
* @category Input Flow Control
|
|
209
|
+
* @see {@link createDefaultZoomControlStateMachine} for factory function
|
|
123
210
|
*/
|
|
124
|
-
export declare class ZoomControlStateMachine extends TemplateStateMachine<ZoomEventPayloadMapping,
|
|
125
|
-
constructor(states: Record<ZoomControlStates, State<ZoomEventPayloadMapping,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
211
|
+
export declare class ZoomControlStateMachine extends TemplateStateMachine<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping> {
|
|
212
|
+
constructor(states: Record<ZoomControlStates, State<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping>>, initialState: ZoomControlStates, context: BaseContext);
|
|
213
|
+
/**
|
|
214
|
+
* Notifies the state machine of user zoom input around an anchor point.
|
|
215
|
+
*
|
|
216
|
+
* @param delta - Zoom delta (multiplier)
|
|
217
|
+
* @param at - Anchor point for zoom
|
|
218
|
+
* @returns Event handling result with output event
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* Dispatches `userZoomByAtInput` event. Accepted in `ACCEPTING_USER_INPUT` and `TRANSITION` states.
|
|
222
|
+
*/
|
|
223
|
+
notifyZoomByAtInput(delta: number, at: Point): import("@ue-too/being").EventResult<ZoomControlStates, ZoomControlOutputEvent>;
|
|
224
|
+
/**
|
|
225
|
+
* Initiates a zoom animation around an anchor point.
|
|
226
|
+
*
|
|
227
|
+
* @param delta - Zoom delta (multiplier)
|
|
228
|
+
* @param at - Anchor point for zoom
|
|
229
|
+
* @returns Event handling result
|
|
230
|
+
*
|
|
231
|
+
* @remarks
|
|
232
|
+
* Dispatches `transitionZoomByAtInput` event, starting a zoom animation.
|
|
233
|
+
*/
|
|
234
|
+
notifyZoomByAtInputAnimation(delta: number, at: Point): import("@ue-too/being").EventResult<ZoomControlStates, ZoomControlOutputEvent>;
|
|
235
|
+
/**
|
|
236
|
+
* Initiates a zoom animation to target level around center anchor.
|
|
237
|
+
*
|
|
238
|
+
* @param targetZoom - Target zoom level
|
|
239
|
+
* @param at - Anchor point for zoom
|
|
240
|
+
* @returns Event handling result
|
|
241
|
+
*
|
|
242
|
+
* @remarks
|
|
243
|
+
* Dispatches `transitionZoomToAtCenterInput` event for center-anchored zoom animation.
|
|
244
|
+
*/
|
|
245
|
+
notifyZoomToAtCenterInput(targetZoom: number, at: Point): import("@ue-too/being").EventResult<ZoomControlStates, ZoomControlOutputEvent>;
|
|
246
|
+
/**
|
|
247
|
+
* Initiates a zoom animation to target level around world anchor.
|
|
248
|
+
*
|
|
249
|
+
* @param targetZoom - Target zoom level
|
|
250
|
+
* @param at - World anchor point for zoom
|
|
251
|
+
* @returns Event handling result
|
|
252
|
+
*
|
|
253
|
+
* @remarks
|
|
254
|
+
* Dispatches `transitionZoomToAtWorldInput` event for world-anchored zoom animation.
|
|
255
|
+
*/
|
|
256
|
+
notifyZoomToAtWorldInput(targetZoom: number, at: Point): import("@ue-too/being").EventResult<ZoomControlStates, ZoomControlOutputEvent>;
|
|
257
|
+
/**
|
|
258
|
+
* Initiates transition to `TRANSITION` state.
|
|
259
|
+
*
|
|
260
|
+
* @remarks
|
|
261
|
+
* Forces state change to begin animation or transition sequence.
|
|
262
|
+
* Called when starting programmatic camera movements.
|
|
263
|
+
*/
|
|
264
|
+
initateTransition(): import("@ue-too/being").EventResult<ZoomControlStates, void>;
|
|
131
265
|
}
|
|
132
266
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
267
|
+
* Creates the default set of zoom control states.
|
|
268
|
+
* @returns State instances for all zoom control states
|
|
135
269
|
* @category Input Flow Control
|
|
136
270
|
*/
|
|
137
|
-
export declare function createDefaultZoomControlStates(): Record<ZoomControlStates, State<ZoomEventPayloadMapping,
|
|
271
|
+
export declare function createDefaultZoomControlStates(): Record<ZoomControlStates, State<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping>>;
|
|
138
272
|
/**
|
|
139
|
-
*
|
|
273
|
+
* Creates a zoom control state machine with default configuration.
|
|
274
|
+
*
|
|
275
|
+
* @param context - Camera rig or context for zoom operations
|
|
276
|
+
* @returns Configured zoom control state machine starting in `ACCEPTING_USER_INPUT` state
|
|
277
|
+
*
|
|
278
|
+
* @remarks
|
|
279
|
+
* Factory function for creating a zoom state machine with sensible defaults.
|
|
280
|
+
* The machine starts in `ACCEPTING_USER_INPUT` state, ready to accept user zoom gestures.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* const cameraRig = createDefaultCameraRig(camera);
|
|
285
|
+
* const zoomSM = createDefaultZoomControlStateMachine(cameraRig);
|
|
286
|
+
* ```
|
|
140
287
|
*
|
|
141
288
|
* @category Input Flow Control
|
|
142
289
|
*/
|
|
143
|
-
export declare function createDefaultZoomControlStateMachine(context:
|
|
290
|
+
export declare function createDefaultZoomControlStateMachine(context: BaseContext): ZoomControlStateMachine;
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera multiplexer (mux) module exports.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module provides camera input coordination and arbitration between different control sources
|
|
6
|
+
* (user input, animations, programmatic control). The camera mux decides whether to allow or block
|
|
7
|
+
* camera operations based on the current state (e.g., block user input during animations).
|
|
8
|
+
*
|
|
9
|
+
* ## Implementations
|
|
10
|
+
*
|
|
11
|
+
* - **{@link Relay}**: Simple passthrough mux that allows all operations
|
|
12
|
+
* - **{@link CameraMuxWithAnimationAndLock}**: Advanced mux with animation support and input blocking
|
|
13
|
+
*
|
|
14
|
+
* ## Use Cases
|
|
15
|
+
*
|
|
16
|
+
* - Smooth camera animations (pan-to, zoom-to, rotate-to)
|
|
17
|
+
* - Input locking during programmatic camera movements
|
|
18
|
+
* - State-based input arbitration
|
|
19
|
+
* - Animation interruption handling
|
|
20
|
+
*
|
|
21
|
+
* @see {@link CameraMux} for the mux interface
|
|
22
|
+
* @see {@link CameraMuxWithAnimationAndLock} for animation support
|
|
23
|
+
* @see {@link Relay} for simple passthrough
|
|
24
|
+
*
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
1
27
|
export * from "./interface";
|
|
2
28
|
export * from "./relay";
|
|
3
29
|
export * from "./animation-and-lock";
|