@idetik/core 0.4.3 → 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
@@ -2770,7 +2770,6 @@ class IC {
2770
2770
  }
2771
2771
  }
2772
2772
  class Do {
2773
- lastAnimationId_;
2774
2773
  chunkManager_;
2775
2774
  context_;
2776
2775
  renderer_;
@@ -2779,6 +2778,9 @@ class Do {
2779
2778
  overlays;
2780
2779
  stats_;
2781
2780
  sizeObserver_;
2781
+ lastAnimationId_;
2782
+ // this value will be set after start
2783
+ lastTimestamp_ = 0;
2782
2784
  /**
2783
2785
  * Creates a new Idetik visualization runtime instance.
2784
2786
  *
@@ -2868,20 +2870,24 @@ class Do {
2868
2870
  if (U.info("Idetik", "Idetik runtime starting"), this.lastAnimationId_ === void 0) {
2869
2871
  for (const A of this.viewports_)
2870
2872
  A.events.connect();
2871
- this.sizeObserver_.connect(), this.animate();
2873
+ this.sizeObserver_.connect(), this.lastAnimationId_ = requestAnimationFrame((A) => {
2874
+ this.lastTimestamp_ = A, this.animate(A);
2875
+ });
2872
2876
  } else
2873
2877
  U.warn("Idetik", "Idetik runtime already started");
2874
2878
  return this;
2875
2879
  }
2876
2880
  animate(A) {
2877
2881
  this.stats_ && this.stats_.begin();
2878
- for (const I of this.viewports_)
2879
- 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);
2880
2886
  this.chunkManager_.update();
2881
- for (const I of this.overlays)
2882
- I.update(this, A);
2887
+ for (const B of this.overlays)
2888
+ B.update(this);
2883
2889
  this.stats_ && this.stats_.end(), this.lastAnimationId_ = requestAnimationFrame(
2884
- (I) => this.animate(I)
2890
+ (B) => this.animate(B)
2885
2891
  );
2886
2892
  }
2887
2893
  stop() {
@@ -3272,6 +3278,8 @@ class yo {
3272
3278
  break;
3273
3279
  }
3274
3280
  }
3281
+ onUpdate(A) {
3282
+ }
3275
3283
  onWheel(A) {
3276
3284
  if (!A.worldPos || !A.clipPos) return;
3277
3285
  const I = A.event;