@micrio/client 6.0.0 → 6.0.1
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 +13 -973
- package/micrio.min.js +2 -2
- package/package.json +1 -1
package/micrio.min.d.ts
CHANGED
|
@@ -12,948 +12,12 @@ declare module '@micrio/client' {
|
|
|
12
12
|
* @returns A Promise resolving to the loaded TextureBitmap.
|
|
13
13
|
*/
|
|
14
14
|
export const loadTexture: (src: string) => Promise<TextureBitmap>;
|
|
15
|
-
/**
|
|
16
|
-
* Engine-wide constants and math values.
|
|
17
|
-
* @author Marcel Duin <marcel@micr.io>
|
|
18
|
-
*/
|
|
19
|
-
export const PI: number;
|
|
20
|
-
export const PIh: number;
|
|
21
|
-
export const PI2: number;
|
|
22
|
-
/** Number of horizontal segments for 360 sphere geometry. */
|
|
23
|
-
export const segsX = 16;
|
|
24
|
-
/** Number of vertical segments for 360 sphere geometry. */
|
|
25
|
-
export const segsY = 16;
|
|
26
|
-
/** Base distance for 360 space transitions. */
|
|
27
|
-
export const base360Distance = 8;
|
|
28
|
-
/** Calculates 2 to the power of num (2^num). */
|
|
29
|
-
export function twoNth(num: number): number;
|
|
30
|
-
/** Calculates the positive modulo (floored division remainder). */
|
|
31
|
-
export function mod(n: number, m?: number): number;
|
|
32
|
-
/** Calculates the modulo 1 of a number (keeps the fractional part, positive). @deprecated Use mod(n, 1) */
|
|
33
|
-
export const mod1: (n: number) => number;
|
|
34
|
-
/** Calculates the modulo 2*PI of a number (wraps angles to the range [0, 2*PI)). */
|
|
35
|
-
export function modPI(n: number): number;
|
|
36
|
-
/**
|
|
37
|
-
* Calculates the shortest angular distance between two longitude coordinates.
|
|
38
|
-
* Handles wrapping around the 360-degree sphere.
|
|
39
|
-
* @param from Starting longitude coordinate (0-1).
|
|
40
|
-
* @param to Target longitude coordinate (0-1).
|
|
41
|
-
* @returns The shortest signed distance (-0.5 to 0.5).
|
|
42
|
-
*/
|
|
43
|
-
export function longitudeDistance(from: number, to: number): number;
|
|
44
|
-
/**
|
|
45
|
-
* Implements a cubic bezier curve calculation.
|
|
46
|
-
* Used for animation easing functions.
|
|
47
|
-
*/
|
|
48
|
-
export class Bicubic {
|
|
49
|
-
private readonly Cx;
|
|
50
|
-
private readonly Bx;
|
|
51
|
-
private readonly Ax;
|
|
52
|
-
private readonly Cy;
|
|
53
|
-
private readonly By;
|
|
54
|
-
private readonly Ay;
|
|
55
|
-
private readonly isLinear;
|
|
56
|
-
constructor(p1: number, p2: number, p3: number, p4: number);
|
|
57
|
-
/** Calculates the X coordinate on the bezier curve for a given parameter t. */
|
|
58
|
-
private bezier_x;
|
|
59
|
-
/** Calculates the Y coordinate on the bezier curve for a given parameter t. */
|
|
60
|
-
private bezier_y;
|
|
61
|
-
/** Calculates the derivative of the bezier curve's X component with respect to t. */
|
|
62
|
-
private bezier_x_der;
|
|
63
|
-
/**
|
|
64
|
-
* Approximates the parameter t that corresponds to a given X coordinate on the curve,
|
|
65
|
-
* using Newton's method.
|
|
66
|
-
* @param x The target X coordinate.
|
|
67
|
-
* @returns The approximated parameter t for the given x.
|
|
68
|
-
*/
|
|
69
|
-
private find_x_for;
|
|
70
|
-
/**
|
|
71
|
-
* Gets the eased Y value for a given progress value t (0-1).
|
|
72
|
-
* @param t The progress value (time).
|
|
73
|
-
* @returns The eased Y value.
|
|
74
|
-
*/
|
|
75
|
-
get(t: number): number;
|
|
76
|
-
}
|
|
77
|
-
/** Predefined cubic bezier easing: ease-in-out (standard). */
|
|
78
|
-
export const easeInOut: Bicubic;
|
|
79
|
-
/** Predefined cubic bezier easing: ease-in. */
|
|
80
|
-
export const easeIn: Bicubic;
|
|
81
|
-
/** Predefined cubic bezier easing: ease-out. */
|
|
82
|
-
export const easeOut: Bicubic;
|
|
83
|
-
/** Predefined cubic bezier easing: linear. */
|
|
84
|
-
export const linear: Bicubic;
|
|
85
|
-
/**
|
|
86
|
-
* High-performance matrix and vector operations for WebGL.
|
|
87
|
-
* Ported from gl-matrix 3.2.1 (Copyright (c) 2015-2020, Brandon Jones, Colin MacKenzie IV).
|
|
88
|
-
* Originally ported to AssemblyScript/WASM by marcel@micr.io, 2020.
|
|
89
|
-
* Re-ported to TypeScript for the Micrio engine.
|
|
90
|
-
*
|
|
91
|
-
* @license MIT
|
|
92
|
-
*/
|
|
93
|
-
/** Represents a 4x4 matrix, tailored for WebGL operations. */
|
|
94
|
-
export class Mat4 {
|
|
95
|
-
a0: number;
|
|
96
|
-
a1: number;
|
|
97
|
-
a2: number;
|
|
98
|
-
a3: number;
|
|
99
|
-
a4: number;
|
|
100
|
-
a5: number;
|
|
101
|
-
a6: number;
|
|
102
|
-
a7: number;
|
|
103
|
-
a8: number;
|
|
104
|
-
a9: number;
|
|
105
|
-
a10: number;
|
|
106
|
-
a11: number;
|
|
107
|
-
a12: number;
|
|
108
|
-
a13: number;
|
|
109
|
-
a14: number;
|
|
110
|
-
a15: number;
|
|
111
|
-
/** Float32Array view for direct use with WebGL uniformMatrix4fv. */
|
|
112
|
-
readonly arr: Float32Array;
|
|
113
|
-
/**
|
|
114
|
-
* Creates a new identity Mat4.
|
|
115
|
-
* Matrix layout (column-major):
|
|
116
|
-
* a0 a4 a8 a12
|
|
117
|
-
* a1 a5 a9 a13
|
|
118
|
-
* a2 a6 a10 a14
|
|
119
|
-
* a3 a7 a11 a15
|
|
120
|
-
*/
|
|
121
|
-
constructor(a0?: number, a1?: number, a2?: number, a3?: number, a4?: number, a5?: number, a6?: number, a7?: number, a8?: number, a9?: number, a10?: number, a11?: number, a12?: number, a13?: number, a14?: number, a15?: number);
|
|
122
|
-
/** Updates the internal Float32Array with the current matrix values. */
|
|
123
|
-
toArray(): Float32Array;
|
|
124
|
-
/** Resets the matrix to the identity matrix. */
|
|
125
|
-
identity(): void;
|
|
126
|
-
/** Copies the values from another Mat4 into this one. */
|
|
127
|
-
copy(s: Mat4): void;
|
|
128
|
-
/** Multiplies this matrix by a rotation matrix created from the given angle around the X axis. */
|
|
129
|
-
rotateX(rad: number): void;
|
|
130
|
-
/** Multiplies this matrix by a rotation matrix created from the given angle around the Y axis. */
|
|
131
|
-
rotateY(rad: number): void;
|
|
132
|
-
/** Multiplies this matrix by a rotation matrix created from the given angle around the Z axis. */
|
|
133
|
-
rotateZ(rad: number): void;
|
|
134
|
-
/** Uniform scale applied only to X and Y columns (Z unchanged). */
|
|
135
|
-
scaleFlat(scale: number): void;
|
|
136
|
-
/** Translates the matrix by the given vector [x, y, z]. */
|
|
137
|
-
translate(x: number, y: number, z: number): void;
|
|
138
|
-
/** Generates a perspective projection matrix with the given bounds. */
|
|
139
|
-
perspective(fovy: number, aspect: number, near: number, far: number): void;
|
|
140
|
-
/** Generates a simplified perspective matrix suitable for CSS 3D transforms (no near/far clipping). */
|
|
141
|
-
perspectiveCss(fovy: number): void;
|
|
142
|
-
/** Inverts the matrix. */
|
|
143
|
-
invert(): void;
|
|
144
|
-
/** Multiplies this matrix by another matrix `a` (this = this * a). */
|
|
145
|
-
multiply(a: Mat4): void;
|
|
146
|
-
/** Scales the matrix by the given vector [x, y, z]. */
|
|
147
|
-
scaleXY(x: number, y: number, z?: number): void;
|
|
148
|
-
}
|
|
149
|
-
/** Represents a 4D vector (x, y, z, w). */
|
|
150
|
-
export class Vec4 {
|
|
151
|
-
x: number;
|
|
152
|
-
y: number;
|
|
153
|
-
z: number;
|
|
154
|
-
w: number;
|
|
155
|
-
constructor(x?: number, y?: number, z?: number, w?: number);
|
|
156
|
-
/** Copies the values from another Vec4 into this one. */
|
|
157
|
-
copy(v: Vec4): void;
|
|
158
|
-
/** Transforms the vector by the given Mat4. */
|
|
159
|
-
transformMat4(m: Mat4): void;
|
|
160
|
-
/** Normalizes the vector (scales it to have a length of 1). */
|
|
161
|
-
normalize(): void;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Represents a single image source (tiled or single) within a TileCanvas.
|
|
165
|
-
* Handles tile pyramid, layer management, and tile culling.
|
|
166
|
-
* @author Marcel Duin <marcel@micr.io>
|
|
167
|
-
*/
|
|
168
|
-
/** Represents a single resolution layer within an Image. */
|
|
169
|
-
class Layer {
|
|
170
|
-
readonly image: Image;
|
|
171
|
-
readonly index: number;
|
|
172
|
-
readonly start: number;
|
|
173
|
-
readonly end: number;
|
|
174
|
-
readonly tileSize: number;
|
|
175
|
-
readonly cols: number;
|
|
176
|
-
readonly rows: number;
|
|
177
|
-
readonly tileWidth: number;
|
|
178
|
-
readonly tileHeight: number;
|
|
179
|
-
constructor(image: Image, index: number, start: number, end: number, tileSize: number, cols: number, rows: number);
|
|
180
|
-
getTileRect(idx: number, r: DrawRect): DrawRect;
|
|
181
|
-
}
|
|
182
|
-
/** Represents a single image source (tiled or single) within a TileCanvas. */
|
|
183
|
-
export default class Image {
|
|
184
|
-
private readonly canvas;
|
|
185
|
-
readonly index: number;
|
|
186
|
-
readonly localIdx: number;
|
|
187
|
-
readonly width: number;
|
|
188
|
-
readonly height: number;
|
|
189
|
-
readonly tileSize: number;
|
|
190
|
-
readonly isSingle: boolean;
|
|
191
|
-
readonly isVideo: boolean;
|
|
192
|
-
readonly startOffset: number;
|
|
193
|
-
opacity: number;
|
|
194
|
-
tOpacity: number;
|
|
195
|
-
rotX: number;
|
|
196
|
-
rotY: number;
|
|
197
|
-
rotZ: number;
|
|
198
|
-
readonly scale: number;
|
|
199
|
-
readonly fromScale: number;
|
|
200
|
-
private static readonly toDraw;
|
|
201
|
-
private static toDrawSeen;
|
|
202
|
-
private static toDrawSeenBase;
|
|
203
|
-
readonly vec: Vec4;
|
|
204
|
-
readonly mat: Mat4;
|
|
205
|
-
rScale: number;
|
|
206
|
-
readonly layers: Layer[];
|
|
207
|
-
numLayers: number;
|
|
208
|
-
targetLayer: number;
|
|
209
|
-
x0: number;
|
|
210
|
-
y0: number;
|
|
211
|
-
x1: number;
|
|
212
|
-
y1: number;
|
|
213
|
-
rWidth: number;
|
|
214
|
-
rHeight: number;
|
|
215
|
-
areaCenterX: number;
|
|
216
|
-
areaCenterY: number;
|
|
217
|
-
areaWidth: number;
|
|
218
|
-
areaHeight: number;
|
|
219
|
-
sphere3DX: number;
|
|
220
|
-
sphere3DY: number;
|
|
221
|
-
sphere3DZ: number;
|
|
222
|
-
angularWidth: number;
|
|
223
|
-
angularHeight: number;
|
|
224
|
-
gotBase: number;
|
|
225
|
-
readonly endOffset: number;
|
|
226
|
-
aspect: number;
|
|
227
|
-
doneTotal: number;
|
|
228
|
-
doRender: boolean;
|
|
229
|
-
private is360Embed;
|
|
230
|
-
isVideoPlaying: boolean;
|
|
231
|
-
private static sampledXs;
|
|
232
|
-
private static sampledYs;
|
|
233
|
-
private static uniqueXs;
|
|
234
|
-
private static sampledLength;
|
|
235
|
-
private static uniqueLength;
|
|
236
|
-
constructor(canvas: TileCanvas, index: number, localIdx: number, width: number, height: number, tileSize: number, isSingle: boolean, isVideo: boolean, startOffset: number, opacity: number, tOpacity: number, rotX: number, rotY: number, rotZ: number, scale: number, fromScale: number);
|
|
237
|
-
/** Sets the relative area this image occupies within its parent canvas. */
|
|
238
|
-
setArea(x0: number, y0: number, x1: number, y1: number): void;
|
|
239
|
-
/** Converts 2D sphere coordinates to 3D unit sphere position */
|
|
240
|
-
private calculate3DSpherePosition;
|
|
241
|
-
/**
|
|
242
|
-
* Checks if embed's 3D sphere position is within camera's viewing frustum
|
|
243
|
-
*/
|
|
244
|
-
private sphere3DOverlap;
|
|
245
|
-
/** Checks if the image's bounding box is completely outside the current view. */
|
|
246
|
-
private outsideView;
|
|
247
|
-
/** Determines if this image should be rendered in the current frame. */
|
|
248
|
-
shouldRender(): boolean;
|
|
249
|
-
/**
|
|
250
|
-
* Steps the opacity animation for this image.
|
|
251
|
-
* @returns True if the opacity changed (animation is active or snapped).
|
|
252
|
-
*/
|
|
253
|
-
opacityTick(direct: boolean): boolean;
|
|
254
|
-
/**
|
|
255
|
-
* Calculates the set of tiles needed to render the current view for this image.
|
|
256
|
-
* @returns The number of tiles from this image that are already loaded/drawn.
|
|
257
|
-
*/
|
|
258
|
-
getTiles(scale: number): number;
|
|
259
|
-
/** Calculates the target layer index based on the current scale. */
|
|
260
|
-
private getTargetLayer;
|
|
261
|
-
/** Calculates and adds tiles within a given rectangular area for a specific layer. */
|
|
262
|
-
private getTilesRect;
|
|
263
|
-
/**
|
|
264
|
-
* Calculates tiles for 360 embeds using viewport-based coordinates.
|
|
265
|
-
*/
|
|
266
|
-
private getTilesViewport;
|
|
267
|
-
private setToDraw;
|
|
268
|
-
/** Calculates the vertex positions for an embedded image within a 360 canvas. */
|
|
269
|
-
setDrawRect(r: DrawRect): void;
|
|
270
|
-
/** Calculates the effective scale of an embedded image based on its projection. */
|
|
271
|
-
private getEmbeddedScale;
|
|
272
|
-
private get360Tiles;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Shared data structures for the Micrio engine: View, Coordinates, Viewport, DrawRect.
|
|
276
|
-
* @author Marcel Duin <marcel@micr.io>
|
|
277
|
-
*/
|
|
278
|
-
/** Structure to hold information about a specific tile to be drawn. */
|
|
279
|
-
export class DrawRect {
|
|
280
|
-
/** Left edge of the tile in relative image coordinates (0-1). */
|
|
281
|
-
x0: number;
|
|
282
|
-
/** Top edge of the tile in relative image coordinates (0-1). */
|
|
283
|
-
y0: number;
|
|
284
|
-
/** Right edge of the tile in relative image coordinates (0-1). */
|
|
285
|
-
x1: number;
|
|
286
|
-
/** Bottom edge of the tile in relative image coordinates (0-1). */
|
|
287
|
-
y1: number;
|
|
288
|
-
/** Index of the resolution layer this tile belongs to. */
|
|
289
|
-
layer: number;
|
|
290
|
-
/** Column index of the tile within its layer. */
|
|
291
|
-
x: number;
|
|
292
|
-
/** Row index of the tile within its layer. */
|
|
293
|
-
y: number;
|
|
294
|
-
/** Reference to the Image instance this tile belongs to. */
|
|
295
|
-
image: Image;
|
|
296
|
-
constructor(
|
|
297
|
-
/** Left edge of the tile in relative image coordinates (0-1). */
|
|
298
|
-
x0?: number,
|
|
299
|
-
/** Top edge of the tile in relative image coordinates (0-1). */
|
|
300
|
-
y0?: number,
|
|
301
|
-
/** Right edge of the tile in relative image coordinates (0-1). */
|
|
302
|
-
x1?: number,
|
|
303
|
-
/** Bottom edge of the tile in relative image coordinates (0-1). */
|
|
304
|
-
y1?: number,
|
|
305
|
-
/** Index of the resolution layer this tile belongs to. */
|
|
306
|
-
layer?: number,
|
|
307
|
-
/** Column index of the tile within its layer. */
|
|
308
|
-
x?: number,
|
|
309
|
-
/** Row index of the tile within its layer. */
|
|
310
|
-
y?: number);
|
|
311
|
-
}
|
|
312
|
-
/** Represents the logical view rectangle within an image. */
|
|
313
|
-
export class View {
|
|
314
|
-
private readonly canvas;
|
|
315
|
-
centerX: number;
|
|
316
|
-
centerY: number;
|
|
317
|
-
width: number;
|
|
318
|
-
height: number;
|
|
319
|
-
lCenterX: number;
|
|
320
|
-
lCenterY: number;
|
|
321
|
-
lWidth: number;
|
|
322
|
-
lHeight: number;
|
|
323
|
-
/** Float64Array view of [centerX, centerY, width, height] — for efficient JS access. */
|
|
324
|
-
readonly arr: Float64Array;
|
|
325
|
-
/** Flag indicating if the view coordinates have changed since the last frame. */
|
|
326
|
-
changed: boolean;
|
|
327
|
-
/** Flag indicating if the view limits have changed. */
|
|
328
|
-
limitChanged: boolean;
|
|
329
|
-
constructor(canvas: TileCanvas, centerX?: number, centerY?: number, width?: number, height?: number, lCenterX?: number, lCenterY?: number, lWidth?: number, lHeight?: number);
|
|
330
|
-
get x0(): number;
|
|
331
|
-
get y0(): number;
|
|
332
|
-
get x1(): number;
|
|
333
|
-
get y1(): number;
|
|
334
|
-
get lX0(): number;
|
|
335
|
-
get lY0(): number;
|
|
336
|
-
get lX1(): number;
|
|
337
|
-
get lY1(): number;
|
|
338
|
-
get yaw(): number;
|
|
339
|
-
get pitch(): number;
|
|
340
|
-
get aspect(): number;
|
|
341
|
-
get size(): number;
|
|
342
|
-
set(centerX: number, centerY: number, width: number, height: number, preserveAspect?: boolean): void;
|
|
343
|
-
/** Sets the relative View area of a MicrioImage to render to, animates by default. Used in grids. */
|
|
344
|
-
setArea(x0: number, y0: number, x1: number, y1: number): void;
|
|
345
|
-
setLimit(lCenterX: number, lCenterY: number, lWidth: number, lHeight: number): void;
|
|
346
|
-
copy(v: View, excludeLimit?: boolean): void;
|
|
347
|
-
/** Calculates the perspective value needed to achieve this view height in 360 mode. */
|
|
348
|
-
getPerspective(): number;
|
|
349
|
-
/** Calculates the effective scale factor represented by this view. */
|
|
350
|
-
getScale(): number;
|
|
351
|
-
/** Calculates a distance metric between this view and another view, used for animation duration. */
|
|
352
|
-
getDistance(v: View, correctAspect: boolean): number;
|
|
353
|
-
limit(correctZoom: boolean, noLimit?: boolean, freeMove?: boolean): void;
|
|
354
|
-
correctAspectRatio(): void;
|
|
355
|
-
/** Updates the shared Float64Array with the current view coordinates. */
|
|
356
|
-
toArray(): Float64Array;
|
|
357
|
-
/** Checks if this view is equal to another view. */
|
|
358
|
-
equals(centerX: number, centerY: number, width: number, height: number): boolean;
|
|
359
|
-
/** Checks if this view represents the full image [0,0,1,1]. */
|
|
360
|
-
isFull(): boolean;
|
|
361
|
-
}
|
|
362
|
-
/** Represents coordinates: relative image coordinates or screen pixel coordinates. */
|
|
363
|
-
export class Coordinates {
|
|
364
|
-
x: number;
|
|
365
|
-
y: number;
|
|
366
|
-
scale: number;
|
|
367
|
-
w: number;
|
|
368
|
-
direction: number;
|
|
369
|
-
/** Float64Array view for efficient JS access [x, y, scale, w/depth, direction]. */
|
|
370
|
-
readonly arr: Float64Array;
|
|
371
|
-
constructor(x?: number, y?: number, scale?: number, w?: number, direction?: number);
|
|
372
|
-
/** Checks if the screen coordinate is potentially within the viewport bounds. */
|
|
373
|
-
inView(v: Viewport): boolean;
|
|
374
|
-
/** Updates the shared Float64Array with the current coordinate values. */
|
|
375
|
-
toArray(): Float64Array;
|
|
376
|
-
}
|
|
377
|
-
/** Represents the screen viewport of a TileCanvas element. */
|
|
378
|
-
export class Viewport {
|
|
379
|
-
width: number;
|
|
380
|
-
height: number;
|
|
381
|
-
left: number;
|
|
382
|
-
top: number;
|
|
383
|
-
areaWidth: number;
|
|
384
|
-
areaHeight: number;
|
|
385
|
-
ratio: number;
|
|
386
|
-
scale: number;
|
|
387
|
-
isPortrait: boolean;
|
|
388
|
-
/** Int32Array view for efficient JS access [width, height, left, top]. */
|
|
389
|
-
readonly arr: Int32Array;
|
|
390
|
-
constructor(width?: number, height?: number, left?: number, top?: number, areaWidth?: number, areaHeight?: number, ratio?: number, scale?: number, isPortrait?: boolean);
|
|
391
|
-
get centerX(): number;
|
|
392
|
-
get centerY(): number;
|
|
393
|
-
get aspect(): number;
|
|
394
|
-
/** Updates the shared Int32Array with the current viewport dimensions (integer pixels). */
|
|
395
|
-
toArray(): Int32Array;
|
|
396
|
-
/**
|
|
397
|
-
* Sets the viewport properties, scaling by device pixel ratio.
|
|
398
|
-
* @returns True if any property changed, false otherwise.
|
|
399
|
-
*/
|
|
400
|
-
set(w: number, h: number, l: number, t: number, r: number, s: number, p: boolean): boolean;
|
|
401
|
-
/** Copies properties from another Viewport object. */
|
|
402
|
-
copy(v: Viewport): void;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Main controller class for the Micrio engine.
|
|
406
|
-
* Manages all canvases, global settings, and host callbacks.
|
|
407
|
-
* @author Marcel Duin <marcel@micr.io>
|
|
408
|
-
*/
|
|
409
|
-
/** Host interface for callbacks from the engine to the JS host. */
|
|
410
|
-
export interface MainHost {
|
|
411
|
-
drawTile: (imgIdx: number, idx: number, layer: number, x: number, y: number, opacity: number, animating: boolean, isTargetLayer: boolean) => boolean;
|
|
412
|
-
drawQuad: (opacity: number) => void;
|
|
413
|
-
getTileOpacity: (idx: number) => number;
|
|
414
|
-
setTileOpacity: (idx: number, direct: boolean, imageOpacity: number) => number;
|
|
415
|
-
setMatrix: (arr: Float32Array) => void;
|
|
416
|
-
setViewport: (x: number, y: number, width: number, height: number) => void;
|
|
417
|
-
aniDone: (c: TileCanvas) => void;
|
|
418
|
-
aniAbort: (c: TileCanvas) => void;
|
|
419
|
-
viewSet: (c: TileCanvas) => void;
|
|
420
|
-
viewportSet: (c: TileCanvas, x: number, y: number, w: number, h: number) => void;
|
|
421
|
-
setCanvasVisible: (c: TileCanvas, visible: boolean) => void;
|
|
422
|
-
setImageVisible: (c: Image, visible: boolean) => void;
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Main controller class for the Micrio engine.
|
|
426
|
-
* Manages all canvases, global settings, and the render loop.
|
|
427
|
-
* Host callbacks are provided at construction via {@link MainHost}.
|
|
428
|
-
*/
|
|
429
|
-
export class Main {
|
|
430
|
-
/** Viewport representing the main HTML element (<micr-io>). */
|
|
431
|
-
readonly el: Viewport;
|
|
432
|
-
/** Vertex buffer for rendering 2D image tiles (quads). */
|
|
433
|
-
readonly vertexBuffer: Float32Array;
|
|
434
|
-
/** Vertex buffer for rendering 360 sphere geometry. */
|
|
435
|
-
readonly vertexBuffer360: Float32Array;
|
|
436
|
-
/** Array holding all active TileCanvas instances managed by this engine. */
|
|
437
|
-
readonly canvases: TileCanvas[];
|
|
438
|
-
/** Total number of tiles across all images in all canvases. */
|
|
439
|
-
numTiles: number;
|
|
440
|
-
/** Total number of Image instances across all canvases. */
|
|
441
|
-
numImages: number;
|
|
442
|
-
/** Timestamp of the current frame (performance.now()). */
|
|
443
|
-
now: number;
|
|
444
|
-
/** Flag indicating if any animation is active in any canvas this frame. */
|
|
445
|
-
animating: boolean;
|
|
446
|
-
/** Overall loading progress (0-1) based on tiles drawn vs tiles needed. */
|
|
447
|
-
progress: number;
|
|
448
|
-
/** Total number of tiles needed across all canvases this frame. */
|
|
449
|
-
toDrawTotal: number;
|
|
450
|
-
/** Total number of tiles successfully drawn (or already loaded) across all canvases this frame. */
|
|
451
|
-
doneTotal: number;
|
|
452
|
-
/** Default duration (seconds) for crossfade between canvases. */
|
|
453
|
-
crossfadeDuration: number;
|
|
454
|
-
/** Default duration (seconds) for grid item transitions. */
|
|
455
|
-
gridTransitionDuration: number;
|
|
456
|
-
/** Default easing function for grid transitions. */
|
|
457
|
-
gridTransitionTimingFunction: Bicubic;
|
|
458
|
-
/** Default duration (seconds) for transitions between 360 spaces. */
|
|
459
|
-
spacesTransitionDuration: number;
|
|
460
|
-
/** Default duration (seconds) for fading embedded images/videos. */
|
|
461
|
-
embedFadeDuration: number;
|
|
462
|
-
/** Elasticity factor for kinetic dragging (higher = more movement). */
|
|
463
|
-
dragElasticity: number;
|
|
464
|
-
/** Flag indicating if a binary archive is being used. */
|
|
465
|
-
hasArchive: boolean;
|
|
466
|
-
/** Layer offset when using an archive. */
|
|
467
|
-
archiveLayerOffset: number;
|
|
468
|
-
/** Number of "underzoom" levels. */
|
|
469
|
-
underzoomLevels: number;
|
|
470
|
-
/** Number of lowest resolution layers to skip loading initially. */
|
|
471
|
-
skipBaseLevels: number;
|
|
472
|
-
/** Flag for barebone mode (minimal texture loading). */
|
|
473
|
-
bareBone: boolean;
|
|
474
|
-
/** Flag indicating if the current context is a swipe gallery. */
|
|
475
|
-
isSwipe: boolean;
|
|
476
|
-
/** Flag to disable panning during pinch gestures. */
|
|
477
|
-
noPinchPan: boolean;
|
|
478
|
-
/** Target direction for 360 transition. */
|
|
479
|
-
direction: number;
|
|
480
|
-
/** Horizontal distance for 360 transition. */
|
|
481
|
-
distanceX: number;
|
|
482
|
-
/** Vertical distance for 360 transition. */
|
|
483
|
-
distanceY: number;
|
|
484
|
-
/** Estimated time per frame in seconds (used for animation speed normalization). */
|
|
485
|
-
frameTime: number;
|
|
486
|
-
private readonly _host;
|
|
487
|
-
constructor(host: MainHost);
|
|
488
|
-
get drawTile(): (imgIdx: number, idx: number, layer: number, x: number, y: number, opacity: number, animating: boolean, isTargetLayer: boolean) => boolean;
|
|
489
|
-
get drawQuad(): (opacity: number) => void;
|
|
490
|
-
get getTileOpacity(): (idx: number) => number;
|
|
491
|
-
get setTileOpacity(): (idx: number, direct: boolean, imageOpacity: number) => number;
|
|
492
|
-
get setMatrix(): (arr: Float32Array) => void;
|
|
493
|
-
get setViewport(): (x: number, y: number, width: number, height: number) => void;
|
|
494
|
-
get aniDone(): (c: TileCanvas) => void;
|
|
495
|
-
get aniAbort(): (c: TileCanvas) => void;
|
|
496
|
-
get viewSet(): (c: TileCanvas) => void;
|
|
497
|
-
get viewportSet(): (c: TileCanvas, x: number, y: number, w: number, h: number) => void;
|
|
498
|
-
get setCanvasVisible(): (c: TileCanvas, visible: boolean) => void;
|
|
499
|
-
get setImageVisible(): (c: Image, visible: boolean) => void;
|
|
500
|
-
shouldDraw(now: number): boolean;
|
|
501
|
-
draw(): void;
|
|
502
|
-
reset(): void;
|
|
503
|
-
aniStop(): void;
|
|
504
|
-
/**
|
|
505
|
-
* Updates the main element's viewport dimensions and triggers resize on all canvases.
|
|
506
|
-
*/
|
|
507
|
-
resize(w: number, h: number, l: number, t: number, r: number, s: number, p: boolean): void;
|
|
508
|
-
/** Removes a specific TileCanvas instance from the managed list. */
|
|
509
|
-
remove(c: TileCanvas): void;
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Handles kinetic scrolling/dragging behavior after user interaction stops.
|
|
513
|
-
* @author Marcel Duin <marcel@micr.io>
|
|
514
|
-
*/
|
|
515
|
-
/** Handles kinetic scrolling/dragging behavior after user interaction stops. */
|
|
516
|
-
export default class Kinetic {
|
|
517
|
-
private canvas;
|
|
518
|
-
/** Accumulated horizontal delta during drag. */
|
|
519
|
-
private dX;
|
|
520
|
-
/** Accumulated vertical delta during drag. */
|
|
521
|
-
private dY;
|
|
522
|
-
/** Timestamp when the drag interaction started. */
|
|
523
|
-
private startTime;
|
|
524
|
-
/** Timestamp of the previous step added. */
|
|
525
|
-
private prevTime;
|
|
526
|
-
/** Timestamp when the drag interaction ended (kinetic phase started). */
|
|
527
|
-
private endTime;
|
|
528
|
-
/** Timestamp of the last significant interaction step. */
|
|
529
|
-
private lastInteraction;
|
|
530
|
-
/** Current horizontal velocity for kinetic movement. */
|
|
531
|
-
private velocityX;
|
|
532
|
-
/** Current vertical velocity for kinetic movement. */
|
|
533
|
-
private velocityY;
|
|
534
|
-
/** Flag indicating if kinetic movement is currently active. */
|
|
535
|
-
started: boolean;
|
|
536
|
-
constructor(canvas: TileCanvas);
|
|
537
|
-
/**
|
|
538
|
-
* Adds a step (delta) from the user's drag interaction.
|
|
539
|
-
* @param pX Horizontal pixel delta since last step.
|
|
540
|
-
* @param pY Vertical pixel delta since last step.
|
|
541
|
-
* @param time Current timestamp (performance.now()).
|
|
542
|
-
*/
|
|
543
|
-
addStep(pX: number, pY: number, time: number): void;
|
|
544
|
-
/** Starts the kinetic movement phase (called when user stops dragging). */
|
|
545
|
-
start(): void;
|
|
546
|
-
/** Stops the kinetic movement and resets state. */
|
|
547
|
-
stop(): void;
|
|
548
|
-
/**
|
|
549
|
-
* Calculates and applies the kinetic movement step for the current frame.
|
|
550
|
-
* @returns Progress towards stopping (0 = max velocity, 1 = stopped).
|
|
551
|
-
*/
|
|
552
|
-
step(time: number): number;
|
|
553
|
-
}
|
|
554
|
-
/** Manages camera and view animations (fly-to, zoom). */
|
|
555
|
-
export default class Ani {
|
|
556
|
-
private canvas;
|
|
557
|
-
/** Flag indicating if a view animation (fly-to) is active. */
|
|
558
|
-
private isView;
|
|
559
|
-
/** Starting view state for the animation. */
|
|
560
|
-
private readonly vFrom;
|
|
561
|
-
/** Target view state for the animation. */
|
|
562
|
-
private readonly vTo;
|
|
563
|
-
/** Stores the final target view requested (might differ from vTo during corrections). */
|
|
564
|
-
readonly lastView: View;
|
|
565
|
-
/** Flag indicating if a zoom animation (perspective change in 360) is active. */
|
|
566
|
-
private isZoom;
|
|
567
|
-
/** Flag indicating if the animation is a "jump" (zooms out then in). */
|
|
568
|
-
private isJump;
|
|
569
|
-
/** Starting perspective value for zoom animation. */
|
|
570
|
-
private zFrom;
|
|
571
|
-
/** Target perspective value for zoom animation. */
|
|
572
|
-
private zTo;
|
|
573
|
-
/** Flag to disable perspective limits during zoom animation. */
|
|
574
|
-
private zNoLimit;
|
|
575
|
-
/** Easing function used for the current animation. */
|
|
576
|
-
private fn;
|
|
577
|
-
/** Timestamp when the animation started. */
|
|
578
|
-
private started;
|
|
579
|
-
/** Total duration of the animation in milliseconds. */
|
|
580
|
-
private duration;
|
|
581
|
-
/** Flag indicating if the animation is currently running (not paused). */
|
|
582
|
-
private isRunning;
|
|
583
|
-
/** Flag indicating if the view should be limited during animation (usually false during animation). */
|
|
584
|
-
limit: boolean;
|
|
585
|
-
/** Flag indicating if the current animation step resulted in zooming out. */
|
|
586
|
-
zoomingOut: boolean;
|
|
587
|
-
/** Flag indicating if the animation is a fly-to type. */
|
|
588
|
-
flying: boolean;
|
|
589
|
-
/** Flag indicating if the animation is correcting the view to stay within limits. */
|
|
590
|
-
correcting: boolean;
|
|
591
|
-
/** Timestamp when the animation was paused. 0 if not paused. */
|
|
592
|
-
private pausedAt;
|
|
593
|
-
private fL;
|
|
594
|
-
private fT;
|
|
595
|
-
private fR;
|
|
596
|
-
private fB;
|
|
597
|
-
/** Start point for the ease-in part of the jump animation curve. */
|
|
598
|
-
private mI;
|
|
599
|
-
/** Start point for the ease-out part of the jump animation curve. */
|
|
600
|
-
private mO;
|
|
601
|
-
/** Starting frame index for omni object rotation animation. */
|
|
602
|
-
private omniStartIdx;
|
|
603
|
-
/** Delta (number of frames) to rotate during omni animation. */
|
|
604
|
-
private omniDelta;
|
|
605
|
-
constructor(canvas: TileCanvas);
|
|
606
|
-
/** Pauses the current animation. */
|
|
607
|
-
pause(time: number): void;
|
|
608
|
-
/** Resumes a paused animation. */
|
|
609
|
-
resume(time: number): void;
|
|
610
|
-
/** Stops the current animation completely and resets state. */
|
|
611
|
-
stop(): void;
|
|
612
|
-
/** Checks if a view animation is currently running. */
|
|
613
|
-
isStarted(): boolean;
|
|
614
|
-
/**
|
|
615
|
-
* Starts or updates a "fly-to" animation to a target view rectangle.
|
|
616
|
-
* @returns Calculated or provided animation duration in ms.
|
|
617
|
-
*/
|
|
618
|
-
toView(toCenterX: number, toCenterY: number, toWidth: number, toHeight: number, dur: number, speed: number, perc: number, isJump: boolean, limitViewport: boolean, omniIdx: number, fn: number, time: number, correct?: boolean): number;
|
|
619
|
-
/** Updates the target view of a running animation. Used for corrections. */
|
|
620
|
-
updateTarget(toCenterX: number, toCenterY: number, toWidth: number, toHeight: number, limiting?: boolean): void;
|
|
621
|
-
/**
|
|
622
|
-
* Starts a zoom animation (perspective change for 360).
|
|
623
|
-
* @returns Calculated or provided animation duration in ms.
|
|
624
|
-
*/
|
|
625
|
-
zoom(to: number, dur: number, speed: number, noLimit: boolean, time: number): number;
|
|
626
|
-
/** Sets the starting view for progress calculation in flyTo animations. */
|
|
627
|
-
setStartView(centerX: number, centerY: number, width: number, height: number, correctRatio: boolean): void;
|
|
628
|
-
/**
|
|
629
|
-
* Calculates and applies the animation step for the current frame.
|
|
630
|
-
* @returns Current animation progress (0-1).
|
|
631
|
-
*/
|
|
632
|
-
step(time: number): number;
|
|
633
|
-
}
|
|
634
|
-
/**
|
|
635
|
-
* Handles 2D camera logic, view calculations, and user interactions like pan, zoom, pinch.
|
|
636
|
-
* @author Marcel Duin <marcel@micr.io>
|
|
637
|
-
*/
|
|
638
|
-
/** Handles 2D camera logic, view calculations, and user interactions like pan, zoom, pinch. */
|
|
639
|
-
export default class Camera {
|
|
640
|
-
private canvas;
|
|
641
|
-
scale: number;
|
|
642
|
-
minScale: number;
|
|
643
|
-
minSize: number;
|
|
644
|
-
maxScale: number;
|
|
645
|
-
fullScale: number;
|
|
646
|
-
coverScale: number;
|
|
647
|
-
readonly xy: Coordinates;
|
|
648
|
-
readonly coo: Coordinates;
|
|
649
|
-
private readonly startCoo;
|
|
650
|
-
private pinching;
|
|
651
|
-
private inited;
|
|
652
|
-
private hasStartCoo;
|
|
653
|
-
cpw: number;
|
|
654
|
-
cph: number;
|
|
655
|
-
private wasCoverLimit;
|
|
656
|
-
constructor(canvas: TileCanvas);
|
|
657
|
-
/**
|
|
658
|
-
* Converts screen pixel coordinates to relative image coordinates [0-1].
|
|
659
|
-
*/
|
|
660
|
-
getCoo(x: number, y: number, abs: boolean, noLimit: boolean): Coordinates;
|
|
661
|
-
/**
|
|
662
|
-
* Converts relative image coordinates [0-1] to screen pixel coordinates.
|
|
663
|
-
*/
|
|
664
|
-
getXY(x: number, y: number, abs: boolean): Coordinates;
|
|
665
|
-
getXYOmni(x: number, y: number, radius: number, rotation: number, abs: boolean): Coordinates;
|
|
666
|
-
/**
|
|
667
|
-
* Converts 3D coordinates relative to an omni object's center to screen pixel coordinates.
|
|
668
|
-
*/
|
|
669
|
-
getXYOmniCoo(x: number, y: number, z: number, rotation: number, abs: boolean): Coordinates;
|
|
670
|
-
/** Recalculates scale limits (minScale, maxScale, coverScale, fullScale) based on current canvas and image dimensions. */
|
|
671
|
-
setCanvas(): void;
|
|
672
|
-
/** Corrects minScale and maxScale based on coverLimit and focus area. */
|
|
673
|
-
correctMinMax(noLimit?: boolean): void;
|
|
674
|
-
/** Checks if the current scale is below the minimum allowed scale (considering minSize margin). */
|
|
675
|
-
isUnderZoom(): boolean;
|
|
676
|
-
/** Checks if the camera is fully zoomed out (at or below minScale, considering minSize margin). */
|
|
677
|
-
isZoomedOut(b?: boolean): boolean;
|
|
678
|
-
/** Checks if the camera is fully zoomed in (at or above maxScale). */
|
|
679
|
-
isZoomedIn(): boolean;
|
|
680
|
-
/**
|
|
681
|
-
* Calculates and sets the current camera scale and view offsets based on the logical view rectangle.
|
|
682
|
-
* @returns True if the view was successfully set, false if initialization is pending.
|
|
683
|
-
*/
|
|
684
|
-
setView(): boolean;
|
|
685
|
-
/** Checks if the current view extends beyond the defined limits or max scale. */
|
|
686
|
-
isOutsideLimit(): boolean;
|
|
687
|
-
/**
|
|
688
|
-
* Pans the view by a given pixel delta.
|
|
689
|
-
*/
|
|
690
|
-
pan(xPx: number, yPx: number, duration: number, noLimit: boolean, time: number, force?: boolean, isKinetic?: boolean): void;
|
|
691
|
-
/**
|
|
692
|
-
* Zooms the view by a given delta, centered on screen coordinates.
|
|
693
|
-
* @returns The calculated animation duration.
|
|
694
|
-
*/
|
|
695
|
-
zoom(delta: number, xPx: number, yPx: number, duration: number, noLimit: boolean, time: number): number;
|
|
696
|
-
prevSize: number;
|
|
697
|
-
prevCenterX: number;
|
|
698
|
-
prevCenterY: number;
|
|
699
|
-
/** Handles pinch gesture updates. */
|
|
700
|
-
pinch(xPx1: number, yPx1: number, xPx2: number, yPx2: number): void;
|
|
701
|
-
/** Signals the start of a pinch gesture. */
|
|
702
|
-
pinchStart(): void;
|
|
703
|
-
/** Signals the end of a pinch gesture. */
|
|
704
|
-
pinchStop(time: number): void;
|
|
705
|
-
private snapToBounds;
|
|
706
|
-
/**
|
|
707
|
-
* Initiates a fly-to animation to a target view rectangle.
|
|
708
|
-
* @returns The calculated animation duration.
|
|
709
|
-
*/
|
|
710
|
-
flyTo(centerX: number, centerY: number, width: number, height: number, dur: number, speed: number, perc: number, isJump: boolean, limit: boolean, limitZoom: boolean, toOmniIdx: number, fn: number, time: number): number;
|
|
711
|
-
/**
|
|
712
|
-
* Sets the view center and scale, optionally animating.
|
|
713
|
-
* @returns The calculated animation duration.
|
|
714
|
-
*/
|
|
715
|
-
setCoo(x: number, y: number, scale: number, dur: number, speed: number, limit: boolean, fn: number, time: number): number;
|
|
716
|
-
}
|
|
717
|
-
/** Handles 360 camera logic, perspective, and related SphericalView calculations. */
|
|
718
|
-
export default class SphericalView {
|
|
719
|
-
private canvas;
|
|
720
|
-
readonly pMatrix: Mat4;
|
|
721
|
-
readonly iMatrix: Mat4;
|
|
722
|
-
private readonly cachedInverse;
|
|
723
|
-
private inverseDirty;
|
|
724
|
-
private readonly rMatrix;
|
|
725
|
-
readonly position: Vec4;
|
|
726
|
-
radius: number;
|
|
727
|
-
scale: number;
|
|
728
|
-
scaleY: number;
|
|
729
|
-
offY: number;
|
|
730
|
-
dofY: number;
|
|
731
|
-
limitX: number;
|
|
732
|
-
limitY: number;
|
|
733
|
-
baseYaw: number;
|
|
734
|
-
yaw: number;
|
|
735
|
-
pitch: number;
|
|
736
|
-
defaultPerspective: number;
|
|
737
|
-
perspective: number;
|
|
738
|
-
maxPerspective: number;
|
|
739
|
-
minPerspective: number;
|
|
740
|
-
cameraForwardX: number;
|
|
741
|
-
cameraForwardY: number;
|
|
742
|
-
cameraForwardZ: number;
|
|
743
|
-
cameraUpX: number;
|
|
744
|
-
cameraUpY: number;
|
|
745
|
-
cameraUpZ: number;
|
|
746
|
-
cameraRightX: number;
|
|
747
|
-
cameraRightY: number;
|
|
748
|
-
cameraRightZ: number;
|
|
749
|
-
fieldOfView: number;
|
|
750
|
-
aspectRatio: number;
|
|
751
|
-
readonly vec4: Vec4;
|
|
752
|
-
readonly coo: Coordinates;
|
|
753
|
-
offX: number;
|
|
754
|
-
constructor(canvas: TileCanvas);
|
|
755
|
-
/** Sets the horizontal and vertical movement limits. */
|
|
756
|
-
setLimits(x: number, y: number): void;
|
|
757
|
-
/** Updates the projection and rotation matrices based on current state. */
|
|
758
|
-
update(noPersp?: boolean): void;
|
|
759
|
-
/**
|
|
760
|
-
* Applies rotation based on pixel delta from mouse/touch drag.
|
|
761
|
-
*/
|
|
762
|
-
rotate(xPx: number, yPx: number, duration: number, time: number): void;
|
|
763
|
-
/** Clamps the pitch value based on perspective and vertical limits. */
|
|
764
|
-
private limitPitch;
|
|
765
|
-
/** Clamps the yaw value based on horizontal limits. */
|
|
766
|
-
private limitYaw;
|
|
767
|
-
/**
|
|
768
|
-
* Applies zoom by adjusting the perspective.
|
|
769
|
-
*/
|
|
770
|
-
zoom(factor: number, dur: number, speed: number, noLimit: boolean, t: number, pxX?: number, pxY?: number): number;
|
|
771
|
-
/** Sets the perspective (FoV) and updates related state. */
|
|
772
|
-
setPerspective(perspective: number, noLimit: boolean): void;
|
|
773
|
-
/** Recalculates the effective scale based on coordinate conversion. */
|
|
774
|
-
readScale(): void;
|
|
775
|
-
/** Sets the camera orientation directly. */
|
|
776
|
-
setDirection(yaw: number, pitch: number, persp: number): void;
|
|
777
|
-
/** Sets the camera orientation using viewport format (center + dimensions). */
|
|
778
|
-
setView(centerX: number, centerY: number, _width: number, height: number, noLimit?: boolean, correctNorth?: boolean): void;
|
|
779
|
-
/** Synchronizes the logical view with the current camera state for 360 images. */
|
|
780
|
-
private syncLogicalView;
|
|
781
|
-
/** Calculates 3D camera frustum for accurate 360 embed visibility detection */
|
|
782
|
-
calculate3DFrustum(): void;
|
|
783
|
-
/** Applies translation offset for 360 space transitions. */
|
|
784
|
-
moveTo(distance: number, distanceY: number, direction: number, addYaw: number): void;
|
|
785
|
-
/** Handles canvas resize events for 360 mode. */
|
|
786
|
-
resize(): void;
|
|
787
|
-
/** Ensures the cached inverse projection matrix is up to date. */
|
|
788
|
-
private ensureInverse;
|
|
789
|
-
/** Converts screen pixel coordinates to 360 image coordinates [0-1]. */
|
|
790
|
-
getCoo(pxX: number, pxY: number): Coordinates;
|
|
791
|
-
/** Converts 360 image coordinates [0-1] to screen pixel coordinates. */
|
|
792
|
-
getXYZ(x: number, y: number): Coordinates;
|
|
793
|
-
/**
|
|
794
|
-
* Calculates the 3D vector corresponding to a point on the 360 sphere.
|
|
795
|
-
*/
|
|
796
|
-
getVec3(x: number, y: number, abs?: boolean, rad?: number): Vec4;
|
|
797
|
-
/**
|
|
798
|
-
* Calculates the combined transformation matrix for placing an element
|
|
799
|
-
* at a specific point on the 360 sphere.
|
|
800
|
-
*/
|
|
801
|
-
getMatrix(x: number, y: number, scale: number, radius: number, rX: number, rY: number, rZ: number, transY: number, sX?: number, sY?: number, _noCorrectNorth?: boolean): Mat4;
|
|
802
|
-
/** Generates vertex data for a segment of the 360 sphere geometry. */
|
|
803
|
-
setTile360(x: number, y: number, w: number, h: number): void;
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* Represents a single rendering canvas within the Micrio engine.
|
|
807
|
-
* Orchestrates image loading, tile calculation, camera control, and drawing.
|
|
808
|
-
* @author Marcel Duin <marcel@micr.io>
|
|
809
|
-
*/
|
|
810
|
-
export interface TileCanvasConfig {
|
|
811
|
-
tileSize: number;
|
|
812
|
-
is360: boolean;
|
|
813
|
-
noImage: boolean;
|
|
814
|
-
isSingle: boolean;
|
|
815
|
-
freeMove: boolean;
|
|
816
|
-
coverStart: boolean;
|
|
817
|
-
maxScale: number;
|
|
818
|
-
scaleMultiplier: number;
|
|
819
|
-
camSpeed: number;
|
|
820
|
-
rotationY: number;
|
|
821
|
-
isGallerySwitch: boolean;
|
|
822
|
-
pagesHaveBackground: boolean;
|
|
823
|
-
isOmni: boolean;
|
|
824
|
-
pinchZoomOutLimit: boolean;
|
|
825
|
-
omniNumLayers: number;
|
|
826
|
-
omniStartLayer: number;
|
|
827
|
-
}
|
|
828
|
-
export default class TileCanvas {
|
|
829
|
-
readonly main: Main;
|
|
830
|
-
width: number;
|
|
831
|
-
height: number;
|
|
832
|
-
targetOpacity: number;
|
|
833
|
-
coverLimit: boolean;
|
|
834
|
-
readonly hasParent: boolean;
|
|
835
|
-
readonly view: View;
|
|
836
|
-
readonly focus: View;
|
|
837
|
-
readonly ani: Ani;
|
|
838
|
-
readonly kinetic: Kinetic;
|
|
839
|
-
readonly camera: Camera;
|
|
840
|
-
readonly webgl: SphericalView;
|
|
841
|
-
readonly rect: DrawRect;
|
|
842
|
-
readonly el: Viewport;
|
|
843
|
-
readonly images: Image[];
|
|
844
|
-
private readonly children;
|
|
845
|
-
readonly area: View;
|
|
846
|
-
readonly currentArea: View;
|
|
847
|
-
readonly targetArea: View;
|
|
848
|
-
readonly visible: View;
|
|
849
|
-
readonly full: View;
|
|
850
|
-
private areaAniPerc;
|
|
851
|
-
private areaAniPaused;
|
|
852
|
-
private _zIndex;
|
|
853
|
-
private childrenDirty;
|
|
854
|
-
get zIndex(): number;
|
|
855
|
-
set zIndex(v: number);
|
|
856
|
-
readonly toDraw: number[];
|
|
857
|
-
readonly aspect: number;
|
|
858
|
-
private index;
|
|
859
|
-
private isVisible;
|
|
860
|
-
opacity: number;
|
|
861
|
-
bOpacity: number;
|
|
862
|
-
isReady: boolean;
|
|
863
|
-
activeImageIdx: number;
|
|
864
|
-
omniFieldOfView: number;
|
|
865
|
-
omniVerticalAngle: number;
|
|
866
|
-
omniDistance: number;
|
|
867
|
-
omniOffsetX: number;
|
|
868
|
-
limited: boolean;
|
|
869
|
-
layer: number;
|
|
870
|
-
readonly tileSize: number;
|
|
871
|
-
readonly is360: boolean;
|
|
872
|
-
readonly noImage: boolean;
|
|
873
|
-
readonly isSingle: boolean;
|
|
874
|
-
readonly freeMove: boolean;
|
|
875
|
-
readonly coverStart: boolean;
|
|
876
|
-
readonly maxScale: number;
|
|
877
|
-
readonly scaleMultiplier: number;
|
|
878
|
-
readonly camSpeed: number;
|
|
879
|
-
readonly rotationY: number;
|
|
880
|
-
readonly isGallerySwitch: boolean;
|
|
881
|
-
readonly pagesHaveBackground: boolean;
|
|
882
|
-
readonly isOmni: boolean;
|
|
883
|
-
readonly pinchZoomOutLimit: boolean;
|
|
884
|
-
readonly omniNumLayers: number;
|
|
885
|
-
readonly omniStartLayer: number;
|
|
886
|
-
constructor(main: Main, width: number, height: number, targetOpacity: number, coverLimit: boolean, cfg: TileCanvasConfig, hasParent?: boolean);
|
|
887
|
-
/** Reference to the parent canvas (if this is a child/grid item). */
|
|
888
|
-
parent: TileCanvas;
|
|
889
|
-
/** Sets the parent canvas for a child canvas. */
|
|
890
|
-
setParent(parent: TileCanvas): void;
|
|
891
|
-
/**
|
|
892
|
-
* Adds an image source (usually tiled) to this canvas.
|
|
893
|
-
*/
|
|
894
|
-
addImage(x0: number, y0: number, x1: number, y1: number, w: number, h: number, tileSize: number, isSingle: boolean, isVideo: boolean, opa: number, rotX: number, rotY: number, rotZ: number, scale: number, fromScale: number): Image;
|
|
895
|
-
addChild(x0: number, y0: number, x1: number, y1: number, width: number, height: number): TileCanvas;
|
|
896
|
-
/** Steps the opacity fade animation and applies 360 transition movement. */
|
|
897
|
-
private stepOpacity;
|
|
898
|
-
/** Notifies the JS host about visibility changes. */
|
|
899
|
-
setCanvasVisible(b: boolean): void;
|
|
900
|
-
/** Initiates a fade-out animation. */
|
|
901
|
-
fadeOut(): void;
|
|
902
|
-
/** Initiates a fade-in animation. */
|
|
903
|
-
fadeIn(): void;
|
|
904
|
-
/** Checks if the canvas area is currently animating. */
|
|
905
|
-
areaAnimating(): boolean;
|
|
906
|
-
/** Checks if the canvas is effectively hidden. */
|
|
907
|
-
isHidden(): boolean;
|
|
908
|
-
/** Determines if the canvas needs to be drawn in the next frame and calculates tiles needed. */
|
|
909
|
-
shouldDraw(): void;
|
|
910
|
-
/** Executes the drawing commands for the current frame for this canvas. */
|
|
911
|
-
draw(): void;
|
|
912
|
-
private partialView;
|
|
913
|
-
/** Sets the target area for this canvas within its parent, optionally animating. */
|
|
914
|
-
setArea(x0: number, y0: number, x1: number, y1: number, direct: boolean, noDispatch: boolean): void;
|
|
915
|
-
/** Calculates the vertex positions for a given tile index and updates the vertex buffer. */
|
|
916
|
-
private setTile;
|
|
917
|
-
/** Notifies JS host about the current screen viewport details. */
|
|
918
|
-
sendViewport(): void;
|
|
919
|
-
/** Finds the Image, Layer, and calculates the DrawRect for a given global tile index. */
|
|
920
|
-
private findTileRect;
|
|
921
|
-
/** Handles resizing of the canvas element. */
|
|
922
|
-
resize(): void;
|
|
923
|
-
/** Resets the canvas state. */
|
|
924
|
-
reset(): void;
|
|
925
|
-
/** Removes this canvas instance from the main controller. */
|
|
926
|
-
remove(): void;
|
|
927
|
-
/** Re-adds this canvas instance to the main controller. */
|
|
928
|
-
replace(): void;
|
|
929
|
-
/** Sets the active layer for multi-layer omni objects. */
|
|
930
|
-
setActiveLayer(idx: number): void;
|
|
931
|
-
/** Sets the active image(s) for gallery/omni canvases. */
|
|
932
|
-
setActiveImage(idx: number, num: number): void;
|
|
933
|
-
/** Sets the focus area for gallery/grid canvases. */
|
|
934
|
-
setFocus(x0: number, y0: number, x1: number, y1: number, noLimit: boolean): void;
|
|
935
|
-
/** Gets image coordinates from screen coordinates. */
|
|
936
|
-
getCoo(x: number, y: number, abs: boolean, noLimit: boolean): Float64Array;
|
|
937
|
-
/** Gets screen coordinates from image coordinates. */
|
|
938
|
-
getXY(x: number, y: number, abs: boolean, radius: number, rotation: number): Float64Array;
|
|
939
|
-
/** Gets the current logical view array. */
|
|
940
|
-
getView(): Float64Array;
|
|
941
|
-
/** Sets the logical view directly. */
|
|
942
|
-
setView(centerX: number, centerY: number, width: number, height: number, noLimit: boolean, noLastView: boolean, correctNorth?: boolean, forceLimit?: boolean): void;
|
|
943
|
-
getScale(): number;
|
|
944
|
-
isZoomedIn(): boolean;
|
|
945
|
-
isZoomedOut(b?: boolean): boolean;
|
|
946
|
-
setDirection(yaw: number, pitch: number, resetPersp: boolean): void;
|
|
947
|
-
getMatrix(x: number, y: number, s: number, r: number, rX: number, rY: number, rZ: number, t: number, sX?: number, sY?: number, noCorrectNorth?: boolean): Float32Array;
|
|
948
|
-
aniPause(time: number): void;
|
|
949
|
-
aniResume(time: number): void;
|
|
950
|
-
aniStop(): void;
|
|
951
|
-
aniDone(): void;
|
|
952
|
-
aniAbort(): void;
|
|
953
|
-
}
|
|
954
15
|
/** Type for error codes */
|
|
955
16
|
export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
956
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Calculates the positive modulo (floored division remainder).
|
|
19
|
+
*/
|
|
20
|
+
export const mod: (n: number, m?: number) => number;
|
|
957
21
|
/**
|
|
958
22
|
* Converts seconds into a human-readable time string (hh?:mm:ss).
|
|
959
23
|
* @param s Time in seconds. Can be negative for remaining time display.
|
|
@@ -1215,7 +279,7 @@ declare module '@micrio/client' {
|
|
|
1215
279
|
isZoomedOut: (full?: boolean) => boolean;
|
|
1216
280
|
/**
|
|
1217
281
|
* Sets a rectangular limit for camera navigation within the image.
|
|
1218
|
-
* @param
|
|
282
|
+
* @param v The viewport limit rectangle [x0, y0, x1, y1].
|
|
1219
283
|
*/
|
|
1220
284
|
setLimit(v: Models.Camera.ViewRect): void;
|
|
1221
285
|
/**
|
|
@@ -1276,7 +340,7 @@ declare module '@micrio/client' {
|
|
|
1276
340
|
* @param duration Forced duration in ms (0 for instant).
|
|
1277
341
|
* @param x Screen pixel X-coordinate for zoom focus (optional, defaults to center).
|
|
1278
342
|
* @param y Screen pixel Y-coordinate for zoom focus (optional, defaults to center).
|
|
1279
|
-
* @param
|
|
343
|
+
* @param _speed Animation speed multiplier (optional).
|
|
1280
344
|
* @param noLimit If true, allows zooming beyond image boundaries.
|
|
1281
345
|
* @returns A Promise that resolves when the zoom animation completes.
|
|
1282
346
|
*/
|
|
@@ -1363,8 +427,6 @@ declare module '@micrio/client' {
|
|
|
1363
427
|
private now;
|
|
1364
428
|
private raf;
|
|
1365
429
|
private drawing;
|
|
1366
|
-
/** Returns the engine TileCanvas for a MicrioImage, or undefined. */
|
|
1367
|
-
getCanvas(img: MicrioImage | Models.Omni.Frame): TileCanvas | undefined;
|
|
1368
430
|
constructor(micrio: HTMLMicrioElement);
|
|
1369
431
|
/**
|
|
1370
432
|
* Initializes the engine (replaces WebAssembly loading).
|
|
@@ -3077,19 +2139,19 @@ declare module '@micrio/client' {
|
|
|
3077
2139
|
/** A numeric array or Float64Array used for camera geometry. */
|
|
3078
2140
|
type CameraArray = number[] | Float64Array;
|
|
3079
2141
|
/** A viewport rectangle `[x0, y0, x1, y1]` (corners). */
|
|
3080
|
-
|
|
2142
|
+
type ViewRect = CameraArray;
|
|
3081
2143
|
/** An area definition `[x0, y0, width, height]` (origin + size). */
|
|
3082
|
-
|
|
2144
|
+
type View = CameraArray;
|
|
3083
2145
|
/** Coordinate tuple, [x, y, scale] */
|
|
3084
|
-
|
|
2146
|
+
type Coords = [number, number, number?] | Float64Array;
|
|
3085
2147
|
/** A 360 vector for use in Spaces */
|
|
3086
|
-
|
|
2148
|
+
type Vector = {
|
|
3087
2149
|
direction: number;
|
|
3088
2150
|
distanceX: number;
|
|
3089
2151
|
distanceY: number;
|
|
3090
2152
|
};
|
|
3091
|
-
|
|
3092
|
-
|
|
2153
|
+
type TimingFunction = ('ease' | 'ease-in' | 'ease-out' | 'linear');
|
|
2154
|
+
interface AnimationOptions {
|
|
3093
2155
|
/** Animation duration in ms */
|
|
3094
2156
|
duration?: number;
|
|
3095
2157
|
/** Limit the viewport to fill the screen */
|
|
@@ -3099,7 +2161,6 @@ declare module '@micrio/client' {
|
|
|
3099
2161
|
/** Transition timing function */
|
|
3100
2162
|
timingFunction?: TimingFunction;
|
|
3101
2163
|
}
|
|
3102
|
-
export {};
|
|
3103
2164
|
}
|
|
3104
2165
|
namespace Embeds {
|
|
3105
2166
|
interface EmbedOptions {
|
|
@@ -3891,7 +2952,7 @@ declare module '@micrio/client' {
|
|
|
3891
2952
|
* </script>
|
|
3892
2953
|
* ```
|
|
3893
2954
|
*
|
|
3894
|
-
*
|
|
2955
|
+
* {@include ./element.md}
|
|
3895
2956
|
*
|
|
3896
2957
|
* @author Marcel Duin <marcel@micr.io>
|
|
3897
2958
|
*/
|
|
@@ -4216,27 +3277,6 @@ declare module '@micrio/client' {
|
|
|
4216
3277
|
export { archive } from "ts/render/archive";
|
|
4217
3278
|
export { loadTexture, runningThreads, numThreads, abortDownload } from "ts/render/textures";
|
|
4218
3279
|
export type { TextureBitmap } from "ts/render/textures";
|
|
4219
|
-
/**
|
|
4220
|
-
* Micrio Engine — TypeScript compute core for the Micrio image viewer.
|
|
4221
|
-
*
|
|
4222
|
-
* This module replaces the WebAssembly/AssemblyScript compute layer.
|
|
4223
|
-
* It provides the same computational logic (camera math, tile pyramid
|
|
4224
|
-
* management, animation engine, 360 sphere geometry, matrix/vector math)
|
|
4225
|
-
* as pure TypeScript classes.
|
|
4226
|
-
*
|
|
4227
|
-
* @author Marcel Duin <marcel@micr.io>
|
|
4228
|
-
*/
|
|
4229
|
-
export { Main } from "engine/main";
|
|
4230
|
-
export { default as TileCanvas } from "engine/canvas/canvas";
|
|
4231
|
-
export { default as Image } from "engine/canvas/image";
|
|
4232
|
-
export { default as SphericalView } from "engine/webgl/webgl";
|
|
4233
|
-
export { default as Camera } from "engine/camera/camera";
|
|
4234
|
-
export { default as Ani } from "engine/camera/ani";
|
|
4235
|
-
export { default as Kinetic } from "engine/camera/kinetic";
|
|
4236
|
-
export { View, Coordinates, Viewport, DrawRect } from "engine/shared/shared";
|
|
4237
|
-
export { Mat4, Vec4 } from "engine/webgl/mat";
|
|
4238
|
-
export { Bicubic, easeInOut, easeIn, easeOut, linear, mod1, modPI, twoNth, longitudeDistance } from "engine/utils/utils";
|
|
4239
|
-
export { PI, PI2, PIh, segsX, segsY, base360Distance } from "engine/globals";
|
|
4240
3280
|
}declare module "svelte/store" {
|
|
4241
3281
|
/** Callback to inform of a value updates.
|
|
4242
3282
|
*/
|