Skip to content

Instantly share code, notes, and snippets.

@gzmask
Last active June 25, 2020 18:23
Show Gist options
  • Save gzmask/a84211db6f805f3c7be018a259cba03f to your computer and use it in GitHub Desktop.
Save gzmask/a84211db6f805f3c7be018a259cba03f to your computer and use it in GitHub Desktop.
3d model csg
{:entities
[{:type union
:entities [{:type :sphere
:diameter 6
:transformations {:translate {:x 6}
:rotate-x 1}}
{:type :cube
:width 10
:length 10
:transformations {:scale {:size 0.5}}}]}
]}
(def union
(let [sphere* (.transformed sphere (.. Transform
(unity)
(translateX 3)))
cps (.transformed cube-plus-sphere (.. Transform
(unity)
(translateX 6)))
cms (.transformed cube-minus-sphere (.. Transform
(unity)
(translateX 9)))
cis (.transformed cube-intersect-sphere (.. Transform
(unity)
(translateX 12)))
cpf (.transformed cube-plus-figure (.. Transform
(unity)
(translateX 15)))]
(.. cube
(union sphere*)
(union cms)
(union cis)
(union cpf)
(union cps))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment