         if Math.abs(z1 - z0) < eps
             z1 += 1
             z0 -= 1
-
-        mx = (x0+x1)/2
-        my = (y0+y1)/2
-        mz = (z0+z1)/2
-        @_center = @vector mx, my, mz
+        ###
+
+        min = @bounding_box.geometry.boundingBox.min
+        max = @bounding_box.geometry.boundingBox.max
+        avg = min.clone().add(max).divideScalar(2)
+        dim = max.clone().sub(min)
+
+        @_center = @vector avg.x, avg.y, avg.z
 
         if @camera?
-            d = 1.5*Math.max @aspect_ratio_scale(x1-x0, y1-y0, z1-z0)...
-            @camera.position.set mx+d, my+d, mz+d/2
+            d = 1.5*Math.max @aspect_ratio_scale(dim.x, dim.y, dim.z)...
+            @camera.position.set avg.x+d, avg.y+d, avg.z+d/2
 
         if opts.draw
-            if @frame?
-                # remove existing frame
-                for x in @frame
-                    @scene.remove x
-                delete @frame
-            @frame = []
-            # trace the edges of a cube
-            v = [[[x0,y0,z0], [x1,y0,z0], [x1,y1,z0], [x0,y1,z0], [x0,y0,z0],
-                  [x0,y0,z1], [x1,y0,z1], [x1,y1,z1], [x0,y1,z1], [x0,y0,z1]],
-                 [[x1,y0,z0], [x1,y0,z1]],
-                 [[x0,y1,z0], [x0,y1,z1]],
-                 [[x1,y1,z0], [x1,y1,z1]]]
-            for points in v
-                line = @add_line
-                    points    : points
-                    color     : opts.color
-                    thickness : opts.thickness
-                @frame.push line
+            # set the color and linewidth of the bounding box
+            @bounding_box.material.color.setRGB opts.color
+            @bounding_box.material.linewidth = opts.thickness
+
+            # add the bounding box to the scene
+            @scene.add @bounding_box
 
         if opts.draw and opts.labels
 


            @_frame_labels = []

            l = (a, b) ->
                if not b?
                    z = a
                else
                    z = (a+b)/2
                z = z.toFixed 2
                return (z*1).toString()

            txt = (x, y, z, text) =>
                @_frame_labels.push(
                    @add_text
                        pos           : [x,y,z]
                        text          : text
                        fontsize      : opts.fontsize
                        color         : opts.color
                        constant_size : false
                    )

            offset = 0.075
            if opts.draw
                e = (y1 - y0)*offset
                txt x1, y0-e, z0, l z0
                txt x1, y0-e, mz, "z=#{l z0, z1}"
                txt x1, y0-e, z1, l z1

                e = (x1 - x0)*offset
                txt x1+e, y0, z0, l y0
                txt x1+e, my, z0, "y=#{l y0, y1}"
                txt x1+e, y1, z0, l y1

                e = (y1 - y0)*offset
                txt x1, y1+e, z0, l x1
                txt mx, y1+e, z0, "x=#{l x0, x1}"
                txt x0, y1+e, z0, l x0

        v = @vector mx, my, mz
        @camera.lookAt v
        if @controls?
            @controls.target = @_center
        @render_scene()

    add_3dgraphics_obj: (opts) ->
        opts = defaults opts,
            obj       : required
            wireframe : undefined
            set_frame : undefined

        for obj in opts.obj
            switch obj.type
                when 'text'
                    delete obj.type
                    @add_text obj
                when 'index_face_set'
                    delete obj.type
                    if opts.wireframe?
                        obj.wireframe = opts.wireframe
                    @add_index_face_set obj
                    if obj.mesh and not obj.wireframe  # draw a wireframe mesh on top of the surface we just drew.
                        obj.material.color = [0, 0, 0]
                        obj.wireframe = obj.mesh
                        @add_index_face_set obj
                when 'line'
                    delete obj.type
                    @add_line obj
                when 'point'
                    delete obj.type
                    @add_point obj
                else
                    console.log "ERROR: bad object type #{obj.type}"

        if opts.set_frame?
            @set_frame opts.set_frame

        #geometry.computeVertexNormals()
        geometry.computeBoundingSphere()

        if @opts.wireframe or opts.wireframe
            if typeof opts.wireframe is 'number'
                line_width = opts.wireframe
            else if typeof @opts.wireframe is 'number'
                line_width = @opts.wireframe
            else
