@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.
- package/LICENSE.txt +19 -0
- package/board.tsbuildinfo +1 -0
- package/boardify/index.d.ts +192 -0
- package/camera/base.d.ts +189 -0
- package/camera/camera-mux/animation-and-lock/animation-and-lock.d.ts +50 -0
- package/camera/camera-mux/animation-and-lock/index.d.ts +4 -0
- package/camera/camera-mux/animation-and-lock/pan-control-state-machine.d.ts +137 -0
- package/camera/camera-mux/animation-and-lock/rotation-control-state-machine.d.ts +131 -0
- package/camera/camera-mux/animation-and-lock/zoom-control-state-machine.d.ts +143 -0
- package/camera/camera-mux/index.d.ts +3 -0
- package/camera/camera-mux/interface.d.ts +12 -0
- package/camera/camera-mux/relay.d.ts +27 -0
- package/camera/camera-rig/camera-rig.d.ts +207 -0
- package/camera/camera-rig/index.d.ts +5 -0
- package/camera/camera-rig/pan-handler.d.ts +113 -0
- package/camera/camera-rig/rotation-handler.d.ts +78 -0
- package/camera/camera-rig/update-batcher/index.d.ts +3 -0
- package/camera/camera-rig/update-batcher/position-update-batcher.d.ts +58 -0
- package/camera/camera-rig/update-batcher/rotation-update-batcher.d.ts +54 -0
- package/camera/camera-rig/update-batcher/zoom-udpate-batcher.d.ts +60 -0
- package/camera/camera-rig/zoom-handler.d.ts +77 -0
- package/camera/default-camera.d.ts +170 -0
- package/camera/index.d.ts +8 -0
- package/camera/interface.d.ts +59 -0
- package/camera/update-publisher.d.ts +172 -0
- package/camera/utils/coordinate-conversion.d.ts +75 -0
- package/camera/utils/index.d.ts +5 -0
- package/camera/utils/matrix.d.ts +114 -0
- package/camera/utils/position.d.ts +71 -0
- package/camera/utils/rotation.d.ts +64 -0
- package/camera/utils/zoom.d.ts +25 -0
- package/index.d.ts +5 -0
- package/index.js +2 -0
- package/index.js.map +1 -0
- package/input-interpretation/index.d.ts +3 -0
- package/input-interpretation/input-state-machine/index.d.ts +4 -0
- package/input-interpretation/input-state-machine/kmt-input-context.d.ts +130 -0
- package/input-interpretation/input-state-machine/kmt-input-state-machine.d.ts +194 -0
- package/input-interpretation/input-state-machine/touch-input-context.d.ts +44 -0
- package/input-interpretation/input-state-machine/touch-input-state-machine.d.ts +64 -0
- package/input-interpretation/raw-input-parser/index.d.ts +2 -0
- package/input-interpretation/raw-input-parser/vanilla-kmt-event-parser.d.ts +87 -0
- package/input-interpretation/raw-input-parser/vanilla-touch-event-parser.d.ts +55 -0
- package/input-interpretation/raw-input-publisher/index.d.ts +1 -0
- package/input-interpretation/raw-input-publisher/raw-input-publisher.d.ts +130 -0
- package/package.json +39 -0
- package/utils/canvas-position-dimension.d.ts +18 -0
- package/utils/coorindate-conversion.d.ts +5 -0
- package/utils/drawing-utils.d.ts +55 -0
- package/utils/drawing.d.ts +30 -0
- package/utils/handler-pipeline.d.ts +30 -0
- package/utils/index.d.ts +8 -0
- package/utils/observable.d.ts +9 -0
- package/utils/ruler.d.ts +1 -0
- package/utils/zoomlevel-adjustment.d.ts +28 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Point } from "@ue-too/math";
|
|
2
|
+
import { UnSubscribe } from "./update-publisher";
|
|
3
|
+
import { RotationLimits } from "./utils/rotation";
|
|
4
|
+
import { ZoomLevelLimits } from "./utils/zoom";
|
|
5
|
+
import { Boundaries } from "./utils/position";
|
|
6
|
+
import { CameraEventMap, CameraState } from "./update-publisher";
|
|
7
|
+
import { SubscriptionOptions } from "../utils/observable";
|
|
8
|
+
/**
|
|
9
|
+
* @description The interface for the observable board camera.
|
|
10
|
+
*
|
|
11
|
+
* @category Camera
|
|
12
|
+
*/
|
|
13
|
+
export interface ObservableBoardCamera extends BoardCamera {
|
|
14
|
+
on<K extends keyof CameraEventMap>(eventName: K, callback: (event: CameraEventMap[K], cameraState: CameraState) => void, options?: SubscriptionOptions): UnSubscribe;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @description The interface for the board camera.
|
|
18
|
+
*
|
|
19
|
+
* @category Camera
|
|
20
|
+
*/
|
|
21
|
+
export interface BoardCamera {
|
|
22
|
+
position: Point;
|
|
23
|
+
rotation: number;
|
|
24
|
+
zoomLevel: number;
|
|
25
|
+
viewPortWidth: number;
|
|
26
|
+
viewPortHeight: number;
|
|
27
|
+
boundaries?: Boundaries;
|
|
28
|
+
zoomBoundaries?: ZoomLevelLimits;
|
|
29
|
+
rotationBoundaries?: RotationLimits;
|
|
30
|
+
setPosition(destination: Point): boolean;
|
|
31
|
+
setZoomLevel(zoomLevel: number): boolean;
|
|
32
|
+
setRotation(rotation: number): boolean;
|
|
33
|
+
setMinZoomLevel(minZoomLevel: number): void;
|
|
34
|
+
setMaxZoomLevel(maxZoomLevel: number): void;
|
|
35
|
+
setHorizontalBoundaries(min: number, max: number): void;
|
|
36
|
+
setVerticalBoundaries(min: number, max: number): void;
|
|
37
|
+
getCameraOriginInWindow(centerInWindow: Point): Point;
|
|
38
|
+
convertFromViewPort2WorldSpace(point: Point): Point;
|
|
39
|
+
convertFromWorld2ViewPort(point: Point): Point;
|
|
40
|
+
getTRS(devicePixelRatio: number, alignCoordinateSystem: boolean): {
|
|
41
|
+
scale: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
rotation: number;
|
|
46
|
+
translation: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
getTransform(devicePixelRatio: number, alignCoordinateSystem: boolean): {
|
|
52
|
+
a: number;
|
|
53
|
+
b: number;
|
|
54
|
+
c: number;
|
|
55
|
+
d: number;
|
|
56
|
+
e: number;
|
|
57
|
+
f: number;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Point } from "@ue-too/math";
|
|
2
|
+
import { SubscriptionOptions } from "../utils/observable";
|
|
3
|
+
/**
|
|
4
|
+
* @description The payload for the pan event.
|
|
5
|
+
*
|
|
6
|
+
* @category Camera
|
|
7
|
+
*/
|
|
8
|
+
export type CameraPanEventPayload = {
|
|
9
|
+
diff: Point;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* @description The payload for the zoom event.
|
|
13
|
+
*
|
|
14
|
+
* @category Camera
|
|
15
|
+
*/
|
|
16
|
+
export type CameraZoomEventPayload = {
|
|
17
|
+
deltaZoomAmount: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @description The payload for the rotate event.
|
|
21
|
+
*
|
|
22
|
+
* @category Camera
|
|
23
|
+
*/
|
|
24
|
+
export type CameraRotateEventPayload = {
|
|
25
|
+
deltaRotation: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @description The mapping of the camera events.
|
|
29
|
+
* This is primarily used for type inference.
|
|
30
|
+
*
|
|
31
|
+
* @category Camera
|
|
32
|
+
*/
|
|
33
|
+
export type CameraEventMap = {
|
|
34
|
+
"pan": CameraPanEventPayload;
|
|
35
|
+
"zoom": CameraZoomEventPayload;
|
|
36
|
+
"rotate": CameraRotateEventPayload;
|
|
37
|
+
"all": AllCameraEventPayload;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* @description The type of the camera rotate event.
|
|
41
|
+
* The type is for discriminating the event type when the all event is triggered.
|
|
42
|
+
*
|
|
43
|
+
* @category Camera
|
|
44
|
+
*/
|
|
45
|
+
export type CameraRotateEvent = {
|
|
46
|
+
type: "rotate";
|
|
47
|
+
} & CameraRotateEventPayload;
|
|
48
|
+
/**
|
|
49
|
+
* @description The type of the camera pan event.
|
|
50
|
+
* The type is for discriminating the event type when the all event is triggered.
|
|
51
|
+
*
|
|
52
|
+
* @category Camera
|
|
53
|
+
*/
|
|
54
|
+
export type CameraPanEvent = {
|
|
55
|
+
type: "pan";
|
|
56
|
+
} & CameraPanEventPayload;
|
|
57
|
+
/**
|
|
58
|
+
* @description The type of the camera zoom event.
|
|
59
|
+
* The type is for discriminating the event type when the all event is triggered.
|
|
60
|
+
*
|
|
61
|
+
* @category Camera
|
|
62
|
+
*/
|
|
63
|
+
export type CameraZoomEvent = {
|
|
64
|
+
type: "zoom";
|
|
65
|
+
} & CameraZoomEventPayload;
|
|
66
|
+
/**
|
|
67
|
+
* @description The type of the camera state.
|
|
68
|
+
*
|
|
69
|
+
* @category Camera
|
|
70
|
+
*/
|
|
71
|
+
export type CameraState = {
|
|
72
|
+
position: Point;
|
|
73
|
+
zoomLevel: number;
|
|
74
|
+
rotation: number;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* @description The payload type of the "all" camera event payload.
|
|
78
|
+
*
|
|
79
|
+
* @category Camera
|
|
80
|
+
*/
|
|
81
|
+
export type AllCameraEventPayload = CameraRotateEvent | CameraPanEvent | CameraZoomEvent;
|
|
82
|
+
/**
|
|
83
|
+
* @description The callback function type for the camera event.
|
|
84
|
+
*
|
|
85
|
+
* @category Camera
|
|
86
|
+
*/
|
|
87
|
+
export type Callback<K extends keyof CameraEventMap> = (event: CameraEventMap[K], cameraState: CameraState) => void;
|
|
88
|
+
/**
|
|
89
|
+
* @description The callback function type for the "all" camera event.
|
|
90
|
+
*
|
|
91
|
+
* @category Camera
|
|
92
|
+
*/
|
|
93
|
+
export type ConslidateCallback = (payload: AllCameraEventPayload, cameraState: CameraState) => void;
|
|
94
|
+
/**
|
|
95
|
+
* @description The type of the unsubscribe function.
|
|
96
|
+
*
|
|
97
|
+
* @category Camera
|
|
98
|
+
*/
|
|
99
|
+
export type UnSubscribe = () => void;
|
|
100
|
+
/**
|
|
101
|
+
* @description The observer type for the pan event.
|
|
102
|
+
*
|
|
103
|
+
* @category Camera
|
|
104
|
+
*/
|
|
105
|
+
export type PanObserver = Callback<"pan">;
|
|
106
|
+
/**
|
|
107
|
+
* @description The observer type for the zoom event.
|
|
108
|
+
*
|
|
109
|
+
* @category Camera
|
|
110
|
+
*/
|
|
111
|
+
export type ZoomObserver = Callback<"zoom">;
|
|
112
|
+
/**
|
|
113
|
+
* @description The observer type for the rotate event.
|
|
114
|
+
*
|
|
115
|
+
* @category Camera
|
|
116
|
+
*/
|
|
117
|
+
export type RotateObserver = Callback<"rotate">;
|
|
118
|
+
/**
|
|
119
|
+
* @description The observer type for the "all" camera event.
|
|
120
|
+
*
|
|
121
|
+
* @category Camera
|
|
122
|
+
*/
|
|
123
|
+
export type AllObserver = Callback<"all">;
|
|
124
|
+
/**
|
|
125
|
+
* @description The camera update publisher.
|
|
126
|
+
*
|
|
127
|
+
* @category Camera
|
|
128
|
+
*/
|
|
129
|
+
export declare class CameraUpdatePublisher {
|
|
130
|
+
private pan;
|
|
131
|
+
private zoom;
|
|
132
|
+
private rotate;
|
|
133
|
+
private all;
|
|
134
|
+
constructor();
|
|
135
|
+
/**
|
|
136
|
+
* @description Notify the pan event.
|
|
137
|
+
* Will also notify the "all" event.
|
|
138
|
+
*
|
|
139
|
+
* @category Camera
|
|
140
|
+
*/
|
|
141
|
+
notifyPan(event: CameraEventMap["pan"], cameraState: CameraState): void;
|
|
142
|
+
/**
|
|
143
|
+
* @description Notify the zoom event.
|
|
144
|
+
* Will also notify the "all" event.
|
|
145
|
+
*
|
|
146
|
+
* @category Camera
|
|
147
|
+
*/
|
|
148
|
+
notifyZoom(event: CameraEventMap["zoom"], cameraState: CameraState): void;
|
|
149
|
+
/**
|
|
150
|
+
* @description Notify the rotate event.
|
|
151
|
+
* Will also notify the "all" event.
|
|
152
|
+
*
|
|
153
|
+
* @category Camera
|
|
154
|
+
*/
|
|
155
|
+
notifyRotate(event: CameraEventMap["rotate"], cameraState: CameraState): void;
|
|
156
|
+
/**
|
|
157
|
+
* @description Subscribe to the camera event.
|
|
158
|
+
* You can also pass in the abort controller signal within the options to cancel the subscription. Like this:
|
|
159
|
+
* ```ts
|
|
160
|
+
* const controller = new AbortController();
|
|
161
|
+
* const unSubscribe = on("pan", (event, cameraState)=>{}, {signal: controller.signal});
|
|
162
|
+
*
|
|
163
|
+
* // later in other place where you want to unsubscribe
|
|
164
|
+
* controller.abort();
|
|
165
|
+
*
|
|
166
|
+
* ```
|
|
167
|
+
* This means you can cancel multiple subscriptions by aborting the same controller. Just like regular event listeners.
|
|
168
|
+
*
|
|
169
|
+
* @category Camera
|
|
170
|
+
*/
|
|
171
|
+
on<K extends keyof CameraEventMap>(eventName: K, callback: (event: CameraEventMap[K], cameraState: CameraState) => void, options?: SubscriptionOptions): UnSubscribe;
|
|
172
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Point } from "@ue-too/math";
|
|
2
|
+
import { TransformationMatrix } from "./matrix";
|
|
3
|
+
/**
|
|
4
|
+
* @description Finds the world space coordinate of the interest point if the camera is at target position.
|
|
5
|
+
* The target position is the "would be" position of the camera in world space.
|
|
6
|
+
* The interest point is the point in view port space where the "bottom left" corner is the origin.
|
|
7
|
+
*
|
|
8
|
+
* @category Camera
|
|
9
|
+
*/
|
|
10
|
+
export declare function convert2WorldSpaceWRT(targetPosition: Point, interestPoint: Point, viewPortWidth: number, viewPortHeight: number, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
11
|
+
/**
|
|
12
|
+
* @description Converts the point to world space.
|
|
13
|
+
* The point is in the viewport space where the "bottom left" corner is the origin.
|
|
14
|
+
* Camera position is the position of the camera in world space.
|
|
15
|
+
*
|
|
16
|
+
* @category Camera
|
|
17
|
+
*/
|
|
18
|
+
export declare function convert2WorldSpace(point: Point, viewPortWidth: number, viewPortHeight: number, cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
19
|
+
/**
|
|
20
|
+
* @description Converts the point to world space.
|
|
21
|
+
* The point is in the viewport space where the origin is at the center of the viewport.
|
|
22
|
+
* Camera position is the position of the camera in world space.
|
|
23
|
+
*
|
|
24
|
+
* @category Camera
|
|
25
|
+
*/
|
|
26
|
+
export declare function convert2WorldSpaceAnchorAtCenter(point: Point, cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
27
|
+
/**
|
|
28
|
+
* @description Converts a point in "stage/context/world" space to view port space.
|
|
29
|
+
* The origin of the viewport is at the center of the viewport.
|
|
30
|
+
* The point is in world space.
|
|
31
|
+
* The camera position is the position of the camera in world space.
|
|
32
|
+
*
|
|
33
|
+
* @category Camera
|
|
34
|
+
*/
|
|
35
|
+
export declare function convert2ViewPortSpaceAnchorAtCenter(point: Point, cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
36
|
+
/**
|
|
37
|
+
* @description Converts a point in "stage/context/world" space to view port space.
|
|
38
|
+
* The origin of the view port is at the bottom left corner.
|
|
39
|
+
* The point is in world space.
|
|
40
|
+
* The camera position is the position of the camera in world space.
|
|
41
|
+
*
|
|
42
|
+
* @category Camera
|
|
43
|
+
*/
|
|
44
|
+
export declare function invertFromWorldSpace(point: Point, viewPortWidth: number, viewPortHeight: number, cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
45
|
+
/**
|
|
46
|
+
* @description Checks if a point is in the view port.
|
|
47
|
+
* The point is in world space.
|
|
48
|
+
* The camera position is the position of the camera in world space.
|
|
49
|
+
*
|
|
50
|
+
* @category Camera
|
|
51
|
+
*/
|
|
52
|
+
export declare function pointIsInViewPort(point: Point, viewPortWidth: number, viewPortHeight: number, cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* @description Converts a delta in view port space to world space.
|
|
55
|
+
* The delta is in view port space.
|
|
56
|
+
*
|
|
57
|
+
* @category Camera
|
|
58
|
+
*/
|
|
59
|
+
export declare function convertDeltaInViewPortToWorldSpace(delta: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
60
|
+
/**
|
|
61
|
+
* @description Converts a delta in world space to view port space.
|
|
62
|
+
* The delta is in world space.
|
|
63
|
+
*
|
|
64
|
+
* @category Camera
|
|
65
|
+
*/
|
|
66
|
+
export declare function convertDeltaInWorldToViewPortSpace(delta: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
67
|
+
/**
|
|
68
|
+
* @description Calculates the camera position to get a point in "stage/context/world" space to be at a certain point in view port space.
|
|
69
|
+
* This is useful to coordinate camera pan and zoom at the same time.
|
|
70
|
+
*
|
|
71
|
+
* @category Camera
|
|
72
|
+
*/
|
|
73
|
+
export declare function cameraPositionToGet(pointInWorld: Point, toPointInViewPort: Point, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
74
|
+
export declare function transformationMatrixFromCamera(cameraPosition: Point, cameraZoomLevel: number, cameraRotation: number): TransformationMatrix;
|
|
75
|
+
export declare function convert2WorldSpaceWithTransformationMatrix(point: Point, transformationMatrix: TransformationMatrix): Point;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description The transform matrix for the camera.
|
|
3
|
+
* It's in the format like this:
|
|
4
|
+
* ```
|
|
5
|
+
* | a c e |
|
|
6
|
+
* | b d f |
|
|
7
|
+
* | 0 0 1 |
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @category Camera
|
|
11
|
+
*/
|
|
12
|
+
export type TransformationMatrix = {
|
|
13
|
+
a: number;
|
|
14
|
+
b: number;
|
|
15
|
+
c: number;
|
|
16
|
+
d: number;
|
|
17
|
+
e: number;
|
|
18
|
+
f: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Decomposes a camera transformation matrix back to camera parameters
|
|
22
|
+
*
|
|
23
|
+
* Transformation order:
|
|
24
|
+
* 1. Scale by device pixel ratio
|
|
25
|
+
* 2. Translate to canvas center
|
|
26
|
+
* 3. Rotate by -camera.rotation
|
|
27
|
+
* 4. Scale by zoom level
|
|
28
|
+
* 5. Translate by -camera.position
|
|
29
|
+
*
|
|
30
|
+
* Final matrix: M = S1 * T1 * R * S2 * T2
|
|
31
|
+
*/
|
|
32
|
+
export declare function decomposeCameraMatrix(transformMatrix: TransformationMatrix, devicePixelRatio: number, canvasWidth: number, canvasHeight: number): {
|
|
33
|
+
position: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
37
|
+
zoom: number;
|
|
38
|
+
rotation: number;
|
|
39
|
+
};
|
|
40
|
+
export declare function createCameraMatrix(cameraPos: {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
}, zoom: number, rotation: number, devicePixelRatio: number, canvasWidth: number, canvasHeight: number): {
|
|
44
|
+
a: number;
|
|
45
|
+
b: number;
|
|
46
|
+
c: number;
|
|
47
|
+
d: number;
|
|
48
|
+
e: number;
|
|
49
|
+
f: number;
|
|
50
|
+
};
|
|
51
|
+
export declare function multiplyMatrix(m1: TransformationMatrix, m2: TransformationMatrix): {
|
|
52
|
+
a: number;
|
|
53
|
+
b: number;
|
|
54
|
+
c: number;
|
|
55
|
+
d: number;
|
|
56
|
+
e: number;
|
|
57
|
+
f: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Decomposes a 2D transformation matrix into Translation, Rotation, and Scale (TRS)
|
|
61
|
+
*
|
|
62
|
+
* @param matrix - The transformation matrix to decompose
|
|
63
|
+
* @returns Object containing translation, rotation (in radians), and scale components
|
|
64
|
+
*
|
|
65
|
+
* @category Matrix
|
|
66
|
+
*/
|
|
67
|
+
export declare function decomposeTRS(matrix: TransformationMatrix): {
|
|
68
|
+
translation: {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
};
|
|
72
|
+
rotation: number;
|
|
73
|
+
scale: {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Creates a transformation matrix from TRS components
|
|
80
|
+
*
|
|
81
|
+
* @param translation - Translation vector
|
|
82
|
+
* @param rotation - Rotation in radians
|
|
83
|
+
* @param scale - Scale vector
|
|
84
|
+
* @returns Transformation matrix
|
|
85
|
+
*
|
|
86
|
+
* @category Matrix
|
|
87
|
+
*/
|
|
88
|
+
export declare function createTRSMatrix(translation: {
|
|
89
|
+
x: number;
|
|
90
|
+
y: number;
|
|
91
|
+
}, rotation: number, scale: {
|
|
92
|
+
x: number;
|
|
93
|
+
y: number;
|
|
94
|
+
}): TransformationMatrix;
|
|
95
|
+
/**
|
|
96
|
+
* Decomposes a matrix using SVD (Singular Value Decomposition) approach
|
|
97
|
+
* This is an alternative method that can handle more complex transformations
|
|
98
|
+
*
|
|
99
|
+
* @param matrix - The transformation matrix to decompose
|
|
100
|
+
* @returns Object containing translation, rotation, and scale components
|
|
101
|
+
*
|
|
102
|
+
* @category Matrix
|
|
103
|
+
*/
|
|
104
|
+
export declare function decomposeTRSSVD(matrix: TransformationMatrix): {
|
|
105
|
+
translation: {
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
};
|
|
109
|
+
rotation: number;
|
|
110
|
+
scale: {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Point } from "@ue-too/math";
|
|
2
|
+
/**
|
|
3
|
+
* @description The boundaries of a camera.
|
|
4
|
+
* The x and y are in world space.
|
|
5
|
+
*
|
|
6
|
+
* @category Camera
|
|
7
|
+
*/
|
|
8
|
+
export type Boundaries = {
|
|
9
|
+
min?: {
|
|
10
|
+
x?: number;
|
|
11
|
+
y?: number;
|
|
12
|
+
};
|
|
13
|
+
max?: {
|
|
14
|
+
x?: number;
|
|
15
|
+
y?: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @description Checks if a point is within the boundaries.
|
|
20
|
+
*
|
|
21
|
+
* @category Camera
|
|
22
|
+
*/
|
|
23
|
+
export declare function withinBoundaries(point: Point, boundaries: Boundaries | undefined): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* @description Checks if the boundaries are valid.
|
|
26
|
+
*
|
|
27
|
+
* @category Camera
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidBoundaries(boundaries: Boundaries | undefined): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @description Checks if the boundaries are fully defined.
|
|
32
|
+
*
|
|
33
|
+
* @category Camera
|
|
34
|
+
*/
|
|
35
|
+
export declare function boundariesFullyDefined(boundaries: Boundaries | undefined): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @description Clamps a point to the boundaries.
|
|
38
|
+
*
|
|
39
|
+
* @category Camera
|
|
40
|
+
*/
|
|
41
|
+
export declare function clampPoint(point: Point, boundaries: Boundaries | undefined): Point;
|
|
42
|
+
/**
|
|
43
|
+
* @description Gets the translation width of the boundaries.
|
|
44
|
+
*
|
|
45
|
+
* @category Camera
|
|
46
|
+
*/
|
|
47
|
+
export declare function translationWidthOf(boundaries: Boundaries | undefined): number | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* @description Gets the half translation width of the boundaries.
|
|
50
|
+
*
|
|
51
|
+
* @category Camera
|
|
52
|
+
*/
|
|
53
|
+
export declare function halfTranslationWidthOf(boundaries: Boundaries): number | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* @description Gets the translation height of the boundaries.
|
|
56
|
+
*
|
|
57
|
+
* @category Camera
|
|
58
|
+
*/
|
|
59
|
+
export declare function translationHeightOf(boundaries: Boundaries | undefined): number | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* @description Gets the half translation height of the boundaries.
|
|
62
|
+
*
|
|
63
|
+
* @category Camera
|
|
64
|
+
*/
|
|
65
|
+
export declare function halfTranslationHeightOf(boundaries: Boundaries): number | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* @description Clamps the entire viewport within the boundaries
|
|
68
|
+
*
|
|
69
|
+
* @category Camera
|
|
70
|
+
*/
|
|
71
|
+
export declare function clampPointEntireViewPort(point: Point, viewPortWidth: number, viewPortHeight: number, boundaries: Boundaries | undefined, cameraZoomLevel: number, cameraRotation: number): Point;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description The limits of the rotation.
|
|
3
|
+
*
|
|
4
|
+
* @category Camera
|
|
5
|
+
*/
|
|
6
|
+
export type RotationLimits = {
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
ccw: boolean;
|
|
10
|
+
startAsTieBreaker: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @description The boundary of the rotation. (experimental)
|
|
14
|
+
*
|
|
15
|
+
* @category Camera
|
|
16
|
+
*/
|
|
17
|
+
export type RotationBoundary = {
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
positiveDirection: boolean;
|
|
21
|
+
startAsTieBreaker: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @description Clamps the rotation within the limits.
|
|
25
|
+
*
|
|
26
|
+
* @category Camera
|
|
27
|
+
*/
|
|
28
|
+
export declare function clampRotation(rotation: number, rotationLimits?: RotationLimits): number;
|
|
29
|
+
/**
|
|
30
|
+
* @description Checks if the rotation is within the limits.
|
|
31
|
+
*
|
|
32
|
+
* @category Camera
|
|
33
|
+
*/
|
|
34
|
+
export declare function rotationWithinLimits(rotation: number, rotationLimits?: RotationLimits): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @description Checks if the rotation is within the boundary. (experimental)
|
|
37
|
+
*
|
|
38
|
+
* @category Camera
|
|
39
|
+
*/
|
|
40
|
+
export declare function rotationWithinBoundary(rotation: number, rotationBoundary: RotationBoundary): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @description Normalizes the angle to be between 0 and 2π.
|
|
43
|
+
*
|
|
44
|
+
* @category Camera
|
|
45
|
+
*/
|
|
46
|
+
export declare function normalizeAngleZero2TwoPI(angle: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* @description Gets the smaller angle span between two angles. (in radians)
|
|
49
|
+
*
|
|
50
|
+
* @category Camera
|
|
51
|
+
*/
|
|
52
|
+
export declare function angleSpan(from: number, to: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* @description Converts degrees to radians.
|
|
55
|
+
*
|
|
56
|
+
* @category Camera
|
|
57
|
+
*/
|
|
58
|
+
export declare function deg2rad(deg: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* @description Converts radians to degrees.
|
|
61
|
+
*
|
|
62
|
+
* @category Camera
|
|
63
|
+
*/
|
|
64
|
+
export declare function rad2deg(rad: number): number;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description The limits of the zoom level.
|
|
3
|
+
*
|
|
4
|
+
* @category Camera
|
|
5
|
+
*/
|
|
6
|
+
export type ZoomLevelLimits = {
|
|
7
|
+
min?: number;
|
|
8
|
+
max?: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @description Checks if the zoom level limits are valid.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isValidZoomLevelLimits(zoomLevelLimits: ZoomLevelLimits | undefined): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @description Clamps the zoom level within the limits.
|
|
16
|
+
*
|
|
17
|
+
* @category Camera
|
|
18
|
+
*/
|
|
19
|
+
export declare function clampZoomLevel(zoomLevel: number, zoomLevelLimits?: ZoomLevelLimits): number;
|
|
20
|
+
/**
|
|
21
|
+
* @description Checks if the zoom level is within the limits.
|
|
22
|
+
*
|
|
23
|
+
* @category Camera
|
|
24
|
+
*/
|
|
25
|
+
export declare function zoomLevelWithinLimits(zoomLevel: number, zoomLevelLimits?: ZoomLevelLimits): boolean;
|