@eyepop.ai/eyepop-render-2d 3.21.0 → 3.23.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.
@@ -463,7 +463,17 @@ var _Renderer2d = class _Renderer2d {
463
463
  this.rules[i].start(this.context, this.style);
464
464
  }
465
465
  }
466
+ /**
467
+ * Draw a prediction over the frame it was made on.
468
+ *
469
+ * A selected prediction (`p.selected`) is skipped: it belongs to a past
470
+ * frame, so drawn over the current one its boxes land where the object no
471
+ * longer is, and its past timestamp would rewind the trails.
472
+ */
466
473
  draw(p, color) {
474
+ if (p.selected) {
475
+ return;
476
+ }
467
477
  const x_scale = this.context.canvas.width / p.source_width;
468
478
  const y_scale = this.context.canvas.height / p.source_height;
469
479
  const streamTime = p;
@@ -3638,6 +3648,10 @@ var RenderTrail = class {
3638
3648
  if (!context || !style) {
3639
3649
  throw new Error("render() called before start()");
3640
3650
  }
3651
+ const previous = this.traces.get(element.trackId);
3652
+ if (previous !== void 0 && streamTime.timestamp < previous.timestamp) {
3653
+ return;
3654
+ }
3641
3655
  const points = [];
3642
3656
  if (this.traceDetails) {
3643
3657
  const targets = jp2.query(element, this.traceDetails);
@@ -3668,7 +3682,7 @@ var RenderTrail = class {
3668
3682
  const head = {
3669
3683
  points,
3670
3684
  timestamp: streamTime.timestamp,
3671
- next: this.traces.get(element.trackId) ?? null
3685
+ next: previous ?? null
3672
3686
  };
3673
3687
  this.traces.set(element.trackId, head);
3674
3688
  const radius = element.width * xScale / 40;
@@ -3684,6 +3698,7 @@ var RenderTrail = class {
3684
3698
  }
3685
3699
  }
3686
3700
  if (streamTime.timestamp - this.lastTrim > TRIM_INTERVAL) {
3701
+ this.lastTrim = streamTime.timestamp;
3687
3702
  this.traces.forEach((traceEntry, trackId) => {
3688
3703
  const age = streamTime.timestamp - traceEntry.timestamp;
3689
3704
  if (age > this.trailLengthNanos) {