Skip to content

feat: bidirectional-sync - #18

Merged
ericgozzi merged 4 commits into
mainfrom
feature/bidirectional-sync
Sep 7, 2026
Merged

feat: bidirectional-sync#18
ericgozzi merged 4 commits into
mainfrom
feature/bidirectional-sync

Conversation

@ericgozzi

@ericgozzi ericgozzi commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces a new "Objects" toolbar group in the UI, enabling users to add new geometry (box, sphere, point) and edit object materials (color, metalness, roughness) directly from the frontend. These actions now send messages to the backend to mutate live Python objects, making the viewer bidirectional for object creation and material editing. The implementation includes new UI components, supporting methods in ViewerRuntime, and documentation.

UI Enhancements:

  • Added AddObjectGroup to the main toolbar, grouping the new AddObjectButton and MaterialButton for object creation and material editing. (Toolbar.vue, AddObjectGroup.vue, index.ts) [1] [2] [3]
  • Implemented AddObjectButton.vue: a popover UI to select geometry type and parameters, calling createGeometry() on add. (AddObjectButton.vue)
  • Implemented MaterialButton.vue: a popover UI for editing the selected object's color, metalness, and roughness, disabled unless an object is picked. (MaterialButton.vue)

Bidirectional Backend Communication:

  • Added createGeometry(type, params) to ViewerRuntime, sending a create_geometry message to the backend to create new objects at the camera's target. (viewer_runtime.ts)
  • Added getMaterialSnapshot(guid) and setMaterial(guid, fields) to read and update material properties both locally and on the backend via material_edit messages. (viewer_runtime.ts)
  • Improved transform gizmo interaction: captures drag start matrix and sends a delta transform to the backend on drag end, ensuring correct placement and avoiding animation conflicts. (viewer_runtime.ts) [1] [2]

Documentation:

  • Added a comprehensive BIDIRECTIONAL_SYNC.md explaining the new bidirectional sync architecture, message formats, and UI integration. (BIDIRECTIONAL_SYNC.md)

Checklist

  • npm run check is green (formatting, lint, types, unit tests, both builds).
  • npm run test:browser and npm run test:package pass.

@ericgozzi
ericgozzi marked this pull request as ready for review August 19, 2026 13:08
@ericgozzi
ericgozzi requested a review from gonzalocasas August 19, 2026 13:08

@gonzalocasas gonzalocasas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

ericgozzi and others added 4 commits September 7, 2026 10:34
… edit

Mirrors frontend edits back to the backend's live COMPAS objects instead of
only receiving updates from it:

- Transform gizmo drag/rotate on a picked object now sends the world-space
  delta to the backend on release (dispatch: object_transform), computed
  against the object's matrix as of drag-start so it's correct regardless of
  whether the frontend's placement convention for that object is identity or
  absolute. Also guards against a continuously self-animating object (e.g. a
  spinning torus) rebuilding the mesh out from under an active drag.
- New "Add object" toolbar control (AddObjectButton.vue) sends
  create_geometry for Box/Sphere/Point, spawned at the camera's current orbit
  target.
- New "Material" toolbar control (MaterialButton.vue) streams color/
  metalness/roughness edits (material_edit) for the picked object, with
  local instant preview.
- New reactive store field pickedObjectGuid, since nothing previously exposed
  the current pick selection to Vue components.

Requires the paired compas_threejs backend changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Explains the transform-gizmo delta math, the two bugs found and fixed while
building it (wrong matrix convention, a spinning object fighting its own
drag), the new create_geometry/material_edit UI, and the new pickedObjectGuid
store field, for a future agent to pick up without re-deriving it. Pairs with
the equivalent doc in the compas_threejs backend repo.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Lets the backend move/rotate an existing object by applying a matrix
directly via Object3D.applyMatrix4 instead of resending the full
geometry, mirroring object_transform's outbound convention. Reuses the
existing manageGeometry dragging guard so a live gizmo drag isn't
fought by an incoming backend transform.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ericgozzi
ericgozzi force-pushed the feature/bidirectional-sync branch from 7b23a14 to 19e42ac Compare September 7, 2026 08:38
@ericgozzi
ericgozzi merged commit 7b5d135 into main Sep 7, 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.

2 participants