@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,5 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera rig module exports.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module provides the camera constraint and restriction system through handler pipelines.
|
|
6
|
+
* Camera rigs wrap camera instances and apply configurable rules to pan, zoom, and rotation operations.
|
|
7
|
+
*
|
|
8
|
+
* ## Key Concepts
|
|
9
|
+
*
|
|
10
|
+
* - **Handler Pipelines**: Composable functions that transform camera operations
|
|
11
|
+
* - **Restrictions**: Completely disable specific camera movements (e.g., lock rotation)
|
|
12
|
+
* - **Clamping**: Enforce boundaries on camera position, zoom level, and rotation angle
|
|
13
|
+
* - **Boundaries**: Define world-space limits for camera movement
|
|
14
|
+
*
|
|
15
|
+
* ## Components
|
|
16
|
+
*
|
|
17
|
+
* - **{@link CameraRig}**: Main rig interface and {@link DefaultCameraRig} implementation
|
|
18
|
+
* - **Pan Handlers**: {@link createDefaultPanByHandler}, {@link createDefaultPanToHandler}
|
|
19
|
+
* - **Zoom Handlers**: {@link createDefaultZoomByOnlyHandler}, {@link createDefaultZoomToOnlyHandler}
|
|
20
|
+
* - **Rotation Handlers**: {@link createDefaultRotateByHandler}, {@link createDefaultRotateToHandler}
|
|
21
|
+
*
|
|
22
|
+
* @see {@link CameraRig} for the main rig interface
|
|
23
|
+
* @see {@link DefaultCameraRig} for the default implementation
|
|
24
|
+
*
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
1
27
|
export * from "./zoom-handler";
|
|
2
28
|
export * from "./pan-handler";
|
|
3
29
|
export * from "./rotation-handler";
|
|
4
30
|
export * from "./camera-rig";
|
|
5
|
-
export * from "./update-batcher";
|
|
@@ -1,114 +1,574 @@
|
|
|
1
1
|
import { Point } from "@ue-too/math";
|
|
2
2
|
import { BoardCamera } from "../interface";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Combined configuration for pan handler behavior, merging restriction and clamping settings.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
6
|
+
* @remarks
|
|
7
|
+
* This type combines {@link PanHandlerRestrictionConfig} and {@link PanHandlerClampConfig}
|
|
8
|
+
* to provide complete control over camera panning behavior.
|
|
9
|
+
*
|
|
10
|
+
* Pan handlers use this configuration to:
|
|
11
|
+
* - Restrict movement along specific axes (world or viewport-relative)
|
|
12
|
+
* - Clamp camera position to stay within boundaries
|
|
13
|
+
* - Control whether entire viewport or just center must stay in bounds
|
|
14
|
+
*
|
|
15
|
+
* @category Camera Rig
|
|
16
|
+
* @see {@link PanHandlerRestrictionConfig} for movement restriction options
|
|
17
|
+
* @see {@link PanHandlerClampConfig} for boundary clamping options
|
|
7
18
|
*/
|
|
8
19
|
export type PanHandlerConfig = PanHandlerRestrictionConfig & PanHandlerClampConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for boundary clamping behavior during camera panning.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* Controls how camera position is constrained to stay within defined boundaries.
|
|
25
|
+
*
|
|
26
|
+
* @property limitEntireViewPort - When true, ensures the entire viewport rectangle stays within boundaries.
|
|
27
|
+
* When false, only the camera center point (position) is constrained.
|
|
28
|
+
* This affects how {@link BoardCamera.boundaries} are interpreted.
|
|
29
|
+
*
|
|
30
|
+
* @property clampTranslation - When true, enforces boundary constraints on pan operations.
|
|
31
|
+
* When false, camera can pan freely outside boundaries.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const config: PanHandlerClampConfig = {
|
|
36
|
+
* limitEntireViewPort: true, // Entire view must stay in bounds
|
|
37
|
+
* clampTranslation: true // Enforce boundaries
|
|
38
|
+
* };
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @category Camera Rig
|
|
42
|
+
*/
|
|
9
43
|
export type PanHandlerClampConfig = {
|
|
10
44
|
/**
|
|
11
|
-
*
|
|
45
|
+
* Whether to constrain the entire viewport or just the camera center.
|
|
12
46
|
*/
|
|
13
47
|
limitEntireViewPort: boolean;
|
|
14
48
|
/**
|
|
15
|
-
*
|
|
49
|
+
* Whether to enforce boundary constraints on panning.
|
|
16
50
|
*/
|
|
17
51
|
clampTranslation: boolean;
|
|
18
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Configuration for restricting camera movement along specific axes.
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* Provides fine-grained control over which directions the camera can move.
|
|
58
|
+
* Supports both world-space restrictions (absolute X/Y) and viewport-relative
|
|
59
|
+
* restrictions (screen-space horizontal/vertical, accounting for rotation).
|
|
60
|
+
*
|
|
61
|
+
* **World-space restrictions:**
|
|
62
|
+
* - `restrictXTranslation`: Prevents movement along world X axis
|
|
63
|
+
* - `restrictYTranslation`: Prevents movement along world Y axis
|
|
64
|
+
*
|
|
65
|
+
* **Viewport-relative restrictions (rotation-aware):**
|
|
66
|
+
* - `restrictRelativeXTranslation`: Prevents horizontal movement (screen-space)
|
|
67
|
+
* - `restrictRelativeYTranslation`: Prevents vertical movement (screen-space)
|
|
68
|
+
*
|
|
69
|
+
* Use cases:
|
|
70
|
+
* - Side-scrolling games: `restrictYTranslation = true`
|
|
71
|
+
* - Locked vertical scrolling: `restrictRelativeYTranslation = true`
|
|
72
|
+
* - Fixed-axis pan tools in editors
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* // Side-scroller: only allow horizontal movement in world space
|
|
77
|
+
* const config: PanHandlerRestrictionConfig = {
|
|
78
|
+
* restrictXTranslation: false,
|
|
79
|
+
* restrictYTranslation: true,
|
|
80
|
+
* restrictRelativeXTranslation: false,
|
|
81
|
+
* restrictRelativeYTranslation: false
|
|
82
|
+
* };
|
|
83
|
+
*
|
|
84
|
+
* // Lock to vertical screen movement only (with camera rotation)
|
|
85
|
+
* const screenConfig: PanHandlerRestrictionConfig = {
|
|
86
|
+
* restrictXTranslation: false,
|
|
87
|
+
* restrictYTranslation: false,
|
|
88
|
+
* restrictRelativeXTranslation: true,
|
|
89
|
+
* restrictRelativeYTranslation: false
|
|
90
|
+
* };
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @category Camera Rig
|
|
94
|
+
*/
|
|
19
95
|
export type PanHandlerRestrictionConfig = {
|
|
20
96
|
/**
|
|
21
|
-
*
|
|
97
|
+
* Whether to prevent movement along the world X axis.
|
|
22
98
|
*/
|
|
23
99
|
restrictXTranslation: boolean;
|
|
24
100
|
/**
|
|
25
|
-
*
|
|
101
|
+
* Whether to prevent movement along the world Y axis.
|
|
26
102
|
*/
|
|
27
103
|
restrictYTranslation: boolean;
|
|
28
104
|
/**
|
|
29
|
-
*
|
|
105
|
+
* Whether to prevent horizontal movement in viewport/screen space.
|
|
106
|
+
* Accounts for camera rotation - locks movement perpendicular to screen's vertical direction.
|
|
30
107
|
*/
|
|
31
108
|
restrictRelativeXTranslation: boolean;
|
|
32
109
|
/**
|
|
33
|
-
*
|
|
110
|
+
* Whether to prevent vertical movement in viewport/screen space.
|
|
111
|
+
* Accounts for camera rotation - locks movement perpendicular to screen's horizontal direction.
|
|
34
112
|
*/
|
|
35
113
|
restrictRelativeYTranslation: boolean;
|
|
36
114
|
};
|
|
37
115
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @
|
|
42
|
-
* @
|
|
116
|
+
* Handler function type for absolute "pan to" camera operations.
|
|
117
|
+
*
|
|
118
|
+
* @param destination - Target camera position in world space
|
|
119
|
+
* @param camera - Current camera instance
|
|
120
|
+
* @param config - Pan behavior configuration
|
|
121
|
+
* @returns Transformed destination position (after applying restrictions and clamping)
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* Pan-to handlers process absolute camera positioning requests. They form a pipeline
|
|
125
|
+
* that can apply restrictions, clamping, and other transformations to the target position.
|
|
126
|
+
*
|
|
127
|
+
* Handler pipeline pattern:
|
|
128
|
+
* - Each handler receives the current destination, camera state, and config
|
|
129
|
+
* - Returns a potentially modified destination point
|
|
130
|
+
* - Handlers can be chained using {@link createHandlerChain}
|
|
131
|
+
*
|
|
132
|
+
* Common transformations:
|
|
133
|
+
* - Axis restrictions (prevent movement on specific axes)
|
|
134
|
+
* - Boundary clamping (keep position within bounds)
|
|
135
|
+
* - Viewport constraints (ensure entire viewport stays in bounds)
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const myPanToHandler: PanToHandlerFunction = (dest, camera, config) => {
|
|
140
|
+
* // Custom logic: snap to grid
|
|
141
|
+
* return {
|
|
142
|
+
* x: Math.round(dest.x / 100) * 100,
|
|
143
|
+
* y: Math.round(dest.y / 100) * 100
|
|
144
|
+
* };
|
|
145
|
+
* };
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @category Camera Rig
|
|
149
|
+
* @see {@link createHandlerChain} for composing handler pipelines
|
|
150
|
+
* @see {@link createDefaultPanToHandler} for the default implementation
|
|
43
151
|
*/
|
|
44
152
|
export type PanToHandlerFunction = (destination: Point, camera: BoardCamera, config: PanHandlerConfig) => Point;
|
|
45
153
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @
|
|
50
|
-
* @
|
|
154
|
+
* Handler function type for relative "pan by" camera operations.
|
|
155
|
+
*
|
|
156
|
+
* @param delta - Movement delta in world space
|
|
157
|
+
* @param camera - Current camera instance
|
|
158
|
+
* @param config - Pan behavior configuration
|
|
159
|
+
* @returns Transformed movement delta (after applying restrictions and clamping)
|
|
160
|
+
*
|
|
161
|
+
* @remarks
|
|
162
|
+
* Pan-by handlers process relative camera movement requests. They form a pipeline
|
|
163
|
+
* that can apply restrictions, clamping, and other transformations to the movement delta.
|
|
164
|
+
*
|
|
165
|
+
* Handler pipeline pattern:
|
|
166
|
+
* - Each handler receives the current delta, camera state, and config
|
|
167
|
+
* - Returns a potentially modified delta
|
|
168
|
+
* - Handlers can be chained using {@link createHandlerChain}
|
|
169
|
+
*
|
|
170
|
+
* Common transformations:
|
|
171
|
+
* - Axis restrictions (prevent movement on specific axes)
|
|
172
|
+
* - Boundary clamping (prevent moving outside bounds)
|
|
173
|
+
* - Delta dampening or acceleration
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* const myPanByHandler: PanByHandlerFunction = (delta, camera, config) => {
|
|
178
|
+
* // Custom logic: dampen large movements
|
|
179
|
+
* const magnitude = Math.sqrt(delta.x ** 2 + delta.y ** 2);
|
|
180
|
+
* if (magnitude > 100) {
|
|
181
|
+
* const scale = 100 / magnitude;
|
|
182
|
+
* return { x: delta.x * scale, y: delta.y * scale };
|
|
183
|
+
* }
|
|
184
|
+
* return delta;
|
|
185
|
+
* };
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @category Camera Rig
|
|
189
|
+
* @see {@link createHandlerChain} for composing handler pipelines
|
|
190
|
+
* @see {@link createDefaultPanByHandler} for the default implementation
|
|
51
191
|
*/
|
|
52
192
|
export type PanByHandlerFunction = (delta: Point, camera: BoardCamera, config: PanHandlerConfig) => Point;
|
|
53
193
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
194
|
+
* Creates a default "pan to" handler pipeline for absolute camera positioning.
|
|
195
|
+
*
|
|
196
|
+
* @returns Pan-to handler function with restriction and clamping
|
|
197
|
+
*
|
|
198
|
+
* @remarks
|
|
199
|
+
* The default handler pipeline applies transformations in this order:
|
|
200
|
+
* 1. **Restriction** ({@link restrictPanToHandler}): Applies axis restrictions based on config
|
|
201
|
+
* 2. **Clamping** ({@link clampToHandler}): Clamps position to boundaries
|
|
202
|
+
*
|
|
203
|
+
* This ensures that:
|
|
204
|
+
* - Camera respects axis lock settings (e.g., side-scroller constraints)
|
|
205
|
+
* - Camera position stays within configured boundaries
|
|
206
|
+
* - Entire viewport can be kept in bounds (if `limitEntireViewPort` is true)
|
|
207
|
+
*
|
|
208
|
+
* All operations work in world coordinate space.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const panTo = createDefaultPanToHandler();
|
|
57
213
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
214
|
+
* // Use in camera rig
|
|
215
|
+
* const destination = { x: 1000, y: 500 };
|
|
216
|
+
* const constrainedDest = panTo(destination, camera, {
|
|
217
|
+
* restrictYTranslation: true, // Lock Y axis
|
|
218
|
+
* clampTranslation: true,
|
|
219
|
+
* limitEntireViewPort: true,
|
|
220
|
+
* // ... other config
|
|
221
|
+
* });
|
|
222
|
+
* camera.setPosition(constrainedDest);
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* // Create custom pipeline using default handlers
|
|
228
|
+
* const customPanTo = createHandlerChain<Point, [BoardCamera, PanHandlerConfig]>(
|
|
229
|
+
* restrictPanToHandler, // From default
|
|
230
|
+
* myCustomHandler, // Your custom logic
|
|
231
|
+
* clampToHandler // From default
|
|
232
|
+
* );
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @category Camera Rig
|
|
236
|
+
* @see {@link createHandlerChain} for creating custom handler pipelines
|
|
237
|
+
* @see {@link restrictPanToHandler} for the restriction step
|
|
238
|
+
* @see {@link clampToHandler} for the clamping step
|
|
60
239
|
*/
|
|
61
240
|
export declare function createDefaultPanToHandler(): PanToHandlerFunction;
|
|
62
241
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
242
|
+
* Creates a default "pan by" handler pipeline for relative camera movement.
|
|
243
|
+
*
|
|
244
|
+
* @returns Pan-by handler function with restriction and clamping
|
|
245
|
+
*
|
|
246
|
+
* @remarks
|
|
247
|
+
* The default handler pipeline applies transformations in this order:
|
|
248
|
+
* 1. **Restriction** ({@link restrictPanByHandler}): Applies axis restrictions based on config
|
|
249
|
+
* 2. **Clamping** ({@link clampByHandler}): Clamps resulting position to boundaries
|
|
250
|
+
*
|
|
251
|
+
* This ensures that:
|
|
252
|
+
* - Camera movement respects axis lock settings
|
|
253
|
+
* - Camera stays within configured boundaries after applying delta
|
|
254
|
+
* - Delta is adjusted to prevent boundary violations
|
|
255
|
+
*
|
|
256
|
+
* The input delta is in world space. All operations work in world coordinates.
|
|
66
257
|
*
|
|
67
|
-
* @
|
|
68
|
-
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* const panBy = createDefaultPanByHandler();
|
|
261
|
+
*
|
|
262
|
+
* // Use in camera rig
|
|
263
|
+
* const delta = { x: 50, y: -30 };
|
|
264
|
+
* const constrainedDelta = panBy(delta, camera, {
|
|
265
|
+
* restrictRelativeYTranslation: true, // Lock screen-vertical movement
|
|
266
|
+
* clampTranslation: true,
|
|
267
|
+
* limitEntireViewPort: false,
|
|
268
|
+
* // ... other config
|
|
269
|
+
* });
|
|
270
|
+
* camera.setPosition(PointCal.addVector(camera.position, constrainedDelta));
|
|
271
|
+
* ```
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* // Create custom pipeline with dampening
|
|
276
|
+
* const dampenedPanBy = createHandlerChain<Point, [BoardCamera, PanHandlerConfig]>(
|
|
277
|
+
* restrictPanByHandler,
|
|
278
|
+
* (delta) => ({ x: delta.x * 0.8, y: delta.y * 0.8 }), // 20% dampening
|
|
279
|
+
* clampByHandler
|
|
280
|
+
* );
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* @category Camera Rig
|
|
284
|
+
* @see {@link createHandlerChain} for creating custom handler pipelines
|
|
285
|
+
* @see {@link restrictPanByHandler} for the restriction step
|
|
286
|
+
* @see {@link clampByHandler} for the clamping step
|
|
69
287
|
*/
|
|
70
288
|
export declare function createDefaultPanByHandler(): PanByHandlerFunction;
|
|
71
289
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
290
|
+
* Handler pipeline step that applies axis restrictions to "pan to" destinations.
|
|
291
|
+
*
|
|
292
|
+
* @param destination - Target camera position in world space
|
|
293
|
+
* @param camera - Current camera instance
|
|
294
|
+
* @param config - Restriction configuration
|
|
295
|
+
* @returns Restricted destination position
|
|
296
|
+
*
|
|
297
|
+
* @remarks
|
|
298
|
+
* This handler enforces axis-lock constraints on absolute camera positioning.
|
|
299
|
+
* It converts the destination to a delta, applies restrictions, then converts back.
|
|
75
300
|
*
|
|
76
|
-
*
|
|
301
|
+
* Algorithm:
|
|
302
|
+
* 1. Calculate delta from current position to destination
|
|
303
|
+
* 2. Apply restrictions using {@link convertDeltaToComplyWithRestriction}
|
|
304
|
+
* 3. If delta becomes zero, return original destination (already at target)
|
|
305
|
+
* 4. Otherwise, return current position + restricted delta
|
|
306
|
+
*
|
|
307
|
+
* Can be used standalone, but typically composed into a handler pipeline via
|
|
308
|
+
* {@link createDefaultPanToHandler} or {@link createHandlerChain}.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* // Standalone usage
|
|
313
|
+
* const config: PanHandlerRestrictionConfig = {
|
|
314
|
+
* restrictYTranslation: true, // Lock Y axis
|
|
315
|
+
* restrictXTranslation: false,
|
|
316
|
+
* restrictRelativeXTranslation: false,
|
|
317
|
+
* restrictRelativeYTranslation: false
|
|
318
|
+
* };
|
|
319
|
+
*
|
|
320
|
+
* const destination = { x: 1000, y: 500 };
|
|
321
|
+
* const restricted = restrictPanToHandler(destination, camera, config);
|
|
322
|
+
* // If camera is at { x: 0, y: 200 }, result is { x: 1000, y: 200 }
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @category Camera Rig
|
|
326
|
+
* @see {@link convertDeltaToComplyWithRestriction} for restriction logic
|
|
327
|
+
* @see {@link createDefaultPanToHandler} for default pipeline usage
|
|
77
328
|
*/
|
|
78
329
|
export declare function restrictPanToHandler(destination: Point, camera: BoardCamera, config: PanHandlerRestrictionConfig): Point;
|
|
79
330
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
331
|
+
* Handler pipeline step that applies axis restrictions to "pan by" deltas.
|
|
332
|
+
*
|
|
333
|
+
* @param delta - Movement delta in world space
|
|
334
|
+
* @param camera - Current camera instance
|
|
335
|
+
* @param config - Restriction configuration
|
|
336
|
+
* @returns Restricted movement delta
|
|
337
|
+
*
|
|
338
|
+
* @remarks
|
|
339
|
+
* This handler enforces axis-lock constraints on relative camera movement.
|
|
340
|
+
* It directly transforms the delta according to restriction rules.
|
|
83
341
|
*
|
|
84
|
-
* @
|
|
342
|
+
* Restrictions applied by {@link convertDeltaToComplyWithRestriction}:
|
|
343
|
+
* - World-space axis locks (X/Y)
|
|
344
|
+
* - Viewport-relative axis locks (horizontal/vertical, accounting for rotation)
|
|
345
|
+
*
|
|
346
|
+
* Can be used standalone, but typically composed into a handler pipeline via
|
|
347
|
+
* {@link createDefaultPanByHandler} or {@link createHandlerChain}.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```typescript
|
|
351
|
+
* // Standalone usage - lock to screen-horizontal movement
|
|
352
|
+
* const config: PanHandlerRestrictionConfig = {
|
|
353
|
+
* restrictXTranslation: false,
|
|
354
|
+
* restrictYTranslation: false,
|
|
355
|
+
* restrictRelativeXTranslation: false,
|
|
356
|
+
* restrictRelativeYTranslation: true // Lock screen-vertical
|
|
357
|
+
* };
|
|
358
|
+
*
|
|
359
|
+
* const delta = { x: 50, y: 30 };
|
|
360
|
+
* const restricted = restrictPanByHandler(delta, camera, config);
|
|
361
|
+
* // Result depends on camera rotation - only horizontal screen movement allowed
|
|
362
|
+
* ```
|
|
363
|
+
*
|
|
364
|
+
* @category Camera Rig
|
|
365
|
+
* @see {@link convertDeltaToComplyWithRestriction} for restriction logic
|
|
366
|
+
* @see {@link createDefaultPanByHandler} for default pipeline usage
|
|
85
367
|
*/
|
|
86
368
|
export declare function restrictPanByHandler(delta: Point, camera: BoardCamera, config: PanHandlerRestrictionConfig): Point;
|
|
87
369
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
370
|
+
* Handler pipeline step that clamps "pan to" destinations to camera boundaries.
|
|
371
|
+
*
|
|
372
|
+
* @param destination - Target camera position in world space
|
|
373
|
+
* @param camera - Current camera instance (provides boundaries and viewport dimensions)
|
|
374
|
+
* @param config - Clamping configuration
|
|
375
|
+
* @returns Clamped destination position
|
|
376
|
+
*
|
|
377
|
+
* @remarks
|
|
378
|
+
* This handler enforces boundary constraints on absolute camera positioning.
|
|
379
|
+
* Behavior depends on configuration:
|
|
91
380
|
*
|
|
92
|
-
*
|
|
381
|
+
* - If `clampTranslation` is false: Returns destination unchanged (no clamping)
|
|
382
|
+
* - If `limitEntireViewPort` is false: Clamps camera center to boundaries
|
|
383
|
+
* - If `limitEntireViewPort` is true: Ensures entire viewport rectangle stays in bounds
|
|
384
|
+
*
|
|
385
|
+
* The entire-viewport mode accounts for:
|
|
386
|
+
* - Viewport dimensions (width/height)
|
|
387
|
+
* - Current zoom level (affects viewport size in world space)
|
|
388
|
+
* - Camera rotation (affects viewport orientation)
|
|
389
|
+
*
|
|
390
|
+
* Can be used standalone, but typically composed into a handler pipeline via
|
|
391
|
+
* {@link createDefaultPanToHandler} or {@link createHandlerChain}.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* // Standalone usage - ensure entire viewport stays in bounds
|
|
396
|
+
* camera.boundaries = {
|
|
397
|
+
* min: { x: 0, y: 0 },
|
|
398
|
+
* max: { x: 2000, y: 1000 }
|
|
399
|
+
* };
|
|
400
|
+
*
|
|
401
|
+
* const config: PanHandlerClampConfig = {
|
|
402
|
+
* clampTranslation: true,
|
|
403
|
+
* limitEntireViewPort: true
|
|
404
|
+
* };
|
|
405
|
+
*
|
|
406
|
+
* const destination = { x: 2500, y: 500 }; // Outside bounds
|
|
407
|
+
* const clamped = clampToHandler(destination, camera, config);
|
|
408
|
+
* // Result keeps entire viewport within [0,0] to [2000,1000]
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* @category Camera Rig
|
|
412
|
+
* @see {@link clampPoint} for center-point clamping
|
|
413
|
+
* @see {@link clampPointEntireViewPort} for full-viewport clamping
|
|
414
|
+
* @see {@link createDefaultPanToHandler} for default pipeline usage
|
|
93
415
|
*/
|
|
94
416
|
export declare function clampToHandler(destination: Point, camera: BoardCamera, config: PanHandlerClampConfig): Point;
|
|
95
417
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
418
|
+
* Handler pipeline step that clamps "pan by" deltas to prevent boundary violations.
|
|
419
|
+
*
|
|
420
|
+
* @param delta - Movement delta in world space
|
|
421
|
+
* @param camera - Current camera instance (provides boundaries and viewport dimensions)
|
|
422
|
+
* @param config - Clamping configuration
|
|
423
|
+
* @returns Adjusted delta that respects boundaries
|
|
424
|
+
*
|
|
425
|
+
* @remarks
|
|
426
|
+
* This handler ensures that applying the delta won't move the camera outside boundaries.
|
|
427
|
+
* It works by:
|
|
428
|
+
* 1. Calculating the potential new position (current + delta)
|
|
429
|
+
* 2. Clamping that position to boundaries
|
|
430
|
+
* 3. Returning the difference (clamped - current) as the new delta
|
|
431
|
+
*
|
|
432
|
+
* Behavior depends on configuration:
|
|
433
|
+
* - If `clampTranslation` is false: Returns delta unchanged
|
|
434
|
+
* - If `limitEntireViewPort` is false: Clamps based on camera center
|
|
435
|
+
* - If `limitEntireViewPort` is true: Ensures entire viewport stays in bounds
|
|
436
|
+
*
|
|
437
|
+
* The resulting delta may be zero if the camera is already at a boundary
|
|
438
|
+
* and trying to move further outside.
|
|
439
|
+
*
|
|
440
|
+
* Can be used standalone, but typically composed into a handler pipeline via
|
|
441
|
+
* {@link createDefaultPanByHandler} or {@link createHandlerChain}.
|
|
99
442
|
*
|
|
100
|
-
* @
|
|
443
|
+
* @example
|
|
444
|
+
* ```typescript
|
|
445
|
+
* // Standalone usage
|
|
446
|
+
* camera.position = { x: 1950, y: 500 };
|
|
447
|
+
* camera.boundaries = { max: { x: 2000 } };
|
|
448
|
+
*
|
|
449
|
+
* const config: PanHandlerClampConfig = {
|
|
450
|
+
* clampTranslation: true,
|
|
451
|
+
* limitEntireViewPort: false
|
|
452
|
+
* };
|
|
453
|
+
*
|
|
454
|
+
* const delta = { x: 100, y: 0 }; // Try to move right
|
|
455
|
+
* const clamped = clampByHandler(delta, camera, config);
|
|
456
|
+
* // Result: { x: 50, y: 0 } - only move to boundary, not beyond
|
|
457
|
+
* ```
|
|
458
|
+
*
|
|
459
|
+
* @category Camera Rig
|
|
460
|
+
* @see {@link clampPoint} for center-point clamping
|
|
461
|
+
* @see {@link clampPointEntireViewPort} for full-viewport clamping
|
|
462
|
+
* @see {@link createDefaultPanByHandler} for default pipeline usage
|
|
101
463
|
*/
|
|
102
464
|
export declare function clampByHandler(delta: Point, camera: BoardCamera, config: PanHandlerClampConfig): Point;
|
|
103
465
|
/**
|
|
104
|
-
*
|
|
466
|
+
* Transforms a movement delta to comply with axis restriction configuration.
|
|
467
|
+
*
|
|
468
|
+
* @param delta - Original movement delta in world space
|
|
469
|
+
* @param camera - Current camera instance (provides rotation for relative restrictions)
|
|
470
|
+
* @param config - Restriction configuration
|
|
471
|
+
* @returns Transformed delta that respects all enabled restrictions
|
|
472
|
+
*
|
|
473
|
+
* @remarks
|
|
474
|
+
* This function applies axis-lock logic for both world-space and viewport-relative restrictions.
|
|
475
|
+
* Restrictions are processed in priority order:
|
|
476
|
+
*
|
|
477
|
+
* 1. **Complete locks** (highest priority):
|
|
478
|
+
* - Both world axes locked → return zero delta
|
|
479
|
+
* - Both relative axes locked → return zero delta
|
|
480
|
+
*
|
|
481
|
+
* 2. **World-space axis locks**:
|
|
482
|
+
* - `restrictXTranslation` → Zero out X component
|
|
483
|
+
* - `restrictYTranslation` → Zero out Y component
|
|
484
|
+
*
|
|
485
|
+
* 3. **Viewport-relative axis locks** (rotation-aware):
|
|
486
|
+
* - `restrictRelativeXTranslation` → Project delta onto screen-vertical direction
|
|
487
|
+
* - `restrictRelativeYTranslation` → Project delta onto screen-horizontal direction
|
|
488
|
+
*
|
|
489
|
+
* For viewport-relative restrictions:
|
|
490
|
+
* - "Relative X" = horizontal in viewport/screen space
|
|
491
|
+
* - "Relative Y" = vertical in viewport/screen space
|
|
492
|
+
* - These account for camera rotation by projecting onto rotated axes
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```typescript
|
|
496
|
+
* // World-space restriction: lock Y axis
|
|
497
|
+
* const config1 = {
|
|
498
|
+
* restrictXTranslation: false,
|
|
499
|
+
* restrictYTranslation: true,
|
|
500
|
+
* restrictRelativeXTranslation: false,
|
|
501
|
+
* restrictRelativeYTranslation: false
|
|
502
|
+
* };
|
|
503
|
+
*
|
|
504
|
+
* const delta1 = { x: 50, y: 30 };
|
|
505
|
+
* const result1 = convertDeltaToComplyWithRestriction(delta1, camera, config1);
|
|
506
|
+
* // result1 = { x: 50, y: 0 } - Y component removed
|
|
507
|
+
* ```
|
|
105
508
|
*
|
|
106
|
-
* @
|
|
509
|
+
* @example
|
|
510
|
+
* ```typescript
|
|
511
|
+
* // Viewport-relative restriction: lock horizontal screen movement
|
|
512
|
+
* const config2 = {
|
|
513
|
+
* restrictXTranslation: false,
|
|
514
|
+
* restrictYTranslation: false,
|
|
515
|
+
* restrictRelativeXTranslation: true, // Lock screen-horizontal
|
|
516
|
+
* restrictRelativeYTranslation: false
|
|
517
|
+
* };
|
|
518
|
+
*
|
|
519
|
+
* // Camera rotated 45 degrees
|
|
520
|
+
* const delta2 = { x: 100, y: 100 };
|
|
521
|
+
* const result2 = convertDeltaToComplyWithRestriction(delta2, camera, config2);
|
|
522
|
+
* // result2 projects delta onto screen-vertical direction
|
|
523
|
+
* // (perpendicular to screen-horizontal)
|
|
524
|
+
* ```
|
|
525
|
+
*
|
|
526
|
+
* @category Camera Rig
|
|
527
|
+
* @see {@link restrictPanByHandler} for usage in pan-by pipeline
|
|
528
|
+
* @see {@link restrictPanToHandler} for usage in pan-to pipeline
|
|
107
529
|
*/
|
|
108
530
|
export declare function convertDeltaToComplyWithRestriction(delta: Point, camera: BoardCamera, config: PanHandlerRestrictionConfig): Point;
|
|
109
531
|
/**
|
|
110
|
-
*
|
|
532
|
+
* Converts a user input delta (viewport space) to camera movement delta (world space).
|
|
533
|
+
*
|
|
534
|
+
* @param delta - Movement delta in viewport/screen coordinates (CSS pixels)
|
|
535
|
+
* @param camera - Current camera instance (provides rotation and zoom)
|
|
536
|
+
* @returns Equivalent delta in world space
|
|
537
|
+
*
|
|
538
|
+
* @remarks
|
|
539
|
+
* This function performs the standard viewport-to-world delta conversion:
|
|
540
|
+
* 1. Rotate delta by camera rotation (convert screen direction to world direction)
|
|
541
|
+
* 2. Scale by inverse zoom (convert screen distance to world distance)
|
|
542
|
+
*
|
|
543
|
+
* Formula: `worldDelta = rotate(viewportDelta, cameraRotation) / zoomLevel`
|
|
544
|
+
*
|
|
545
|
+
* This is the core conversion used by {@link DefaultCameraRig.panByViewPort}.
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* ```typescript
|
|
549
|
+
* // User drags mouse 100 pixels right, 50 pixels down
|
|
550
|
+
* const viewportDelta = { x: 100, y: 50 };
|
|
551
|
+
*
|
|
552
|
+
* // Camera at 2x zoom, no rotation
|
|
553
|
+
* camera.zoomLevel = 2.0;
|
|
554
|
+
* camera.rotation = 0;
|
|
555
|
+
*
|
|
556
|
+
* const worldDelta = convertUserInputDeltaToCameraDelta(viewportDelta, camera);
|
|
557
|
+
* // worldDelta = { x: 50, y: 25 } - half the viewport delta due to 2x zoom
|
|
558
|
+
* ```
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* ```typescript
|
|
562
|
+
* // With camera rotation
|
|
563
|
+
* camera.zoomLevel = 1.0;
|
|
564
|
+
* camera.rotation = Math.PI / 2; // 90 degrees
|
|
565
|
+
*
|
|
566
|
+
* const viewportDelta = { x: 100, y: 0 }; // Drag right
|
|
567
|
+
* const worldDelta = convertUserInputDeltaToCameraDelta(viewportDelta, camera);
|
|
568
|
+
* // worldDelta ≈ { x: 0, y: -100 } - rotated 90 degrees in world space
|
|
569
|
+
* ```
|
|
111
570
|
*
|
|
112
|
-
* @category Camera
|
|
571
|
+
* @category Camera Rig
|
|
572
|
+
* @see {@link DefaultCameraRig.panByViewPort} for usage
|
|
113
573
|
*/
|
|
114
574
|
export declare function convertUserInputDeltaToCameraDelta(delta: Point, camera: BoardCamera): Point;
|