mishig HF Staff commited on
Commit
7b3e34c
·
verified ·
1 Parent(s): 3376268

Sync from huggingface/lerobot-dataset-visualizer via hub-sync

Browse files
Files changed (1) hide show
  1. src/components/replay-viewer.tsx +27 -4
src/components/replay-viewer.tsx CHANGED
@@ -549,6 +549,8 @@ function RobotScene({
549
  vertexColors: true,
550
  transparent: true,
551
  worldUnits: false,
 
 
552
  });
553
  mat.resolution.set(window.innerWidth, window.innerHeight);
554
  mats.push(mat);
@@ -636,6 +638,9 @@ function RobotScene({
636
  }, [robot, usdUrl, scale, scene, onJointsLoaded, ensureTrails, invalidate]);
637
 
638
  const tipWorldPos = useMemo(() => new THREE.Vector3(), []);
 
 
 
639
  const baseQuat = useMemo(() => new THREE.Quaternion(), []);
640
 
641
  useFrame((state) => {
@@ -707,11 +712,29 @@ function RobotScene({
707
  trail.positions[idx * 3 + 2] = tipWorldPos.z;
708
  trail.times.push(now);
709
 
 
 
 
 
 
 
 
 
 
 
 
 
710
  for (let i = 0; i < trail.count; i++) {
711
- const t = Math.max(0, 1 - (now - trail.times[i]) / TRAIL_DURATION);
712
- trail.colors[i * 3] = trailColor.r * t;
713
- trail.colors[i * 3 + 1] = trailColor.g * t;
714
- trail.colors[i * 3 + 2] = trailColor.b * t;
 
 
 
 
 
 
715
  }
716
 
717
  if (trail.count < 2) {
 
549
  vertexColors: true,
550
  transparent: true,
551
  worldUnits: false,
552
+ // Like the background, so a faded point matches it.
553
+ toneMapped: false,
554
  });
555
  mat.resolution.set(window.innerWidth, window.innerHeight);
556
  mats.push(mat);
 
638
  }, [robot, usdUrl, scale, scene, onJointsLoaded, ensureTrails, invalidate]);
639
 
640
  const tipWorldPos = useMemo(() => new THREE.Vector3(), []);
641
+ const fadeFrom = useMemo(() => new THREE.Color(), []);
642
+ const fadeTo = useMemo(() => new THREE.Color(), []);
643
+ const fadedColor = useMemo(() => new THREE.Color(), []);
644
  const baseQuat = useMemo(() => new THREE.Quaternion(), []);
645
 
646
  useFrame((state) => {
 
712
  trail.positions[idx * 3 + 2] = tipWorldPos.z;
713
  trail.times.push(now);
714
 
715
+ /// Line2 has no per-vertex alpha: points fade into the background color, mixed in sRGB as
716
+ /// alpha blending would, and are dropped once faded, so no dark tail is left behind the tip.
717
+ const expired = trail.times.findIndex((t) => now - t < TRAIL_DURATION);
718
+ if (expired > 0) {
719
+ trail.positions.copyWithin(0, expired * 3, trail.count * 3);
720
+ trail.times.splice(0, expired);
721
+ trail.count -= expired;
722
+ }
723
+ fadeFrom
724
+ .copy(state.scene.background as THREE.Color)
725
+ .convertLinearToSRGB();
726
+ fadeTo.copy(trailColor).convertLinearToSRGB();
727
  for (let i = 0; i < trail.count; i++) {
728
+ fadedColor
729
+ .lerpColors(
730
+ fadeFrom,
731
+ fadeTo,
732
+ 1 - (now - trail.times[i]) / TRAIL_DURATION,
733
+ )
734
+ .convertSRGBToLinear();
735
+ trail.colors[i * 3] = fadedColor.r;
736
+ trail.colors[i * 3 + 1] = fadedColor.g;
737
+ trail.colors[i * 3 + 2] = fadedColor.b;
738
  }
739
 
740
  if (trail.count < 2) {