         mesh.load_from_va_ia va, ia
         mesh.elements = []
         mesh.materials = [@material]
-        mesh.color = color4.new 1,1,1,1 # TODO FIXME plain shader
         mesh.data.draw_method = render_manager.gl.LINES
         mesh.scale = vec3.new 1,1,1
         mesh._update_matrices()

        bone.load_from_lists(d, [0,1,0,2,0,3,0,4,1,2,2,3,3,4,4,1,
                           5,1,5,2,5,3,5,4])

        @material = mat = new Material @context, '_debug', {
            material_type: 'PLAIN_SHADER'
            vertex: plain_vs,
            fragment: plain_fs,
            uniforms: [{varname:'color', value: color4.create()}],
        }

        for ob in [box, cylinder, cone, sphere, arrow, bone]
            ob.elements = []
            ob.stride = 4
            ob.materials = [mat]
            ob.color = color4.new 1,1,1,1
            ob.data.draw_method = @context.render_manager.gl.LINES
            ob.scale = {x: 1, y:1, z:1}
            ob.rotation_order = 'Q'

                    # visible pass
                    gl.disable gl.BLEND
                    gl.enable gl.DEPTH_TEST
                    color4.set color, 1, 1, 1, 1
                    @draw_mesh dob, dob.world_matrix
                if ob != cam and ob.type == 'CAMERA'
                    dob = @debug.box
                    # Draw camera with frustum of far=1
                    {near_plane, far_plane} = ob
                    ob.near_plane = 1e-4
                    ob.far_plane = 1
                    ob.recalculate_projection()
                    mat4.invert mm4, ob.projection_matrix
                    mat4.mul mm4, ob.world_matrix, mm4
                    ob.near_plane = near_plane
                    ob.far_plane = far_plane
                    ob.recalculate_projection()

                    # occluded pass
                    color4.set color, 1, 1, 1, .2
                    gl.enable gl.BLEND
                    gl.disable gl.DEPTH_TEST
                    @draw_mesh dob, mm4

                    # visible pass
                    gl.disable gl.BLEND
                    gl.enable gl.DEPTH_TEST
                    color4.set color, 1, 1, 1, 1
                    @draw_mesh dob, mm4

                    # Draw whole frustum
                    mat4.invert mm4, ob.projection_matrix
                    mat4.mul mm4, ob.world_matrix, mm4

                    # occluded pass
                    color4.set color, 1, 1, 1, .1
                    gl.enable gl.BLEND
                    gl.disable gl.DEPTH_TEST
                    @draw_mesh dob, mm4

                    # visible pass
                    gl.enable gl.DEPTH_TEST
                    color4.set color, 1, 1, 1, .5
                    @draw_mesh dob, mm4
                    gl.disable gl.BLEND

            gl.disable gl.DEPTH_TEST
            for dvec in @debug.vectors
