react-photo-sphere-viewer icon indicating copy to clipboard operation
react-photo-sphere-viewer copied to clipboard

Stopping at 270 degree angles

Open KKS1 opened this issue 1 month ago • 0 comments

Is there a way that React PhotoSphere Viewer exposes where one can hard stop user to rotate beyond 270 degree angle, just to avoid them seeing the place where fold is happening in panorama images. I tried below, but still user was able to drag on image and go beyond to see full 360.

// Clamp yaw to [-135deg, 135deg] (270deg range)
    const minYaw = (-135 * Math.PI) / 180;
    const maxYaw = (135 * Math.PI) / 180;
    function clampYaw(yaw: number) {
      if (yaw < minYaw) return minYaw;
      if (yaw > maxYaw) return maxYaw;
      return yaw;
    }
    viewerInstance.addEventListener('position-updated', (e) => {
      const { yaw } = e.position;
      if (yaw < minYaw || yaw > maxYaw) {
        viewerInstance.animate({
          yaw: clampYaw(yaw),
          speed: 99999,
        });
      }
    });

KKS1 avatar Oct 20 '25 22:10 KKS1