@ue-too/board 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE.txt +19 -0
  2. package/board.tsbuildinfo +1 -0
  3. package/boardify/index.d.ts +192 -0
  4. package/camera/base.d.ts +189 -0
  5. package/camera/camera-mux/animation-and-lock/animation-and-lock.d.ts +50 -0
  6. package/camera/camera-mux/animation-and-lock/index.d.ts +4 -0
  7. package/camera/camera-mux/animation-and-lock/pan-control-state-machine.d.ts +137 -0
  8. package/camera/camera-mux/animation-and-lock/rotation-control-state-machine.d.ts +131 -0
  9. package/camera/camera-mux/animation-and-lock/zoom-control-state-machine.d.ts +143 -0
  10. package/camera/camera-mux/index.d.ts +3 -0
  11. package/camera/camera-mux/interface.d.ts +12 -0
  12. package/camera/camera-mux/relay.d.ts +27 -0
  13. package/camera/camera-rig/camera-rig.d.ts +207 -0
  14. package/camera/camera-rig/index.d.ts +5 -0
  15. package/camera/camera-rig/pan-handler.d.ts +113 -0
  16. package/camera/camera-rig/rotation-handler.d.ts +78 -0
  17. package/camera/camera-rig/update-batcher/index.d.ts +3 -0
  18. package/camera/camera-rig/update-batcher/position-update-batcher.d.ts +58 -0
  19. package/camera/camera-rig/update-batcher/rotation-update-batcher.d.ts +54 -0
  20. package/camera/camera-rig/update-batcher/zoom-udpate-batcher.d.ts +60 -0
  21. package/camera/camera-rig/zoom-handler.d.ts +77 -0
  22. package/camera/default-camera.d.ts +170 -0
  23. package/camera/index.d.ts +8 -0
  24. package/camera/interface.d.ts +59 -0
  25. package/camera/update-publisher.d.ts +172 -0
  26. package/camera/utils/coordinate-conversion.d.ts +75 -0
  27. package/camera/utils/index.d.ts +5 -0
  28. package/camera/utils/matrix.d.ts +114 -0
  29. package/camera/utils/position.d.ts +71 -0
  30. package/camera/utils/rotation.d.ts +64 -0
  31. package/camera/utils/zoom.d.ts +25 -0
  32. package/index.d.ts +5 -0
  33. package/index.js +2 -0
  34. package/index.js.map +1 -0
  35. package/input-interpretation/index.d.ts +3 -0
  36. package/input-interpretation/input-state-machine/index.d.ts +4 -0
  37. package/input-interpretation/input-state-machine/kmt-input-context.d.ts +130 -0
  38. package/input-interpretation/input-state-machine/kmt-input-state-machine.d.ts +194 -0
  39. package/input-interpretation/input-state-machine/touch-input-context.d.ts +44 -0
  40. package/input-interpretation/input-state-machine/touch-input-state-machine.d.ts +64 -0
  41. package/input-interpretation/raw-input-parser/index.d.ts +2 -0
  42. package/input-interpretation/raw-input-parser/vanilla-kmt-event-parser.d.ts +87 -0
  43. package/input-interpretation/raw-input-parser/vanilla-touch-event-parser.d.ts +55 -0
  44. package/input-interpretation/raw-input-publisher/index.d.ts +1 -0
  45. package/input-interpretation/raw-input-publisher/raw-input-publisher.d.ts +130 -0
  46. package/package.json +39 -0
  47. package/utils/canvas-position-dimension.d.ts +18 -0
  48. package/utils/coorindate-conversion.d.ts +5 -0
  49. package/utils/drawing-utils.d.ts +55 -0
  50. package/utils/drawing.d.ts +30 -0
  51. package/utils/handler-pipeline.d.ts +30 -0
  52. package/utils/index.d.ts +8 -0
  53. package/utils/observable.d.ts +9 -0
  54. package/utils/ruler.d.ts +1 -0
  55. package/utils/zoomlevel-adjustment.d.ts +28 -0
@@ -0,0 +1,113 @@
1
+ import { Point } from "@ue-too/math";
2
+ import { BoardCamera } from "../interface";
3
+ /**
4
+ * @description Configuration for the pan handler functions.
5
+ *
6
+ * @category Camera
7
+ */
8
+ export type PanHandlerConfig = PanHandlerRestrictionConfig & PanHandlerClampConfig;
9
+ export type PanHandlerClampConfig = {
10
+ /**
11
+ * @description Whether to limit the pan to the entire view port.
12
+ */
13
+ limitEntireViewPort: boolean;
14
+ /**
15
+ * @description Whether to clamp the translation.
16
+ */
17
+ clampTranslation: boolean;
18
+ };
19
+ export type PanHandlerRestrictionConfig = {
20
+ /**
21
+ * @description Whether to restrict the x translation.
22
+ */
23
+ restrictXTranslation: boolean;
24
+ /**
25
+ * @description Whether to restrict the y translation.
26
+ */
27
+ restrictYTranslation: boolean;
28
+ /**
29
+ * @description Whether to restrict the relative x translation. (because the camera can be rotated, the relative x translation is the horizontal direction of what the user sees on the screen)
30
+ */
31
+ restrictRelativeXTranslation: boolean;
32
+ /**
33
+ * @description Whether to restrict the relative y translation. (because the camera can be rotated, the relative y translation is the vertical direction of what the user sees on the screen)
34
+ */
35
+ restrictRelativeYTranslation: boolean;
36
+ };
37
+ /**
38
+ * @description Function Type that is used to define the "pan to" handler.
39
+ * The destination is in "stage/context/world" space.
40
+ * This is structured as a handler pipeline.
41
+ * @see {@link createHandlerChain}
42
+ * @category Camera
43
+ */
44
+ export type PanToHandlerFunction = (destination: Point, camera: BoardCamera, config: PanHandlerConfig) => Point;
45
+ /**
46
+ * @description Function Type that is used to define the "pan by" handler.
47
+ * The delta is in "stage/context/world" space.
48
+ * This is structured as a handler pipeline.
49
+ * @see {@link createHandlerChain}
50
+ * @category Camera
51
+ */
52
+ export type PanByHandlerFunction = (delta: Point, camera: BoardCamera, config: PanHandlerConfig) => Point;
53
+ /**
54
+ * @description Helper function that creates a default "pan to" handler.
55
+ * The default pan to handler will first restrict the pan to the view port, then clamp the pan to the boundaries, and then pan to the destination.
56
+ *
57
+ * @see {@link createHandlerChain} to create your own custom pan handler pipeline. (you can also use this function as a part of your own custom pan handler pipeline)
58
+ * @category Camera
59
+ */
60
+ export declare function createDefaultPanToHandler(): PanToHandlerFunction;
61
+ /**
62
+ * @description Helper function that creates a default "pan by" handler.
63
+ * The resulting pan by handler takes in a delta that is in "stage/context/world" space.
64
+ * The default pan by handler will first restrict the pan by the view port, then clamp the pan by the boundaries, and then pan by the delta.
65
+ *
66
+ * @see {@link createHandlerChain} to create your own custom pan handler pipeline. (you can also use this function as a part of your own custom pan handler pipeline)
67
+ * @category Camera
68
+ */
69
+ export declare function createDefaultPanByHandler(): PanByHandlerFunction;
70
+ /**
71
+ * @description Function that is part of the "pan to" handler pipeline. It restricts the "pan to" destination to within a single axis based on the config. (relative to the current camera position)
72
+ * You can use this function standalone to restrict the "pan to" destination to within a single axis based on the config.
73
+ * But it is recommended to use this kind of function as part of the pan handler pipeline. (to include this function in your own custom pan handler pipeline)
74
+ *
75
+ * @category Camera
76
+ */
77
+ export declare function restrictPanToHandler(destination: Point, camera: BoardCamera, config: PanHandlerRestrictionConfig): Point;
78
+ /**
79
+ * @description Function that is part of the "pan by" handler pipeline. It restricts the pan delta to within a single axis based on the config. (relative to the current camera position)
80
+ * You can use this function standalone to restrict the pan delta to within a single axis based on the config.
81
+ * But it is recommended to use this kind of function as part of the pan handler pipeline. (to include this function in your own custom pan handler pipeline)
82
+ *
83
+ * @category Camera
84
+ */
85
+ export declare function restrictPanByHandler(delta: Point, camera: BoardCamera, config: PanHandlerRestrictionConfig): Point;
86
+ /**
87
+ * @description Function that is part of the "pan to" handler pipeline. It clamps the pan destination within the boundaries of the view port.
88
+ * You can use this function standalone to clamp the pan destination within the boundaries of the view port.
89
+ * But it is recommended to use this kind of function as part of the pan handler pipeline. (to include this function in your own custom pan handler pipeline)
90
+ *
91
+ * @category Camera
92
+ */
93
+ export declare function clampToHandler(destination: Point, camera: BoardCamera, config: PanHandlerClampConfig): Point;
94
+ /**
95
+ * @description Function that is part of the "pan by" handler pipeline. It clamps the pan delta within the boundaries of the view port.
96
+ * You can use this function standalone to clamp the pan delta within the boundaries of the view port.
97
+ * But it is recommended to use this kind of function as part of the pan handler pipeline. (to include this function in your own custom pan handler pipeline)
98
+ *
99
+ * @category Camera
100
+ */
101
+ export declare function clampByHandler(delta: Point, camera: BoardCamera, config: PanHandlerClampConfig): Point;
102
+ /**
103
+ * @description Helper function that converts the delta to comply with the restrictions of the config.
104
+ *
105
+ * @category Camera
106
+ */
107
+ export declare function convertDeltaToComplyWithRestriction(delta: Point, camera: BoardCamera, config: PanHandlerRestrictionConfig): Point;
108
+ /**
109
+ * @description Helper function that converts the user input delta to the camera delta.
110
+ *
111
+ * @category Camera
112
+ */
113
+ export declare function convertUserInputDeltaToCameraDelta(delta: Point, camera: BoardCamera): Point;
@@ -0,0 +1,78 @@
1
+ import { BoardCamera } from "../interface";
2
+ /**
3
+ * @description This is the configuration for the rotation handler functions.
4
+ * This is the configuration object that is passed to the rotation handler functions.
5
+ *
6
+ * @category Camera
7
+ */
8
+ export type RotationHandlerConfig = RotationHandlerRestrictConfig & RotationHandlerClampConfig;
9
+ export type RotationHandlerRestrictConfig = {
10
+ /**
11
+ * @description Whether to restrict the rotation. (if true, rotation input will be ignored)
12
+ */
13
+ restrictRotation: boolean;
14
+ };
15
+ export type RotationHandlerClampConfig = {
16
+ /**
17
+ * @description Whether to clamp the rotation if the rotation is out of the rotation boundaries.
18
+ */
19
+ clampRotation: boolean;
20
+ };
21
+ /**
22
+ * @description The function that is used to rotate the camera by a specific delta.
23
+ * The delta is in radians.
24
+ * This is structured as a handler pipeline.
25
+ *
26
+ * @see {@link createHandlerChain}
27
+ * @category Camera
28
+ */
29
+ export type RotateByHandlerFunction = (delta: number, camera: BoardCamera, config: RotationHandlerConfig) => number;
30
+ /**
31
+ * @description The function that is used to rotate the camera to a specific target rotation.
32
+ * The target rotation is in radians.
33
+ * This is structured as a handler pipeline.
34
+ *
35
+ * @see {@link createHandlerChain}
36
+ * @category Camera
37
+ */
38
+ export type RotateToHandlerFunction = (targetRotation: number, camera: BoardCamera, config: RotationHandlerConfig) => number;
39
+ /**
40
+ * @description This is the clamp handler for the "rotate by" handler pipeline.
41
+ * It clamps the delta to the range of the camera's rotation boundaries.
42
+ *
43
+ * @category Camera
44
+ */
45
+ export declare function clampRotateByHandler(delta: number, camera: BoardCamera, config: RotationHandlerClampConfig): number;
46
+ /**
47
+ * @description This is the restrict handler for the "rotate by" handler pipeline.
48
+ * It restricts the delta to the range of the camera's rotation boundaries.
49
+ *
50
+ * @category Camera
51
+ */
52
+ export declare function restrictRotateByHandler(delta: number, camera: BoardCamera, config: RotationHandlerRestrictConfig): number;
53
+ /**
54
+ * @description This is the clamp handler for the "rotate to" handler pipeline.
55
+ * It clamps the target rotation to the range of the camera's rotation boundaries.
56
+ *
57
+ * @category Camera
58
+ */
59
+ export declare function clampRotateToHandler(targetRotation: number, camera: BoardCamera, config: RotationHandlerClampConfig): number;
60
+ /**
61
+ * @description This is the restrict handler for the "rotate to" handler pipeline.
62
+ * It restricts the target rotation to the range of the camera's rotation boundaries.
63
+ *
64
+ * @category Camera
65
+ */
66
+ export declare function restrictRotateToHandler(targetRotation: number, camera: BoardCamera, config: RotationHandlerRestrictConfig): number;
67
+ /**
68
+ * @description This is the create default handler chain function for the "rotate by" handler pipeline.
69
+ *
70
+ * @category Camera
71
+ */
72
+ export declare function createDefaultRotateByHandler(): RotateByHandlerFunction;
73
+ /**
74
+ * @description This is the create default handler chain function for the "rotate to" handler pipeline.
75
+ *
76
+ * @category Camera
77
+ */
78
+ export declare function createDefaultRotateToHandler(): RotateToHandlerFunction;
@@ -0,0 +1,3 @@
1
+ export * from "./position-update-batcher";
2
+ export * from "./rotation-update-batcher";
3
+ export * from "./zoom-udpate-batcher";
@@ -0,0 +1,58 @@
1
+ import { Observer, SubscriptionOptions } from "../../../utils/observable";
2
+ export type Position = {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ export type Velocity = {
7
+ vx: number;
8
+ vy: number;
9
+ };
10
+ export type DestinationUpdate = Position & {
11
+ type: 'destination';
12
+ };
13
+ export type DeltaUpdate = Position & {
14
+ type: 'delta';
15
+ };
16
+ export type PositionUpdate = DestinationUpdate | DeltaUpdate;
17
+ export declare class CameraPositionUpdateBatcher {
18
+ private nextPosition;
19
+ private delta;
20
+ private observable;
21
+ private queuePositionUpdateCount;
22
+ private queuePositionUpdateToCount;
23
+ private queuePositionUpdateByCount;
24
+ private lastUpdateCount;
25
+ constructor();
26
+ /**
27
+ * Queue an absolute position update to be processed in the next animation frame
28
+ */
29
+ queuePositionUpdate(x: number, y: number): void;
30
+ /**
31
+ * Queue a position update to a specific destination to be processed in the next animation frame
32
+ * This will override any pending delta updates
33
+ */
34
+ queuePositionUpdateTo(destination: Position): void;
35
+ /**
36
+ * Queue a position update by delta to be processed in the next animation frame
37
+ * This will be ignored if there's a pending destination update
38
+ */
39
+ queuePositionUpdateBy(delta: Position): void;
40
+ /**
41
+ * Process and clear all queued position updates
42
+ * @returns the update to apply to the position, with type information
43
+ */
44
+ processQueuedUpdates(): PositionUpdate | null;
45
+ /**
46
+ * Subscribe to position updates
47
+ */
48
+ subscribe(observer: Observer<[PositionUpdate]>, options?: SubscriptionOptions): () => void;
49
+ /**
50
+ * Get debug information about queue method calls since last update
51
+ */
52
+ getDebugInfo(): {
53
+ lastUpdateTotalCalls: number;
54
+ queuePositionUpdateCalls: number;
55
+ queuePositionUpdateToCalls: number;
56
+ queuePositionUpdateByCalls: number;
57
+ };
58
+ }
@@ -0,0 +1,54 @@
1
+ import { Observer, SubscriptionOptions } from "../../../utils/observable";
2
+ export type Rotation = number;
3
+ export type RotationVelocity = number;
4
+ export type RotationDestinationUpdate = {
5
+ type: 'destination';
6
+ destination: Rotation;
7
+ };
8
+ export type RotationDeltaUpdate = {
9
+ type: 'delta';
10
+ delta: Rotation;
11
+ };
12
+ export type RotationUpdate = RotationDestinationUpdate | RotationDeltaUpdate;
13
+ export declare class CameraRotationUpdateBatcher {
14
+ private nextRotation;
15
+ private delta;
16
+ private observable;
17
+ private queueRotationUpdateCount;
18
+ private queueRotationUpdateToCount;
19
+ private queueRotationUpdateByCount;
20
+ private lastUpdateCount;
21
+ constructor();
22
+ /**
23
+ * Queue an absolute rotation update to be processed in the next animation frame
24
+ */
25
+ queueRotationUpdate(rotation: Rotation): void;
26
+ /**
27
+ * Queue a rotation update to a specific destination to be processed in the next animation frame
28
+ * This will override any pending delta updates
29
+ */
30
+ queueRotationUpdateTo(destination: Rotation): void;
31
+ /**
32
+ * Queue a rotation update by delta to be processed in the next animation frame
33
+ * This will be ignored if there's a pending destination update
34
+ */
35
+ queueRotationUpdateBy(delta: Rotation): void;
36
+ /**
37
+ * Process and clear all queued rotation updates
38
+ * @returns the update to apply to the rotation, with type information
39
+ */
40
+ processQueuedUpdates(): RotationUpdate | null;
41
+ /**
42
+ * Subscribe to rotation updates
43
+ */
44
+ subscribe(observer: Observer<[RotationUpdate]>, options?: SubscriptionOptions): () => void;
45
+ /**
46
+ * Get debug information about queue method calls since last update
47
+ */
48
+ getDebugInfo(): {
49
+ lastUpdateTotalCalls: number;
50
+ queueRotationUpdateCalls: number;
51
+ queueRotationUpdateToCalls: number;
52
+ queueRotationUpdateByCalls: number;
53
+ };
54
+ }
@@ -0,0 +1,60 @@
1
+ import { Observer, SubscriptionOptions } from "../../../utils/observable";
2
+ import { Point } from "@ue-too/math";
3
+ export type DestinationZoomUpdate = {
4
+ type: 'destination';
5
+ destination: number;
6
+ anchor?: Point;
7
+ };
8
+ export type DeltaZoomUpdate = {
9
+ type: 'delta';
10
+ delta: number;
11
+ anchor?: Point;
12
+ };
13
+ export type ZoomUpdate = {
14
+ anchorCoordinateSystem: 'world' | 'viewport';
15
+ update: DestinationZoomUpdate | DeltaZoomUpdate;
16
+ };
17
+ export declare class CameraZoomUpdateBatcher {
18
+ private nextZoom;
19
+ private observable;
20
+ private anchor;
21
+ private delta;
22
+ private anchorCoordinateSystem;
23
+ private queueZoomUpdateCount;
24
+ private queueZoomUpdateToCount;
25
+ private lastUpdateCount;
26
+ constructor();
27
+ /**
28
+ * Queue a zoom update to a specific destination to be processed in the next animation frame
29
+ */
30
+ queueZoomUpdateTo(destination: number, anchor?: Point): void;
31
+ /**
32
+ * Queue a zoom update by delta to be processed in the next animation frame
33
+ */
34
+ queueZoomUpdateBy(delta: number, anchor?: Point): void;
35
+ /**
36
+ * Queue a zoom update by delta at a world anchor to be processed in the next animation frame
37
+ */
38
+ queueZoomByAtWorld(delta: number, worldAnchor: Point): void;
39
+ /**
40
+ * Queue a zoom update to a specific destination at a world anchor to be processed in the next animation frame
41
+ */
42
+ queueZoomToAtWorld(destination: number, worldAnchor: Point): void;
43
+ /**
44
+ * Process and clear all queued zoom updates
45
+ * @returns the update to apply to the zoom level, with type information
46
+ */
47
+ processQueuedUpdates(): ZoomUpdate | null;
48
+ /**
49
+ * Subscribe to zoom updates
50
+ */
51
+ subscribe(observer: Observer<[ZoomUpdate]>, options?: SubscriptionOptions): () => void;
52
+ /**
53
+ * Get debug information about queue method calls since last update
54
+ */
55
+ getDebugInfo(): {
56
+ lastUpdateTotalCalls: number;
57
+ queueZoomUpdateCalls: number;
58
+ queueZoomUpdateToCalls: number;
59
+ };
60
+ }
@@ -0,0 +1,77 @@
1
+ import { BoardCamera } from "../interface";
2
+ /**
3
+ * @description The configuration for the base zoom handler.
4
+ *
5
+ * @category Camera
6
+ */
7
+ export type ZoomHandlerConfig = ZoomHandlerClampConfig & ZoomHandlerRestrictConfig;
8
+ export type ZoomHandlerClampConfig = {
9
+ /**
10
+ * @description Whether to clamp the zoom level.
11
+ */
12
+ clampZoom: boolean;
13
+ };
14
+ export type ZoomHandlerRestrictConfig = {
15
+ /**
16
+ * @description Whether to restrict the zoom level.
17
+ */
18
+ restrictZoom: boolean;
19
+ };
20
+ /**
21
+ * @description The function signature for the zoom to handler.
22
+ *
23
+ * @category Camera
24
+ */
25
+ export type ZoomToHandlerFunction = (destination: number, camera: BoardCamera, config: ZoomHandlerConfig) => number;
26
+ /**
27
+ * @description The function signature for the zoom by handler.
28
+ *
29
+ * @category Camera
30
+ */
31
+ export type ZoomByHandlerFunction = (delta: number, camera: BoardCamera, config: ZoomHandlerConfig) => number;
32
+ /**
33
+ * @description The function that is part of the zoom to handler pipeline.
34
+ * Clamps the zoom level to the zoom boundaries.
35
+ *
36
+ * @see {@link createHandlerChain}
37
+ * @category Camera
38
+ */
39
+ export declare function clampZoomToHandler(destination: number, camera: BoardCamera, config: ZoomHandlerClampConfig): number;
40
+ /**
41
+ * @description The function that is part of the zoom by handler pipeline.
42
+ * Clamps the zoom level to the zoom boundaries.
43
+ *
44
+ * @see {@link createHandlerChain}
45
+ * @category Camera
46
+ */
47
+ export declare function clampZoomByHandler(delta: number, camera: BoardCamera, config: ZoomHandlerClampConfig): number;
48
+ /**
49
+ * @description The function that is part of the zoom to handler pipeline.
50
+ * Restricts the zoom level to the zoom boundaries.
51
+ *
52
+ * @see {@link createHandlerChain}
53
+ * @category Camera
54
+ */
55
+ export declare function restrictZoomToHandler(destination: number, camera: BoardCamera, config: ZoomHandlerRestrictConfig): number;
56
+ /**
57
+ * @description The function that is part of the zoom by handler pipeline.
58
+ * Restricts the zoom level to the zoom boundaries.
59
+ *
60
+ * @see {@link createHandlerChain}
61
+ * @category Camera
62
+ */
63
+ export declare function restrictZoomByHandler(delta: number, camera: BoardCamera, config: ZoomHandlerRestrictConfig): number;
64
+ /**
65
+ * @description The function that creates the default zoom to only handler.
66
+ * clamp -> restrict -> base
67
+ * @see {@link createHandlerChain}
68
+ * @category Camera
69
+ */
70
+ export declare function createDefaultZoomToOnlyHandler(): ZoomToHandlerFunction;
71
+ /**
72
+ * @description The function that creates the default zoom by only handler.
73
+ * clamp -> restrict -> base
74
+ * @see {@link createHandlerChain}
75
+ * @category Camera
76
+ */
77
+ export declare function createDefaultZoomByOnlyHandler(): ZoomByHandlerFunction;
@@ -0,0 +1,170 @@
1
+ import { Point } from '@ue-too/math';
2
+ import { Boundaries } from './utils/position';
3
+ import { TransformationMatrix } from './utils/matrix';
4
+ import { UnSubscribe } from './update-publisher';
5
+ import { ZoomLevelLimits } from './utils/zoom';
6
+ import { RotationLimits } from './utils/rotation';
7
+ import { CameraEventMap, CameraState } from './update-publisher';
8
+ import { ObservableBoardCamera } from './interface';
9
+ import { SubscriptionOptions } from '../utils/observable';
10
+ export declare const DEFAULT_BOARD_CAMERA_VIEWPORT_WIDTH = 1000;
11
+ export declare const DEFAULT_BOARD_CAMERA_VIEWPORT_HEIGHT = 1000;
12
+ export declare const DEFAULT_BOARD_CAMERA_ZOOM_BOUNDARIES: ZoomLevelLimits;
13
+ export declare const DEFAULT_BOARD_CAMERA_BOUNDARIES: Boundaries;
14
+ export declare const DEFAULT_BOARD_CAMERA_ROTATION_BOUNDARIES: RotationLimits;
15
+ /**
16
+ * @description The default board camera. This is basically the same as the {@link BaseCamera} class.
17
+ * But it's observable.
18
+ *
19
+ * @category Camera
20
+ */
21
+ export default class DefaultBoardCamera implements ObservableBoardCamera {
22
+ private _baseCamera;
23
+ private _observer;
24
+ /**
25
+ * @param position The position of the camera in the world coordinate system
26
+ * @param rotation The rotation of the camera in the world coordinate system
27
+ * @param zoomLevel The zoom level of the camera
28
+ * @param viewPortWidth The width of the viewport. (The width of the canvas in css pixels)
29
+ * @param viewPortHeight The height of the viewport. (The height of the canvas in css pixels)
30
+ * @param boundaries The boundaries of the camera in the world coordinate system
31
+ * @param zoomLevelBoundaries The boundaries of the zoom level of the camera
32
+ * @param rotationBoundaries The boundaries of the rotation of the camera
33
+ */
34
+ constructor(viewPortWidth?: number, viewPortHeight?: number, position?: Point, rotation?: number, zoomLevel?: number, boundaries?: Boundaries, zoomLevelBoundaries?: ZoomLevelLimits, rotationBoundaries?: RotationLimits);
35
+ /**
36
+ * @description The boundaries of the camera in the world coordinate system.
37
+ *
38
+ * @category Camera
39
+ */
40
+ get boundaries(): Boundaries | undefined;
41
+ set boundaries(boundaries: Boundaries | undefined);
42
+ /**
43
+ * @description The width of the viewport. (The width of the canvas in css pixels)
44
+ *
45
+ * @category Camera
46
+ */
47
+ get viewPortWidth(): number;
48
+ set viewPortWidth(width: number);
49
+ /**
50
+ * @description The height of the viewport. (The height of the canvas in css pixels)
51
+ *
52
+ * @category Camera
53
+ */
54
+ get viewPortHeight(): number;
55
+ set viewPortHeight(height: number);
56
+ /**
57
+ * @description The position of the camera in the world coordinate system.
58
+ *
59
+ * @category Camera
60
+ */
61
+ get position(): Point;
62
+ /**
63
+ * @description This function is used to set the position of the camera.
64
+ * @param destination The destination point of the camera.
65
+ * @returns Whether the position is set successfully.
66
+ *
67
+ * @description This function has a guard that checks if the destination point is within the boundaries of the camera.
68
+ * If the destination point is not within the boundaries, the function will return false and the position will not be updated.
69
+ * If the destination point is within the boundaries, the function will return true and the position will be updated.
70
+ */
71
+ setPosition(destination: Point): boolean;
72
+ /**
73
+ * @description The zoom level of the camera.
74
+ *
75
+ * @category Camera
76
+ */
77
+ get zoomLevel(): number;
78
+ /**
79
+ * @description The boundaries of the zoom level of the camera.
80
+ *
81
+ * @category Camera
82
+ */
83
+ get zoomBoundaries(): ZoomLevelLimits | undefined;
84
+ set zoomBoundaries(zoomBoundaries: ZoomLevelLimits | undefined);
85
+ setMaxZoomLevel(maxZoomLevel: number): boolean;
86
+ setMinZoomLevel(minZoomLevel: number): boolean;
87
+ setZoomLevel(zoomLevel: number): boolean;
88
+ /**
89
+ * @description The rotation of the camera in the world coordinate system.
90
+ *
91
+ * @category Camera
92
+ */
93
+ get rotation(): number;
94
+ /**
95
+ * @description The boundaries of the rotation of the camera.
96
+ *
97
+ * @category Camera
98
+ */
99
+ get rotationBoundaries(): RotationLimits | undefined;
100
+ set rotationBoundaries(rotationBoundaries: RotationLimits | undefined);
101
+ /**
102
+ * @description The order of the transformation is as follows:
103
+ * 1. Scale (scale the context using the device pixel ratio)
104
+ * 2. Translation (move the origin of the context to the center of the canvas)
105
+ * 3. Rotation (rotate the context negatively the rotation of the camera)
106
+ * 4. Zoom (scale the context using the zoom level of the camera)
107
+ * 5. Translation (move the origin of the context to the position of the camera in the context coordinate system)
108
+ *
109
+ * @param devicePixelRatio The device pixel ratio of the canvas
110
+ * @param alignCoorindate Whether to align the coordinate system to the camera's position
111
+ * @returns The transformation matrix
112
+ */
113
+ getTransform(devicePixelRatio: number, alignCoorindate: boolean): TransformationMatrix;
114
+ /**
115
+ * @description This function is used to set the rotation of the camera.
116
+ * @param rotation The rotation of the camera in the world coordinate system.
117
+ * @returns Whether the rotation is set successfully.
118
+ */
119
+ setRotation(rotation: number): boolean;
120
+ /**
121
+ * @description The origin of the camera in the window coordinate system.
122
+ * @deprecated
123
+ *
124
+ * @param centerInWindow The center of the camera in the window coordinate system.
125
+ * @returns The origin of the camera in the window coordinate system.
126
+ */
127
+ getCameraOriginInWindow(centerInWindow: Point): Point;
128
+ /**
129
+ * @description Converts a point from the viewport coordinate system to the world coordinate system.
130
+ *
131
+ * @param point The point in the viewport coordinate system.
132
+ * @returns The point in the world coordinate system.
133
+ */
134
+ convertFromViewPort2WorldSpace(point: Point): Point;
135
+ /**
136
+ * @description Converts a point from the world coordinate system to the viewport coordinate system.
137
+ *
138
+ * @param point The point in the world coordinate system.
139
+ * @returns The point in the viewport coordinate system.
140
+ */
141
+ convertFromWorld2ViewPort(point: Point): Point;
142
+ /**
143
+ * @description Inverts a point from the world coordinate system to the viewport coordinate system.
144
+ *
145
+ * @param point The point in the world coordinate system.
146
+ * @returns The point in the viewport coordinate system.
147
+ */
148
+ invertFromWorldSpace2ViewPort(point: Point): Point;
149
+ setHorizontalBoundaries(min: number, max: number): void;
150
+ setVerticalBoundaries(min: number, max: number): void;
151
+ /**
152
+ * @description This function is used to subscribe to the camera events.
153
+ * @param eventName The name of the event to subscribe to.
154
+ * @param callback The callback function to be called when the event is triggered.
155
+ * @param options The options for the subscription.
156
+ * @returns The unsubscribe function.
157
+ */
158
+ on<K extends keyof CameraEventMap>(eventName: K, callback: (event: CameraEventMap[K], cameraState: CameraState) => void, options?: SubscriptionOptions): UnSubscribe;
159
+ getTRS(devicePixelRatio: number, alignCoordinateSystem: boolean): {
160
+ scale: {
161
+ x: number;
162
+ y: number;
163
+ };
164
+ rotation: number;
165
+ translation: {
166
+ x: number;
167
+ y: number;
168
+ };
169
+ };
170
+ }
@@ -0,0 +1,8 @@
1
+ export * from "./base";
2
+ export * from './utils';
3
+ export * from './default-camera';
4
+ export * from './interface';
5
+ export * from './update-publisher';
6
+ export * from './camera-rig';
7
+ export * from './camera-mux';
8
+ export { default as DefaultBoardCamera } from './default-camera';