@expofp/renderer 2.3.1 → 3.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 +62 -40
- package/dist/index.js +4147 -3881
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ export declare interface EngineEvents {
|
|
|
145
145
|
/** Mouse click */
|
|
146
146
|
"pointer:click": MouseEventData;
|
|
147
147
|
/** Viewport pixel to svg scale */
|
|
148
|
-
"viewport:ptscale":
|
|
148
|
+
"viewport:ptscale": PtScaleEventData;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
export declare type EventHandler<Payload> = (payload: Payload) => void;
|
|
@@ -294,10 +294,8 @@ export declare interface LineDef extends SharedDef {
|
|
|
294
294
|
export declare interface MouseEventData {
|
|
295
295
|
/** Original mouse event */
|
|
296
296
|
event: MouseEvent;
|
|
297
|
-
/**
|
|
298
|
-
|
|
299
|
-
/** Intersected defs */
|
|
300
|
-
defs: RenderableDef[];
|
|
297
|
+
/** Translated pointer data for each loaded scene */
|
|
298
|
+
data: PointWithinSceneData[];
|
|
301
299
|
}
|
|
302
300
|
|
|
303
301
|
/**
|
|
@@ -316,6 +314,16 @@ export declare interface PitchHandlerOptions {
|
|
|
316
314
|
maxPitch?: number;
|
|
317
315
|
}
|
|
318
316
|
|
|
317
|
+
/** Point within a scene coupled with the scene identifier and intersected defs */
|
|
318
|
+
export declare interface PointWithinSceneData {
|
|
319
|
+
/** Point in SVG/model coordinates. */
|
|
320
|
+
point: Vector2Like;
|
|
321
|
+
/** Identifier of the scene that contains the point. Undefined in case of default scene. */
|
|
322
|
+
sceneId?: string;
|
|
323
|
+
/** Intersected defs */
|
|
324
|
+
defs: RenderableDef[];
|
|
325
|
+
}
|
|
326
|
+
|
|
319
327
|
/** Polygon shape instance. */
|
|
320
328
|
export declare class Polygon {
|
|
321
329
|
private _indices;
|
|
@@ -367,6 +375,14 @@ export declare class Polygon {
|
|
|
367
375
|
private computeBoundingRect;
|
|
368
376
|
}
|
|
369
377
|
|
|
378
|
+
/** Data for ptScale events */
|
|
379
|
+
export declare interface PtScaleEventData {
|
|
380
|
+
/** Scene identifier, undefined for default scene */
|
|
381
|
+
sceneId?: string;
|
|
382
|
+
/** Pixel to SVG scale factor */
|
|
383
|
+
ptScale: number;
|
|
384
|
+
}
|
|
385
|
+
|
|
370
386
|
/** Rectangle shape instance. */
|
|
371
387
|
export declare class Rect {
|
|
372
388
|
/** Optional rotation of the rectangle. In radians, around center. Positive values rotate clockwise. */
|
|
@@ -433,19 +449,20 @@ export declare class Renderer {
|
|
|
433
449
|
readonly canvas: HTMLCanvasElement;
|
|
434
450
|
private ui?;
|
|
435
451
|
private gl?;
|
|
452
|
+
private ctx;
|
|
453
|
+
private clock;
|
|
454
|
+
private renderer;
|
|
455
|
+
private memoryInfoExtension;
|
|
456
|
+
private memoryInfo?;
|
|
436
457
|
private eventSystem;
|
|
437
458
|
private layerSystem;
|
|
438
459
|
private viewportSystem;
|
|
460
|
+
private updatesSystem;
|
|
439
461
|
private interactionsSystem;
|
|
440
|
-
private controlsSystem
|
|
462
|
+
private controlsSystem?;
|
|
441
463
|
private controlsAPI?;
|
|
442
464
|
private eventsAPI?;
|
|
443
465
|
private viewportAPI?;
|
|
444
|
-
private clock;
|
|
445
|
-
private renderer;
|
|
446
|
-
private visibleRectValue?;
|
|
447
|
-
private memoryInfoExtension;
|
|
448
|
-
private memoryInfo?;
|
|
449
466
|
private initialized;
|
|
450
467
|
private disposed;
|
|
451
468
|
private needsRedraw;
|
|
@@ -453,24 +470,27 @@ export declare class Renderer {
|
|
|
453
470
|
* @param opts {@link RendererOptions}
|
|
454
471
|
*/
|
|
455
472
|
constructor(opts: RendererOptions);
|
|
456
|
-
/**
|
|
457
|
-
* {@link ControlsAPI} instance for controlling the viewport
|
|
458
|
-
*/
|
|
459
|
-
get controls(): ControlsAPI;
|
|
460
473
|
/**
|
|
461
474
|
* {@link EventsAPI} instance for subscribing to internal events
|
|
462
475
|
*/
|
|
463
476
|
get events(): EventsAPI;
|
|
464
477
|
/**
|
|
465
|
-
* {@link
|
|
478
|
+
* {@link ControlsAPI} instance for controlling the viewport
|
|
479
|
+
*/
|
|
480
|
+
get controls(): ControlsAPI;
|
|
481
|
+
/**
|
|
482
|
+
* {@link ViewportAPI} instance for view transforms and coordinate conversion.
|
|
466
483
|
*/
|
|
467
484
|
get viewport(): ViewportAPI;
|
|
468
485
|
/**
|
|
469
|
-
* Optional sub-rectangle of the viewport
|
|
486
|
+
* Optional CSS-pixel sub-rectangle of the viewport used for positioning the scene's viewbox.
|
|
470
487
|
*/
|
|
471
488
|
get visibleRect(): Rect | undefined;
|
|
472
489
|
/**
|
|
473
|
-
*
|
|
490
|
+
* Sets the CSS-pixel visible sub-rectangle.
|
|
491
|
+
* Triggers a viewport transform recompute (and schedules a redraw) only if the renderer
|
|
492
|
+
* is already initialized and not disposed; otherwise the value is stored and applied on the
|
|
493
|
+
* next {@link init} or {@link addScene} call.
|
|
474
494
|
*/
|
|
475
495
|
set visibleRect(rect: Rect);
|
|
476
496
|
/**
|
|
@@ -482,7 +502,8 @@ export declare class Renderer {
|
|
|
482
502
|
* Returns true if the renderer is in external mode, meaning that webgl context is managed outside of the renderer
|
|
483
503
|
* (for example, when using Mapbox GL JS as a host context). In this mode renderer will not clear the canvas before
|
|
484
504
|
* rendering, and will not automatically compute scene and camera transformations. Clients are responsible for setting
|
|
485
|
-
* the
|
|
505
|
+
* the transform matrix manually by using {@link SceneDef.staticTransform} and passing camera projection matrix
|
|
506
|
+
* to {@link render} as an optional argument.
|
|
486
507
|
*/
|
|
487
508
|
get isExternalMode(): boolean;
|
|
488
509
|
/**
|
|
@@ -498,20 +519,29 @@ export declare class Renderer {
|
|
|
498
519
|
* Should be called once on startup. Repeated calls will produce console warnings.
|
|
499
520
|
* @param sceneDef {@link SceneDef} to render
|
|
500
521
|
*/
|
|
501
|
-
init(sceneDef
|
|
522
|
+
init(sceneDef?: SceneDef): void;
|
|
523
|
+
/**
|
|
524
|
+
* Add a scene to the renderer. Note that this method is untested in internal mode. Use {@link Renderer.init} instead.
|
|
525
|
+
* @param sceneDef {@link SceneDef} to render
|
|
526
|
+
* @param sceneId identifier of the scene (map key)
|
|
527
|
+
*/
|
|
528
|
+
addScene(sceneDef: SceneDef, sceneId: string): void;
|
|
502
529
|
/**
|
|
503
530
|
* Start the rendering loop
|
|
504
531
|
*/
|
|
505
532
|
start(): void;
|
|
506
533
|
/**
|
|
507
|
-
* Update the given defs to make them reflect the current state
|
|
534
|
+
* Update the given defs to make them reflect the current state.
|
|
535
|
+
* Defs are queued for processing and will be applied during the next render frame,
|
|
536
|
+
* with frustum culling deferring off-screen text and image updates.
|
|
508
537
|
* @param defs {@link RenderableDef} array to update
|
|
509
538
|
*/
|
|
510
539
|
update(...defs: RenderableDef[]): void;
|
|
511
540
|
/**
|
|
512
541
|
* Render a single frame
|
|
542
|
+
* @param cameraProjection optional camera projection matrix. Ignored in internal mode, required in external mode.
|
|
513
543
|
*/
|
|
514
|
-
render(): void;
|
|
544
|
+
render(cameraProjection?: number[]): void;
|
|
515
545
|
/**
|
|
516
546
|
* Stop the rendering loop
|
|
517
547
|
*/
|
|
@@ -522,16 +552,13 @@ export declare class Renderer {
|
|
|
522
552
|
* will result in a console warning and no-op methods. If you need to re-initialize the renderer, create a new instance.
|
|
523
553
|
*/
|
|
524
554
|
dispose(): void;
|
|
555
|
+
private initScene;
|
|
525
556
|
private resizeCanvasToDisplaySize;
|
|
526
|
-
private
|
|
557
|
+
private createRendererContext;
|
|
527
558
|
private onContextLost;
|
|
528
559
|
private onContextRestored;
|
|
529
560
|
private initStatsContext;
|
|
530
|
-
private
|
|
531
|
-
private assertInitialized;
|
|
532
|
-
private assertNotInitialized;
|
|
533
|
-
private assertNotExternalMode;
|
|
534
|
-
private assertExternalMode;
|
|
561
|
+
private updateMemoryInfo;
|
|
535
562
|
}
|
|
536
563
|
|
|
537
564
|
/**
|
|
@@ -576,6 +603,8 @@ export declare interface SceneDef {
|
|
|
576
603
|
viewbox: Rect;
|
|
577
604
|
/** Textures memory limit in megabytes */
|
|
578
605
|
memoryLimit?: number;
|
|
606
|
+
/** Static transform matrix */
|
|
607
|
+
staticTransform?: number[];
|
|
579
608
|
}
|
|
580
609
|
|
|
581
610
|
export declare type Shape = Rect | Polygon;
|
|
@@ -662,19 +691,12 @@ export declare interface ViewportAPI {
|
|
|
662
691
|
/**
|
|
663
692
|
* Convert canvas coordinates (CSS pixels, relative to canvas top-left) to SVG coordinates.
|
|
664
693
|
* @param point point in canvas space (CSS pixels)
|
|
665
|
-
* @returns
|
|
666
|
-
*/
|
|
667
|
-
canvasToSvg: (point: Vector2Like) => Vector2Like | undefined;
|
|
668
|
-
/**
|
|
669
|
-
* Set static part of an svg -> px transform matrix
|
|
670
|
-
* @param staticTransformMatrix static transform matrix to apply to the scene
|
|
671
|
-
*/
|
|
672
|
-
setStaticTransform: (staticTransformMatrix: number[]) => void;
|
|
673
|
-
/**
|
|
674
|
-
* Set dynamic part of an svg -> px transform matrix. Should be called every frame.
|
|
675
|
-
* @param dynamicTransformMatrix dynamic transform matrix (changes every frame)
|
|
694
|
+
* @returns Array of points in SVG coordinates of all loaded scenes
|
|
676
695
|
*/
|
|
677
|
-
|
|
696
|
+
canvasToSvg: (point: Vector2Like) => {
|
|
697
|
+
point: Vector2Like;
|
|
698
|
+
sceneId?: string;
|
|
699
|
+
}[];
|
|
678
700
|
/**
|
|
679
701
|
* Set the maximum zoom factor. Default is 35.
|
|
680
702
|
* @param maxZoom Maximum zoom factor
|