     render_scene: (force=false) =>
         #console.log('render', @opts.element.length)
         @opts.element.show()
-        
+
         if @controls?
             @controls?.update()
         else

        #console.log("load_threejs: already loading...")
        return

    load = (script, cb) -> $.getScript(script).done(()=>cb()).fail(()=>cb("error loading"))

    async.series([
        (cb) -> load("/static/threejs/r59/three.min.js",cb)
        (cb) -> load("/static/threejs/r59/TrackballControls.js",cb)
        (cb) -> load("/static/threejs/Detector.js",cb)
        (cb) ->
            f = () ->
                if THREE?

rgb_to_hex = (r, g, b) -> "#" + component_to_hex(r) + component_to_hex(g) + component_to_hex(b)

_loading_threejs_callbacks = []

VERSION = '59'
#VERSION = '68'
$.ajaxSetup(cache: true) # when using getScript, cache result.

load_threejs = (cb) ->
    _loading_threejs_callbacks.push(cb)
    #console.log("load_threejs")
