@idetik/core 0.27.1 → 0.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as gl_matrix from 'gl-matrix';
2
- import { vec3, mat4, quat, vec4, vec2 } from 'gl-matrix';
2
+ import { vec2, mat4, vec3, quat, vec4 } from 'gl-matrix';
3
3
  import * as zarr from 'zarrita';
4
4
  import { Location, Readable } from 'zarrita';
5
5
  import { z } from 'zod';
@@ -98,7 +98,7 @@ type SliceCoordinates = {
98
98
  t?: number;
99
99
  };
100
100
  type ChunkSource = {
101
- getLoader(): ChunkLoader;
101
+ get loader(): ChunkLoader;
102
102
  };
103
103
  type ChunkLoader = {
104
104
  getSourceDimensionMap(): SourceDimensionMap;
@@ -145,19 +145,17 @@ declare function createNoPrefetchPolicy(overrides?: Partial<ImageSourcePolicyCon
145
145
 
146
146
  declare class ChunkStore {
147
147
  private readonly chunks_;
148
- private readonly loader_;
149
148
  private readonly lowestResLOD_;
150
149
  private readonly dimensions_;
151
150
  private readonly views_;
152
151
  private hasHadViews_;
153
- constructor(loader: ChunkLoader);
152
+ constructor(dimensions: SourceDimensionMap);
154
153
  getChunkGrid(lod: number, t: number, c: number): Chunk[][][] | undefined;
155
154
  hasChunksAtTime(timeIndex: number): boolean;
156
155
  get lodCount(): number;
157
156
  get channelCount(): number;
158
157
  get dimensions(): SourceDimensionMap;
159
158
  getLowestResLOD(): number;
160
- loadChunkData(chunk: Chunk, signal: AbortSignal): Promise<void>;
161
159
  addView(policy: ImageSourcePolicy): ChunkStoreView;
162
160
  get views(): ReadonlyArray<ChunkStoreView>;
163
161
  canDispose(): boolean;
@@ -169,6 +167,95 @@ declare class ChunkStore {
169
167
  private getAndValidateChannelDimension;
170
168
  }
171
169
 
170
+ declare class Box2 {
171
+ min: vec2;
172
+ max: vec2;
173
+ /**
174
+ * Initializes as an empty box if no values are provided using the
175
+ * "empty-by-sentinel" pattern: min = +Infinity, max = -Infinity.
176
+ * This allows expansion functions to work without special-casing
177
+ * the first element, and avoids biasing toward (0,0).
178
+ */
179
+ constructor(min?: vec2, max?: vec2);
180
+ clone(): Box2;
181
+ isEmpty(): boolean;
182
+ static intersects(a: Box2, b: Box2): boolean;
183
+ static equals(a: Box2, b: Box2): boolean;
184
+ floor(): Box2;
185
+ toRect(): {
186
+ x: number;
187
+ y: number;
188
+ width: number;
189
+ height: number;
190
+ };
191
+ }
192
+
193
+ declare class ChunkStoreView {
194
+ private readonly store_;
195
+ private policy_;
196
+ private policyChanged_;
197
+ private currentLOD_;
198
+ private lastViewBounds2D_;
199
+ private lastViewProjection_;
200
+ private lastZBounds_?;
201
+ private lastTCoord_?;
202
+ private lastCCoords_?;
203
+ private sourceMaxSquareDistance2D_;
204
+ private readonly chunkViewStates_;
205
+ private isDisposed_;
206
+ constructor(store: ChunkStore, policy: ImageSourcePolicy);
207
+ get chunkViewStates(): ReadonlyMap<Chunk, ChunkViewState>;
208
+ get isDisposed(): boolean;
209
+ get lodCount(): number;
210
+ get channelCount(): number;
211
+ getChunksToRender(): Chunk[];
212
+ updateChunksForImage(sliceCoords: SliceCoordinates, view: {
213
+ worldViewRect: Box2;
214
+ bufferWidthPx: number;
215
+ }): void;
216
+ updateChunksForVolume(sliceCoords: SliceCoordinates, viewProjection: mat4): void;
217
+ allVisibleFallbackLODLoaded(): boolean;
218
+ get currentLOD(): number;
219
+ maybeForgetChunk(chunk: Chunk): void;
220
+ dispose(): void;
221
+ setImageSourcePolicy(newPolicy: ImageSourcePolicy, key: symbol): void;
222
+ private setLOD;
223
+ private markTimeChunksForPrefetchImage;
224
+ private markTimeChunksForPrefetchVolume;
225
+ private computePriority;
226
+ private channelsOfInterest;
227
+ private chunkIndexRange;
228
+ private iterateChunksInBox;
229
+ private iterateAllChunksAtLod;
230
+ private getChunkAabb;
231
+ private fallbackLOD;
232
+ private timeIndex;
233
+ private getZBounds;
234
+ private viewBounds2DChanged;
235
+ private hasViewProjectionChanged;
236
+ private zBoundsChanged;
237
+ private cCoordsChanged;
238
+ private getPaddedBounds;
239
+ private squareDistance2D;
240
+ }
241
+
242
+ type QueueStats = {
243
+ pending: number;
244
+ running: number;
245
+ };
246
+
247
+ declare class ChunkManager {
248
+ private readonly stores_;
249
+ private readonly queue_;
250
+ get queueStats(): QueueStats;
251
+ get memoryStats(): {
252
+ cpuChunkBytes: number;
253
+ cpuChunkCount: number;
254
+ };
255
+ addView(source: ChunkSource, policy: ImageSourcePolicy): ChunkStoreView;
256
+ update(): void;
257
+ }
258
+
172
259
  declare class Box3 {
173
260
  min: vec3;
174
261
  max: vec3;
@@ -266,29 +353,6 @@ declare class Color {
266
353
  private toHexComponent;
267
354
  }
268
355
 
269
- declare class Box2 {
270
- min: vec2;
271
- max: vec2;
272
- /**
273
- * Initializes as an empty box if no values are provided using the
274
- * "empty-by-sentinel" pattern: min = +Infinity, max = -Infinity.
275
- * This allows expansion functions to work without special-casing
276
- * the first element, and avoids biasing toward (0,0).
277
- */
278
- constructor(min?: vec2, max?: vec2);
279
- clone(): Box2;
280
- isEmpty(): boolean;
281
- static intersects(a: Box2, b: Box2): boolean;
282
- static equals(a: Box2, b: Box2): boolean;
283
- floor(): Box2;
284
- toRect(): {
285
- x: number;
286
- y: number;
287
- width: number;
288
- height: number;
289
- };
290
- }
291
-
292
356
  type CullingMode = "none" | "front" | "back" | "both";
293
357
 
294
358
  declare abstract class RenderableObject extends Node {
@@ -340,6 +404,7 @@ declare abstract class Camera extends RenderableObject {
340
404
  get viewMatrix(): mat4;
341
405
  get right(): vec3;
342
406
  get up(): vec3;
407
+ getViewProjection(): mat4;
343
408
  get frustum(): Frustum;
344
409
  abstract setAspectRatio(aspectRatio: number): void;
345
410
  abstract zoom(factor: number): void;
@@ -372,49 +437,6 @@ declare class EventDispatcher {
372
437
  private readonly handleEvent;
373
438
  }
374
439
 
375
- type LayerState = "initialized" | "loading" | "ready";
376
- type BlendMode = "none" | "normal" | "additive" | "subtractive" | "multiply" | "premultiplied";
377
- type StateChangeCallback = (newState: LayerState, prevState?: LayerState) => void;
378
- interface LayerOptions {
379
- opacity?: number;
380
- blendMode?: BlendMode;
381
- }
382
- type RenderContext = {
383
- viewport: Viewport;
384
- };
385
- declare abstract class Layer {
386
- abstract readonly type: string;
387
- private objects_;
388
- private state_;
389
- private attached_;
390
- private readonly callbacks_;
391
- private opacity_;
392
- blendMode: BlendMode;
393
- constructor({ opacity, blendMode }?: LayerOptions);
394
- get opacity(): number;
395
- set opacity(value: number);
396
- abstract update(context?: RenderContext): void;
397
- onEvent(_: EventContext): void;
398
- onAttached(context: IdetikContext): void;
399
- onDetached(context: IdetikContext): void;
400
- protected attach(_context: IdetikContext): void;
401
- protected detach(_context: IdetikContext): void;
402
- get objects(): RenderableObject[];
403
- get state(): LayerState;
404
- addStateChangeCallback(callback: StateChangeCallback): void;
405
- removeStateChangeCallback(callback: StateChangeCallback): void;
406
- hasMultipleLODs(): boolean;
407
- protected setState(newState: LayerState): void;
408
- protected addObject(object: RenderableObject): void;
409
- protected removeObject(object: RenderableObject): void;
410
- protected clearObjects(): void;
411
- /**
412
- * Get uniforms for shader program. Override in derived classes that need custom uniforms.
413
- * @returns Object containing uniform name-value pairs
414
- */
415
- getUniforms(): Record<string, unknown>;
416
- }
417
-
418
440
  declare class OrthographicCamera extends Camera {
419
441
  private width_;
420
442
  private height_;
@@ -476,73 +498,56 @@ declare class Viewport {
476
498
  removeAllLayers(): void;
477
499
  updateSize(): void;
478
500
  getBoxRelativeTo(canvas: HTMLCanvasElement): Box2;
501
+ getBufferRect(): {
502
+ x: number;
503
+ y: number;
504
+ width: number;
505
+ height: number;
506
+ };
479
507
  clientToClip(position: vec2, depth?: number): vec3;
480
508
  clientToWorld(position: vec2, depth?: number): vec3;
481
509
  private getBox;
482
510
  private updateAspectRatio;
483
511
  }
484
512
 
485
- declare class ChunkStoreView {
486
- private readonly store_;
487
- private policy_;
488
- private policyChanged_;
489
- private currentLOD_;
490
- private lastViewBounds2D_;
491
- private lastViewProjection_;
492
- private lastZBounds_?;
493
- private lastTCoord_?;
494
- private lastCCoords_?;
495
- private sourceMaxSquareDistance2D_;
496
- private readonly chunkViewStates_;
497
- private isDisposed_;
498
- constructor(store: ChunkStore, policy: ImageSourcePolicy);
499
- get chunkViewStates(): ReadonlyMap<Chunk, ChunkViewState>;
500
- get isDisposed(): boolean;
501
- get lodCount(): number;
502
- get channelCount(): number;
503
- getChunksToRender(): Chunk[];
504
- updateChunksForImage(sliceCoords: SliceCoordinates, viewport: Viewport): void;
505
- updateChunksForVolume(sliceCoords: SliceCoordinates, viewport: Viewport): void;
506
- allVisibleFallbackLODLoaded(): boolean;
507
- get currentLOD(): number;
508
- maybeForgetChunk(chunk: Chunk): void;
509
- dispose(): void;
510
- setImageSourcePolicy(newPolicy: ImageSourcePolicy, key: symbol): void;
511
- private setLOD;
512
- private markTimeChunksForPrefetchImage;
513
- private markTimeChunksForPrefetchVolume;
514
- private computePriority;
515
- private channelsOfInterest;
516
- private chunkIndexRange;
517
- private iterateChunksInBox;
518
- private iterateAllChunksAtLod;
519
- private getChunkAabb;
520
- private fallbackLOD;
521
- private timeIndex;
522
- private getZBounds;
523
- private viewBounds2DChanged;
524
- private hasViewProjectionChanged;
525
- private zBoundsChanged;
526
- private cCoordsChanged;
527
- private getPaddedBounds;
528
- private squareDistance2D;
513
+ type LayerState = "initialized" | "loading" | "ready";
514
+ type BlendMode = "none" | "normal" | "additive" | "subtractive" | "multiply" | "premultiplied";
515
+ type StateChangeCallback = (newState: LayerState, prevState?: LayerState) => void;
516
+ interface LayerOptions {
517
+ opacity?: number;
518
+ blendMode?: BlendMode;
529
519
  }
530
-
531
- type QueueStats = {
532
- pending: number;
533
- running: number;
534
- };
535
-
536
- declare class ChunkManager {
537
- private readonly stores_;
538
- private readonly queue_;
539
- get queueStats(): QueueStats;
540
- get memoryStats(): {
541
- cpuChunkBytes: number;
542
- cpuChunkCount: number;
543
- };
544
- addView(source: ChunkSource, policy: ImageSourcePolicy): ChunkStoreView;
545
- update(): void;
520
+ declare abstract class Layer {
521
+ abstract readonly type: string;
522
+ private objects_;
523
+ private state_;
524
+ private attached_;
525
+ private readonly callbacks_;
526
+ private opacity_;
527
+ blendMode: BlendMode;
528
+ constructor({ opacity, blendMode }?: LayerOptions);
529
+ get opacity(): number;
530
+ set opacity(value: number);
531
+ abstract update(viewport?: Viewport): void;
532
+ onEvent(_: EventContext): void;
533
+ onAttached(context: IdetikContext): void;
534
+ onDetached(context: IdetikContext): void;
535
+ protected attach(_context: IdetikContext): void;
536
+ protected detach(_context: IdetikContext): void;
537
+ get objects(): RenderableObject[];
538
+ get state(): LayerState;
539
+ addStateChangeCallback(callback: StateChangeCallback): void;
540
+ removeStateChangeCallback(callback: StateChangeCallback): void;
541
+ hasMultipleLODs(): boolean;
542
+ protected setState(newState: LayerState): void;
543
+ protected addObject(object: RenderableObject): void;
544
+ protected removeObject(object: RenderableObject): void;
545
+ protected clearObjects(): void;
546
+ /**
547
+ * Get uniforms for shader program. Override in derived classes that need custom uniforms.
548
+ * @returns Object containing uniform name-value pairs
549
+ */
550
+ getUniforms(): Record<string, unknown>;
546
551
  }
547
552
 
548
553
  declare abstract class Renderer {
@@ -1295,7 +1300,7 @@ declare class OmeZarrImageSource {
1295
1300
  private static openLoader;
1296
1301
  getDimensions(): SourceDimensionMap;
1297
1302
  getChannelCount(): number;
1298
- getLoader(): OmeZarrImageLoader;
1303
+ get loader(): OmeZarrImageLoader;
1299
1304
  /**
1300
1305
  * Creates and opens an OmeZarrImageSource from an HTTP(S) URL.
1301
1306
  *
@@ -1372,7 +1377,7 @@ declare class ImageLayer extends Layer implements ChannelsEnabled {
1372
1377
  constructor({ source, sliceCoords, policy, channelProps, onPickValue, ...layerOptions }: ImageLayerProps);
1373
1378
  protected attach(context: IdetikContext): void;
1374
1379
  protected detach(_context: IdetikContext): void;
1375
- update(context?: RenderContext): void;
1380
+ update(viewport?: Viewport): void;
1376
1381
  private updateChunks;
1377
1382
  hasMultipleLODs(): boolean;
1378
1383
  get lastPresentationTimeCoord(): number | undefined;
@@ -1442,7 +1447,7 @@ declare class VolumeLayer extends Layer implements ChannelsEnabled {
1442
1447
  private updateChunks;
1443
1448
  private updateVolumeTransform;
1444
1449
  private releaseAndRemoveVolume;
1445
- update(context?: RenderContext): void;
1450
+ update(viewport?: Viewport): void;
1446
1451
  getUniforms(): Record<string, unknown>;
1447
1452
  }
1448
1453
 
@@ -1483,7 +1488,7 @@ declare class LabelLayer extends Layer {
1483
1488
  constructor({ source, sliceCoords, policy, colorMap, onPickValue, outlineSelected, ...layerOptions }: LabelLayerProps);
1484
1489
  protected attach(context: IdetikContext): void;
1485
1490
  protected detach(_context: IdetikContext): void;
1486
- update(context?: RenderContext): void;
1491
+ update(viewport?: Viewport): void;
1487
1492
  private updateChunks;
1488
1493
  private isPresentationStale;
1489
1494
  onEvent(event: EventContext): void;