@ue-too/board 0.14.1 → 0.15.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 +21 -10
- package/boardify/index.d.ts +7 -8
- package/camera/base.d.ts +14 -14
- package/camera/camera-edge-auto-input.d.ts +1 -1
- package/camera/camera-mux/animation-and-lock/animation-and-lock.d.ts +5 -5
- package/camera/camera-mux/animation-and-lock/index.d.ts +4 -4
- package/camera/camera-mux/animation-and-lock/pan-control-state-machine.d.ts +21 -21
- package/camera/camera-mux/animation-and-lock/rotation-control-state-machine.d.ts +20 -20
- package/camera/camera-mux/animation-and-lock/zoom-control-state-machine.d.ts +46 -46
- package/camera/camera-mux/index.d.ts +3 -3
- package/camera/camera-mux/interface.d.ts +1 -1
- package/camera/camera-mux/relay.d.ts +2 -2
- package/camera/camera-rig/camera-rig.d.ts +6 -6
- package/camera/camera-rig/index.d.ts +4 -4
- package/camera/camera-rig/pan-handler.d.ts +2 -2
- package/camera/camera-rig/rotation-handler.d.ts +3 -1
- package/camera/camera-rig/zoom-handler.d.ts +1 -1
- package/camera/default-camera.d.ts +9 -7
- package/camera/index.d.ts +1 -1
- package/camera/interface.d.ts +7 -15
- package/camera/update-publisher.d.ts +16 -16
- package/camera/utils/coordinate-conversion.d.ts +4 -4
- package/camera/utils/index.d.ts +5 -5
- package/camera/utils/position.d.ts +11 -2
- package/index.d.ts +5 -5
- package/index.js +2 -2
- package/index.js.map +65 -63
- package/input-interpretation/index.d.ts +4 -4
- package/input-interpretation/input-orchestrator.d.ts +5 -5
- package/input-interpretation/input-state-machine/index.d.ts +4 -4
- package/input-interpretation/input-state-machine/kmt-input-context.d.ts +7 -7
- package/input-interpretation/input-state-machine/kmt-input-state-machine.d.ts +10 -11
- package/input-interpretation/input-state-machine/touch-input-context.d.ts +2 -2
- package/input-interpretation/input-state-machine/touch-input-state-machine.d.ts +8 -8
- package/input-interpretation/raw-input-parser/index.d.ts +2 -2
- package/input-interpretation/raw-input-parser/vanilla-kmt-event-parser.d.ts +7 -3
- package/input-interpretation/raw-input-parser/vanilla-touch-event-parser.d.ts +2 -2
- package/input-interpretation/raw-input-publisher/index.d.ts +1 -1
- package/input-interpretation/raw-input-publisher/raw-input-publisher.d.ts +8 -8
- package/package.json +3 -3
- package/utils/canvas-position-dimension.d.ts +2 -1
- package/utils/coordinate-conversions/canvas-viewport.d.ts +1 -1
- package/utils/coordinate-conversions/index.d.ts +3 -0
- package/utils/coordinate-conversions/viewport-world.d.ts +1 -1
- package/utils/coordinate-conversions/window-canvas.d.ts +2 -2
- package/utils/coorindate-conversion.d.ts +2 -2
- package/utils/drawing-utils.d.ts +2 -2
- package/utils/drawing.d.ts +1 -1
- package/utils/index.d.ts +10 -8
- package/utils/scrollbar/index.d.ts +1 -0
- package/utils/scrollbar/scrollbar.d.ts +20 -0
- package/utils/zoomlevel-adjustment.d.ts +2 -2
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
## Overview
|
|
35
35
|
|
|
36
36
|
### What This Library Provides
|
|
37
|
+
|
|
37
38
|
- Transforms HTML canvas into a near-infinite canvas with panning, zooming, and rotation capabilities
|
|
38
39
|
- Provides utility functions that simplify the complex mathematics required for infinite canvas operations
|
|
39
40
|
- Compatible with multiple canvas frameworks (vanilla, Pixi.js, Fabric.js, Konva) as the underlying mathematical principles remain consistent
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
- Accomplishes the same goal as pixi-viewport but without pixi.js dependency
|
|
42
43
|
|
|
43
44
|
### What This Library Is Not
|
|
45
|
+
|
|
44
46
|
- A complete drawing application like Excalidraw or tldraw
|
|
45
47
|
- A full-featured package with built-in drawing tools and user interfaces
|
|
46
48
|
|
|
@@ -55,6 +57,7 @@ As you add these features, the code becomes increasingly complex, especially whe
|
|
|
55
57
|
Even if you're not building a drawing app, `ue-too` is useful for any canvas that requires panning functionality. It works with various frameworks including pixi.js, fabric.js, Konva, vanilla JavaScript canvas API, and even headless canvas in Node.js.
|
|
56
58
|
|
|
57
59
|
## Quick Demo
|
|
60
|
+
|
|
58
61
|
[Stackblitz example link](https://stackblitz.com/edit/vitejs-vite-jpxrtxzg?file=index.html): This example demonstrates the basic functionality shown in the [Quick Start](#quick-start-using-only-html-canvas) section.
|
|
59
62
|
|
|
60
63
|
Additional examples in the [`devserver`](https://github.com/niuee/board/tree/main/devserver) directory show integration with pixi.js, fabric.js, and Konva (incomplete but providing general implementation guidance).
|
|
@@ -62,15 +65,17 @@ Additional examples in the [`devserver`](https://github.com/niuee/board/tree/mai
|
|
|
62
65
|
## Installation and Usage
|
|
63
66
|
|
|
64
67
|
### Installation
|
|
68
|
+
|
|
65
69
|
```bash
|
|
66
70
|
npm install @ue-too/board
|
|
67
71
|
```
|
|
68
72
|
|
|
69
73
|
```javascript
|
|
70
|
-
import { Board } from
|
|
74
|
+
import { Board } from '@ue-too/board';
|
|
71
75
|
```
|
|
72
76
|
|
|
73
77
|
## Key Features
|
|
78
|
+
|
|
74
79
|
- Modularity: Use only the components you need (details in the [Under the Hood](#under-the-hood) section)
|
|
75
80
|
- Comprehensive input support: touch, trackpad (macOS), keyboard, and mouse, with customizable behavior
|
|
76
81
|
- Framework-agnostic: Works with HTML and JavaScript, and can be integrated with frontend frameworks/libraries
|
|
@@ -81,25 +86,26 @@ import { Board } from "@ue-too/board";
|
|
|
81
86
|
This example is based on the MDN documentation for the [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API). (turning the MDN example into an infinite canvas)
|
|
82
87
|
|
|
83
88
|
HTML:
|
|
89
|
+
|
|
84
90
|
```html
|
|
85
91
|
<canvas id="graph"></canvas>
|
|
86
92
|
```
|
|
87
93
|
|
|
88
94
|
```javascript
|
|
89
|
-
import { Board } from
|
|
95
|
+
import { Board } from '@ue-too/board';
|
|
90
96
|
|
|
91
|
-
const canvas = document.getElementById(
|
|
97
|
+
const canvas = document.getElementById('graph');
|
|
92
98
|
|
|
93
99
|
const board = new Board(canvas);
|
|
94
100
|
|
|
95
101
|
function draw(timestamp) {
|
|
96
|
-
// step the board
|
|
102
|
+
// step the board
|
|
97
103
|
board.step(timestamp);
|
|
98
104
|
|
|
99
105
|
// add the rectangle back to the canvas, the drawing steps is the same as the MDN example but we're using the context from the board instance.
|
|
100
|
-
board.context.fillStyle =
|
|
106
|
+
board.context.fillStyle = 'green';
|
|
101
107
|
board.context.fillRect(10, 10, 150, 100);
|
|
102
|
-
|
|
108
|
+
|
|
103
109
|
// request the next frame
|
|
104
110
|
requestAnimationFrame(draw);
|
|
105
111
|
}
|
|
@@ -111,21 +117,25 @@ requestAnimationFrame(draw);
|
|
|
111
117
|
### Default Input Controls
|
|
112
118
|
|
|
113
119
|
Pan:
|
|
120
|
+
|
|
114
121
|
- Mouse + Keyboard: Drag while holding spacebar or use scroll wheel button
|
|
115
122
|
- Trackpad: Two-finger swipe
|
|
116
123
|
- Touch: Two-finger swipe
|
|
117
124
|
|
|
118
125
|
Zoom:
|
|
126
|
+
|
|
119
127
|
- Mouse + Keyboard: Ctrl + scroll wheel
|
|
120
128
|
- Trackpad: Two-finger pinch
|
|
121
129
|
- Touch: Two-finger pinch
|
|
122
130
|
|
|
123
131
|
### Important Notes
|
|
132
|
+
|
|
124
133
|
- All drawing operations should be performed in the `requestAnimationFrame` callback after the `step` function
|
|
125
134
|
- The `Board` class is designed for minimal setup but offers less flexibility
|
|
126
135
|
- For more customization, refer to the [Under the Hood](#under-the-hood) section
|
|
127
136
|
|
|
128
137
|
The `Board` class handles:
|
|
138
|
+
|
|
129
139
|
- Input event interpretation
|
|
130
140
|
- Automatic camera zoom boundary adjustments
|
|
131
141
|
- And more...
|
|
@@ -145,16 +155,16 @@ Please refer to the [README](https://github.com/ue-too/ue-too/) in the root dire
|
|
|
145
155
|
1. This package is within a monorepo, and is managed by nx and pnpm. I am not super familiar with nx or monorepo; this is kind of an experiment and a learning experience for me. (if you have any suggestions on how to improve the setup, please let me know!)
|
|
146
156
|
2. Bundling the package is done through rollup and testing through jest.
|
|
147
157
|
|
|
148
|
-
|
|
149
158
|
## Under the Hood
|
|
150
159
|
|
|
151
|
-
ue-too consists of 3 core components:
|
|
160
|
+
ue-too consists of 3 core components:
|
|
152
161
|
|
|
153
162
|
- `Board Camera (viewport)`: This is the core of the cores xD; It's the class that holds the information about the viewport.
|
|
154
|
-
- `Camera Input Multiplexer`: This is the part that determines which kind of input should be passed through based on the current condition. This is to support multiple input methods. For example, user input would take precedence over the transition animation input and so on.
|
|
163
|
+
- `Camera Input Multiplexer`: This is the part that determines which kind of input should be passed through based on the current condition. This is to support multiple input methods. For example, user input would take precedence over the transition animation input and so on.
|
|
155
164
|
- `User Input Interpretation`: This is the part that handles the user input events from the canvas element (pointer, keyboard, touch, etc.), and based on the events determine what the user intentions are.
|
|
156
165
|
|
|
157
166
|
To see detail of each component navigate to the respective readme in the subdirectories.
|
|
167
|
+
|
|
158
168
|
- [Board Camera](https://github.com/ue-too/ue-too/tree/main/packages/board/src/camera)
|
|
159
169
|
- [Camera Mux](https://github.com/ue-too/ue-too/tree/main/packages/board/src/camera/camera-mux)
|
|
160
170
|
- [User Input Interpreter](https://github.com/ue-too/ue-too/tree/main/packages/board/src/input-interpretation)
|
|
@@ -210,7 +220,7 @@ flowchart TB
|
|
|
210
220
|
IO -->|"always publish"| RIP
|
|
211
221
|
RIP --> RIO
|
|
212
222
|
IO -->|"ask permission"| CM
|
|
213
|
-
|
|
223
|
+
|
|
214
224
|
%% Camera Mux
|
|
215
225
|
OCIS -->|"request input"| CM
|
|
216
226
|
CM -->|"allowPassThrough?"| IO
|
|
@@ -222,6 +232,7 @@ flowchart TB
|
|
|
222
232
|
```
|
|
223
233
|
|
|
224
234
|
**Key concepts:**
|
|
235
|
+
|
|
225
236
|
- **Event Parsers**: Register listeners on canvas (should work with vanilla out of the box, pixi.js, fabric.js, konva with some modifications)
|
|
226
237
|
- **Input State Machine**: Interprets raw events into camera intents (pan/zoom/rotate)
|
|
227
238
|
- **Input Orchestrator**: Routes outputs in parallel — always publishes raw input, and asks CameraMux for permission to pass through the input to the camera rig.
|
package/boardify/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ObservableBoardCamera } from '../camera/interface';
|
|
2
|
-
import { KMTEventParser } from '../input-interpretation/raw-input-parser';
|
|
3
|
-
import { TouchEventParser } from '../input-interpretation/raw-input-parser';
|
|
4
1
|
import { Point } from '@ue-too/math';
|
|
5
|
-
import { CameraEventMap, CameraState, UnSubscribe } from '../camera/update-publisher';
|
|
6
|
-
import { UnsubscribeToUserRawInput, RawUserInputEventMap } from '../input-interpretation/raw-input-publisher';
|
|
7
2
|
import { CameraMux } from '../camera/camera-mux';
|
|
8
3
|
import { CameraRig } from '../camera/camera-rig';
|
|
9
|
-
import {
|
|
4
|
+
import { ObservableBoardCamera } from '../camera/interface';
|
|
5
|
+
import { CameraEventMap, CameraState, UnSubscribe } from '../camera/update-publisher';
|
|
10
6
|
import { InputOrchestrator } from '../input-interpretation/input-orchestrator';
|
|
7
|
+
import { CanvasDimensions } from '../input-interpretation/input-state-machine';
|
|
8
|
+
import { KMTEventParser } from '../input-interpretation/raw-input-parser';
|
|
9
|
+
import { TouchEventParser } from '../input-interpretation/raw-input-parser';
|
|
10
|
+
import { RawUserInputEventMap, UnsubscribeToUserRawInput } from '../input-interpretation/raw-input-publisher';
|
|
11
11
|
/**
|
|
12
12
|
* Main user-facing API class that provides an infinite canvas with pan, zoom, and rotate capabilities.
|
|
13
13
|
*
|
|
@@ -143,10 +143,9 @@ import { InputOrchestrator } from '../input-interpretation/input-orchestrator';
|
|
|
143
143
|
* ```
|
|
144
144
|
*
|
|
145
145
|
* @example
|
|
146
|
-
*
|
|
146
|
+
* Initialize board without canvas, attach canvas later
|
|
147
147
|
* ```typescript
|
|
148
148
|
* const board = new Board();
|
|
149
|
-
* board.fullScreen = true; // Canvas will resize with window
|
|
150
149
|
*
|
|
151
150
|
* // Attach canvas later
|
|
152
151
|
* const canvasElement = document.createElement('canvas');
|
package/camera/base.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { Point } from '@ue-too/math';
|
|
2
|
-
import { Boundaries } from './utils/position';
|
|
3
|
-
import { ZoomLevelLimits } from './utils/zoom';
|
|
4
|
-
import { RotationLimits } from './utils/rotation';
|
|
5
2
|
import { BoardCamera } from './interface';
|
|
6
3
|
import { TransformationMatrix } from './utils/matrix';
|
|
4
|
+
import { Boundaries } from './utils/position';
|
|
5
|
+
import { RotationLimits } from './utils/rotation';
|
|
6
|
+
import { ZoomLevelLimits } from './utils/zoom';
|
|
7
|
+
export type CameraOptions = {
|
|
8
|
+
viewPortWidth?: number;
|
|
9
|
+
viewPortHeight?: number;
|
|
10
|
+
position?: Point;
|
|
11
|
+
rotation?: number;
|
|
12
|
+
zoomLevel?: number;
|
|
13
|
+
boundaries?: Boundaries;
|
|
14
|
+
zoomLevelBoundaries?: ZoomLevelLimits;
|
|
15
|
+
rotationBoundaries?: RotationLimits;
|
|
16
|
+
};
|
|
7
17
|
/**
|
|
8
18
|
* Base camera implementation providing core functionality for an infinite canvas system.
|
|
9
19
|
* This is the fundamental building block for camera management in the board package.
|
|
@@ -90,7 +100,7 @@ export default class BaseCamera implements BoardCamera {
|
|
|
90
100
|
* );
|
|
91
101
|
* ```
|
|
92
102
|
*/
|
|
93
|
-
constructor(
|
|
103
|
+
constructor(options: CameraOptions);
|
|
94
104
|
/**
|
|
95
105
|
* Gets the current position boundaries that constrain camera movement in world coordinates.
|
|
96
106
|
*
|
|
@@ -343,16 +353,6 @@ export default class BaseCamera implements BoardCamera {
|
|
|
343
353
|
* ```
|
|
344
354
|
*/
|
|
345
355
|
setRotation(rotation: number): boolean;
|
|
346
|
-
/**
|
|
347
|
-
* Gets the camera origin in window coordinates.
|
|
348
|
-
*
|
|
349
|
-
* @deprecated This method is deprecated and will be removed in a future version.
|
|
350
|
-
* Currently just returns the input unchanged.
|
|
351
|
-
*
|
|
352
|
-
* @param centerInWindow - Center point in window coordinates
|
|
353
|
-
* @returns The same point (camera origin equals window center)
|
|
354
|
-
*/
|
|
355
|
-
getCameraOriginInWindow(centerInWindow: Point): Point;
|
|
356
356
|
/**
|
|
357
357
|
* Converts a point from viewport coordinates to world coordinates.
|
|
358
358
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { PanControlStateMachine } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { Point } from '@ue-too/math';
|
|
2
|
+
import { CameraMux, CameraMuxPanOutput, CameraMuxRotationOutput, CameraMuxZoomOutput } from '../interface';
|
|
3
|
+
import { PanControlStateMachine } from './pan-control-state-machine';
|
|
4
|
+
import { RotateControlOutputEvent, RotateControlStateMachine } from './rotation-control-state-machine';
|
|
5
|
+
import { ZoomControlStateMachine } from './zoom-control-state-machine';
|
|
6
6
|
/**
|
|
7
7
|
* Advanced camera input multiplexer with animation support and input locking via state machines.
|
|
8
8
|
*
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*
|
|
26
26
|
* @module
|
|
27
27
|
*/
|
|
28
|
-
export * from
|
|
29
|
-
export * from
|
|
30
|
-
export * from
|
|
31
|
-
export * from
|
|
28
|
+
export * from './animation-and-lock';
|
|
29
|
+
export * from './pan-control-state-machine';
|
|
30
|
+
export * from './zoom-control-state-machine';
|
|
31
|
+
export * from './rotation-control-state-machine';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import type { BaseContext, EventReactions, State } from '@ue-too/being';
|
|
2
|
+
import { TemplateState, TemplateStateMachine } from '@ue-too/being';
|
|
3
|
+
import { Point } from '@ue-too/math';
|
|
4
4
|
/**
|
|
5
5
|
* State identifiers for the pan control state machine.
|
|
6
6
|
*
|
|
@@ -12,7 +12,7 @@ import { TemplateState, TemplateStateMachine } from "@ue-too/being";
|
|
|
12
12
|
*
|
|
13
13
|
* @category Input Flow Control
|
|
14
14
|
*/
|
|
15
|
-
export type PanControlStates =
|
|
15
|
+
export type PanControlStates = 'ACCEPTING_USER_INPUT' | 'TRANSITION' | 'LOCKED_ON_OBJECT';
|
|
16
16
|
/**
|
|
17
17
|
* Payload for pan-by input events (relative panning).
|
|
18
18
|
* @category Input Flow Control
|
|
@@ -44,14 +44,14 @@ type EmptyPayload = {};
|
|
|
44
44
|
* @category Input Flow Control
|
|
45
45
|
*/
|
|
46
46
|
export type PanEventPayloadMapping = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
userPanByInput: PanByInputEventPayload;
|
|
48
|
+
userPanToInput: PanToInputEventPayload;
|
|
49
|
+
transitionPanByInput: PanByInputEventPayload;
|
|
50
|
+
transitionPanToInput: PanToInputEventPayload;
|
|
51
|
+
lockedOnObjectPanByInput: PanByInputEventPayload;
|
|
52
|
+
lockedOnObjectPanToInput: PanToInputEventPayload;
|
|
53
|
+
unlock: EmptyPayload;
|
|
54
|
+
initateTransition: EmptyPayload;
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
57
|
* Discriminated union of output events from pan control state machine.
|
|
@@ -65,13 +65,13 @@ export type PanEventPayloadMapping = {
|
|
|
65
65
|
* @category Input Flow Control
|
|
66
66
|
*/
|
|
67
67
|
export type PanControlOutputEvent = {
|
|
68
|
-
type:
|
|
68
|
+
type: 'panByViewPort';
|
|
69
69
|
delta: Point;
|
|
70
70
|
} | {
|
|
71
|
-
type:
|
|
71
|
+
type: 'panToWorld';
|
|
72
72
|
target: Point;
|
|
73
73
|
} | {
|
|
74
|
-
type:
|
|
74
|
+
type: 'none';
|
|
75
75
|
};
|
|
76
76
|
/**
|
|
77
77
|
* Output event type mapping for pan control events.
|
|
@@ -80,12 +80,12 @@ export type PanControlOutputEvent = {
|
|
|
80
80
|
* @category Input Flow Control
|
|
81
81
|
*/
|
|
82
82
|
export type PanControlOutputMapping = {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
userPanByInput: PanControlOutputEvent;
|
|
84
|
+
userPanToInput: PanControlOutputEvent;
|
|
85
|
+
transitionPanByInput: PanControlOutputEvent;
|
|
86
|
+
transitionPanToInput: PanControlOutputEvent;
|
|
87
|
+
lockedOnObjectPanByInput: PanControlOutputEvent;
|
|
88
|
+
lockedOnObjectPanToInput: PanControlOutputEvent;
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
91
91
|
* State machine controlling pan input flow and animations.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EventReactions, State
|
|
2
|
-
import { TemplateState, TemplateStateMachine } from
|
|
1
|
+
import type { BaseContext, EventReactions, State } from '@ue-too/being';
|
|
2
|
+
import { TemplateState, TemplateStateMachine } from '@ue-too/being';
|
|
3
3
|
/**
|
|
4
4
|
* State identifiers for the rotation control state machine.
|
|
5
5
|
*
|
|
@@ -11,7 +11,7 @@ import { TemplateState, TemplateStateMachine } from "@ue-too/being";
|
|
|
11
11
|
*
|
|
12
12
|
* @category Input Flow Control
|
|
13
13
|
*/
|
|
14
|
-
export type RotateControlStates =
|
|
14
|
+
export type RotateControlStates = 'ACCEPTING_USER_INPUT' | 'TRANSITION' | 'LOCKED_ON_OBJECT';
|
|
15
15
|
/**
|
|
16
16
|
* Payload for rotate-by input events (relative rotation).
|
|
17
17
|
* @category Input Flow Control
|
|
@@ -43,14 +43,14 @@ type EmptyPayload = {};
|
|
|
43
43
|
* @category Input Flow Control
|
|
44
44
|
*/
|
|
45
45
|
export type RotateEventPayloadMapping = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
userRotateByInput: RotateByInputEventPayload;
|
|
47
|
+
userRotateToInput: RotateToInputEventPayload;
|
|
48
|
+
transitionRotateByInput: RotateByInputEventPayload;
|
|
49
|
+
transitionRotateToInput: RotateToInputEventPayload;
|
|
50
|
+
lockedOnObjectRotateByInput: RotateByInputEventPayload;
|
|
51
|
+
lockedOnObjectRotateToInput: RotateToInputEventPayload;
|
|
52
|
+
unlock: EmptyPayload;
|
|
53
|
+
initateTransition: EmptyPayload;
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
56
56
|
* Discriminated union of output events from rotation control state machine.
|
|
@@ -64,13 +64,13 @@ export type RotateEventPayloadMapping = {
|
|
|
64
64
|
* @category Input Flow Control
|
|
65
65
|
*/
|
|
66
66
|
export type RotateControlOutputEvent = {
|
|
67
|
-
type:
|
|
67
|
+
type: 'rotateBy';
|
|
68
68
|
delta: number;
|
|
69
69
|
} | {
|
|
70
|
-
type:
|
|
70
|
+
type: 'rotateTo';
|
|
71
71
|
target: number;
|
|
72
72
|
} | {
|
|
73
|
-
type:
|
|
73
|
+
type: 'none';
|
|
74
74
|
};
|
|
75
75
|
/**
|
|
76
76
|
* Output event type mapping for rotation control events.
|
|
@@ -79,12 +79,12 @@ export type RotateControlOutputEvent = {
|
|
|
79
79
|
* @category Input Flow Control
|
|
80
80
|
*/
|
|
81
81
|
export type RotateControlOutputMapping = {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
userRotateByInput: RotateControlOutputEvent;
|
|
83
|
+
userRotateToInput: RotateControlOutputEvent;
|
|
84
|
+
transitionRotateByInput: RotateControlOutputEvent;
|
|
85
|
+
transitionRotateToInput: RotateControlOutputEvent;
|
|
86
|
+
lockedOnObjectRotateByInput: RotateControlOutputEvent;
|
|
87
|
+
lockedOnObjectRotateToInput: RotateControlOutputEvent;
|
|
88
88
|
};
|
|
89
89
|
/**
|
|
90
90
|
* State machine controlling rotation input flow and animations.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { TemplateState, TemplateStateMachine } from
|
|
3
|
-
import { Point } from
|
|
1
|
+
import type { BaseContext, EventReactions, State } from '@ue-too/being';
|
|
2
|
+
import { TemplateState, TemplateStateMachine } from '@ue-too/being';
|
|
3
|
+
import { Point } from '@ue-too/math';
|
|
4
4
|
/**
|
|
5
5
|
* State identifiers for the zoom control state machine.
|
|
6
6
|
*
|
|
@@ -12,7 +12,7 @@ import { Point } from "@ue-too/math";
|
|
|
12
12
|
*
|
|
13
13
|
* @category Input Flow Control
|
|
14
14
|
*/
|
|
15
|
-
export type ZoomControlStates =
|
|
15
|
+
export type ZoomControlStates = 'ACCEPTING_USER_INPUT' | 'TRANSITION' | 'LOCKED_ON_OBJECT';
|
|
16
16
|
/**
|
|
17
17
|
* Payload for zoom-by-at input events (relative zoom around a point).
|
|
18
18
|
* @category Input Flow Control
|
|
@@ -62,17 +62,17 @@ export type ZoomToPayload = {
|
|
|
62
62
|
* @category Input Flow Control
|
|
63
63
|
*/
|
|
64
64
|
export type ZoomEventPayloadMapping = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
userZoomByAtInput: ZoomByAtInputPayload;
|
|
66
|
+
userZoomToAtInput: ZoomToAtInputPayload;
|
|
67
|
+
transitionZoomByAtInput: ZoomByAtInputPayload;
|
|
68
|
+
transitionZoomToAtInput: ZoomToAtInputPayload;
|
|
69
|
+
transitionZoomByAtCenterInput: ZoomByPayload;
|
|
70
|
+
transitionZoomToAtCenterInput: ZoomToAtInputPayload;
|
|
71
|
+
transitionZoomToAtWorldInput: ZoomToAtInputPayload;
|
|
72
|
+
lockedOnObjectZoomByAtInput: ZoomByAtInputPayload;
|
|
73
|
+
lockedOnObjectZoomToAtInput: ZoomToAtInputPayload;
|
|
74
|
+
unlock: {};
|
|
75
|
+
initiateTransition: {};
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
78
78
|
* Discriminated union of output events from zoom control state machine.
|
|
@@ -90,29 +90,29 @@ export type ZoomEventPayloadMapping = {
|
|
|
90
90
|
* @category Input Flow Control
|
|
91
91
|
*/
|
|
92
92
|
export type ZoomControlOutputEvent = {
|
|
93
|
-
type:
|
|
93
|
+
type: 'zoomByAt';
|
|
94
94
|
deltaZoom: number;
|
|
95
95
|
anchorPoint: Point;
|
|
96
96
|
} | {
|
|
97
|
-
type:
|
|
97
|
+
type: 'zoomToAt';
|
|
98
98
|
targetZoom: number;
|
|
99
99
|
anchorPoint: Point;
|
|
100
100
|
} | {
|
|
101
|
-
type:
|
|
101
|
+
type: 'zoomBy';
|
|
102
102
|
deltaZoom: number;
|
|
103
103
|
} | {
|
|
104
|
-
type:
|
|
104
|
+
type: 'zoomTo';
|
|
105
105
|
targetZoom: number;
|
|
106
106
|
} | {
|
|
107
|
-
type:
|
|
107
|
+
type: 'zoomByAtWorld';
|
|
108
108
|
deltaZoom: number;
|
|
109
109
|
anchorPoint: Point;
|
|
110
110
|
} | {
|
|
111
|
-
type:
|
|
111
|
+
type: 'zoomToAtWorld';
|
|
112
112
|
targetZoom: number;
|
|
113
113
|
anchorPoint: Point;
|
|
114
114
|
} | {
|
|
115
|
-
type:
|
|
115
|
+
type: 'none';
|
|
116
116
|
};
|
|
117
117
|
/**
|
|
118
118
|
* Output event type mapping for zoom control events.
|
|
@@ -121,15 +121,15 @@ export type ZoomControlOutputEvent = {
|
|
|
121
121
|
* @category Input Flow Control
|
|
122
122
|
*/
|
|
123
123
|
export type ZoomControlOutputMapping = {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
userZoomByAtInput: ZoomControlOutputEvent;
|
|
125
|
+
userZoomToAtInput: ZoomControlOutputEvent;
|
|
126
|
+
transitionZoomByAtInput: ZoomControlOutputEvent;
|
|
127
|
+
transitionZoomToAtInput: ZoomControlOutputEvent;
|
|
128
|
+
transitionZoomByAtCenterInput: ZoomControlOutputEvent;
|
|
129
|
+
transitionZoomToAtCenterInput: ZoomControlOutputEvent;
|
|
130
|
+
transitionZoomToAtWorldInput: ZoomControlOutputEvent;
|
|
131
|
+
lockedOnObjectZoomByAtInput: ZoomControlOutputEvent;
|
|
132
|
+
lockedOnObjectZoomToAtInput: ZoomControlOutputEvent;
|
|
133
133
|
};
|
|
134
134
|
/**
|
|
135
135
|
* State implementation for accepting user zoom input (idle/normal state).
|
|
@@ -138,8 +138,8 @@ export type ZoomControlOutputMapping = {
|
|
|
138
138
|
*/
|
|
139
139
|
export declare class ZoomAcceptingUserInputState extends TemplateState<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping> {
|
|
140
140
|
protected _eventReactions: EventReactions<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping>;
|
|
141
|
-
userZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
142
|
-
userZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
141
|
+
userZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['userZoomByAtInput']): ZoomControlOutputEvent;
|
|
142
|
+
userZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['userZoomToAtInput']): ZoomControlOutputEvent;
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* State implementation for zoom animations and transitions.
|
|
@@ -149,15 +149,15 @@ export declare class ZoomAcceptingUserInputState extends TemplateState<ZoomEvent
|
|
|
149
149
|
export declare class ZoomTransitionState extends TemplateState<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping> {
|
|
150
150
|
constructor();
|
|
151
151
|
protected _eventReactions: EventReactions<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping>;
|
|
152
|
-
lockedOnObjectZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
153
|
-
lockedOnObjectZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
154
|
-
userZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
155
|
-
userZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
156
|
-
transitionZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
157
|
-
transitionZoomByAtCenterInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
158
|
-
transitionZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
159
|
-
transitionZoomToAtCenterInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
160
|
-
transitionZoomToAtWorldInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
152
|
+
lockedOnObjectZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['lockedOnObjectZoomByAtInput']): ZoomControlOutputEvent;
|
|
153
|
+
lockedOnObjectZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['lockedOnObjectZoomToAtInput']): ZoomControlOutputEvent;
|
|
154
|
+
userZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['userZoomByAtInput']): ZoomControlOutputEvent;
|
|
155
|
+
userZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['userZoomToAtInput']): ZoomControlOutputEvent;
|
|
156
|
+
transitionZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['transitionZoomByAtInput']): ZoomControlOutputEvent;
|
|
157
|
+
transitionZoomByAtCenterInput(context: BaseContext, payload: ZoomEventPayloadMapping['transitionZoomByAtCenterInput']): ZoomControlOutputEvent;
|
|
158
|
+
transitionZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['transitionZoomToAtInput']): ZoomControlOutputEvent;
|
|
159
|
+
transitionZoomToAtCenterInput(context: BaseContext, payload: ZoomEventPayloadMapping['transitionZoomToAtCenterInput']): ZoomControlOutputEvent;
|
|
160
|
+
transitionZoomToAtWorldInput(context: BaseContext, payload: ZoomEventPayloadMapping['transitionZoomToAtWorldInput']): ZoomControlOutputEvent;
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* State implementation for camera locked to follow an object with zoom.
|
|
@@ -167,10 +167,10 @@ export declare class ZoomTransitionState extends TemplateState<ZoomEventPayloadM
|
|
|
167
167
|
export declare class ZoomLockedOnObjectState extends TemplateState<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping> {
|
|
168
168
|
constructor();
|
|
169
169
|
protected _eventReactions: EventReactions<ZoomEventPayloadMapping, BaseContext, ZoomControlStates, ZoomControlOutputMapping>;
|
|
170
|
-
lockedOnObjectZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
171
|
-
lockedOnObjectZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
172
|
-
userZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
173
|
-
userZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping[
|
|
170
|
+
lockedOnObjectZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['lockedOnObjectZoomByAtInput']): ZoomControlOutputEvent;
|
|
171
|
+
lockedOnObjectZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['lockedOnObjectZoomToAtInput']): ZoomControlOutputEvent;
|
|
172
|
+
userZoomByAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['userZoomByAtInput']): ZoomControlOutputEvent;
|
|
173
|
+
userZoomToAtInput(context: BaseContext, payload: ZoomEventPayloadMapping['userZoomToAtInput']): ZoomControlOutputEvent;
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
176
|
* State machine controlling zoom input flow and animations.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Point } from '@ue-too/math';
|
|
2
|
+
import { CameraMux, CameraMuxPanOutput, CameraMuxRotationOutput, CameraMuxZoomOutput } from './interface';
|
|
3
3
|
/**
|
|
4
4
|
* Stateless camera input multiplexer that always allows inputs to pass through.
|
|
5
5
|
* This is the simplest {@link CameraMux} implementation with no filtering or state management.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
1
|
+
import type { BaseContext } from '@ue-too/being';
|
|
2
|
+
import { Point } from '@ue-too/math';
|
|
3
|
+
import { ObservableBoardCamera } from '../interface';
|
|
4
|
+
import { PanHandlerConfig } from './pan-handler';
|
|
5
|
+
import type { RotationHandlerConfig } from './rotation-handler';
|
|
6
|
+
import { ZoomHandlerConfig } from './zoom-handler';
|
|
7
7
|
/**
|
|
8
8
|
* Configuration for camera rig behavior combining pan, zoom, and rotation settings.
|
|
9
9
|
* Composed from individual handler configs.
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*
|
|
25
25
|
* @module
|
|
26
26
|
*/
|
|
27
|
-
export * from
|
|
28
|
-
export * from
|
|
29
|
-
export * from
|
|
30
|
-
export * from
|
|
27
|
+
export * from './zoom-handler';
|
|
28
|
+
export * from './pan-handler';
|
|
29
|
+
export * from './rotation-handler';
|
|
30
|
+
export * from './camera-rig';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Point } from
|
|
2
|
-
import { BoardCamera } from
|
|
1
|
+
import { Point } from '@ue-too/math';
|
|
2
|
+
import { BoardCamera } from '../interface';
|
|
3
3
|
/**
|
|
4
4
|
* Combined configuration for pan handler behavior, merging restriction and clamping settings.
|
|
5
5
|
*
|