VibeCad Model Author
Create or modify parametric 3D models for VibeCad Studio using OpenSCAD.
Project Context
VibeCad Studio is a browser-based parametric CAD workbench. Models are written in OpenSCAD (.scad files) and compiled to STL via openscad-wasm. Models are auto-discovered — no manual registration needed.
Model File Structure
Each model lives in src/models/<slug>/ with a single file:
src/models/<slug>/model.scad
scad1// Description shown on the home page gallery 2length = 40; // [10:100] 3width = 30; // [5:80] 4height = 20; // [5:60] 5 6cube([length, width, height]);
Conventions:
- First line:
// commentbecomes the model description for the gallery - Parameters:
name = value; // [min:max]orname = value; // [min:step:max]become UI sliders - The folder name becomes the slug, which is auto-converted to a display name (
example-box→Example Box)
Key Conventions
- Parameter names should be
snake_caseand descriptive (e.g.wall_thickness, notwt) - All parameter values are numbers
- Use
$fnfor controlling curve resolution (32 is a good default) - Keep models manifold (watertight) for 3D printing compatibility
OpenSCAD Quick Reference
3D Primitives
scad1cube([x, y, z]); // box 2cube([x, y, z], center=true); // centered box 3sphere(r=radius, $fn=64); // sphere 4cylinder(h=height, r=radius, $fn=32); // cylinder 5cylinder(h=height, r1=bot, r2=top, $fn=32); // cone/frustum
2D Primitives (for extrusion)
scad1square([w, h]); 2square([w, h], center=true); 3circle(r=radius, $fn=64); 4polygon(points=[[x1,y1], [x2,y2], ...]); 5text("hello", size=10);
Transformations
scad1translate([x, y, z]) { ... } 2rotate([rx, ry, rz]) { ... } // degrees 3scale([sx, sy, sz]) { ... } 4mirror([x, y, z]) { ... } 5color("red") { ... } 6color([r, g, b, a]) { ... }
Boolean Operations
scad1union() { a(); b(); } // combine shapes 2difference() { a(); b(); } // subtract b from a 3intersection() { a(); b(); } // keep overlap only
Extrusions
scad1linear_extrude(height=h, twist=deg, scale=s) { 2d_shape(); } 2rotate_extrude(angle=360, $fn=64) { 2d_profile(); }
Hull & Minkowski
scad1hull() { a(); b(); } // convex hull 2minkowski() { a(); b(); } // Minkowski sum (rounding)
Modules (reusable components)
scad1module rounded_box(size, radius) { 2 minkowski() { 3 cube([size[0]-2*radius, size[1]-2*radius, size[2]/2]); 4 cylinder(r=radius, h=size[2]/2, $fn=32); 5 } 6} 7 8rounded_box([40, 30, 20], 3);
Loops & Conditionals
scad1for (i = [0:5]) { translate([i*10, 0, 0]) cube(5); } 2for (a = [0:60:300]) { rotate([0, 0, a]) translate([20, 0, 0]) sphere(3); } 3if (wall > 0) { difference() { outer(); inner(); } }
Useful Patterns
scad1// Hollow box (shell) 2difference() { 3 cube([outer_w, outer_d, outer_h]); 4 translate([wall, wall, wall]) 5 cube([outer_w - 2*wall, outer_d - 2*wall, outer_h]); 6} 7 8// Rounded edges via minkowski 9minkowski() { 10 cube([w - 2*r, d - 2*r, h/2]); 11 cylinder(r=r, h=h/2, $fn=32); 12} 13 14// Circular pattern 15for (i = [0:n-1]) { 16 rotate([0, 0, i * 360/n]) 17 translate([radius, 0, 0]) 18 child_shape(); 19}
Workflow
When creating a new model:
- Read 1-2 existing models for reference patterns
- Create the folder:
mkdir -p src/models/<slug>/ - Write
src/models/<slug>/model.scad - Run
node scripts/verify-model.js src/models/<slug>/model.scadto verify - If errors, fix and re-run until exit code 0
When modifying an existing model:
- Read the current model.scad
- Make the requested changes
- Run
node scripts/verify-model.js src/models/<slug>/model.scadto verify
Tips
- Start simple, iterate. A basic cube is better than a broken complex shape.
- OpenSCAD error messages include line numbers — use them to pinpoint issues.
minkowski()is expensive — use it sparingly and with low-poly shapes.$fncontrols facet count: higher = smoother but slower. 32 for cylinders, 64 for spheres.difference()subtracts all children after the first from the first child.- Use
center=trueon primitives to simplify positioning. - The dev server supports HMR — model changes appear live in the browser.
Existing Models for Reference
| Model | Slug | Techniques |
|---|---|---|
| Example Box | example-box | minkowski rounding, difference for hollow interior, parametric dimensions |