A 3D CAD environment powered by turtle graphics and ClojureScript. Create 3D models using an intuitive, programmable approach inspired by Logo.
Try it now in your browser — no installation required!
Ridley combines the simplicity of turtle graphics with powerful 3D modeling capabilities. Write Clojure code to define shapes, extrude profiles along paths, and create complex geometry through boolean operations.
Key Features:
- Turtle-based modeling: Move, turn, and place geometry in 3D space
- Shape extrusion: Sweep 2D profiles along arbitrary paths
- Loft with transformations: Scale, rotate, and morph shapes during extrusion
- Path recording: Define reusable movement sequences with loops and conditionals
- Boolean operations: Union, difference, and intersection via Manifold WASM
- Live REPL: Interactive development with command history
# Install dependencies
npm install
# Start development server
npx shadow-cljs watch app
# Open http://localhost:9000The interface has two panels:
- Definitions (top-left): Define reusable shapes, paths, and functions. Press
Cmd+Enterto evaluate. - REPL (bottom-left): Execute commands interactively. Press
Enterto run,↑↓for history.
;; Movement
(f 30) ; Move forward 30 units
(th 90) ; Turn horizontal (yaw) 90°
(tv 45) ; Turn vertical (pitch) 45°
(tr 30) ; Turn roll 30°
;; 3D Primitives
(box 20) ; Cube
(box 30 20 10) ; Rectangular box
(sphere 15) ; Sphere
(cyl 10 30) ; Cylinder
(cone 15 5 25) ; Cone (r1, r2, height)Create 3D geometry by extruding 2D shapes along the turtle's path:
;; Basic cylinder
(extrude (circle 10) (f 30))
;; Rectangle extruded with a turn
(extrude (rect 20 10) (f 20) (th 45) (f 20))
;; Cone via loft (shape transforms during extrusion)
(loft (circle 20) #(scale %1 (- 1 %2)) (f 30))
;; Twisted extrusion
(loft (rect 20 10) #(rotate-shape %1 (* %2 90)) (f 40))Record movement sequences for reuse:
;; Define a square path
(def square-path (path (dotimes [_ 4] (f 20) (th 90))))
;; Extrude along the path
(extrude (circle 5) square-path)
;; Create a closed torus
(extrude-closed (circle 5) square-path)Combine meshes using CSG operations (requires Manifold WASM):
;; Create two overlapping shapes
(box 20)
(def a (last-mesh))
(f 10)
(sphere 15)
(def b (last-mesh))
;; Boolean operations
(mesh-union a b) ; Combine
(mesh-difference a b) ; Subtract
(mesh-intersection a b) ; Intersect| Shape | Description |
|---|---|
(circle r) |
Circle with radius r |
(circle r n) |
Circle with n points |
(rect w h) |
Rectangle w×h |
(polygon pts) |
Custom polygon from points |
(star n outer inner) |
Star with n points |
Use these in loft transform functions:
(scale shape factor) ; Uniform scale
(scale shape fx fy) ; Non-uniform scale
(rotate-shape shape angle) ; Rotate (degrees)
(translate shape dx dy) ; Translate shape
(morph shape-a shape-b t) ; Interpolate between shapes
(resample shape n) ; Resample to n pointssrc/ridley/
├── core.cljs # Application entry point, UI handling
├── editor/
│ └── repl.cljs # SCI-based code evaluation
├── turtle/
│ ├── core.cljs # Turtle state and movement
│ ├── shape.cljs # 2D shape constructors
│ ├── path.cljs # Path utilities
│ └── transform.cljs # Shape transformations
├── geometry/
│ ├── primitives.cljs # Box, sphere, cylinder, cone
│ ├── operations.cljs # Extrude, revolve, sweep, loft
│ └── faces.cljs # Face identification
├── viewport/
│ └── core.cljs # Three.js rendering
└── manifold/
└── core.cljs # Manifold WASM integration
- ClojureScript - Language
- shadow-cljs - Build tool
- SCI - Small Clojure Interpreter for REPL
- Three.js - 3D rendering
- Manifold - Mesh boolean operations (WASM)
# Watch mode with hot reload
npx shadow-cljs watch app
# Production build
npx shadow-cljs release app
# REPL connection
npx shadow-cljs cljs-repl appSee dev-docs/Examples.md for comprehensive examples including:
- Basic turtle drawing
- 3D primitives
- Shape extrusion and sweeping
- Loft with transformations
- Closed extrusions (torus-like shapes)
- Manifold boolean operations
MIT
