Skip to content

Instantly share code, notes, and snippets.

@jackrusher
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackrusher/9022760 to your computer and use it in GitHub Desktop.
Save jackrusher/9022760 to your computer and use it in GitHub Desktop.
(def stl-test (decode stl-codec (to-buf-seq (nio/mmap "data/duck.stl"))))
(defn setup []
(frame-rate 5)
(smooth))
(defn draw []
(frame-rate 5)
(background 20)
(no-stroke)
(fill 255)
(translate (/ (width) 2) (/ (height) 2) -10)
(rotate-z (radians 180))
(rotate-y (radians -50))
(scale 0.2)
(lights)
(directional-light 215 0 0 -10 -10 -10)
(begin-shape :triangles)
(texture (load-image "data/duck-cm.jpg"))
(doseq [{:keys [v1 v2 v3]} (:shape stl-test)]
(apply vertex v1)
(apply vertex v2)
(apply vertex v3))
(end-shape)
(display-filter :blur 0.85))
(defsketch stl-sketch
:title "3D"
:setup setup
:draw draw
:size [800 600]
:key-pressed #(when (= (key-code) 32) (save-frame))
:renderer :p3d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment