Fix state persistence, drag tracking, and shader rotation sync

State persistence:
- Use rememberUpdatedState to always get latest params inside pointerInput
- Capture gestureStartParams at beginning of each gesture
- All adjustments now use initial values + accumulated change

Drag tracking:
- Track initialDragCentroid at drag start
- Calculate total drag offset from initial point (not frame-by-frame)
- Drag now properly moves focus center 1:1

Shader rotation sync:
- Adjust angle by -90° in shader to compensate for portrait texture rotation
- Preview blur effect now rotates in sync with overlay UI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2026-01-28 16:10:18 +01:00
commit e8a5fa4811
2 changed files with 36 additions and 35 deletions

View file

@ -24,8 +24,10 @@ float focusDistance(vec2 uv) {
vec2 center = vec2(uPositionX, uPositionY);
vec2 offset = uv - center;
float cosA = cos(uAngle);
float sinA = sin(uAngle);
// Adjust angle by -90 degrees to compensate for portrait texture rotation
float adjustedAngle = uAngle - 1.5707963;
float cosA = cos(adjustedAngle);
float sinA = sin(adjustedAngle);
// After rotation, measure perpendicular distance from center line
float rotatedY = -offset.x * sinA + offset.y * cosA;
@ -70,8 +72,8 @@ vec4 sampleBlurred(vec2 uv, float blur) {
vec4 color = vec4(0.0);
vec2 texelSize = 1.0 / uResolution;
// Blur direction perpendicular to focus line
float blurAngle = uAngle + 1.5707963; // +90 degrees
// Blur direction perpendicular to focus line (adjusted for portrait texture rotation)
float blurAngle = uAngle; // Already perpendicular after -90 adjustment in focusDistance
vec2 blurDir = vec2(cos(blurAngle), sin(blurAngle));
// Scale blur radius by blur amount