Repository navigation
CAD Studio Prototype
A new, viewport-first CAD app built on @barocss/cad, answering the editor review in CAD and GPU engine review §11: the existing editor does not feel like CAD because it is not built around the CAD interaction loop. This prototype is that loop.
-
Where:
apps/cad-studioon the local review branchreview/cad-gpu-engine-2026-10-14(commits43d0d692→c832ab91, based on develop373aeaf8). Not pushed, no PR. It does not touchapps/cad-editororpackages/barocss-cad-editor. - Design direction: "A — Plasticity-like": dark graphite, viewport fills the screen, floating icon toolbar / outliner / command HUD, command palette, keyboard-first, one yellow accent. Chosen by the owner over a Fusion/SolidWorks-like light layout (which survives as the light theme).
-
Run:
pnpm --filter @barocss/cad-studio-app dev→http://127.0.0.1:52020. Unit tests:node apps/cad-studio/scripts/test.mjs. Browser flow:PW_DIR=<playwright package> CHROME=<chrome binary> node apps/cad-studio/test/browser-flow.mjs [out-dir]. -
Dependency note: the app reuses dependency versions already in the workspace.
pnpm installrewrote the whole lockfile (~3.5k lines), so the lockfile was not committed; registering the app's importer is left to Integration at merge time.
Verified by 9 engine unit tests and an 11-step real-browser flow (headless Chrome, all pass): starter load · box · second box + union · undo/redo · supported hole · plain-language refusal · pattern from the right-click menu · slot sketch → curved body · solver-locked lengths → fully defined · arc-notch outline → one body · palette + light theme.
| area | behaviour |
|---|---|
| Viewport | WebGL2, MSAA, plane-aware SSAO, clay shading, wide crease edges, ground grid with X/Y axes, contact shadow, gradient background; right-drag orbit, middle / Shift-right pan, wheel zoom to cursor, Alt-drag orbit for trackpads; F frame; Iso / Top / Front / Right; orthographic; live axis triad |
| Selection | GPU ID-buffer face picking, screen-space edge picking, hover pre-highlight, face / edge / body selection, Shift-click multi-body, window (left→right) and crossing (right→left) marquee |
| Commands | Selection-driven: Box, Cylinder, Sketch, Hole (on a top face, click sets the centre), Chamfer (on a picked edge), Move (with drag gizmo), Rotate, Mirror, Linear / Circular pattern, Split, Union / Subtract / Intersect. Fillet, Shell, Draft, Revolve-to-solid, Loft-to-solid are present but disabled with “isn’t available in the kernel yet”. |
| Command HUD | Few fields, keyboard-first (Tab / Enter / Esc), live preview evaluated in a Web Worker as values change; Apply is only possible for the evaluated values; kernel refusals inline in plain language with the kernel text behind “Kernel detail”. |
| Sketch | Enter on the XY plane or a selected top face (camera looks at the plane, bodies ghosted); Rectangle (R) / Circle (C) / Line (L) / Arc (A) / Slot (O) on a 1 mm snap. Line and Arc share one chain (3-point arcs, bulge follows the cursor). Live dimension chips (click to edit: lengths, arc radii, slot length/width). Straight outlines are solved by the kernel's numerical sketch solver: point 1 anchored, drawn H/V kept, typed lengths locked, rank and remaining DOF shown, conflicts explained. Concave, curved and slot outlines extrude as line + arc solids. Finish → Extrude with Join / New body / Cut when on a face. |
| History | Feature strip with icons; click to edit a feature’s dimensions (downstream features rebuild); double-click to roll back; undo / redo (50 steps). |
| Other | Command palette (Space) with reasons for unavailable commands; right-click context menu with the commands that apply to what was clicked; outliner; selection card with type, normal, area, length, bounds, volume, mass (Al 6061); Save / Open .bcad (the kernel’s own model JSON); STL export (kernel writer, mesh fallback); New part; dark / light theme (remembered); AO toggle. |


-
Kernel: new
extruded-profile-solidmodule in@barocss/cad(commit8dc6316e). A closed simple loop of lines and circular arcs (concave allowed, clockwise input normalised) becomes an exact B-rep prism: rational quadratic arc edges (≤ 90° spans), plane and cylinder faces, edge-use and Euler checks, Green's-theorem area / centroid / second moments, mass and inertia, a watertight tessellation and binary STL. Typed refusals: input, budget, geometry, topology, self-intersection. -
Model graph:
modeling.tsaccepts it as sketch profileloop(andmodel.sketch.loop()), with optionalfromplacement. Body familyextruded-profile;massPropertiesandexportStlsupport it. Like circle bodies, loop bodies are refused by the convex-only operations (chamfer, move, rotate, mirror, patterns, split, booleans), and the studio explains that before evaluation. 15 strict zero-native admission tests register the new provider; full CAD suite 727/728 (the one failure is the known Node 22.23.3 example pin). -
Solver path: the kernel's
constrained-polygoncannot hold lengths, so sketch editing usessolveXYNumericalSketchdirectly. It handles straight outlines only (lines; no arcs, at most 8 segments), so arcs are edited by radius and stay outside the solve. - Still missing: arcs in the solver (tangent, radius, concentric constraints), sketch editing after Finish, fillet of a sketch corner, and convex-only operations on curved bodies (they need the general B-rep work in the review §9).
-
Document = the kernel’s saved model JSON (
format: barocss-cad-model, nodes + outputs). Commands append or edit nodes; rollback evaluates a prefix; Save/Open is that JSON. Visible bodies are derived from the node graph (patterns and mirrors keep their parent; other operations consume it). -
Evaluation in a Web Worker (
cad.load), newest request wins, results transferred as typed arrays. - One display mesh per body from the four kernel body families (convex-planar, plate-with-hole, circle prism, orthogonal-cell panels): triangles with a face index per vertex, face records, and crease edges. Coplanar orthogonal panels are merged into one face. The edge builder tolerates the kernel’s hole-preview T-junctions (see the review §9.7).
-
Renderer (
src/viewport/renderer.ts, ~400 lines) keeps GPU resources persistent: a camera move only writes uniforms; hover/selection only rewrites small state buffers.
- Model-level limits the UI must explain before evaluation, now pre-checked in the command layer: a part with a hole cannot also have chamfers, splits, subtractions or intersections; Move/Rotate only as the last step of a single-body part; Booleans only between whole-millimetre axis-aligned boxes; sizes that are not dyadic ratios are refused (e.g. any Ø6 hole on 100 × 60 × 5).
- These limits shape the app far more than any UI choice. The general B-rep and tolerance work in the review §9 is what turns this from a careful demo into a usable modeller.
The studio could not use @barocss/gpu for its viewport (review §10): no single renderer combines lit multi-mesh, edges, highlight and a camera-only fast path. The in-app renderer is a concrete requirement list for the unified core:
persistent geometry buffers + uniform-only camera updates · per-vertex/per-segment state buffers for hover/selection · instanced wide lines with depth bias · ID-buffer picking · MSAA target + resolve + SSAO composite · theme-driven palette · DPR-aware sizing.
- Owner review of the prototype in the browser; decide whether
apps/cad-studiobecomes the product editor path and how it lands (Integration owns the lockfile and workspace registration). - Sketch: arc constraints in the solver (tangent / radius / concentric), re-editing a finished sketch, sketch-on-any-planar-face. (Lines + arcs, slots and a length/H/V solver landed 2026-10-15.)
- Hook the studio’s viewport requirements into the GPU unified-core plan, then swap the in-app renderer for
@barocss/gpu. - As the kernel generalises (B-rep core, tolerance policy), remove the pre-checks one by one; the browser flow gains a step per capability.