Skip to content

adding Sketching + Theming + Revolves + Sketch Snapping + 3mF support - #27

Open
WC3D wants to merge 41 commits into
Formsmith746:mainfrom
WC3D:main
Open

adding Sketching + Theming + Revolves + Sketch Snapping + 3mF support#27
WC3D wants to merge 41 commits into
Formsmith746:mainfrom
WC3D:main

Conversation

@WC3D

@WC3D WC3D commented Jul 11, 2026

Copy link
Copy Markdown

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.
Screenshot1
Screenshot2

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:

  • Exact STEP export of sketch extrusions
  • More reliable downstream booleans
  • Editable sketch regeneration
  • Future parametric extrusion and cut features
  • Future sketching on planar faces

Changes

  • Added a dedicated OCCT sketch worker.
  • Converts line segments into exact OCCT line edges.
  • Converts cubic Bézier segments into OCCT Bézier edges.
  • Orders connected sketch segments into closed paths.
  • Detects enclosed profiles and treats them as holes.
  • Supports multiple disjoint profile regions.
  • Creates planar faces and exact extruded B-Reps.
  • Tessellates the B-Rep for the existing Three.js viewport.
  • Stores the exact result using existing cadBrep metadata.
  • Regenerates the solid after reopening and finishing its sketch.
  • Reports worker, timeout, and kernel errors without closing the active sketch.
  • Added topology-preparation unit tests.

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

  • TypeScript typecheck passed.
  • Full unit suite passed: 40 tests across 9 files.
  • Production build passed.
  • Browser-tested closed rectangle sketch → 10 mm exact extrusion.
  • Browser-tested reopening the sketch → successful B-Rep regeneration.
  • Tests cover:
    • closed-loop ordering
    • enclosed holes
    • disjoint regions
    • rejection of open paths

Scope and follow-up work

This PR is intentionally limited to workplane sketch extrusion.

It does not yet implement:

  • a dimensional/geometric constraint solver
  • sketch attachment to arbitrary planar faces
  • parametric cut targets
  • a general feature-history graph
  • automatic B-Rep regeneration while dragging extrusion dimensions

Those can be developed separately on top of this foundation.

@Formsmith746

Copy link
Copy Markdown
Owner

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 OCCT worker loads from /assets/occt/, while SketchForge serves the runtime from /occt/, causing 404 errors when finishing a sketch.
  • A new worker is created and terminated for every extrusion, forcing the large OCCT runtime to reload each time and making the operation noticeably slow. The worker should be reused.
  • Some profile combinations can produce geometry that does not match the visible sketch, particularly mixed open/closed paths and nested profiles. Invalid profiles should be rejected clearly, and nested regions must preserve holes and solid islands correctly.
  • Runtime or integration tests are needed for worker loading, production/static builds, actual B-Rep extrusion, and these profile edge cases. The PR should also have passing CI checks.

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.

WC3D added 3 commits July 13, 2026 16:05
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.
@WC3D WC3D changed the title Basic example of adding Sketching Basic example of adding Sketching + Theming Jul 13, 2026
WC3D added 3 commits July 13, 2026 17:43
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.
@WC3D

WC3D commented Jul 14, 2026

Copy link
Copy Markdown
Author

PR Summary: OCCT Worker Fixes, Circles, Profile Validation, Worker Reuse, Tests, and UI Improvements

Screenshot 2026-07-14 at 12 01 46 AM Screenshot 2026-07-14 at 12 00 37 AM Screenshot 2026-07-13 at 5 27 29 PM Screenshot 2026-07-13 at 5 12 22 PM

Overview

This PR resolves all review feedback from the original occt-sketch-extrusion PR and introduces several additional UI and performance improvements.

Scope

  • 44 files changed
  • Approximately 2,965 insertions and 575 deletions
  • All CI checks passing:
    • Typecheck
    • 77 unit tests
    • 13 end-to-end tests

1. Fixed OCCT Worker Loading Paths

Problem

Both Web Workers—sketchCad.worker.ts and cadModifier.worker.ts—attempted to load the OCCT WASM runtime from /assets/occt/.

However:

  • scripts/copy-occt-wasm.mjs copies the runtime to public/occt/
  • brepKernel.ts already loads it from /occt/

This mismatch caused 404 errors when users finished a sketch.

Changes

  • Updated sketchCad.worker.ts to load:
    • /occt/occt-wasm.js
    • /occt/occt-wasm.wasm
  • Updated cadModifier.worker.ts to use the shared CAD_MODIFIER_RUNTIME_BASE constant from lib/cadModifierRuntime.ts
  • Removed the duplicate, Git-tracked public/assets/occt/ directory, saving approximately 22 MB
  • Added apps/web/public/assets/occt/ to .gitignore

2. Reused the Sketch CAD Worker

Problem

Every sketch extrusion created and terminated a new Web Worker. This forced the browser to reload the 22 MB OCCT WASM runtime each time, making repeated extrusions noticeably slow.

Changes

Updated SketchForgeEditor.tsx to:

  • Create the worker only when it is first needed
  • Reuse one persistent worker for subsequent extrusions
  • Track pending operations with request IDs
  • Safely support concurrent requests
  • Automatically recover from worker errors by recreating the worker on the next request

Result

Repeated sketch extrusions no longer reload the complete OCCT runtime, significantly reducing unnecessary overhead.


3. Improved Profile Validation

Problem

cadSketchRegions() in sketchCadProfile.ts did not correctly handle regions nested three or more levels deep.

For example:

Outer boundary
└── Hole
    └── Island

The island was identified as a child of the hole but was discarded because no region used the hole path as its outer boundary.

Changes

  • Reworked cadSketchRegions() to calculate nesting depth using point-in-polygon containment
  • Classified boundaries by depth:
    • Even depth → solid outer boundary
    • Odd depth → hole
  • Added support for arbitrary nesting, including:
    • Outer boundary
    • Hole
    • Island
    • Hole inside an island
    • Further nested regions
  • Added a clearer error when every profile path is open:

All profile paths are open. Close at least one loop before finishing the sketch.

  • Improved the worker error message for profiles that produce no valid regions

4. Expanded Runtime and Integration Testing

New primary test files

Test file Coverage
tests/e2e/sketchCadExtrusion.e2e.ts End-to-end B-Rep sketch extrusion
tests/unit/workerPaths.test.ts OCCT worker runtime paths
tests/unit/sketchCadProfile.test.ts Profile nesting and edge cases
tests/unit/workplaneSettings.test.ts Workplane settings behavior and regression fix

Additional test files

  • tests/unit/cadModifierGroups.test.ts
  • tests/unit/cadModifierRuntime.test.ts
  • tests/unit/edgeTreatmentHistory.test.ts
  • tests/unit/gridSnap.test.ts
  • tests/unit/svgImport.test.ts
  • tests/unit/workplaneGrid.test.ts
  • tests/unit/workplaneShapes.test.ts

Static asset verification

Added scripts/verify-static-worker-assets.mjs to verify that OCCT runtime assets are correctly staged under /occt/ for static builds.


5. Improved UI and Theming

Background color picker

Updated WorkspaceSettingsModal.tsx and globals.css.

The previous background control was a single swatch that toggled between two colors. It has been replaced with:

  • Seven preset background colors:
    • White
    • Light blue
    • Warm gray
    • Light cyan
    • Medium gray
    • Dark gray
    • Near-black
  • A primary-color outline for the active preset
  • A custom option using the native color picker

Theming system

Introduced a broader theming system in commit acca084.

Changes include:

  • New lib/themes.ts
  • Four built-in themes:
    • Light
    • Dark
    • SolidWorks
    • Inventor
  • Custom theme support
    • User can set their own colors
  • Theme-specific CSS variables in globals.css
  • Viewport theming through the WorkplaneViewport theme prop
  • A theme selector under Workspace Settings → Appearance
  • Theme persistence through localStorage

Custom theme editor

  • Added editable UI and viewport color controls
  • Added human-readable color labels
  • Filtered out compound CSS values that cannot be edited with native color inputs
  • Enlarged color controls and the custom-theme editor

6. ## Sketch Circle Tools

Added two circle construction tools to the sketch toolbar:

  • Center Point Circle: choose a center followed by a radius point
  • Two Point Circle: choose two opposite points on the diameter

Both tools include:

  • Grid-snapped input
  • Live circle previews
  • Radius or diameter readouts
  • Zero-radius validation
  • Escape and tool-switch cancellation
  • Undo and redo support
  • Selection, editing, refinement, and deletion
  • Persistence as part of the sketch profile
  • OCCT extrusion support

Circles are represented as closed paths containing four smooth cubic Bézier segments. This allows them to use the existing sketch selection, editing, profile, and CAD extrusion infrastructure.


Added:

  • apps/web/src/lib/sketchCircles.ts
  • tests/unit/sketchCircles.test.ts
  • Real OCCT circle-extrusion coverage in tests/e2e/sketchCadExtrusion.e2e.ts

Key Files Changed

Core fixes

  • apps/web/src/workers/sketchCad.worker.ts
    Fixed the OCCT runtime path.

  • apps/web/src/workers/cadModifier.worker.ts
    Fixed the OCCT runtime path using the shared base constant.

  • apps/web/src/lib/cadModifierRuntime.ts
    Added the shared CAD_MODIFIER_RUNTIME_BASE constant.

  • apps/web/src/components/SketchForgeEditor.tsx
    Added persistent worker reuse and theme integration.

  • apps/web/src/lib/sketchCadProfile.ts
    Added depth-based nested-region handling and improved validation errors.

Tests

  • tests/e2e/sketchCadExtrusion.e2e.ts
  • tests/unit/workerPaths.test.ts
  • tests/unit/sketchCadProfile.test.ts
  • tests/unit/workplaneSettings.test.ts

UI

  • apps/web/src/components/workplane/WorkspaceSettingsModal.tsx
    Added background presets and a custom color picker.

  • apps/web/src/app/globals.css
    Added color-swatch and theme styles.

  • apps/web/src/lib/themes.ts
    Added the new theme definitions and custom-theme support.

Cleanup

  • Updated .gitignore to exclude apps/web/public/assets/occt/
  • Removed the duplicate occt-wasm.js and occt-wasm.wasm files from apps/web/public/assets/occt/, reducing the repository by approximately 22 MB

Development Reliability

  • Automatically allows private LAN development origins
  • Fixed project-thumbnail GET, POST, and DELETE requests when the app is accessed through a private LAN address
  • Preserved same-origin and private-network validation for thumbnail requests
  • Prevented failed thumbnail saves from installing invalid thumbnail URLs
  • Replaced the passive React wheel handler with an explicit non-passive listener, removing repeated preventDefault warnings
  • Restored Fast Refresh and development font loading over LAN

Fresh verification confirms:
Typecheck: passing
Unit tests: 77/77
End-to-end tests: 14/14

WC3D added 6 commits July 14, 2026 19:18
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
@WC3D

WC3D commented Jul 22, 2026

Copy link
Copy Markdown
Author

@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 main and resolves the outstanding merge conflict.

Sketch Modeling

  • Adds corner and center rectangle tools.
  • Adds inscribed, circumscribed, and edge-defined polygon tools with adjustable side counts.
  • Adds text placement converted into editable sketch geometry.
  • Adds persisted horizontal, vertical, and fixed-point constraints.
  • Adds editable driving dimensions for line lengths.
  • Adds a deterministic constraint solver with propagation, pruning, and conflict detection.
  • Adds constraint indicators, fixed-point styling, and a segment constraint inspector.
  • Automatically applies horizontal and vertical constraints to generated rectangles.
  • Preserves constraints and dimensions through movement, deletion, splitting, undo, redo, and sketch editing.

Project Files and Sharing

  • Adds packaged .skf project import and export.
  • Preserves editable shapes, sketches, constraints, history, exact CAD data, groups, and imported source assets.
  • Adds asset deduplication, integrity hashing, package validation, and archive safety limits.
  • Adds configurable undo-history depth for SKF exports.
  • Adds shared-project API and save-to-shared workflows.
  • Adds project asset tracking and source regeneration support.
  • Adds SKF format documentation.

Import and Export

  • Adds top-view SVG export.
  • Improves SVG import validation and geometry handling.
  • Improves local download routing and generic download path handling.
  • Supports SKF hashing in HTTP environments without Web Crypto.

CAD and Editor Reliability

  • Keeps exact OpenCascade sketch extrusion as the primary path with an intersection-safe fallback.
  • Improves CAD modifier runtime handling, edge history restoration, and project synchronization.
  • Adds bounded editor history and more reliable history hydration.
  • Prevents workspace hydration feedback loops when value-equivalent settings receive new object references.
  • Isolates development, production, and static-export Next.js build directories.
  • Preserves local-network development origins and Docker standalone builds.
  • Improves theme defaults and workspace setting persistence.

Security and Dependencies

  • Updates manifold-3d to 3.5.1.
  • Overrides vulnerable transitive PostCSS with 8.5.22.
  • Overrides vulnerable transitive Sharp with 0.35.3.
  • Resolves the PostCSS style-breakout advisory and inherited libvips advisories.
  • npm audit reports zero vulnerabilities.

Testing

  • npm run typecheck
  • npm test - 132 tests passed
  • npm run test:e2e - 14 CAD integration tests passed
  • npm run build
  • Sharp native image-processing smoke test
  • PostCSS style-breakout proof-of-concept verification

WC3D and others added 6 commits July 23, 2026 02:28
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.
@WC3D WC3D mentioned this pull request Jul 24, 2026
@WC3D

WC3D commented Jul 24, 2026

Copy link
Copy Markdown
Author

Summary

This 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 main, including the latest workspace-dimension fix, and the merge conflict has been resolved.

Scope

  • 52 files changed
  • 7,935 additions
  • 564 deletions
  • 23 commits relative to upstream main

Exact Sketch Extrusion

  • Converts closed line and cubic Bezier profiles into OpenCascade edges, wires, faces, and exact extruded B-Reps.
  • Supports holes, nested islands, and multiple disconnected solids.
  • Stores exact B-Rep data for STEP export and downstream CAD operations.
  • Reuses a persistent OCCT worker instead of reloading the WASM kernel for every extrusion.
  • Uses request IDs, timeouts, and worker recovery for more reliable asynchronous processing.
  • Retains mesh extrusion as a fallback when exact CAD generation fails.
  • Reports open, invalid, or degenerate profiles without closing the active sketch.

Sketch Geometry

  • Adds center-radius circles.
  • Adds two-point diameter circles.
  • Adds corner and center rectangles.
  • Adds inscribed, circumscribed, and edge-defined polygons.
  • Adds configurable polygon side counts.
  • Adds text placement converted into editable closed sketch geometry.
  • Adds live geometry, radius, diameter, dimension, and placement previews.

Constraints and Dimensions

  • Adds fixed-point constraints.
  • Adds horizontal and vertical line constraints.
  • Adds editable driving dimensions for line lengths.
  • Adds constraint indicators and fixed-point markers.
  • Adds draggable dimension labels.
  • Propagates constrained geometry changes when points or dimensions move.
  • Preserves applicable constraints through editing and transformation.
  • Detects conflicting constraints and removes stale parameters after deletion.

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

  • Snaps to existing sketch points.
  • Snaps to segment midpoints and inferred centers.
  • Snaps to text anchors and visible grid lines.
  • Supports independent X and Z alignment snapping.
  • Gives geometry anchors priority over grid snapping.
  • Adds alignment guides, snap labels, and center markers.
  • Provides separate geometry and grid magnetic controls.

Construction Planes

  • Adds offset XY, XZ, and YZ principal planes.
  • Creates construction planes from planar model faces.
  • Keeps face-attached planes associated with translated, rotated, or resized source geometry.
  • Stores sketch geometry relative to its selected construction plane.
  • Preserves sketch orientation and placement when reopening or rebuilding features.
  • Excludes construction planes from normal design exports and transform selection.

Advanced Sketch Operations

  • Projects existing sketches into the active sketch plane.
  • Intersects mesh geometry with the active plane.
  • Supports linked projections that refresh from source geometry.
  • Supports one-time editable projection copies.
  • Offsets connected open and closed sketch paths.
  • Mirrors geometry around sketch axes or selected segments.
  • Creates rectangular patterns using configurable spacing and direction.
  • Creates circular patterns around the origin or a selected point.
  • Sweeps a closed section along a separate open sketch path.
  • Preserves applicable constraints, dimensions, images, text, and Bezier handles during transformations.

Themes and Workspace Appearance

  • Adds Light, Dark, SolidWorks-style, Inventor-style, and Custom themes.
  • Applies themes to both application controls and viewport rendering.
  • Adds human-readable custom-theme color controls.
  • Makes missing custom-theme values inherit from the Light theme.
  • Adds seven workspace background presets.
  • Adds an arbitrary background color picker.
  • Persists theme selections and default settings for new projects.

CAD Reliability

  • Correctly extracts closed solids from OCCT compound results.
  • Handles touching, overlapping, and disconnected grouped bodies.
  • Preserves holes when preparing grouped shapes for fillet and chamfer operations.
  • Improves nested sketch-region classification.
  • Improves worker error handling and runtime recovery.
  • Prevents unnecessary workspace hydration cycles for value-equivalent settings.
  • Applies live snap-grid and workspace dimensions when entering sketch or workplane views.

WebGL Reliability

  • Explicitly requests WebGL2 for the viewport and revolve preview.
  • Handles renderer creation failures without crashing the application.
  • Displays an actionable hardware-acceleration message.
  • Adds a retry control for the main viewport.

Project Persistence

The .skf format now preserves:

  • Construction planes and plane attachments.
  • Sketch constraints and driving dimensions.
  • Sketch text entities.
  • Linked projections and projected entity IDs.
  • Dimension-label positions.
  • Sweep source references.
  • Exact CAD metadata and generated geometry.

Development and Runtime Improvements

  • Standardizes OCCT runtime loading under /occt/.
  • Removes approximately 22 MB of duplicated tracked OCCT assets.
  • Stages OCCT assets from node_modules during development and production builds.
  • Supports local-network Next.js development origins.
  • Improves thumbnail API handling for private and link-local network hosts.
  • Prevents failed thumbnail writes from installing invalid thumbnail URLs.
  • Upgrades Next.js to 15.5.21.
  • Upgrades manifold-3d to 3.5.1.
  • Pins Sharp and PostCSS resolutions for dependency stability.

Test Coverage

New and expanded tests cover:

  • OCCT extrusion of rectangles, circles, holes, nested islands, and disconnected solids.
  • Open and invalid sketch-profile rejection.
  • Construction-plane transforms and face attachments.
  • Constraint solving and stale-parameter pruning.
  • Circle generation and profile classification.
  • Projection and mesh-plane intersection.
  • Path offsetting and topology validation.
  • Magnetic snapping priority and alignment.
  • Mirror, rectangular-pattern, and circular-pattern transformations.
  • Sweep geometry generation.
  • Grouped CAD topology and hole preservation.
  • OCCT runtime paths.
  • Workspace hydration behavior.
  • SKF serialization of the new entities.

Validation

  • npm run typecheck
  • npm run test
  • 32 test files passed
  • 191 unit tests passed
  • End-to-end OCCT passed

Review Focus

  • Sketch toolbar state and selection behavior.
  • Constraint propagation in dense or closed networks.
  • Construction-plane attachment after source transforms.
  • Offset behavior on tight curves and large distances.
  • Linked-projection refresh behavior.
  • Sweep persistence and editing.
  • Responsive styling across the expanded sketch interface.
  • WebGL2 behavior on older or software-rendered devices.
  • Deployment workflows that bypass predev or prebuild, since OCCT assets are no longer tracked.

Known Limitations

  • Sweep output is mesh-based rather than exact OCCT B-Rep geometry.
  • Offset curves are adaptively flattened and may lose analytic curvature.
  • Linked projections refresh when sketches are opened or rebuilt, not continuously.
  • The constraint solver supports a focused initial set of constraint types.

# Conflicts:
#	apps/web/src/components/SketchForgeEditor.tsx
#	apps/web/src/lib/skfProject.ts
WC3D added 11 commits July 27, 2026 14:52
# 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
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).
@WC3D

WC3D commented Jul 31, 2026

Copy link
Copy Markdown
Author

Summary

This 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

  • Adds a dedicated 2D sketching workflow with pan, zoom, marquee selection, and sketch-local undo/redo.
  • Adds lines, Bézier and smooth curves, circles, rectangles, polygons, text outlines, point refinement, and reference images.
  • Introduces fixed-point, horizontal, vertical, driving-length, and reference-distance dimensions.
  • Adds snapping to endpoints, midpoints, centers, intersections, alignment axes, text anchors, and grid lines.
  • Adds selectable extrusion regions with support for holes, nested islands, disjoint profiles, and curved boundaries.
  • Builds exact sketch extrusion B-Reps through a reusable OpenCascade worker, with tessellated fallback geometry.
  • Adds editable revolve operations with persisted settings and live 3D previews.
  • Adds sweep, connected-path offset, mirror, rectangular-pattern, circular-pattern, and projection tools.
  • Adds offset principal construction planes and associative planes attached to planar model faces.
  • Preserves construction-plane attachments when sketches and generated bodies are rebuilt.

Themes And Interface

  • Adds SketchForge, Light, Dark, SolidWorks, Inventor, and Custom theme presets.
  • Adds configurable UI and viewport colors, background presets, and custom color controls.
  • Persists theme selections per project and uses them as defaults for new projects.
  • Expands the Sketch toolbar, operation panels, region controls, and construction-plane management.
  • Adds explicit WebGL initialization failure handling and retry guidance.
  • Prevents workspace hydration feedback loops and stale project updates.

3MF And Project Files

  • Adds 3MF import through the dashboard, editor picker, and drag-and-drop.
  • Adds selected-object and full-scene 3MF export with millimeter units, object names, colors, and print-oriented coordinates.
  • Validates 3MF ZIP structure, paths, expansion limits, model complexity, units, component graphs, and required extensions.
  • Stores original 3MF files as deduplicated .skf source assets.
  • Extends .skf persistence for constraints, dimensions, text, projections, construction planes, sweep metadata, extrusion regions, and themes.
  • Adds validation for the new project records and references during restoration.

CAD And Runtime Fixes

  • Fixes fillet and chamfer preparation for fused, disconnected, and cut grouped solids.
  • Correctly unwraps compound-wrapped OpenCascade solids while preserving separate components and holes.
  • Standardizes CAD, sketch-CAD, and B-Rep workers on staged /occt/ runtime assets.
  • Removes tracked legacy OCCT binaries and stages the runtime from node_modules during development and builds.
  • Strengthens static worker verification against symlinks, path escapes, and incorrect asset prefixes.

Security And Platform

  • Restricts local-folder exports to approved existing directories under ~/Downloads or SKETCHFORGE_LOCAL_DOWNLOAD_ROOT.
  • Blocks traversal and symlink escapes and uses atomic temporary-file replacement.
  • Expands secure thumbnail access for private and link-local development hosts.
  • Upgrades Next.js to 16.2.12 and Manifold to 3.5.1.
  • Pins patched Sharp and PostCSS versions.
  • Moves development and production builds to webpack.
  • Updates CI and Docker environments and disables persisted checkout credentials.
  • Adds local-network development origins automatically.

Documentation And Tests

  • Updates the README with the expanded sketching, revolve, construction-plane, theme, and 3MF workflows.
  • Updates the SKF format documentation for new source assets and persisted sketch/CAD metadata.
  • Adds unit coverage for construction planes, constraints, dimensions, snapping, regions, offsets, projections, sweeps, transforms, themes, secure downloads, 3MF, and project persistence.
  • Adds real-OpenCascade tests for sketch extrusion and grouped CAD topology.

Verification

  • npm run typecheck
  • npm test (39 test files and 229 tests passing)
  • npm run build (production build completed successfully)

@WC3D WC3D changed the title Basic example of adding Sketching + Theming adding Sketching + Theming + Revolves + Sketch Snapping + 3mF support Aug 2, 2026
SchoepsLabs added a commit to SchoepsLabs/SketchForge-3D that referenced this pull request Aug 2, 2026
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
@gogades

gogades commented Aug 9, 2026

Copy link
Copy Markdown

I tried this PR out of curiosity and while it has a few rough edges and bug, having sketching is a huge enhancement.

@WC3D

WC3D commented Aug 9, 2026

Copy link
Copy Markdown
Author

@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!

@Formsmith746

Copy link
Copy Markdown
Owner

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!

@gogades

gogades commented Aug 10, 2026

Copy link
Copy Markdown

@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.

@Formsmith746

Copy link
Copy Markdown
Owner

Out of curiosity, what improvements have you added on your merge branch?

@gogades

gogades commented Aug 10, 2026

Copy link
Copy Markdown

@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.

WC3D added 2 commits August 10, 2026 12:23
# 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.
@WC3D

WC3D commented Aug 10, 2026

Copy link
Copy Markdown
Author

@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

  • Prevented moved sketch extrusions from snapping back.
  • Added draggable closed-profile center handles with snapping.
  • Improved disabled toolbar icon visibility.
  • Removed the Dark workspace preset and migrated saved selections to Light. (The theme was hard to read, and I prefer the SketchForge theme)
  • Added regression tests for movement, translation, and theme migration.
    Verification
  • Typecheck passed.
  • 270 unit tests passed.
  • 17 end-to-end tests passed.
  • Production build 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.

3 participants