@idetik/core 0.4.2 → 0.5.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/dist/index.d.ts CHANGED
@@ -475,6 +475,7 @@ declare class OrthographicCamera extends Camera {
475
475
  }
476
476
 
477
477
  interface CameraControls {
478
+ onUpdate(dt: number): void;
478
479
  onEvent(event: EventContext): void;
479
480
  }
480
481
  declare class PanZoomControls implements CameraControls {
@@ -483,6 +484,7 @@ declare class PanZoomControls implements CameraControls {
483
484
  private dragStart_;
484
485
  constructor(camera: OrthographicCamera);
485
486
  onEvent(event: EventContext): void;
487
+ onUpdate(_delta: number): void;
486
488
  private onWheel;
487
489
  private onPointerDown;
488
490
  private onPointerMove;
@@ -564,7 +566,7 @@ declare class ChunkManager {
564
566
  }
565
567
 
566
568
  type Overlay = {
567
- update(idetik: Idetik, timestamp?: DOMHighResTimeStamp): void;
569
+ update(idetik: Idetik): void;
568
570
  };
569
571
  type IdetikParams = {
570
572
  canvas: HTMLCanvasElement;
@@ -576,7 +578,6 @@ type IdetikContext = {
576
578
  chunkManager: ChunkManager;
577
579
  };
578
580
  declare class Idetik {
579
- private lastAnimationId_?;
580
581
  private readonly chunkManager_;
581
582
  private readonly context_;
582
583
  private readonly renderer_;
@@ -585,6 +586,8 @@ declare class Idetik {
585
586
  readonly overlays: Overlay[];
586
587
  private readonly stats_?;
587
588
  private readonly sizeObserver_;
589
+ private lastAnimationId_?;
590
+ private lastTimestamp_;
588
591
  /**
589
592
  * Creates a new Idetik visualization runtime instance.
590
593
  *
package/dist/index.js CHANGED
@@ -2350,10 +2350,16 @@ class PQ {
2350
2350
  A.state = "unloaded";
2351
2351
  return;
2352
2352
  }
2353
- A.state === "loaded" && !A.visible && !A.prefetch && (A.data = void 0, A.state = "unloaded", A.priority = null, A.orderKey = null, A.prefetch = !1, U.debug(
2354
- "ChunkStore",
2355
- `Disposing chunk ${JSON.stringify(A.chunkIndex)} in LOD ${A.lod}`
2356
- ));
2353
+ if (A.state === "loaded" && A.priority === null) {
2354
+ if (A.visible || A.prefetch)
2355
+ throw new Error(
2356
+ `Chunk state inconsistency detected: priority is null but visible=${A.visible} or prefetch=${A.prefetch} for chunk ${JSON.stringify(A.chunkIndex)} in LOD ${A.lod}`
2357
+ );
2358
+ A.data = void 0, A.state = "unloaded", A.orderKey = null, U.debug(
2359
+ "ChunkStore",
2360
+ `Disposing chunk ${JSON.stringify(A.chunkIndex)} in LOD ${A.lod}`
2361
+ );
2362
+ }
2357
2363
  }
2358
2364
  validateXYScaleRatios() {
2359
2365
  const A = this.dimensions_.x, I = this.dimensions_.y;
@@ -2764,7 +2770,6 @@ class IC {
2764
2770
  }
2765
2771
  }
2766
2772
  class Do {
2767
- lastAnimationId_;
2768
2773
  chunkManager_;
2769
2774
  context_;
2770
2775
  renderer_;
@@ -2773,6 +2778,9 @@ class Do {
2773
2778
  overlays;
2774
2779
  stats_;
2775
2780
  sizeObserver_;
2781
+ lastAnimationId_;
2782
+ // this value will be set after start
2783
+ lastTimestamp_ = 0;
2776
2784
  /**
2777
2785
  * Creates a new Idetik visualization runtime instance.
2778
2786
  *
@@ -2862,20 +2870,24 @@ class Do {
2862
2870
  if (U.info("Idetik", "Idetik runtime starting"), this.lastAnimationId_ === void 0) {
2863
2871
  for (const A of this.viewports_)
2864
2872
  A.events.connect();
2865
- this.sizeObserver_.connect(), this.animate();
2873
+ this.sizeObserver_.connect(), this.lastAnimationId_ = requestAnimationFrame((A) => {
2874
+ this.lastTimestamp_ = A, this.animate(A);
2875
+ });
2866
2876
  } else
2867
2877
  U.warn("Idetik", "Idetik runtime already started");
2868
2878
  return this;
2869
2879
  }
2870
2880
  animate(A) {
2871
2881
  this.stats_ && this.stats_.begin();
2872
- for (const I of this.viewports_)
2873
- this.renderer_.render(I);
2882
+ const I = Math.min(A - this.lastTimestamp_, 100) / 1e3;
2883
+ this.lastTimestamp_ = A;
2884
+ for (const B of this.viewports_)
2885
+ B.cameraControls?.onUpdate(I), this.renderer_.render(B);
2874
2886
  this.chunkManager_.update();
2875
- for (const I of this.overlays)
2876
- I.update(this, A);
2887
+ for (const B of this.overlays)
2888
+ B.update(this);
2877
2889
  this.stats_ && this.stats_.end(), this.lastAnimationId_ = requestAnimationFrame(
2878
- (I) => this.animate(I)
2890
+ (B) => this.animate(B)
2879
2891
  );
2880
2892
  }
2881
2893
  stop() {
@@ -3266,6 +3278,8 @@ class yo {
3266
3278
  break;
3267
3279
  }
3268
3280
  }
3281
+ onUpdate(A) {
3282
+ }
3269
3283
  onWheel(A) {
3270
3284
  if (!A.worldPos || !A.clipPos) return;
3271
3285
  const I = A.event;