Skip to content

feat: frontend drawing support - arcs, circles, polygons, delete, extrude and on_create callbacks - #61

Open
ericgozzi wants to merge 4 commits into
mainfrom
feature/create-geometry-from-points
Open

ericgozzi wants to merge 4 commits into
mainfrom
feature/create-geometry-from-points

Conversation

@ericgozzi

Copy link
Copy Markdown
Collaborator

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: turns create_geometry messages into COMPAS objects - point, box, sphere, circle from a location (boxes and circles take their frame axes from xaxis/yaxis, so shapes drawn on vertical or tilted drawing planes keep their orientation), and line, polyline, polygon (a real Polygon) and three-point arc from points. Invalid input is logged and ignored.
  • A guid in create_geometry becomes the new object's guid, so the frontend can refer to what it drew.
  • delete_geometry removes an object (Delete / Undo in the frontend); extrude_geometry extrudes a polygon along its normal into a new prism Mesh, 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-ts 2.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 --check pass.
  • Run live against the viewer with compas_threejs_draw: every tool, Delete, Undo, Extrude and examples/draw.py.

🤖 Generated with Claude Code

ericgozzi and others added 4 commits September 23, 2026 10:49
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

No deployments
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