@micrio/client 7.2.0 → 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/micrio.min.d.ts CHANGED
@@ -13,6 +13,7 @@ declare module '@micrio/client' {
13
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;
@@ -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 */
@@ -50,6 +52,7 @@ declare module '@micrio/client' {
50
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:
@@ -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,6 +179,7 @@ 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 {
@@ -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,6 +331,7 @@ declare module '@micrio/client' {
324
331
  };
325
332
  }
326
333
  }
334
+
327
335
  /**
328
336
  * # Base image data
329
337
  *
@@ -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
- /** Which frame is 0deg rotation */
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
- /** Gallery is omni object photography over 2 axes */
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 */
@@ -741,6 +753,7 @@ declare module '@micrio/client' {
741
753
  panZoom?: 'cells' | 'grid';
742
754
  };
743
755
  }
756
+
744
757
  export namespace Grid {
745
758
  /** Grid .focus() transition from current view */
746
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';
@@ -771,6 +784,7 @@ declare module '@micrio/client' {
771
784
  blur?: number;
772
785
  }
773
786
  }
787
+
774
788
  /**
775
789
  * # Image content data
776
790
  *
@@ -1237,6 +1251,7 @@ declare module '@micrio/client' {
1237
1251
  tours?: ImageData.MarkerTour[];
1238
1252
  }
1239
1253
  }
1254
+
1240
1255
  export type MicrioEvent<T = unknown> = Event & {
1241
1256
  detail: T;
1242
1257
  };
@@ -1325,6 +1340,11 @@ declare module '@micrio/client' {
1325
1340
  'autoplay-blocked': void;
1326
1341
  /** Media was blocked from autoplaying */
1327
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
+ };
1328
1348
  /** Media has started playing */
1329
1349
  'media-play': void;
1330
1350
  /** Media has stopped playing */
@@ -1359,469 +1379,232 @@ declare module '@micrio/client' {
1359
1379
  export type MicrioEventMap = {
1360
1380
  [K in keyof MicrioEventDetails]: MicrioEvent<MicrioEventDetails[K]>;
1361
1381
  };
1362
- }
1363
1382
 
1364
- /** Names of all icons available in the Micrio UI icon library. */
1365
- 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';
1366
1383
 
1367
- /**
1368
- * # Store API in Micrio
1369
- *
1370
- * Micrio uses a custom store implementation (`$core/store`) for its internal state management.
1371
- * The API is compatible with stores (writable, readable, get, subscribe).
1372
- *
1373
- * This means that changes in values can passively trigger state updates.
1374
- *
1375
- * 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.
1376
- *
1377
- * Typically, for accessing the data directly instead of its store, Micrio offers `$` prefixes to any store properties:
1378
- *
1379
- * ```js
1380
- * // This is the current active image in <micr-io> (.current is the store Writable)
1381
- * const image = micrio.$current;
1382
- *
1383
- * // The current image ImageInfo value
1384
- * const info = image.$info;
1385
- *
1386
- * // Log the current image resolution
1387
- * console.log(`The current image is ${info.width} x ${info.height}px`);
1388
- *
1389
- * // The current CultureData value of the current MicrioImage
1390
- * console.log(micrio.$current.$data);
1391
- * ```
1392
- *
1393
- * An example of setting and subscribing to the {@link MicrioImage.data} writable store:
1394
- *
1395
- * ```js
1396
- *
1397
- * // Subscribe to any changes in its data (markers, tours, etc)
1398
- * image.data.subscribe(data => {
1399
- * // Data for this image been set, removed or changed
1400
- * // This also triggers when the image data has been loaded from the server
1401
- * if(data) console.log(`The image now has ${data.markers.length} markers`);
1402
- * else console.log('The image data is now empty.');
1403
- * });
1404
- *
1405
- * // Let's set the image data to something. It expects ImageData.
1406
- * image.data.set({
1407
- * markers: [{
1408
- * "title": "My First Marker",
1409
- * "x": .5,
1410
- * "y": .5
1411
- * }]
1412
- * });
1413
- *
1414
- * // Immediately access the data
1415
- * console.log('The data has been set to', image.$data);
1416
- * ```
1417
- *
1418
- * ## List of stores used by Micrio:
1419
- *
1420
- * | Property | Direct value getter | Type | Description |
1421
- * | ----------- | ----------- | ------------- | ---- |
1422
- * | **`<micr-io>` Element** |||
1423
- * | .{@link HTMLMicrioElement.current} | {@link HTMLMicrioElement.$current} | {@link Writable}&lt;{@link MicrioImage}&gt; | The current active and shown {@link MicrioImage} |
1424
- * | **`<micr-io>.state` controller** |||
1425
- * | .{@link State.Main.tour} | {@link State.Main.$tour} | {@link Writable}&lt;{@link Models.ImageData.MarkerTour} &#124; {@link Models.ImageData.VideoTour}&gt; | The current running VideoTour or MarkerTour |
1426
- * | .{@link State.Main.marker} | {@link State.Main.$marker} | {@link Writable}&lt;{@link Models.ImageData.Marker}&gt; | The current opened marker in the current opened {@link MicrioImage} |
1427
- * **Individual `MicrioImage`** |||
1428
- * | .{@link MicrioImage.info} | {@link MicrioImage.$info} | {@link Readable}&lt;{@link Models.ImageInfo}&gt; | The static image base info |
1429
- * | .{@link MicrioImage.data} | {@link MicrioImage.$data} | {@link Writable}&lt;{@link Models.ImageData}&gt; | The image data (markers, tours, etc) |
1430
- * **`MicrioImage.state` controller** |||
1431
- * | .{@link State.Image.view} | {@link State.Image.$view} | {@link Writable}&lt;{@link Models.Camera.View}&gt; | The current viewport |
1432
- * | .{@link State.Main.marker} | {@link State.Main.$marker} | {@link Writable}&lt;{@link Models.ImageData.Marker}&gt; | The current opened marker of this image |
1433
- *
1434
- *
1435
- */
1436
- /** Callback type for receiving store value updates. */
1437
- type Subscriber<T> = (value: T) => void;
1438
- /** Cleanup function returned by store subscription methods. */
1439
- type Unsubscriber = () => void;
1440
- /** Transformer function used with Writable.update(). */
1441
- type Updater<T> = (value: T) => T;
1442
- /** A read-only store that emits value changes to subscribers. */
1443
- export interface Readable<T> {
1444
- subscribe: (this: void, run: Subscriber<T>, invalidate?: (value?: T) => void) => Unsubscriber;
1445
1384
  }
1446
- /** A writable store that supports setting and updating its value. */
1447
- export interface Writable<T> extends Readable<T> {
1448
- set: (value: T) => void;
1449
- update: (fn: Updater<T>) => void;
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;
1450
1392
  }
1451
- /** Synchronously reads the current value of a store by subscribing and immediately unsubscribing. */
1452
- export function get<T>(store: {
1453
- subscribe: (fn: Subscriber<T>) => Unsubscriber;
1454
- }): T;
1455
- export type { Subscriber, Unsubscriber, Updater };
1456
1393
 
1457
- /**
1458
- * Represents the virtual camera used to view a {@link MicrioImage}.
1459
- * Provides methods for controlling the viewport (position, zoom, rotation),
1460
- * converting between screen and image coordinates, and managing animations.
1461
- *
1462
- * Instances are typically accessed via `micrioImage.camera`.
1463
- * @author Marcel Duin <marcel@micr.io>
1464
- */
1465
- export class Camera {
1394
+
1395
+ export class MicrioAudioLocation {
1466
1396
  #private;
1467
- /** Possible .zoom() override for Book3D */
1468
- _zoomOverride: ((n: number) => void) | undefined;
1469
- /** Possible override for Book3D */
1470
- _isZoomedInOverride: (() => boolean) | undefined;
1471
- /** Possible override for `_getXYDirect` for Book3D */
1472
- _getXYDirectOverride: ((x: number, y: number) => Float64Array) | undefined;
1473
- /** getMatrix book3d override */
1474
- _getMatrixOverride: ((x: number, y: number, scale: number, rotX?: number, rotY?: number, rotZ?: number, scaleX?: number, scaleY?: number,
1475
- /** The element's content width in CSS pixels (used to convert `scale` to a world size). */
1476
- width?: number) => Float32Array) | undefined;
1477
- /**
1478
- * Gets the current image view rectangle [x0, y0, width, height].
1479
- */
1480
- getView: () => Models.Camera.View;
1481
- /**
1482
- * Gets the current image view rectangle [x0, y0, width, height] relative to the image (0-1).
1483
- * @returns The live Float64Array buffer from the engine.
1484
- */
1485
- getViewRaw: () => Float64Array;
1486
- /**
1487
- * Sets the camera view instantly to the specified viewport.
1488
- * @param view The target viewport as a View [x0, y0, width, height].
1489
- * @param opts Options for setting the view.
1490
- */
1491
- setView(view: Models.Camera.View, opts?: {
1492
- /** If true, allows setting a view outside the normal image boundaries. */
1493
- noLimit?: boolean;
1494
- /** If true (for 360), corrects the view based on the `trueNorth` setting. */
1495
- correctNorth?: boolean;
1496
- /** If true, prevents triggering a render after setting the view. */
1497
- noRender?: boolean;
1498
- }): void;
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;
1499
1405
  /**
1500
- * Gets the relative image coordinates [x, y, scale, depth, yaw?, pitch?] corresponding to a screen coordinate.
1501
- * Rounds the result for cleaner output.
1502
- * @param x The screen X coordinate in pixels.
1503
- * @param y The screen Y coordinate in pixels.
1504
- * @param absolute If true, treats x/y as absolute browser window coordinates.
1505
- * @param noLimit If true, allows returning coordinates outside the image bounds (0-1).
1506
- * @returns A Float64Array containing the relative image coordinates [x, y, scale, depth, yaw?, pitch?].
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]`.
1507
1409
  */
1508
- getCoo(x: number, y: number, absolute?: boolean, noLimit?: boolean): Float64Array;
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;
1509
1444
  /**
1510
- * Gets the screen coordinates [x, y, scale, depth] corresponding to relative image coordinates.
1511
- * @param x The image X coordinate (0-1).
1512
- * @param y The image Y coordinate (0-1).
1513
- * @param abs If true, returns absolute browser window coordinates instead of element-relative.
1514
- * @param radius Optional offset radius for 360 calculations.
1515
- * @param rotation Optional offset rotation (radians) for 360 calculations.
1516
- * @param noTrueNorth If true (for 360), ignores the `trueNorth` correction.
1517
- * @returns A Float64Array containing the screen coordinates [x, y, scale, depth].
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).
1518
1447
  */
1519
- getXY(x: number, y: number, abs?: boolean, radius?: number, rotation?: number, noTrueNorth?: boolean): Float64Array;
1448
+ rotateView(direction: 1 | -1): void;
1449
+ /** Whether the 90° rotate-view feature is enabled. */
1450
+ _allowRotation(): boolean;
1520
1451
  /**
1521
- * Sets the center of the screen to the specified image coordinates and scale instantly.
1522
- * @param x The target image X coordinate (0-1).
1523
- * @param y The target image Y coordinate (0-1).
1524
- * @param scale The target scale (optional, defaults to current scale).
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.
1525
1460
  */
1526
- setCoo(x: number, y: number, scale?: number): void;
1527
- /** Gets the current camera zoom scale. */
1528
- getScale: () => number;
1529
- /** Gets the scale at which the image fully covers the viewport. */
1530
- getCoverScale: () => number;
1531
- /** Gets the minimum allowed camera zoom scale. */
1532
- getMinScale: () => number;
1533
- /** Sets the minimum allowed camera zoom scale. */
1534
- setMinScale(s: number): void;
1535
- /** Sets the minimum screen size ratio that the image must occupy, restricting zoom-out. */
1536
- setMinScreenSize(s: number): void;
1537
- /** Checks if the camera is zoomed in to the maximum allowed scale or beyond. */
1538
- isZoomedIn: () => boolean;
1539
- /** Checks if the camera is fully zoomed out. */
1540
- isZoomedOut: (full?: boolean) => boolean;
1541
- /** Gets the current viewing direction (yaw) in 360 mode. @returns The current yaw in radians. */
1542
- getDirection: () => number;
1543
- /** Gets the current viewing pitch in 360 mode. @returns The current pitch in radians. */
1544
- getPitch: () => number;
1545
- /**
1546
- * Sets the viewing direction (yaw/pitch) in 360 mode.
1547
- * @param yaw The target yaw in radians.
1548
- * @param pitch The target pitch in radians (defaults to current pitch).
1549
- */
1550
- setDirection(yaw: number, pitch?: number): void;
1551
- /**
1552
- * Sets a rectangular limit for camera navigation within the image.
1553
- * @param v The viewport limit [x, y, width, height] in image-relative coordinates.
1554
- */
1555
- setLimit(v: Models.Camera.View): void;
1556
- /**
1557
- * Sets whether the camera view should be limited to always cover the viewport.
1558
- * @param b If true, limits the view to cover the screen.
1559
- */
1560
- setCoverLimit(b: boolean): void;
1561
- getCoverLimit: () => boolean;
1562
- /**
1563
- * Sets horizontal and vertical pan limits for 360 images as percentages of the full sphere.
1564
- * @param xPerc Horizontal limit percentage (0-100).
1565
- * @param yPerc Vertical limit percentage (0-100).
1566
- */
1567
- set360RangeLimit(xPerc?: number, yPerc?: number): void;
1568
- /** Stops any ongoing camera animation immediately. */
1569
- stop(): void;
1570
- /** Pauses the current camera animation. */
1571
- pause(): void;
1572
- /** Resumes a previously paused camera animation and triggers a render. */
1573
- resume(): void;
1574
- /**
1575
- * Calculates a 4x4 transformation matrix for placing an object at specific coordinates
1576
- * with scale and rotation in 360 space. Used for CSS `matrix3d`.
1577
- * @param x The image X coordinate (0-1).
1578
- * @param y The image Y coordinate (0-1).
1579
- * @param scale The object scale multiplier.
1580
- * @param radius The object radius (distance from center, default 10). For Book3D images
1581
- * this is used as the element's content width in CSS pixels, so `scale` stays a fraction
1582
- * of the page width.
1583
- * @param rotX The object X rotation in radians.
1584
- * @param rotY The object Y rotation in radians.
1585
- * @param rotZ The object Z rotation in radians.
1586
- * @param transY Optional Y translation in 3D space.
1587
- * @param scaleX Optional non-uniform X scaling.
1588
- * @param scaleY Optional non-uniform Y scaling.
1589
- * @returns The resulting 4x4 matrix as a Float32Array.
1590
- */
1591
- getMatrix(x: number, y: number, scale?: number, radius?: number, rotX?: number, rotY?: number, rotZ?: number, transY?: number, scaleX?: number, scaleY?: number, noCorrectNorth?: boolean): Float32Array;
1592
- /**
1593
- * Sets the rendering area for this image within the main canvas.
1594
- * Used for grid/embed layout effects. Animates by default.
1595
- * @param v The target area rectangle [x0, y0, width, height] relative to the main canvas (0-1).
1596
- * @param opts Options for setting the area.
1597
- */
1598
- setArea(v: Models.Camera.View, opts?: {
1599
- direct?: boolean;
1600
- noDispatch?: boolean;
1601
- noRender?: boolean;
1602
- }): void;
1603
- /** Sets the 3D rotation for an embedded image (used for placing embeds in 360 space). */
1604
- setRotation(rotX?: number, rotY?: number, rotZ?: number): void;
1605
- /** [Omni] Gets the current rotation angle in radians based on the active frame index. */
1606
- getOmniRotation(): number;
1607
- /** [Omni] Gets the screen coordinates [x, y, scale, depth] for given 3D object coordinates. */
1608
- getOmniXY(x: number, y: number, z: number): Float64Array;
1609
- /**
1610
- * Animates the camera smoothly to a target viewport.
1611
- * @param view The target viewport as a View [x0, y0, width, height].
1612
- * @param opts Optional animation settings.
1613
- * @returns A Promise that resolves when the animation completes, or rejects if aborted.
1614
- */
1615
- flyToView(view: Models.Camera.View, opts?: Models.Camera.AnimationOptions & {
1616
- /** Set the starting animation progress percentage (0-1). */
1617
- progress?: number;
1618
- /** Base the progress override on this starting view. */
1619
- prevView?: Models.Camera.View;
1620
- /** If true, performs a "jump" animation (zooms out then in). */
1621
- isJump?: boolean;
1622
- /** For Omni objects: the target image frame index to animate to. */
1623
- omniIndex?: number;
1624
- /** If true, respects the image's maximum zoom limit during animation. */
1625
- limitZoom?: boolean;
1626
- /** If provided, adds a margin to the view. */
1627
- margin?: [number, number];
1628
- }): Promise<void>;
1629
- /**
1630
- * Animates the camera to a view showing the entire image (minimum zoom).
1631
- * @param opts Optional animation settings.
1632
- * @returns A Promise that resolves when the animation completes.
1633
- */
1634
- flyToFullView(opts?: Models.Camera.AnimationOptions): Promise<void>;
1635
- /**
1636
- * Animates the camera to a view where the image covers the viewport.
1637
- * @param opts Optional animation settings.
1638
- * @returns A Promise that resolves when the animation completes.
1639
- */
1640
- flyToCoverView(opts?: Models.Camera.AnimationOptions): Promise<void>;
1641
- /**
1642
- * Animates the camera to center on specific image coordinates and scale.
1643
- * @param coords The target coordinates [x, y, scale]. Scale is optional.
1644
- * @param opts Optional animation settings.
1645
- * @returns A Promise that resolves when the animation completes.
1646
- */
1647
- flyToCoo(coords: Models.Camera.Coords, opts?: Models.Camera.AnimationOptions): Promise<void>;
1648
- /**
1649
- * Performs an animated zoom centered on a specific screen point (or the current center).
1650
- * @param delta The amount to zoom (positive zooms out, negative zooms in).
1651
- * @param duration Forced duration in ms (0 for instant).
1652
- * @param x Screen pixel X-coordinate for zoom focus (optional, defaults to center).
1653
- * @param y Screen pixel Y-coordinate for zoom focus (optional, defaults to center).
1654
- * @param _speed Animation speed multiplier (optional).
1655
- * @param noLimit If true, allows zooming beyond image boundaries.
1656
- * @returns A Promise that resolves when the zoom animation completes.
1657
- */
1658
- zoom(delta: number, duration?: number, x?: number, y?: number, _speed?: number, noLimit?: boolean): Promise<void>;
1659
- /**
1660
- * Zooms in by a specified factor.
1661
- * @param factor Zoom factor (e.g., 1 = standard zoom step).
1662
- * @param duration Animation duration in ms.
1663
- * @param speed Animation speed multiplier.
1664
- * @returns A Promise that resolves when the animation completes.
1665
- */
1666
- zoomIn(factor?: number, duration?: number, speed?: number): Promise<void>;
1667
- /**
1668
- * Zooms out by a specified factor.
1669
- * @param factor Zoom factor (e.g., 1 = standard zoom step).
1670
- * @param duration Animation duration in ms.
1671
- * @param speed Animation speed multiplier.
1672
- * @returns A Promise that resolves when the animation completes.
1673
- */
1674
- zoomOut(factor?: number, duration?: number, speed?: number): Promise<void>;
1675
- /**
1676
- * Pans the camera view by a relative pixel amount.
1677
- * @param x The horizontal pixel distance to pan.
1678
- * @param y The vertical pixel distance to pan.
1679
- * @param duration Animation duration in ms (0 for instant).
1680
- * @param opts Options: render (force render), noLimit (allow panning outside bounds).
1681
- */
1682
- pan(x: number, y: number, duration?: number, opts?: {
1683
- render?: boolean;
1684
- noLimit?: boolean;
1685
- }): void;
1686
- /** Sets the camera zoom scale instantly. */
1687
- 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;
1688
1468
  }
1689
1469
 
1690
- /**
1691
- * Abstract base class for all Micrio custom HTML elements.
1692
- * Provides a standard lifecycle and prop/render pattern, store subscription helpers,
1693
- * and a context (provide/inject) system for parent-child communication.
1694
- */
1695
- export abstract class MicrioElement<_P extends object = Record<string, unknown>> extends HTMLElement {
1470
+
1471
+ export class PageFlipAnimator {
1696
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;
1697
1490
  }
1698
1491
 
1699
- /** UI chrome auto-hide/themming effects, imported only in the full build (see `coreStubAliases` in vite.config.js). */
1700
1492
 
1701
- export class MicrioAudioLocation {
1702
- #private;
1703
- constructor(micrio: HTMLMicrioElement, marker: Models.ImageData.Marker, ctx: AudioContext, is360: boolean);
1704
- destroy(): void;
1705
- }
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;
1706
1497
 
1707
- /** Manages spatial audio, playlist playback, and user interaction for Micrio images. */
1708
- export class MicrioAudioController {
1709
- #private;
1710
- constructor(micrio: HTMLMicrioElement, image: MicrioImage);
1711
- destroy(): void;
1712
- }
1713
1498
 
1714
1499
  /**
1715
- * Video tour controller. Manages playback and camera animation for video tours
1716
- * defined by a timeline of view rectangles and durations.
1717
- * @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.
1718
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
+ }
1719
1519
  /**
1720
- * Controls the playback of a video tour, animating the camera according
1721
- * to a predefined timeline and synchronizing with associated audio/video media.
1722
- * Instances are typically created and managed internally.
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.
1723
1531
  */
1724
- export class VideoTourInstance {
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 {
1725
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;
1726
1581
  /**
1727
- * Creates a VideoTourInstance.
1728
- * @param image The parent {@link MicrioImage} instance.
1729
- * @param data The {@link Models.ImageData.VideoTour} data object.
1730
- */
1731
- constructor(image: MicrioImage, data: Models.ImageData.VideoTour);
1732
- /** Cleans up the tour instance, stops animations, and re-hooks events if necessary. */
1733
- destroy(): void;
1734
- /** Parses the raw timeline data from the tour content into the internal `timeline` array. */
1735
- read(): void;
1736
- /**
1737
- * Checks all tour events against the given time and dispatches `tour-event`
1738
- * when an event becomes active or inactive.
1739
- * 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.
1740
1586
  */
1741
- updateEvents(time: number): void;
1742
- /** Getter for the total duration of the tour in seconds. */
1743
- get duration(): number;
1744
- /** Setter for the total duration (updates internal content). */
1745
- set duration(v: number);
1746
- /** Getter for the current paused state. */
1747
- get paused(): boolean;
1748
- /** Getter indicating if the tour has ended. */
1749
- get ended(): boolean;
1750
- /** Getter for the current playback time in seconds. */
1751
- get currentTime(): number;
1752
- /** Setter for the current playback time (seeks to the corresponding progress). */
1753
- set currentTime(v: number);
1754
- /** Getter for the current progress percentage (0-1). */
1755
- get progress(): number;
1756
- /** Setter for the current progress percentage (seeks to that point). */
1757
- set progress(v: number);
1758
- /** Starts or resumes tour playback. */
1759
- play(): void;
1760
- /** Pauses the tour playback. */
1761
- pause(): void;
1762
- }
1763
-
1764
- export interface MicrioSplitLink {
1765
- micrioId: string;
1766
- markerId?: string;
1767
- follows?: boolean;
1768
- }
1769
- export function parseSplitLink(raw?: string): MicrioSplitLink | undefined;
1770
- export function hasSplit(primary: MicrioImage): boolean;
1771
- export function getSplitSecondary(primary: MicrioImage): MicrioImage | undefined;
1772
- export function isSplitSecondary(image: MicrioImage): boolean;
1773
- export function openSplit(micrio: HTMLMicrioElement, primary: MicrioImage, link: MicrioSplitLink, opts?: {
1774
- isPassive?: boolean;
1775
- }): Promise<void>;
1776
- export function closeSplit(micrio: HTMLMicrioElement, primary: MicrioImage, opts?: {
1777
- keepSecondaryCanvas?: boolean;
1778
- }): void;
1779
- export function closeAllSplits(micrio: HTMLMicrioElement): void;
1780
-
1781
- /** Manages a collection of gallery images with navigation (swipe, switch, grid, album). */
1782
- export class Gallery {
1783
- #private;
1784
- readonly _items: Models.ImageInfo.ImageInfo[];
1785
- gotoId: (id: string) => Promise<MicrioImage | undefined>;
1786
- goto: (index: number) => Promise<MicrioImage | undefined>;
1787
- next: () => void;
1788
- prev: () => void;
1789
- }
1790
-
1791
- /** Manages omni 3D object rotation UI: dial, swipe gestures, frame navigation, and layer menu. */
1792
- export class OmniUI {
1793
- #private;
1794
- /** Navigate to a specific frame index. */
1795
- goto(i: number): void;
1796
- /** Active frame index currently displayed. */
1797
- get currentIndex(): number;
1798
- /** Initialize the omni UI: create frame objects, set up dial, swipe gestures, and layer menu. */
1799
- setup(): Promise<void>;
1800
- /** Tear down the omni UI, remove listeners, and clean up resources. */
1801
- destroy(): void;
1802
- /** Smoothly animate to a target frame index. */
1803
- 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;
1804
1600
  }
1805
1601
 
1806
- export class Vec3 {
1807
- #private;
1808
- _x: number;
1809
- _y: number;
1810
- _z: number;
1811
- constructor(_x?: number, _y?: number, _z?: number);
1812
- _clone(): Vec3;
1813
- _set(x: number, y: number, z: number): Vec3;
1814
- _copy(v: Vec3): Vec3;
1815
- _add(v: Vec3): Vec3;
1816
- _sub(v: Vec3): Vec3;
1817
- _length(): number;
1818
- _normalize(): Vec3;
1819
- _dot(v: Vec3): number;
1820
- _cross(v: Vec3): Vec3;
1821
- }
1822
1602
 
1823
1603
  /** Thickness of a single paper page in world-space units */
1824
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;
1825
1608
  /** Default page aspect ratio (height / width) — √2 ≅ A4 paper */
1826
1609
  export const DEFAULT_ASPECT: number;
1827
1610
  /** Use each page's own aspect ratio from source images instead of the book-wide average */
@@ -1909,6 +1692,52 @@ declare module '@micrio/client' {
1909
1692
  /** Active lighting preset name. Available: 'daylight', 'incandescent', 'candlelight', 'rainy day', 'moonlight', 'fireplace', 'haunted' */
1910
1693
  export const LIGHTING_PRESET = "daylight";
1911
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
+
1912
1741
  export { GRID_COLS, GRID_ROWS, VERTEX_COUNT } from "book/core/settings";
1913
1742
  export interface EdgeConstraint {
1914
1743
  _i: number;
@@ -1928,6 +1757,7 @@ declare module '@micrio/client' {
1928
1757
  export function addEdgeConstraint(i: number, j: number, restPositions: Float32Array, added: Set<string>, constrs: EdgeConstraint[]): void;
1929
1758
  export function addGridConstraints(baseIdx: number, add: (i: number, j: number) => void): void;
1930
1759
 
1760
+
1931
1761
  export { GRID_COLS, GRID_ROWS, VERTEX_COUNT } from "book/core/settings";
1932
1762
  export type { EdgeConstraint, BendingConstraint, TriangleData };
1933
1763
  export class PaperMesh {
@@ -1944,7 +1774,14 @@ declare module '@micrio/client' {
1944
1774
  readonly _yOffset: number;
1945
1775
  readonly _paperWidth: number;
1946
1776
  readonly _paperHeight: number;
1947
- constructor(yOffset?: number, paperWidth?: number, aspectRatio?: number);
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);
1948
1785
  protected _generateGrid(paperHeight: number): void;
1949
1786
  protected _generateTexCoords(): void;
1950
1787
  protected _generateTriangles(): void;
@@ -1956,109 +1793,171 @@ declare module '@micrio/client' {
1956
1793
  _computeNormals(): Float32Array;
1957
1794
  }
1958
1795
 
1959
- export class CoverMesh extends PaperMesh {
1960
- #private;
1961
- readonly _coverThickness: number;
1962
- readonly _coverScale: number;
1963
- readonly _coverScaleY: number;
1964
- constructor(yOffset?: number, paperWidth?: number, aspectRatio?: number, coverThickness?: number, coverScale?: number, coverScaleY?: number);
1965
- protected _generateGrid(): void;
1966
- protected _generateTexCoords(): void;
1967
- protected _generateTriangles(): void;
1968
- protected _generateDistanceConstraints(): void;
1969
- protected _generateBendingConstraints(): void;
1970
- protected _identifyBoundEdges(): void;
1971
- _computeNormals(): Float32Array;
1972
- }
1973
1796
 
1974
- export class OrbitCamera {
1975
- #private;
1976
- _theta: number;
1977
- _phi: number;
1978
- _radius: number;
1979
- _target: Vec3;
1980
- _rotateSpeed: number;
1981
- _zoomSpeed: number;
1982
- _minRadius: number;
1983
- _maxRadius: number;
1984
- _panBoundsMin: Vec3 | null;
1985
- _panBoundsMax: Vec3 | null;
1986
- _freeCamMode: boolean;
1987
- _canPanLeft: boolean;
1988
- _canPanRight: boolean;
1989
- _canPanUp: boolean;
1990
- _canPanDown: boolean;
1991
- _manualZoomActive: boolean;
1992
- _isZoomedIn(): boolean;
1993
- _fov: number;
1994
- _setCanvasSize(w: number, h: number): void;
1995
- _initContainRadius(bounds: {
1996
- minX: number;
1997
- maxX: number;
1998
- minZ: number;
1999
- maxZ: number;
2000
- }, margin: number): void;
2001
- _snap(): void;
2002
- _update(dt: number): void;
2003
- _isMoving(): boolean;
2004
- _getEye(): Vec3;
2005
- _getViewMatrix(): Mat4;
2006
- _setFreeCamMode(on: boolean): void;
2007
- _rotate(deltaTheta: number, deltaPhi: number, clampPhi?: boolean): void;
2008
- /**
2009
- * Rotates the view by a 90° step (`π/2`) around the vertical axis to either
2010
- * side: `+1` turns clockwise (right), `-1` counter-clockwise (left). The
2011
- * current target azimuth is snapped to the nearest 90° grid point first, so
2012
- * the view always rests on a 90° increment even after a free-drag orbit.
2013
- */
2014
- _rotateViewStep(direction: 1 | -1): void;
2015
- _getPickRay(screenX: number, screenY: number): {
2016
- origin: Vec3;
2017
- direction: Vec3;
2018
- };
2019
- _zoom(delta: number, hitPoint?: Vec3): void;
2020
- _pan(deltaX: number, deltaY: number): void;
2021
- _clampViewport(screenBounds: {
2022
- minX: number;
2023
- maxX: number;
2024
- minY: number;
2025
- maxY: number;
2026
- }, viewportW: number, viewportH: number, margin: number): void;
1797
+ export interface RayHit {
1798
+ _t: number;
1799
+ _point: Vec3;
1800
+ _meshIndex: number;
2027
1801
  }
1802
+ export function rayIntersectMeshes(meshes: readonly PaperMesh[], origin: Vec3, direction: Vec3): RayHit | null;
2028
1803
 
2029
- export interface LightingParam {
2030
- key: string;
2031
- default: number;
2032
- }
2033
- export interface LightingPreset {
2034
- name: string;
2035
- isAnimated: boolean;
2036
- params: LightingParam[];
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;
2037
1814
  }
2038
- export interface LightingState {
2039
- _lightDir: [number, number, number];
2040
- _lightColor: [number, number, number];
2041
- _ambientColor: [number, number, number];
2042
- _numPointLights: number;
2043
- _pointLightPos: Float32Array;
2044
- _pointLightColor: Float32Array;
2045
- _pointLightIntensity: Float32Array;
2046
- _bumpStrength: number;
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;
2047
1826
  }
2048
- export function getPresets(): LightingPreset[];
2049
- export function getPreset(name: string): LightingPreset | undefined;
2050
- export function computeLighting(presetName: string, params: Record<string, number>, time: number): LightingState;
2051
-
2052
- export function computeWeightFactor(progress: Float32Array, pageCount: number): number;
2053
- export function computePageSpineY(pageIndex: number, progress: number, weightFactor: number, totalStackHeight: number, pageCount: number, pageThickness: number): number;
2054
- export function computeAllPageFloors(progress: Float32Array, weightFactor: number, totalStackHeight: number, pageCount: number, pageThickness: number): Float32Array;
2055
- export function applySpineDelta(positions: Float32Array, delta: number): void;
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
+
2056
1919
 
2057
1920
  export function compileShader(gl: WebGL2RenderingContext, type: number, src: string): WebGLShader;
2058
1921
  export function createGLProgram(gl: WebGL2RenderingContext, vertSrc: string, fragSrc: string): WebGLProgram;
2059
1922
  export function setupTextureParams(gl: WebGL2RenderingContext, tex: WebGLTexture): void;
2060
1923
  export function createWhiteTexture(gl: WebGL2RenderingContext): WebGLTexture;
2061
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
+
2062
1961
  export class PaperRenderer {
2063
1962
  #private;
2064
1963
  _tiltShiftEnabled: boolean;
@@ -2111,233 +2010,956 @@ declare module '@micrio/client' {
2111
2010
  _render(camera: OrbitCamera): void;
2112
2011
  }
2113
2012
 
2114
- export class InputHandler {
2115
- #private;
2116
- _onPrevPage: (() => void) | null;
2117
- _onNextPage: (() => void) | null;
2118
- _onPageClick: ((x: number, y: number) => {
2119
- direction: 'prev' | 'next';
2120
- grabRow: number;
2121
- } | null) | null;
2122
- _lastClickGrabRow: number | null;
2123
- _onWheelZoom: ((screenX: number, screenY: number) => Vec3 | null) | null;
2124
- /** Override for the zoomed-in check, e.g. wired to the viewer's own viewport-fit logic. */
2125
- _isZoomedInFn: (() => boolean) | null;
2126
- _onPageDragStart: ((startX: number, startY: number) => void) | null;
2127
- _onPageDragMove: ((currentX: number, currentY: number) => void) | null;
2128
- _onPageDragEnd: (() => void) | null;
2129
- _operation: 'none' | 'orbit' | 'pan';
2130
- constructor(canvas: HTMLCanvasElement, camera: OrbitCamera, onActivity: () => void);
2131
- }
2132
2013
 
2133
- export class PageFlipAnimator {
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 {
2134
2023
  #private;
2135
- _hardCoverPages: Set<number>;
2136
- get _animating(): boolean;
2137
- _isPageAnimating(pageIndex: number): boolean;
2138
- /** -1 = flipping back (left→right), +1 = flipping forward (right→left), 0 = idle/dragging. */
2139
- _getPageDirection(pageIndex: number): number;
2140
- _getPageProgress(pageIndex: number): number;
2141
- _setPageProgress(pageIndex: number, value: number): void;
2142
- _instantFlip(mesh: PaperMesh, pageIndex: number): void;
2143
- _initSlots(pageCount: number): void;
2144
- _flipLeft(pageIndex?: number, grabRow?: number): void;
2145
- _flipRight(pageIndex?: number, grabRow?: number): void;
2146
- _beginDrag(pageIndex: number, grabRow: number): void;
2147
- _setDragProgress(pageIndex: number, progress: number): void;
2148
- _endDrag(pageIndex: number, direction: number): void;
2149
- _isPageDragging(pageIndex: number): boolean;
2150
- _reset(meshes: PaperMesh[]): void;
2151
- _update(dt: number, meshes: PaperMesh[], selectedPage: number, totalStackHeight: number, pageCount: number, pageThickness: number): void;
2152
- }
2153
-
2154
- /** Structure-of-arrays constraint layout for cache-friendly iteration. */
2155
- export interface ConstraintSet {
2156
- count: number;
2157
- i: Int32Array;
2158
- j: Int32Array;
2159
- restLength: Float32Array;
2160
- }
2161
- export interface SubstepParams {
2162
- dt: number;
2163
- solverIterations: number;
2164
- distanceCompliance: number;
2165
- bendingCompliance: number;
2166
- damping: number;
2167
- gravity: number;
2168
- gravityEnabled: boolean;
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}&lt;{@link MicrioImage}&gt; | The current active and shown {@link MicrioImage} |
2599
+ * | **`<micr-io>.state` controller** |||
2600
+ * | .{@link State.Main.tour} | {@link State.Main.$tour} | {@link Writable}&lt;{@link Models.ImageData.MarkerTour} &#124; {@link Models.ImageData.VideoTour}&gt; | The current running VideoTour or MarkerTour |
2601
+ * | .{@link State.Main.marker} | {@link State.Main.$marker} | {@link Writable}&lt;{@link Models.ImageData.Marker}&gt; | The current opened marker in the current opened {@link MicrioImage} |
2602
+ * **Individual `MicrioImage`** |||
2603
+ * | .{@link MicrioImage.info} | {@link MicrioImage.$info} | {@link Readable}&lt;{@link Models.ImageInfo}&gt; | The static image base info |
2604
+ * | .{@link MicrioImage.data} | {@link MicrioImage.$data} | {@link Writable}&lt;{@link Models.ImageData}&gt; | The image data (markers, tours, etc) |
2605
+ * **`MicrioImage.state` controller** |||
2606
+ * | .{@link State.Image.view} | {@link State.Image.$view} | {@link Writable}&lt;{@link Models.Camera.View}&gt; | The current viewport |
2607
+ * | .{@link State.Main.marker} | {@link State.Main.$marker} | {@link Writable}&lt;{@link Models.ImageData.Marker}&gt; | 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;
2169
2698
  }
2170
- /** Flatten a mesh's {_i, _j, _restLength} constraint list into SoA buffers. */
2171
- export function buildConstraintSet(constraints: EdgeConstraint[] | BendingConstraint[]): ConstraintSet;
2699
+
2700
+
2701
+ export {};
2702
+
2703
+
2704
+ export {};
2705
+
2706
+
2707
+ export {};
2708
+
2709
+
2710
+ export {};
2711
+
2712
+
2713
+ export {};
2714
+
2715
+
2172
2716
  /**
2173
- * Run one XPBD substep over all vertices and constraints.
2174
- * Mutates `positions` / `velocities` in place and writes the start-of-step
2175
- * position backup into `prevPositions`.
2717
+ * Context object providing access to shared state for event handlers.
2718
+ * This is passed to each handler module to avoid circular dependencies.
2176
2719
  */
2177
- 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;
2178
-
2179
- export interface SolverSettings {
2180
- _solverIterations: number;
2181
- _substeps: number;
2182
- _distanceCompliance: number;
2183
- _bendingCompliance: number;
2184
- _damping: number;
2185
- _gravity: number;
2186
- _gravityEnabled: boolean;
2720
+ export interface EventContext {
2187
2721
  }
2188
- export function isSolverReady(): boolean;
2189
- export function initSolver(meshes: PaperMesh[], pageCount: number): Promise<void>;
2190
- export function dispatchSolve(subDt: number, activeIndices: number[], substeps: number, solverSettings: SolverSettings, meshes: PaperMesh[], progress: Float32Array, totalStackHeight: number, pageCount: number, pageThickness: number): void;
2191
2722
 
2192
- export class IIIFTextureManager {
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 {
2193
2735
  #private;
2194
- /** Set by the host so the manager can request a redraw when it has something new to show. */
2195
- _onRequestFrame: (() => void) | null;
2196
- constructor(renderer: PaperRenderer, baseUrl?: string);
2197
- _init(images: Models.ImageInfo.ImageInfo[], pageCount: number, pageIdxes: number[][]): void;
2198
- _onFrame(now: number, spreadCenter: number, cameraRadius: number): boolean;
2199
- _hasPendingWork(): boolean;
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;
2200
2741
  }
2201
2742
 
2202
- export interface PageClickResult {
2203
- direction: 'prev' | 'next';
2204
- grabRow: number;
2205
- }
2206
- export interface PageDragResult {
2207
- pageIndex: number;
2208
- grabRow: number;
2209
- worldX: number;
2210
- }
2211
2743
 
2212
- export interface RayHit {
2213
- _t: number;
2214
- _point: Vec3;
2215
- _meshIndex: number;
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;
2216
2757
  }
2217
- export function rayIntersectMeshes(meshes: readonly PaperMesh[], origin: Vec3, direction: Vec3): RayHit | null;
2218
2758
 
2219
- export interface UvWorldResult {
2220
- /** Interpolated world-space position on the deformed mesh. */
2221
- _point: Vec3;
2222
- /** Interpolated (normalized) world-space surface normal at that point. */
2223
- _normal: Vec3;
2224
- /** World-space direction of increasing image u (not normalized). */
2225
- _tangentU: Vec3;
2226
- /** World-space direction of increasing image v (not normalized). */
2227
- _tangentV: Vec3;
2228
- }
2759
+
2760
+ export {};
2761
+
2762
+
2763
+ export {};
2764
+
2765
+
2229
2766
  /**
2230
- * The sub-rectangle of a page's UV space in which a texture is displayed with
2231
- * its native aspect ratio. `uMin`/`vMin` are the lower-left corner and
2232
- * `fU`/`fV` the fraction of the page's u/v range the texture occupies. A region
2233
- * of `(0, 0, 1, 1)` stretches the texture over the whole page.
2767
+ * Defines the types of actions that can be performed on a Grid instance,
2768
+ * often triggered by marker data (`gridAction`) or tour events.
2234
2769
  */
2235
- export interface TexRegion {
2236
- uMin: number;
2237
- vMin: number;
2238
- fU: number;
2239
- fV: number;
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
2240
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[]>;
2838
+ }
2839
+
2840
+
2841
+ export {};
2842
+
2843
+
2844
+ export {};
2845
+
2846
+
2847
+ export {};
2848
+
2849
+
2850
+ export {};
2851
+
2852
+
2853
+ export {};
2854
+
2855
+
2241
2856
  /**
2242
- * Returns the world-space position, surface normal and UV tangents of a
2243
- * relative texture coordinate (u, v) on a page mesh, using the mesh's *current*
2244
- * (possibly animated/displaced) positions.
2245
- *
2246
- * `side` is the page side the image is displayed on:
2247
- * 0 = front face (sampled at uv directly),
2248
- * 1 = back face (sampled with the U axis mirrored on a single-grid PaperMesh,
2249
- * or on the separate back-face grid of a CoverMesh).
2250
- *
2251
- * `region` restricts the image to a sub-rectangle of the page (see
2252
- * {@link TexRegion}); the tangents are scaled accordingly. When omitted the
2253
- * image is stretched over the whole page.
2254
- *
2255
- * Returns null when (u, v) falls outside [0, 1].
2256
- */
2257
- export function uvToWorldPosition(mesh: PaperMesh, u: number, v: number, side: 0 | 1, region?: TexRegion | null): UvWorldResult | null;
2258
- /**
2259
- * Like `uvToWorldPosition` but returns only the interpolated world-space
2260
- * position, skipping the surface normal and tangent computation.
2857
+ * HLS.js Player adapter.
2858
+ * Extends HTML5PlayerAdapter to add HLS.js streaming support.
2859
+ * @author Marcel Duin <marcel@micr.io>
2261
2860
  */
2262
- export function sampleMeshPosition(mesh: PaperMesh, u: number, v: number, side: 0 | 1, region?: TexRegion | null): Vec3 | null;
2861
+ export {};
2862
+
2863
+
2263
2864
  /**
2264
- * Projects a world-space point through the given view-projection matrix to CSS
2265
- * pixel coordinates relative to the canvas top-left. Returns null when the point
2266
- * is behind the camera.
2865
+ * HTML5 Media Element adapter.
2866
+ * Wraps native <audio> and <video> elements with a common interface.
2867
+ * @author Marcel Duin <marcel@micr.io>
2267
2868
  */
2268
- export function projectWorldToScreen(point: Vec3, viewProj: Mat4, clientWidth: number, clientHeight: number): {
2269
- x: number;
2270
- y: number;
2271
- } | null;
2869
+ export {};
2272
2870
 
2273
- export interface DrawnImage {
2274
- /** The micrio image id. */
2275
- id: string;
2276
- /**
2277
- * A rough axis-aligned rectangle `[u, v, w, h]` in the image's texture UV
2278
- * space (0..1) covering the part currently visible in the viewport. The
2279
- * full texture visible is `[0, 0, 1, 1]`.
2280
- */
2281
- bounds: [number, number, number, number];
2282
- }
2283
- export interface BookViewerOptions {
2284
- /** The WebGL2 canvas to render into. Must be present in the document and sized by its host. */
2285
- _canvas: HTMLCanvasElement;
2286
- /** The already-loaded book index JSON. */
2287
- _images: Models.ImageInfo.ImageInfo[];
2288
- /** Called whenever the current reading position changes. */
2289
- _onPageChange?: (pageIdx: number) => void;
2290
- /** Called whenever the camera moves (rotate/zoom/pan, including smoothing). */
2291
- _onViewChange?: (images: DrawnImage[]) => void;
2292
- /** 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. */
2293
- _onDraw?: (images: DrawnImage[]) => void;
2294
- _hardCover?: boolean;
2295
- _tiltShift?: boolean;
2296
- _lightingPreset?: string;
2297
- _useIndividualAspects?: boolean;
2298
- /** When true, page margins without a texture are discarded instead of drawn as
2299
- * transparent: they no longer block the pages behind them and you can see
2300
- * through to the underlying spread. */
2301
- _seeThroughMargins?: boolean;
2302
- /** When false, the 90° rotate-view feature is disabled and its UI is hidden. Defaults to true. */
2303
- _allowRotation?: boolean;
2304
- _startPageIdx?: number;
2305
- /** Base URL for the IIIF image server (hi-res streaming). */
2306
- _iiifBaseUrl?: string;
2307
- }
2308
- export class BookViewer {
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 {
2309
2883
  #private;
2310
- static _getPresets: typeof getPresets;
2311
- readonly _ready: Promise<void>;
2312
- constructor(options: BookViewerOptions);
2313
- goto(pageIdx: number): Promise<void>;
2314
- zoom(delta: number): void;
2315
2884
  /**
2316
- * Rotates the view by a 90° increment around the vertical axis: `1` turns
2317
- * the book to the right (clockwise), `-1` to the left (counter-clockwise).
2885
+ * Creates a VideoTourInstance.
2886
+ * @param image The parent {@link MicrioImage} instance.
2887
+ * @param data The {@link Models.ImageData.VideoTour} data object.
2318
2888
  */
2319
- rotateView(direction: 1 | -1): void;
2320
- /** Whether the 90° rotate-view feature is enabled. */
2321
- _allowRotation(): boolean;
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;
2322
2894
  /**
2323
- * Returns whether the camera is zoomed in beyond the fit view. This is the
2324
- * complement of "the whole spread fits the viewport": when every currently
2325
- * visible image shows its full texture (`[0, 0, 1, 1]` bounds) the view is
2326
- * zoomed out, and any image cut off by the viewport means it is zoomed in.
2327
- * A page that is part of the current view but entirely out of the viewport
2328
- * (e.g. one page of a spread fills the screen while the other is off-screen)
2329
- * also counts as zoomed in. Based on the last rendered frame's on-screen
2330
- * bounds, so it stays accurate after zooming back out.
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).
2331
2898
  */
2332
- isZoomedIn(): boolean;
2333
- setLightingPreset(name: string): void;
2334
- _getCurrentPage(): number;
2335
- _getPageCount(): number;
2336
- _nextPage(grabRow?: number): void;
2337
- _prevPage(grabRow?: number): void;
2338
- _hookImageBook3d(img: MicrioImage): void;
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;
2339
2920
  }
2340
2921
 
2922
+
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
+
2930
+
2931
+ /**
2932
+ * YouTube IFrame Player API adapter.
2933
+ * Wraps the YouTube player with a common interface.
2934
+ * @author Marcel Duin <marcel@micr.io>
2935
+ */
2936
+ export {};
2937
+
2938
+
2939
+ /**
2940
+ * Manages camera and view animations (fly-to, zoom, jump).
2941
+ * @author Marcel Duin <marcel@micr.io>
2942
+ * @internal
2943
+ */
2944
+ export {};
2945
+
2946
+
2947
+ /**
2948
+ * Handles 2D camera logic, view calculations, and user interactions like pan, zoom, pinch.
2949
+ * @author Marcel Duin <marcel@micr.io>
2950
+ * @internal
2951
+ */
2952
+ export {};
2953
+
2954
+
2955
+ /**
2956
+ * Handles 360 camera logic, perspective, and related calculations.
2957
+ * @author Marcel Duin <marcel@micr.io>
2958
+ * @internal
2959
+ */
2960
+ export {};
2961
+
2962
+
2341
2963
  /**
2342
2964
  * Manages the HTML `<canvas>` element used for WebGL rendering,
2343
2965
  * handles resizing, and provides viewport information.
@@ -2370,357 +2992,197 @@ declare module '@micrio/client' {
2370
2992
  setMargins(width: number, height: number): void;
2371
2993
  }
2372
2994
 
2995
+
2373
2996
  /**
2374
- * Context object providing access to shared state for event handlers.
2375
- * This is passed to each handler module to avoid circular dependencies.
2997
+ * Engine-wide constants and math values.
2998
+ * @author Marcel Duin <marcel@micr.io>
2999
+ * @internal
2376
3000
  */
2377
- export interface EventContext {
2378
- }
3001
+ export {};
3002
+
2379
3003
 
2380
3004
  /**
2381
- * Handles user input events (mouse, touch, keyboard, wheel, gestures) for the Micrio viewer.
2382
- * Translates browser events into camera movements (pan, zoom), dispatches custom Micrio events,
2383
- * and manages interaction states like panning, pinching, and enabled/disabled states.
2384
- * Accessed via `micrio.events`.
3005
+ * Mathematical utility functions and easing curve implementation.
2385
3006
  * @author Marcel Duin <marcel@micr.io>
3007
+ * @internal
2386
3008
  */
2387
- export class Events implements EventContext {
2388
- #private;
2389
- /** Writable store indicating if event handling is currently enabled. Set to false during tours or animations. */
2390
- enabled: Writable<boolean>;
2391
- /** Getter for the current value of the {@link enabled} store. */
2392
- get $enabled(): boolean;
2393
- /**
2394
- * The Events constructor.
2395
- * @param micrio The main HTMLMicrioElement instance.
2396
- */
2397
- constructor(micrio: HTMLMicrioElement);
2398
- /**
2399
- * Checks if the user is currently interacting with the map via panning, pinching, or wheeling.
2400
- * @returns True if the user is actively navigating.
2401
- */
2402
- get isNavigating(): boolean;
2403
- /** Hooks all necessary event listeners based on current settings. */
2404
- hook(): void;
2405
- /** Unhooks all attached event listeners. */
2406
- unhook(): void;
2407
- /** Hooks keyboard event listeners. */
2408
- hookKeys(): void;
2409
- /** Unhooks keyboard event listeners. */
2410
- unhookKeys(): void;
2411
- /** Hooks zoom-related event listeners (pinch, scroll, double-tap/click). */
2412
- hookZoom(): void;
2413
- /** Unhooks zoom-related event listeners. */
2414
- unhookZoom(): void;
2415
- /** Flag indicating if scroll listeners are attached. */
2416
- get scrollHooked(): boolean;
2417
- /** Hooks mouse wheel/scroll event listeners. */
2418
- hookScroll(): void;
2419
- /** Unhooks mouse wheel/scroll event listeners. */
2420
- unhookScroll(): void;
2421
- /** Hooks touch pinch and macOS gesture event listeners. */
2422
- hookPinch(): void;
2423
- /** Unhooks touch pinch and macOS gesture event listeners. */
2424
- unhookPinch(): void;
2425
- /** Hooks pointer down/move/up listeners for drag panning. */
2426
- hookDrag(): void;
2427
- /** Unhooks pointer listeners for drag panning. */
2428
- unhookDrag(): void;
2429
- /** Hooks the native context menu copy crop handler (`data-contextmenu-crop`). */
2430
- hookContextMenuCopy(): void;
2431
- /** Unhooks the native context menu copy crop handler. */
2432
- unhookContextMenuCopy(): void;
2433
- }
3009
+ export {};
3010
+
2434
3011
 
2435
3012
  /**
2436
- * # Micrio State management
2437
- *
2438
- * Manages the application state using stores, allowing reactive updates
2439
- * throughout the UI.
2440
- * Replaces the imperative API of Micrio 3.x.
2441
- *
2442
- * Consists of two main state controllers:
2443
- * 1. {@link State.Main}: Global state for the `<micr-io>` element (active tour, marker, UI state).
2444
- * 2. {@link State.Image}: State specific to individual {@link MicrioImage} instances (view, active marker within that image).
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.
2445
3040
  *
2446
- * @see {@link https://doc.micr.io/client/v4/migrating.html | Migrating from Micrio 3.x}
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.
2447
3052
  * @author Marcel Duin <marcel@micr.io>
3053
+ * @internal
2448
3054
  */
2449
- export namespace State {
2450
- /**
2451
- * # HTMLMicrioElement state controller (`micrio.state`)
2452
- *
2453
- * Manages the global application state associated with the main `<micr-io>` element.
2454
- * Provides stores for reactive UI updates.
2455
- */
2456
- class Main {
2457
- #private;
2458
- /** Writable store holding the currently active tour object (VideoTour or MarkerTour), or undefined if no tour is active. */
2459
- readonly tour: Writable<Models.ImageData.VideoTour | Models.ImageData.MarkerTour | undefined>;
2460
- /** Getter for the current value of the {@link tour} store. */
2461
- get $tour(): Models.ImageData.VideoTour | Models.ImageData.MarkerTour | undefined;
2462
- /** Writable store holding the marker object currently opened in the *main* active image, or undefined if none is open. */
2463
- readonly marker: Writable<Models.ImageData.Marker | undefined>;
2464
- /** Writable store holding the ID of the marker currently being hovered over. */
2465
- readonly markerHoverId: Writable<string | undefined>;
2466
- /** Getter for the current value of the {@link marker} store. */
2467
- get $marker(): Models.ImageData.Marker | undefined;
2468
- /** Writable store holding the marker object whose popup is currently displayed. */
2469
- readonly popup: Writable<Models.ImageData.Marker | undefined>;
2470
- /** Writable store holding the data for the currently displayed popover (custom page or gallery). See {@link Models.State.PopoverType}. */
2471
- readonly popover: Writable<Models.State.PopoverType | undefined>;
2472
- }
2473
- /**
2474
- * # MicrioImage state controller (`micrioImage.state`)
2475
- *
2476
- * Manages the state specific to a single {@link MicrioImage} instance,
2477
- * primarily its viewport and currently opened marker.
2478
- */
2479
- class Image {
2480
- #private;
2481
- /** Writable store holding the current viewport [x0, y0, width, height] of this image. */
2482
- readonly view: Writable<Models.Camera.View | undefined>;
2483
- /** Getter for the current value of the {@link view} store. */
2484
- get $view(): Models.Camera.View | undefined;
2485
- /**
2486
- * Writable store holding the currently active marker within *this specific image*.
2487
- * Can be set with a marker ID string or a full marker object. Setting to undefined closes the marker.
2488
- */
2489
- readonly marker: Writable<Models.ImageData.Marker | string | undefined>;
2490
- /** Getter for the current value of the {@link marker} store. */
2491
- get $marker(): Models.ImageData.Marker | undefined;
2492
- /** Writable store holding the currently displayed layer index (for Omni objects). */
2493
- readonly layer: Writable<number>;
2494
- /** Creates an Image state controller and subscribes to view/marker changes to synchronise with the main element state. @param image The parent MicrioImage instance. */
2495
- constructor(image: MicrioImage);
2496
- }
2497
- }
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
+
3088
+
3089
+ /**
3090
+ * Media player type definitions and interfaces.
3091
+ * @author Marcel Duin <marcel@micr.io>
3092
+ */
3093
+ export {};
3094
+
2498
3095
 
2499
3096
  /**
2500
- * The main Micrio custom HTML element `<micr-io>`.
2501
- * This class acts as the central controller for the Micrio viewer, managing
2502
- * the WebGL canvas, compute engine, UI, state, events, and image loading.
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.
2503
3118
  *
2504
- * It orchestrates the interaction between different parts of the library and
2505
- * exposes methods and properties for controlling the viewer.
3119
+ * If the bundle fails the image is simply unavailable — there are no
3120
+ * individual `info.json` / `data.json` fallbacks.
2506
3121
  *
2507
- * @example
2508
- * ```html
2509
- * <micr-io id="image123"></micr-io>
2510
- * <script>
2511
- * const viewer = document.querySelector('micr-io');
2512
- * viewer.open('image456');
2513
- * viewer.addEventListener('marker-click', (e) => console.log(e.detail));
2514
- * </script>
2515
- * ```
3122
+ * This is the single source of truth for image info & data fetches.
2516
3123
  *
2517
3124
  * @author Marcel Duin <marcel@micr.io>
2518
3125
  */
2519
- export class HTMLMicrioElement extends MicrioElement {
2520
- #private;
2521
- /** Observed attributes trigger `attributeChangedCallback` when changed. */
2522
- static get observedAttributes(): string[];
2523
- /** The Micrio library version number. */
2524
- static VERSION: string;
2525
- /**
2526
- * Writable store holding the currently active main {@link MicrioImage}.
2527
- * Use `<micr-io>.open()` to change the active image.
2528
- * Subscribe to this store to react to image changes.
2529
- * Access the current value directly using the {@link $current} getter.
2530
- */
2531
- readonly current: Writable<MicrioImage | undefined>;
2532
- /**
2533
- * Getter for the current value of the {@link current} store.
2534
- * Provides direct access to the active {@link MicrioImage} instance.
2535
- * @readonly
2536
- */
2537
- get $current(): MicrioImage | undefined;
2538
- /** Getter for the virtual {@link Camera} instance of the currently active image. */
2539
- get camera(): Camera | undefined;
2540
- /** The controller managing the HTML `<canvas>` element, resizing, and viewport. */
2541
- readonly canvas: Canvas;
2542
- /** The controller managing user input events (mouse, touch, keyboard) and dispatching custom events. */
2543
- readonly events: Events;
2544
- /** The main state manager, providing access to various application states (UI visibility, active marker, tour, etc.). See {@link State.Main}. */
2545
- readonly state: State.Main;
2546
- /** Writable store indicating if barebone texture downloading is enabled (lower quality, less bandwidth). */
2547
- readonly barebone: Writable<boolean>;
2548
- /** Custom settings object provided programmatically, overriding server-fetched settings. */
2549
- defaultSettings?: Partial<Models.ImageInfo.Settings>;
2550
- /** Holds data for the current 360 space, if applicable (loaded via `data-space` attribute or API). */
2551
- spaceData: Models.Spaces.Space | undefined;
2552
- /** Holds bundle-level marker tours, available regardless of which image is shown. */
2553
- bundleTours: Models.ImageData.MarkerTour[] | undefined;
2554
- /** The current active gallery controller, if any. */
2555
- gallery: Gallery | undefined;
2556
- /** Destroys the Micrio instance, cleans up resources, and removes event listeners. */
2557
- destroy(): void;
2558
- /**
2559
- * Opens a Micrio image by its Micrio ID (triggers a `bundle.json` download) or
2560
- * by providing a pre-resolved {@link Models.ImageBundle.BundleImage}.
2561
- *
2562
- * @param idOrInfo A Micrio image ID string or a full {@link Models.ImageBundle.BundleImage} object.
2563
- * @param opts Options for opening the image.
2564
- * @returns The {@link MicrioImage} instance being opened.
2565
- */
2566
- open(idOrInfo: string | Models.ImageBundle.BundleImage, opts?: {
2567
- /** If true, keeps the grid view active instead of focusing on the opened image. */
2568
- gridView?: boolean;
2569
- /** An optional starting view to apply immediately. */
2570
- startView?: Models.Camera.View;
2571
- /** For 360 transitions, provides the direction vector from the previous image. */
2572
- vector?: Models.Camera.Vector;
2573
- /** Optional Gallery controller, used for gallery/grid views. */
2574
- gallery?: Gallery;
2575
- }): Promise<MicrioImage | undefined>;
2576
- /**
2577
- * Closes an opened MicrioImage and removes its canvas from the engine.
2578
- * @param img The {@link MicrioImage} instance to close.
2579
- */
2580
- close(img: MicrioImage): void;
2581
- /** Getter for the current language code. */
2582
- get lang(): string;
2583
- /** Setter for the current language code. Triggers language change logic. */
2584
- set lang(l: string);
2585
- }
3126
+ export {};
3127
+
2586
3128
 
2587
3129
  /**
2588
- * Defines the types of actions that can be performed on a Grid instance,
2589
- * often triggered by marker data (`gridAction`) or tour events.
3130
+ * DOM and general utility functions.
3131
+ * @author Marcel Duin <marcel@micr.io>
2590
3132
  */
2591
- export enum GridActionType {
2592
- /** Focus on specific images within the grid, hiding others. Data: comma-separated image IDs. */
2593
- focus = 0,
2594
- /** Animate the main grid view to fit the bounding box of specified images. Data: comma-separated image IDs. */
2595
- flyTo = 1,
2596
- /** Focus on images containing markers with a specific tag. Data: tag name. */
2597
- focusWithTagged = 2,
2598
- /** Focus on images containing markers with a specific tag and fly to the marker views. Data: tag name. */
2599
- focusTagged = 3,
2600
- /** Reset the grid to its initial layout and view. */
2601
- reset = 4,
2602
- /** Navigate back one step in the grid layout history. */
2603
- back = 5,
2604
- /** Instantly switch a focused image back to its position within the grid layout. */
2605
- switchToGrid = 6,
2606
- /** Filter the grid to show only images that are part of the currently active marker tour. */
2607
- filterTourImages = 7,
2608
- /** Set a one-time crossfade duration for the *next* grid transition. Data: duration in seconds. */
2609
- nextFadeDuration = 8
2610
- }
3133
+ export {};
2611
3134
 
2612
- /** The main Grid controller that arranges {@link MicrioImage} instances into a CSS grid layout. */
2613
- export class Grid extends MicrioElement<GridProps> {
2614
- #private;
2615
- /** All {@link MicrioImage} instances managed by this grid. */
2616
- get images(): readonly MicrioImage[];
2617
- /** Get a grid {@link MicrioImage} instance by its image ID, if it is part of this grid. */
2618
- getImage(id: string): MicrioImage | undefined;
2619
- /** The currently focussed (single-view) image, if any. */
2620
- get $focussed(): MicrioImage | undefined;
2621
- /** The parent `<micrio-*>` element this grid is bound to. */
2622
- micrio: HTMLMicrioElement;
2623
- /** The main {@link MicrioImage} that serves as the grid viewport. */
2624
- image: MicrioImage;
2625
- /** Set the grid to display the given images, arranging them into a CSS grid. */
2626
- set(images?: Models.Grid.GridImage[], opts?: {
2627
- noHistory?: boolean;
2628
- keepGrid?: boolean;
2629
- horizontal?: boolean;
2630
- duration?: number;
2631
- view?: Models.Camera.View;
2632
- noCamAni?: boolean;
2633
- forceAreaAni?: boolean;
2634
- noBlur?: boolean;
2635
- noFade?: boolean;
2636
- transition?: Models.Grid.GridSetTransition;
2637
- forceAni?: boolean;
2638
- coverLimit?: boolean;
2639
- cover?: boolean;
2640
- scale?: number;
2641
- columns?: number;
2642
- }): Promise<MicrioImage[]>;
2643
- /** Reset the grid to its initial layout (all gallery images), clearing all history. */
2644
- reset(duration?: number, noCamAni?: boolean, forceAni?: boolean): Promise<MicrioImage[]>;
2645
- /** Navigate to the previous layout state from the history stack. */
2646
- back(duration?: number): Promise<void>;
2647
- /** Focus the grid on a single image, optionally with a transition animation. */
2648
- gridFocus(img: MicrioImage | undefined, opts?: Models.Grid.FocusOptions): Promise<void>;
2649
- /** Remove focus from the currently focussed image and return to the grid overview. */
2650
- blur(): void;
2651
- /** Execute a grid action by type (e.g. `focus`, `reset`, `back`) with optional data and duration. */
2652
- action(action: GridActionType | string, data?: string, duration?: number): void;
2653
- /** Enlarge a specific grid cell to span the given number of columns/rows, re-laying out without history. */
2654
- enlarge(idx: number, width: number, height?: number): Promise<MicrioImage[]>;
2655
- }
2656
3135
 
2657
3136
  /**
2658
- * Represents and controls a single Micrio image instance within the viewer.
2659
- * This class manages the image's metadata (info), cultural data (data),
2660
- * settings, camera, state, and interactions with the compute engine
2661
- * for rendering and processing. It handles loading image tiles, embeds,
2662
- * markers, tours, and galleries associated with the image.
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.
2663
3166
  *
2664
- * Instances are typically created and managed by the main {@link HTMLMicrioElement}.
2665
3167
  * @author Marcel Duin <marcel@micr.io>
2666
3168
  */
2667
- export class MicrioImage {
2668
- #private;
2669
- /** The unique identifier (Micrio ID) for this image. */
2670
- id: string;
2671
- /** A unique instance identifier (UUID) generated for this specific instance. */
2672
- readonly uuid: string;
2673
- /** Getter for the current value of the {@link info} property.
2674
- * @readonly
2675
- */
2676
- get $info(): Models.ImageInfo.ImageInfo;
2677
- /** Getter for the current value of the {@link settings} store. */
2678
- get $settings(): Models.ImageInfo.Settings;
2679
- /** Writable store holding the image's cultural data (markers, tours, text content for the current language). See {@link Models.ImageData.ImageData}. */
2680
- readonly data: Writable<Models.ImageData.ImageData | undefined>;
2681
- /** Getter for the current value of the {@link data} store. */
2682
- get $data(): Models.ImageData.ImageData | undefined;
2683
- /** State manager specific to this image instance (view, active marker, etc.). See {@link State.Image}. */
2684
- readonly state: State.Image;
2685
- /** The virtual camera instance controlling the view for this image. */
2686
- camera: Camera;
2687
- /** Writable store holding the HTMLVideoElement if this image represents a video. */
2688
- readonly video: Writable<HTMLVideoElement | undefined>;
2689
- /** Writable store indicating if this image's canvas is currently visible and being rendered.
2690
- * @readonly
2691
- */
2692
- readonly visible: Writable<boolean>;
2693
- /** Album information if this image is part of a V5 album. */
2694
- album?: Models.Album | undefined;
2695
- /** OmniUI instance, if this image is an omni 3D object. */
2696
- omni: OmniUI | undefined;
2697
- /** Grid controller instance, if this image is a grid container. */
2698
- grid: Grid | undefined;
2699
- /** Stores an error message if loading failed. */
2700
- error: string | undefined;
2701
- /** Options controlling this image instance's behaviour (embedding, area, parent camera usage). */
2702
- opts: {
2703
- /** Optional sub area [x, y, width, height] defining placement within a parent canvas (for embeds/galleries). */
2704
- area?: Models.Camera.View;
2705
- /** If true, this image is embedded within another image (affects rendering/camera). */
2706
- isEmbed?: boolean;
2707
- /** If true, uses the parent image's camera instead of creating its own (for switch/omni galleries). */
2708
- useParentCamera?: boolean;
2709
- };
2710
- /**
2711
- * Adds an embedded MicrioImage (representing another Micrio image or video) within this image.
2712
- * @param info Partial info data for the embed.
2713
- * @param settings Optional settings for the embed.
2714
- * @param area The placement area `[x, y, width, height]` within the parent image.
2715
- * @param opts Embedding options (opacity, fit, etc.).
2716
- * @returns The newly created embedded {@link MicrioImage} instance.
2717
- */
2718
- addEmbed(info: Partial<Models.ImageInfo.ImageInfo>, settings: Partial<Models.ImageInfo.Settings> | undefined, area: Models.Camera.View, opts?: Models.Embeds.EmbedOptions): MicrioImage;
2719
- /**
2720
- * Gets the HTMLMediaElement associated with a video embed ID.
2721
- * @param id The embed identifier.
2722
- * @returns The media element, or undefined if not found.
2723
- */
2724
- getEmbedMediaElement(id: string): HTMLMediaElement | undefined;
2725
- }
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
+
2726
3188
  }