Last active
August 29, 2015 13:56
-
-
Save jackrusher/9022760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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