@expofp/renderer 1.5.0 → 2.0.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/dist/index.d.ts +90 -32
- package/dist/index.js +645 -319
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare interface ControlsAPI {
|
|
|
48
48
|
* @param immediate If true, applies the change immediately without animation
|
|
49
49
|
* @returns Promise that resolves when the zoom animation completes
|
|
50
50
|
*/
|
|
51
|
-
zoomBy(zoom: number, immediate?: boolean)
|
|
51
|
+
zoomBy: (zoom: number, immediate?: boolean) => Promise<void>;
|
|
52
52
|
/**
|
|
53
53
|
* Zooms the camera to fit the given rectangle.
|
|
54
54
|
* @param rect Rectangle to zoom to in SVG coordinates
|
|
@@ -56,7 +56,7 @@ export declare interface ControlsAPI {
|
|
|
56
56
|
* @param immediate If true, applies the change immediately without animation
|
|
57
57
|
* @returns Promise that resolves when the zoom animation completes
|
|
58
58
|
*/
|
|
59
|
-
zoomTo(rect: Rect, options?: Partial<ZoomToOptions>, immediate?: boolean)
|
|
59
|
+
zoomTo: (rect: Rect, options?: Partial<ZoomToOptions>, immediate?: boolean) => Promise<void>;
|
|
60
60
|
/**
|
|
61
61
|
* Pans the camera by the given offset in SVG space.
|
|
62
62
|
* @param x X offset in SVG space
|
|
@@ -64,7 +64,7 @@ export declare interface ControlsAPI {
|
|
|
64
64
|
* @param immediate If true, applies the change immediately without animation
|
|
65
65
|
* @returns Promise that resolves when the pan animation completes
|
|
66
66
|
*/
|
|
67
|
-
panBy(x: number, y: number, immediate?: boolean)
|
|
67
|
+
panBy: (x: number, y: number, immediate?: boolean) => Promise<void>;
|
|
68
68
|
/**
|
|
69
69
|
* Pans the camera to the given coordinates in SVG space.
|
|
70
70
|
* @param x X coordinate in SVG space
|
|
@@ -72,7 +72,7 @@ export declare interface ControlsAPI {
|
|
|
72
72
|
* @param immediate If true, applies the change immediately without animation
|
|
73
73
|
* @returns Promise that resolves when the pan animation completes
|
|
74
74
|
*/
|
|
75
|
-
panTo(x: number, y: number, immediate?: boolean)
|
|
75
|
+
panTo: (x: number, y: number, immediate?: boolean) => Promise<void>;
|
|
76
76
|
/**
|
|
77
77
|
* Rolls the camera by the given angle in degrees.
|
|
78
78
|
* Note: This method won't work if {@link ControlsAPI.handlers | handlers.roll} is disabled.
|
|
@@ -80,7 +80,7 @@ export declare interface ControlsAPI {
|
|
|
80
80
|
* @param immediate If true, applies the change immediately without animation
|
|
81
81
|
* @returns Promise that resolves when the roll animation completes
|
|
82
82
|
*/
|
|
83
|
-
rollBy(angle: number, immediate?: boolean)
|
|
83
|
+
rollBy: (angle: number, immediate?: boolean) => Promise<void>;
|
|
84
84
|
/**
|
|
85
85
|
* Rolls the camera to the given angle in degrees.
|
|
86
86
|
* Note: This method won't work if {@link ControlsAPI.handlers | handlers.roll} is disabled.
|
|
@@ -88,7 +88,7 @@ export declare interface ControlsAPI {
|
|
|
88
88
|
* @param immediate If true, applies the change immediately without animation
|
|
89
89
|
* @returns Promise that resolves when the roll animation completes
|
|
90
90
|
*/
|
|
91
|
-
rollTo(angle: number, immediate?: boolean)
|
|
91
|
+
rollTo: (angle: number, immediate?: boolean) => Promise<void>;
|
|
92
92
|
/**
|
|
93
93
|
* Pitches the camera by the given angle in degrees.
|
|
94
94
|
* Positive angles increase pitch, negative angles decrease pitch.
|
|
@@ -97,7 +97,7 @@ export declare interface ControlsAPI {
|
|
|
97
97
|
* @param immediate If true, applies the change immediately without animation
|
|
98
98
|
* @returns Promise that resolves when the pitch animation completes
|
|
99
99
|
*/
|
|
100
|
-
pitchBy(angle: number, immediate?: boolean)
|
|
100
|
+
pitchBy: (angle: number, immediate?: boolean) => Promise<void>;
|
|
101
101
|
/**
|
|
102
102
|
* Pitches the camera to the given angle in degrees.
|
|
103
103
|
* The angle is clamped to the 0-90 degree range.
|
|
@@ -106,30 +106,30 @@ export declare interface ControlsAPI {
|
|
|
106
106
|
* @param immediate If true, applies the change immediately without animation
|
|
107
107
|
* @returns Promise that resolves when the pitch animation completes
|
|
108
108
|
*/
|
|
109
|
-
pitchTo(angle: number, immediate?: boolean)
|
|
109
|
+
pitchTo: (angle: number, immediate?: boolean) => Promise<void>;
|
|
110
110
|
/**
|
|
111
111
|
* Resets the camera to the starting state.
|
|
112
112
|
* @param options Configuration for which handlers to reset
|
|
113
113
|
* @param immediate If true, applies the change immediately without animation
|
|
114
114
|
* @returns Promise that resolves when all reset animations complete
|
|
115
115
|
*/
|
|
116
|
-
resetCamera(options?: Partial<ResetCameraOptions>, immediate?: boolean)
|
|
116
|
+
resetCamera: (options?: Partial<ResetCameraOptions>, immediate?: boolean) => Promise<void>;
|
|
117
117
|
/**
|
|
118
118
|
* Configures smooth time values for camera operations.
|
|
119
119
|
* @param options Partial configuration object with time values in seconds
|
|
120
120
|
*/
|
|
121
|
-
configure(options: Partial<ConfigureOptions>)
|
|
121
|
+
configure: (options: Partial<ConfigureOptions>) => void;
|
|
122
122
|
/**
|
|
123
123
|
* Sets the camera bounds to restrict camera movement.
|
|
124
124
|
* Note: This method must be called after the viewport is initialized by `renderer.start()`.
|
|
125
125
|
* @param rect Rectangle in SVG coordinates defining the camera boundary or `undefined` to remove the boundary
|
|
126
126
|
*/
|
|
127
|
-
setCameraBounds(rect?: Rect)
|
|
127
|
+
setCameraBounds: (rect?: Rect) => void;
|
|
128
128
|
/**
|
|
129
129
|
* Gets the current camera state.
|
|
130
130
|
* @returns Camera state object with center, zoom, roll, pitch, and ptScale
|
|
131
131
|
*/
|
|
132
|
-
getCameraState()
|
|
132
|
+
getCameraState: () => CameraState;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
@@ -170,9 +170,27 @@ export declare type EventHandler<Payload> = (payload: Payload) => void;
|
|
|
170
170
|
* Public API for interacting with the event system
|
|
171
171
|
*/
|
|
172
172
|
export declare interface EventsAPI {
|
|
173
|
+
/**
|
|
174
|
+
* Add an event listener for a specific event
|
|
175
|
+
* @param event - The event to listen for
|
|
176
|
+
* @param handler - The handler to call when the event is emitted
|
|
177
|
+
*/
|
|
173
178
|
addEventListener<E extends keyof EngineEvents>(event: E, handler: EventHandler<EngineEvents[E]>): void;
|
|
179
|
+
/**
|
|
180
|
+
* Remove an event listener for a specific event
|
|
181
|
+
* @param event - The event to remove the listener for
|
|
182
|
+
* @param handler - The handler to remove
|
|
183
|
+
*/
|
|
174
184
|
removeEventListener<E extends keyof EngineEvents>(event: E, handler: EventHandler<EngineEvents[E]>): void;
|
|
185
|
+
/**
|
|
186
|
+
* Check if there are any listeners for a specific event
|
|
187
|
+
* @param event - The event to check
|
|
188
|
+
* @returns true if there are listeners, false otherwise
|
|
189
|
+
*/
|
|
175
190
|
hasListeners<E extends keyof EngineEvents>(event: E): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Clear all event listeners
|
|
193
|
+
*/
|
|
176
194
|
clear(): void;
|
|
177
195
|
}
|
|
178
196
|
|
|
@@ -401,12 +419,17 @@ export declare class Renderer {
|
|
|
401
419
|
private viewportSystem;
|
|
402
420
|
private interactionsSystem;
|
|
403
421
|
private controlsSystem;
|
|
422
|
+
private controlsAPI?;
|
|
423
|
+
private eventsAPI?;
|
|
424
|
+
private viewportAPI?;
|
|
404
425
|
private clock;
|
|
405
426
|
private renderer;
|
|
406
|
-
private
|
|
407
|
-
private needsRedraw;
|
|
427
|
+
private visibleRectValue?;
|
|
408
428
|
private memoryInfoExtension;
|
|
409
|
-
private memoryInfo
|
|
429
|
+
private memoryInfo?;
|
|
430
|
+
private initialized;
|
|
431
|
+
private disposed;
|
|
432
|
+
private needsRedraw;
|
|
410
433
|
/**
|
|
411
434
|
* @param opts {@link RendererOptions}
|
|
412
435
|
*/
|
|
@@ -419,6 +442,10 @@ export declare class Renderer {
|
|
|
419
442
|
* {@link EventsAPI} instance for subscribing to internal events
|
|
420
443
|
*/
|
|
421
444
|
get events(): EventsAPI;
|
|
445
|
+
/**
|
|
446
|
+
* {@link ViewportAPI} instance for view transforms and external transforms.
|
|
447
|
+
*/
|
|
448
|
+
get viewport(): ViewportAPI;
|
|
422
449
|
/**
|
|
423
450
|
* Optional sub-rectangle of the viewport that is used for positioning scene's viewbox
|
|
424
451
|
*/
|
|
@@ -433,34 +460,37 @@ export declare class Renderer {
|
|
|
433
460
|
get context(): WebGLRenderer;
|
|
434
461
|
/* Excluded from this release type: size */
|
|
435
462
|
/**
|
|
436
|
-
*
|
|
437
|
-
*
|
|
463
|
+
* Returns true if the renderer is in external mode, meaning that webgl context is managed outside of the renderer
|
|
464
|
+
* (for example, when using Mapbox GL JS as a host context). In this mode renderer will not clear the canvas before
|
|
465
|
+
* rendering, and will not automatically compute scene and camera transformations. Clients are responsible for setting
|
|
466
|
+
* the matrices manually by using {@link Renderer.viewport} methods.
|
|
438
467
|
*/
|
|
439
|
-
|
|
468
|
+
get isExternalMode(): boolean;
|
|
440
469
|
/**
|
|
441
|
-
*
|
|
442
|
-
|
|
470
|
+
* Returns true if the renderer is initialized, meaning that the viewport and scene have been set up.
|
|
471
|
+
*/
|
|
472
|
+
get isInitialized(): boolean;
|
|
473
|
+
/**
|
|
474
|
+
* Returns true if the renderer is disposed, meaning that all WebGL resources have been released.
|
|
443
475
|
*/
|
|
444
|
-
|
|
476
|
+
get isDisposed(): boolean;
|
|
445
477
|
/**
|
|
446
|
-
*
|
|
478
|
+
* Initializes viewport and scene with the given scene definition.
|
|
479
|
+
* Should be called once on startup. Repeated calls will produce console warnings.
|
|
447
480
|
* @param sceneDef {@link SceneDef} to render
|
|
448
|
-
* @param startLoop whether to start the rendering loop
|
|
449
481
|
*/
|
|
450
|
-
|
|
482
|
+
init(sceneDef: SceneDef): void;
|
|
483
|
+
/**
|
|
484
|
+
* Start the rendering loop
|
|
485
|
+
*/
|
|
486
|
+
start(): void;
|
|
451
487
|
/**
|
|
452
488
|
* Update the given defs to make them reflect the current state
|
|
453
489
|
* @param defs {@link RenderableDef} array to update
|
|
454
490
|
*/
|
|
455
491
|
update(...defs: RenderableDef[]): void;
|
|
456
492
|
/**
|
|
457
|
-
*
|
|
458
|
-
* @param point point in canvas space (relative to the canvas's top left corner), in css pixels
|
|
459
|
-
* @returns point in SVG space
|
|
460
|
-
*/
|
|
461
|
-
screenToSvg(point: Vector2Like): Vector2Like;
|
|
462
|
-
/**
|
|
463
|
-
* Main rendering loop
|
|
493
|
+
* Render a single frame
|
|
464
494
|
*/
|
|
465
495
|
render(): void;
|
|
466
496
|
/**
|
|
@@ -468,13 +498,21 @@ export declare class Renderer {
|
|
|
468
498
|
*/
|
|
469
499
|
stop(): void;
|
|
470
500
|
/**
|
|
471
|
-
* Dispose all WebGL resources
|
|
501
|
+
* Dispose all WebGL resources. This calls {@link Renderer.stop} internally.
|
|
502
|
+
* WARNING: This method is final and cannot be undone. Attempting to use the renderer after calling this method
|
|
503
|
+
* will result in a console warning and no-op methods. If you need to re-initialize the renderer, create a new instance.
|
|
472
504
|
*/
|
|
473
505
|
dispose(): void;
|
|
474
506
|
private resizeCanvasToDisplaySize;
|
|
475
507
|
private updateMemoryInfo;
|
|
476
508
|
private onContextLost;
|
|
477
509
|
private onContextRestored;
|
|
510
|
+
private initContext;
|
|
511
|
+
private assertNotDisposed;
|
|
512
|
+
private assertInitialized;
|
|
513
|
+
private assertNotInitialized;
|
|
514
|
+
private assertNotExternalMode;
|
|
515
|
+
private assertExternalMode;
|
|
478
516
|
}
|
|
479
517
|
|
|
480
518
|
/**
|
|
@@ -595,6 +633,26 @@ export declare interface UI {
|
|
|
595
633
|
memoryInfoPanel: HTMLDivElement;
|
|
596
634
|
}
|
|
597
635
|
|
|
636
|
+
/** Viewport system public API. */
|
|
637
|
+
export declare interface ViewportAPI {
|
|
638
|
+
/**
|
|
639
|
+
* Convert canvas coordinates (CSS pixels, relative to canvas top-left) to SVG coordinates.
|
|
640
|
+
* @param point point in canvas space (CSS pixels)
|
|
641
|
+
* @returns point in SVG coordinates or undefined if point is outside the SVG plane
|
|
642
|
+
*/
|
|
643
|
+
canvasToSvg: (point: Vector2Like) => Vector2Like | undefined;
|
|
644
|
+
/**
|
|
645
|
+
* Set static part of an svg -> px transform matrix
|
|
646
|
+
* @param staticTransformMatrix static transform matrix to apply to the scene
|
|
647
|
+
*/
|
|
648
|
+
setStaticTransform: (staticTransformMatrix: number[]) => void;
|
|
649
|
+
/**
|
|
650
|
+
* Set dynamic part of an svg -> px transform matrix. Should be called every frame.
|
|
651
|
+
* @param dynamicTransformMatrix dynamic transform matrix (changes every frame)
|
|
652
|
+
*/
|
|
653
|
+
setDynamicTransform: (dynamicTransformMatrix: number[]) => void;
|
|
654
|
+
}
|
|
655
|
+
|
|
598
656
|
/** Options for the {@link ControlsAPI.zoomTo} method. */
|
|
599
657
|
export declare interface ZoomToOptions {
|
|
600
658
|
/** Maximum zoom factor. */
|