Refactor video coordinate system to use video-local coordinates - #51
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_XandVIDEO_CENTER_Yscreen-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
videoScalePropertyandvideoOffsetPropertytoSimModel, with a derivedvideoTransformPropertythat combines them into aMatrix3transformation. This allows the entire video and all overlays to be scaled and translated together.Video Content Layer: Introduced
videoContentLayerinVideoPlayerNodeas 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 thevideoTransformPropertyis applied to this layer.Overlay Node Reparenting: Moved all overlay tool nodes (coordinate system, calibration, measuring tape, angle tool) from
SimScreenViewto be children ofvideoContentLayer, ensuring they share the same video-local coordinate space and transform with the video.Layout Simplification: Replaced the
VBoxlayout inVideoPlayerNodewith manual positioning to prevent overlay nodes from affecting the centering of the source control row.Bounds Management: Updated
videoContentLayerbounds to stay in sync with video dimensions, preventing layout shifts when video size changes.AutoTrackerNode Fix: Simplified coordinate conversion in
AutoTrackerNodeto directly use video-local pixel coordinates instead of converting through global/scene coordinates, since the model'spixelToModelCoordsnow operates in video-local space.Notable Implementation Details
VIDEO_LOCAL_CENTER_X,VIDEO_LOCAL_CENTER_Y) replace the screen-space constants, making the coordinate system more intuitive and maintainable.(0, 0)to(VIDEO_WIDTH, VIDEO_HEIGHT)in video-local space.videoTransformPropertyis properly linked/unlinked in the dispose method to prevent memory leaks.https://claude.ai/code/session_01TMMU2E3kbrbWwzaacMRrLB