 
 # Macros
 # should work as normal functions, as well
-tileIndexByTileMacro = (tile) ->
-
-  tile[0] * (1 << @TEXTURE_SIZE_P - @cube.BUCKET_SIZE_P) + tile[1]
+tileIndexByTileMacro = (_this, tile) ->
+
+  tile[0] * (1 << @TEXTURE_SIZE_P - _this.cube.BUCKET_SIZE_P) + tile[1]
 
 
 subTileMacro = (tile, index) ->

    bucket[@U] += tile[0]
    bucket[@V] += tile[1]

    destOffset = bufferOffsetByTileMacro(tile, @cube.BUCKET_SIZE_P)
    sourceOffset = ((@volumeTexture.layer >> @volumeTexture.zoomStep) & (1 << @cube.BUCKET_SIZE_P) - 1)  << @DELTA[@W]

    bucketData = @cube.getVolumeBucketByZoomedAddress(bucket)

  [(tile[0] << 1) + (index % 2), (tile[1] << 1) + (index >> 1)]


bufferOffsetByTileMacro = (_this, tile, tileSize) ->

  tile[0] * (1 << tileSize) + tile[1] * (1 << tileSize) * (1 << _this.TEXTURE_SIZE_P)


class Plane2D
