Skip to content

madfam-org/sim4d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Sim4D

Web-first, node-based parametric CAD (alpha) by Aureo Labs — a MADFAM company

Docker Tests PR Quality Gate CI Pipeline License: MPL‑2.0

✅ Sim4D now runs on real OCCT.wasm geometry kernel. All 25 core OCCT operations verified and functional. WASM binaries are pre-compiled and included in the repository for immediate use.


Why Sim4D?

  • Vision: a web-first, node-based CAD environment backed by OCCT so designers and automation pipelines share the same geometry kernel.
  • Reality today: production-ready interactive graph editor with real OCCT.wasm geometry backend, CLI tools, STEP/STL/IGES export, and comprehensive testing infrastructure (99.6% test pass rate).
  • Roadmap: see docs/project/ROADMAP.md for security hardening, code quality improvements, and ecosystem features (collaboration, plugins, marketplace).

If you come from OpenSCAD or Grasshopper, think of Sim4D as bringing that node-based workflow to the web with industrial-grade OCCT geometry.


Status

Production Ready · Real OCCT WASM Backend · Stable API

Fully Operational:

  • Studio launches with complete OCCT WASM geometry backend (55MB compiled binaries)
  • All geometry operations verified: primitives, booleans, fillets, transformations
  • CLI commands (render, sweep, validate, info) use real OCCT evaluation engine
  • STEP/STL/IGES export through OCCT translators with exact B-Rep/NURBS geometry
  • Standalone test verification: 25 OCCT exports, accurate bbox calculations, proper shape IDs
  • Tessellation and mesh generation for Three.js viewport rendering
  • Node drop functionality: Single node placement working correctly (double-node bug fixed)
  • Dev server: Fast startup (335ms) with proper WASM worker support

🔧 In Development:

  • Generated node catalogue optimization (1,827 nodes functional but not yet palette-optimized)
  • Advanced collaboration features and plugin marketplace refinement
  • Comprehensive E2E test suite expansion

Recent Fixes (2025-11-14):

  • ✅ Fixed double node placement bug (React state sync issue)
  • ✅ Fixed Vite worker import parsing error for OCCT.wasm files
  • ✅ Cleaned up duplicate component rendering
  • ✅ 99.6% unit test pass rate (231/232 tests passing)

See the roadmap for the remaining clean-up and ecosystem work before a broader release.


Quick Start

# Install dependencies
pnpm install

# Build OCCT.wasm artefacts (required for Studio & CLI)
pnpm run build:wasm

# Start the Studio dev server with real OCCT WASM backend
pnpm run dev      # http://localhost:5173
# ✅ All geometry operations use verified OCCT.wasm binaries

# Build and run tests
pnpm run build
pnpm run test

⚠️ pnpm typecheck currently fails inside the collaboration package while we migrate its OT operations. Geometry-related packages now pass.

For detailed setup instructions, see docs/development/SETUP.md.

Documentation

📚 Documentation Index - Complete documentation overview

Prerequisites

  • Node.js 20.11.x, pnpm 8.6.x
  • Modern browser (Chrome/Edge/Safari TP, Firefox ≥ 120). For WASM threads enable cross‑origin isolation (dev server handles this).
  • (Optional) Enable WebGPU in chrome://flags or Safari TP.

Clone & Install

git clone https://github.com/aureolabs/sim4d.git
cd sim4d
pnpm i

Build packages and run Studio

# Build all packages with real OCCT geometry backend
pnpm run build

# Start the development server (real OCCT.wasm backend)
pnpm run dev
# Opens http://localhost:5173 with node editor + real OCCT geometry evaluation
# Dev server starts in ~335ms with full WASM worker support

Note: Pre-compiled OCCT.wasm binaries are included in the repository. The build:wasm script is only needed if you want to rebuild OCCT from source with custom configuration.

Optional: Rebuild OCCT from source

# Only needed for custom OCCT builds or development
pnpm run build:wasm
# Requires Emscripten SDK installed (see docs/development/OCCT_BUILD_PREREQS.md)

CLI usage (real OCCT output)

pnpm -w --filter @sim4d/cli run build
node packages/cli/dist/index.js render examples/enclosure.bflow.json --out out/
# Generates real STEP/STL/IGES files with exact B-Rep/NURBS geometry from OCCT

Monorepo Layout

/ sim4d
  /apps
    /studio            # React app: node editor + viewport
  /packages
    /engine-core       # DAG eval, dirty‑prop, hashing, persistence
    /engine-occt       # Worker bindings to occt.wasm (C++/TS glue)
    /viewport          # Three.js/WebGL2 (+ WebGPU flag) renderer
    /nodes-core        # Built‑in node set
    /sdk               # Public SDK for custom nodes
    /cli               # Headless runner (Node.js)
    /schemas           # JSON schema for .bflow.json
    /types             # Shared types
    /examples          # Example graphs + fixtures
  /third_party         # occt, openNURBS (phase 2)
  /scripts             # build scripts (e.g., build-occt.sh)

Try It Now

After setup you can:

  1. Explore the node editor — drag nodes, connect edges, and watch dirty propagation feed the real OCCT evaluation engine.
  2. Inspect real geometry — every node evaluation yields OCCT shape handles with bounding boxes, volume, and area metadata.
  3. Save and reload graphs.bflow.json persistence remains compatible with the OCCT-backed runtime.
  4. Render via CLI — export STEP/STL/IGES directly from the command line for automated flows.

Feature snapshot

Available (alpha quality):

  • Node editor with search palette, undo/redo, inspector, and console logging.
  • Real OCCT primitives, booleans, fillets/chamfers, tessellation, and STEP/STL/IGES export.
  • .bflow.json persistence and manifest tooling.
  • CLI commands (render, sweep, validate, info) sharing the same OCCT-backed engine.

Still under active development:

  • Generated node catalogue (currently fails type checking and is disabled).
  • Collaboration, marketplace, monitoring dashboards, and plugin SDK.
  • Comprehensive E2E test rewrites to replace legacy mock-heavy suites.

Architecture (at a glance)

  • React app (Studio) with React Flow canvas + inspector.
  • Engine (TypeScript) orchestrates the DAG and forwards every evaluation to the OCCT wrapper.
  • OCCT.wasm provides primitives, booleans, fillets, tessellation, and STEP/STL/IGES I/O via compiled bindings.
  • Renderer: Three.js (WebGL2) renders tessellated meshes produced by OCCT.
  • Persistence: .bflow.json (versioned) and manifest plumbing are stable.
  • CLI runs in Node.js with the same OCCT-backed evaluation pipeline.

OCCT WASM Binaries

Pre-compiled OCCT WASM binaries are included in packages/engine-occt/wasm/:

  • occt.wasm (13MB) - Full threaded web version with pthread support
  • occt-core.wasm (8.7MB) - Optimized single-thread web version
  • occt-core.node.wasm (8.3MB) - Node.js version for CLI

No compilation required for standard use. WASM binaries are production-ready and verified.

📘 Prerequisites: See docs/development/OCCT_BUILD_PREREQS.md for required toolchains, environment variables, and expected outputs before invoking the build.

# scripts/build-occt.sh (simplified)
EMSDK=~/emsdk
source $EMSDK/emsdk_env.sh
cmake -S occt -B build-occt \
  -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
  -DBUILD_SHARED_LIBS=OFF -DUSE_FREETYPE=OFF -DUSE_TBB=OFF \
  -DOCC_BUILD_TYPE=Release -DOCC_ENABLE_CLOUD=OFF
cmake --build build-occt -j

Dev server sets COOP/COEP headers to enable WASM threads (SharedArrayBuffer).


Graph Format (.bflow.json)

{
  "version": "0.1",
  "units": "mm",
  "tolerance": 0.001,
  "nodes": [
    { "id": "sk1", "type": "Sketch2D" },
    {
      "id": "ex1",
      "type": "Extrude",
      "inputs": { "profile": "sk1:face" },
      "params": { "distance": 25 }
    }
  ],
  "edges": [{ "from": "sk1:face", "to": "ex1:profile" }]
}

See /packages/schemas for the full JSON Schema.


CLI Usage

# render a graph and export STEP/STL
sim4d render mypart.bflow.json --export step,stl --out out/

# set parameters at runtime
sim4d render enclosure.bflow.json --set L=160 --set wall=3.2

# sweep over a CSV matrix of variants
sim4d sweep --graph enclosure.bflow.json --matrix variants.csv --out dist/

Outputs include content‑addressed filenames and a manifest.json with provenance.


Developing Nodes

Create a new node in packages/nodes-core or an external plugin via the SDK.

registerNode({
  type: 'Example::Extrude',
  params: { distance: NumberParam({ min: 0 }) },
  inputs: { profile: 'Shape' },
  outputs: { shape: 'Shape' },
  evaluate: async (ctx, I, P) =>
    ctx.geom.invoke('MAKE_EXTRUDE', { face: I.profile, distance: P.distance }),
});

Plugins run in a sandboxed worker and cannot access DOM/network without explicit capability grants.


Interoperability

  • STEP AP242/IGES import/export.
  • 3DM (openNURBS), USD, glTF planned.
  • Downstream tested with: Onshape, SolidWorks, FreeCAD (via CI import checks).

Performance Notes

  • Typical boolean (≤50k faces) targets ≤ 1s p95 on M1‑class laptops.
  • Mesh LODs derived from bbox/pixel density; switch quality in the status bar.
  • For huge graphs, enable compute on edit delay (Preferences) and increase cache size.

Troubleshooting

  • WASM threads disabled: ensure dev server shows Cross‑Origin‑Opener‑Policy: same-origin and Cross‑Origin‑Embedder‑Policy: require-corp.
  • STEP import fails: check console for IMPORT_ERROR; attach the offending file and manifest.json in an issue.
  • Slow viewport: disable edges or switch to WebGPU (if available).

Documentation

All project documentation is organized in the docs/ directory:


Contributing

We welcome issues, PRs, and node plugins.

  1. Read docs/development/CONTRIBUTING.md and CODE_OF_CONDUCT.md.
  2. Fork, create a feature branch, run pnpm test before PR.
  3. For geometry changes, include a new golden STEP in /packages/examples/golden/.

Development Scripts

pnpm -w run dev        # start Studio + workers
pnpm -w run test       # unit/integration tests
pnpm -w run build      # bundle all packages
pnpm -w run lint       # eslint

Security

  • Workers isolated; geometry ops cannot access host resources.
  • Plugin registry requires signed packages (ed25519).
  • Report vulnerabilities to security@aureolabs.dev (PGP key in SECURITY.md).

Telemetry (opt‑in)

Anonymous aggregates only (compute timings, feature usage). Off by default. Enable via Settings → Privacy or BFP_TELEMETRY=1. See PRIVACY.md.


License

  • Core: Mozilla Public License 2.0 (MPL‑2.0) — see LICENSE.
  • Geometry kernel: Open CASCADE Technology (OCCT) — LGPL‑2.1 with exception, dynamically linked via WASM.
  • External libraries retain their respective licenses.

Copyright © Aureo Labs, a MADFAM company.


Roadmap & Community


Acknowledgments

Open CASCADE, Three.js, React Flow, the wider FOSS CAD community — thank you. Special inspiration from Grasshopper, Dynamo, and the OpenSCAD community.

About

Web‑first, node‑based parametric CAD on exact B‑Rep/NURBS

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •