Skip to content

feat: bidirectional-sync - #46

Open
ericgozzi wants to merge 3 commits into
mainfrom
feature/bidirectional-sync
Open

feat: bidirectional-sync#46
ericgozzi wants to merge 3 commits into
mainfrom
feature/bidirectional-sync

Conversation

@ericgozzi

Copy link
Copy Markdown
Collaborator

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:

  • Implemented bidirectional sync so that frontend actions (gizmo drags/rotations, toolbar geometry creation, and material edits) directly mutate the same live backend Python objects seen by running scripts, rather than only updating the frontend. See src/compas_threejs/viewer/BIDIRECTIONAL_SYNC.md for details.
  • Added detailed documentation (BIDIRECTIONAL_SYNC.md) describing the new sync model, message types (object_transform, create_geometry, material_edit), handler logic, concurrency caveats, and extension points.
  • Modified App initialization so Inbox receives a reference to the parent App instance, enabling handlers to access workspace methods for updating geometry and materials.

ericgozzi and others added 3 commits August 17, 2026 10:43
… 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>
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