A high-performance, web-based CAD engine supporting both OpenSCAD and JavaScript/TypeScript. Built with modern technologies and powered by manifold-3d for guaranteed manifold geometry.
Write CAD models in your preferred language:
difference() {
cube([20, 20, 10]);
translate([10, 10, 0])
sphere(8, $fn=32);
}import { Shape } from 'moicad';
const box = Shape.cube([20, 20, 10]);
const hole = Shape.sphere(8, { $fn: 32 }).translate([10, 10, 0]);
export default box.subtract(hole);📚 Complete JavaScript API Documentation: See JAVASCRIPT_API.md
Modern Bun Monorepo (Restructured January 2026)
moicad/
├── packages/
│ ├── sdk/ # @moicad/sdk - Core CAD engine (publishable npm package)
│ │ ├── src/
│ │ │ ├── shape.ts # Fluent API: Shape.cube(10)
│ │ │ ├── functional.ts # Functional API: cube(10)
│ │ │ ├── scad/ # OpenSCAD parser & evaluator
│ │ │ ├── manifold/ # Manifold-3d CSG integration
│ │ │ ├── viewport/ # Three.js viewport component
│ │ │ ├── animation/ # GIF/video export (NEW!)
│ │ │ ├── interactive/ # Click/hover interactions (NEW!)
│ │ │ └── plugins/ # Extensibility system
│ │ └── dist/ # Built npm package
│ │
│ ├── landing/ # @moicad/landing - Next.js 16 web app
│ │ ├── app/
│ │ │ ├── page.tsx # Landing page
│ │ │ ├── demo/ # Interactive CAD editor
│ │ │ ├── docs/ # Auto-generated API docs
│ │ │ └── api/ # API routes (evaluate, parse, export)
│ │ ├── components/demo/ # UI components (Editor, Viewport, TopMenu, etc.)
│ │ ├── hooks/ # React hooks (useAnimation, useInteraction)
│ │ ├── lib/ # Three.js utilities, API client
│ │ └── scripts/ # Build scripts (Bun module fix)
│ │
│ ├── desktop/ # Tauri desktop app (optional)
│ └── shared/ # Minimal shared types
│
├── backend/ # ⚠️ NEEDS MIGRATION - Bun server (currently broken)
│ ├── core/ # Server infrastructure
│ ├── mcp/ # MCP server & collaboration
│ └── middleware/ # HTTP middleware
│
└── examples/ # Example code
├── javascript/ # JavaScript API examples
└── openscad/ # OpenSCAD examples
Tech Stack:
- Runtime: Bun (TypeScript/JavaScript) + Node.js (Vercel)
- Languages: OpenSCAD + JavaScript/TypeScript ⚡
- CSG Engine: manifold-3d (WebAssembly npm package)
- SDK: Publishable npm package (@moicad/sdk v0.1.8)
- Backend: API routes in Next.js (backend/ needs SDK migration)
- Frontend: Next.js 16 + React 19 + Three.js
- Desktop: Tauri (optional)
- Deployment: Vercel (with npm workaround for Bun bug)
Modern CAD programming with 10-20x better performance:
- ✅ Full API: All OpenSCAD features + classes, async/await, npm packages
- ✅ Type Safety: Complete TypeScript definitions with IntelliSense
- ✅ Two Styles: Fluent (OOP) and Functional (FP) APIs
- ✅ Performance: 1.6ms vs 32ms for simple cube (20x faster!)
- ✅ Modern: ES6+, imports/exports, parametric classes
- ✅ Documented: 400+ line API guide + 6 working examples
Quick Example:
import { Shape } from 'moicad';
class Bolt {
constructor(length, diameter) {
this.length = length;
this.diameter = diameter;
}
build() {
const shaft = Shape.cylinder(this.length, this.diameter / 2);
const head = Shape.cylinder(this.diameter * 0.7, this.diameter * 0.9, { $fn: 6 })
.translate([0, 0, this.length]);
return shaft.union(head);
}
}
export default new Bolt(20, 6).build();📚 Learn More:
- Complete API Documentation - 400+ line reference
- Examples - 6 complete examples
- Status Report - Implementation details
Primitives
- ✅ cube, sphere, cylinder, cone
- ✅ circle, square, polygon, polyhedron
- ✅ text (ASCII characters, basic Latin)
- ✅ surface (heightmap import)
Transformations
- ✅ translate, rotate, scale, mirror
- ✅ multmatrix (4x4 custom transforms)
CSG Operations
- ✅ union, difference, intersection
- ✅ hull (convex hull)
- ✅ minkowski (Minkowski sum)
2D Operations
- ✅ linear_extrude, rotate_extrude
- ✅ offset (expand/contract polygons)
- ✅ projection (3D → 2D)
Language Features
- ✅ Variables, functions, modules
- ✅ Conditionals (if/else), loops (for)
- ✅ Expressions, operators (arithmetic, logical, ternary)
- ✅ List comprehensions
- ✅ Built-in functions (math, array, string)
- ✅ File imports (include, use)
- ✅ Special variables ($fn, $fa, $fs, $t, $vpr, $vpt, $preview, etc.)
- ✅ OpenSCAD modifiers (#, %, !, *)
Interactive Features
- ✅ Real-time hover highlighting
- ✅ Click selection, multi-select
- ✅ Code-to-geometry mapping
- ✅ Professional Blender-style UI
Model Context Protocol (MCP)
- Expose moicad as an MCP server for Claude Desktop
- AI agents can evaluate OpenSCAD code
- Real-time geometry generation from natural language
- Integration with other AI tools
- Bun v1.0+ (for development)
- Node.js v18+ (for Vercel deployment)
# Clone repository
git clone https://github.com/yourusername/moicad.git
cd moicad
# Install dependencies (monorepo root)
bun install# Build SDK first (required)
cd packages/sdk
bun run build
# Start web app (http://localhost:3000)
cd ../landing
bun run dev
# Or build SDK + start landing in one command
cd packages/landing
bun run build # prebuild hook builds SDK automatically# Build SDK
cd packages/sdk
bun run build
# Build landing (Next.js)
cd ../landing
bun run build
# Start production server
bun run startSee VERCEL_DEPLOYMENT.md for detailed instructions.
Quick setup:
- Import repo to Vercel
- Set root directory to
packages/landing - Vercel auto-detects Next.js and uses npm (via vercel.json)
- Build succeeds automatically!
Note: A postinstall script automatically fixes Bun's module installation bug on both local and Vercel builds.
# Test SDK
cd packages/sdk
bun test
# Test landing
cd packages/landing
bun run test
# Full test suite (from root)
bun run test:allPOST /api/parse Parse OpenSCAD code to AST.
Request: { "code": "cube(10);" }
Response: { "ast": [...], "errors": [], "success": true }POST /api/evaluate Parse and evaluate to 3D geometry.
Request: { "code": "sphere(10);" }
Response: {
"geometry": {
"vertices": [...],
"indices": [...],
"normals": [...],
"bounds": { "min": [...], "max": [...] },
"stats": { "vertexCount": N, "faceCount": N, "volume": V }
},
"errors": [],
"success": true,
"executionTime": 45.2
}POST /api/export Export geometry to STL or OBJ.
Request: { "geometry": {...}, "format": "stl" }
Response: Binary STL fileWS /ws Real-time code evaluation.
Client → Server: { "type": "evaluate", "code": "cube(10);", "requestId": "abc123" }
Server → Client: { "type": "evaluate_response", "requestId": "abc123", "geometry": {...} }WS /ws/mcp Model Context Protocol for AI integration.
Claude Desktop can connect to moicad as an MCP server to evaluate OpenSCAD code and generate geometry.
Add to your Claude Desktop MCP configuration (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"moicad": {
"command": "bun",
"args": ["run", "/path/to/moicad/backend/index.ts"],
"env": {
"MCP_ENABLED": "true"
}
}
}
}Now Claude can generate 3D models by writing OpenSCAD code!
# Start Tauri development mode
bun run tauri:dev
# Build desktop executable
bun run tauri:build- CLAUDE.md - Developer guide for AI agents (project context)
- MIGRATION.md - Monorepo restructuring (January 2026)
- VERCEL_DEPLOYMENT.md - Deployment guide & Bun bug workaround
- BUILD_GUIDE.md - Detailed build instructions
- JAVASCRIPT_API.md - Complete JavaScript API documentation
- packages/sdk/README.md - SDK usage guide
- IMPLEMENTATION_STATUS.md - Feature implementation status
- MANIFOLD_MIGRATION_COMPLETE.md - Manifold-3d migration
- ANIMATION_DESIGN.md - Animation system design
- RESTRUCTURING_COMPLETE.md - Monorepo restructure details
Why monorepo with packages/?
- SDK is publishable to npm independently (@moicad/sdk)
- Landing app uses SDK as dependency
- Clear separation: engine vs. UI
- Desktop app can also use SDK
- Easier to maintain and test
Why manifold-3d?
- Guaranteed manifold output (no topology errors)
- Robust Boolean operations (replaces custom BSP tree)
- High performance with parallel processing
- Clean geometry eliminates rendering artifacts
- Available as npm WebAssembly package
Why Bun + npm hybrid?
- Bun for development (fast, modern)
- npm for Vercel deployment (reliable)
- Bun v1.3.7 has workspace bug (missing package.json in symlinks)
- Automatic postinstall script fixes Bun's installation
- Best of both worlds
Why Three.js (not custom WebGL)?
- Manifold-3d provides clean geometry
- No BSP artifacts = no custom renderer needed
- Standard Three.js works perfectly
- Better ecosystem and community support
Why Next.js API routes (not separate backend)?
- Simpler deployment (single Vercel project)
- API routes handle evaluate/parse/export
- Can add WebSocket via custom server later
- Backend server currently broken, needs SDK migration
Comprehensive test suite with 98-99% OpenSCAD compatibility:
- Unit tests: Primitives, transformations, CSG operations, language features
- Integration tests: API endpoints, WebSocket, file imports
- Performance benchmarks: Rendering speed, memory usage
- Validation tests: OpenSCAD compatibility verification
Contributions welcome! Please read COLLABORATION_GUIDE.md for details.
MIT License - see LICENSE for details.
- OpenSCAD - The original inspiration
- manifold-3d - Robust CSG geometry engine
- Three.js - 3D rendering library
- Bun - Fast JavaScript runtime
- Model Context Protocol - AI integration standard
Built with ❤️ using modern JavaScript technologies