view: refactor generic parts of MapView into a TileView

This commit is contained in:
Matthias Schiffer 2018-10-31 14:24:38 +01:00
parent 272e37a408
commit af04cbe359
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
5 changed files with 103 additions and 62 deletions

View file

@ -1,4 +1,6 @@
import {mapValues, mapValuesAsync, nextPowerOf2} from '../util';
import { mapValues, mapValuesAsync, nextPowerOf2 } from '../util';
import { TileCoords } from './tile';
import MapState from '../model/state/MapState';
import MapView from './MapView';
@ -6,7 +8,7 @@ import Renderer from './renderer/Renderer';
export interface TileMap {
texture: WebGLTexture;
tiles: Map<string, [number, number, number, number]>;
tiles: Map<string, TileCoords>;
}
function loadImage(url: string): Promise<HTMLImageElement> {
@ -54,7 +56,7 @@ function mkTileMap(
canvas.width = canvas.height = canvasSize;
let x = 0, y = 0;
const map: Map<string, [number, number, number, number]> = new Map();
const map: Map<string, TileCoords> = new Map();
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
for (const [k, tile] of tiles) {