Skip to content

Fix members globe drag and rotate-to-country - #74

Merged
ronaldtse merged 12 commits into
mainfrom
globe-drag-fix
Nov 20, 2026
Merged

ronaldtse merged 12 commits into
mainfrom
globe-drag-fix

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

Fixes the two interaction bugs in the members globe (found by headless simulation against the real projection + world data):

  1. Drag was broken — the drag code used the wrong versor API (passed screen pixels into versor.fromAngles and angles into versor.delta, which takes sphere cartesians). Now implements the canonical versor-dragging algorithm: projection.invert(pointer) → versor.cartesian → versor.multiply(versor.delta(v0, v1), q0) → versor.rotation, with incremental state updates (1:1 sphere tracking + inertia).
  2. Rotate-to-country threw — called nonexistent versor.interpolateAngles; the actual API is versor.interpolate (quaternion slerp over angles). Rotate-to-country now slerps (great-circle ease, 850ms).

Plus smoother motion: auto-rotation eases in over 1.2s after the idle period instead of starting instantly; inertia decay slightly softer.

Verified in Node: simulated 10-step drag rotates 20°→43.6° with finite angles and re-rendered paths; slerp midpoint and endpoint land exactly on the target rotation.

Test plan

  • Headless drag simulation: finite, responsive, renders changed paths
  • Slerp: midpoint between start/target, exact endpoint
  • Build green (verify-dist invariants); preview serves new bundle + world data 200
  • Human: drag feel, auto-rotation, legend rotate on the preview

@ronaldtse

Copy link
Copy Markdown
Contributor Author

Added: rAF-coalesced rendering (jitter fix), hover pauses auto-rotation, grab/grabbing cursors, low-pass inertia, Hong Kong membership (Ronald Tse) with HK+CN polygon highlight (HK has no Natural Earth 110m polygon — the CN feature carries the Hong Kong interaction). Awaiting manual UX sign-off before merge.

@ronaldtse

Copy link
Copy Markdown
Contributor Author

Full drag redo: replaced all hand-mapped frame math with the canonical versor-dragging algorithm (projection.invert → versor.cartesian → multiply(versor.delta(v0,v1), q0), incremental, no clamps). Headless simulation: world point now tracks the cursor on all gestures — right 8px / left 4px / down 6px / rim 14px / diagonal-300px 9px residual (previously perpendicular or zero movement). rAF-coalesced rendering retained for smoothness. Awaiting manual drag test.

@ronaldtse

Copy link
Copy Markdown
Contributor Author

ROOT CAUSE FOUND AND FIXED. Your console error (ReferenceError: Can't find variable: feature) was the real answer: the client <script> block called feature(topology, …) but never imported it — the import at the file top belongs to the Astro frontmatter module, a separate module from the script block. The unhandled rejection killed the world-data fetch callback, so loaded never became true and the entire interactive layer (drag rendering, auto-rotation, rotate-to-country) has been dead in every deployed version. All prior symptom-chasing (frame math, pointer capture) was secondary to this. The bundle now contains the topojson implementation and calls a defined symbol. Test: http://localhost:4322/members

@ronaldtse
ronaldtse merged commit 2b99cc7 into main Nov 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant