creates grid in provider, not in renderer
This commit is contained in:
parent
bec012103c
commit
9a6f3dd76d
@ -231,6 +231,12 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
this.renderer.firstTileCoords = {coord: this._tiles[min.k].coord, pos:this.getTilePos(this._tiles[min.k].coord)};
|
||||
ctx.setTransform(1, 0, 0, 1, this.renderer.firstTileCoords.pos.x, this.renderer.firstTileCoords.pos.y);
|
||||
|
||||
var valsPerTile = 256/this.options.resolution;
|
||||
this.renderer.globalGrid = Array.apply(null, Array(this.renderer.tileDimensions.h * valsPerTile)).map(Number.prototype.valueOf,0);
|
||||
for (var i = 0; i < this.renderer.globalGrid.length; i++){
|
||||
this.renderer.globalGrid[i] = Array.apply(null, Array(this.renderer.tileDimensions.w * valsPerTile)).map(Number.prototype.valueOf,0);
|
||||
}
|
||||
|
||||
for(t in this._tiles) {
|
||||
tile = this._tiles[t];
|
||||
if (tile) {
|
||||
|
@ -215,23 +215,15 @@ var contour = require('./contour');
|
||||
|
||||
_gridData: function(tile){
|
||||
var valsPerTile = this.TILE_SIZE/this.options.resolution;
|
||||
// baseIndex is the distance to the upper left corner of the grid, in cells
|
||||
var baseIndex = {
|
||||
x: (tile.coord.x - this.firstTileCoords.coord.x) * valsPerTile,
|
||||
y: (tile.coord.y - this.firstTileCoords.coord.y) * valsPerTile
|
||||
}
|
||||
|
||||
this.globalGrid = Array.apply(null, Array(this.tileDimensions.h * valsPerTile)).map(Number.prototype.valueOf,0);
|
||||
for (var i = 0; i < this.globalGrid.length; i++){
|
||||
this.globalGrid[i] = Array.apply(null, Array(this.tileDimensions.w * valsPerTile)).map(Number.prototype.valueOf,0);
|
||||
}
|
||||
|
||||
// to do invert
|
||||
for(var i =0; i < tile.renderData.length; i++){
|
||||
for(var i = 0; i < tile.renderData.length; i++){
|
||||
var x = tile.x[i], y = tile.y[i];
|
||||
if(!this.globalGrid[baseIndex.y + y/this.options.resolution]){
|
||||
this.globalGrid[baseIndex.y + y/this.options.resolution] = [];
|
||||
}
|
||||
this.globalGrid[baseIndex.y + y/this.options.resolution][baseIndex.y + x/this.options.resolution] = tile.renderData[i];
|
||||
this.globalGrid[baseIndex.y + (256 - y)/this.options.resolution-1][baseIndex.x + x/this.options.resolution] = tile.renderData[i];
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user