@fxi/zartigl 0.10.1 → 0.10.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/zartigl.d.ts CHANGED
@@ -252,29 +252,14 @@ east: number,
252
252
  north: number
253
253
  ];
254
254
 
255
- declare type GeoVideoEventMap = {
256
- loading: () => void;
257
- loaded: (meta: FieldMeta) => void;
258
- error: (error: Error) => void;
259
- status: (status: ZartiglStatus) => void;
260
- timeChange: (time: number) => void;
261
- playbackChange: (playing: boolean) => void;
262
- /** Playback reached the end of the timeline without looping. */
263
- playbackEnd: () => void;
264
- };
255
+ declare type GeoVideoEventMap = GeoVideoPlaybackEvents;
265
256
 
266
257
  export declare class GeoVideoLayer implements CustomLayerInterface {
267
258
  readonly id: string;
268
259
  readonly type: "custom";
269
260
  readonly renderingMode: "3d";
270
261
  private readonly source;
271
- /** Start playback once ready: autoplay, or a swap that was playing. */
272
- private playOnReady;
273
- private loop;
274
- private playbackRate;
275
- private requestedTime;
276
- private requestedTimeRange?;
277
- private timeRange;
262
+ private readonly playback;
278
263
  private opacity;
279
264
  private colorRamp;
280
265
  private colorDomain;
@@ -283,78 +268,25 @@ export declare class GeoVideoLayer implements CustomLayerInterface {
283
268
  private map;
284
269
  private gl;
285
270
  private manifest;
286
- private video;
287
- /** Manifest of `video`, which still differs from `manifest` mid-swap. */
288
- private videoManifest;
289
- /** Incoming media of a swap, shown once its first frame is decodable. */
290
- private pendingVideo;
291
- private standby;
292
- /** Ended on a preloaded artifact: playing until it is swapped in or paused. */
293
- private awaitingNext;
294
- private maskUrl;
295
- private colorTexture;
296
- private maskTexture;
297
271
  private colorRampTexture;
298
- private maskCanvas;
299
- private maskContext;
300
272
  private mercatorProgram;
301
273
  private globeProgram;
302
274
  private vertexBuffer;
303
275
  private indexBuffer;
304
276
  private indexCount;
305
- private frameCallback;
306
- private repaintFrame;
307
- private frameDirty;
308
- private maskDirty;
309
- private colorTextureInitialized;
310
- private maskTextureInitialized;
311
- private maskCaptured;
312
- private mediaReady;
313
- private readyEmitted;
314
- private hasVideoFrameCallback;
315
- private lastBufferedMediaTime;
316
- private lastUploadedMediaTime;
317
- private decodedFrames;
318
- private frameCallbackCount;
319
- private frameCallbackTimes;
320
- private lastFrameCallbackAt;
321
- private bufferedFrames;
322
- private skippedFrames;
323
- private uploadedFrames;
324
- private lastUploadDurationMs;
325
277
  private abortController;
326
- private resumePlayback;
327
- private stepTimer;
328
- private endEmitted;
329
278
  private listeners;
330
279
  constructor(options: GeoVideoLayerOptions);
331
280
  onAdd(map: Map_2, context: WebGLRenderingContext | WebGL2RenderingContext): Promise<void>;
332
281
  render(context: WebGLRenderingContext | WebGL2RenderingContext, options: CustomRenderMethodInput): void;
333
282
  onRemove(): void;
334
283
  setTime(time: string | number): void;
335
- /**
336
- * Switch to another artifact of the same frame size, such as the next
337
- * archive chunk, keeping the map layer and GL state. The current frame stays
338
- * on screen until the new media can show its first one, at once when it was
339
- * preloaded. Returns false when the artifact needs a new layer.
340
- */
341
284
  replaceManifest(manifest: GeoVideoManifest, options?: GeoVideoReplaceOptions): boolean;
342
- /**
343
- * Load the artifact expected next, such as the following archive chunk, so
344
- * `replaceManifest` can show it without waiting for the network. Until then,
345
- * reaching the end of the current artifact keeps the playing state and
346
- * emits `playbackEnd` for the caller to swap it in, or to pause. Returns
347
- * false when the artifact cannot replace the current one in place.
348
- */
349
285
  preloadManifest(manifest: GeoVideoManifest, options?: GeoVideoReplaceOptions): boolean;
350
- /** Clamped time range of a compatible replacement, else null. */
351
- private replacementTimeRange;
352
- /** The preloaded artifact when it holds this media; any other is dropped. */
353
- private takeStandby;
354
286
  setTimeAndDepth(time: string | number, _depth: number): void;
355
287
  setDepth(_depth: number): void;
356
- prefetchTime(_ms: number): Promise<void>;
357
- isFrameCached(_ms: number): boolean;
288
+ prefetchTime(ms: number): Promise<void>;
289
+ isFrameCached(ms: number): boolean;
358
290
  cancelPrefetches(): void;
359
291
  suspend(): void;
360
292
  resume(): void;
@@ -366,24 +298,6 @@ export declare class GeoVideoLayer implements CustomLayerInterface {
366
298
  setOpacity(value: number): void;
367
299
  play(): Promise<void>;
368
300
  pause(): void;
369
- /**
370
- * Playback is a request, applied once ready, while the manifest loads,
371
- * mid-swap, or at an end waiting for the preloaded artifact.
372
- */
373
- private deferredPlayback;
374
- private isPlaying;
375
- /**
376
- * Below the slowest media rate browsers accept, keep the video paused and
377
- * seek one sample (or frame) at a time.
378
- */
379
- private startStepping;
380
- private stopStepping;
381
- private step;
382
- /**
383
- * The timeline ended without looping. With a preloaded artifact, keep the
384
- * playing state for the caller to swap it in; otherwise stop.
385
- */
386
- private reachEnd;
387
301
  setLoop(loop: boolean): void;
388
302
  setPlaybackRate(rate: number): void;
389
303
  setTimeRange(range: [number, number]): void;
@@ -392,35 +306,6 @@ export declare class GeoVideoLayer implements CustomLayerInterface {
392
306
  on<K extends keyof GeoVideoEventMap>(event: K, handler: GeoVideoEventMap[K]): this;
393
307
  off<K extends keyof GeoVideoEventMap>(event: K, handler: GeoVideoEventMap[K]): this;
394
308
  private initGl;
395
- private initVideo;
396
- /**
397
- * Media element for a manifest. Its events drive the layer only while it is
398
- * the current video and no swap is pending.
399
- */
400
- private createVideo;
401
- /** Track presented frames of the current video. */
402
- private startFrameCallbacks;
403
- /**
404
- * Time a loading video opens at: its preload target, or the requested time
405
- * within the active range.
406
- */
407
- private startTime;
408
- private checkVideoSize;
409
- private cancelFrameCallback;
410
- /** Stop the current video and free its media resources. */
411
- private releaseVideo;
412
- private discardStandby;
413
- private discardPendingVideo;
414
- private bufferFrame;
415
- private createMaskImage;
416
- /** Show the mask of a manifest once its image, possibly preloaded, loads. */
417
- private applyMask;
418
- private emitReady;
419
- private createVideoTexture;
420
- private uploadTextureSource;
421
- private startRepaintLoop;
422
- private stopRepaintLoop;
423
- private presentedFps;
424
309
  private bindGrid;
425
310
  private unbindGrid;
426
311
  private emit;
@@ -515,6 +400,34 @@ export declare interface GeoVideoOptions {
515
400
  stepsPerSecond?: number;
516
401
  }
517
402
 
403
+ declare type GeoVideoPlaybackEvents = {
404
+ loading: () => void;
405
+ loaded: (meta: FieldMeta) => void;
406
+ error: (error: Error) => void;
407
+ status: (status: ZartiglStatus) => void;
408
+ timeChange: (time: number) => void;
409
+ playbackChange: (playing: boolean) => void;
410
+ /** Playback reached the end of the timeline without looping. */
411
+ playbackEnd: () => void;
412
+ };
413
+
414
+ declare interface GeoVideoPlaybackOptions {
415
+ time?: string | number;
416
+ timeRange?: [number, number];
417
+ autoplay?: boolean;
418
+ loop?: boolean;
419
+ playbackRate?: number;
420
+ stepsPerSecond?: number;
421
+ }
422
+
423
+ declare interface GeoVideoPlaybackReplaceOptions {
424
+ time?: number;
425
+ stepsPerSecond?: number;
426
+ timeRange?: [number, number];
427
+ loop?: boolean;
428
+ playbackRate?: number;
429
+ }
430
+
518
431
  export declare interface GeoVideoRangeTimeline {
519
432
  kind: "range";
520
433
  dateStart: string;
@@ -526,12 +439,7 @@ export declare interface GeoVideoRangeTimeline {
526
439
  * Playback state for an artifact swapped in with `replaceManifest`, or
527
440
  * loaded ahead with `preloadManifest`.
528
441
  */
529
- declare interface GeoVideoReplaceOptions {
530
- time?: number;
531
- timeRange?: [number, number];
532
- loop?: boolean;
533
- playbackRate?: number;
534
- }
442
+ declare type GeoVideoReplaceOptions = GeoVideoPlaybackReplaceOptions;
535
443
 
536
444
  export declare interface GeoVideoSampleSequenceTimeline {
537
445
  kind: "sample-sequence";
@@ -616,7 +524,7 @@ declare type LayerEventMap = {
616
524
  cacheInvalidated: () => void;
617
525
  };
618
526
 
619
- declare type LayerEventMap_2 = {
527
+ declare type LayerEventMap_2 = GeoVideoPlaybackEvents & {
620
528
  loading: () => void;
621
529
  loaded: (meta: FieldMeta) => void;
622
530
  error: (err: Error) => void;
@@ -773,19 +681,19 @@ export declare class ParticleSimulation {
773
681
  south: number;
774
682
  east: number;
775
683
  north: number;
776
- }, isGlobe?: boolean, globeCenter?: [number, number, number], clippingPlane?: [number, number, number, number]): void;
684
+ }, isGlobe?: boolean, globeCenter?: [number, number, number], clippingPlane?: [number, number, number, number], velocityPair?: VelocityTexturePair): void;
777
685
  renderGrid(velocityTexUnit: number, velocityMin: [number, number], velocityMax: [number, number], matrix: Iterable<number>, worldSize: number, worldCopyOffsets: number[], geoBounds: {
778
686
  west: number;
779
687
  south: number;
780
688
  east: number;
781
689
  north: number;
782
- }, opacityScale?: number, solid?: Vec4): void;
690
+ }, opacityScale?: number, solid?: Vec4, velocityPair?: VelocityTexturePair): void;
783
691
  renderGridGlobe(velocityTexUnit: number, velocityMin: [number, number], velocityMax: [number, number], matrix: Iterable<number>, geoBounds: {
784
692
  west: number;
785
693
  south: number;
786
694
  east: number;
787
695
  north: number;
788
- }, clippingPlane: [number, number, number, number], opacityScale?: number, solid?: Vec4): void;
696
+ }, clippingPlane: [number, number, number, number], opacityScale?: number, solid?: Vec4, velocityPair?: VelocityTexturePair): void;
789
697
  private setGridFieldUniforms;
790
698
  private bindRasterGrid;
791
699
  private unbindRasterGrid;
@@ -1199,9 +1107,12 @@ export declare class VectorLayer implements CustomLayerInterface {
1199
1107
  readonly renderingMode: "3d";
1200
1108
  private map;
1201
1109
  private gl;
1110
+ private readonly playback;
1111
+ private readonly geoVideoManifest?;
1202
1112
  private simulation;
1203
1113
  private velocityField;
1204
- private zarrSource;
1114
+ private readonly zarrSourceValue;
1115
+ private get zarrSource();
1205
1116
  private variableU;
1206
1117
  private variableV;
1207
1118
  private vectorDerivation;
@@ -1256,6 +1167,13 @@ export declare class VectorLayer implements CustomLayerInterface {
1256
1167
  suspend(): void;
1257
1168
  resume(): void;
1258
1169
  setDepth(depth: number): void;
1170
+ play(): Promise<void>;
1171
+ pause(): void;
1172
+ setLoop(loop: boolean): void;
1173
+ setStepsPerSecond(value: number): void;
1174
+ setTimeRange(range: [number, number]): void;
1175
+ replaceManifest(manifest: GeoVideoManifest, options?: GeoVideoPlaybackReplaceOptions): boolean;
1176
+ preloadManifest(manifest: GeoVideoManifest, options?: GeoVideoPlaybackReplaceOptions): boolean;
1259
1177
  setSpeed(v: number): void;
1260
1178
  setFade(v: number): void;
1261
1179
  setParticleDensity(density: number): void;
@@ -1287,6 +1205,10 @@ export declare interface VectorLayerDebugInfo {
1287
1205
  }
1288
1206
 
1289
1207
  export declare interface VectorLayerOptions {
1208
+ /** Decoded GeoVideo playback; omitted for the unchanged Zarr field path. */
1209
+ geoVideo?: GeoVideoPlaybackOptions & {
1210
+ manifest: GeoVideoManifest;
1211
+ };
1290
1212
  id: string;
1291
1213
  source: string;
1292
1214
  /** Optional initialized/shared source. When omitted, the layer creates one from `source`. */
@@ -1382,6 +1304,22 @@ export declare class VelocityField {
1382
1304
  destroy(): void;
1383
1305
  }
1384
1306
 
1307
+ /** One bound velocity texture and the physical range used to decode it. */
1308
+ declare interface VelocityTextureField {
1309
+ unit: number;
1310
+ min: [number, number];
1311
+ max: [number, number];
1312
+ /** Physical (u, v, validity, 0); otherwise normalized (u, v, 0, validity). */
1313
+ physical?: boolean;
1314
+ northToSouth?: boolean;
1315
+ }
1316
+
1317
+ declare interface VelocityTexturePair {
1318
+ a: VelocityTextureField;
1319
+ b: VelocityTextureField;
1320
+ mix: number;
1321
+ }
1322
+
1385
1323
  declare interface WebGLRendererInfo {
1386
1324
  vendor: string;
1387
1325
  renderer: string;
@@ -1736,7 +1674,7 @@ export declare class Zartigl {
1736
1674
  /** GeoVideo playback options shared by a new layer and an in-place swap. */
1737
1675
  private geoVideoPlayback;
1738
1676
  /**
1739
- * Show another artifact of the same scalar GeoVideo entry, such as the next
1677
+ * Show another artifact of the same GeoVideo entry, such as the next
1740
1678
  * archive chunk, in the attached layer. The last frame stays on screen until
1741
1679
  * the new media is ready, instead of a blank map while a new layer loads.
1742
1680
  */