                                                                                   material
                                                                                   tex-coord-0)
                                                                         (:inputs program)))]
-                                    ;;(js/console.log (clj->js diffuse))
-                                    ;;(js/console.log (clj->js scene-data))
-                                    ;;(js/console.log (clj->js program))
+                                    ;;(js/console.log (pr-str program-name))
                                     ;; Check for normals so we don't try to draw e.g. lines right now.
-                                    (when normals
-                                      (try
-                                        (driver/draw-elements driver program
-                                                              (assoc scene-data
-                                                                     {:tag :element-index} indices)
-                                                              {:draw-mode (:draw-mode mesh)
-                                                               :count     draw-count})
-                                        (catch js/Error e
-                                          nil))))))
+                                    (when (and diffuse normals)
+                                      (gd/draw-elements driver (gd/bind driver program
+                                                                        (assoc scene-data
+                                                                               {:tag :element-index} indices))
+                                                        {:draw-mode (:draw-mode mesh)
+                                                         :count     draw-count})))))
                               (doseq [child (vals (:children node))]
                                 (render-node [(:name child) child] mv))))]
       (doseq [node (:nodes scene)]


(def v-tex-coord-0
  (g/varying "v_texcoord0" :vec2 :highp))

;; precision highp float;
;; varying vec3 v_normal;
;; uniform vec4 u_diffuse;
;; void main(void) {
;; vec3 normal = normalize(v_normal);
;; vec4 color = vec4(0., 0., 0., 0.);
;; vec4 diffuse = vec4(0., 0., 0., 1.);
;; diffuse = u_diffuse;
;; diffuse.xyz *= max(dot(normal,vec3(0.,0.,1.)), 0.);
;; color.xyz += diffuse.xyz;
;; color = vec4(color.rgb * diffuse.a, diffuse.a);
;; gl_FragColor = color;
;; }


(def u-light-angle
  (g/uniform "uLightAngle" :vec3))

        height           (.-clientHeight node)
        driver           (make-driver gl)
        starting-program 0
        programs         {:diffuse-flat  program-diffuse-flat
                          :diffuse-light program-diffuse-light
                          :texture-flat  program-texture-flat
                          :texture-light program-texture-light}
        state            (-> (app-state width height)
                             (assoc-in [:runtime :programs] programs)
                             (assoc-in [:runtime :current-program] 0))]
