@micrio/client 7.1.10 → 7.3.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 +2 -2
- package/micrio.core.min.js +2 -2
- package/micrio.min.d.ts +1764 -1300
- package/micrio.min.js +3 -3
- package/package.json +1 -1
package/micrio.min.d.ts
CHANGED
|
@@ -7,12 +7,13 @@ declare module '@micrio/client' {
|
|
|
7
7
|
* This data is created in the [Micrio editor](https://dash.micr.io/), and published as static JSON file per image.
|
|
8
8
|
*/
|
|
9
9
|
export namespace Models {
|
|
10
|
-
export
|
|
10
|
+
export interface I18n<T> {
|
|
11
11
|
[lang: string]: T;
|
|
12
|
-
}
|
|
13
|
-
export
|
|
12
|
+
}
|
|
13
|
+
export interface RevisionType {
|
|
14
14
|
[key: string]: number;
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
|
+
|
|
16
17
|
export namespace Camera {
|
|
17
18
|
/** A numeric array or Float64Array used for camera geometry. */
|
|
18
19
|
type CameraArray = number[] | Float64Array;
|
|
@@ -21,12 +22,12 @@ declare module '@micrio/client' {
|
|
|
21
22
|
/** Coordinate tuple, [x, y, scale] */
|
|
22
23
|
type Coords = [number, number, number?] | Float64Array;
|
|
23
24
|
/** A 360 vector for use in Spaces */
|
|
24
|
-
|
|
25
|
+
interface Vector {
|
|
25
26
|
direction: number;
|
|
26
27
|
distanceX: number;
|
|
27
28
|
distanceY: number;
|
|
28
|
-
}
|
|
29
|
-
type TimingFunction =
|
|
29
|
+
}
|
|
30
|
+
type TimingFunction = 'ease' | 'ease-in' | 'ease-out' | 'linear';
|
|
30
31
|
interface AnimationOptions {
|
|
31
32
|
/** Animation duration in ms */
|
|
32
33
|
duration?: number;
|
|
@@ -38,6 +39,7 @@ declare module '@micrio/client' {
|
|
|
38
39
|
timingFunction?: TimingFunction;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
|
|
41
43
|
export namespace Embeds {
|
|
42
44
|
interface EmbedOptions {
|
|
43
45
|
/** The embed opacity */
|
|
@@ -47,9 +49,10 @@ declare module '@micrio/client' {
|
|
|
47
49
|
/** The embed will have a minimal memory footprint, without its own camera */
|
|
48
50
|
asImage?: boolean;
|
|
49
51
|
/** Fit the embed's original size into the specified area. Defaults to 'stretch' */
|
|
50
|
-
fit?:
|
|
52
|
+
fit?: 'contain' | 'cover' | 'stretch';
|
|
51
53
|
}
|
|
52
54
|
}
|
|
55
|
+
|
|
53
56
|
export namespace Attributes {
|
|
54
57
|
/**
|
|
55
58
|
* Rendering mode for the `data-embeds-inside-gl` attribute:
|
|
@@ -60,9 +63,9 @@ declare module '@micrio/client' {
|
|
|
60
63
|
type EmbedGLMode = 'auto' | 'true' | 'false';
|
|
61
64
|
interface MicrioCustomAttributes {
|
|
62
65
|
/** The image ID */
|
|
63
|
-
|
|
66
|
+
id?: string;
|
|
64
67
|
/** The data language code to use. Default: 'en' */
|
|
65
|
-
|
|
68
|
+
lang?: string;
|
|
66
69
|
/** For custom hosted Micrio images, specify the root URL. Default: Based on image */
|
|
67
70
|
'data-path'?: string;
|
|
68
71
|
/** Set this to 'cover' to start the image using the full viewport. Default: undefined */
|
|
@@ -70,7 +73,7 @@ declare module '@micrio/client' {
|
|
|
70
73
|
/** The user cannot zoom out further than the full viewport. Default: undefined */
|
|
71
74
|
'data-coverlimit'?: boolean;
|
|
72
75
|
/** Only start loading the image when it's been scrolled into the user's view. Default: false */
|
|
73
|
-
|
|
76
|
+
lazyload?: boolean;
|
|
74
77
|
/** Do not load any metadata (markers, tours, etc). Default: false */
|
|
75
78
|
'data-skipmeta'?: boolean;
|
|
76
79
|
/** Simulate an <img/> element. No logo, loader bar, and no event listeners. Default: false */
|
|
@@ -130,9 +133,9 @@ declare module '@micrio/client' {
|
|
|
130
133
|
/** The minimap width in pixels. Default: 200 */
|
|
131
134
|
'data-minimap-width'?: number;
|
|
132
135
|
/** All audio will be disabled if this attribute is present. */
|
|
133
|
-
|
|
136
|
+
muted?: boolean;
|
|
134
137
|
/** The general sound volume for music/sfx (between 0 and 1). Default: 1 */
|
|
135
|
-
|
|
138
|
+
volume?: number;
|
|
136
139
|
/** Fade music to this volume while other audio plays (between 0 and 1). Default: 0 */
|
|
137
140
|
'data-mutedvolume'?: number;
|
|
138
141
|
/** How embedded images/videos are rendered. `'auto'` (default, same as omitting
|
|
@@ -152,6 +155,7 @@ declare module '@micrio/client' {
|
|
|
152
155
|
'data-contextmenu-crop'?: boolean;
|
|
153
156
|
}
|
|
154
157
|
}
|
|
158
|
+
|
|
155
159
|
export namespace State {
|
|
156
160
|
/** Popover interface state type */
|
|
157
161
|
interface PopoverType {
|
|
@@ -175,9 +179,10 @@ declare module '@micrio/client' {
|
|
|
175
179
|
portrait: boolean;
|
|
176
180
|
}
|
|
177
181
|
}
|
|
182
|
+
|
|
178
183
|
/** Assets (audio, video, images) */
|
|
179
184
|
export namespace Assets {
|
|
180
|
-
|
|
185
|
+
interface BaseAsset {
|
|
181
186
|
/** The asset title (not filename) */
|
|
182
187
|
title: string;
|
|
183
188
|
/** The asset file name */
|
|
@@ -188,7 +193,7 @@ declare module '@micrio/client' {
|
|
|
188
193
|
size: number;
|
|
189
194
|
/** Created */
|
|
190
195
|
uploaded: number;
|
|
191
|
-
}
|
|
196
|
+
}
|
|
192
197
|
type Audio = BaseAsset & {
|
|
193
198
|
/** The sample duration */
|
|
194
199
|
duration: number;
|
|
@@ -256,6 +261,7 @@ declare module '@micrio/client' {
|
|
|
256
261
|
};
|
|
257
262
|
type Subtitle = BaseAsset;
|
|
258
263
|
}
|
|
264
|
+
|
|
259
265
|
export namespace Spaces {
|
|
260
266
|
interface SpaceImage {
|
|
261
267
|
/** The Micrio ID */
|
|
@@ -309,6 +315,7 @@ declare module '@micrio/client' {
|
|
|
309
315
|
custom?: boolean;
|
|
310
316
|
}
|
|
311
317
|
}
|
|
318
|
+
|
|
312
319
|
/** OmniImages */
|
|
313
320
|
export namespace Omni {
|
|
314
321
|
interface Frame {
|
|
@@ -324,49 +331,50 @@ declare module '@micrio/client' {
|
|
|
324
331
|
};
|
|
325
332
|
}
|
|
326
333
|
}
|
|
334
|
+
|
|
327
335
|
/**
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
336
|
+
* # Base image data
|
|
337
|
+
*
|
|
338
|
+
* The MicrioData.ImageInfo.ImageInfo JSON data object, containing all basic image properties.
|
|
339
|
+
*
|
|
340
|
+
* The static image information, such as original resolution, image type, title, and all non-language specific **settings** ({@link ImageInfo.Settings}), such as initial viewport, camera behavior, and 360° settings.
|
|
341
|
+
*
|
|
342
|
+
* The only required field is `id`. If only the `id` field is specified, Micrio attempts to download the additional image data by itself (`info.json`), published by the Micrio servers. This data will also include image title, and any custom viewing settings set in the image editor.
|
|
343
|
+
*
|
|
344
|
+
* This is a minimal accepted example:
|
|
345
|
+
*
|
|
346
|
+
* ```json
|
|
347
|
+
* {
|
|
348
|
+
* "id": "dzzLm",
|
|
349
|
+
* }
|
|
350
|
+
* ```
|
|
351
|
+
*
|
|
352
|
+
* If you have manually entered the image `width` and `height`, _it will not download_ the `info.json` file, assuming you have provided correct and complete data:
|
|
353
|
+
*
|
|
354
|
+
* ```json
|
|
355
|
+
* {
|
|
356
|
+
* "id": "dzzLm",
|
|
357
|
+
* "width": 41472,
|
|
358
|
+
* "height": 30219
|
|
359
|
+
* }
|
|
360
|
+
* ```
|
|
361
|
+
*
|
|
362
|
+
* Optionally, when using {@link HTMLMicrioElement} `<micr-io>` tag attributes, these will overwrite whatever is loaded from the server. So if in the Micrio editor you have enabled the fullscreen toggle button, you can disable it in your own HTML using `<micr-io data-fullscreen="false">`.
|
|
363
|
+
*
|
|
364
|
+
*
|
|
365
|
+
*/
|
|
358
366
|
export namespace ImageInfo {
|
|
359
367
|
/** A Micrio image's main static image data object */
|
|
360
|
-
|
|
368
|
+
interface ImageInfo {
|
|
361
369
|
/** The image id */
|
|
362
370
|
id: string;
|
|
363
371
|
/** The image base path URI, with a trailing `/`
|
|
364
372
|
* @default https://b.micr.io/
|
|
365
|
-
|
|
373
|
+
*/
|
|
366
374
|
path: string;
|
|
367
375
|
/** The Micrio version this image was created in
|
|
368
376
|
* @default autoloaded
|
|
369
|
-
|
|
377
|
+
*/
|
|
370
378
|
version: string;
|
|
371
379
|
/** Created date */
|
|
372
380
|
created?: number;
|
|
@@ -376,15 +384,15 @@ declare module '@micrio/client' {
|
|
|
376
384
|
revision?: RevisionType;
|
|
377
385
|
/** The original image width
|
|
378
386
|
* @default autoloaded
|
|
379
|
-
|
|
387
|
+
*/
|
|
380
388
|
width: number;
|
|
381
389
|
/** The original image height
|
|
382
390
|
* @default autoloaded
|
|
383
|
-
|
|
391
|
+
*/
|
|
384
392
|
height: number;
|
|
385
393
|
/** The original tile size in px
|
|
386
394
|
* @default 1024
|
|
387
|
-
|
|
395
|
+
*/
|
|
388
396
|
tileSize?: number;
|
|
389
397
|
/** Use an alternative image ID for the image tiles */
|
|
390
398
|
tilesId?: string;
|
|
@@ -416,7 +424,7 @@ declare module '@micrio/client' {
|
|
|
416
424
|
albumId?: string;
|
|
417
425
|
/** The 360 tour space ID */
|
|
418
426
|
spacesId?: string;
|
|
419
|
-
}
|
|
427
|
+
}
|
|
420
428
|
interface Organisation {
|
|
421
429
|
name: string;
|
|
422
430
|
slug: string;
|
|
@@ -428,7 +436,7 @@ declare module '@micrio/client' {
|
|
|
428
436
|
fontFamily?: string;
|
|
429
437
|
}
|
|
430
438
|
/** Micrio image settings */
|
|
431
|
-
|
|
439
|
+
interface Settings {
|
|
432
440
|
/** The starting viewport */
|
|
433
441
|
view?: Camera.View;
|
|
434
442
|
/** Restrict navigation to this viewport (`[x0, y0, width, height]`) */
|
|
@@ -437,7 +445,7 @@ declare module '@micrio/client' {
|
|
|
437
445
|
focus?: [number, number];
|
|
438
446
|
/** When opening the image without a predefined deeplink, open this */
|
|
439
447
|
start?: {
|
|
440
|
-
type:
|
|
448
|
+
type: 'marker' | 'markerTour' | 'tour' | 'page';
|
|
441
449
|
id: string;
|
|
442
450
|
};
|
|
443
451
|
/** Use a custom uri for the info json file */
|
|
@@ -547,7 +555,7 @@ declare module '@micrio/client' {
|
|
|
547
555
|
/** The clustered marker radius */
|
|
548
556
|
clusterMarkerRadius?: number;
|
|
549
557
|
/** Dark/light theme */
|
|
550
|
-
theme?:
|
|
558
|
+
theme?: 'dark' | 'light' | 'os';
|
|
551
559
|
/** Load a custom JS file with this image */
|
|
552
560
|
js?: {
|
|
553
561
|
/** The asset href */
|
|
@@ -600,7 +608,7 @@ declare module '@micrio/client' {
|
|
|
600
608
|
* uniform sampler2D u_image; // the render buffer texture
|
|
601
609
|
* varying vec2 v_texCoord; // the texture coordinate
|
|
602
610
|
* uniform float u_time; // elapsed time in seconds
|
|
603
|
-
|
|
611
|
+
*/
|
|
604
612
|
postProcessingFragmentShader?: string;
|
|
605
613
|
/** Watermark opacity, defaults to 0.075 */
|
|
606
614
|
watermarkOpacity?: number;
|
|
@@ -610,8 +618,8 @@ declare module '@micrio/client' {
|
|
|
610
618
|
noFollow?: boolean;
|
|
611
619
|
/** Split-screen: if false, the secondary image is display-only (no user interaction). */
|
|
612
620
|
secondaryInteractive?: boolean;
|
|
613
|
-
}
|
|
614
|
-
|
|
621
|
+
}
|
|
622
|
+
interface OmniSettings {
|
|
615
623
|
/** Number of frames */
|
|
616
624
|
frames: number;
|
|
617
625
|
/** Starting frame index */
|
|
@@ -626,7 +634,12 @@ declare module '@micrio/client' {
|
|
|
626
634
|
offsetX: number;
|
|
627
635
|
/** Put the labels on the side of the object */
|
|
628
636
|
sideLabels?: boolean;
|
|
629
|
-
/**
|
|
637
|
+
/**
|
|
638
|
+
* Which frame is 0deg rotation.
|
|
639
|
+
* @deprecated Read nowhere in this client, and exposed by no dashboard page — a legacy
|
|
640
|
+
* field the server still sends. Wiring it up has to change
|
|
641
|
+
* `omni-viewer.test.ts`'s "legacy-only omni settings" test.
|
|
642
|
+
*/
|
|
630
643
|
frontIndex?: number;
|
|
631
644
|
/** Layers */
|
|
632
645
|
layers?: {
|
|
@@ -640,19 +653,20 @@ declare module '@micrio/client' {
|
|
|
640
653
|
noDial?: boolean;
|
|
641
654
|
/** Show degrees on dial */
|
|
642
655
|
showDegrees?: boolean;
|
|
643
|
-
/**
|
|
656
|
+
/**
|
|
657
|
+
* Gallery is omni object photography over 2 axes.
|
|
658
|
+
* @deprecated Read nowhere in this client, and exposed by no dashboard page — a legacy
|
|
659
|
+
* field the server still sends. Wiring it up has to change
|
|
660
|
+
* `omni-viewer.test.ts`'s "legacy-only omni settings" test.
|
|
661
|
+
*/
|
|
644
662
|
twoAxes?: boolean;
|
|
645
|
-
/** Don't add key bindings for rotating */
|
|
663
|
+
/** Don't add key bindings for rotating; an omni with this set never hooks the keyboard */
|
|
646
664
|
noKeys?: boolean;
|
|
647
|
-
}
|
|
665
|
+
}
|
|
648
666
|
/** Image-wide marker settings */
|
|
649
|
-
|
|
667
|
+
interface MarkerSettings {
|
|
650
668
|
/** An image-wise custom marker icon */
|
|
651
669
|
markerIcon?: Assets.Image;
|
|
652
|
-
/** The default marker color */
|
|
653
|
-
markerColor?: string;
|
|
654
|
-
/** The default marker size in px */
|
|
655
|
-
markerSize?: string;
|
|
656
670
|
/** Zoom out when closing a marker */
|
|
657
671
|
zoomOutAfterClose?: boolean;
|
|
658
672
|
/** Relative speed factor when zooming out after close */
|
|
@@ -661,8 +675,6 @@ declare module '@micrio/client' {
|
|
|
661
675
|
showTitles?: boolean;
|
|
662
676
|
/** Don't print any marker titles at all */
|
|
663
677
|
noTitles?: boolean;
|
|
664
|
-
/** All markers are sized to their viewports */
|
|
665
|
-
viewportIsMarker?: boolean;
|
|
666
678
|
/** All marker embeds are printed in HTML, not WebGL */
|
|
667
679
|
embedsInHtml?: boolean;
|
|
668
680
|
/** Auto-start a marker tour when just opening marker */
|
|
@@ -689,9 +701,9 @@ declare module '@micrio/client' {
|
|
|
689
701
|
keepPopupsDuringTourTransitions?: boolean;
|
|
690
702
|
/** Optional custom uploaded icons */
|
|
691
703
|
customIcons?: Assets.Image[];
|
|
692
|
-
}
|
|
704
|
+
}
|
|
693
705
|
/** Custom interface settings */
|
|
694
|
-
|
|
706
|
+
interface UserInterfaceSettings {
|
|
695
707
|
controls?: {
|
|
696
708
|
/** Show the culture switch button if there are multiple available languages */
|
|
697
709
|
cultureSwitch?: boolean;
|
|
@@ -699,7 +711,7 @@ declare module '@micrio/client' {
|
|
|
699
711
|
serialTourNoTimeScrub?: boolean;
|
|
700
712
|
};
|
|
701
713
|
icons?: Partial<Record<IconName, string>>;
|
|
702
|
-
}
|
|
714
|
+
}
|
|
703
715
|
}
|
|
704
716
|
export interface Album {
|
|
705
717
|
/** The number of pages in this album */
|
|
@@ -722,15 +734,17 @@ declare module '@micrio/client' {
|
|
|
722
734
|
currentImage?: Writable<MicrioImage>;
|
|
723
735
|
}
|
|
724
736
|
/** Gallery configuration */
|
|
725
|
-
export
|
|
726
|
-
type
|
|
737
|
+
export interface GalleryConfig {
|
|
738
|
+
/** The gallery type; unset while a gallery config is still being collected from attributes. */
|
|
739
|
+
type?: 'swipe' | 'switch' | 'grid' | 'book3d';
|
|
727
740
|
startId?: string;
|
|
728
741
|
sort?: 'name' | '-name' | 'created' | '-created' | 'random';
|
|
729
742
|
isSpreads?: boolean;
|
|
730
743
|
coverPages?: number;
|
|
731
744
|
archive?: string;
|
|
732
745
|
archiveLayerOffset?: number;
|
|
733
|
-
revisions?: Record<string, Record<string,
|
|
746
|
+
revisions?: Record<string, Record<string, unknown>>;
|
|
747
|
+
/** Custom gallery settings JSON. */
|
|
734
748
|
settings?: Record<string, any>;
|
|
735
749
|
id?: string;
|
|
736
750
|
name?: string;
|
|
@@ -738,11 +752,12 @@ declare module '@micrio/client' {
|
|
|
738
752
|
clickable?: 'focus' | 'zoom' | false;
|
|
739
753
|
panZoom?: 'cells' | 'grid';
|
|
740
754
|
};
|
|
741
|
-
}
|
|
755
|
+
}
|
|
756
|
+
|
|
742
757
|
export namespace Grid {
|
|
743
758
|
/** Grid .focus() transition from current view */
|
|
744
|
-
type MarkerFocusTransition =
|
|
745
|
-
type GridSetTransition =
|
|
759
|
+
type MarkerFocusTransition = 'crossfade' | 'slide' | 'slide-horiz' | 'slide-vert' | 'slide-up' | 'slide-down' | 'slide-right' | 'slide-left' | 'swipe' | 'swipe-horiz' | 'swipe-vert' | 'swipe-up' | 'swipe-down' | 'swipe-right' | 'swipe-left' | 'behind' | 'behind-left' | 'behind-right';
|
|
760
|
+
type GridSetTransition = 'crossfade' | 'behind' | 'behind-delayed' | 'appear-delayed';
|
|
746
761
|
/** Virtual ImageInfo extension to support grid logic */
|
|
747
762
|
interface GridImage {
|
|
748
763
|
id: string;
|
|
@@ -769,76 +784,77 @@ declare module '@micrio/client' {
|
|
|
769
784
|
blur?: number;
|
|
770
785
|
}
|
|
771
786
|
}
|
|
787
|
+
|
|
772
788
|
/**
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
789
|
+
* # Image content data
|
|
790
|
+
*
|
|
791
|
+
* The image content {@link ImageData} JSON object, which is accessible as {@link MicrioImage.data} as the Writable store, and {@link MicrioImage.$data} for its current value.
|
|
792
|
+
*
|
|
793
|
+
* This JSON data includes, for all published languages for this image:
|
|
794
|
+
*
|
|
795
|
+
* * Markers
|
|
796
|
+
* * Marker tours
|
|
797
|
+
* * Video tours
|
|
798
|
+
* * Audio, music
|
|
799
|
+
* * In-image embeds
|
|
800
|
+
* * Custom menu screens and content pages
|
|
801
|
+
*
|
|
802
|
+
* To access the data of the current viewed image, use:
|
|
803
|
+
*
|
|
804
|
+
* ```js
|
|
805
|
+
* // The current shown image value of the .data store Writable
|
|
806
|
+
* const data = micrio.$current.$data;
|
|
807
|
+
*
|
|
808
|
+
* if(data) console.log(`The current image has ${data.markers.length} markers!`);
|
|
809
|
+
* else console.warn('The current image has no data set.');
|
|
810
|
+
* ```
|
|
811
|
+
*
|
|
812
|
+
* To subscribe to any data changes:
|
|
813
|
+
*
|
|
814
|
+
* ```js
|
|
815
|
+
* micrio.$current.data.subscribe(data => {
|
|
816
|
+
* console.log('Image has new or updated data!', data);
|
|
817
|
+
* })
|
|
818
|
+
* ```
|
|
819
|
+
*
|
|
820
|
+
* To set your own custom data:
|
|
821
|
+
*
|
|
822
|
+
* ```js
|
|
823
|
+
* micrio.$current.data.set({
|
|
824
|
+
* "markers": [
|
|
825
|
+
* {
|
|
826
|
+
* "i18n": {
|
|
827
|
+
* "en": {
|
|
828
|
+
* "title": "This is a test marker!"
|
|
829
|
+
* }
|
|
830
|
+
* },
|
|
831
|
+
* "x": .5,
|
|
832
|
+
* "y": .5
|
|
833
|
+
* }
|
|
834
|
+
* ]
|
|
835
|
+
* })
|
|
836
|
+
* ```
|
|
837
|
+
*
|
|
838
|
+
* Or to update an existing loaded data object:
|
|
839
|
+
*
|
|
840
|
+
* ```js
|
|
841
|
+
* micrio.$current.data.update(data => {
|
|
842
|
+
* data.markers.push({
|
|
843
|
+
* "i18n": {
|
|
844
|
+
* "en": {
|
|
845
|
+
* "title": "This is a newly added marker"
|
|
846
|
+
* }
|
|
847
|
+
* },
|
|
848
|
+
* "x": .6,
|
|
849
|
+
* "y": .5
|
|
850
|
+
* });
|
|
851
|
+
* return data;
|
|
852
|
+
* })
|
|
853
|
+
* ```
|
|
854
|
+
*/
|
|
839
855
|
export namespace ImageData {
|
|
840
856
|
/** The main data JSON structure */
|
|
841
|
-
|
|
857
|
+
interface ImageData {
|
|
842
858
|
/** V5+: Save revision */
|
|
843
859
|
revision?: RevisionType;
|
|
844
860
|
/** Localized image details */
|
|
@@ -862,7 +878,7 @@ declare module '@micrio/client' {
|
|
|
862
878
|
/** The music audio volume [0-1] (default: `1`) */
|
|
863
879
|
volume?: number;
|
|
864
880
|
};
|
|
865
|
-
}
|
|
881
|
+
}
|
|
866
882
|
interface ImageDetailsCultureData {
|
|
867
883
|
/** Optional lang-specific image title */
|
|
868
884
|
title?: string;
|
|
@@ -894,7 +910,7 @@ declare module '@micrio/client' {
|
|
|
894
910
|
embedDescription?: string;
|
|
895
911
|
}
|
|
896
912
|
/** A Marker */
|
|
897
|
-
|
|
913
|
+
interface Marker {
|
|
898
914
|
/** The marker ID */
|
|
899
915
|
id: string;
|
|
900
916
|
/** The relative marker X coordinate [0-1] */
|
|
@@ -915,9 +931,9 @@ declare module '@micrio/client' {
|
|
|
915
931
|
/** If an image has multiple layers, switch to this layer */
|
|
916
932
|
imageLayer?: number;
|
|
917
933
|
/** Content type, for displaying */
|
|
918
|
-
type?:
|
|
934
|
+
type?: 'default' | 'image' | 'audio' | 'video' | 'media' | 'link' | 'waypoint' | 'cluster';
|
|
919
935
|
/** Popup type */
|
|
920
|
-
popupType?:
|
|
936
|
+
popupType?: 'popup' | 'popover' | 'none' | 'micrioLink';
|
|
921
937
|
/** If type is area, this HTML embed will be used for the marker */
|
|
922
938
|
clickableArea?: Embed;
|
|
923
939
|
/** Custom marker tags which will be also used as classnames on the marker elements */
|
|
@@ -942,9 +958,9 @@ declare module '@micrio/client' {
|
|
|
942
958
|
onclick?: (m: ImageData.Marker) => void;
|
|
943
959
|
/** Additional options */
|
|
944
960
|
data?: MarkerData;
|
|
945
|
-
}
|
|
961
|
+
}
|
|
946
962
|
/** Optional individual marker settings */
|
|
947
|
-
|
|
963
|
+
interface MarkerData {
|
|
948
964
|
/** A custom marker icon image */
|
|
949
965
|
icon?: Assets.Image;
|
|
950
966
|
/** A predefined custom icon idx in MarkerSettings */
|
|
@@ -955,7 +971,7 @@ declare module '@micrio/client' {
|
|
|
955
971
|
noAnimate?: boolean;
|
|
956
972
|
/** Show the title below the marker
|
|
957
973
|
* @deprecated Use the main marker setting for this
|
|
958
|
-
|
|
974
|
+
*/
|
|
959
975
|
showTitle?: boolean;
|
|
960
976
|
/** Don't open a large image viewer/gallery on image click */
|
|
961
977
|
preventImageOpen?: boolean;
|
|
@@ -983,9 +999,9 @@ declare module '@micrio/client' {
|
|
|
983
999
|
/** When opening this marker inside a grid, resize the tile to this */
|
|
984
1000
|
gridSize?: number | string;
|
|
985
1001
|
/** Any other value is accepted */
|
|
986
|
-
[key: string]:
|
|
1002
|
+
[key: string]: unknown;
|
|
987
1003
|
};
|
|
988
|
-
}
|
|
1004
|
+
}
|
|
989
1005
|
/**
|
|
990
1006
|
* An embedded element inside the main image. This could be an image,
|
|
991
1007
|
* iframe embed, or simple empty HTML element (Spaces).
|
|
@@ -1015,7 +1031,7 @@ declare module '@micrio/client' {
|
|
|
1015
1031
|
/** Opacity */
|
|
1016
1032
|
opacity?: number;
|
|
1017
1033
|
/** Click interaction */
|
|
1018
|
-
clickAction?:
|
|
1034
|
+
clickAction?: 'markerId' | 'href';
|
|
1019
1035
|
/** Click action target */
|
|
1020
1036
|
clickTarget?: string;
|
|
1021
1037
|
/** Opens link in new window */
|
|
@@ -1052,8 +1068,8 @@ declare module '@micrio/client' {
|
|
|
1052
1068
|
}
|
|
1053
1069
|
/** The MicrioTour abstract shared class for both {@link MarkerTour} and {@link VideoTour}
|
|
1054
1070
|
* @abstract
|
|
1055
|
-
|
|
1056
|
-
|
|
1071
|
+
*/
|
|
1072
|
+
interface Tour {
|
|
1057
1073
|
/** The tour id */
|
|
1058
1074
|
id: string;
|
|
1059
1075
|
/** Localized tour culture data */
|
|
@@ -1064,9 +1080,9 @@ declare module '@micrio/client' {
|
|
|
1064
1080
|
cannotClose?: boolean;
|
|
1065
1081
|
/** Exit the tour on finish */
|
|
1066
1082
|
closeOnFinish?: boolean;
|
|
1067
|
-
}
|
|
1083
|
+
}
|
|
1068
1084
|
/** A single videotour timeline viewport */
|
|
1069
|
-
|
|
1085
|
+
interface VideoTourView {
|
|
1070
1086
|
/** Start time in seconds */
|
|
1071
1087
|
start: number;
|
|
1072
1088
|
/** End time in seconds */
|
|
@@ -1075,7 +1091,7 @@ declare module '@micrio/client' {
|
|
|
1075
1091
|
title?: string;
|
|
1076
1092
|
/** View rectangle */
|
|
1077
1093
|
rect: Camera.View;
|
|
1078
|
-
}
|
|
1094
|
+
}
|
|
1079
1095
|
interface VideoTourCultureData extends TourCultureData {
|
|
1080
1096
|
/** The tour duration in seconds */
|
|
1081
1097
|
duration: number;
|
|
@@ -1103,7 +1119,7 @@ declare module '@micrio/client' {
|
|
|
1103
1119
|
instance?: VideoTourInstance;
|
|
1104
1120
|
};
|
|
1105
1121
|
/** Timed events inside a {@link VideoTour} */
|
|
1106
|
-
|
|
1122
|
+
interface Event {
|
|
1107
1123
|
/** Start time in seconds */
|
|
1108
1124
|
start: number;
|
|
1109
1125
|
/** End time in seconds */
|
|
@@ -1116,7 +1132,7 @@ declare module '@micrio/client' {
|
|
|
1116
1132
|
id?: string;
|
|
1117
1133
|
/** The event is currently active */
|
|
1118
1134
|
active?: boolean;
|
|
1119
|
-
}
|
|
1135
|
+
}
|
|
1120
1136
|
/**
|
|
1121
1137
|
* A Micrio marker tour -- a sequence of markers, which the user can navigate
|
|
1122
1138
|
* through. This is created in the [Micrio editor](https://dash.micr.io/).
|
|
@@ -1152,7 +1168,7 @@ declare module '@micrio/client' {
|
|
|
1152
1168
|
goto?: (n: number) => void;
|
|
1153
1169
|
};
|
|
1154
1170
|
/** Auto generated metadata for marker tours */
|
|
1155
|
-
|
|
1171
|
+
interface MarkerTourStepInfo {
|
|
1156
1172
|
markerId: string;
|
|
1157
1173
|
micrioId: string;
|
|
1158
1174
|
duration: number;
|
|
@@ -1166,14 +1182,14 @@ declare module '@micrio/client' {
|
|
|
1166
1182
|
/** Media has ended */
|
|
1167
1183
|
ended?: boolean;
|
|
1168
1184
|
hasSubtitle?: boolean;
|
|
1169
|
-
}
|
|
1185
|
+
}
|
|
1170
1186
|
interface MenuPageButton {
|
|
1171
1187
|
/** Localized button title */
|
|
1172
1188
|
i18nTitle: {
|
|
1173
1189
|
[key: string]: string;
|
|
1174
1190
|
};
|
|
1175
1191
|
/** Button action type */
|
|
1176
|
-
type:
|
|
1192
|
+
type: 'close' | 'marker' | 'mtour' | 'vtour' | 'link';
|
|
1177
1193
|
/** The action value */
|
|
1178
1194
|
action?: string;
|
|
1179
1195
|
/** Link opens in net tab */
|
|
@@ -1192,7 +1208,7 @@ declare module '@micrio/client' {
|
|
|
1192
1208
|
* websites, or direct links to opening a marker.
|
|
1193
1209
|
* This is created in the [Micrio editor](https://dash.micr.io/).
|
|
1194
1210
|
*/
|
|
1195
|
-
|
|
1211
|
+
interface Menu {
|
|
1196
1212
|
/** The menu ID */
|
|
1197
1213
|
id: string;
|
|
1198
1214
|
/** Localized culture data */
|
|
@@ -1211,20 +1227,20 @@ declare module '@micrio/client' {
|
|
|
1211
1227
|
image?: Assets.Image;
|
|
1212
1228
|
/** Custom page action buttons */
|
|
1213
1229
|
buttons?: MenuPageButton[];
|
|
1214
|
-
}
|
|
1230
|
+
}
|
|
1215
1231
|
}
|
|
1216
1232
|
/**
|
|
1217
1233
|
* A bundled image response from the `bundle.json` endpoint.
|
|
1218
1234
|
* Contains both info and data for one or more related images in a single response.
|
|
1219
1235
|
*/
|
|
1220
1236
|
export namespace ImageBundle {
|
|
1221
|
-
|
|
1237
|
+
interface BundleImage {
|
|
1222
1238
|
id: string;
|
|
1223
1239
|
info: ImageInfo.ImageInfo;
|
|
1224
1240
|
data?: ImageData.ImageData;
|
|
1225
1241
|
settings?: Partial<ImageInfo.Settings>;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1242
|
+
}
|
|
1243
|
+
interface BundleResponse {
|
|
1228
1244
|
images: BundleImage[];
|
|
1229
1245
|
organisation?: ImageInfo.Organisation;
|
|
1230
1246
|
spaces?: {
|
|
@@ -1233,52 +1249,53 @@ declare module '@micrio/client' {
|
|
|
1233
1249
|
}[];
|
|
1234
1250
|
album?: GalleryConfig;
|
|
1235
1251
|
tours?: ImageData.MarkerTour[];
|
|
1236
|
-
}
|
|
1252
|
+
}
|
|
1237
1253
|
}
|
|
1238
|
-
|
|
1254
|
+
|
|
1255
|
+
export type MicrioEvent<T = unknown> = Event & {
|
|
1239
1256
|
detail: T;
|
|
1240
1257
|
};
|
|
1241
1258
|
export interface MicrioEventDetails {
|
|
1242
1259
|
/** The main Micrio image is loaded and fully shown */
|
|
1243
|
-
|
|
1260
|
+
show: HTMLMicrioElement;
|
|
1244
1261
|
/** Before the ImageInfo settings are read, this event allows you to alter them */
|
|
1245
1262
|
'pre-info': ImageInfo.ImageInfo;
|
|
1246
1263
|
/** Before the ImageData contents are read, this event allows you to alter it */
|
|
1247
1264
|
'pre-data': {
|
|
1248
1265
|
[micrioId: string]: ImageData.ImageData;
|
|
1249
1266
|
};
|
|
1250
|
-
/** The main Micrio element has initialized and is being printed */
|
|
1251
|
-
|
|
1267
|
+
/** The main Micrio element has initialized and is being printed. The detail carries the parsed attribute options, which are partial. */
|
|
1268
|
+
print: Partial<ImageInfo.ImageInfo>;
|
|
1252
1269
|
/** Individual image data is loaded and Micrio will start rendering */
|
|
1253
|
-
|
|
1270
|
+
load: MicrioImage;
|
|
1254
1271
|
/** The user has switched available languages */
|
|
1255
1272
|
'lang-switch': string;
|
|
1256
1273
|
/** The camera has zoomed */
|
|
1257
|
-
|
|
1274
|
+
zoom: {
|
|
1258
1275
|
image: MicrioImage;
|
|
1259
1276
|
view: Camera.View;
|
|
1260
1277
|
};
|
|
1261
1278
|
/** The camera has moved */
|
|
1262
|
-
|
|
1279
|
+
move: {
|
|
1263
1280
|
image: MicrioImage;
|
|
1264
1281
|
view: Camera.View;
|
|
1265
1282
|
};
|
|
1266
1283
|
/** A frame has been drawn */
|
|
1267
|
-
|
|
1284
|
+
draw: void;
|
|
1268
1285
|
/** The <micr-io> element was resized */
|
|
1269
|
-
|
|
1286
|
+
resize: DOMRect;
|
|
1270
1287
|
/** The user has started panning */
|
|
1271
|
-
|
|
1288
|
+
panstart: void;
|
|
1272
1289
|
/** The user has stopped panning */
|
|
1273
|
-
|
|
1290
|
+
panend: {
|
|
1274
1291
|
duration: number;
|
|
1275
1292
|
movedX: number;
|
|
1276
1293
|
movedY: number;
|
|
1277
1294
|
};
|
|
1278
1295
|
/** The user has stopped pinching */
|
|
1279
|
-
|
|
1296
|
+
pinchstart: void;
|
|
1280
1297
|
/** The user has stopped pinching */
|
|
1281
|
-
|
|
1298
|
+
pinchend: {
|
|
1282
1299
|
duration: number;
|
|
1283
1300
|
movedX: number;
|
|
1284
1301
|
movedY: number;
|
|
@@ -1323,6 +1340,11 @@ declare module '@micrio/client' {
|
|
|
1323
1340
|
'autoplay-blocked': void;
|
|
1324
1341
|
/** Media was blocked from autoplaying */
|
|
1325
1342
|
'media-blocked': void;
|
|
1343
|
+
/** Media failed to play (bad source, network failure, decoder error) */
|
|
1344
|
+
'media-error': {
|
|
1345
|
+
error: Error;
|
|
1346
|
+
reason: string;
|
|
1347
|
+
};
|
|
1326
1348
|
/** Media has started playing */
|
|
1327
1349
|
'media-play': void;
|
|
1328
1350
|
/** Media has stopped playing */
|
|
@@ -1330,7 +1352,7 @@ declare module '@micrio/client' {
|
|
|
1330
1352
|
/** Media has ended */
|
|
1331
1353
|
'media-ended': void;
|
|
1332
1354
|
/** A media timeupdate tick */
|
|
1333
|
-
|
|
1355
|
+
timeupdate: number;
|
|
1334
1356
|
/** A custom popover page was opened */
|
|
1335
1357
|
'page-open': ImageData.Menu;
|
|
1336
1358
|
/** A custom popover page was closed */
|
|
@@ -1352,474 +1374,237 @@ declare module '@micrio/client' {
|
|
|
1352
1374
|
/** A split-screen secondary image has been closed */
|
|
1353
1375
|
'splitscreen-stop': MicrioImage;
|
|
1354
1376
|
/** When there is any user action, this event fires. Deferred and fires at a maximum rate of every 500ms */
|
|
1355
|
-
|
|
1377
|
+
update: string[];
|
|
1356
1378
|
}
|
|
1357
1379
|
export type MicrioEventMap = {
|
|
1358
1380
|
[K in keyof MicrioEventDetails]: MicrioEvent<MicrioEventDetails[K]>;
|
|
1359
1381
|
};
|
|
1360
|
-
}
|
|
1361
1382
|
|
|
1362
|
-
/** Names of all icons available in the Micrio UI icon library. */
|
|
1363
|
-
export type IconName = ('zoomIn' | 'zoomOut' | 'fullscreenEnter' | 'fullscreenLeave' | 'close' | 'next' | 'down' | 'prev' | 'up' | 'rotateLeft' | 'rotateRight' | 'play' | 'pause' | 'subtitles' | 'subtitlesOff' | 'muted' | 'unmuted' | 'playFilled' | 'a11y' | 'menu' | 'audio' | 'video' | 'share' | 'error' | 'chevronDown' | 'link' | 'linkExt' | 'ellipsisVertical' | 'image' | 'layerGroup');
|
|
1364
1383
|
|
|
1365
|
-
/**
|
|
1366
|
-
* # Store API in Micrio
|
|
1367
|
-
*
|
|
1368
|
-
* Micrio uses a custom store implementation (`$core/store`) for its internal state management.
|
|
1369
|
-
* The API is compatible with stores (writable, readable, get, subscribe).
|
|
1370
|
-
*
|
|
1371
|
-
* This means that changes in values can passively trigger state updates.
|
|
1372
|
-
*
|
|
1373
|
-
* There are two types of stores: {@link Readable}, which is read-only for the user, and {@link Writable} which can be updated or overridden by the user.
|
|
1374
|
-
*
|
|
1375
|
-
* Typically, for accessing the data directly instead of its store, Micrio offers `$` prefixes to any store properties:
|
|
1376
|
-
*
|
|
1377
|
-
* ```js
|
|
1378
|
-
* // This is the current active image in <micr-io> (.current is the store Writable)
|
|
1379
|
-
* const image = micrio.$current;
|
|
1380
|
-
*
|
|
1381
|
-
* // The current image ImageInfo value
|
|
1382
|
-
* const info = image.$info;
|
|
1383
|
-
*
|
|
1384
|
-
* // Log the current image resolution
|
|
1385
|
-
* console.log(`The current image is ${info.width} x ${info.height}px`);
|
|
1386
|
-
*
|
|
1387
|
-
* // The current CultureData value of the current MicrioImage
|
|
1388
|
-
* console.log(micrio.$current.$data);
|
|
1389
|
-
* ```
|
|
1390
|
-
*
|
|
1391
|
-
* An example of setting and subscribing to the {@link MicrioImage.data} writable store:
|
|
1392
|
-
*
|
|
1393
|
-
* ```js
|
|
1394
|
-
*
|
|
1395
|
-
* // Subscribe to any changes in its data (markers, tours, etc)
|
|
1396
|
-
* image.data.subscribe(data => {
|
|
1397
|
-
* // Data for this image been set, removed or changed
|
|
1398
|
-
* // This also triggers when the image data has been loaded from the server
|
|
1399
|
-
* if(data) console.log(`The image now has ${data.markers.length} markers`);
|
|
1400
|
-
* else console.log('The image data is now empty.');
|
|
1401
|
-
* });
|
|
1402
|
-
*
|
|
1403
|
-
* // Let's set the image data to something. It expects ImageData.
|
|
1404
|
-
* image.data.set({
|
|
1405
|
-
* markers: [{
|
|
1406
|
-
* "title": "My First Marker",
|
|
1407
|
-
* "x": .5,
|
|
1408
|
-
* "y": .5
|
|
1409
|
-
* }]
|
|
1410
|
-
* });
|
|
1411
|
-
*
|
|
1412
|
-
* // Immediately access the data
|
|
1413
|
-
* console.log('The data has been set to', image.$data);
|
|
1414
|
-
* ```
|
|
1415
|
-
*
|
|
1416
|
-
* ## List of stores used by Micrio:
|
|
1417
|
-
*
|
|
1418
|
-
* | Property | Direct value getter | Type | Description |
|
|
1419
|
-
* | ----------- | ----------- | ------------- | ---- |
|
|
1420
|
-
* | **`<micr-io>` Element** |||
|
|
1421
|
-
* | .{@link HTMLMicrioElement.current} | {@link HTMLMicrioElement.$current} | {@link Writable}<{@link MicrioImage}> | The current active and shown {@link MicrioImage} |
|
|
1422
|
-
* | **`<micr-io>.state` controller** |||
|
|
1423
|
-
* | .{@link State.Main.tour} | {@link State.Main.$tour} | {@link Writable}<{@link Models.ImageData.MarkerTour} | {@link Models.ImageData.VideoTour}> | The current running VideoTour or MarkerTour |
|
|
1424
|
-
* | .{@link State.Main.marker} | {@link State.Main.$marker} | {@link Writable}<{@link Models.ImageData.Marker}> | The current opened marker in the current opened {@link MicrioImage} |
|
|
1425
|
-
* **Individual `MicrioImage`** |||
|
|
1426
|
-
* | .{@link MicrioImage.info} | {@link MicrioImage.$info} | {@link Readable}<{@link Models.ImageInfo}> | The static image base info |
|
|
1427
|
-
* | .{@link MicrioImage.data} | {@link MicrioImage.$data} | {@link Writable}<{@link Models.ImageData}> | The image data (markers, tours, etc) |
|
|
1428
|
-
* **`MicrioImage.state` controller** |||
|
|
1429
|
-
* | .{@link State.Image.view} | {@link State.Image.$view} | {@link Writable}<{@link Models.Camera.View}> | The current viewport |
|
|
1430
|
-
* | .{@link State.Main.marker} | {@link State.Main.$marker} | {@link Writable}<{@link Models.ImageData.Marker}> | The current opened marker of this image |
|
|
1431
|
-
*
|
|
1432
|
-
*
|
|
1433
|
-
*/
|
|
1434
|
-
/** Callback type for receiving store value updates. */
|
|
1435
|
-
type Subscriber<T> = (value: T) => void;
|
|
1436
|
-
/** Cleanup function returned by store subscription methods. */
|
|
1437
|
-
type Unsubscriber = () => void;
|
|
1438
|
-
/** Transformer function used with Writable.update(). */
|
|
1439
|
-
type Updater<T> = (value: T) => T;
|
|
1440
|
-
/** A read-only store that emits value changes to subscribers. */
|
|
1441
|
-
export interface Readable<T> {
|
|
1442
|
-
subscribe(this: void, run: Subscriber<T>, invalidate?: (value?: T) => void): Unsubscriber;
|
|
1443
1384
|
}
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1385
|
+
|
|
1386
|
+
|
|
1387
|
+
/** Manages spatial audio, playlist playback, and user interaction for Micrio images. */
|
|
1388
|
+
export class MicrioAudioController {
|
|
1389
|
+
#private;
|
|
1390
|
+
constructor(micrio: HTMLMicrioElement, image: MicrioImage);
|
|
1391
|
+
destroy(): void;
|
|
1448
1392
|
}
|
|
1449
|
-
/** Synchronously reads the current value of a store by subscribing and immediately unsubscribing. */
|
|
1450
|
-
export function get<T>(store: {
|
|
1451
|
-
subscribe(fn: Subscriber<T>): Unsubscriber;
|
|
1452
|
-
}): T;
|
|
1453
|
-
export type { Subscriber, Unsubscriber, Updater };
|
|
1454
1393
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
* Provides methods for controlling the viewport (position, zoom, rotation),
|
|
1458
|
-
* converting between screen and image coordinates, and managing animations.
|
|
1459
|
-
*
|
|
1460
|
-
* Instances are typically accessed via `micrioImage.camera`.
|
|
1461
|
-
* @author Marcel Duin <marcel@micr.io>
|
|
1462
|
-
*/
|
|
1463
|
-
export class Camera {
|
|
1394
|
+
|
|
1395
|
+
export class MicrioAudioLocation {
|
|
1464
1396
|
#private;
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
/**
|
|
1472
|
-
|
|
1473
|
-
/** The element's content width in CSS pixels (used to convert `scale` to a world size). */
|
|
1474
|
-
width?: number) => Float32Array) | undefined;
|
|
1397
|
+
constructor(micrio: HTMLMicrioElement, marker: Models.ImageData.Marker, ctx: AudioContext, is360: boolean);
|
|
1398
|
+
destroy(): void;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
|
|
1402
|
+
export interface DrawnImage {
|
|
1403
|
+
/** The micrio image id. */
|
|
1404
|
+
id: string;
|
|
1475
1405
|
/**
|
|
1476
|
-
*
|
|
1406
|
+
* A rough axis-aligned rectangle `[u, v, w, h]` in the image's texture UV
|
|
1407
|
+
* space (0..1) covering the part currently visible in the viewport. The
|
|
1408
|
+
* full texture visible is `[0, 0, 1, 1]`.
|
|
1477
1409
|
*/
|
|
1478
|
-
|
|
1410
|
+
bounds: [number, number, number, number];
|
|
1411
|
+
}
|
|
1412
|
+
export interface BookViewerOptions {
|
|
1413
|
+
/** The WebGL2 canvas to render into. Must be present in the document and sized by its host. */
|
|
1414
|
+
_canvas: HTMLCanvasElement;
|
|
1415
|
+
/** The already-loaded book index JSON. */
|
|
1416
|
+
_images: Models.ImageInfo.ImageInfo[];
|
|
1417
|
+
/** Called whenever the current reading position changes. */
|
|
1418
|
+
_onPageChange?: (pageIdx: number) => void;
|
|
1419
|
+
/** Called whenever the camera moves (rotate/zoom/pan, including smoothing). */
|
|
1420
|
+
_onViewChange?: (images: DrawnImage[]) => void;
|
|
1421
|
+
/** Called after every frame that is drawn to the canvas, with the micrioIds of the images visible in the current spread (plus any page mid-flip), each with a rough `[u, v, w, h]` rectangle (in texture UV space 0..1) of the part visible in the viewport. */
|
|
1422
|
+
_onDraw?: (images: DrawnImage[]) => void;
|
|
1423
|
+
_hardCover?: boolean;
|
|
1424
|
+
_tiltShift?: boolean;
|
|
1425
|
+
_lightingPreset?: string;
|
|
1426
|
+
_useIndividualAspects?: boolean;
|
|
1427
|
+
/** When true, page margins without a texture are discarded instead of drawn as
|
|
1428
|
+
* transparent: they no longer block the pages behind them and you can see
|
|
1429
|
+
* through to the underlying spread. */
|
|
1430
|
+
_seeThroughMargins?: boolean;
|
|
1431
|
+
/** When false, the 90° rotate-view feature is disabled and its UI is hidden. Defaults to true. */
|
|
1432
|
+
_allowRotation?: boolean;
|
|
1433
|
+
_startPageIdx?: number;
|
|
1434
|
+
/** Base URL for the IIIF image server (hi-res streaming). */
|
|
1435
|
+
_iiifBaseUrl?: string;
|
|
1436
|
+
}
|
|
1437
|
+
export class BookViewer {
|
|
1438
|
+
#private;
|
|
1439
|
+
static _getPresets: typeof getPresets;
|
|
1440
|
+
readonly _ready: Promise<void>;
|
|
1441
|
+
constructor(options: BookViewerOptions);
|
|
1442
|
+
goto(pageIdx: number): Promise<void>;
|
|
1443
|
+
zoom(delta: number): void;
|
|
1479
1444
|
/**
|
|
1480
|
-
*
|
|
1481
|
-
*
|
|
1445
|
+
* Rotates the view by a 90° increment around the vertical axis: `1` turns
|
|
1446
|
+
* the book to the right (clockwise), `-1` to the left (counter-clockwise).
|
|
1482
1447
|
*/
|
|
1483
|
-
|
|
1448
|
+
rotateView(direction: 1 | -1): void;
|
|
1449
|
+
/** Whether the 90° rotate-view feature is enabled. */
|
|
1450
|
+
_allowRotation(): boolean;
|
|
1484
1451
|
/**
|
|
1485
|
-
*
|
|
1486
|
-
*
|
|
1487
|
-
*
|
|
1452
|
+
* Returns whether the camera is zoomed in beyond the fit view. This is the
|
|
1453
|
+
* complement of "the whole spread fits the viewport": when every currently
|
|
1454
|
+
* visible image shows its full texture (`[0, 0, 1, 1]` bounds) the view is
|
|
1455
|
+
* zoomed out, and any image cut off by the viewport means it is zoomed in.
|
|
1456
|
+
* A page that is part of the current view but entirely out of the viewport
|
|
1457
|
+
* (e.g. one page of a spread fills the screen while the other is off-screen)
|
|
1458
|
+
* also counts as zoomed in. Based on the last rendered frame's on-screen
|
|
1459
|
+
* bounds, so it stays accurate after zooming back out.
|
|
1488
1460
|
*/
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
}): void;
|
|
1497
|
-
/**
|
|
1498
|
-
* Gets the relative image coordinates [x, y, scale, depth, yaw?, pitch?] corresponding to a screen coordinate.
|
|
1499
|
-
* Rounds the result for cleaner output.
|
|
1500
|
-
* @param x The screen X coordinate in pixels.
|
|
1501
|
-
* @param y The screen Y coordinate in pixels.
|
|
1502
|
-
* @param absolute If true, treats x/y as absolute browser window coordinates.
|
|
1503
|
-
* @param noLimit If true, allows returning coordinates outside the image bounds (0-1).
|
|
1504
|
-
* @returns A Float64Array containing the relative image coordinates [x, y, scale, depth, yaw?, pitch?].
|
|
1505
|
-
*/
|
|
1506
|
-
getCoo(x: number, y: number, absolute?: boolean, noLimit?: boolean): Float64Array;
|
|
1507
|
-
/**
|
|
1508
|
-
* Gets the screen coordinates [x, y, scale, depth] corresponding to relative image coordinates.
|
|
1509
|
-
* @param x The image X coordinate (0-1).
|
|
1510
|
-
* @param y The image Y coordinate (0-1).
|
|
1511
|
-
* @param abs If true, returns absolute browser window coordinates instead of element-relative.
|
|
1512
|
-
* @param radius Optional offset radius for 360 calculations.
|
|
1513
|
-
* @param rotation Optional offset rotation (radians) for 360 calculations.
|
|
1514
|
-
* @param noTrueNorth If true (for 360), ignores the `trueNorth` correction.
|
|
1515
|
-
* @returns A Float64Array containing the screen coordinates [x, y, scale, depth].
|
|
1516
|
-
*/
|
|
1517
|
-
getXY(x: number, y: number, abs?: boolean, radius?: number, rotation?: number, noTrueNorth?: boolean): Float64Array;
|
|
1518
|
-
/**
|
|
1519
|
-
* Sets the center of the screen to the specified image coordinates and scale instantly.
|
|
1520
|
-
* @param x The target image X coordinate (0-1).
|
|
1521
|
-
* @param y The target image Y coordinate (0-1).
|
|
1522
|
-
* @param scale The target scale (optional, defaults to current scale).
|
|
1523
|
-
*/
|
|
1524
|
-
setCoo(x: number, y: number, scale?: number): void;
|
|
1525
|
-
/** Gets the current camera zoom scale. */
|
|
1526
|
-
getScale: () => number;
|
|
1527
|
-
/** Gets the scale at which the image fully covers the viewport. */
|
|
1528
|
-
getCoverScale: () => number;
|
|
1529
|
-
/** Gets the minimum allowed camera zoom scale. */
|
|
1530
|
-
getMinScale: () => number;
|
|
1531
|
-
/** Sets the minimum allowed camera zoom scale. */
|
|
1532
|
-
setMinScale(s: number): void;
|
|
1533
|
-
/** Sets the minimum screen size ratio that the image must occupy, restricting zoom-out. */
|
|
1534
|
-
setMinScreenSize(s: number): void;
|
|
1535
|
-
/** Checks if the camera is zoomed in to the maximum allowed scale or beyond. */
|
|
1536
|
-
isZoomedIn: () => boolean;
|
|
1537
|
-
/** Checks if the camera is fully zoomed out. */
|
|
1538
|
-
isZoomedOut: (full?: boolean) => boolean;
|
|
1539
|
-
/** Gets the current viewing direction (yaw) in 360 mode. @returns The current yaw in radians. */
|
|
1540
|
-
getDirection: () => number;
|
|
1541
|
-
/** Gets the current viewing pitch in 360 mode. @returns The current pitch in radians. */
|
|
1542
|
-
getPitch: () => number;
|
|
1543
|
-
/**
|
|
1544
|
-
* Sets the viewing direction (yaw/pitch) in 360 mode.
|
|
1545
|
-
* @param yaw The target yaw in radians.
|
|
1546
|
-
* @param pitch The target pitch in radians (defaults to current pitch).
|
|
1547
|
-
*/
|
|
1548
|
-
setDirection(yaw: number, pitch?: number): void;
|
|
1549
|
-
/**
|
|
1550
|
-
* Sets a rectangular limit for camera navigation within the image.
|
|
1551
|
-
* @param v The viewport limit [x, y, width, height] in image-relative coordinates.
|
|
1552
|
-
*/
|
|
1553
|
-
setLimit(v: Models.Camera.View): void;
|
|
1554
|
-
/**
|
|
1555
|
-
* Sets whether the camera view should be limited to always cover the viewport.
|
|
1556
|
-
* @param b If true, limits the view to cover the screen.
|
|
1557
|
-
*/
|
|
1558
|
-
setCoverLimit(b: boolean): void;
|
|
1559
|
-
getCoverLimit: () => boolean;
|
|
1560
|
-
/**
|
|
1561
|
-
* Sets horizontal and vertical pan limits for 360 images as percentages of the full sphere.
|
|
1562
|
-
* @param xPerc Horizontal limit percentage (0-100).
|
|
1563
|
-
* @param yPerc Vertical limit percentage (0-100).
|
|
1564
|
-
*/
|
|
1565
|
-
set360RangeLimit(xPerc?: number, yPerc?: number): void;
|
|
1566
|
-
/** Stops any ongoing camera animation immediately. */
|
|
1567
|
-
stop(): void;
|
|
1568
|
-
/** Pauses the current camera animation. */
|
|
1569
|
-
pause(): void;
|
|
1570
|
-
/** Resumes a previously paused camera animation and triggers a render. */
|
|
1571
|
-
resume(): void;
|
|
1572
|
-
/**
|
|
1573
|
-
* Calculates a 4x4 transformation matrix for placing an object at specific coordinates
|
|
1574
|
-
* with scale and rotation in 360 space. Used for CSS `matrix3d`.
|
|
1575
|
-
* @param x The image X coordinate (0-1).
|
|
1576
|
-
* @param y The image Y coordinate (0-1).
|
|
1577
|
-
* @param scale The object scale multiplier.
|
|
1578
|
-
* @param radius The object radius (distance from center, default 10). For Book3D images
|
|
1579
|
-
* this is used as the element's content width in CSS pixels, so `scale` stays a fraction
|
|
1580
|
-
* of the page width.
|
|
1581
|
-
* @param rotX The object X rotation in radians.
|
|
1582
|
-
* @param rotY The object Y rotation in radians.
|
|
1583
|
-
* @param rotZ The object Z rotation in radians.
|
|
1584
|
-
* @param transY Optional Y translation in 3D space.
|
|
1585
|
-
* @param scaleX Optional non-uniform X scaling.
|
|
1586
|
-
* @param scaleY Optional non-uniform Y scaling.
|
|
1587
|
-
* @returns The resulting 4x4 matrix as a Float32Array.
|
|
1588
|
-
*/
|
|
1589
|
-
getMatrix(x: number, y: number, scale?: number, radius?: number, rotX?: number, rotY?: number, rotZ?: number, transY?: number, scaleX?: number, scaleY?: number, noCorrectNorth?: boolean): Float32Array;
|
|
1590
|
-
/**
|
|
1591
|
-
* Sets the rendering area for this image within the main canvas.
|
|
1592
|
-
* Used for grid/embed layout effects. Animates by default.
|
|
1593
|
-
* @param v The target area rectangle [x0, y0, width, height] relative to the main canvas (0-1).
|
|
1594
|
-
* @param opts Options for setting the area.
|
|
1595
|
-
*/
|
|
1596
|
-
setArea(v: Models.Camera.View, opts?: {
|
|
1597
|
-
direct?: boolean;
|
|
1598
|
-
noDispatch?: boolean;
|
|
1599
|
-
noRender?: boolean;
|
|
1600
|
-
}): void;
|
|
1601
|
-
/** Sets the 3D rotation for an embedded image (used for placing embeds in 360 space). */
|
|
1602
|
-
setRotation(rotX?: number, rotY?: number, rotZ?: number): void;
|
|
1603
|
-
/** [Omni] Gets the current rotation angle in radians based on the active frame index. */
|
|
1604
|
-
getOmniRotation(): number;
|
|
1605
|
-
/** [Omni] Gets the screen coordinates [x, y, scale, depth] for given 3D object coordinates. */
|
|
1606
|
-
getOmniXY(x: number, y: number, z: number): Float64Array;
|
|
1607
|
-
/**
|
|
1608
|
-
* Animates the camera smoothly to a target viewport.
|
|
1609
|
-
* @param view The target viewport as a View [x0, y0, width, height].
|
|
1610
|
-
* @param opts Optional animation settings.
|
|
1611
|
-
* @returns A Promise that resolves when the animation completes, or rejects if aborted.
|
|
1612
|
-
*/
|
|
1613
|
-
flyToView(view: Models.Camera.View, opts?: Models.Camera.AnimationOptions & {
|
|
1614
|
-
/** Set the starting animation progress percentage (0-1). */
|
|
1615
|
-
progress?: number;
|
|
1616
|
-
/** Base the progress override on this starting view. */
|
|
1617
|
-
prevView?: Models.Camera.View;
|
|
1618
|
-
/** If true, performs a "jump" animation (zooms out then in). */
|
|
1619
|
-
isJump?: boolean;
|
|
1620
|
-
/** For Omni objects: the target image frame index to animate to. */
|
|
1621
|
-
omniIndex?: number;
|
|
1622
|
-
/** If true, respects the image's maximum zoom limit during animation. */
|
|
1623
|
-
limitZoom?: boolean;
|
|
1624
|
-
/** If provided, adds a margin to the view. */
|
|
1625
|
-
margin?: [number, number];
|
|
1626
|
-
}): Promise<void>;
|
|
1627
|
-
/**
|
|
1628
|
-
* Animates the camera to a view showing the entire image (minimum zoom).
|
|
1629
|
-
* @param opts Optional animation settings.
|
|
1630
|
-
* @returns A Promise that resolves when the animation completes.
|
|
1631
|
-
*/
|
|
1632
|
-
flyToFullView(opts?: Models.Camera.AnimationOptions): Promise<void>;
|
|
1633
|
-
/**
|
|
1634
|
-
* Animates the camera to a view where the image covers the viewport.
|
|
1635
|
-
* @param opts Optional animation settings.
|
|
1636
|
-
* @returns A Promise that resolves when the animation completes.
|
|
1637
|
-
*/
|
|
1638
|
-
flyToCoverView(opts?: Models.Camera.AnimationOptions): Promise<void>;
|
|
1639
|
-
/**
|
|
1640
|
-
* Animates the camera to center on specific image coordinates and scale.
|
|
1641
|
-
* @param coords The target coordinates [x, y, scale]. Scale is optional.
|
|
1642
|
-
* @param opts Optional animation settings.
|
|
1643
|
-
* @returns A Promise that resolves when the animation completes.
|
|
1644
|
-
*/
|
|
1645
|
-
flyToCoo(coords: Models.Camera.Coords, opts?: Models.Camera.AnimationOptions): Promise<void>;
|
|
1646
|
-
/**
|
|
1647
|
-
* Performs an animated zoom centered on a specific screen point (or the current center).
|
|
1648
|
-
* @param delta The amount to zoom (positive zooms out, negative zooms in).
|
|
1649
|
-
* @param duration Forced duration in ms (0 for instant).
|
|
1650
|
-
* @param x Screen pixel X-coordinate for zoom focus (optional, defaults to center).
|
|
1651
|
-
* @param y Screen pixel Y-coordinate for zoom focus (optional, defaults to center).
|
|
1652
|
-
* @param _speed Animation speed multiplier (optional).
|
|
1653
|
-
* @param noLimit If true, allows zooming beyond image boundaries.
|
|
1654
|
-
* @returns A Promise that resolves when the zoom animation completes.
|
|
1655
|
-
*/
|
|
1656
|
-
zoom(delta: number, duration?: number, x?: number, y?: number, _speed?: number, noLimit?: boolean): Promise<void>;
|
|
1657
|
-
/**
|
|
1658
|
-
* Zooms in by a specified factor.
|
|
1659
|
-
* @param factor Zoom factor (e.g., 1 = standard zoom step).
|
|
1660
|
-
* @param duration Animation duration in ms.
|
|
1661
|
-
* @param speed Animation speed multiplier.
|
|
1662
|
-
* @returns A Promise that resolves when the animation completes.
|
|
1663
|
-
*/
|
|
1664
|
-
zoomIn(factor?: number, duration?: number, speed?: number): Promise<void>;
|
|
1665
|
-
/**
|
|
1666
|
-
* Zooms out by a specified factor.
|
|
1667
|
-
* @param factor Zoom factor (e.g., 1 = standard zoom step).
|
|
1668
|
-
* @param duration Animation duration in ms.
|
|
1669
|
-
* @param speed Animation speed multiplier.
|
|
1670
|
-
* @returns A Promise that resolves when the animation completes.
|
|
1671
|
-
*/
|
|
1672
|
-
zoomOut(factor?: number, duration?: number, speed?: number): Promise<void>;
|
|
1673
|
-
/**
|
|
1674
|
-
* Pans the camera view by a relative pixel amount.
|
|
1675
|
-
* @param x The horizontal pixel distance to pan.
|
|
1676
|
-
* @param y The vertical pixel distance to pan.
|
|
1677
|
-
* @param duration Animation duration in ms (0 for instant).
|
|
1678
|
-
* @param opts Options: render (force render), noLimit (allow panning outside bounds).
|
|
1679
|
-
*/
|
|
1680
|
-
pan(x: number, y: number, duration?: number, opts?: {
|
|
1681
|
-
render?: boolean;
|
|
1682
|
-
noLimit?: boolean;
|
|
1683
|
-
}): void;
|
|
1684
|
-
/** Sets the camera zoom scale instantly. */
|
|
1685
|
-
setScale(s: number): void;
|
|
1461
|
+
isZoomedIn(): boolean;
|
|
1462
|
+
setLightingPreset(name: string): void;
|
|
1463
|
+
_getCurrentPage(): number;
|
|
1464
|
+
_getPageCount(): number;
|
|
1465
|
+
_nextPage(grabRow?: number): void;
|
|
1466
|
+
_prevPage(grabRow?: number): void;
|
|
1467
|
+
_hookImageBook3d(img: MicrioImage): void;
|
|
1686
1468
|
}
|
|
1687
1469
|
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
* Provides a standard lifecycle and prop/render pattern, store subscription helpers,
|
|
1691
|
-
* and a context (provide/inject) system for parent-child communication.
|
|
1692
|
-
*/
|
|
1693
|
-
export abstract class MicrioElement<_P = {}> extends HTMLElement {
|
|
1470
|
+
|
|
1471
|
+
export class PageFlipAnimator {
|
|
1694
1472
|
#private;
|
|
1473
|
+
_hardCoverPages: Set<number>;
|
|
1474
|
+
get _animating(): boolean;
|
|
1475
|
+
_isPageAnimating(pageIndex: number): boolean;
|
|
1476
|
+
/** -1 = flipping back (left→right), +1 = flipping forward (right→left), 0 = idle/dragging. */
|
|
1477
|
+
_getPageDirection(pageIndex: number): number;
|
|
1478
|
+
_getPageProgress(pageIndex: number): number;
|
|
1479
|
+
_setPageProgress(pageIndex: number, value: number): void;
|
|
1480
|
+
_instantFlip(mesh: PaperMesh, pageIndex: number): void;
|
|
1481
|
+
_initSlots(pageCount: number): void;
|
|
1482
|
+
_flipLeft(pageIndex?: number, grabRow?: number): void;
|
|
1483
|
+
_flipRight(pageIndex?: number, grabRow?: number): void;
|
|
1484
|
+
_beginDrag(pageIndex: number, grabRow: number): void;
|
|
1485
|
+
_setDragProgress(pageIndex: number, progress: number): void;
|
|
1486
|
+
_endDrag(pageIndex: number, direction: number): void;
|
|
1487
|
+
_isPageDragging(pageIndex: number): boolean;
|
|
1488
|
+
_reset(meshes: PaperMesh[]): void;
|
|
1489
|
+
_update(dt: number, meshes: PaperMesh[], selectedPage: number, totalStackHeight: number, pageCount: number, pageThickness: number): void;
|
|
1695
1490
|
}
|
|
1696
1491
|
|
|
1697
|
-
/** UI chrome auto-hide/themming effects, imported only in the full build (see `coreStubAliases` in vite.config.js). */
|
|
1698
1492
|
|
|
1699
|
-
export
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
}
|
|
1493
|
+
export function computeWeightFactor(progress: Float32Array, pageCount: number): number;
|
|
1494
|
+
export function computePageSpineY(pageIndex: number, progress: number, weightFactor: number, totalStackHeight: number, pageCount: number, pageThickness: number): number;
|
|
1495
|
+
export function computeAllPageFloors(progress: Float32Array, weightFactor: number, totalStackHeight: number, pageCount: number, pageThickness: number): Float32Array;
|
|
1496
|
+
export function applySpineDelta(positions: Float32Array, delta: number): void;
|
|
1704
1497
|
|
|
1705
|
-
/** Manages spatial audio, playlist playback, and user interaction for Micrio images. */
|
|
1706
|
-
export class MicrioAudioController {
|
|
1707
|
-
#private;
|
|
1708
|
-
constructor(micrio: HTMLMicrioElement, image: MicrioImage);
|
|
1709
|
-
destroy(): void;
|
|
1710
|
-
}
|
|
1711
1498
|
|
|
1712
1499
|
/**
|
|
1713
|
-
*
|
|
1714
|
-
*
|
|
1715
|
-
* @author Marcel Duin <marcel@micr.io>
|
|
1500
|
+
* The page layout of a book: how the images are paired onto physical pages and
|
|
1501
|
+
* the aspect ratios each page (and each face) is initialised with.
|
|
1716
1502
|
*/
|
|
1503
|
+
export interface PageLayout {
|
|
1504
|
+
/** Number of physical pages: `ceil(images.length / 2)`. */
|
|
1505
|
+
pageCnt: number;
|
|
1506
|
+
/** The image indices displayed on each page: `[0]`, then `[1, 2]`, `[3, 4]`, … */
|
|
1507
|
+
pageIdxes: number[][];
|
|
1508
|
+
/** The number of images in the book. */
|
|
1509
|
+
totalImagePages: number;
|
|
1510
|
+
/** The page aspect (height / width) every page's geometry is built with. */
|
|
1511
|
+
aspectsForInit: Float32Array;
|
|
1512
|
+
/** Per-page front face aspect (height / width) of the front image. */
|
|
1513
|
+
frontAspects: Float32Array;
|
|
1514
|
+
/** Per-page back face aspect, falling back to the front's when there is no back image. */
|
|
1515
|
+
backAspects: Float32Array;
|
|
1516
|
+
/** The book-wide average aspect every page is built with. */
|
|
1517
|
+
avgAspect: number;
|
|
1518
|
+
}
|
|
1717
1519
|
/**
|
|
1718
|
-
*
|
|
1719
|
-
*
|
|
1720
|
-
*
|
|
1520
|
+
* Pairs the book's images onto pages and computes the aspect ratios each page is
|
|
1521
|
+
* initialised with.
|
|
1522
|
+
*
|
|
1523
|
+
* Page 0 holds image 0 alone; every following page holds the pair `2p-1, 2p`, so
|
|
1524
|
+
* the covers are the outer pages of the book. Images with no usable dimensions
|
|
1525
|
+
* (`width`/`height` <= 0, or missing) contribute the default aspect instead of
|
|
1526
|
+
* skewing the average.
|
|
1527
|
+
*
|
|
1528
|
+
* Note that every page shares one geometry (the book-wide average aspect);
|
|
1529
|
+
* per-image aspects are honoured by rendering each texture in its own region of
|
|
1530
|
+
* the page (see `computeTexRegion`) rather than by resizing the page.
|
|
1721
1531
|
*/
|
|
1722
|
-
export
|
|
1532
|
+
export function computePageLayout(images: Models.ImageInfo.ImageInfo[]): PageLayout;
|
|
1533
|
+
/**
|
|
1534
|
+
* The sub-rectangle of a page's UV space in which a texture with `texAspect`
|
|
1535
|
+
* (height / width) is drawn without distortion on a page of aspect `pageAspect`.
|
|
1536
|
+
* Returns `[uMin, vMin, fU, fV]`; the leftover page space is transparent.
|
|
1537
|
+
*
|
|
1538
|
+
* The image is always anchored to the book's spine. When `spineAtHigh` is true
|
|
1539
|
+
* the spine lies at sampled u = 1 (a single-grid page's back face, sampled
|
|
1540
|
+
* mirrored), so the image's far edge sits on the spine (`uMin = 1 - fU`).
|
|
1541
|
+
* Otherwise the spine lies at sampled u = 0 and the image's near edge sits on it
|
|
1542
|
+
* (`uMin = 0`). Vertically the image stays centered.
|
|
1543
|
+
*/
|
|
1544
|
+
export function computeTexRegion(texAspect: number, pageAspect: number, spineAtHigh: boolean): [number, number, number, number];
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
export class OrbitCamera {
|
|
1723
1548
|
#private;
|
|
1549
|
+
_theta: number;
|
|
1550
|
+
_phi: number;
|
|
1551
|
+
_radius: number;
|
|
1552
|
+
_target: Vec3;
|
|
1553
|
+
_rotateSpeed: number;
|
|
1554
|
+
_zoomSpeed: number;
|
|
1555
|
+
_minRadius: number;
|
|
1556
|
+
_maxRadius: number;
|
|
1557
|
+
_panBoundsMin: Vec3 | null;
|
|
1558
|
+
_panBoundsMax: Vec3 | null;
|
|
1559
|
+
_freeCamMode: boolean;
|
|
1560
|
+
_canPanLeft: boolean;
|
|
1561
|
+
_canPanRight: boolean;
|
|
1562
|
+
_canPanUp: boolean;
|
|
1563
|
+
_canPanDown: boolean;
|
|
1564
|
+
_manualZoomActive: boolean;
|
|
1565
|
+
_isZoomedIn(): boolean;
|
|
1566
|
+
_fov: number;
|
|
1567
|
+
_setCanvasSize(w: number, h: number): void;
|
|
1568
|
+
_initContainRadius(bounds: {
|
|
1569
|
+
minX: number;
|
|
1570
|
+
maxX: number;
|
|
1571
|
+
minZ: number;
|
|
1572
|
+
maxZ: number;
|
|
1573
|
+
}, margin: number): void;
|
|
1574
|
+
_snap(): void;
|
|
1575
|
+
_update(dt: number): void;
|
|
1576
|
+
_isMoving(): boolean;
|
|
1577
|
+
_getEye(): Vec3;
|
|
1578
|
+
_getViewMatrix(): Mat4;
|
|
1579
|
+
_setFreeCamMode(on: boolean): void;
|
|
1580
|
+
_rotate(deltaTheta: number, deltaPhi: number, clampPhi?: boolean): void;
|
|
1724
1581
|
/**
|
|
1725
|
-
*
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1728
|
-
|
|
1729
|
-
constructor(image: MicrioImage, data: Models.ImageData.VideoTour);
|
|
1730
|
-
/** Cleans up the tour instance, stops animations, and re-hooks events if necessary. */
|
|
1731
|
-
destroy(): void;
|
|
1732
|
-
/** Parses the raw timeline data from the tour content into the internal `timeline` array. */
|
|
1733
|
-
read(): void;
|
|
1734
|
-
/**
|
|
1735
|
-
* Checks all tour events against the given time and dispatches `tour-event`
|
|
1736
|
-
* when an event becomes active or inactive.
|
|
1737
|
-
* Called externally during playback (e.g. from MicrioMedia time updates).
|
|
1582
|
+
* Rotates the view by a 90° step (`π/2`) around the vertical axis to either
|
|
1583
|
+
* side: `+1` turns clockwise (right), `-1` counter-clockwise (left). The
|
|
1584
|
+
* current target azimuth is snapped to the nearest 90° grid point first, so
|
|
1585
|
+
* the view always rests on a 90° increment even after a free-drag orbit.
|
|
1738
1586
|
*/
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
/** Getter for the current progress percentage (0-1). */
|
|
1753
|
-
get progress(): number;
|
|
1754
|
-
/** Setter for the current progress percentage (seeks to that point). */
|
|
1755
|
-
set progress(v: number);
|
|
1756
|
-
/** Starts or resumes tour playback. */
|
|
1757
|
-
play(): void;
|
|
1758
|
-
/** Pauses the tour playback. */
|
|
1759
|
-
pause(): void;
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
export interface MicrioSplitLink {
|
|
1763
|
-
micrioId: string;
|
|
1764
|
-
markerId?: string;
|
|
1765
|
-
follows?: boolean;
|
|
1766
|
-
}
|
|
1767
|
-
export function parseSplitLink(raw?: string): MicrioSplitLink | undefined;
|
|
1768
|
-
export function hasSplit(primary: MicrioImage): boolean;
|
|
1769
|
-
export function getSplitSecondary(primary: MicrioImage): MicrioImage | undefined;
|
|
1770
|
-
export function isSplitSecondary(image: MicrioImage): boolean;
|
|
1771
|
-
export function openSplit(micrio: HTMLMicrioElement, primary: MicrioImage, link: MicrioSplitLink, opts?: {
|
|
1772
|
-
isPassive?: boolean;
|
|
1773
|
-
}): Promise<void>;
|
|
1774
|
-
export function closeSplit(micrio: HTMLMicrioElement, primary: MicrioImage, opts?: {
|
|
1775
|
-
keepSecondaryCanvas?: boolean;
|
|
1776
|
-
}): void;
|
|
1777
|
-
export function closeAllSplits(micrio: HTMLMicrioElement): void;
|
|
1778
|
-
|
|
1779
|
-
/** Manages a collection of gallery images with navigation (swipe, switch, grid, album). */
|
|
1780
|
-
export class Gallery {
|
|
1781
|
-
#private;
|
|
1782
|
-
readonly _items: Models.ImageInfo.ImageInfo[];
|
|
1783
|
-
gotoId: (id: string) => Promise<MicrioImage | undefined>;
|
|
1784
|
-
goto: (index: number) => Promise<MicrioImage | undefined>;
|
|
1785
|
-
next: () => void;
|
|
1786
|
-
prev: () => void;
|
|
1787
|
-
}
|
|
1788
|
-
|
|
1789
|
-
/** Manages omni 3D object rotation UI: dial, swipe gestures, frame navigation, and layer menu. */
|
|
1790
|
-
export class OmniUI {
|
|
1791
|
-
#private;
|
|
1792
|
-
/** Navigate to a specific frame index. */
|
|
1793
|
-
goto(i: number): void;
|
|
1794
|
-
/** Active frame index currently displayed. */
|
|
1795
|
-
get currentIndex(): number;
|
|
1796
|
-
/** Initialize the omni UI: create frame objects, set up dial, swipe gestures, and layer menu. */
|
|
1797
|
-
setup(): Promise<void>;
|
|
1798
|
-
/** Tear down the omni UI, remove listeners, and clean up resources. */
|
|
1799
|
-
destroy(): void;
|
|
1800
|
-
/** Smoothly animate to a target frame index. */
|
|
1801
|
-
animateTo(idx: number): void;
|
|
1587
|
+
_rotateViewStep(direction: 1 | -1): void;
|
|
1588
|
+
_getPickRay(screenX: number, screenY: number): {
|
|
1589
|
+
origin: Vec3;
|
|
1590
|
+
direction: Vec3;
|
|
1591
|
+
};
|
|
1592
|
+
_zoom(delta: number, hitPoint?: Vec3): void;
|
|
1593
|
+
_pan(deltaX: number, deltaY: number): void;
|
|
1594
|
+
_clampViewport(screenBounds: {
|
|
1595
|
+
minX: number;
|
|
1596
|
+
maxX: number;
|
|
1597
|
+
minY: number;
|
|
1598
|
+
maxY: number;
|
|
1599
|
+
}, viewportW: number, viewportH: number, margin: number): void;
|
|
1802
1600
|
}
|
|
1803
1601
|
|
|
1804
|
-
export class Vec3 {
|
|
1805
|
-
#private;
|
|
1806
|
-
_x: number;
|
|
1807
|
-
_y: number;
|
|
1808
|
-
_z: number;
|
|
1809
|
-
constructor(_x?: number, _y?: number, _z?: number);
|
|
1810
|
-
_clone(): Vec3;
|
|
1811
|
-
_set(x: number, y: number, z: number): Vec3;
|
|
1812
|
-
_copy(v: Vec3): Vec3;
|
|
1813
|
-
_add(v: Vec3): Vec3;
|
|
1814
|
-
_sub(v: Vec3): Vec3;
|
|
1815
|
-
_length(): number;
|
|
1816
|
-
_normalize(): Vec3;
|
|
1817
|
-
_dot(v: Vec3): number;
|
|
1818
|
-
_cross(v: Vec3): Vec3;
|
|
1819
|
-
}
|
|
1820
1602
|
|
|
1821
1603
|
/** Thickness of a single paper page in world-space units */
|
|
1822
1604
|
export const PAGE_THICKNESS = 0.0012;
|
|
1605
|
+
/** Width of every page in world-space units: the book shares one page geometry,
|
|
1606
|
+
* and a page's own shape comes from its aspect (`aspectsForInit`). */
|
|
1607
|
+
export const PAGE_WIDTH = 1;
|
|
1823
1608
|
/** Default page aspect ratio (height / width) — √2 ≅ A4 paper */
|
|
1824
1609
|
export const DEFAULT_ASPECT: number;
|
|
1825
1610
|
/** Use each page's own aspect ratio from source images instead of the book-wide average */
|
|
@@ -1907,6 +1692,52 @@ declare module '@micrio/client' {
|
|
|
1907
1692
|
/** Active lighting preset name. Available: 'daylight', 'incandescent', 'candlelight', 'rainy day', 'moonlight', 'fireplace', 'haunted' */
|
|
1908
1693
|
export const LIGHTING_PRESET = "daylight";
|
|
1909
1694
|
|
|
1695
|
+
|
|
1696
|
+
export interface PageClickResult {
|
|
1697
|
+
direction: 'prev' | 'next';
|
|
1698
|
+
grabRow: number;
|
|
1699
|
+
}
|
|
1700
|
+
export interface PageDragResult {
|
|
1701
|
+
pageIndex: number;
|
|
1702
|
+
grabRow: number;
|
|
1703
|
+
worldX: number;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
|
|
1707
|
+
export class Vec3 {
|
|
1708
|
+
#private;
|
|
1709
|
+
_x: number;
|
|
1710
|
+
_y: number;
|
|
1711
|
+
_z: number;
|
|
1712
|
+
constructor(_x?: number, _y?: number, _z?: number);
|
|
1713
|
+
_clone(): Vec3;
|
|
1714
|
+
_set(x: number, y: number, z: number): Vec3;
|
|
1715
|
+
_copy(v: Vec3): Vec3;
|
|
1716
|
+
_add(v: Vec3): Vec3;
|
|
1717
|
+
_sub(v: Vec3): Vec3;
|
|
1718
|
+
_length(): number;
|
|
1719
|
+
_normalize(): Vec3;
|
|
1720
|
+
_dot(v: Vec3): number;
|
|
1721
|
+
_cross(v: Vec3): Vec3;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
|
|
1725
|
+
export class CoverMesh extends PaperMesh {
|
|
1726
|
+
#private;
|
|
1727
|
+
readonly _coverThickness: number;
|
|
1728
|
+
readonly _coverScale: number;
|
|
1729
|
+
readonly _coverScaleY: number;
|
|
1730
|
+
constructor(yOffset?: number, paperWidth?: number, aspectRatio?: number, coverThickness?: number, coverScale?: number, coverScaleY?: number);
|
|
1731
|
+
protected _generateGrid(): void;
|
|
1732
|
+
protected _generateTexCoords(): void;
|
|
1733
|
+
protected _generateTriangles(): void;
|
|
1734
|
+
protected _generateDistanceConstraints(): void;
|
|
1735
|
+
protected _generateBendingConstraints(): void;
|
|
1736
|
+
protected _identifyBoundEdges(): void;
|
|
1737
|
+
_computeNormals(): Float32Array;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
|
|
1910
1741
|
export { GRID_COLS, GRID_ROWS, VERTEX_COUNT } from "book/core/settings";
|
|
1911
1742
|
export interface EdgeConstraint {
|
|
1912
1743
|
_i: number;
|
|
@@ -1926,6 +1757,7 @@ declare module '@micrio/client' {
|
|
|
1926
1757
|
export function addEdgeConstraint(i: number, j: number, restPositions: Float32Array, added: Set<string>, constrs: EdgeConstraint[]): void;
|
|
1927
1758
|
export function addGridConstraints(baseIdx: number, add: (i: number, j: number) => void): void;
|
|
1928
1759
|
|
|
1760
|
+
|
|
1929
1761
|
export { GRID_COLS, GRID_ROWS, VERTEX_COUNT } from "book/core/settings";
|
|
1930
1762
|
export type { EdgeConstraint, BendingConstraint, TriangleData };
|
|
1931
1763
|
export class PaperMesh {
|
|
@@ -1942,7 +1774,14 @@ declare module '@micrio/client' {
|
|
|
1942
1774
|
readonly _yOffset: number;
|
|
1943
1775
|
readonly _paperWidth: number;
|
|
1944
1776
|
readonly _paperHeight: number;
|
|
1945
|
-
|
|
1777
|
+
/**
|
|
1778
|
+
* `generate` exists so a subclass can opt out of the grid/constraint build:
|
|
1779
|
+
* this constructor calls the virtual `_generate*` methods, and a subclass
|
|
1780
|
+
* override that uses private members cannot run before its own constructor
|
|
1781
|
+
* body (the private brand is only installed after `super` returns). Such a
|
|
1782
|
+
* subclass passes `false` and builds its geometry itself afterwards.
|
|
1783
|
+
*/
|
|
1784
|
+
constructor(yOffset?: number, paperWidth?: number, aspectRatio?: number, generate?: boolean);
|
|
1946
1785
|
protected _generateGrid(paperHeight: number): void;
|
|
1947
1786
|
protected _generateTexCoords(): void;
|
|
1948
1787
|
protected _generateTriangles(): void;
|
|
@@ -1954,387 +1793,1172 @@ declare module '@micrio/client' {
|
|
|
1954
1793
|
_computeNormals(): Float32Array;
|
|
1955
1794
|
}
|
|
1956
1795
|
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
constructor(yOffset?: number, paperWidth?: number, aspectRatio?: number, coverThickness?: number, coverScale?: number, coverScaleY?: number);
|
|
1963
|
-
protected _generateGrid(): void;
|
|
1964
|
-
protected _generateTexCoords(): void;
|
|
1965
|
-
protected _generateTriangles(): void;
|
|
1966
|
-
protected _generateDistanceConstraints(): void;
|
|
1967
|
-
protected _generateBendingConstraints(): void;
|
|
1968
|
-
protected _identifyBoundEdges(): void;
|
|
1969
|
-
_computeNormals(): Float32Array;
|
|
1796
|
+
|
|
1797
|
+
export interface RayHit {
|
|
1798
|
+
_t: number;
|
|
1799
|
+
_point: Vec3;
|
|
1800
|
+
_meshIndex: number;
|
|
1970
1801
|
}
|
|
1802
|
+
export function rayIntersectMeshes(meshes: readonly PaperMesh[], origin: Vec3, direction: Vec3): RayHit | null;
|
|
1971
1803
|
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
1804
|
+
|
|
1805
|
+
export interface UvWorldResult {
|
|
1806
|
+
/** Interpolated world-space position on the deformed mesh. */
|
|
1807
|
+
_point: Vec3;
|
|
1808
|
+
/** Interpolated (normalized) world-space surface normal at that point. */
|
|
1809
|
+
_normal: Vec3;
|
|
1810
|
+
/** World-space direction of increasing image u (not normalized). */
|
|
1811
|
+
_tangentU: Vec3;
|
|
1812
|
+
/** World-space direction of increasing image v (not normalized). */
|
|
1813
|
+
_tangentV: Vec3;
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* The sub-rectangle of a page's UV space in which a texture is displayed with
|
|
1817
|
+
* its native aspect ratio. `uMin`/`vMin` are the lower-left corner and
|
|
1818
|
+
* `fU`/`fV` the fraction of the page's u/v range the texture occupies. A region
|
|
1819
|
+
* of `(0, 0, 1, 1)` stretches the texture over the whole page.
|
|
1820
|
+
*/
|
|
1821
|
+
export interface TexRegion {
|
|
1822
|
+
uMin: number;
|
|
1823
|
+
vMin: number;
|
|
1824
|
+
fU: number;
|
|
1825
|
+
fV: number;
|
|
1826
|
+
}
|
|
1827
|
+
/**
|
|
1828
|
+
* Returns the world-space position, surface normal and UV tangents of a
|
|
1829
|
+
* relative texture coordinate (u, v) on a page mesh, using the mesh's *current*
|
|
1830
|
+
* (possibly animated/displaced) positions.
|
|
1831
|
+
*
|
|
1832
|
+
* `side` is the page side the image is displayed on:
|
|
1833
|
+
* 0 = front face (sampled at uv directly),
|
|
1834
|
+
* 1 = back face (sampled with the U axis mirrored on a single-grid PaperMesh,
|
|
1835
|
+
* or on the separate back-face grid of a CoverMesh).
|
|
1836
|
+
*
|
|
1837
|
+
* `region` restricts the image to a sub-rectangle of the page (see
|
|
1838
|
+
* {@link TexRegion}); the tangents are scaled accordingly. When omitted the
|
|
1839
|
+
* image is stretched over the whole page.
|
|
1840
|
+
*
|
|
1841
|
+
* Returns null when (u, v) falls outside [0, 1].
|
|
1842
|
+
*/
|
|
1843
|
+
export function uvToWorldPosition(mesh: PaperMesh, u: number, v: number, side: 0 | 1, region?: TexRegion | null): UvWorldResult | null;
|
|
1844
|
+
/**
|
|
1845
|
+
* Like `uvToWorldPosition` but returns only the interpolated world-space
|
|
1846
|
+
* position, skipping the surface normal and tangent computation.
|
|
1847
|
+
*/
|
|
1848
|
+
export function sampleMeshPosition(mesh: PaperMesh, u: number, v: number, side: 0 | 1, region?: TexRegion | null): Vec3 | null;
|
|
1849
|
+
/**
|
|
1850
|
+
* Projects a world-space point through the given view-projection matrix to CSS
|
|
1851
|
+
* pixel coordinates relative to the canvas top-left. Returns null when the point
|
|
1852
|
+
* is behind the camera.
|
|
1853
|
+
*/
|
|
1854
|
+
export function projectWorldToScreen(point: Vec3, viewProj: Mat4, clientWidth: number, clientHeight: number): {
|
|
1855
|
+
x: number;
|
|
1856
|
+
y: number;
|
|
1857
|
+
} | null;
|
|
1858
|
+
|
|
1859
|
+
|
|
1860
|
+
export class InputHandler {
|
|
1861
|
+
#private;
|
|
1862
|
+
_onPrevPage: (() => void) | null;
|
|
1863
|
+
_onNextPage: (() => void) | null;
|
|
1864
|
+
_onPageClick: ((x: number, y: number) => {
|
|
1865
|
+
direction: 'prev' | 'next';
|
|
1866
|
+
grabRow: number;
|
|
1867
|
+
} | null) | null;
|
|
1868
|
+
_lastClickGrabRow: number | null;
|
|
1869
|
+
_onWheelZoom: ((screenX: number, screenY: number) => Vec3 | null) | null;
|
|
1870
|
+
/** Override for the zoomed-in check, e.g. wired to the viewer's own viewport-fit logic. */
|
|
1871
|
+
_isZoomedInFn: (() => boolean) | null;
|
|
1872
|
+
_onPageDragStart: ((startX: number, startY: number) => void) | null;
|
|
1873
|
+
_onPageDragMove: ((currentX: number, currentY: number) => void) | null;
|
|
1874
|
+
_onPageDragEnd: (() => void) | null;
|
|
1875
|
+
_operation: 'none' | 'orbit' | 'pan';
|
|
1876
|
+
constructor(canvas: HTMLCanvasElement, camera: OrbitCamera, onActivity: () => void);
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
|
|
1880
|
+
/** Structure-of-arrays constraint layout for cache-friendly iteration. */
|
|
1881
|
+
export interface ConstraintSet {
|
|
1882
|
+
count: number;
|
|
1883
|
+
i: Int32Array;
|
|
1884
|
+
j: Int32Array;
|
|
1885
|
+
restLength: Float32Array;
|
|
1886
|
+
}
|
|
1887
|
+
export interface SubstepParams {
|
|
1888
|
+
dt: number;
|
|
1889
|
+
solverIterations: number;
|
|
1890
|
+
distanceCompliance: number;
|
|
1891
|
+
bendingCompliance: number;
|
|
1892
|
+
damping: number;
|
|
1893
|
+
gravity: number;
|
|
1894
|
+
gravityEnabled: boolean;
|
|
1895
|
+
}
|
|
1896
|
+
/** Flatten a mesh's {_i, _j, _restLength} constraint list into SoA buffers. */
|
|
1897
|
+
export function buildConstraintSet(constraints: EdgeConstraint[] | BendingConstraint[]): ConstraintSet;
|
|
1898
|
+
/**
|
|
1899
|
+
* Run one XPBD substep over all vertices and constraints.
|
|
1900
|
+
* Mutates `positions` / `velocities` in place and writes the start-of-step
|
|
1901
|
+
* position backup into `prevPositions`.
|
|
1902
|
+
*/
|
|
1903
|
+
export function runSubstep(positions: Float32Array, velocities: Float32Array, prevPositions: Float32Array, invMasses: Float32Array, N: number, distanceConstraints: ConstraintSet, bendingConstraints: ConstraintSet, distanceLambda: Float64Array, bendingLambda: Float64Array, params: SubstepParams, pageFloor: number): void;
|
|
1904
|
+
|
|
1905
|
+
|
|
1906
|
+
export interface SolverSettings {
|
|
1907
|
+
_solverIterations: number;
|
|
1908
|
+
_substeps: number;
|
|
1909
|
+
_distanceCompliance: number;
|
|
1910
|
+
_bendingCompliance: number;
|
|
1911
|
+
_damping: number;
|
|
1912
|
+
_gravity: number;
|
|
1913
|
+
_gravityEnabled: boolean;
|
|
1914
|
+
}
|
|
1915
|
+
export function isSolverReady(): boolean;
|
|
1916
|
+
export function initSolver(meshes: PaperMesh[], pageCount: number): Promise<void>;
|
|
1917
|
+
export function dispatchSolve(subDt: number, activeIndices: number[], substeps: number, solverSettings: SolverSettings, meshes: PaperMesh[], progress: Float32Array, totalStackHeight: number, pageCount: number, pageThickness: number): void;
|
|
1918
|
+
|
|
1919
|
+
|
|
1920
|
+
export function compileShader(gl: WebGL2RenderingContext, type: number, src: string): WebGLShader;
|
|
1921
|
+
export function createGLProgram(gl: WebGL2RenderingContext, vertSrc: string, fragSrc: string): WebGLProgram;
|
|
1922
|
+
export function setupTextureParams(gl: WebGL2RenderingContext, tex: WebGLTexture): void;
|
|
1923
|
+
export function createWhiteTexture(gl: WebGL2RenderingContext): WebGLTexture;
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
export class IIIFTextureManager {
|
|
1927
|
+
#private;
|
|
1928
|
+
/** Set by the host so the manager can request a redraw when it has something new to show. */
|
|
1929
|
+
_onRequestFrame: (() => void) | null;
|
|
1930
|
+
constructor(renderer: PaperRenderer, baseUrl?: string);
|
|
1931
|
+
_init(images: Models.ImageInfo.ImageInfo[], pageCount: number, pageIdxes: number[][]): void;
|
|
1932
|
+
_onFrame(now: number, spreadCenter: number, cameraRadius: number): boolean;
|
|
1933
|
+
_hasPendingWork(): boolean;
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
export interface LightingParam {
|
|
1938
|
+
key: string;
|
|
1939
|
+
default: number;
|
|
1940
|
+
}
|
|
1941
|
+
export interface LightingPreset {
|
|
1942
|
+
name: string;
|
|
1943
|
+
isAnimated: boolean;
|
|
1944
|
+
params: LightingParam[];
|
|
1945
|
+
}
|
|
1946
|
+
export interface LightingState {
|
|
1947
|
+
_lightDir: [number, number, number];
|
|
1948
|
+
_lightColor: [number, number, number];
|
|
1949
|
+
_ambientColor: [number, number, number];
|
|
1950
|
+
_numPointLights: number;
|
|
1951
|
+
_pointLightPos: Float32Array;
|
|
1952
|
+
_pointLightColor: Float32Array;
|
|
1953
|
+
_pointLightIntensity: Float32Array;
|
|
1954
|
+
_bumpStrength: number;
|
|
1955
|
+
}
|
|
1956
|
+
export function getPresets(): LightingPreset[];
|
|
1957
|
+
export function getPreset(name: string): LightingPreset | undefined;
|
|
1958
|
+
export function computeLighting(presetName: string, params: Record<string, number>, time: number): LightingState;
|
|
1959
|
+
|
|
1960
|
+
|
|
1961
|
+
export class PaperRenderer {
|
|
1962
|
+
#private;
|
|
1963
|
+
_tiltShiftEnabled: boolean;
|
|
1964
|
+
/** When true, page margins without a texture are discarded (see-through) instead of drawn as transparent, so pages behind remain visible. */
|
|
1965
|
+
_seeThroughMargins: boolean;
|
|
1966
|
+
constructor(gl: WebGL2RenderingContext);
|
|
1967
|
+
_initialize(meshes: PaperMesh[]): void;
|
|
1968
|
+
_setPageTextures(pageIndex: number, frontBitmap: TexImageSource, backBitmap: TexImageSource): void;
|
|
1969
|
+
_setPageHiResTexture(pageIdx: number, side: 0 | 1, slot: 0 | 1, bitmap: ImageBitmap): void;
|
|
1970
|
+
_setPageBlend(pageIdx: number, frontBlendA: number, frontBlendB: number, backBlendA: number, backBlendB: number): void;
|
|
1971
|
+
/**
|
|
1972
|
+
* Sets the per-page texture regions (see the fragment shader): each page's
|
|
1973
|
+
* front/back texture only occupies a sub-rectangle `[uMin, vMin, fU, fV]` of
|
|
1974
|
+
* the page UV space. Pass regions of `(0, 0, 1, 1)` to stretch textures over
|
|
1975
|
+
* the whole page. Each array has `4 · pageCount` floats.
|
|
1976
|
+
*/
|
|
1977
|
+
_setAspectRegions(frontRegions: Float32Array, backRegions: Float32Array): void;
|
|
1978
|
+
_evictPageHiRes(pageIdx: number, side: 0 | 1, slot: 0 | 1): void;
|
|
1979
|
+
_getCanvas(): HTMLCanvasElement;
|
|
1980
|
+
_setLightingPreset(name: string, params: Record<string, number>): void;
|
|
1981
|
+
_isLightingAnimated(): boolean;
|
|
1982
|
+
_resize(): void;
|
|
1983
|
+
_updateVertexBuffer(meshIndex: number, mesh: PaperMesh): void;
|
|
1984
|
+
_updateNormalBuffer(meshIndex: number, mesh: PaperMesh): void;
|
|
1985
|
+
_getBoundingBoxCorners(): Float32Array | null;
|
|
1986
|
+
_getCanvasSize(): {
|
|
1987
|
+
width: number;
|
|
1988
|
+
height: number;
|
|
1989
|
+
};
|
|
1990
|
+
/**
|
|
1991
|
+
* Projects the 8 bounding box corners to screen CSS pixel coordinates.
|
|
1992
|
+
* Returns { minX, maxX, minY, maxY } or null if no corners are visible.
|
|
1993
|
+
*/
|
|
1994
|
+
_getBoundingBoxScreenBounds(viewProj: Mat4): {
|
|
1995
|
+
minX: number;
|
|
1996
|
+
maxX: number;
|
|
1997
|
+
minY: number;
|
|
1998
|
+
maxY: number;
|
|
1999
|
+
} | null;
|
|
2000
|
+
_setFlipProgress(progress: Float32Array): void;
|
|
2001
|
+
_setBoundingBox(min: {
|
|
2002
|
+
x: number;
|
|
2003
|
+
y: number;
|
|
2004
|
+
z: number;
|
|
2005
|
+
}, max: {
|
|
2006
|
+
x: number;
|
|
2007
|
+
y: number;
|
|
2008
|
+
z: number;
|
|
2009
|
+
}): void;
|
|
2010
|
+
_render(camera: OrbitCamera): void;
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
|
|
2014
|
+
/**
|
|
2015
|
+
* Represents the virtual camera used to view a {@link MicrioImage}.
|
|
2016
|
+
* Provides methods for controlling the viewport (position, zoom, rotation),
|
|
2017
|
+
* converting between screen and image coordinates, and managing animations.
|
|
2018
|
+
*
|
|
2019
|
+
* Instances are typically accessed via `micrioImage.camera`.
|
|
2020
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2021
|
+
*/
|
|
2022
|
+
export class Camera {
|
|
2023
|
+
#private;
|
|
2024
|
+
/** Possible .zoom() override for Book3D */
|
|
2025
|
+
_zoomOverride: ((n: number) => void) | undefined;
|
|
2026
|
+
/** Possible override for Book3D */
|
|
2027
|
+
_isZoomedInOverride: (() => boolean) | undefined;
|
|
2028
|
+
/** Possible override for `_getXYDirect` for Book3D */
|
|
2029
|
+
_getXYDirectOverride: ((x: number, y: number) => Float64Array) | undefined;
|
|
2030
|
+
/** getMatrix book3d override */
|
|
2031
|
+
_getMatrixOverride: ((x: number, y: number, scale: number, rotX?: number, rotY?: number, rotZ?: number, scaleX?: number, scaleY?: number,
|
|
2032
|
+
/** The element's content width in CSS pixels (used to convert `scale` to a world size). */
|
|
2033
|
+
width?: number) => Float32Array) | undefined;
|
|
2034
|
+
/**
|
|
2035
|
+
* Gets the current image view rectangle [x0, y0, width, height].
|
|
2036
|
+
*/
|
|
2037
|
+
getView: () => Models.Camera.View;
|
|
2038
|
+
/**
|
|
2039
|
+
* Gets the current image view rectangle [x0, y0, width, height] relative to the image (0-1).
|
|
2040
|
+
* @returns The live Float64Array buffer from the engine.
|
|
2041
|
+
*/
|
|
2042
|
+
getViewRaw: () => Float64Array;
|
|
2043
|
+
/**
|
|
2044
|
+
* Sets the camera view instantly to the specified viewport.
|
|
2045
|
+
* @param view The target viewport as a View [x0, y0, width, height].
|
|
2046
|
+
* @param opts Options for setting the view.
|
|
2047
|
+
*/
|
|
2048
|
+
setView(view: Models.Camera.View, opts?: {
|
|
2049
|
+
/** If true, allows setting a view outside the normal image boundaries. */
|
|
2050
|
+
noLimit?: boolean;
|
|
2051
|
+
/** If true (for 360), corrects the view based on the `trueNorth` setting. */
|
|
2052
|
+
correctNorth?: boolean;
|
|
2053
|
+
/** If true, prevents triggering a render after setting the view. */
|
|
2054
|
+
noRender?: boolean;
|
|
2055
|
+
}): void;
|
|
2056
|
+
/**
|
|
2057
|
+
* Gets the relative image coordinates [x, y, scale, depth, yaw?, pitch?] corresponding to a screen coordinate.
|
|
2058
|
+
* Rounds the result for cleaner output.
|
|
2059
|
+
* @param x The screen X coordinate in pixels.
|
|
2060
|
+
* @param y The screen Y coordinate in pixels.
|
|
2061
|
+
* @param absolute If true, treats x/y as absolute browser window coordinates.
|
|
2062
|
+
* @param noLimit If true, allows returning coordinates outside the image bounds (0-1).
|
|
2063
|
+
* @returns A Float64Array containing the relative image coordinates [x, y, scale, depth, yaw?, pitch?].
|
|
2064
|
+
*/
|
|
2065
|
+
getCoo(x: number, y: number, absolute?: boolean, noLimit?: boolean): Float64Array;
|
|
2066
|
+
/**
|
|
2067
|
+
* Gets the screen coordinates [x, y, scale, depth] corresponding to relative image coordinates.
|
|
2068
|
+
* @param x The image X coordinate (0-1).
|
|
2069
|
+
* @param y The image Y coordinate (0-1).
|
|
2070
|
+
* @param abs If true, returns absolute browser window coordinates instead of element-relative.
|
|
2071
|
+
* @param radius Optional offset radius for 360 calculations.
|
|
2072
|
+
* @param rotation Optional offset rotation (radians) for 360 calculations.
|
|
2073
|
+
* @param noTrueNorth If true (for 360), ignores the `trueNorth` correction.
|
|
2074
|
+
* @returns A Float64Array containing the screen coordinates [x, y, scale, depth].
|
|
2075
|
+
*/
|
|
2076
|
+
getXY(x: number, y: number, abs?: boolean, radius?: number, rotation?: number, noTrueNorth?: boolean): Float64Array;
|
|
2077
|
+
/**
|
|
2078
|
+
* Sets the center of the screen to the specified image coordinates and scale instantly.
|
|
2079
|
+
* @param x The target image X coordinate (0-1).
|
|
2080
|
+
* @param y The target image Y coordinate (0-1).
|
|
2081
|
+
* @param scale The target scale (optional, defaults to current scale).
|
|
2082
|
+
*/
|
|
2083
|
+
setCoo(x: number, y: number, scale?: number): void;
|
|
2084
|
+
/** Gets the current camera zoom scale. */
|
|
2085
|
+
getScale: () => number;
|
|
2086
|
+
/** Gets the scale at which the image fully covers the viewport. */
|
|
2087
|
+
getCoverScale: () => number;
|
|
2088
|
+
/** Gets the minimum allowed camera zoom scale. */
|
|
2089
|
+
getMinScale: () => number;
|
|
2090
|
+
/** Sets the minimum allowed camera zoom scale. */
|
|
2091
|
+
setMinScale(s: number): void;
|
|
2092
|
+
/** Sets the minimum screen size ratio that the image must occupy, restricting zoom-out. */
|
|
2093
|
+
setMinScreenSize(s: number): void;
|
|
2094
|
+
/** Checks if the camera is zoomed in to the maximum allowed scale or beyond. */
|
|
2095
|
+
isZoomedIn: () => boolean;
|
|
2096
|
+
/** Checks if the camera is fully zoomed out. */
|
|
2097
|
+
isZoomedOut: (full?: boolean) => boolean;
|
|
2098
|
+
/** Gets the current viewing direction (yaw) in 360 mode. @returns The current yaw in radians. */
|
|
2099
|
+
getDirection: () => number;
|
|
2100
|
+
/** Gets the current viewing pitch in 360 mode. @returns The current pitch in radians. */
|
|
2101
|
+
getPitch: () => number;
|
|
2102
|
+
/**
|
|
2103
|
+
* Sets the viewing direction (yaw/pitch) in 360 mode.
|
|
2104
|
+
* @param yaw The target yaw in radians.
|
|
2105
|
+
* @param pitch The target pitch in radians (defaults to current pitch).
|
|
2106
|
+
*/
|
|
2107
|
+
setDirection(yaw: number, pitch?: number): void;
|
|
2108
|
+
/**
|
|
2109
|
+
* Sets a rectangular limit for camera navigation within the image.
|
|
2110
|
+
* @param v The viewport limit [x, y, width, height] in image-relative coordinates.
|
|
2111
|
+
*/
|
|
2112
|
+
setLimit(v: Models.Camera.View): void;
|
|
2113
|
+
/**
|
|
2114
|
+
* Sets whether the camera view should be limited to always cover the viewport.
|
|
2115
|
+
* @param b If true, limits the view to cover the screen.
|
|
2116
|
+
*/
|
|
2117
|
+
setCoverLimit(b: boolean): void;
|
|
2118
|
+
getCoverLimit: () => boolean;
|
|
2119
|
+
/**
|
|
2120
|
+
* Sets horizontal and vertical pan limits for 360 images as percentages of the full sphere.
|
|
2121
|
+
* @param xPerc Horizontal limit percentage (0-100).
|
|
2122
|
+
* @param yPerc Vertical limit percentage (0-100).
|
|
2123
|
+
*/
|
|
2124
|
+
set360RangeLimit(xPerc?: number, yPerc?: number): void;
|
|
2125
|
+
/** Stops any ongoing camera animation immediately. */
|
|
2126
|
+
stop(): void;
|
|
2127
|
+
/** Pauses the current camera animation. */
|
|
2128
|
+
pause(): void;
|
|
2129
|
+
/** Resumes a previously paused camera animation and triggers a render. */
|
|
2130
|
+
resume(): void;
|
|
2131
|
+
/**
|
|
2132
|
+
* Calculates a 4x4 transformation matrix for placing an object at specific coordinates
|
|
2133
|
+
* with scale and rotation in 360 space. Used for CSS `matrix3d`.
|
|
2134
|
+
* @param x The image X coordinate (0-1).
|
|
2135
|
+
* @param y The image Y coordinate (0-1).
|
|
2136
|
+
* @param scale The object scale multiplier.
|
|
2137
|
+
* @param radius The object radius (distance from center, default 10). For Book3D images
|
|
2138
|
+
* this is used as the element's content width in CSS pixels, so `scale` stays a fraction
|
|
2139
|
+
* of the page width.
|
|
2140
|
+
* @param rotX The object X rotation in radians.
|
|
2141
|
+
* @param rotY The object Y rotation in radians.
|
|
2142
|
+
* @param rotZ The object Z rotation in radians.
|
|
2143
|
+
* @param transY Optional Y translation in 3D space.
|
|
2144
|
+
* @param scaleX Optional non-uniform X scaling.
|
|
2145
|
+
* @param scaleY Optional non-uniform Y scaling.
|
|
2146
|
+
* @returns The resulting 4x4 matrix as a Float32Array.
|
|
2147
|
+
*/
|
|
2148
|
+
getMatrix(x: number, y: number, scale?: number, radius?: number, rotX?: number, rotY?: number, rotZ?: number, transY?: number, scaleX?: number, scaleY?: number, noCorrectNorth?: boolean): Float32Array;
|
|
2149
|
+
/**
|
|
2150
|
+
* Sets the rendering area for this image within the main canvas.
|
|
2151
|
+
* Used for grid/embed layout effects. Animates by default.
|
|
2152
|
+
* @param v The target area rectangle [x0, y0, width, height] relative to the main canvas (0-1).
|
|
2153
|
+
* @param opts Options for setting the area.
|
|
2154
|
+
*/
|
|
2155
|
+
setArea(v: Models.Camera.View, opts?: {
|
|
2156
|
+
direct?: boolean;
|
|
2157
|
+
noDispatch?: boolean;
|
|
2158
|
+
noRender?: boolean;
|
|
2159
|
+
}): void;
|
|
2160
|
+
/** Sets the 3D rotation for an embedded image (used for placing embeds in 360 space). */
|
|
2161
|
+
setRotation(rotX?: number, rotY?: number, rotZ?: number): void;
|
|
2162
|
+
/** [Omni] Gets the current rotation angle in radians based on the active frame index. */
|
|
2163
|
+
getOmniRotation(): number;
|
|
2164
|
+
/** [Omni] Gets the screen coordinates [x, y, scale, depth] for given 3D object coordinates. */
|
|
2165
|
+
getOmniXY(x: number, y: number, z: number): Float64Array;
|
|
2166
|
+
/**
|
|
2167
|
+
* Animates the camera smoothly to a target viewport.
|
|
2168
|
+
* @param view The target viewport as a View [x0, y0, width, height].
|
|
2169
|
+
* @param opts Optional animation settings.
|
|
2170
|
+
* @returns A Promise that resolves when the animation completes, or rejects if aborted.
|
|
2171
|
+
*/
|
|
2172
|
+
flyToView(view: Models.Camera.View, opts?: Models.Camera.AnimationOptions & {
|
|
2173
|
+
/** Set the starting animation progress percentage (0-1). */
|
|
2174
|
+
progress?: number;
|
|
2175
|
+
/** Base the progress override on this starting view. */
|
|
2176
|
+
prevView?: Models.Camera.View;
|
|
2177
|
+
/** If true, performs a "jump" animation (zooms out then in). */
|
|
2178
|
+
isJump?: boolean;
|
|
2179
|
+
/** For Omni objects: the target image frame index to animate to. */
|
|
2180
|
+
omniIndex?: number;
|
|
2181
|
+
/** If true, respects the image's maximum zoom limit during animation. */
|
|
2182
|
+
limitZoom?: boolean;
|
|
2183
|
+
/** If provided, adds a margin to the view. */
|
|
2184
|
+
margin?: [number, number];
|
|
2185
|
+
}): Promise<void>;
|
|
2186
|
+
/**
|
|
2187
|
+
* Animates the camera to a view showing the entire image (minimum zoom).
|
|
2188
|
+
* @param opts Optional animation settings.
|
|
2189
|
+
* @returns A Promise that resolves when the animation completes.
|
|
2190
|
+
*/
|
|
2191
|
+
flyToFullView(opts?: Models.Camera.AnimationOptions): Promise<void>;
|
|
2192
|
+
/**
|
|
2193
|
+
* Animates the camera to a view where the image covers the viewport.
|
|
2194
|
+
* @param opts Optional animation settings.
|
|
2195
|
+
* @returns A Promise that resolves when the animation completes.
|
|
2196
|
+
*/
|
|
2197
|
+
flyToCoverView(opts?: Models.Camera.AnimationOptions): Promise<void>;
|
|
2198
|
+
/**
|
|
2199
|
+
* Animates the camera to center on specific image coordinates and scale.
|
|
2200
|
+
* @param coords The target coordinates [x, y, scale]. Scale is optional.
|
|
2201
|
+
* @param opts Optional animation settings.
|
|
2202
|
+
* @returns A Promise that resolves when the animation completes.
|
|
2203
|
+
*/
|
|
2204
|
+
flyToCoo(coords: Models.Camera.Coords, opts?: Models.Camera.AnimationOptions): Promise<void>;
|
|
2205
|
+
/**
|
|
2206
|
+
* Performs an animated zoom centered on a specific screen point (or the current center).
|
|
2207
|
+
* @param delta The amount to zoom (positive zooms out, negative zooms in).
|
|
2208
|
+
* @param duration Forced duration in ms (0 for instant).
|
|
2209
|
+
* @param x Screen pixel X-coordinate for zoom focus (optional, defaults to center).
|
|
2210
|
+
* @param y Screen pixel Y-coordinate for zoom focus (optional, defaults to center).
|
|
2211
|
+
* @param _speed Animation speed multiplier (optional).
|
|
2212
|
+
* @param noLimit If true, allows zooming beyond image boundaries.
|
|
2213
|
+
* @returns A Promise that resolves when the zoom animation completes.
|
|
2214
|
+
*/
|
|
2215
|
+
zoom(delta: number, duration?: number, x?: number, y?: number, _speed?: number, noLimit?: boolean): Promise<void>;
|
|
2216
|
+
/**
|
|
2217
|
+
* Zooms in by a specified factor.
|
|
2218
|
+
* @param factor Zoom factor (e.g., 1 = standard zoom step).
|
|
2219
|
+
* @param duration Animation duration in ms.
|
|
2220
|
+
* @param speed Animation speed multiplier.
|
|
2221
|
+
* @returns A Promise that resolves when the animation completes.
|
|
2222
|
+
*/
|
|
2223
|
+
zoomIn(factor?: number, duration?: number, speed?: number): Promise<void>;
|
|
2224
|
+
/**
|
|
2225
|
+
* Zooms out by a specified factor.
|
|
2226
|
+
* @param factor Zoom factor (e.g., 1 = standard zoom step).
|
|
2227
|
+
* @param duration Animation duration in ms.
|
|
2228
|
+
* @param speed Animation speed multiplier.
|
|
2229
|
+
* @returns A Promise that resolves when the animation completes.
|
|
2230
|
+
*/
|
|
2231
|
+
zoomOut(factor?: number, duration?: number, speed?: number): Promise<void>;
|
|
2232
|
+
/**
|
|
2233
|
+
* Pans the camera view by a relative pixel amount.
|
|
2234
|
+
* @param x The horizontal pixel distance to pan.
|
|
2235
|
+
* @param y The vertical pixel distance to pan.
|
|
2236
|
+
* @param duration Animation duration in ms (0 for instant).
|
|
2237
|
+
* @param opts Options: render (force render), noLimit (allow panning outside bounds).
|
|
2238
|
+
*/
|
|
2239
|
+
pan(x: number, y: number, duration?: number, opts?: {
|
|
2240
|
+
render?: boolean;
|
|
2241
|
+
noLimit?: boolean;
|
|
2242
|
+
}): void;
|
|
2243
|
+
/** Sets the camera zoom scale instantly. */
|
|
2244
|
+
setScale(s: number): void;
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
/**
|
|
2249
|
+
* Abstract base class for all Micrio custom HTML elements.
|
|
2250
|
+
* Provides a standard lifecycle and prop/render pattern, store subscription helpers,
|
|
2251
|
+
* and a context (provide/inject) system for parent-child communication.
|
|
2252
|
+
*/
|
|
2253
|
+
export abstract class MicrioElement<_P extends object = Record<string, unknown>> extends HTMLElement {
|
|
2254
|
+
#private;
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
|
|
2258
|
+
/** UI chrome auto-hide/themming effects, imported only in the full build (see `coreStubAliases` in vite.config.js). */
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
/**
|
|
2262
|
+
* The main Micrio custom HTML element `<micr-io>`.
|
|
2263
|
+
* This class acts as the central controller for the Micrio viewer, managing
|
|
2264
|
+
* the WebGL canvas, compute engine, UI, state, events, and image loading.
|
|
2265
|
+
*
|
|
2266
|
+
* It orchestrates the interaction between different parts of the library and
|
|
2267
|
+
* exposes methods and properties for controlling the viewer.
|
|
2268
|
+
*
|
|
2269
|
+
* @example
|
|
2270
|
+
* ```html
|
|
2271
|
+
* <micr-io id="image123"></micr-io>
|
|
2272
|
+
* <script>
|
|
2273
|
+
* const viewer = document.querySelector('micr-io');
|
|
2274
|
+
* viewer.open('image456');
|
|
2275
|
+
* viewer.addEventListener('marker-click', (e) => console.log(e.detail));
|
|
2276
|
+
* </script>
|
|
2277
|
+
* ```
|
|
2278
|
+
*
|
|
2279
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2280
|
+
*/
|
|
2281
|
+
export class HTMLMicrioElement extends MicrioElement {
|
|
2282
|
+
#private;
|
|
2283
|
+
/** Observed attributes trigger `attributeChangedCallback` when changed. */
|
|
2284
|
+
static get observedAttributes(): string[];
|
|
2285
|
+
/** The Micrio library version number. */
|
|
2286
|
+
static VERSION: string;
|
|
2287
|
+
/**
|
|
2288
|
+
* Writable store holding the currently active main {@link MicrioImage}.
|
|
2289
|
+
* Use `<micr-io>.open()` to change the active image.
|
|
2290
|
+
* Subscribe to this store to react to image changes.
|
|
2291
|
+
* Access the current value directly using the {@link $current} getter.
|
|
2292
|
+
*/
|
|
2293
|
+
readonly current: Writable<MicrioImage | undefined>;
|
|
2294
|
+
/**
|
|
2295
|
+
* Getter for the current value of the {@link current} store.
|
|
2296
|
+
* Provides direct access to the active {@link MicrioImage} instance.
|
|
2297
|
+
* @readonly
|
|
2298
|
+
*/
|
|
2299
|
+
get $current(): MicrioImage | undefined;
|
|
2300
|
+
/** Getter for the virtual {@link Camera} instance of the currently active image. */
|
|
2301
|
+
get camera(): Camera | undefined;
|
|
2302
|
+
/** The controller managing the HTML `<canvas>` element, resizing, and viewport. */
|
|
2303
|
+
readonly canvas: Canvas;
|
|
2304
|
+
/** The controller managing user input events (mouse, touch, keyboard) and dispatching custom events. */
|
|
2305
|
+
readonly events: Events;
|
|
2306
|
+
/** The main state manager, providing access to various application states (UI visibility, active marker, tour, etc.). See {@link State.Main}. */
|
|
2307
|
+
readonly state: State.Main;
|
|
2308
|
+
/** Writable store indicating if barebone texture downloading is enabled (lower quality, less bandwidth). */
|
|
2309
|
+
readonly barebone: Writable<boolean>;
|
|
2310
|
+
/** Custom settings object provided programmatically, overriding server-fetched settings. */
|
|
2311
|
+
defaultSettings?: Partial<Models.ImageInfo.Settings>;
|
|
2312
|
+
/** Holds data for the current 360 space, if applicable (loaded via `data-space` attribute or API). */
|
|
2313
|
+
spaceData: Models.Spaces.Space | undefined;
|
|
2314
|
+
/** Holds bundle-level marker tours, available regardless of which image is shown. */
|
|
2315
|
+
bundleTours: Models.ImageData.MarkerTour[] | undefined;
|
|
2316
|
+
/** The current active gallery controller, if any. */
|
|
2317
|
+
gallery: Gallery | undefined;
|
|
2318
|
+
/** Destroys the Micrio instance, cleans up resources, and removes event listeners. */
|
|
2319
|
+
destroy(): void;
|
|
2320
|
+
/**
|
|
2321
|
+
* Opens a Micrio image by its Micrio ID (triggers a `bundle.json` download) or
|
|
2322
|
+
* by providing a pre-resolved {@link Models.ImageBundle.BundleImage}.
|
|
2323
|
+
*
|
|
2324
|
+
* @param idOrInfo A Micrio image ID string or a full {@link Models.ImageBundle.BundleImage} object.
|
|
2325
|
+
* @param opts Options for opening the image.
|
|
2326
|
+
* @returns The {@link MicrioImage} instance being opened.
|
|
2327
|
+
*/
|
|
2328
|
+
open(idOrInfo: string | Models.ImageBundle.BundleImage, opts?: {
|
|
2329
|
+
/** If true, keeps the grid view active instead of focusing on the opened image. */
|
|
2330
|
+
gridView?: boolean;
|
|
2331
|
+
/** An optional starting view to apply immediately. */
|
|
2332
|
+
startView?: Models.Camera.View;
|
|
2333
|
+
/** For a grid focus, the transition animation to use (a marker's `gridTourTransition`). */
|
|
2334
|
+
transition?: Models.Grid.MarkerFocusTransition;
|
|
2335
|
+
/** For 360 transitions, provides the direction vector from the previous image. */
|
|
2336
|
+
vector?: Models.Camera.Vector;
|
|
2337
|
+
/** Optional Gallery controller, used for gallery/grid views. */
|
|
2338
|
+
gallery?: Gallery;
|
|
2339
|
+
}): Promise<MicrioImage | undefined>;
|
|
2340
|
+
/**
|
|
2341
|
+
* Closes an opened MicrioImage and removes its canvas from the engine.
|
|
2342
|
+
*
|
|
2343
|
+
* The image stays in the element's list of loaded images, so opening it again (or making it
|
|
2344
|
+
* `current` again) rebuilds its canvas. Closing an image that is not placed is a no-op.
|
|
2345
|
+
* @param img The {@link MicrioImage} instance to close.
|
|
2346
|
+
*/
|
|
2347
|
+
close(img: MicrioImage): void;
|
|
2348
|
+
/** Getter for the current language code. */
|
|
2349
|
+
get lang(): string;
|
|
2350
|
+
/** Setter for the current language code. Triggers language change logic. */
|
|
2351
|
+
set lang(l: string);
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
|
|
2355
|
+
/**
|
|
2356
|
+
* Custom error class for Micrio-specific errors.
|
|
2357
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2358
|
+
*/
|
|
2359
|
+
export {};
|
|
2360
|
+
|
|
2361
|
+
|
|
2362
|
+
/**
|
|
2363
|
+
* Central frame scheduler.
|
|
2364
|
+
*
|
|
2365
|
+
* This module is the **only** place in the client that calls
|
|
2366
|
+
* `requestAnimationFrame`. Everything that needs a frame — the WebGL engine's
|
|
2367
|
+
* render loop, the book3d render loop, gallery animations, one-shot deferrals
|
|
2368
|
+
* and `afterFrame()` helpers — routes through {@link Frame}.
|
|
2369
|
+
*
|
|
2370
|
+
* Using a single loop guarantees:
|
|
2371
|
+
* - at most one rAF is in flight at any time, no matter how many engines,
|
|
2372
|
+
* viewers or components are active;
|
|
2373
|
+
* - all frame work happens in a well-defined order inside the same frame;
|
|
2374
|
+
* - the loop stops completely when nothing requests a frame.
|
|
2375
|
+
*
|
|
2376
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2377
|
+
*/
|
|
2378
|
+
export {};
|
|
2379
|
+
|
|
2380
|
+
|
|
2381
|
+
/**
|
|
2382
|
+
* Global variables, constants, default settings, and attribute parsing logic.
|
|
2383
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2384
|
+
*/
|
|
2385
|
+
export {};
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
/**
|
|
2389
|
+
* Represents and controls a single Micrio image instance within the viewer.
|
|
2390
|
+
* This class manages the image's metadata (info), cultural data (data),
|
|
2391
|
+
* settings, camera, state, and interactions with the compute engine
|
|
2392
|
+
* for rendering and processing. It handles loading image tiles, embeds,
|
|
2393
|
+
* markers, tours, and galleries associated with the image.
|
|
2394
|
+
*
|
|
2395
|
+
* Instances are typically created and managed by the main {@link HTMLMicrioElement}.
|
|
2396
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2397
|
+
*/
|
|
2398
|
+
export class MicrioImage {
|
|
2399
|
+
#private;
|
|
2400
|
+
/** The unique identifier (Micrio ID) for this image. */
|
|
2401
|
+
id: string;
|
|
2402
|
+
/** A unique instance identifier (UUID) generated for this specific instance. */
|
|
2403
|
+
readonly uuid: string;
|
|
2404
|
+
/** Getter for the current value of the {@link info} property.
|
|
2405
|
+
* @readonly
|
|
2406
|
+
*/
|
|
2407
|
+
get $info(): Models.ImageInfo.ImageInfo;
|
|
2408
|
+
/** Getter for the current value of the {@link settings} store. */
|
|
2409
|
+
get $settings(): Models.ImageInfo.Settings;
|
|
2410
|
+
/** Writable store holding the image's cultural data (markers, tours, text content for the current language). See {@link Models.ImageData.ImageData}. */
|
|
2411
|
+
readonly data: Writable<Models.ImageData.ImageData | undefined>;
|
|
2412
|
+
/** Getter for the current value of the {@link data} store. */
|
|
2413
|
+
get $data(): Models.ImageData.ImageData | undefined;
|
|
2414
|
+
/** State manager specific to this image instance (view, active marker, etc.). See {@link State.Image}. */
|
|
2415
|
+
readonly state: State.Image;
|
|
2416
|
+
/** The virtual camera instance controlling the view for this image. */
|
|
2417
|
+
camera: Camera;
|
|
2418
|
+
/** Writable store holding the HTMLVideoElement if this image represents a video. */
|
|
2419
|
+
readonly video: Writable<HTMLVideoElement | undefined>;
|
|
2420
|
+
/** Writable store indicating if this image's canvas is currently visible and being rendered.
|
|
2421
|
+
* @readonly
|
|
2422
|
+
*/
|
|
2423
|
+
readonly visible: Writable<boolean>;
|
|
2424
|
+
/** Album information if this image is part of a V5 album. */
|
|
2425
|
+
album?: Models.Album | undefined;
|
|
2426
|
+
/** OmniUI instance, if this image is an omni 3D object. */
|
|
2427
|
+
omni: OmniUI | undefined;
|
|
2428
|
+
/** Grid controller instance, if this image is a grid container. */
|
|
2429
|
+
grid: Grid | undefined;
|
|
2430
|
+
/** Stores an error message if loading failed. */
|
|
2431
|
+
error: string | undefined;
|
|
2432
|
+
/** Options controlling this image instance's behaviour (embedding, area, parent camera usage). */
|
|
2433
|
+
opts: {
|
|
2434
|
+
/** Optional sub area [x, y, width, height] defining placement within a parent canvas (for embeds/galleries). */
|
|
2435
|
+
area?: Models.Camera.View;
|
|
2436
|
+
/** If true, this image is embedded within another image (affects rendering/camera). */
|
|
2437
|
+
isEmbed?: boolean;
|
|
2438
|
+
/** If true, uses the parent image's camera instead of creating its own (for switch/omni galleries). */
|
|
2439
|
+
useParentCamera?: boolean;
|
|
2440
|
+
};
|
|
2441
|
+
/**
|
|
2442
|
+
* Adds an embedded MicrioImage (representing another Micrio image or video) within this image.
|
|
2443
|
+
* @param info Partial info data for the embed.
|
|
2444
|
+
* @param settings Optional settings for the embed.
|
|
2445
|
+
* @param area The placement area `[x, y, width, height]` within the parent image.
|
|
2446
|
+
* @param opts Embedding options (opacity, fit, etc.).
|
|
2447
|
+
* @returns The newly created embedded {@link MicrioImage} instance.
|
|
2448
|
+
*/
|
|
2449
|
+
addEmbed(info: Partial<Models.ImageInfo.ImageInfo>, settings: Partial<Models.ImageInfo.Settings> | undefined, area: Models.Camera.View, opts?: Models.Embeds.EmbedOptions): MicrioImage;
|
|
2450
|
+
/**
|
|
2451
|
+
* Gets the HTMLMediaElement associated with a video embed ID.
|
|
2452
|
+
* @param id The embed identifier.
|
|
2453
|
+
* @returns The media element, or undefined if not found.
|
|
2454
|
+
*/
|
|
2455
|
+
getEmbedMediaElement(id: string): HTMLMediaElement | undefined;
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
|
|
2459
|
+
export interface MicrioSplitLink {
|
|
2460
|
+
micrioId: string;
|
|
2461
|
+
markerId?: string;
|
|
2462
|
+
follows?: boolean;
|
|
2463
|
+
}
|
|
2464
|
+
export function parseSplitLink(raw?: string): MicrioSplitLink | undefined;
|
|
2465
|
+
export function hasSplit(primary: MicrioImage): boolean;
|
|
2466
|
+
export function getSplitSecondary(primary: MicrioImage): MicrioImage | undefined;
|
|
2467
|
+
export function isSplitSecondary(image: MicrioImage): boolean;
|
|
2468
|
+
export function openSplit(micrio: HTMLMicrioElement, primary: MicrioImage, link: MicrioSplitLink, opts?: {
|
|
2469
|
+
isPassive?: boolean;
|
|
2470
|
+
}): Promise<void>;
|
|
2471
|
+
export function closeSplit(micrio: HTMLMicrioElement, primary: MicrioImage, opts?: {
|
|
2472
|
+
keepSecondaryCanvas?: boolean;
|
|
2473
|
+
}): void;
|
|
2474
|
+
export function closeAllSplits(micrio: HTMLMicrioElement): void;
|
|
2475
|
+
|
|
2476
|
+
|
|
2477
|
+
/**
|
|
2478
|
+
* # Micrio State management
|
|
2479
|
+
*
|
|
2480
|
+
* Manages the application state using stores, allowing reactive updates
|
|
2481
|
+
* throughout the UI.
|
|
2482
|
+
* Replaces the imperative API of Micrio 3.x.
|
|
2483
|
+
*
|
|
2484
|
+
* Consists of two main state controllers:
|
|
2485
|
+
* 1. {@link State.Main}: Global state for the `<micr-io>` element (active tour, marker, UI state).
|
|
2486
|
+
* 2. {@link State.Image}: State specific to individual {@link MicrioImage} instances (view, active marker within that image).
|
|
2487
|
+
*
|
|
2488
|
+
* @see {@link https://doc.micr.io/client/v4/migrating.html | Migrating from Micrio 3.x}
|
|
2489
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2490
|
+
*/
|
|
2491
|
+
export namespace State {
|
|
2492
|
+
/**
|
|
2493
|
+
* # HTMLMicrioElement state controller (`micrio.state`)
|
|
2494
|
+
*
|
|
2495
|
+
* Manages the global application state associated with the main `<micr-io>` element.
|
|
2496
|
+
* Provides stores for reactive UI updates.
|
|
2497
|
+
*/
|
|
2498
|
+
class Main {
|
|
2499
|
+
#private;
|
|
2500
|
+
/** Writable store holding the currently active tour object (VideoTour or MarkerTour), or undefined if no tour is active. */
|
|
2501
|
+
readonly tour: Writable<Models.ImageData.VideoTour | Models.ImageData.MarkerTour | undefined>;
|
|
2502
|
+
/** Getter for the current value of the {@link tour} store. */
|
|
2503
|
+
get $tour(): Models.ImageData.VideoTour | Models.ImageData.MarkerTour | undefined;
|
|
2504
|
+
/** Writable store holding the marker object currently opened in the *main* active image, or undefined if none is open. */
|
|
2505
|
+
readonly marker: Writable<Models.ImageData.Marker | undefined>;
|
|
2506
|
+
/** Writable store holding the ID of the marker currently being hovered over. */
|
|
2507
|
+
readonly markerHoverId: Writable<string | undefined>;
|
|
2508
|
+
/** Getter for the current value of the {@link marker} store. */
|
|
2509
|
+
get $marker(): Models.ImageData.Marker | undefined;
|
|
2510
|
+
/** Writable store holding the marker object whose popup is currently displayed. */
|
|
2511
|
+
readonly popup: Writable<Models.ImageData.Marker | undefined>;
|
|
2512
|
+
/** Writable store holding the data for the currently displayed popover (custom page or gallery). See {@link Models.State.PopoverType}. */
|
|
2513
|
+
readonly popover: Writable<Models.State.PopoverType | undefined>;
|
|
2514
|
+
}
|
|
2515
|
+
/**
|
|
2516
|
+
* # MicrioImage state controller (`micrioImage.state`)
|
|
2517
|
+
*
|
|
2518
|
+
* Manages the state specific to a single {@link MicrioImage} instance,
|
|
2519
|
+
* primarily its viewport and currently opened marker.
|
|
2520
|
+
*/
|
|
2521
|
+
class Image {
|
|
2522
|
+
#private;
|
|
2523
|
+
/** Writable store holding the current viewport [x0, y0, width, height] of this image. */
|
|
2524
|
+
readonly view: Writable<Models.Camera.View | undefined>;
|
|
2525
|
+
/** Getter for the current value of the {@link view} store. */
|
|
2526
|
+
get $view(): Models.Camera.View | undefined;
|
|
2527
|
+
/**
|
|
2528
|
+
* Writable store holding the currently active marker within *this specific image*.
|
|
2529
|
+
* Can be set with a marker ID string or a full marker object. Setting to undefined closes the marker.
|
|
2530
|
+
*/
|
|
2531
|
+
readonly marker: Writable<Models.ImageData.Marker | string | undefined>;
|
|
2532
|
+
/** Getter for the current value of the {@link marker} store. */
|
|
2533
|
+
get $marker(): Models.ImageData.Marker | undefined;
|
|
2534
|
+
/** Writable store holding the currently displayed layer index (for Omni objects). */
|
|
2535
|
+
readonly layer: Writable<number>;
|
|
2536
|
+
/** Creates an Image state controller and subscribes to view/marker changes to synchronise with the main element state. @param image The parent MicrioImage instance. */
|
|
2537
|
+
constructor(image: MicrioImage);
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
/**
|
|
2543
|
+
* # Store API in Micrio
|
|
2544
|
+
*
|
|
2545
|
+
* Micrio uses a custom store implementation (`$core/store`) for its internal state management.
|
|
2546
|
+
* The API is compatible with stores (writable, readable, get, subscribe).
|
|
2547
|
+
*
|
|
2548
|
+
* This means that changes in values can passively trigger state updates.
|
|
2549
|
+
*
|
|
2550
|
+
* There are two types of stores: {@link Readable}, which is read-only for the user, and {@link Writable} which can be updated or overridden by the user.
|
|
2551
|
+
*
|
|
2552
|
+
* Typically, for accessing the data directly instead of its store, Micrio offers `$` prefixes to any store properties:
|
|
2553
|
+
*
|
|
2554
|
+
* ```js
|
|
2555
|
+
* // This is the current active image in <micr-io> (.current is the store Writable)
|
|
2556
|
+
* const image = micrio.$current;
|
|
2557
|
+
*
|
|
2558
|
+
* // The current image ImageInfo value
|
|
2559
|
+
* const info = image.$info;
|
|
2560
|
+
*
|
|
2561
|
+
* // Log the current image resolution
|
|
2562
|
+
* console.log(`The current image is ${info.width} x ${info.height}px`);
|
|
2563
|
+
*
|
|
2564
|
+
* // The current CultureData value of the current MicrioImage
|
|
2565
|
+
* console.log(micrio.$current.$data);
|
|
2566
|
+
* ```
|
|
2567
|
+
*
|
|
2568
|
+
* An example of setting and subscribing to the {@link MicrioImage.data} writable store:
|
|
2569
|
+
*
|
|
2570
|
+
* ```js
|
|
2571
|
+
*
|
|
2572
|
+
* // Subscribe to any changes in its data (markers, tours, etc)
|
|
2573
|
+
* image.data.subscribe(data => {
|
|
2574
|
+
* // Data for this image been set, removed or changed
|
|
2575
|
+
* // This also triggers when the image data has been loaded from the server
|
|
2576
|
+
* if(data) console.log(`The image now has ${data.markers.length} markers`);
|
|
2577
|
+
* else console.log('The image data is now empty.');
|
|
2578
|
+
* });
|
|
2579
|
+
*
|
|
2580
|
+
* // Let's set the image data to something. It expects ImageData.
|
|
2581
|
+
* image.data.set({
|
|
2582
|
+
* markers: [{
|
|
2583
|
+
* "title": "My First Marker",
|
|
2584
|
+
* "x": .5,
|
|
2585
|
+
* "y": .5
|
|
2586
|
+
* }]
|
|
2587
|
+
* });
|
|
2588
|
+
*
|
|
2589
|
+
* // Immediately access the data
|
|
2590
|
+
* console.log('The data has been set to', image.$data);
|
|
2591
|
+
* ```
|
|
2592
|
+
*
|
|
2593
|
+
* ## List of stores used by Micrio:
|
|
2594
|
+
*
|
|
2595
|
+
* | Property | Direct value getter | Type | Description |
|
|
2596
|
+
* | ----------- | ----------- | ------------- | ---- |
|
|
2597
|
+
* | **`<micr-io>` Element** |||
|
|
2598
|
+
* | .{@link HTMLMicrioElement.current} | {@link HTMLMicrioElement.$current} | {@link Writable}<{@link MicrioImage}> | The current active and shown {@link MicrioImage} |
|
|
2599
|
+
* | **`<micr-io>.state` controller** |||
|
|
2600
|
+
* | .{@link State.Main.tour} | {@link State.Main.$tour} | {@link Writable}<{@link Models.ImageData.MarkerTour} | {@link Models.ImageData.VideoTour}> | The current running VideoTour or MarkerTour |
|
|
2601
|
+
* | .{@link State.Main.marker} | {@link State.Main.$marker} | {@link Writable}<{@link Models.ImageData.Marker}> | The current opened marker in the current opened {@link MicrioImage} |
|
|
2602
|
+
* **Individual `MicrioImage`** |||
|
|
2603
|
+
* | .{@link MicrioImage.info} | {@link MicrioImage.$info} | {@link Readable}<{@link Models.ImageInfo}> | The static image base info |
|
|
2604
|
+
* | .{@link MicrioImage.data} | {@link MicrioImage.$data} | {@link Writable}<{@link Models.ImageData}> | The image data (markers, tours, etc) |
|
|
2605
|
+
* **`MicrioImage.state` controller** |||
|
|
2606
|
+
* | .{@link State.Image.view} | {@link State.Image.$view} | {@link Writable}<{@link Models.Camera.View}> | The current viewport |
|
|
2607
|
+
* | .{@link State.Main.marker} | {@link State.Main.$marker} | {@link Writable}<{@link Models.ImageData.Marker}> | The current opened marker of this image |
|
|
2608
|
+
*
|
|
2609
|
+
*
|
|
2610
|
+
*/
|
|
2611
|
+
/** Callback type for receiving store value updates. */
|
|
2612
|
+
type Subscriber<T> = (value: T) => void;
|
|
2613
|
+
/** Cleanup function returned by store subscription methods. */
|
|
2614
|
+
type Unsubscriber = () => void;
|
|
2615
|
+
/** Transformer function used with Writable.update(). */
|
|
2616
|
+
type Updater<T> = (value: T) => T;
|
|
2617
|
+
/** A read-only store that emits value changes to subscribers. */
|
|
2618
|
+
export interface Readable<T> {
|
|
2619
|
+
subscribe: (this: void, run: Subscriber<T>, invalidate?: (value?: T) => void) => Unsubscriber;
|
|
2620
|
+
}
|
|
2621
|
+
/** A writable store that supports setting and updating its value. */
|
|
2622
|
+
export interface Writable<T> extends Readable<T> {
|
|
2623
|
+
set: (value: T) => void;
|
|
2624
|
+
update: (fn: Updater<T>) => void;
|
|
2625
|
+
}
|
|
2626
|
+
/** Synchronously reads the current value of a store by subscribing and immediately unsubscribing. */
|
|
2627
|
+
export function get<T>(store: {
|
|
2628
|
+
subscribe: (fn: Subscriber<T>) => Unsubscriber;
|
|
2629
|
+
}): T;
|
|
2630
|
+
export type { Subscriber, Unsubscriber, Updater };
|
|
2631
|
+
|
|
2632
|
+
|
|
2633
|
+
export {};
|
|
2634
|
+
|
|
2635
|
+
|
|
2636
|
+
export {};
|
|
2637
|
+
|
|
2638
|
+
|
|
2639
|
+
export {};
|
|
2640
|
+
|
|
2641
|
+
|
|
2642
|
+
export {};
|
|
2643
|
+
|
|
2644
|
+
|
|
2645
|
+
/**
|
|
2646
|
+
* Handles user input events (mouse, touch, keyboard, wheel, gestures) for the Micrio viewer.
|
|
2647
|
+
* Translates browser events into camera movements (pan, zoom), dispatches custom Micrio events,
|
|
2648
|
+
* and manages interaction states like panning, pinching, and enabled/disabled states.
|
|
2649
|
+
* Accessed via `micrio.events`.
|
|
2650
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2651
|
+
*/
|
|
2652
|
+
export class Events implements EventContext {
|
|
2653
|
+
#private;
|
|
2654
|
+
/** Writable store indicating if event handling is currently enabled. Set to false during tours or animations. */
|
|
2655
|
+
enabled: Writable<boolean>;
|
|
2656
|
+
/** Getter for the current value of the {@link enabled} store. */
|
|
2657
|
+
get $enabled(): boolean;
|
|
2658
|
+
/**
|
|
2659
|
+
* The Events constructor.
|
|
2660
|
+
* @param micrio The main HTMLMicrioElement instance.
|
|
2661
|
+
*/
|
|
2662
|
+
constructor(micrio: HTMLMicrioElement);
|
|
2663
|
+
/**
|
|
2664
|
+
* Checks if the user is currently interacting with the map via panning, pinching, or wheeling.
|
|
2665
|
+
* @returns True if the user is actively navigating.
|
|
2666
|
+
*/
|
|
2667
|
+
get isNavigating(): boolean;
|
|
2668
|
+
/** Hooks all necessary event listeners based on current settings. */
|
|
2669
|
+
hook(): void;
|
|
2670
|
+
/** Unhooks all attached event listeners. */
|
|
2671
|
+
unhook(): void;
|
|
2672
|
+
/** Hooks keyboard event listeners. */
|
|
2673
|
+
hookKeys(): void;
|
|
2674
|
+
/** Unhooks keyboard event listeners. */
|
|
2675
|
+
unhookKeys(): void;
|
|
2676
|
+
/** Hooks zoom-related event listeners (pinch, scroll, double-tap/click). */
|
|
2677
|
+
hookZoom(): void;
|
|
2678
|
+
/** Unhooks zoom-related event listeners. */
|
|
2679
|
+
unhookZoom(): void;
|
|
2680
|
+
/** Flag indicating if scroll listeners are attached. */
|
|
2681
|
+
get scrollHooked(): boolean;
|
|
2682
|
+
/** Hooks mouse wheel/scroll event listeners. */
|
|
2683
|
+
hookScroll(): void;
|
|
2684
|
+
/** Unhooks mouse wheel/scroll event listeners. */
|
|
2685
|
+
unhookScroll(): void;
|
|
2686
|
+
/** Hooks touch pinch and macOS gesture event listeners. */
|
|
2687
|
+
hookPinch(): void;
|
|
2688
|
+
/** Unhooks touch pinch and macOS gesture event listeners. */
|
|
2689
|
+
unhookPinch(): void;
|
|
2690
|
+
/** Hooks pointer down/move/up listeners for drag panning. */
|
|
2691
|
+
hookDrag(): void;
|
|
2692
|
+
/** Unhooks pointer listeners for drag panning. */
|
|
2693
|
+
unhookDrag(): void;
|
|
2694
|
+
/** Hooks the native context menu copy crop handler (`data-contextmenu-crop`). */
|
|
2695
|
+
hookContextMenuCopy(): void;
|
|
2696
|
+
/** Unhooks the native context menu copy crop handler. */
|
|
2697
|
+
unhookContextMenuCopy(): void;
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
|
|
2701
|
+
export {};
|
|
2702
|
+
|
|
2703
|
+
|
|
2704
|
+
export {};
|
|
2705
|
+
|
|
2706
|
+
|
|
2707
|
+
export {};
|
|
2708
|
+
|
|
2709
|
+
|
|
2710
|
+
export {};
|
|
2711
|
+
|
|
2712
|
+
|
|
2713
|
+
export {};
|
|
2714
|
+
|
|
2715
|
+
|
|
2716
|
+
/**
|
|
2717
|
+
* Context object providing access to shared state for event handlers.
|
|
2718
|
+
* This is passed to each handler module to avoid circular dependencies.
|
|
2719
|
+
*/
|
|
2720
|
+
export interface EventContext {
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
|
|
2724
|
+
export {};
|
|
2725
|
+
|
|
2726
|
+
|
|
2727
|
+
export {};
|
|
2728
|
+
|
|
2729
|
+
|
|
2730
|
+
export {};
|
|
2731
|
+
|
|
2732
|
+
|
|
2733
|
+
/** Manages a collection of gallery images with navigation (swipe, switch, grid, album). */
|
|
2734
|
+
export class Gallery {
|
|
2735
|
+
#private;
|
|
2736
|
+
readonly _items: Models.ImageInfo.ImageInfo[];
|
|
2737
|
+
gotoId: (id: string) => Promise<MicrioImage | undefined>;
|
|
2738
|
+
goto: (index: number) => Promise<MicrioImage | undefined>;
|
|
2739
|
+
next: () => void;
|
|
2740
|
+
prev: () => void;
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
|
|
2744
|
+
/** Manages omni 3D object rotation UI: dial, swipe gestures, frame navigation, and layer menu. */
|
|
2745
|
+
export class OmniUI {
|
|
2746
|
+
#private;
|
|
2747
|
+
/** Navigate to a specific frame index. */
|
|
2748
|
+
goto(i: number): void;
|
|
2749
|
+
/** Active frame index currently displayed. */
|
|
2750
|
+
get currentIndex(): number;
|
|
2751
|
+
/** Initialize the omni UI: create frame objects, set up dial, swipe gestures, and layer menu. */
|
|
2752
|
+
setup(): Promise<void>;
|
|
2753
|
+
/** Tear down the omni UI, remove listeners, and clean up resources. */
|
|
2754
|
+
destroy(): void;
|
|
2755
|
+
/** Smoothly animate to a target frame index. */
|
|
2756
|
+
animateTo(idx: number): void;
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
|
|
2760
|
+
export {};
|
|
2761
|
+
|
|
2762
|
+
|
|
2763
|
+
export {};
|
|
2764
|
+
|
|
2765
|
+
|
|
2766
|
+
/**
|
|
2767
|
+
* Defines the types of actions that can be performed on a Grid instance,
|
|
2768
|
+
* often triggered by marker data (`gridAction`) or tour events.
|
|
2769
|
+
*/
|
|
2770
|
+
export enum GridActionType {
|
|
2771
|
+
/** Focus on specific images within the grid, hiding others. Data: comma-separated image IDs. */
|
|
2772
|
+
focus = 0,
|
|
2773
|
+
/** Animate the main grid view to fit the bounding box of specified images. Data: comma-separated image IDs. */
|
|
2774
|
+
flyTo = 1,
|
|
2775
|
+
/** Focus on images containing markers with a specific tag. Data: tag name. */
|
|
2776
|
+
focusWithTagged = 2,
|
|
2777
|
+
/** Focus on images containing markers with a specific tag and fly to the marker views. Data: tag name. */
|
|
2778
|
+
focusTagged = 3,
|
|
2779
|
+
/** Reset the grid to its initial layout and view. */
|
|
2780
|
+
reset = 4,
|
|
2781
|
+
/** Navigate back one step in the grid layout history. */
|
|
2782
|
+
back = 5,
|
|
2783
|
+
/** Instantly switch a focused image back to its position within the grid layout. */
|
|
2784
|
+
switchToGrid = 6,
|
|
2785
|
+
/** Filter the grid to show only images that are part of the currently active marker tour. */
|
|
2786
|
+
filterTourImages = 7,
|
|
2787
|
+
/** Set a one-time crossfade duration for the *next* grid transition. Data: duration in seconds. */
|
|
2788
|
+
nextFadeDuration = 8
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
|
|
2792
|
+
export {};
|
|
2793
|
+
|
|
2794
|
+
|
|
2795
|
+
/** The main Grid controller that arranges {@link MicrioImage} instances into a CSS grid layout. */
|
|
2796
|
+
export class Grid extends MicrioElement<GridProps> {
|
|
2797
|
+
#private;
|
|
2798
|
+
/** All {@link MicrioImage} instances managed by this grid. */
|
|
2799
|
+
get images(): readonly MicrioImage[];
|
|
2800
|
+
/** Get a grid {@link MicrioImage} instance by its image ID, if it is part of this grid. */
|
|
2801
|
+
getImage(id: string): MicrioImage | undefined;
|
|
2802
|
+
/** The currently focussed (single-view) image, if any. */
|
|
2803
|
+
get $focussed(): MicrioImage | undefined;
|
|
2804
|
+
/** The parent `<micrio-*>` element this grid is bound to. */
|
|
2805
|
+
micrio: HTMLMicrioElement;
|
|
2806
|
+
/** The main {@link MicrioImage} that serves as the grid viewport. */
|
|
2807
|
+
image: MicrioImage;
|
|
2808
|
+
/** Set the grid to display the given images, arranging them into a CSS grid. */
|
|
2809
|
+
set(images?: Models.Grid.GridImage[], opts?: {
|
|
2810
|
+
noHistory?: boolean;
|
|
2811
|
+
keepGrid?: boolean;
|
|
2812
|
+
horizontal?: boolean;
|
|
2813
|
+
duration?: number;
|
|
2814
|
+
view?: Models.Camera.View;
|
|
2815
|
+
noCamAni?: boolean;
|
|
2816
|
+
forceAreaAni?: boolean;
|
|
2817
|
+
noBlur?: boolean;
|
|
2818
|
+
noFade?: boolean;
|
|
2819
|
+
transition?: Models.Grid.GridSetTransition;
|
|
2820
|
+
forceAni?: boolean;
|
|
2821
|
+
coverLimit?: boolean;
|
|
2822
|
+
cover?: boolean;
|
|
2823
|
+
scale?: number;
|
|
2824
|
+
columns?: number;
|
|
2825
|
+
}): Promise<MicrioImage[]>;
|
|
2826
|
+
/** Reset the grid to its initial layout (all gallery images), clearing all history. */
|
|
2827
|
+
reset(duration?: number, noCamAni?: boolean, forceAni?: boolean): Promise<MicrioImage[]>;
|
|
2828
|
+
/** Navigate to the previous layout state from the history stack. */
|
|
2829
|
+
back(duration?: number): Promise<void>;
|
|
2830
|
+
/** Focus the grid on a single image, optionally with a transition animation. */
|
|
2831
|
+
gridFocus(img: MicrioImage | undefined, opts?: Models.Grid.FocusOptions): Promise<void>;
|
|
2832
|
+
/** Remove focus from the currently focussed image and return to the grid overview. */
|
|
2833
|
+
blur(): void;
|
|
2834
|
+
/** Execute a grid action by type (e.g. `focus`, `reset`, `back`) with optional data and duration. */
|
|
2835
|
+
action(action: GridActionType | string, data?: string, duration?: number, focusTransition?: Models.Grid.MarkerFocusTransition): void;
|
|
2836
|
+
/** Enlarge a specific grid cell to span the given number of columns/rows, re-laying out without history. */
|
|
2837
|
+
enlarge(idx: number, width: number, height?: number): Promise<MicrioImage[]>;
|
|
2025
2838
|
}
|
|
2026
2839
|
|
|
2027
|
-
export interface LightingParam {
|
|
2028
|
-
key: string;
|
|
2029
|
-
default: number;
|
|
2030
|
-
}
|
|
2031
|
-
export interface LightingPreset {
|
|
2032
|
-
name: string;
|
|
2033
|
-
isAnimated: boolean;
|
|
2034
|
-
params: LightingParam[];
|
|
2035
|
-
}
|
|
2036
|
-
export interface LightingState {
|
|
2037
|
-
_lightDir: [number, number, number];
|
|
2038
|
-
_lightColor: [number, number, number];
|
|
2039
|
-
_ambientColor: [number, number, number];
|
|
2040
|
-
_numPointLights: number;
|
|
2041
|
-
_pointLightPos: Float32Array;
|
|
2042
|
-
_pointLightColor: Float32Array;
|
|
2043
|
-
_pointLightIntensity: Float32Array;
|
|
2044
|
-
_bumpStrength: number;
|
|
2045
|
-
}
|
|
2046
|
-
export function getPresets(): LightingPreset[];
|
|
2047
|
-
export function getPreset(name: string): LightingPreset | undefined;
|
|
2048
|
-
export function computeLighting(presetName: string, params: Record<string, number>, time: number): LightingState;
|
|
2049
2840
|
|
|
2050
|
-
export
|
|
2051
|
-
export function computePageSpineY(pageIndex: number, progress: number, weightFactor: number, totalStackHeight: number, pageCount: number, pageThickness: number): number;
|
|
2052
|
-
export function computeAllPageFloors(progress: Float32Array, weightFactor: number, totalStackHeight: number, pageCount: number, pageThickness: number): Float32Array;
|
|
2053
|
-
export function applySpineDelta(positions: Float32Array, delta: number): void;
|
|
2841
|
+
export {};
|
|
2054
2842
|
|
|
2055
|
-
export function compileShader(gl: WebGL2RenderingContext, type: number, src: string): WebGLShader;
|
|
2056
|
-
export function createGLProgram(gl: WebGL2RenderingContext, vertSrc: string, fragSrc: string): WebGLProgram;
|
|
2057
|
-
export function setupTextureParams(gl: WebGL2RenderingContext, tex: WebGLTexture): void;
|
|
2058
|
-
export function createWhiteTexture(gl: WebGL2RenderingContext): WebGLTexture;
|
|
2059
2843
|
|
|
2060
|
-
export
|
|
2061
|
-
#private;
|
|
2062
|
-
_tiltShiftEnabled: boolean;
|
|
2063
|
-
/** When true, page margins without a texture are discarded (see-through) instead of drawn as transparent, so pages behind remain visible. */
|
|
2064
|
-
_seeThroughMargins: boolean;
|
|
2065
|
-
constructor(gl: WebGL2RenderingContext);
|
|
2066
|
-
_initialize(meshes: PaperMesh[]): void;
|
|
2067
|
-
_setPageTextures(pageIndex: number, frontBitmap: TexImageSource, backBitmap: TexImageSource): void;
|
|
2068
|
-
_setPageHiResTexture(pageIdx: number, side: 0 | 1, slot: 0 | 1, bitmap: ImageBitmap): void;
|
|
2069
|
-
_setPageBlend(pageIdx: number, frontBlendA: number, frontBlendB: number, backBlendA: number, backBlendB: number): void;
|
|
2070
|
-
/**
|
|
2071
|
-
* Sets the per-page texture regions (see the fragment shader): each page's
|
|
2072
|
-
* front/back texture only occupies a sub-rectangle `[uMin, vMin, fU, fV]` of
|
|
2073
|
-
* the page UV space. Pass regions of `(0, 0, 1, 1)` to stretch textures over
|
|
2074
|
-
* the whole page. Each array has `4 · pageCount` floats.
|
|
2075
|
-
*/
|
|
2076
|
-
_setAspectRegions(frontRegions: Float32Array, backRegions: Float32Array): void;
|
|
2077
|
-
_evictPageHiRes(pageIdx: number, side: 0 | 1, slot: 0 | 1): void;
|
|
2078
|
-
_getCanvas(): HTMLCanvasElement;
|
|
2079
|
-
_setLightingPreset(name: string, params: Record<string, number>): void;
|
|
2080
|
-
_isLightingAnimated(): boolean;
|
|
2081
|
-
_resize(): void;
|
|
2082
|
-
_updateVertexBuffer(meshIndex: number, mesh: PaperMesh): void;
|
|
2083
|
-
_updateNormalBuffer(meshIndex: number, mesh: PaperMesh): void;
|
|
2084
|
-
_getBoundingBoxCorners(): Float32Array | null;
|
|
2085
|
-
_getCanvasSize(): {
|
|
2086
|
-
width: number;
|
|
2087
|
-
height: number;
|
|
2088
|
-
};
|
|
2089
|
-
/**
|
|
2090
|
-
* Projects the 8 bounding box corners to screen CSS pixel coordinates.
|
|
2091
|
-
* Returns { minX, maxX, minY, maxY } or null if no corners are visible.
|
|
2092
|
-
*/
|
|
2093
|
-
_getBoundingBoxScreenBounds(viewProj: Mat4): {
|
|
2094
|
-
minX: number;
|
|
2095
|
-
maxX: number;
|
|
2096
|
-
minY: number;
|
|
2097
|
-
maxY: number;
|
|
2098
|
-
} | null;
|
|
2099
|
-
_setFlipProgress(progress: Float32Array): void;
|
|
2100
|
-
_setBoundingBox(min: {
|
|
2101
|
-
x: number;
|
|
2102
|
-
y: number;
|
|
2103
|
-
z: number;
|
|
2104
|
-
}, max: {
|
|
2105
|
-
x: number;
|
|
2106
|
-
y: number;
|
|
2107
|
-
z: number;
|
|
2108
|
-
}): void;
|
|
2109
|
-
_render(camera: OrbitCamera): void;
|
|
2110
|
-
}
|
|
2844
|
+
export {};
|
|
2111
2845
|
|
|
2112
|
-
export class InputHandler {
|
|
2113
|
-
#private;
|
|
2114
|
-
_onPrevPage: (() => void) | null;
|
|
2115
|
-
_onNextPage: (() => void) | null;
|
|
2116
|
-
_onPageClick: ((x: number, y: number) => {
|
|
2117
|
-
direction: 'prev' | 'next';
|
|
2118
|
-
grabRow: number;
|
|
2119
|
-
} | null) | null;
|
|
2120
|
-
_lastClickGrabRow: number | null;
|
|
2121
|
-
_onWheelZoom: ((screenX: number, screenY: number) => Vec3 | null) | null;
|
|
2122
|
-
/** Override for the zoomed-in check, e.g. wired to the viewer's own viewport-fit logic. */
|
|
2123
|
-
_isZoomedInFn: (() => boolean) | null;
|
|
2124
|
-
_onPageDragStart: ((startX: number, startY: number) => void) | null;
|
|
2125
|
-
_onPageDragMove: ((currentX: number, currentY: number) => void) | null;
|
|
2126
|
-
_onPageDragEnd: (() => void) | null;
|
|
2127
|
-
_operation: 'none' | 'orbit' | 'pan';
|
|
2128
|
-
constructor(canvas: HTMLCanvasElement, camera: OrbitCamera, onActivity: () => void);
|
|
2129
|
-
}
|
|
2130
2846
|
|
|
2131
|
-
export
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
_setPageProgress(pageIndex: number, value: number): void;
|
|
2140
|
-
_instantFlip(mesh: PaperMesh, pageIndex: number): void;
|
|
2141
|
-
_initSlots(pageCount: number): void;
|
|
2142
|
-
_flipLeft(pageIndex?: number, grabRow?: number): void;
|
|
2143
|
-
_flipRight(pageIndex?: number, grabRow?: number): void;
|
|
2144
|
-
_beginDrag(pageIndex: number, grabRow: number): void;
|
|
2145
|
-
_setDragProgress(pageIndex: number, progress: number): void;
|
|
2146
|
-
_endDrag(pageIndex: number, direction: number): void;
|
|
2147
|
-
_isPageDragging(pageIndex: number): boolean;
|
|
2148
|
-
_reset(meshes: PaperMesh[]): void;
|
|
2149
|
-
_update(dt: number, meshes: PaperMesh[], selectedPage: number, totalStackHeight: number, pageCount: number, pageThickness: number): void;
|
|
2150
|
-
}
|
|
2847
|
+
export {};
|
|
2848
|
+
|
|
2849
|
+
|
|
2850
|
+
export {};
|
|
2851
|
+
|
|
2852
|
+
|
|
2853
|
+
export {};
|
|
2854
|
+
|
|
2151
2855
|
|
|
2152
|
-
/** Structure-of-arrays constraint layout for cache-friendly iteration. */
|
|
2153
|
-
export interface ConstraintSet {
|
|
2154
|
-
count: number;
|
|
2155
|
-
i: Int32Array;
|
|
2156
|
-
j: Int32Array;
|
|
2157
|
-
restLength: Float32Array;
|
|
2158
|
-
}
|
|
2159
|
-
export interface SubstepParams {
|
|
2160
|
-
dt: number;
|
|
2161
|
-
solverIterations: number;
|
|
2162
|
-
distanceCompliance: number;
|
|
2163
|
-
bendingCompliance: number;
|
|
2164
|
-
damping: number;
|
|
2165
|
-
gravity: number;
|
|
2166
|
-
gravityEnabled: boolean;
|
|
2167
|
-
}
|
|
2168
|
-
/** Flatten a mesh's {_i, _j, _restLength} constraint list into SoA buffers. */
|
|
2169
|
-
export function buildConstraintSet(constraints: EdgeConstraint[] | BendingConstraint[]): ConstraintSet;
|
|
2170
2856
|
/**
|
|
2171
|
-
*
|
|
2172
|
-
*
|
|
2173
|
-
*
|
|
2857
|
+
* HLS.js Player adapter.
|
|
2858
|
+
* Extends HTML5PlayerAdapter to add HLS.js streaming support.
|
|
2859
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2174
2860
|
*/
|
|
2175
|
-
export
|
|
2861
|
+
export {};
|
|
2176
2862
|
|
|
2177
|
-
export interface SolverSettings {
|
|
2178
|
-
_solverIterations: number;
|
|
2179
|
-
_substeps: number;
|
|
2180
|
-
_distanceCompliance: number;
|
|
2181
|
-
_bendingCompliance: number;
|
|
2182
|
-
_damping: number;
|
|
2183
|
-
_gravity: number;
|
|
2184
|
-
_gravityEnabled: boolean;
|
|
2185
|
-
}
|
|
2186
|
-
export function isSolverReady(): boolean;
|
|
2187
|
-
export function initSolver(meshes: PaperMesh[], pageCount: number): Promise<void>;
|
|
2188
|
-
export function dispatchSolve(subDt: number, activeIndices: number[], substeps: number, solverSettings: SolverSettings, meshes: PaperMesh[], progress: Float32Array, totalStackHeight: number, pageCount: number, pageThickness: number): void;
|
|
2189
2863
|
|
|
2190
|
-
|
|
2864
|
+
/**
|
|
2865
|
+
* HTML5 Media Element adapter.
|
|
2866
|
+
* Wraps native <audio> and <video> elements with a common interface.
|
|
2867
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2868
|
+
*/
|
|
2869
|
+
export {};
|
|
2870
|
+
|
|
2871
|
+
|
|
2872
|
+
/**
|
|
2873
|
+
* Video tour controller. Manages playback and camera animation for video tours
|
|
2874
|
+
* defined by a timeline of view rectangles and durations.
|
|
2875
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2876
|
+
*/
|
|
2877
|
+
/**
|
|
2878
|
+
* Controls the playback of a video tour, animating the camera according
|
|
2879
|
+
* to a predefined timeline and synchronizing with associated audio/video media.
|
|
2880
|
+
* Instances are typically created and managed internally.
|
|
2881
|
+
*/
|
|
2882
|
+
export class VideoTourInstance {
|
|
2191
2883
|
#private;
|
|
2192
|
-
/**
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2884
|
+
/**
|
|
2885
|
+
* Creates a VideoTourInstance.
|
|
2886
|
+
* @param image The parent {@link MicrioImage} instance.
|
|
2887
|
+
* @param data The {@link Models.ImageData.VideoTour} data object.
|
|
2888
|
+
*/
|
|
2889
|
+
constructor(image: MicrioImage, data: Models.ImageData.VideoTour);
|
|
2890
|
+
/** Cleans up the tour instance, stops animations, and re-hooks events if necessary. */
|
|
2891
|
+
destroy(): void;
|
|
2892
|
+
/** Parses the raw timeline data from the tour content into the internal `timeline` array. */
|
|
2893
|
+
read(): void;
|
|
2894
|
+
/**
|
|
2895
|
+
* Checks all tour events against the given time and dispatches `tour-event`
|
|
2896
|
+
* when an event becomes active or inactive.
|
|
2897
|
+
* Called externally during playback (e.g. from MicrioMedia time updates).
|
|
2898
|
+
*/
|
|
2899
|
+
updateEvents(time: number): void;
|
|
2900
|
+
/** Getter for the total duration of the tour in seconds. */
|
|
2901
|
+
get duration(): number;
|
|
2902
|
+
/** Setter for the total duration (updates internal content). */
|
|
2903
|
+
set duration(v: number);
|
|
2904
|
+
/** Getter for the current paused state. */
|
|
2905
|
+
get paused(): boolean;
|
|
2906
|
+
/** Getter indicating if the tour has ended. */
|
|
2907
|
+
get ended(): boolean;
|
|
2908
|
+
/** Getter for the current playback time in seconds. */
|
|
2909
|
+
get currentTime(): number;
|
|
2910
|
+
/** Setter for the current playback time (seeks to the corresponding progress). */
|
|
2911
|
+
set currentTime(v: number);
|
|
2912
|
+
/** Getter for the current progress percentage (0-1). */
|
|
2913
|
+
get progress(): number;
|
|
2914
|
+
/** Setter for the current progress percentage (seeks to that point). */
|
|
2915
|
+
set progress(v: number);
|
|
2916
|
+
/** Starts or resumes tour playback. */
|
|
2917
|
+
play(): void;
|
|
2918
|
+
/** Pauses the tour playback. */
|
|
2919
|
+
pause(): void;
|
|
2198
2920
|
}
|
|
2199
2921
|
|
|
2200
|
-
export interface PageClickResult {
|
|
2201
|
-
direction: 'prev' | 'next';
|
|
2202
|
-
grabRow: number;
|
|
2203
|
-
}
|
|
2204
|
-
export interface PageDragResult {
|
|
2205
|
-
pageIndex: number;
|
|
2206
|
-
grabRow: number;
|
|
2207
|
-
worldX: number;
|
|
2208
|
-
}
|
|
2209
2922
|
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
export
|
|
2923
|
+
/**
|
|
2924
|
+
* Vimeo Player API adapter.
|
|
2925
|
+
* Wraps the Vimeo player with a common interface.
|
|
2926
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2927
|
+
*/
|
|
2928
|
+
export {};
|
|
2929
|
+
|
|
2216
2930
|
|
|
2217
|
-
export interface UvWorldResult {
|
|
2218
|
-
/** Interpolated world-space position on the deformed mesh. */
|
|
2219
|
-
_point: Vec3;
|
|
2220
|
-
/** Interpolated (normalized) world-space surface normal at that point. */
|
|
2221
|
-
_normal: Vec3;
|
|
2222
|
-
/** World-space direction of increasing image u (not normalized). */
|
|
2223
|
-
_tangentU: Vec3;
|
|
2224
|
-
/** World-space direction of increasing image v (not normalized). */
|
|
2225
|
-
_tangentV: Vec3;
|
|
2226
|
-
}
|
|
2227
2931
|
/**
|
|
2228
|
-
*
|
|
2229
|
-
*
|
|
2230
|
-
*
|
|
2231
|
-
* of `(0, 0, 1, 1)` stretches the texture over the whole page.
|
|
2932
|
+
* YouTube IFrame Player API adapter.
|
|
2933
|
+
* Wraps the YouTube player with a common interface.
|
|
2934
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2232
2935
|
*/
|
|
2233
|
-
export
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
fU: number;
|
|
2237
|
-
fV: number;
|
|
2238
|
-
}
|
|
2936
|
+
export {};
|
|
2937
|
+
|
|
2938
|
+
|
|
2239
2939
|
/**
|
|
2240
|
-
*
|
|
2241
|
-
*
|
|
2242
|
-
*
|
|
2243
|
-
*
|
|
2244
|
-
* `side` is the page side the image is displayed on:
|
|
2245
|
-
* 0 = front face (sampled at uv directly),
|
|
2246
|
-
* 1 = back face (sampled with the U axis mirrored on a single-grid PaperMesh,
|
|
2247
|
-
* or on the separate back-face grid of a CoverMesh).
|
|
2248
|
-
*
|
|
2249
|
-
* `region` restricts the image to a sub-rectangle of the page (see
|
|
2250
|
-
* {@link TexRegion}); the tangents are scaled accordingly. When omitted the
|
|
2251
|
-
* image is stretched over the whole page.
|
|
2252
|
-
*
|
|
2253
|
-
* Returns null when (u, v) falls outside [0, 1].
|
|
2940
|
+
* Manages camera and view animations (fly-to, zoom, jump).
|
|
2941
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2942
|
+
* @internal
|
|
2254
2943
|
*/
|
|
2255
|
-
export
|
|
2944
|
+
export {};
|
|
2945
|
+
|
|
2946
|
+
|
|
2256
2947
|
/**
|
|
2257
|
-
*
|
|
2258
|
-
*
|
|
2948
|
+
* Handles 2D camera logic, view calculations, and user interactions like pan, zoom, pinch.
|
|
2949
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2950
|
+
* @internal
|
|
2259
2951
|
*/
|
|
2260
|
-
export
|
|
2952
|
+
export {};
|
|
2953
|
+
|
|
2954
|
+
|
|
2261
2955
|
/**
|
|
2262
|
-
*
|
|
2263
|
-
*
|
|
2264
|
-
*
|
|
2956
|
+
* Handles 360 camera logic, perspective, and related calculations.
|
|
2957
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2958
|
+
* @internal
|
|
2265
2959
|
*/
|
|
2266
|
-
export
|
|
2267
|
-
x: number;
|
|
2268
|
-
y: number;
|
|
2269
|
-
} | null;
|
|
2960
|
+
export {};
|
|
2270
2961
|
|
|
2271
|
-
export interface DrawnImage {
|
|
2272
|
-
/** The micrio image id. */
|
|
2273
|
-
id: string;
|
|
2274
|
-
/**
|
|
2275
|
-
* A rough axis-aligned rectangle `[u, v, w, h]` in the image's texture UV
|
|
2276
|
-
* space (0..1) covering the part currently visible in the viewport. The
|
|
2277
|
-
* full texture visible is `[0, 0, 1, 1]`.
|
|
2278
|
-
*/
|
|
2279
|
-
bounds: [number, number, number, number];
|
|
2280
|
-
}
|
|
2281
|
-
export interface BookViewerOptions {
|
|
2282
|
-
/** The WebGL2 canvas to render into. Must be present in the document and sized by its host. */
|
|
2283
|
-
_canvas: HTMLCanvasElement;
|
|
2284
|
-
/** The already-loaded book index JSON. */
|
|
2285
|
-
_images: Models.ImageInfo.ImageInfo[];
|
|
2286
|
-
/** Called whenever the current reading position changes. */
|
|
2287
|
-
_onPageChange?: (pageIdx: number) => void;
|
|
2288
|
-
/** Called whenever the camera moves (rotate/zoom/pan, including smoothing). */
|
|
2289
|
-
_onViewChange?: (images: DrawnImage[]) => void;
|
|
2290
|
-
/** Called after every frame that is drawn to the canvas, with the micrioIds of the images visible in the current spread (plus any page mid-flip), each with a rough `[u, v, w, h]` rectangle (in texture UV space 0..1) of the part visible in the viewport. */
|
|
2291
|
-
_onDraw?: (images: DrawnImage[]) => void;
|
|
2292
|
-
_hardCover?: boolean;
|
|
2293
|
-
_tiltShift?: boolean;
|
|
2294
|
-
_lightingPreset?: string;
|
|
2295
|
-
_useIndividualAspects?: boolean;
|
|
2296
|
-
/** When true, page margins without a texture are discarded instead of drawn as
|
|
2297
|
-
* transparent: they no longer block the pages behind them and you can see
|
|
2298
|
-
* through to the underlying spread. */
|
|
2299
|
-
_seeThroughMargins?: boolean;
|
|
2300
|
-
/** When false, the 90° rotate-view feature is disabled and its UI is hidden. Defaults to true. */
|
|
2301
|
-
_allowRotation?: boolean;
|
|
2302
|
-
_startPageIdx?: number;
|
|
2303
|
-
/** Base URL for the IIIF image server (hi-res streaming). */
|
|
2304
|
-
_iiifBaseUrl?: string;
|
|
2305
|
-
}
|
|
2306
|
-
export class BookViewer {
|
|
2307
|
-
#private;
|
|
2308
|
-
static _getPresets: typeof getPresets;
|
|
2309
|
-
readonly _ready: Promise<void>;
|
|
2310
|
-
constructor(options: BookViewerOptions);
|
|
2311
|
-
goto(pageIdx: number): Promise<void>;
|
|
2312
|
-
zoom(delta: number): void;
|
|
2313
|
-
/**
|
|
2314
|
-
* Rotates the view by a 90° increment around the vertical axis: `1` turns
|
|
2315
|
-
* the book to the right (clockwise), `-1` to the left (counter-clockwise).
|
|
2316
|
-
*/
|
|
2317
|
-
rotateView(direction: 1 | -1): void;
|
|
2318
|
-
/** Whether the 90° rotate-view feature is enabled. */
|
|
2319
|
-
_allowRotation(): boolean;
|
|
2320
|
-
/**
|
|
2321
|
-
* Returns whether the camera is zoomed in beyond the fit view. This is the
|
|
2322
|
-
* complement of "the whole spread fits the viewport": when every currently
|
|
2323
|
-
* visible image shows its full texture (`[0, 0, 1, 1]` bounds) the view is
|
|
2324
|
-
* zoomed out, and any image cut off by the viewport means it is zoomed in.
|
|
2325
|
-
* A page that is part of the current view but entirely out of the viewport
|
|
2326
|
-
* (e.g. one page of a spread fills the screen while the other is off-screen)
|
|
2327
|
-
* also counts as zoomed in. Based on the last rendered frame's on-screen
|
|
2328
|
-
* bounds, so it stays accurate after zooming back out.
|
|
2329
|
-
*/
|
|
2330
|
-
isZoomedIn(): boolean;
|
|
2331
|
-
setLightingPreset(name: string): void;
|
|
2332
|
-
_getCurrentPage(): number;
|
|
2333
|
-
_getPageCount(): number;
|
|
2334
|
-
_nextPage(grabRow?: number): void;
|
|
2335
|
-
_prevPage(grabRow?: number): void;
|
|
2336
|
-
_hookImageBook3d(img: MicrioImage): void;
|
|
2337
|
-
}
|
|
2338
2962
|
|
|
2339
2963
|
/**
|
|
2340
2964
|
* Manages the HTML `<canvas>` element used for WebGL rendering,
|
|
@@ -2364,361 +2988,201 @@ declare module '@micrio/client' {
|
|
|
2364
2988
|
* This likely affects how viewports are calculated or limited.
|
|
2365
2989
|
* @param width The horizontal offset margin in pixels.
|
|
2366
2990
|
* @param height The vertical offset margin in pixels.
|
|
2367
|
-
|
|
2991
|
+
*/
|
|
2368
2992
|
setMargins(width: number, height: number): void;
|
|
2369
2993
|
}
|
|
2370
2994
|
|
|
2995
|
+
|
|
2371
2996
|
/**
|
|
2372
|
-
*
|
|
2373
|
-
*
|
|
2997
|
+
* Engine-wide constants and math values.
|
|
2998
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2999
|
+
* @internal
|
|
2374
3000
|
*/
|
|
2375
|
-
export
|
|
2376
|
-
|
|
3001
|
+
export {};
|
|
3002
|
+
|
|
2377
3003
|
|
|
2378
3004
|
/**
|
|
2379
|
-
*
|
|
2380
|
-
* Translates browser events into camera movements (pan, zoom), dispatches custom Micrio events,
|
|
2381
|
-
* and manages interaction states like panning, pinching, and enabled/disabled states.
|
|
2382
|
-
* Accessed via `micrio.events`.
|
|
3005
|
+
* Mathematical utility functions and easing curve implementation.
|
|
2383
3006
|
* @author Marcel Duin <marcel@micr.io>
|
|
3007
|
+
* @internal
|
|
2384
3008
|
*/
|
|
2385
|
-
export
|
|
2386
|
-
|
|
2387
|
-
/** Writable store indicating if event handling is currently enabled. Set to false during tours or animations. */
|
|
2388
|
-
enabled: Writable<boolean>;
|
|
2389
|
-
/** Getter for the current value of the {@link enabled} store. */
|
|
2390
|
-
get $enabled(): boolean;
|
|
2391
|
-
/**
|
|
2392
|
-
* The Events constructor.
|
|
2393
|
-
* @param micrio The main HTMLMicrioElement instance.
|
|
2394
|
-
*/
|
|
2395
|
-
constructor(micrio: HTMLMicrioElement);
|
|
2396
|
-
/**
|
|
2397
|
-
* Checks if the user is currently interacting with the map via panning, pinching, or wheeling.
|
|
2398
|
-
* @returns True if the user is actively navigating.
|
|
2399
|
-
*/
|
|
2400
|
-
get isNavigating(): boolean;
|
|
2401
|
-
/** Hooks all necessary event listeners based on current settings. */
|
|
2402
|
-
hook(): void;
|
|
2403
|
-
/** Unhooks all attached event listeners. */
|
|
2404
|
-
unhook(): void;
|
|
2405
|
-
/** Hooks keyboard event listeners. */
|
|
2406
|
-
hookKeys(): void;
|
|
2407
|
-
/** Unhooks keyboard event listeners. */
|
|
2408
|
-
unhookKeys(): void;
|
|
2409
|
-
/** Hooks zoom-related event listeners (pinch, scroll, double-tap/click). */
|
|
2410
|
-
hookZoom(): void;
|
|
2411
|
-
/** Unhooks zoom-related event listeners. */
|
|
2412
|
-
unhookZoom(): void;
|
|
2413
|
-
/** Flag indicating if scroll listeners are attached. */
|
|
2414
|
-
get scrollHooked(): boolean;
|
|
2415
|
-
/** Hooks mouse wheel/scroll event listeners. */
|
|
2416
|
-
hookScroll(): void;
|
|
2417
|
-
/** Unhooks mouse wheel/scroll event listeners. */
|
|
2418
|
-
unhookScroll(): void;
|
|
2419
|
-
/** Hooks touch pinch and macOS gesture event listeners. */
|
|
2420
|
-
hookPinch(): void;
|
|
2421
|
-
/** Unhooks touch pinch and macOS gesture event listeners. */
|
|
2422
|
-
unhookPinch(): void;
|
|
2423
|
-
/** Hooks pointer down/move/up listeners for drag panning. */
|
|
2424
|
-
hookDrag(): void;
|
|
2425
|
-
/** Unhooks pointer listeners for drag panning. */
|
|
2426
|
-
unhookDrag(): void;
|
|
2427
|
-
/** Hooks the native context menu copy crop handler (`data-contextmenu-crop`). */
|
|
2428
|
-
hookContextMenuCopy(): void;
|
|
2429
|
-
/** Unhooks the native context menu copy crop handler. */
|
|
2430
|
-
unhookContextMenuCopy(): void;
|
|
2431
|
-
}
|
|
3009
|
+
export {};
|
|
3010
|
+
|
|
2432
3011
|
|
|
2433
3012
|
/**
|
|
2434
|
-
*
|
|
2435
|
-
*
|
|
2436
|
-
*
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
*
|
|
3013
|
+
* Abstract base class for camera implementations (2D and 360).
|
|
3014
|
+
* Provides shared pinch mechanics and the common camera interface.
|
|
3015
|
+
* @internal
|
|
3016
|
+
*/
|
|
3017
|
+
export {};
|
|
3018
|
+
|
|
3019
|
+
|
|
3020
|
+
/**
|
|
3021
|
+
* Manages the Micrio compute engine, render loop, tile loading, and WebGL integration.
|
|
3022
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3023
|
+
*/
|
|
3024
|
+
export {};
|
|
3025
|
+
|
|
3026
|
+
|
|
3027
|
+
/**
|
|
3028
|
+
* Handles kinetic scrolling/dragging behavior after user interaction stops.
|
|
3029
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3030
|
+
* @internal
|
|
3031
|
+
*/
|
|
3032
|
+
export {};
|
|
3033
|
+
|
|
3034
|
+
|
|
3035
|
+
/**
|
|
3036
|
+
* High-performance matrix and vector operations for WebGL.
|
|
3037
|
+
* Ported from gl-matrix 3.2.1 (Copyright (c) 2015-2020, Brandon Jones, Colin MacKenzie IV).
|
|
3038
|
+
* Originally ported to AssemblyScript/WASM by marcel@micr.io, 2020.
|
|
3039
|
+
* Re-ported to TypeScript for the Micrio engine.
|
|
2443
3040
|
*
|
|
2444
|
-
* @
|
|
3041
|
+
* @license MIT
|
|
3042
|
+
* @internal
|
|
3043
|
+
*/
|
|
3044
|
+
export {};
|
|
3045
|
+
|
|
3046
|
+
|
|
3047
|
+
export {};
|
|
3048
|
+
|
|
3049
|
+
|
|
3050
|
+
/**
|
|
3051
|
+
* Shared data structures for the Micrio engine: View, Coordinates, Viewport, DrawRect.
|
|
2445
3052
|
* @author Marcel Duin <marcel@micr.io>
|
|
3053
|
+
* @internal
|
|
2446
3054
|
*/
|
|
2447
|
-
export
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
readonly view: Writable<Models.Camera.View | undefined>;
|
|
2481
|
-
/** Getter for the current value of the {@link view} store. */
|
|
2482
|
-
get $view(): Models.Camera.View | undefined;
|
|
2483
|
-
/**
|
|
2484
|
-
* Writable store holding the currently active marker within *this specific image*.
|
|
2485
|
-
* Can be set with a marker ID string or a full marker object. Setting to undefined closes the marker.
|
|
2486
|
-
*/
|
|
2487
|
-
readonly marker: Writable<Models.ImageData.Marker | string | undefined>;
|
|
2488
|
-
/** Getter for the current value of the {@link marker} store. */
|
|
2489
|
-
get $marker(): Models.ImageData.Marker | undefined;
|
|
2490
|
-
/** Writable store holding the currently displayed layer index (for Omni objects). */
|
|
2491
|
-
readonly layer: Writable<number>;
|
|
2492
|
-
/** Creates an Image state controller and subscribes to view/marker changes to synchronise with the main element state. @param image The parent MicrioImage instance. */
|
|
2493
|
-
constructor(image: MicrioImage);
|
|
2494
|
-
}
|
|
2495
|
-
}
|
|
3055
|
+
export {};
|
|
3056
|
+
|
|
3057
|
+
|
|
3058
|
+
/**
|
|
3059
|
+
* Manages downloading and processing image textures for WebGL using Web Workers.
|
|
3060
|
+
* @internal
|
|
3061
|
+
*/
|
|
3062
|
+
export {};
|
|
3063
|
+
|
|
3064
|
+
|
|
3065
|
+
export {};
|
|
3066
|
+
|
|
3067
|
+
|
|
3068
|
+
/**
|
|
3069
|
+
* Represents a single image source (tiled or single) within a TileCanvas.
|
|
3070
|
+
* Handles tile pyramid, layer management, and tile culling.
|
|
3071
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3072
|
+
* @internal
|
|
3073
|
+
*/
|
|
3074
|
+
export {};
|
|
3075
|
+
|
|
3076
|
+
|
|
3077
|
+
/**
|
|
3078
|
+
* The WebGL rendering module. Handles shader compilation, WebGL context setup,
|
|
3079
|
+
* texture management, and drawing operations called by the Engine module.
|
|
3080
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3081
|
+
*/
|
|
3082
|
+
export {};
|
|
3083
|
+
|
|
3084
|
+
|
|
3085
|
+
/** Names of all icons available in the Micrio UI icon library. */
|
|
3086
|
+
export type IconName = 'zoomIn' | 'zoomOut' | 'fullscreenEnter' | 'fullscreenLeave' | 'close' | 'next' | 'down' | 'prev' | 'up' | 'rotateLeft' | 'rotateRight' | 'play' | 'pause' | 'subtitles' | 'subtitlesOff' | 'muted' | 'unmuted' | 'playFilled' | 'a11y' | 'menu' | 'audio' | 'video' | 'share' | 'error' | 'chevronDown' | 'link' | 'linkExt' | 'ellipsisVertical' | 'image' | 'layerGroup';
|
|
3087
|
+
|
|
2496
3088
|
|
|
2497
3089
|
/**
|
|
2498
|
-
*
|
|
2499
|
-
*
|
|
2500
|
-
|
|
3090
|
+
* Media player type definitions and interfaces.
|
|
3091
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3092
|
+
*/
|
|
3093
|
+
export {};
|
|
3094
|
+
|
|
3095
|
+
|
|
3096
|
+
/**
|
|
3097
|
+
* Lightweight inline SVG icon definitions, replacing @fortawesome/free-solid-svg-icons.
|
|
3098
|
+
* Each icon is a tuple: [width, height, svgPath].
|
|
3099
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3100
|
+
*/
|
|
3101
|
+
export {};
|
|
3102
|
+
|
|
3103
|
+
|
|
3104
|
+
export {};
|
|
3105
|
+
|
|
3106
|
+
|
|
3107
|
+
/**
|
|
3108
|
+
* Browser and OS detection utilities.
|
|
3109
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3110
|
+
*/
|
|
3111
|
+
export {};
|
|
3112
|
+
|
|
3113
|
+
|
|
3114
|
+
/**
|
|
3115
|
+
* Centralized data loading controller.
|
|
3116
|
+
* Uses the `bundle.json` endpoint which returns info + data for multiple
|
|
3117
|
+
* related images in a single request.
|
|
2501
3118
|
*
|
|
2502
|
-
*
|
|
2503
|
-
*
|
|
3119
|
+
* If the bundle fails the image is simply unavailable — there are no
|
|
3120
|
+
* individual `info.json` / `data.json` fallbacks.
|
|
2504
3121
|
*
|
|
2505
|
-
*
|
|
2506
|
-
* ```html
|
|
2507
|
-
* <micr-io id="image123"></micr-io>
|
|
2508
|
-
* <script>
|
|
2509
|
-
* const viewer = document.querySelector('micr-io');
|
|
2510
|
-
* viewer.open('image456');
|
|
2511
|
-
* viewer.addEventListener('marker-click', (e) => console.log(e.detail));
|
|
2512
|
-
* </script>
|
|
2513
|
-
* ```
|
|
3122
|
+
* This is the single source of truth for image info & data fetches.
|
|
2514
3123
|
*
|
|
2515
3124
|
* @author Marcel Duin <marcel@micr.io>
|
|
2516
|
-
|
|
2517
|
-
export
|
|
2518
|
-
|
|
2519
|
-
/** Observed attributes trigger `attributeChangedCallback` when changed. */
|
|
2520
|
-
static get observedAttributes(): string[];
|
|
2521
|
-
/** The Micrio library version number. */
|
|
2522
|
-
static VERSION: string;
|
|
2523
|
-
/**
|
|
2524
|
-
* Writable store holding the currently active main {@link MicrioImage}.
|
|
2525
|
-
* Use `<micr-io>.open()` to change the active image.
|
|
2526
|
-
* Subscribe to this store to react to image changes.
|
|
2527
|
-
* Access the current value directly using the {@link $current} getter.
|
|
2528
|
-
*/
|
|
2529
|
-
readonly current: Writable<MicrioImage | undefined>;
|
|
2530
|
-
/**
|
|
2531
|
-
* Getter for the current value of the {@link current} store.
|
|
2532
|
-
* Provides direct access to the active {@link MicrioImage} instance.
|
|
2533
|
-
* @readonly
|
|
2534
|
-
*/
|
|
2535
|
-
get $current(): MicrioImage | undefined;
|
|
2536
|
-
/** Getter for the virtual {@link Camera} instance of the currently active image. */
|
|
2537
|
-
get camera(): Camera | undefined;
|
|
2538
|
-
/** The controller managing the HTML `<canvas>` element, resizing, and viewport. */
|
|
2539
|
-
readonly canvas: Canvas;
|
|
2540
|
-
/** The controller managing user input events (mouse, touch, keyboard) and dispatching custom events. */
|
|
2541
|
-
readonly events: Events;
|
|
2542
|
-
/** The main state manager, providing access to various application states (UI visibility, active marker, tour, etc.). See {@link State.Main}. */
|
|
2543
|
-
readonly state: State.Main;
|
|
2544
|
-
/** Writable store indicating if barebone texture downloading is enabled (lower quality, less bandwidth). */
|
|
2545
|
-
readonly barebone: Writable<boolean>;
|
|
2546
|
-
/** Custom settings object provided programmatically, overriding server-fetched settings. */
|
|
2547
|
-
defaultSettings?: Partial<Models.ImageInfo.Settings>;
|
|
2548
|
-
/** Holds data for the current 360 space, if applicable (loaded via `data-space` attribute or API). */
|
|
2549
|
-
spaceData: Models.Spaces.Space | undefined;
|
|
2550
|
-
/** Holds bundle-level marker tours, available regardless of which image is shown. */
|
|
2551
|
-
bundleTours: Models.ImageData.MarkerTour[] | undefined;
|
|
2552
|
-
/** The current active gallery controller, if any. */
|
|
2553
|
-
gallery: Gallery | undefined;
|
|
2554
|
-
/** Destroys the Micrio instance, cleans up resources, and removes event listeners. */
|
|
2555
|
-
destroy(): void;
|
|
2556
|
-
/**
|
|
2557
|
-
* Opens a Micrio image by its Micrio ID (triggers a `bundle.json` download) or
|
|
2558
|
-
* by providing a pre-resolved {@link Models.ImageBundle.BundleImage}.
|
|
2559
|
-
*
|
|
2560
|
-
* @param idOrInfo A Micrio image ID string or a full {@link Models.ImageBundle.BundleImage} object.
|
|
2561
|
-
* @param opts Options for opening the image.
|
|
2562
|
-
* @returns The {@link MicrioImage} instance being opened.
|
|
2563
|
-
*/
|
|
2564
|
-
open(idOrInfo: string | Models.ImageBundle.BundleImage, opts?: {
|
|
2565
|
-
/** If true, keeps the grid view active instead of focusing on the opened image. */
|
|
2566
|
-
gridView?: boolean;
|
|
2567
|
-
/** An optional starting view to apply immediately. */
|
|
2568
|
-
startView?: Models.Camera.View;
|
|
2569
|
-
/** For 360 transitions, provides the direction vector from the previous image. */
|
|
2570
|
-
vector?: Models.Camera.Vector;
|
|
2571
|
-
/** Optional Gallery controller, used for gallery/grid views. */
|
|
2572
|
-
gallery?: Gallery;
|
|
2573
|
-
}): Promise<MicrioImage>;
|
|
2574
|
-
/**
|
|
2575
|
-
* Closes an opened MicrioImage and removes its canvas from the engine.
|
|
2576
|
-
* @param img The {@link MicrioImage} instance to close.
|
|
2577
|
-
*/
|
|
2578
|
-
close(img: MicrioImage): void;
|
|
2579
|
-
/** Getter for the current language code. */
|
|
2580
|
-
get lang(): string;
|
|
2581
|
-
/** Setter for the current language code. Triggers language change logic. */
|
|
2582
|
-
set lang(l: string);
|
|
2583
|
-
}
|
|
3125
|
+
*/
|
|
3126
|
+
export {};
|
|
3127
|
+
|
|
2584
3128
|
|
|
2585
3129
|
/**
|
|
2586
|
-
*
|
|
2587
|
-
*
|
|
3130
|
+
* DOM and general utility functions.
|
|
3131
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
2588
3132
|
*/
|
|
2589
|
-
export
|
|
2590
|
-
/** Focus on specific images within the grid, hiding others. Data: comma-separated image IDs. */
|
|
2591
|
-
focus = 0,
|
|
2592
|
-
/** Animate the main grid view to fit the bounding box of specified images. Data: comma-separated image IDs. */
|
|
2593
|
-
flyTo = 1,
|
|
2594
|
-
/** Focus on images containing markers with a specific tag. Data: tag name. */
|
|
2595
|
-
focusWithTagged = 2,
|
|
2596
|
-
/** Focus on images containing markers with a specific tag and fly to the marker views. Data: tag name. */
|
|
2597
|
-
focusTagged = 3,
|
|
2598
|
-
/** Reset the grid to its initial layout and view. */
|
|
2599
|
-
reset = 4,
|
|
2600
|
-
/** Navigate back one step in the grid layout history. */
|
|
2601
|
-
back = 5,
|
|
2602
|
-
/** Instantly switch a focused image back to its position within the grid layout. */
|
|
2603
|
-
switchToGrid = 6,
|
|
2604
|
-
/** Filter the grid to show only images that are part of the currently active marker tour. */
|
|
2605
|
-
filterTourImages = 7,
|
|
2606
|
-
/** Set a one-time crossfade duration for the *next* grid transition. Data: duration in seconds. */
|
|
2607
|
-
nextFadeDuration = 8
|
|
2608
|
-
}
|
|
3133
|
+
export {};
|
|
2609
3134
|
|
|
2610
|
-
/** The main Grid controller that arranges {@link MicrioImage} instances into a CSS grid layout. */
|
|
2611
|
-
export class Grid extends MicrioElement {
|
|
2612
|
-
#private;
|
|
2613
|
-
/** All {@link MicrioImage} instances managed by this grid. */
|
|
2614
|
-
get images(): readonly MicrioImage[];
|
|
2615
|
-
/** Get a grid {@link MicrioImage} instance by its image ID, if it is part of this grid. */
|
|
2616
|
-
getImage(id: string): MicrioImage | undefined;
|
|
2617
|
-
/** The currently focussed (single-view) image, if any. */
|
|
2618
|
-
get $focussed(): MicrioImage | undefined;
|
|
2619
|
-
/** The parent `<micrio-*>` element this grid is bound to. */
|
|
2620
|
-
micrio: HTMLMicrioElement;
|
|
2621
|
-
/** The main {@link MicrioImage} that serves as the grid viewport. */
|
|
2622
|
-
image: MicrioImage;
|
|
2623
|
-
/** Set the grid to display the given images, arranging them into a CSS grid. */
|
|
2624
|
-
set(images?: Models.Grid.GridImage[], opts?: {
|
|
2625
|
-
noHistory?: boolean;
|
|
2626
|
-
keepGrid?: boolean;
|
|
2627
|
-
horizontal?: boolean;
|
|
2628
|
-
duration?: number;
|
|
2629
|
-
view?: Models.Camera.View;
|
|
2630
|
-
noCamAni?: boolean;
|
|
2631
|
-
forceAreaAni?: boolean;
|
|
2632
|
-
noBlur?: boolean;
|
|
2633
|
-
noFade?: boolean;
|
|
2634
|
-
transition?: Models.Grid.GridSetTransition;
|
|
2635
|
-
forceAni?: boolean;
|
|
2636
|
-
coverLimit?: boolean;
|
|
2637
|
-
cover?: boolean;
|
|
2638
|
-
scale?: number;
|
|
2639
|
-
columns?: number;
|
|
2640
|
-
}): Promise<MicrioImage[]>;
|
|
2641
|
-
/** Reset the grid to its initial layout (all gallery images), clearing all history. */
|
|
2642
|
-
reset(duration?: number, noCamAni?: boolean, forceAni?: boolean): Promise<MicrioImage[]>;
|
|
2643
|
-
/** Navigate to the previous layout state from the history stack. */
|
|
2644
|
-
back(duration?: number): Promise<void>;
|
|
2645
|
-
/** Focus the grid on a single image, optionally with a transition animation. */
|
|
2646
|
-
gridFocus(img: MicrioImage | undefined, opts?: Models.Grid.FocusOptions): Promise<void>;
|
|
2647
|
-
/** Remove focus from the currently focussed image and return to the grid overview. */
|
|
2648
|
-
blur(): void;
|
|
2649
|
-
/** Execute a grid action by type (e.g. `focus`, `reset`, `back`) with optional data and duration. */
|
|
2650
|
-
action(action: GridActionType | string, data?: string, duration?: number): void;
|
|
2651
|
-
/** Enlarge a specific grid cell to span the given number of columns/rows, re-laying out without history. */
|
|
2652
|
-
enlarge(idx: number, width: number, height?: number): Promise<MicrioImage[]>;
|
|
2653
|
-
}
|
|
2654
3135
|
|
|
2655
3136
|
/**
|
|
2656
|
-
*
|
|
2657
|
-
*
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
3137
|
+
* Data fetching utilities with caching support.
|
|
3138
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3139
|
+
*/
|
|
3140
|
+
export {};
|
|
3141
|
+
|
|
3142
|
+
|
|
3143
|
+
/**
|
|
3144
|
+
* ID utility functions for Micrio image identifiers.
|
|
3145
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3146
|
+
*/
|
|
3147
|
+
export {};
|
|
3148
|
+
|
|
3149
|
+
|
|
3150
|
+
export {};
|
|
3151
|
+
|
|
3152
|
+
|
|
3153
|
+
/**
|
|
3154
|
+
* Mathematical utility functions.
|
|
3155
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3156
|
+
*/
|
|
3157
|
+
export {};
|
|
3158
|
+
|
|
3159
|
+
|
|
3160
|
+
/**
|
|
3161
|
+
* The audio level rules an image's settings describe.
|
|
3162
|
+
*
|
|
3163
|
+
* `startVolume` and `mutedVolume` are parsed for every image, and the same three places
|
|
3164
|
+
* need to agree on them: the `volume` store the layout provides, the Web Audio master
|
|
3165
|
+
* gain, and the playlist's own element volume.
|
|
2661
3166
|
*
|
|
2662
|
-
* Instances are typically created and managed by the main {@link HTMLMicrioElement}.
|
|
2663
3167
|
* @author Marcel Duin <marcel@micr.io>
|
|
2664
|
-
|
|
2665
|
-
export
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
camera: Camera;
|
|
2685
|
-
/** Writable store holding the HTMLVideoElement if this image represents a video. */
|
|
2686
|
-
readonly video: Writable<HTMLVideoElement | undefined>;
|
|
2687
|
-
/** Writable store indicating if this image's canvas is currently visible and being rendered.
|
|
2688
|
-
* @readonly
|
|
2689
|
-
*/
|
|
2690
|
-
readonly visible: Writable<boolean>;
|
|
2691
|
-
/** Album information if this image is part of a V5 album. */
|
|
2692
|
-
album?: Models.Album | undefined;
|
|
2693
|
-
/** OmniUI instance, if this image is an omni 3D object. */
|
|
2694
|
-
omni: OmniUI | undefined;
|
|
2695
|
-
/** Grid controller instance, if this image is a grid container. */
|
|
2696
|
-
grid: Grid | undefined;
|
|
2697
|
-
/** Stores an error message if loading failed. */
|
|
2698
|
-
error: string | undefined;
|
|
2699
|
-
/** Options controlling this image instance's behaviour (embedding, area, parent camera usage). */
|
|
2700
|
-
opts: {
|
|
2701
|
-
/** Optional sub area [x, y, width, height] defining placement within a parent canvas (for embeds/galleries). */
|
|
2702
|
-
area?: Models.Camera.View;
|
|
2703
|
-
/** If true, this image is embedded within another image (affects rendering/camera). */
|
|
2704
|
-
isEmbed?: boolean;
|
|
2705
|
-
/** If true, uses the parent image's camera instead of creating its own (for switch/omni galleries). */
|
|
2706
|
-
useParentCamera?: boolean;
|
|
2707
|
-
};
|
|
2708
|
-
/**
|
|
2709
|
-
* Adds an embedded MicrioImage (representing another Micrio image or video) within this image.
|
|
2710
|
-
* @param info Partial info data for the embed.
|
|
2711
|
-
* @param settings Optional settings for the embed.
|
|
2712
|
-
* @param area The placement area `[x, y, width, height]` within the parent image.
|
|
2713
|
-
* @param opts Embedding options (opacity, fit, etc.).
|
|
2714
|
-
* @returns The newly created embedded {@link MicrioImage} instance.
|
|
2715
|
-
*/
|
|
2716
|
-
addEmbed(info: Partial<Models.ImageInfo.ImageInfo>, settings: Partial<Models.ImageInfo.Settings> | undefined, area: Models.Camera.View, opts?: Models.Embeds.EmbedOptions): MicrioImage;
|
|
2717
|
-
/**
|
|
2718
|
-
* Gets the HTMLMediaElement associated with a video embed ID.
|
|
2719
|
-
* @param id The embed identifier.
|
|
2720
|
-
* @returns The media element, or undefined if not found.
|
|
2721
|
-
*/
|
|
2722
|
-
getEmbedMediaElement(id: string): HTMLMediaElement | undefined;
|
|
2723
|
-
}
|
|
3168
|
+
*/
|
|
3169
|
+
export {};
|
|
3170
|
+
|
|
3171
|
+
|
|
3172
|
+
/**
|
|
3173
|
+
* Object manipulation utilities.
|
|
3174
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3175
|
+
*/
|
|
3176
|
+
export {};
|
|
3177
|
+
|
|
3178
|
+
|
|
3179
|
+
/**
|
|
3180
|
+
* 360° space navigation utilities.
|
|
3181
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3182
|
+
*/
|
|
3183
|
+
export {};
|
|
3184
|
+
|
|
3185
|
+
|
|
3186
|
+
export {};
|
|
3187
|
+
|
|
2724
3188
|
}
|