       (.render renderer scene camera))))
 
 (defn magnitude
+  "Calculates the magnitude (length) of a vector."
   [v]
   (Math/sqrt (apply + (map #(* % %) v))))
 

     (/ scene-height 2)))

(defn set-position!
  [mesh [x y z]]
  (set! (.-x (.-position mesh)) x)
  (set! (.-y (.-position mesh)) y)
  (set! (.-z (.-position mesh)) z))

(defn rotate-angles!
  [mesh [x y z]]
  (set! (.-x (.-rotation mesh)) (+ (.-x (.-rotation mesh)) x))
  (set! (.-y (.-rotation mesh)) (+ (.-y (.-rotation mesh)) y))
  (set! (.-z (.-rotation mesh)) (+ (.-z (.-rotation mesh)) z)))

(defn mesh-from-particle
  [p]
  (let [geometry (THREE.SphereGeometry.
                  particle-radius particle-radius particle-radius)

    mesh))

(defn init-particles!
  "Sets up all the necessary simulation state for the particles."
  [ps]
  (reset! particles ps)
  (reset! particle-meshes (map mesh-from-particle ps)))

(defn make-renderer!
  "Creates a renderer function from the meshe objects. The resulting function
has no parameters, and completes an entire redraw of the scene when it is
called."
  [meshes]
  (let [camera (THREE.PerspectiveCamera.
                50 (/ scene-width
