                  x-event (-> d3 (.extent datoms #(:x %)))
                  y-event (-> d3 (.extent datoms #(:y %)))
                  z-event (-> d3 (.extent datoms #(:z %)))
-                 x-scale (-> d3 .-scale (.linear) (.domain x-event) (.range [0 100]))
-                 y-scale (-> d3 .-scale (.linear) (.domain y-event) (.range [0 100]))
-                 z-scale (-> d3 .-scale (.linear) (.domain z-event) (.range [0 100]))
+                 x-scale (-> d3 .-scale (.linear) (.domain x-event) (.range [-50 50]))
+                 y-scale (-> d3 .-scale (.linear) (.domain y-event) (.range [-50 50]))
+                 z-scale (-> d3 .-scale (.linear) (.domain z-event) (.range [-50 50]))
                  vpts {:x-max (nth x-event 1)
-                       :x-center (/ (+ (nth x-event 1)
-                                       (nth x-event 0)) 2)
+                       :x-cen (/ (+ (nth x-event 1)
+                                    (nth x-event 0)) 2)
                        :x-min (nth x-event 0)
                        :y-max (nth y-event 1)
-                       :y-center (/ (+ (nth y-event 1)
-                                       (nth y-event 0)) 2)
+                       :y-cen (/ (+ (nth y-event 1)
+                                    (nth y-event 0)) 2)
                        :y-min (nth y-event 0)
                        :z-max (nth z-event 1)
-                       :z-center (/ (+ (nth z-event 1)
-                                       (nth z-event 0)) 2)
+                       :z-cen (/ (+ (nth z-event 1)
+                                    (nth z-event 0)) 2)
                        :z-min (nth z-event 0)}
-                 vs [(v (x-scale (:x-min vpts)) (y-scale (:y-center vpts)) (z-scale (:z-center vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-center vpts)) (z-scale (:z-center vpts)))
-                     (v (x-scale (:x-center vpts)) (y-scale (:y-min vpts)) (z-scale (:z-center vpts))) (v (x-scale (:x-center vpts)) (y-scale (:y-max vpts)) (z-scale (:z-center vpts)))
-                     (v (x-scale (:x-center vpts)) (y-scale (:y-center vpts)) (z-scale (:z-max vpts))) (v (x-scale (:x-center vpts)) (y-scale (:y-center vpts)) (z-scale (:z-min vpts)))
-
+                 vs [(v (x-scale (:x-min vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-cen vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-cen vpts)))
+                     (v (x-scale (:x-cen vpts)) (y-scale (:y-min vpts)) (z-scale (:z-cen vpts))) (v (x-scale (:x-cen vpts)) (y-scale (:y-max vpts)) (z-scale (:z-cen vpts)))
+                     (v (x-scale (:x-cen vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-max vpts))) (v (x-scale (:x-cen vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-min vpts)))
                      (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts)))
                      (v (x-scale (:x-min vpts)) (y-scale (:y-min vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-min vpts)) (z-scale (:z-min vpts)))
                      (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-max vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-max vpts)))
                      (v (x-scale (:x-min vpts)) (y-scale (:y-min vpts)) (z-scale (:z-max vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-min vpts)) (z-scale (:z-max vpts)))
-
-                     (v (x-scale (:x-min vpts)) (y-scale (:y-center vpts)) (z-scale (:z-max vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-center vpts)) (z-scale (:z-max vpts)))
-                     (v (x-scale (:x-min vpts)) (y-scale (:y-center vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-center vpts)) (z-scale (:z-min vpts)))
-                     (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-center vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-center vpts)))
-                     (v (x-scale (:x-min vpts)) (y-scale (:y-min vpts)) (z-scale (:z-center vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-min vpts)) (z-scale (:z-center vpts)))
-
+                     (v (x-scale (:x-min vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-max vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-max vpts)))
+                     (v (x-scale (:x-min vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-min vpts)))
+                     (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-cen vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-cen vpts)))
+                     (v (x-scale (:x-min vpts)) (y-scale (:y-min vpts)) (z-scale (:z-cen vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-min vpts)) (z-scale (:z-cen vpts)))
                      (v (x-scale (:x-max vpts)) (y-scale (:y-min vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts)))
                      (v (x-scale (:x-min vpts)) (y-scale (:y-min vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts)))
                      (v (x-scale (:x-max vpts)) (y-scale (:y-min vpts)) (z-scale (:z-max vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-max vpts)))
                      (v (x-scale (:x-min vpts)) (y-scale (:y-min vpts)) (z-scale (:z-max vpts))) (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-max vpts)))
-
-                     (v (x-scale (:x-center vpts)) (y-scale (:y-min vpts)) (z-scale (:z-max vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts)))
-                     (v (x-scale (:x-center vpts)) (y-scale (:y-min vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts)))
-                     (v (x-scale (:x-max vpts)) (y-scale (:y-min vpts)) (z-scale (:z-center vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-max vpts)))
-                     (v (x-scale (:x-min vpts)) (y-scale (:y-min vpts)) (z-scale (:z-center vpts))) (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-max vpts)))
-
+                     (v (x-scale (:x-cen vpts)) (y-scale (:y-min vpts)) (z-scale (:z-max vpts))) (v (x-scale (:x-cen vpts)) (y-scale (:y-max vpts)) (z-scale (:z-max vpts)))
+                     (v (x-scale (:x-cen vpts)) (y-scale (:y-min vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-cen vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts)))
+                     (v (x-scale (:x-max vpts)) (y-scale (:y-min vpts)) (z-scale (:z-cen vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-cen vpts)))
+                     (v (x-scale (:x-min vpts)) (y-scale (:y-min vpts)) (z-scale (:z-cen vpts))) (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-cen vpts)))
                      (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-max vpts)) (z-scale (:z-max vpts)))
                      (v (x-scale (:x-max vpts)) (y-scale (:y-min vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-min vpts)) (z-scale (:z-max vpts)))
                      (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-min vpts)) (y-scale (:y-max vpts)) (z-scale (:z-max vpts)))
                      (v (x-scale (:x-min vpts)) (y-scale (:y-min vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-min vpts)) (y-scale (:y-min vpts)) (z-scale (:z-max vpts)))
-
-                     (v (x-scale (:x-min vpts)) (y-scale (:y-center vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-min vpts)) (y-scale (:y-center vpts)) (z-scale (:z-max vpts)))
-                     (v (x-scale (:x-max vpts)) (y-scale (:y-center vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-center vpts)) (z-scale (:z-max vpts)))
-                     (v (x-scale (:x-center vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-center vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts)))
-                     (v (x-scale (:x-center vpts)) (y-scale (:y-min vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-center vpts)) (y-scale (:y-min vpts)) (z-scale (:z-max vpts)))
+                     (v (x-scale (:x-min vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-min vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-max vpts)))
+                     (v (x-scale (:x-max vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-max vpts)) (y-scale (:y-cen vpts)) (z-scale (:z-max vpts)))
+                     (v (x-scale (:x-cen vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-cen vpts)) (y-scale (:y-max vpts)) (z-scale (:z-min vpts)))
+                     (v (x-scale (:x-cen vpts)) (y-scale (:y-min vpts)) (z-scale (:z-min vpts))) (v (x-scale (:x-cen vpts)) (y-scale (:y-min vpts)) (z-scale (:z-max vpts)))
                      ]]
              (println vpts)
              (.log js/console (count vs))

(def l (log/get-logger "3d"))
(strokes/bootstrap)

(defn ^:private v [x y z]
  (js/THREE.Vector3. x y z))


;; ref: http://bl.ocks.org/phil-pedruco/9852362
(defcomponent plot-view
  [app owner]
  (init-state
   [_]
   (let [w 960 h 500
         line-geo (js/THREE.Geometry.)
         line-material (js/THREE.LineBasicMaterial.  (clj->js  {:color 0x000000
                                                                :lineWidth 2}))]

      :h h
      :shadow-datoms (atom [])
      :datoms (atom [])
      :sx 0
      :sy 0
      :down false
      }))
  (will-mount
   [_]
