adding Sketching + Theming + Revolves + Sketch Snapping + 3mF support - #27
adding Sketching + Theming + Revolves + Sketch Snapping + 3mF support#27WC3D wants to merge 41 commits into
Conversation
Add OCCT-backed sketch extrusion
|
Thanks for the merge request! I tested it locally, and the overall approach is promising, but a few important issues need to be addressed before it can be merged:
The exact B-Rep extrusion direction is a strong addition, and basic sketches worked well during testing. Once these core correctness, loading, performance, and testing issues are resolved, it should be in much better shape for merging. |
Introduce a theming system and viewport theming: add lib/themes.ts, CSS variables and theme variants, apply themes in SketchForgeEditor and WorkplaneViewport, and persist default theme. Improve CAD handling: refine cadSketchRegions to compute nesting (holes/islands) and throw clearer errors for all-open profiles. Reuse sketch CAD worker with request IDs + timeout instead of one-shot worker. Change OCCT asset paths to /occt/ and remove staged runtime files. Add tests (unit + e2e) and helper scripts (refactor-css/viewport). Minor workspace/settings and package-lock tidy-ups.
Enhanced the workspace background color selection UI with preset color swatches and a custom color picker. Previously limited to a toggle between two colors, users can now choose from 7 preset colors or pick any custom color. Updated styling and refactored test utilities for path construction.
Enhance the custom theme editor with better UX and reliability. Added customThemeWithDefaults function to ensure custom themes inherit missing properties from the light theme. Improved color picker UI with larger inputs (32px), human-readable labels for color properties, hex color filtering, and better styling. Fixed workspace toggle alignment and added theme label exports for reuse across components.
Introduce center-radius and two-point diameter circle sketching. Adds a new sketchCircles lib (circleFromPoints, circleSketchGeometry) that builds a 4-point cubic Bezier approximation (kappa constant). Wire up two new tools (circle-center, circle-diameter) in the editor, persist a circleDraft state, commit generated bezier points/segments into the sketch profile, and render an interactive preview in the workspace (styles added in globals.css). Update input handlers and selection logic to support the new tools. Add unit tests for circle geometry and an e2e extrusion test that extrudes the cubic circle via the OCCT kernel.
Adds comprehensive constraint and sketch modeling features: - Constraint system: fixed points, horizontal/vertical segment constraints - Driving dimensions: set and manage segment lengths - New geometry tools: rectangles (corner/center), polygons (inscribed/circumscribed/edge), text annotations - Constraint solver: propagates changes through constrained geometry with conflict detection - UI controls: constraint inspector, segment dimension editor, polygon sides adjustment - Serialization support for constraints, dimensions, and text in sketch profiles Includes tests for constraint solving and parameter pruning.
Extract workspace hydration requirement check into a dedicated function to prevent unnecessary re-renders when settings values haven't actually changed. The new `workspaceHydrationRequired` function evaluates whether hydration is needed based on key changes and fingerprint comparisons, enabling early return when the current and next states are identical. Also updates manifold-3d to 3.5.1 and pins sharp/postcss versions for dependency stability.
enhance sketch modeling features
|
@Formsmith746 What do you think of this? This PR expands SketchForge's 2D sketching and project workflows, adds an initial parametric constraint system, improves CAD and workspace reliability, and updates vulnerable dependencies. It also brings the branch up to date with Sketch Modeling
Project Files and Sharing
Import and Export
CAD and Editor Reliability
Security and Dependencies
Testing
|
Introduce a sketch snapping system and UI: new lib/sketchSnapping.ts (precision, grid/geometry snapping, dedupe), integrate into SketchWorkspace (hover feedback, snap mode buttons, center markers, magnetic behavior), and add CSS for visuals. Expand SketchForgeEditor to accept more plane-point tools. Improve CAD group handling: add closedCadSolidComponents and use it in cadModifier.worker to treat fused/compound solids correctly. Add unit and e2e tests for snapping and CAD group handling. This fixes snapping UX and ensures grouped fused solids are resolved properly.
Bumps the npm_and_yarn group with 1 update in the / directory: [next](https://github.com/vercel/next.js). Updates `next` from 15.5.18 to 15.5.21 - [Release notes](https://github.com/vercel/next.js/releases) - [Commits](vercel/next.js@v15.5.18...v15.5.21) --- updated-dependencies: - dependency-name: next dependency-version: 15.5.21 dependency-type: direct:production dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] <support@github.com>
Introduce construction plane system and multiple sketch tools: projection, offset, sweep, and affine transforms. Adds new libs (constructionPlanes, sketchProjection, sketchOffset, sketchSweep, sketchTransforms), UI panels and toolbar controls, workspace/viewport interaction updates, CSS for operation panels, type updates, and SKP project serialization for projections and construction planes. Also includes comprehensive unit tests for the new features and integrates projection/sweep/offset flows into the editor. These changes enable associative sketch planes, pattern/mirror/offset operations, sweep creation, and robust projection of meshes/sketches into sketch planes.
…5988e9b934 Bump next from 15.5.18 to 15.5.21 in the npm_and_yarn group across 1 directory
Updates Next.js from 15.5.18 to 15.5.21 and PostCSS from 8.5.15 to 8.5.23, including corresponding updates to all @next/swc platform-specific binaries. Also adds glibc and musl libc specifications to Linux ARM64 and x64 SWC packages.
SummaryThis PR expands SketchForge’s sketching and CAD workflow with exact OCCT-backed extrusion, construction planes, constraints, advanced sketch operations, magnetic snapping, richer geometry tools, workspace themes, and reliability improvements. The branch has been synchronized with upstream Scope
Exact Sketch Extrusion
Sketch Geometry
Constraints and Dimensions
The solver is intentionally limited to fixed points, horizontal or vertical lines, and line-length dimensions. It is not yet a general geometric constraint solver. Magnetic Snapping
Construction Planes
Advanced Sketch Operations
Themes and Workspace Appearance
CAD Reliability
WebGL Reliability
Project PersistenceThe
Development and Runtime Improvements
Test CoverageNew and expanded tests cover:
Validation
Review Focus
Known Limitations
|
# Conflicts: # apps/web/src/components/SketchForgeEditor.tsx # apps/web/src/lib/skfProject.ts
# Conflicts: # apps/web/src/app/globals.css # apps/web/src/components/WorkplaneViewport.tsx # apps/web/src/components/workplane/WorkspaceSettingsModal.tsx # apps/web/src/lib/workplaneSettings.ts # apps/web/src/workers/cadModifier.worker.ts
New features
Add robust path validation and safe writes for the local-download API (SKETCHFORGE_LOCAL_DOWNLOAD_ROOT support, canonicalization, symlink/escape checks, atomic temp-file write+rename). Add unit tests for route. Harden static export verification to reject symlinks and path-escape assets. Bump Next.js to 16.2.12 and adjust scripts/tsconfig/next-env to match, plus minor CI/docker workflow and README updates (Node >=20.9 and local download docs).
Introduce a new 'sketchforge' theme preset and expose theme presets via THEME_PRESET_OPTIONS. Add defaultThemes.sketchforge and appColorModeForThemePreset, update workspace normalization (VALID_THEME_IDS) and tsconfig/next-env paths. Wire theme preset selects in TopActionPanel and WorkspaceSettingsModal to use THEME_PRESET_OPTIONS, and sync app color mode from active preset in SketchForgeEditor. Remove legacy app-wide theme preference UI from the modal and related prop plumbing. Add unit tests for theme presets and update workplaneSettings tests to cover the new preset.
Enhance local downloads security and introduce SketchForge theme preset
Add distance-style sketch dimensions, UI, and CAD region selection for extrusions. Introduces sketchDimensions utilities (anchor candidates, intersections, distance values), workspace/editor UI and handlers for adding/deleting reference dimensions and selecting extrusion regions, and CSS for dimension/selection visuals. Enhances sketchCadProfile with arrangement-based regionization, selectable region IDs, and profile filtering; worker and CAD build types now accept regionIds. Update types, constraint pruning/solving, transforms, SKP validation, and tests to handle new dimension kind and region-aware behavior.
Add full 3MF support: parsing and exporting 3MF packages, UI integration, and project format updates. Introduces apps/web/src/lib/threeMf.ts with importedShapeFrom3mf and exportMeshesTo3mf, enforces a 256 MB asset limit (MAX_PROJECT_ASSET_BYTES), and preflights/validates 3MF archives and model XML. Integrates 3MF into import/export UI, file accept lists, SKF packaging/validation, types, and error messages. Updates README/docs and adds/adjusts unit tests (threeMf.test.ts plus updates to existing tests) to cover format recognition and behavior.
Add a new bullet describing 2D Sketching & Parametric Profiles to the "What It Does" list and introduce a "2D Sketching & Revolve Workflow" section with a feature screenshot (docs/media/sketchforge-editor-v0.8.0.png).
SummaryThis PR significantly expands SketchForge’s 2D sketching and CAD workflows, adds customizable themes and 3MF support, strengthens project persistence and file handling, and modernizes the application runtime. Sketching And CAD
Themes And Interface
3MF And Project Files
CAD And Runtime Fixes
Security And Platform
Documentation And Tests
Verification
|
[Aikido] AI Fix for Potential file inclusion attack via reading file
Competitor scan (Tinkercad, Shapr3D, Plasticity, Fusion, Onshape) filtered to quick AV-part design, plus the full upstream issue/PR tracker. Every candidate gap grep-verified against apps/web/src before being recorded, so the task list contains no features the app already ships. Blocks 1-4 rewritten into 26 tasks, each carrying the files it touches, a one-line acceptance check, and an evidence tag ([C] competitor, [U#] upstream). Tasks prefer new lib/ files over the 7.6k/9.9k-line editor files to keep upstream merges clean and avoid PR Formsmith746#27. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
# Conflicts: # apps/web/src/app/page.tsx # apps/web/src/components/SketchForgeEditor.tsx # apps/web/src/components/WorkplaneViewport.tsx # apps/web/src/components/workplane/WorkspaceSettingsModal.tsx # apps/web/src/lib/skfProject.ts # tests/unit/skfProject.test.ts
|
I tried this PR out of curiosity and while it has a few rough edges and bug, having sketching is a huge enhancement. |
|
@gogades which bugs are causing you the biggest problems? I'm trying to work through many of them. I can prioritize the ones you mention here. Thank you for giving this PR a try! |
|
I really love this pull request, and I’ve been quietly following the changes as it developed. I had a couple of reasons for not merging it earlier. First, it became a very large PR, touching many files, which increased the risk of introducing regressions. I wanted to give it more time to develop and review the individual features carefully. Second, I needed to finalize SketchForge’s license change from MIT to AGPLv3 or GPLv3 before bringing in such a substantial contribution, as per OpenScade's policies. After testing the changes locally, I was especially impressed by the OpenCascade integration for sketching and exact sketch extrusion. I’ve decided to integrate that portion into the next official SketchForge update. Thank you for the time and effort you put into this! |
|
@WC3D The biggest bug I noticed is that most time (but not always), I can't move an extruded sketch around on the workplane - I can move it, but it snaps back to its original location where it was created. I can resize it fine. There's been a few times where I was able to move it, but most time I couldn't. Not sure what the difference was. The UI is also a little confusing - for example, I can't figure out how to move a center point once it's been created. @Formsmith746 I agree - this PR is absolutely massive. In my opinion the theming and possibly 3mf support should be broken out into separate PRs. Some of the themes are are a little buggy anyway - some icons were not displaying (blank space instead of icon) using the solidworks theme for example. I'm really loving sketchforge tho - I love the idea of an OSS Tinkercad++. I've used it to make a few simple models and it's already more powerful than TC while keeping the same simple UI. I have made a few quality of life improvements on my own merge branch that I would like to share and contribute but I'd like to see this big PR go in first. |
|
Out of curiosity, what improvements have you added on your merge branch? |
|
@Formsmith746 Nothing fancy so far, just I added keyboard shortcuts to rotate the view (front, back, left, right, top and bottom are mapped to 1 to 6), and added a "zoom view" feature that zooms in and "fills" the viewport with the currently selected object, or all the objects on the workplane if none selected. That still needs an icon somewhere but I have it mapped to the ` (backtick) key for now. I think it might be improved behaviour versus the "F" shortcut, actually, which is the same as Home. I also prototyped the idea of "component objects" - basically an object that becomes a template and assuming it has not fundamentally changed, changes to template propagate to every instance of that object. That's a much longer discussion and needs more thought. |
# Conflicts: # apps/web/src/app/globals.css # apps/web/src/app/page.tsx # apps/web/src/components/SketchForgeEditor.tsx # apps/web/src/components/SketchWorkspace.tsx # apps/web/src/components/WorkplaneViewport.tsx # apps/web/src/lib/sketchCadProfile.ts # apps/web/src/lib/sketchCadTypes.ts # apps/web/src/workers/sketchCad.worker.ts # tests/e2e/sketchCadExtrusion.e2e.ts # tests/unit/sketchCadProfile.test.ts
Reconcile construction-plane local centers during interactive shape updates so moved sketch extrusions retain their final position. Make derived closed-profile centers draggable in Select mode with atomic point and handle translation, snapping support, and protection for fixed or projected geometry. Improve disabled toolbar icon contrast across light and dark appearances, remove the Dark workspace preset, and migrate saved Dark selections to Light. Add regression coverage for placement reconciliation, profile translation, theme availability, and legacy theme normalization.
|
@Formsmith746 @gogades Thank you for your comments. I fixed some of the bigger issues. Let me know if it works better for you, @gogades. Also, I'd like to apologize for the large PR. When I initially started work on it. I intended to help with a Base for the sketch tools, but then ended up adding more features, ant themes, ETC. I had not realized that anything I pushed to my fork's main branch would have been added to the PR. was my mistake to assume, but I thought I would have to create a new PR to pull the changes each time. Could someone point me to how I can break this PR into a few? I'm willing to do so, but I do not know how or if it's possible at this point. Going forward, I will create separate branches for new features and create separate Pull Requests for them. This is my understanding of the best practices; if I'm wrong, please let me know. Thank you again! @Formsmith746 If there's anything I can do to help you make this work in the next release, please just let me know! I'm happy to help! Changes
|




Summary
This adds an OpenCascade-backed path for converting editable 2D sketches into exact B-Rep extrusions.
Closed sketch profiles are now converted into OCCT edges, wires, planar faces, and extruded solids instead of relying exclusively on
THREE.ExtrudeGeometry.Not sure if this is a direction you wanted to go in but it was something I'd use in my workflow. Thank you for making this awesome project.


Motivation
SketchForge already includes
occt-wasm, exact B-Rep storage, STEP support, and worker-based CAD operations. This change extends that infrastructure to sketch-generated geometry.Producing the B-Rep first provides a foundation for:
Changes
cadBrepmetadata.User impact
The existing sketch UI remains largely unchanged. When the user finishes a valid closed sketch, SketchForge now builds exact CAD geometry through OpenCascade.
Open or degenerate profiles remain in the sketch editor and display an actionable error.
Validation
Scope and follow-up work
This PR is intentionally limited to workplane sketch extrusion.
It does not yet implement:
Those can be developed separately on top of this foundation.