             @last_canvas_target = @controls.target
 
         # remove the current renderer (if it exists)
-        remove_element @opts.element.lastChild
+        remove_element @element.lastChild
 
         # place renderer in correct place in the DOM
-        @opts.element.appendChild @static_image
+        @element.appendChild @static_image
 
     # On mouseover, we switch the renderer out to use webgl, if available, and also enable spin animation.
     init_on_mouseover: ->
 
-        @opts.element.onmouseenter = =>
+        @element.onmouseenter = =>
             @set_dynamic_renderer()
 
-        @opts.element.onmouseleave = =>
+        @element.onmouseleave = =>
             @set_static_renderer()
 
-        @opts.element.onclick = =>
+        @element.onclick = =>
             @set_dynamic_renderer()
 
     # initialize functions to create new vectors, which take into account the scene's 3d frame aspect ratio.

            aspect_ratio    : undefined  # undefined does nothing or a triple [x,y,z] of length three, which scales the x,y,z coordinates of everything by the given values.
            stop_when_gone  : undefined  # if given, animation, etc., stops when this html element (not jquery!) is no longer in the DOM
            frame           : undefined  # if given call set_frame with opts.frame as input when init_done called
            cb              : undefined  # opts.cb(undefined, this object)

        load_threejs (err) =>
            if err
                msg = "Error loading THREE.js -- #{err}"
                if not opts.cb?
                    console.log msg
                else
                    opts.cb? msg
            else
                @attach_to_dom parent_element
                @opts.cb? undefined, @

    attach_to_dom: (parent_element) ->
        if @opts.element?
            remove_element @opts.element
        else
            @opts.element = document.createElement 'span'
            @opts.element.className = 'math-3d-viewer'

        parent_element.appendChild @opts.element

    # client code should call this when start adding objects to the scene
    init: ->

        @renderer_type = 'dynamic'

        # remove the current renderer (if it exists)
        remove_element @element.lastChild

        # place renderer in correct place in the DOM
        @element.appendChild @renderer.domElement

        @renderer.setClearColor @opts.background, 1
        @renderer.setSize @opts.width, @opts.height
