Skip to content

Instantly share code, notes, and snippets.

@aamedina
Created June 17, 2013 14:19
Show Gist options
  • Save aamedina/5797235 to your computer and use it in GitHub Desktop.
Save aamedina/5797235 to your computer and use it in GitHub Desktop.
(defn -main [& args]
(let [camera-options
(atom {:fov 75 :width js/window.innerWidth
:height js/window.innerHeight :near 0.1 :far 1000})
{:keys [fov width height near far]} @camera-options
camera (PerspectiveCamera. fov (/ width height) near far)
scene (Scene.)
renderer (Renderer.)
container (-> (sel1 :body)
(dommy/set-style! :background-color "#000")
(dommy/append! (.-domElement renderer)))
geometry (CubeGeometry. 1 1 1)
material (MeshBasicMaterial. (clj->js {:color 0x00ff00}))
lambert-material (MeshLambertMaterial. (clj->js {:color 0xcc0000}))
cube (Mesh. geometry lambert-material)
sphere-options (atom {:radius 75 :segmentsWidth 28 :segmentsHeight 28})
{:keys [radius segmentsWidth segmentsHeight]} @sphere-options
sphere-geometry (SphereGeometry. 1)
sphere (Mesh. sphere-geometry lambert-material)
light-options (atom {:position {:x 10 :y 50 :z 130}})
light-source (PointLight. 0xffffff)
particle-system (generate-particles 800)]
(doto light-source (setup @light-options))
(doto scene (setup [particle-system light-source camera]))
(doto camera (setup {:position {:z 3}}))
(doto renderer (setup {:width width :height height}))
(animate renderer scene camera [// animatables go here])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment