Skip to content

Instantly share code, notes, and snippets.

@madhephaestus
Last active September 8, 2015 15:50
Show Gist options
  • Save madhephaestus/96ebd49463ef37862ecb to your computer and use it in GitHub Desktop.
Save madhephaestus/96ebd49463ef37862ecb to your computer and use it in GitHub Desktop.
(import '[eu.mihosoft.vrl.v3d CSG Cube Sphere Transform]))
(defn translate-x
"Translates a csg in the x direction"
[csg n]
(.transformed csg (. (Transform/unity) translateX n)))
(defn union-all
[& objs]
(reduce (fn [a b] (.union a b)) objs))
(let [cube (.toCSG (Cube. 2))
sphere (.toCSG (Sphere. 1.25))
csg (union-all cube
(translate-x sphere 3)
(translate-x (.union cube sphere) 6)
(translate-x (.difference cube sphere) 9)
(translate-x (.intersect cube sphere) 12))]
(spit "/home/hephaestus/example.stl" (.toStlString csg)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment