@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,75 +1,372 @@
|
|
|
1
1
|
import { Point } from "@ue-too/math";
|
|
2
2
|
import { TransformationMatrix } from "./matrix";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Converts a viewport point to world space with respect to a hypothetical camera position.
|
|
5
|
+
* "WRT" = "With Respect To" - calculates where a viewport point would be in world space
|
|
6
|
+
* if the camera were at the target position.
|
|
7
|
+
*
|
|
8
|
+
* @param targetPosition - Hypothetical camera position in world coordinates
|
|
9
|
+
* @param interestPoint - Point in canvas coordinates (origin at bottom-left)
|
|
10
|
+
* @param viewPortWidth - Viewport width in CSS pixels
|
|
11
|
+
* @param viewPortHeight - Viewport height in CSS pixels
|
|
12
|
+
* @param cameraZoomLevel - Zoom level to apply
|
|
13
|
+
* @param cameraRotation - Rotation to apply in radians
|
|
14
|
+
* @returns World space coordinates of the interest point
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* This is useful for "what-if" calculations, such as:
|
|
18
|
+
* - Predicting where a viewport corner would land if camera moves to a position
|
|
19
|
+
* - Checking if moving to a position would show certain world objects
|
|
20
|
+
*
|
|
21
|
+
* The interest point uses canvas coordinates (bottom-left origin), not viewport coordinates (center origin).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Where would the top-left viewport corner be in world space
|
|
26
|
+
* // if camera moved to (100, 100)?
|
|
27
|
+
* const worldCorner = convert2WorldSpaceWRT(
|
|
28
|
+
* { x: 100, y: 100 }, // target camera position
|
|
29
|
+
* { x: 0, y: 1080 }, // top-left in canvas coords
|
|
30
|
+
* 1920, 1080, // viewport size
|
|
31
|
+
* 1.0, // zoom
|
|
32
|
+
* 0 // rotation
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
7
35
|
*
|
|
8
36
|
* @category Camera
|
|
9
37
|
*/
|
|
10
38
|
export declare function convert2WorldSpaceWRT(targetPosition: Point, interestPoint: Point, viewPortWidth: number, viewPortHeight: number, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
11
39
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
40
|
+
* Converts a canvas point to world space using current camera state.
|
|
41
|
+
*
|
|
42
|
+
* @param point - Point in canvas coordinates (origin at bottom-left)
|
|
43
|
+
* @param viewPortWidth - Viewport width in CSS pixels
|
|
44
|
+
* @param viewPortHeight - Viewport height in CSS pixels
|
|
45
|
+
* @param cameraPosition - Current camera position in world coordinates
|
|
46
|
+
* @param cameraZoomLevel - Current camera zoom level
|
|
47
|
+
* @param cameraRotation - Current camera rotation in radians
|
|
48
|
+
* @returns World space coordinates of the point
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* Input coordinates use canvas space with origin at bottom-left.
|
|
52
|
+
* This is useful when working with canvas element coordinates directly.
|
|
53
|
+
*
|
|
54
|
+
* For points already in viewport space (origin at center), use
|
|
55
|
+
* {@link convert2WorldSpaceAnchorAtCenter} instead.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* // Convert bottom-left corner of canvas to world coords
|
|
60
|
+
* const worldPos = convert2WorldSpace(
|
|
61
|
+
* { x: 0, y: 0 },
|
|
62
|
+
* 1920, 1080,
|
|
63
|
+
* { x: 100, y: 200 }, // camera position
|
|
64
|
+
* 1.5, // zoom
|
|
65
|
+
* 0 // rotation
|
|
66
|
+
* );
|
|
67
|
+
* ```
|
|
15
68
|
*
|
|
16
69
|
* @category Camera
|
|
17
70
|
*/
|
|
18
71
|
export declare function convert2WorldSpace(point: Point, viewPortWidth: number, viewPortHeight: number, cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
19
72
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
73
|
+
* Converts a viewport point (center-anchored) to world space.
|
|
74
|
+
* This is the most commonly used viewport-to-world conversion function.
|
|
75
|
+
*
|
|
76
|
+
* @param point - Point in viewport coordinates (origin at viewport center)
|
|
77
|
+
* @param cameraPosition - Camera position in world coordinates
|
|
78
|
+
* @param cameraZoomLevel - Camera zoom level
|
|
79
|
+
* @param cameraRotation - Camera rotation in radians
|
|
80
|
+
* @returns World space coordinates of the point
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Viewport coordinates have the origin at the center of the viewport, with:
|
|
84
|
+
* - Positive x to the right
|
|
85
|
+
* - Positive y upward
|
|
86
|
+
* - Point (0, 0) is the center of the viewport
|
|
87
|
+
*
|
|
88
|
+
* This is the standard coordinate system for camera operations.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* // Convert viewport center (0,0) to world space
|
|
93
|
+
* const worldCenter = convert2WorldSpaceAnchorAtCenter(
|
|
94
|
+
* { x: 0, y: 0 },
|
|
95
|
+
* { x: 500, y: 300 }, // camera at world (500, 300)
|
|
96
|
+
* 1.0,
|
|
97
|
+
* 0
|
|
98
|
+
* );
|
|
99
|
+
* // worldCenter will be { x: 500, y: 300 }
|
|
100
|
+
*
|
|
101
|
+
* // Convert point 100 pixels right of center
|
|
102
|
+
* const rightPoint = convert2WorldSpaceAnchorAtCenter(
|
|
103
|
+
* { x: 100, y: 0 },
|
|
104
|
+
* { x: 500, y: 300 },
|
|
105
|
+
* 2.0, // 2x zoom
|
|
106
|
+
* 0
|
|
107
|
+
* );
|
|
108
|
+
* // At 2x zoom, 100 viewport pixels = 50 world units
|
|
109
|
+
* // Result: { x: 550, y: 300 }
|
|
110
|
+
* ```
|
|
23
111
|
*
|
|
24
112
|
* @category Camera
|
|
25
113
|
*/
|
|
26
114
|
export declare function convert2WorldSpaceAnchorAtCenter(point: Point, cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
27
115
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
116
|
+
* Converts a world point to viewport space (center-anchored).
|
|
117
|
+
* Inverse of {@link convert2WorldSpaceAnchorAtCenter}.
|
|
118
|
+
*
|
|
119
|
+
* @param point - Point in world coordinates
|
|
120
|
+
* @param cameraPosition - Camera position in world coordinates
|
|
121
|
+
* @param cameraZoomLevel - Camera zoom level
|
|
122
|
+
* @param cameraRotation - Camera rotation in radians
|
|
123
|
+
* @returns Viewport coordinates (origin at center, in CSS pixels)
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* Use this to find where a world object appears on screen.
|
|
127
|
+
* Result is in viewport space with origin at center, useful for:
|
|
128
|
+
* - Positioning UI elements over world objects
|
|
129
|
+
* - Checking if objects are on screen
|
|
130
|
+
* - Converting click positions
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* // Where does world point (600, 300) appear in viewport?
|
|
135
|
+
* const viewportPos = convert2ViewPortSpaceAnchorAtCenter(
|
|
136
|
+
* { x: 600, y: 300 }, // world position
|
|
137
|
+
* { x: 500, y: 300 }, // camera position
|
|
138
|
+
* 1.0,
|
|
139
|
+
* 0
|
|
140
|
+
* );
|
|
141
|
+
* // Result: { x: 100, y: 0 } (100 pixels right of center)
|
|
142
|
+
*
|
|
143
|
+
* // Position a DOM element at this world object
|
|
144
|
+
* element.style.left = `${viewportPos.x + canvas.width/2}px`;
|
|
145
|
+
* element.style.top = `${-viewportPos.y + canvas.height/2}px`;
|
|
146
|
+
* ```
|
|
32
147
|
*
|
|
33
148
|
* @category Camera
|
|
34
149
|
*/
|
|
35
150
|
export declare function convert2ViewPortSpaceAnchorAtCenter(point: Point, cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
36
151
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
152
|
+
* Converts a world point to canvas coordinates (bottom-left origin).
|
|
153
|
+
*
|
|
154
|
+
* @param point - Point in world coordinates
|
|
155
|
+
* @param viewPortWidth - Viewport width in CSS pixels
|
|
156
|
+
* @param viewPortHeight - Viewport height in CSS pixels
|
|
157
|
+
* @param cameraPosition - Camera position in world coordinates
|
|
158
|
+
* @param cameraZoomLevel - Camera zoom level
|
|
159
|
+
* @param cameraRotation - Camera rotation in radians
|
|
160
|
+
* @returns Canvas coordinates (origin at bottom-left, in CSS pixels)
|
|
161
|
+
*
|
|
162
|
+
* @remarks
|
|
163
|
+
* "Invert" in the function name refers to inverting the forward transformation
|
|
164
|
+
* (world → viewport → canvas). The result uses canvas coordinates where:
|
|
165
|
+
* - (0, 0) is at the bottom-left corner
|
|
166
|
+
* - x increases to the right
|
|
167
|
+
* - y increases upward
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const canvasPos = invertFromWorldSpace(
|
|
172
|
+
* { x: 500, y: 300 }, // world position
|
|
173
|
+
* 1920, 1080,
|
|
174
|
+
* { x: 500, y: 300 }, // camera at same position
|
|
175
|
+
* 1.0,
|
|
176
|
+
* 0
|
|
177
|
+
* );
|
|
178
|
+
* // Result: { x: 960, y: 540 } (center of 1920x1080 canvas)
|
|
179
|
+
* ```
|
|
41
180
|
*
|
|
42
181
|
* @category Camera
|
|
43
182
|
*/
|
|
44
183
|
export declare function invertFromWorldSpace(point: Point, viewPortWidth: number, viewPortHeight: number, cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
45
184
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
185
|
+
* Checks if a world point is currently visible in the viewport.
|
|
186
|
+
*
|
|
187
|
+
* @param point - Point in world coordinates
|
|
188
|
+
* @param viewPortWidth - Viewport width in CSS pixels
|
|
189
|
+
* @param viewPortHeight - Viewport height in CSS pixels
|
|
190
|
+
* @param cameraPosition - Camera position in world coordinates
|
|
191
|
+
* @param cameraZoomLevel - Camera zoom level
|
|
192
|
+
* @param cameraRotation - Camera rotation in radians
|
|
193
|
+
* @returns True if point is visible in viewport, false otherwise
|
|
194
|
+
*
|
|
195
|
+
* @remarks
|
|
196
|
+
* A point is visible if it falls within the rectangular viewport bounds.
|
|
197
|
+
* This uses canvas coordinates for the visibility check (0 to width/height).
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* const isVisible = pointIsInViewPort(
|
|
202
|
+
* { x: 550, y: 300 }, // world point
|
|
203
|
+
* 1920, 1080,
|
|
204
|
+
* { x: 500, y: 300 }, // camera position
|
|
205
|
+
* 1.0,
|
|
206
|
+
* 0
|
|
207
|
+
* );
|
|
208
|
+
* // Returns true if point is within viewport bounds
|
|
209
|
+
* ```
|
|
49
210
|
*
|
|
50
211
|
* @category Camera
|
|
51
212
|
*/
|
|
52
213
|
export declare function pointIsInViewPort(point: Point, viewPortWidth: number, viewPortHeight: number, cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): boolean;
|
|
53
214
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
215
|
+
* Converts a displacement vector from viewport space to world space.
|
|
216
|
+
* Use this for converting movement deltas, not absolute positions.
|
|
217
|
+
*
|
|
218
|
+
* @param delta - Displacement vector in viewport space (CSS pixels)
|
|
219
|
+
* @param cameraZoomLevel - Camera zoom level
|
|
220
|
+
* @param cameraRotation - Camera rotation in radians
|
|
221
|
+
* @returns Displacement vector in world coordinates
|
|
222
|
+
*
|
|
223
|
+
* @remarks
|
|
224
|
+
* This transforms a *relative* displacement, not an absolute point.
|
|
225
|
+
* The conversion accounts for:
|
|
226
|
+
* - Rotation: Delta is rotated by camera rotation
|
|
227
|
+
* - Zoom: Delta is scaled by 1/zoom (viewport pixels → world units)
|
|
228
|
+
*
|
|
229
|
+
* Note: Camera position is NOT needed for delta transformations.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* // User dragged 100 pixels to the right in viewport
|
|
234
|
+
* const viewportDelta = { x: 100, y: 0 };
|
|
235
|
+
* const worldDelta = convertDeltaInViewPortToWorldSpace(
|
|
236
|
+
* viewportDelta,
|
|
237
|
+
* 2.0, // 2x zoom
|
|
238
|
+
* 0 // no rotation
|
|
239
|
+
* );
|
|
240
|
+
* // Result: { x: 50, y: 0 } (100 viewport pixels = 50 world units at 2x zoom)
|
|
241
|
+
* ```
|
|
56
242
|
*
|
|
57
243
|
* @category Camera
|
|
58
244
|
*/
|
|
59
245
|
export declare function convertDeltaInViewPortToWorldSpace(delta: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
60
246
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
247
|
+
* Converts a displacement vector from world space to viewport space.
|
|
248
|
+
* Use this for converting movement deltas, not absolute positions.
|
|
249
|
+
* Inverse of {@link convertDeltaInViewPortToWorldSpace}.
|
|
250
|
+
*
|
|
251
|
+
* @param delta - Displacement vector in world coordinates
|
|
252
|
+
* @param cameraZoomLevel - Camera zoom level
|
|
253
|
+
* @param cameraRotation - Camera rotation in radians
|
|
254
|
+
* @returns Displacement vector in viewport space (CSS pixels)
|
|
255
|
+
*
|
|
256
|
+
* @remarks
|
|
257
|
+
* This transforms a *relative* displacement, not an absolute point.
|
|
258
|
+
* The conversion accounts for:
|
|
259
|
+
* - Rotation: Delta is rotated by -camera rotation
|
|
260
|
+
* - Zoom: Delta is scaled by zoom (world units → viewport pixels)
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* // Object moved 50 units right in world space
|
|
265
|
+
* const worldDelta = { x: 50, y: 0 };
|
|
266
|
+
* const viewportDelta = convertDeltaInWorldToViewPortSpace(
|
|
267
|
+
* worldDelta,
|
|
268
|
+
* 2.0, // 2x zoom
|
|
269
|
+
* 0 // no rotation
|
|
270
|
+
* );
|
|
271
|
+
* // Result: { x: 100, y: 0 } (50 world units = 100 viewport pixels at 2x zoom)
|
|
272
|
+
* ```
|
|
63
273
|
*
|
|
64
274
|
* @category Camera
|
|
65
275
|
*/
|
|
66
276
|
export declare function convertDeltaInWorldToViewPortSpace(delta: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
67
277
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
278
|
+
* Calculates the camera position needed to place a world point at a specific viewport location.
|
|
279
|
+
* Useful for implementing "zoom to point" or "focus on object" features.
|
|
280
|
+
*
|
|
281
|
+
* @param pointInWorld - The world point to focus on
|
|
282
|
+
* @param toPointInViewPort - Where in the viewport this point should appear (origin at center)
|
|
283
|
+
* @param cameraZoomLevel - Target zoom level
|
|
284
|
+
* @param cameraRotation - Target rotation in radians
|
|
285
|
+
* @returns Camera position that achieves the desired framing
|
|
286
|
+
*
|
|
287
|
+
* @remarks
|
|
288
|
+
* This is particularly useful for:
|
|
289
|
+
* - Zoom-to-cursor: Make clicked point stay under cursor while zooming
|
|
290
|
+
* - Pan-and-zoom: Smoothly navigate to show a specific object
|
|
291
|
+
* - Focus features: Center camera on a world object
|
|
292
|
+
*
|
|
293
|
+
* The viewport point is in viewport coordinates (center origin).
|
|
294
|
+
* To center on a world point, use toPointInViewPort = {x: 0, y: 0}.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* // Center camera on world point (1000, 500)
|
|
299
|
+
* const newCameraPos = cameraPositionToGet(
|
|
300
|
+
* { x: 1000, y: 500 }, // world point to focus on
|
|
301
|
+
* { x: 0, y: 0 }, // center of viewport
|
|
302
|
+
* 2.0, // zoom level
|
|
303
|
+
* 0 // rotation
|
|
304
|
+
* );
|
|
305
|
+
* camera.setPosition(newCameraPos);
|
|
306
|
+
*
|
|
307
|
+
* // Zoom to cursor position
|
|
308
|
+
* // Keep world point under cursor at (viewportX, viewportY)
|
|
309
|
+
* const cursorViewport = {
|
|
310
|
+
* x: mouseX - canvas.width/2,
|
|
311
|
+
* y: mouseY - canvas.height/2
|
|
312
|
+
* };
|
|
313
|
+
* const worldAtCursor = camera.convertFromViewPort2WorldSpace(cursorViewport);
|
|
314
|
+
* const newPos = cameraPositionToGet(worldAtCursor, cursorViewport, newZoom, rotation);
|
|
315
|
+
* camera.setPosition(newPos);
|
|
316
|
+
* camera.setZoomLevel(newZoom);
|
|
317
|
+
* ```
|
|
70
318
|
*
|
|
71
319
|
* @category Camera
|
|
72
320
|
*/
|
|
73
321
|
export declare function cameraPositionToGet(pointInWorld: Point, toPointInViewPort: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
322
|
+
/**
|
|
323
|
+
* Creates a transformation matrix from camera parameters.
|
|
324
|
+
* Combines position, zoom, and rotation into a single transform.
|
|
325
|
+
*
|
|
326
|
+
* @param cameraPosition - Camera position in world coordinates
|
|
327
|
+
* @param cameraZoomLevel - Camera zoom level
|
|
328
|
+
* @param cameraRotation - Camera rotation in radians
|
|
329
|
+
* @returns Transformation matrix for viewport-to-world conversion
|
|
330
|
+
*
|
|
331
|
+
* @remarks
|
|
332
|
+
* The resulting matrix can be used with {@link convert2WorldSpaceWithTransformationMatrix}
|
|
333
|
+
* for efficient batch transformations when camera state doesn't change.
|
|
334
|
+
*
|
|
335
|
+
* Matrix composition order: Translation → Rotation → Scale(1/zoom)
|
|
336
|
+
*
|
|
337
|
+
* @category Camera
|
|
338
|
+
*/
|
|
74
339
|
export declare function transformationMatrixFromCamera(cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): TransformationMatrix;
|
|
340
|
+
/**
|
|
341
|
+
* Transforms a viewport point to world space using a precomputed transformation matrix.
|
|
342
|
+
* Faster than repeated function calls when transforming many points with the same camera state.
|
|
343
|
+
*
|
|
344
|
+
* @param point - Point in viewport coordinates (origin at center)
|
|
345
|
+
* @param transformationMatrix - Precomputed transformation matrix from {@link transformationMatrixFromCamera}
|
|
346
|
+
* @returns World space coordinates of the point
|
|
347
|
+
*
|
|
348
|
+
* @remarks
|
|
349
|
+
* Use this for batch transformations when the camera state is constant:
|
|
350
|
+
* 1. Create matrix once with {@link transformationMatrixFromCamera}
|
|
351
|
+
* 2. Transform many points with this function
|
|
352
|
+
*
|
|
353
|
+
* This avoids recalculating sin/cos and matrix operations for each point.
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* // Transform many points efficiently
|
|
358
|
+
* const matrix = transformationMatrixFromCamera(
|
|
359
|
+
* { x: 100, y: 200 },
|
|
360
|
+
* 1.5,
|
|
361
|
+
* Math.PI / 4
|
|
362
|
+
* );
|
|
363
|
+
*
|
|
364
|
+
* const worldPoints = viewportPoints.map(vp =>
|
|
365
|
+
* convert2WorldSpaceWithTransformationMatrix(vp, matrix)
|
|
366
|
+
* );
|
|
367
|
+
* ```
|
|
368
|
+
*
|
|
369
|
+
* @category Camera
|
|
370
|
+
* @see {@link transformationMatrixFromCamera} to create the matrix
|
|
371
|
+
*/
|
|
75
372
|
export declare function convert2WorldSpaceWithTransformationMatrix(point: Point, transformationMatrix: TransformationMatrix): Point;
|
package/camera/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera utility functions module exports.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module provides specialized utility functions for camera operations including
|
|
6
|
+
* coordinate transformations, matrix math, position calculations, rotation utilities,
|
|
7
|
+
* and zoom level helpers.
|
|
8
|
+
*
|
|
9
|
+
* ## Key Utilities
|
|
10
|
+
*
|
|
11
|
+
* - **Coordinate Conversion**: Convert between viewport, world, and window coordinate systems
|
|
12
|
+
* - **Matrix Operations**: Transformation matrix creation and manipulation
|
|
13
|
+
* - **Position Utilities**: Boundary calculations, translation clamping, and position helpers
|
|
14
|
+
* - **Rotation Utilities**: Angle normalization, clamping, and rotation boundary enforcement
|
|
15
|
+
* - **Zoom Utilities**: Zoom level clamping, boundary calculations, and zoom constraints
|
|
16
|
+
*
|
|
17
|
+
* @see {@link convertFromViewPort2WorldSpace} for viewport to world conversion
|
|
18
|
+
* @see {@link clampRotation} for rotation angle clamping
|
|
19
|
+
* @see {@link clampZoomLevel} for zoom level clamping
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
1
23
|
export * from "./coordinate-conversion";
|
|
2
24
|
export * from "./matrix";
|
|
3
25
|
export * from "./position";
|