feat: bidirectional-sync - #46
Open
ericgozzi wants to merge 3 commits into
Open
Conversation
… edit Lets the frontend edit the scene and have it mirrored to the backend's live COMPAS objects instead of only receiving updates: - object_transform: gizmo drag/rotate on a picked object mutates the same live backend geometry in place via Transformation.from_matrix + .transform(), so anything else still mutating it (e.g. an App.loop callback) continues from the new position instead of snapping back. - create_geometry: toolbar "Add" action constructs a real Box/Sphere/Point on the backend and broadcasts it through the existing add_geometry pipeline. - material_edit: toolbar color/metalness/roughness controls mutate the live Material instance via the existing update_material path, so they can't drift out of sync with script-authored material changes. Requires the paired compas_threejs_ts frontend changes (synced build included in src/compas_threejs/viewer/frontend/). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Explains the object_transform/create_geometry/material_edit handlers, the delta-vs-absolute matrix gotcha, and the App.loop concurrency caveat, for a future agent to pick up without re-deriving it. Pairs with the equivalent doc in the compas_threejs_ts frontend repo. Co-Authored-By: Claude Sonnet 5 <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.
This pull request introduces bidirectional synchronization between the frontend and backend for live COMPAS objects, allowing frontend actions (like dragging, creating geometry, and editing materials) to directly mutate the backend's live Python objects. This ensures that both the frontend and backend remain in sync, and that scripts running on the backend see real-time updates from the UI. The implementation is documented and includes changes to initialization and handler wiring.
Bidirectional synchronization and handler wiring:
src/compas_threejs/viewer/BIDIRECTIONAL_SYNC.mdfor details.BIDIRECTIONAL_SYNC.md) describing the new sync model, message types (object_transform,create_geometry,material_edit), handler logic, concurrency caveats, and extension points.Appinitialization soInboxreceives a reference to the parentAppinstance, enabling handlers to access workspace methods for updating geometry and materials.