Skip to content

Refactor video coordinate system to use video-local coordinates - #51

Merged
veillette merged 2 commits into
mainfrom
claude/refactor-video-transformation-8kXWJ
Feb 26, 2026
Merged

Refactor video coordinate system to use video-local coordinates#51
veillette merged 2 commits into
mainfrom
claude/refactor-video-transformation-8kXWJ

Conversation

@veillette

Copy link
Copy Markdown
Collaborator

Summary

This PR refactors the coordinate system used throughout the application to use video-local coordinates (where (0,0) is the top-left of the video element) instead of screen/view coordinates. This enables all overlay tools and the video to be transformed together as a unified unit via a new videoTransformProperty.

Key Changes

  • Coordinate System Refactoring: Removed dependency on VIDEO_CENTER_X and VIDEO_CENTER_Y screen-space constants. All tool positions (coordinate origin, calibration, measuring tape, angle tool) now use video-local coordinates relative to the video dimensions.

  • Video Transform Properties: Added videoScaleProperty and videoOffsetProperty to SimModel, with a derived videoTransformProperty that combines them into a Matrix3 transformation. This allows the entire video and all overlays to be scaled and translated together.

  • Video Content Layer: Introduced videoContentLayer in VideoPlayerNode as a dedicated container for the video element and all overlay nodes. This layer has explicit bounds to prevent overlay children from inflating the layout, and the videoTransformProperty is applied to this layer.

  • Overlay Node Reparenting: Moved all overlay tool nodes (coordinate system, calibration, measuring tape, angle tool) from SimScreenView to be children of videoContentLayer, ensuring they share the same video-local coordinate space and transform with the video.

  • Layout Simplification: Replaced the VBox layout in VideoPlayerNode with manual positioning to prevent overlay nodes from affecting the centering of the source control row.

  • Bounds Management: Updated videoContentLayer bounds to stay in sync with video dimensions, preventing layout shifts when video size changes.

  • AutoTrackerNode Fix: Simplified coordinate conversion in AutoTrackerNode to directly use video-local pixel coordinates instead of converting through global/scene coordinates, since the model's pixelToModelCoords now operates in video-local space.

Notable Implementation Details

  • Video-local coordinate helpers (VIDEO_LOCAL_CENTER_X, VIDEO_LOCAL_CENTER_Y) replace the screen-space constants, making the coordinate system more intuitive and maintainable.
  • Bounds for clamping the coordinate-system origin are now simply (0, 0) to (VIDEO_WIDTH, VIDEO_HEIGHT) in video-local space.
  • The videoTransformProperty is properly linked/unlinked in the dispose method to prevent memory leaks.

https://claude.ai/code/session_01TMMU2E3kbrbWwzaacMRrLB

claude and others added 2 commits February 25, 2026 17:06
All overlay tools (coordinate system, calibration, measuring tape, angle
tool) now share the same video-local coordinate space as the video element
and are children of a single videoContentLayer node. This enables applying
a uniform transform (translate + scale) to the entire video + overlays.

Key changes:
- Convert all tool positions from layout-absolute to video-local coords
- Expose videoContentLayer in VideoPlayerNode; replace VBox with manual layout
- Reparent 4 overlay nodes from SimScreenView to videoContentLayer
- Fix AutoTrackerNode: remove localToGlobalPoint (MVT now operates in video-local space)
- Add videoScaleProperty, videoOffsetProperty, derived videoTransformProperty
- Remove unused VIDEO_CENTER_X/Y layout constants

https://claude.ai/code/session_01TMMU2E3kbrbWwzaacMRrLB
Resolve comment-only conflict in AutoTrackerNode.ts; keep branch
wording that references the MVT operating in video-local space.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@veillette
veillette merged commit 7cf6bb9 into main Feb 26, 2026
1 check passed
@veillette
veillette deleted the claude/refactor-video-transformation-8kXWJ branch February 26, 2026 13:24
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.

2 participants