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

                               (direction dir (magnitude (:vel pb)))))))))))

(defn motion-tick!
  []
  (doseq [i (range particle-count)]
    (let [p (nth @particles i)

     (/ scene-height 2)))

(defn set-position!
  "Convenience function for changing the position of an object. This just wraps
some of the three.js javascriptiness."
  [mesh [x y z]]
  (set! (.-x (.-position mesh)) x)
  (set! (.-y (.-position mesh)) y)
  (set! (.-z (.-position mesh)) z))

(defn rotate-angles!
  "Convenience function for rotating an object. This just wraps some of the
three.js javascriptiness."
  [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
  "Builds a three.js mesh from the particle."
  [p]
  (let [geometry (THREE.SphereGeometry.
                  particle-radius particle-radius particle-radius)
