feat: frontend drawing support - arcs, circles, polygons, delete, extrude and on_create callbacks - #61
Open
ericgozzi wants to merge 4 commits into
Open
feat: frontend drawing support - arcs, circles, polygons, delete, extrude and on_create callbacks#61ericgozzi wants to merge 4 commits into
ericgozzi wants to merge 4 commits into
Conversation
create_geometry now accepts type line/polyline/polygon with a "points" list, for frontend drawing tools. A polygon is created as a closed Polyline, since the viewer can't display COMPAS Polygons yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…backs for frontend drawing Moves frontend geometry creation into compas_threejs.viewer.drawing and extends it: polygons are now real COMPAS Polygons, circles come from a location and radius, and arcs from start/end/through points (with angles kept off 0, which compas-pb-ts 2.0 rejects). create_geometry keeps a guid sent by the frontend. New delete_geometry and extrude_geometry messages remove an object and extrude a polygon into a prism mesh. App.on_create and App.on_delete let scripts react to what the frontend creates or deletes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Uses App.on_create / App.on_delete: drawn polygons become 3 m rooms tagged with their floor area, with a running total; lines and polylines are colored by length; deleting or undoing a polygon removes its room. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…along the normal create_geometry takes optional xaxis/yaxis for boxes and circles, so shapes drawn on a vertical or tilted drawing plane keep its orientation. Extrude now follows the polygon's own normal (turned up for horizontal polygons, as before), so walls drawn on a vertical plane get their thickness. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Backend support for frontend drawing tools such as
compas_threejs_draw(built on the viewer's plugin API, compas-dev/compas_threejs_ts#37): what a user draws in the viewer arrives here as real COMPAS objects, and scripts can react to it.compas_threejs.viewer.drawing: turnscreate_geometrymessages into COMPAS objects -point,box,sphere,circlefrom a location (boxes and circles take their frame axes fromxaxis/yaxis, so shapes drawn on vertical or tilted drawing planes keep their orientation), andline,polyline,polygon(a realPolygon) and three-pointarcfrompoints. Invalid input is logged and ignored.guidincreate_geometrybecomes the new object's guid, so the frontend can refer to what it drew.delete_geometryremoves an object (Delete / Undo in the frontend);extrude_geometryextrudes a polygon along its normal into a new prismMesh, keeping the polygon.App.on_create/App.on_delete: callbacks (usable as decorators) for objects the frontend creates or deletes. A failing callback is logged, not raised into the server.examples/draw.py: drawn polygons become 3 m rooms tagged with their floor area and a running total; lines are colored by length; deleting a polygon removes its room.Arcs are built with their angles placed around pi:
@gramaziokohler/compas-pb-ts2.0.0 rejects an arc with an angle of exactly 0, which COMPAS often produces.Displaying polygons and arcs needs compas-dev/compas_threejs_ts#36 in the frontend.
Test plan
tests/test_create_geometry.py(22 tests in total): every type, invalid input, guids, delete, extrude (including vertical and downward), plane axes, callbacks.pytest,ruff check,ruff format --checkpass.compas_threejs_draw: every tool, Delete, Undo, Extrude andexamples/draw.py.🤖 Generated with Claude Code