                         @mesh_by_id[id] = alt
 
     debug_xy: (x, y) ->
-        x = (x*@w)|0
-        y = ((1-y)*@h)|0
+        x = (x*@width)|0
+        y = ((1-y)*@height)|0
         @debug_x = x
         @debug_y = y
 

            @imagedata.data.set(@pixels)
            d = @imagedata.data
            i = 3
            for y in [0...@h]
                for x in [0...@w]
                    d[i] = if x == @debug_x or y == @debug_y
                        0
                    else

    constructor: (@context, options={}) ->
        {@debug_canvas, @width=512, @height=256,
            @max_distance=10, @render_steps=8, @wait_steps=3} = options
        @buffer = new Framebuffer(@context.render_manager, @width, @height, @context.render_manager.gl.UNSIGNED_BYTE)
        @pixels = new Uint8Array(@width * @height * 4)
        @pixels16 = new Uint16Array(@pixels.buffer)
        @distance = 0
        @alpha_treshold = 0.5
