 
 
 (defn pool-report [] 
-  (pprint/print-table   (mapv #(do {:pool %1 :stats (stats %2)}) 
+  (pprint/print-table   (mapv #(do {:pool %1 :stats (try (stats %2) (catch Exception e :error))}) 
     (into '[<>WaitCursor <>TimeLineCursor <>TweenCursor]
       (map (comp :p :pool :pair last) (filter (comp symbol? first) @REGISTRY)))
     (into [<>WaitCursor <>TimeLineCursor <>TweenCursor]
       (map (comp deref resolve :p :pool :pair last) (filter (comp symbol? first) @REGISTRY))))))
 
-(print (pool-report))
-
-
-
-
-
-
-
+(pool-report)
 
 
 
 (def run true)
 
 (defn hue [^UnityEngine.Material m ^UnityEngine.GameObject o]
-  (timeline [
-    ;(wait (+ (rand) 0.1))
-    (tween {:local 
-      {:scale (Vector3. 2.0 2.0 2.0)
-       :position (v3+ (.position (.transform o)) 
-                      (Vector3. 0.0 2.0 0.0))}} o 1.0 {:in :pow5})
-    (tween {:material-color (UnityEngine.Color. (?f) (?f) (?f))} m (float 0.5) {:in :pow3})
-    (tween {:local 
-      {:scale (Vector3. 1.0 1.0 1.0)
-       :position (v3+ (.position (.transform o)) 
-                      (Vector3. 0.0 0.0 0.0))}} o (float (rand 0.5)) :pow5)
-    
-    #(do (hue m o) nil)]))
+  (lazier-timeline (cycle [
+    (fn [] (wait (+ (rand) 0.3)))
+    (fn [] (tween {:material-color (UnityEngine.Color. (?f) (?f) (?f))} m 0.5 {:in :pow3}))
+    (fn [] (tween 
+      {:local {
+        :scale (Vector3. 2.0 2.0 2.0)
+        :position (v3+ (.position (.transform o)) 
+                       (Vector3. 0.0 2.0 0.0))}} o 1.0 {:in :pow5}))
+    ;(fn [] (wait (+ (rand) 0.1)))
+    (fn [] (tween {:material-color (UnityEngine.Color. 1 1 1)} m 0.5 {:in :pow3})) 
+    (fn [] (tween 
+     {:local {
+        :scale (Vector3. 1.0 1.0 1.0)
+        :position (v3+ (.position (.transform o)) 
+                      (Vector3. 0.0 0.0 0.0))}} o 0.5 :pow5))])))
 
 
 (defn start-demo [_] 
   (clear-cloned!)
-  (dorun (for [x (range 40) 
-               z (range 40)
+  (dorun (for [x (range 20) 
+               z (range 20)
                :let [o (clone! :ball (V* (->v3 x 0 z) 2.0)) ]]
     (hue (.material (.GetComponent o UnityEngine.Renderer)) o))) )
 
-(start-demo nil)
-
-
-(timeline [ 
+
+(defn fast-demo [_] 
+  (clear-cloned!)
+  (let [o-arr 
+        (into-array System.Object 
+          (for [x (range 20) z (range 20)
+            :let [o (clone! :ball (V* (->v3 x 0 z) 2.0)) ]] o))]
+    ) )
+
+(fast-demo nil)
+
+(lazy-timeline [ 
 (tween 
   {:light {
-    :range (float (rand 50))
+    :range (float (+ 15 (rand 50)))
     :color (color (rand-vec 1.0 1.0 1.0))}} 
-    (the lamp) 0.5 :pow4)])
-
-'(ppexpand     (tween {
+    (the lamp) 1.0 :pow4)])
+
+(start-demo nil)
+
+#_(ppexpand     (tween {
       :scale (Vector3. 2.0 2.0 2.0)
       :position (v3+ (.position (.transform (the lamp))) 
                      (Vector3. 0.0 2.0 0.0))} (the lamp) 1.0 {:in :pow5}))




(deftype TimeLineCursor [
  ^:volatile-mutable ^System.Int64    i 
  ^:volatile-mutable ^boolean         v
  ^:volatile-mutable ^System.Single overage])


(defmacro deftag [tag methods]
  (let [sym (symbol (last (re-seq #"[^\.]+" (str tag))))
        once (gensym (str "_once_" sym))
        pair-sym (symbol (str "Pair-" sym))
        wm-f #(with-meta % {:tag tag :volatile-mutable true})
        pool-m (zipmap [:p :c :r] (map (comp symbol str) ["<>" "*" "!"] (repeat pair-sym)))
        entry (conj methods {:pair {:tag pair-sym :pool pool-m}})]
    
    `(do 
        (defonce ~once 
          (do 
           ~(do (swap! REGISTRY assoc tag entry) true)
            (deftype ^:once ~pair-sym [~(wm-f 'a) ~(wm-f 'b)])))
        (def-pool 10000 ~pair-sym ~'a ~'b)
        (quote ~entry))))



(deftype ^:once WaitCursor [
  ^:volatile-mutable ^System.Single start 
  ^:volatile-mutable ^boolean       initiated])

