@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,130 @@
|
|
|
1
|
+
import { Point } from "@ue-too/math";
|
|
2
|
+
import { BaseContext } from "@ue-too/being";
|
|
3
|
+
import { UserInputPublisher } from "../raw-input-publisher";
|
|
4
|
+
import { CanvasPositionDimensionPublisher } from "../../utils";
|
|
5
|
+
export declare enum CursorStyle {
|
|
6
|
+
GRAB = "grab",
|
|
7
|
+
DEFAULT = "default",
|
|
8
|
+
GRABBING = "grabbing"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @description A proxy for the canvas so that client code that needs to access
|
|
12
|
+
* the canvas dimensions and position does not need to access the DOM directly.
|
|
13
|
+
*/
|
|
14
|
+
export interface CanvasOperator {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
position: Point;
|
|
18
|
+
setCursor: (style: CursorStyle) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @description A dummy implementation of the CanvasOperator interface.
|
|
22
|
+
* This is specifically for the case where a input state machine that is for the relay of the input events to the web worker.
|
|
23
|
+
* The input state machine needs a canvas operator in its context, but this context does not have any functionality.
|
|
24
|
+
* @see DummyKmtInputContext
|
|
25
|
+
*/
|
|
26
|
+
export declare class DummyCanvasOperator implements CanvasOperator {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
position: Point;
|
|
30
|
+
setCursor: (style: CursorStyle) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare class CanvasCacheInWebWorker implements CanvasOperator {
|
|
33
|
+
private _width;
|
|
34
|
+
private _height;
|
|
35
|
+
private _position;
|
|
36
|
+
private _postMessageFunction;
|
|
37
|
+
constructor(postMessageFunction: typeof postMessage);
|
|
38
|
+
set width(width: number);
|
|
39
|
+
set height(height: number);
|
|
40
|
+
set position(position: Point);
|
|
41
|
+
get width(): number;
|
|
42
|
+
get height(): number;
|
|
43
|
+
get position(): Point;
|
|
44
|
+
setCursor(style: "grab" | "default" | "grabbing"): void;
|
|
45
|
+
}
|
|
46
|
+
export declare class CanvasProxy implements CanvasOperator {
|
|
47
|
+
private _width;
|
|
48
|
+
private _height;
|
|
49
|
+
private _position;
|
|
50
|
+
private _canvasPositionDimensionPublisher;
|
|
51
|
+
private _canvas;
|
|
52
|
+
constructor(canvas: HTMLCanvasElement, canvasPositionDimensionPublisher?: CanvasPositionDimensionPublisher);
|
|
53
|
+
get width(): number;
|
|
54
|
+
get height(): number;
|
|
55
|
+
get position(): Point;
|
|
56
|
+
setCursor(style: "grab" | "default" | "grabbing"): void;
|
|
57
|
+
attach(canvas: HTMLCanvasElement): void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @description A proxy for the canvas that is used to communicate with the web worker.
|
|
61
|
+
* The primary purpose of this class is to cache the canvas dimensions and position in the DOM to reduce the calling of the getBoundingClientRect method.
|
|
62
|
+
* This class only serves as a relay of the updated canvas dimensions and position to the web worker.
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
export declare class CanvasProxyWorkerRelay implements CanvasOperator {
|
|
66
|
+
private _width;
|
|
67
|
+
private _height;
|
|
68
|
+
private _position;
|
|
69
|
+
private _webWorker;
|
|
70
|
+
private _canvas;
|
|
71
|
+
constructor(canvas: HTMLCanvasElement, webWorker: Worker, canvasDiemsionPublisher: CanvasPositionDimensionPublisher);
|
|
72
|
+
get width(): number;
|
|
73
|
+
get height(): number;
|
|
74
|
+
get position(): Point;
|
|
75
|
+
setCursor(style: "grab" | "default" | "grabbing"): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @description The context for the keyboard mouse and trackpad input state machine.
|
|
79
|
+
*
|
|
80
|
+
* @category Input State Machine
|
|
81
|
+
*/
|
|
82
|
+
export interface KmtInputContext extends BaseContext {
|
|
83
|
+
alignCoordinateSystem: boolean;
|
|
84
|
+
canvas: CanvasOperator;
|
|
85
|
+
notifyOnPan: (delta: Point) => void;
|
|
86
|
+
notifyOnZoom: (zoomAmount: number, anchorPoint: Point) => void;
|
|
87
|
+
notifyOnRotate: (deltaRotation: number) => void;
|
|
88
|
+
setInitialCursorPosition: (position: Point) => void;
|
|
89
|
+
initialCursorPosition: Point;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @description A dummy implementation of the KmtInputContext interface.
|
|
93
|
+
* This is specifically for the case where a input state machine that is for the relay of the input events to the web worker.
|
|
94
|
+
* The input state machine needs a context, but this context does not have any functionality.
|
|
95
|
+
*/
|
|
96
|
+
export declare class DummyKmtInputContext implements KmtInputContext {
|
|
97
|
+
alignCoordinateSystem: boolean;
|
|
98
|
+
canvas: CanvasOperator;
|
|
99
|
+
initialCursorPosition: Point;
|
|
100
|
+
constructor();
|
|
101
|
+
notifyOnPan(delta: Point): void;
|
|
102
|
+
notifyOnZoom(zoomAmount: number, anchorPoint: Point): void;
|
|
103
|
+
notifyOnRotate(deltaRotation: number): void;
|
|
104
|
+
setInitialCursorPosition(position: Point): void;
|
|
105
|
+
cleanup(): void;
|
|
106
|
+
setup(): void;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @description The observable input tracker.
|
|
110
|
+
* This is used as the context for the keyboard mouse and trackpad input state machine.
|
|
111
|
+
*
|
|
112
|
+
* @category Input State Machine
|
|
113
|
+
*/
|
|
114
|
+
export declare class ObservableInputTracker implements KmtInputContext {
|
|
115
|
+
private _alignCoordinateSystem;
|
|
116
|
+
private _canvasOperator;
|
|
117
|
+
private _inputPublisher;
|
|
118
|
+
private _initialCursorPosition;
|
|
119
|
+
constructor(canvasOperator: CanvasOperator, inputPublisher: UserInputPublisher);
|
|
120
|
+
get alignCoordinateSystem(): boolean;
|
|
121
|
+
get canvas(): CanvasOperator;
|
|
122
|
+
get initialCursorPosition(): Point;
|
|
123
|
+
set alignCoordinateSystem(value: boolean);
|
|
124
|
+
notifyOnPan(delta: Point): void;
|
|
125
|
+
notifyOnZoom(zoomAmount: number, anchorPoint: Point): void;
|
|
126
|
+
notifyOnRotate(deltaRotation: number): void;
|
|
127
|
+
setInitialCursorPosition(position: Point): void;
|
|
128
|
+
cleanup(): void;
|
|
129
|
+
setup(): void;
|
|
130
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { EventReactions, EventGuards, Guard, TemplateState, TemplateStateMachine } from "@ue-too/being";
|
|
2
|
+
import type { Point } from "@ue-too/math";
|
|
3
|
+
import { CanvasOperator, KmtInputContext } from "./kmt-input-context";
|
|
4
|
+
/**
|
|
5
|
+
* @description The possible states of the keyboard mouse and trackpad input state machine.
|
|
6
|
+
*
|
|
7
|
+
* @category Input State Machine
|
|
8
|
+
*/
|
|
9
|
+
export type KmtInputStates = "IDLE" | "READY_TO_PAN_VIA_SPACEBAR" | "READY_TO_PAN_VIA_SCROLL_WHEEL" | "PAN" | "INITIAL_PAN" | "PAN_VIA_SCROLL_WHEEL";
|
|
10
|
+
/**
|
|
11
|
+
* @description The payload for the pointer event.
|
|
12
|
+
*
|
|
13
|
+
* @category Input State Machine
|
|
14
|
+
*/
|
|
15
|
+
export type PointerEventPayload = {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
type EmptyPayload = {};
|
|
20
|
+
/**
|
|
21
|
+
* @description The payload for the scroll event.
|
|
22
|
+
*
|
|
23
|
+
* @category Input State Machine
|
|
24
|
+
*/
|
|
25
|
+
export type ScrollEventPayload = {
|
|
26
|
+
deltaX: number;
|
|
27
|
+
deltaY: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @description The payload for the scroll with ctrl event.
|
|
31
|
+
*
|
|
32
|
+
* @category Input State Machine
|
|
33
|
+
*/
|
|
34
|
+
export type ScrollWithCtrlEventPayload = {
|
|
35
|
+
deltaX: number;
|
|
36
|
+
deltaY: number;
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* @description The payload mapping for the events of the keyboard mouse and trackpad input state machine.
|
|
42
|
+
*
|
|
43
|
+
* @category Input State Machine
|
|
44
|
+
*/
|
|
45
|
+
export type KmtInputEventMapping = {
|
|
46
|
+
leftPointerDown: PointerEventPayload;
|
|
47
|
+
leftPointerUp: PointerEventPayload;
|
|
48
|
+
leftPointerMove: PointerEventPayload;
|
|
49
|
+
spacebarDown: EmptyPayload;
|
|
50
|
+
spacebarUp: EmptyPayload;
|
|
51
|
+
stayIdle: EmptyPayload;
|
|
52
|
+
cursorOnElement: EmptyPayload;
|
|
53
|
+
scroll: ScrollEventPayload;
|
|
54
|
+
scrollWithCtrl: ScrollWithCtrlEventPayload;
|
|
55
|
+
middlePointerDown: PointerEventPayload;
|
|
56
|
+
middlePointerUp: PointerEventPayload;
|
|
57
|
+
middlePointerMove: PointerEventPayload;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* @description Converts the point from window coordinates(browser) to view port coordinates.
|
|
61
|
+
*
|
|
62
|
+
* @category Input State Machine
|
|
63
|
+
*/
|
|
64
|
+
export declare function convertFromWindow2ViewPort(point: Point, canvas: HTMLCanvasElement): Point;
|
|
65
|
+
export declare function convertFromWindow2ViewPortWithCanvasOperator(point: Point, canvasOperator: CanvasOperator): Point;
|
|
66
|
+
export declare function convertFromWindow2ViewPortCanvasOperator(point: Point, canvasOperator: CanvasOperator): Point;
|
|
67
|
+
/**
|
|
68
|
+
* @description The possible target states of the idle state.
|
|
69
|
+
*
|
|
70
|
+
* @category Input State Machine
|
|
71
|
+
*/
|
|
72
|
+
export type KmtIdleStatePossibleTargetStates = "IDLE" | "READY_TO_PAN_VIA_SPACEBAR" | "READY_TO_PAN_VIA_SCROLL_WHEEL";
|
|
73
|
+
/**
|
|
74
|
+
* @description The idle state of the keyboard mouse and trackpad input state machine.
|
|
75
|
+
*
|
|
76
|
+
* @category Input State Machine
|
|
77
|
+
*/
|
|
78
|
+
export declare class KmtIdleState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates> {
|
|
79
|
+
constructor();
|
|
80
|
+
protected _guards: Guard<KmtInputContext, "isIdle">;
|
|
81
|
+
protected _eventGuards: Partial<EventGuards<KmtInputEventMapping, KmtInputStates, KmtInputContext, Guard<KmtInputContext>>>;
|
|
82
|
+
get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
83
|
+
protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
84
|
+
scrollHandler(context: KmtInputContext, payload: ScrollEventPayload): void;
|
|
85
|
+
scrollWithCtrlHandler(context: KmtInputContext, payload: ScrollWithCtrlEventPayload): void;
|
|
86
|
+
spacebarDownHandler(context: KmtInputContext, payload: EmptyPayload): void;
|
|
87
|
+
middlePointerDownHandler(context: KmtInputContext, payload: PointerEventPayload): void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @description The possible target states of the ready to select state.
|
|
91
|
+
*
|
|
92
|
+
* @category Input State Machine
|
|
93
|
+
*/
|
|
94
|
+
export type ReadyToSelectStatePossibleTargetStates = "IDLE" | "SELECTING";
|
|
95
|
+
/**
|
|
96
|
+
* @description The context for the ready to select state.
|
|
97
|
+
*
|
|
98
|
+
* @category Input State Machine
|
|
99
|
+
*/
|
|
100
|
+
export type SelectionContext = {
|
|
101
|
+
setSelectionEndPoint: (point: Point) => void;
|
|
102
|
+
toggleSelectionBox: (show: boolean) => void;
|
|
103
|
+
cleanup: () => void;
|
|
104
|
+
setup: () => void;
|
|
105
|
+
canvas: HTMLCanvasElement;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* @description The ready to select state of the keyboard mouse and trackpad input state machine.
|
|
109
|
+
*
|
|
110
|
+
* @category Input State Machine
|
|
111
|
+
*/
|
|
112
|
+
export declare class ReadyToSelectState extends TemplateState<KmtInputEventMapping, SelectionContext, ReadyToSelectStatePossibleTargetStates> {
|
|
113
|
+
constructor();
|
|
114
|
+
leftPointerMove: any;
|
|
115
|
+
protected _eventReactions: EventReactions<KmtInputEventMapping, SelectionContext, ReadyToSelectStatePossibleTargetStates>;
|
|
116
|
+
get eventReactions(): EventReactions<KmtInputEventMapping, SelectionContext, ReadyToSelectStatePossibleTargetStates>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @description The ready to pan via space bar state of the keyboard mouse and trackpad input state machine.
|
|
120
|
+
*
|
|
121
|
+
* @category Input State Machine
|
|
122
|
+
*/
|
|
123
|
+
export declare class ReadyToPanViaSpaceBarState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates> {
|
|
124
|
+
constructor();
|
|
125
|
+
protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
126
|
+
get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
127
|
+
leftPointerDownHandler(context: KmtInputContext, payload: PointerEventPayload): void;
|
|
128
|
+
spacebarUpHandler(context: KmtInputContext, payload: EmptyPayload): void;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @description The initial pan state of the keyboard mouse and trackpad input state machine.
|
|
132
|
+
*
|
|
133
|
+
* @category Input State Machine
|
|
134
|
+
*/
|
|
135
|
+
export declare class InitialPanState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates> {
|
|
136
|
+
constructor();
|
|
137
|
+
protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
138
|
+
get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
139
|
+
leftPointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): void;
|
|
140
|
+
leftPointerUpHandler(context: KmtInputContext, payload: PointerEventPayload): void;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @description The ready to pan via scroll wheel state of the keyboard mouse and trackpad input state machine.
|
|
144
|
+
*
|
|
145
|
+
* @category Input State Machine
|
|
146
|
+
*/
|
|
147
|
+
export declare class ReadyToPanViaScrollWheelState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates> {
|
|
148
|
+
constructor();
|
|
149
|
+
protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
150
|
+
get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
151
|
+
middlePointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): void;
|
|
152
|
+
middlePointerUpHandler(context: KmtInputContext, payload: PointerEventPayload): void;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* @description The pan state of the keyboard mouse and trackpad input state machine.
|
|
156
|
+
*
|
|
157
|
+
* @category Input State Machine
|
|
158
|
+
*/
|
|
159
|
+
export declare class PanState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates> {
|
|
160
|
+
constructor();
|
|
161
|
+
protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
162
|
+
get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
163
|
+
leftPointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): void;
|
|
164
|
+
spacebarUpHandler(context: KmtInputContext, payload: EmptyPayload): void;
|
|
165
|
+
leftPointerUpHandler(context: KmtInputContext, payload: PointerEventPayload): void;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @description The pan via scroll wheel state of the keyboard mouse and trackpad input state machine.
|
|
169
|
+
*
|
|
170
|
+
* @category Input State Machine
|
|
171
|
+
*/
|
|
172
|
+
export declare class PanViaScrollWheelState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates> {
|
|
173
|
+
protected _eventReactions: EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
174
|
+
get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
175
|
+
middlePointerMoveHandler(context: KmtInputContext, payload: PointerEventPayload): void;
|
|
176
|
+
middlePointerUpHandler(context: KmtInputContext, payload: PointerEventPayload): void;
|
|
177
|
+
}
|
|
178
|
+
export declare class KmtEmptyState extends TemplateState<KmtInputEventMapping, KmtInputContext, KmtInputStates> {
|
|
179
|
+
constructor();
|
|
180
|
+
get eventReactions(): EventReactions<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
181
|
+
}
|
|
182
|
+
export type KmtInputStateMachine = TemplateStateMachine<KmtInputEventMapping, KmtInputContext, KmtInputStates>;
|
|
183
|
+
/**
|
|
184
|
+
* @description Creates the keyboard mouse and trackpad input state machine.
|
|
185
|
+
*
|
|
186
|
+
* @category Input State Machine
|
|
187
|
+
*/
|
|
188
|
+
export declare function createKmtInputStateMachine(context: KmtInputContext): KmtInputStateMachine;
|
|
189
|
+
export declare class KmtInputStateMachineWebWorkerProxy extends TemplateStateMachine<KmtInputEventMapping, KmtInputContext, KmtInputStates> {
|
|
190
|
+
private _webworker;
|
|
191
|
+
constructor(webworker: Worker);
|
|
192
|
+
happens(event: keyof KmtInputEventMapping, payload: KmtInputEventMapping[keyof KmtInputEventMapping]): KmtInputStates | undefined;
|
|
193
|
+
}
|
|
194
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Point } from "@ue-too/math";
|
|
2
|
+
import { RawUserInputPublisher } from "../raw-input-publisher";
|
|
3
|
+
import { BaseContext } from "@ue-too/being";
|
|
4
|
+
import { CanvasOperator } from "./kmt-input-context";
|
|
5
|
+
/**
|
|
6
|
+
* @description The touch points.
|
|
7
|
+
*
|
|
8
|
+
* @category Input State Machine
|
|
9
|
+
*/
|
|
10
|
+
export type TouchPoints = {
|
|
11
|
+
ident: number;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
export interface TouchContext extends BaseContext {
|
|
16
|
+
addTouchPoints: (points: TouchPoints[]) => void;
|
|
17
|
+
removeTouchPoints: (idents: number[]) => void;
|
|
18
|
+
getCurrentTouchPointsCount: () => number;
|
|
19
|
+
getInitialTouchPointsPositions: (idents: number[]) => TouchPoints[];
|
|
20
|
+
updateTouchPoints: (pointsMoved: TouchPoints[]) => void;
|
|
21
|
+
notifyOnPan: (delta: Point) => void;
|
|
22
|
+
notifyOnZoom: (zoomAmount: number, anchorPoint: Point) => void;
|
|
23
|
+
alignCoordinateSystem: boolean;
|
|
24
|
+
canvas: CanvasOperator;
|
|
25
|
+
}
|
|
26
|
+
export declare class TouchInputTracker implements TouchContext {
|
|
27
|
+
private _inputPublisher;
|
|
28
|
+
private _touchPointsMap;
|
|
29
|
+
private _canvas;
|
|
30
|
+
private _alignCoordinateSystem;
|
|
31
|
+
constructor(canvas: CanvasOperator, inputPublisher: RawUserInputPublisher);
|
|
32
|
+
addTouchPoints(points: TouchPoints[]): void;
|
|
33
|
+
removeTouchPoints(identifiers: number[]): void;
|
|
34
|
+
getCurrentTouchPointsCount(): number;
|
|
35
|
+
getInitialTouchPointsPositions(idents: number[]): TouchPoints[];
|
|
36
|
+
updateTouchPoints(pointsMoved: TouchPoints[]): void;
|
|
37
|
+
notifyOnPan(delta: Point): void;
|
|
38
|
+
notifyOnZoom(zoomAmount: number, anchorPoint: Point): void;
|
|
39
|
+
get alignCoordinateSystem(): boolean;
|
|
40
|
+
set alignCoordinateSystem(value: boolean);
|
|
41
|
+
get canvas(): CanvasOperator;
|
|
42
|
+
cleanup(): void;
|
|
43
|
+
setup(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { EventReactions, EventGuards, Guard, TemplateState, TemplateStateMachine } from "@ue-too/being";
|
|
2
|
+
import { TouchContext, TouchPoints } from "./touch-input-context";
|
|
3
|
+
export type TouchStates = "IDLE" | "PENDING" | "IN_PROGRESS";
|
|
4
|
+
/**
|
|
5
|
+
* @description The touch event payload.
|
|
6
|
+
*
|
|
7
|
+
* @category Input State Machine
|
|
8
|
+
*/
|
|
9
|
+
export type TouchEventPayload = {
|
|
10
|
+
points: TouchPoints[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @description The touch event mapping.
|
|
14
|
+
*
|
|
15
|
+
* @category Input State Machine
|
|
16
|
+
*/
|
|
17
|
+
export type TouchEventMapping = {
|
|
18
|
+
touchstart: TouchEventPayload;
|
|
19
|
+
touchmove: TouchEventPayload;
|
|
20
|
+
touchend: TouchEventPayload;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @description The idle state of the touch input state machine.
|
|
24
|
+
*
|
|
25
|
+
* @category Input State Machine
|
|
26
|
+
*/
|
|
27
|
+
export declare class IdleState extends TemplateState<TouchEventMapping, TouchContext, TouchStates> {
|
|
28
|
+
private _eventReactions;
|
|
29
|
+
protected _guards: Guard<TouchContext, "touchPointsCount">;
|
|
30
|
+
protected _eventGuards: Partial<EventGuards<TouchEventMapping, TouchStates, TouchContext, typeof this._guards>>;
|
|
31
|
+
get eventReactions(): EventReactions<TouchEventMapping, TouchContext, TouchStates>;
|
|
32
|
+
touchstart(context: TouchContext, payload: TouchEventPayload): void;
|
|
33
|
+
touchend(context: TouchContext, payload: TouchEventPayload): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @description The pending state of the touch input state machine.
|
|
37
|
+
*
|
|
38
|
+
* @category Input State Machine
|
|
39
|
+
*/
|
|
40
|
+
export declare class PendingState extends TemplateState<TouchEventMapping, TouchContext, TouchStates> {
|
|
41
|
+
private _eventReactions;
|
|
42
|
+
get eventReactions(): EventReactions<TouchEventMapping, TouchContext, TouchStates>;
|
|
43
|
+
touchstart(context: TouchContext, payload: TouchEventPayload): void;
|
|
44
|
+
touchend(context: TouchContext, payload: TouchEventPayload): void;
|
|
45
|
+
touchmove(context: TouchContext, payload: TouchEventPayload): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @description The in progress state of the touch input state machine.
|
|
49
|
+
*
|
|
50
|
+
* @category Input State Machine
|
|
51
|
+
*/
|
|
52
|
+
export declare class InProgressState extends TemplateState<TouchEventMapping, TouchContext, TouchStates> {
|
|
53
|
+
private _eventReactions;
|
|
54
|
+
get eventReactions(): EventReactions<TouchEventMapping, TouchContext, TouchStates>;
|
|
55
|
+
touchmove(context: TouchContext, payload: TouchEventPayload): void;
|
|
56
|
+
touchend(context: TouchContext, payload: TouchEventPayload): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @description The touch input state machine.
|
|
60
|
+
*
|
|
61
|
+
* @category Input State Machine
|
|
62
|
+
*/
|
|
63
|
+
export type TouchInputStateMachine = TemplateStateMachine<TouchEventMapping, TouchContext, TouchStates>;
|
|
64
|
+
export declare function createTouchInputStateMachine(context: TouchContext): TouchInputStateMachine;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { KmtInputStateMachine } from "../../input-interpretation/input-state-machine";
|
|
2
|
+
/**
|
|
3
|
+
* @category Event Parser
|
|
4
|
+
*/
|
|
5
|
+
export interface KMTEventParser {
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
setUp(): void;
|
|
8
|
+
tearDown(): void;
|
|
9
|
+
attach(canvas: HTMLCanvasElement): void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @description The minimum pointer event.
|
|
13
|
+
* This is for the interoperability between the vanilla javascript and the pixijs event system.
|
|
14
|
+
*
|
|
15
|
+
* @category Event Parser
|
|
16
|
+
*/
|
|
17
|
+
export type MinimumPointerEvent = {
|
|
18
|
+
button: number;
|
|
19
|
+
pointerType: string;
|
|
20
|
+
clientX: number;
|
|
21
|
+
clientY: number;
|
|
22
|
+
buttons: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* @description The minimum wheel event.
|
|
26
|
+
* This is for the interoperability between the vanilla javascript and the pixijs event system.
|
|
27
|
+
*
|
|
28
|
+
* @category Event Parser
|
|
29
|
+
*/
|
|
30
|
+
export type MinimumWheelEvent = {
|
|
31
|
+
preventDefault: () => void;
|
|
32
|
+
deltaX: number;
|
|
33
|
+
deltaY: number;
|
|
34
|
+
ctrlKey: boolean;
|
|
35
|
+
clientX: number;
|
|
36
|
+
clientY: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @description The minimum keyboard event.
|
|
40
|
+
* This is for the interoperability between the vanilla javascript and the pixijs event system.
|
|
41
|
+
*
|
|
42
|
+
* @category Event Parser
|
|
43
|
+
*/
|
|
44
|
+
export type MinimumKeyboardEvent = {
|
|
45
|
+
preventDefault: () => void;
|
|
46
|
+
key: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* @description The event target with pointer events.
|
|
50
|
+
* This is for the interoperability between the vanilla javascript and the pixijs event system.
|
|
51
|
+
*
|
|
52
|
+
* @category Event Parser
|
|
53
|
+
*/
|
|
54
|
+
export type EventTargetWithPointerEvents = {
|
|
55
|
+
addEventListener: (type: string, listener: (event: any) => void, options?: {
|
|
56
|
+
passive: boolean;
|
|
57
|
+
}) => void;
|
|
58
|
+
removeEventListener: (type: string, listener: (event: any) => void) => void;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* @description The vanilla keyboard mouse and trackpad(KMT) event parser.
|
|
62
|
+
* This parser converts the raw events to events that can be used by the input state machine.
|
|
63
|
+
*
|
|
64
|
+
* @category Event Parser
|
|
65
|
+
*/
|
|
66
|
+
export declare class VanillaKMTEventParser implements KMTEventParser {
|
|
67
|
+
private _disabled;
|
|
68
|
+
private _stateMachine;
|
|
69
|
+
private _keyfirstPressed;
|
|
70
|
+
private _abortController;
|
|
71
|
+
private _canvas;
|
|
72
|
+
constructor(canvas: HTMLCanvasElement, kmtInputStateMachine: KmtInputStateMachine);
|
|
73
|
+
get disabled(): boolean;
|
|
74
|
+
set disabled(value: boolean);
|
|
75
|
+
get stateMachine(): KmtInputStateMachine;
|
|
76
|
+
addEventListeners(signal: AbortSignal): void;
|
|
77
|
+
setUp(): void;
|
|
78
|
+
tearDown(): void;
|
|
79
|
+
bindFunctions(): void;
|
|
80
|
+
pointerDownHandler(e: MinimumPointerEvent): void;
|
|
81
|
+
pointerUpHandler(e: MinimumPointerEvent): void;
|
|
82
|
+
pointerMoveHandler(e: MinimumPointerEvent): void;
|
|
83
|
+
scrollHandler(e: MinimumWheelEvent): void;
|
|
84
|
+
keypressHandler(e: KeyboardEvent): void;
|
|
85
|
+
keyupHandler(e: KeyboardEvent): void;
|
|
86
|
+
attach(canvas: HTMLCanvasElement): void;
|
|
87
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { TouchInputStateMachine } from "../../input-interpretation/input-state-machine/touch-input-state-machine";
|
|
2
|
+
/**
|
|
3
|
+
* @description The touch event parser.
|
|
4
|
+
* This is for the interoperability between the vanilla javascript and the pixijs event system.
|
|
5
|
+
*
|
|
6
|
+
* @category Event Parser
|
|
7
|
+
*/
|
|
8
|
+
export interface TouchEventParser {
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
panDisabled: boolean;
|
|
11
|
+
zoomDisabled: boolean;
|
|
12
|
+
rotateDisabled: boolean;
|
|
13
|
+
enableStrategy(): void;
|
|
14
|
+
disableStrategy(): void;
|
|
15
|
+
setUp(): void;
|
|
16
|
+
tearDown(): void;
|
|
17
|
+
attach(canvas: HTMLCanvasElement): void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @description The vanilla touch event parser.
|
|
21
|
+
* This parser converts the raw events to events that can be used by the input state machine.
|
|
22
|
+
*
|
|
23
|
+
* @category Event Parser
|
|
24
|
+
*/
|
|
25
|
+
export declare class VanillaTouchEventParser implements TouchEventParser {
|
|
26
|
+
private _canvas;
|
|
27
|
+
private _touchInputTracker;
|
|
28
|
+
private _disabled;
|
|
29
|
+
private _panDisabled;
|
|
30
|
+
private _zoomDisabled;
|
|
31
|
+
private _rotateDisabled;
|
|
32
|
+
private touchSM;
|
|
33
|
+
private _abortController;
|
|
34
|
+
constructor(canvas: HTMLCanvasElement, touchInputStateMachine: TouchInputStateMachine);
|
|
35
|
+
get touchStateMachine(): TouchInputStateMachine;
|
|
36
|
+
bindListeners(): void;
|
|
37
|
+
enableStrategy(): void;
|
|
38
|
+
disableStrategy(): void;
|
|
39
|
+
setUp(): void;
|
|
40
|
+
tearDown(): void;
|
|
41
|
+
get disabled(): boolean;
|
|
42
|
+
get alignCoordinateSystem(): boolean;
|
|
43
|
+
set alignCoordinateSystem(alignCoordinateSystem: boolean);
|
|
44
|
+
get panDisabled(): boolean;
|
|
45
|
+
set panDisabled(panDisabled: boolean);
|
|
46
|
+
get zoomDisabled(): boolean;
|
|
47
|
+
set zoomDisabled(zoomDisabled: boolean);
|
|
48
|
+
get rotateDisabled(): boolean;
|
|
49
|
+
set rotateDisabled(rotateDisabled: boolean);
|
|
50
|
+
touchstartHandler(e: TouchEvent): void;
|
|
51
|
+
touchcancelHandler(e: TouchEvent): void;
|
|
52
|
+
touchendHandler(e: TouchEvent): void;
|
|
53
|
+
touchmoveHandler(e: TouchEvent): void;
|
|
54
|
+
attach(canvas: HTMLCanvasElement): void;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./raw-input-publisher";
|