view: refactor generic parts of MapView into a TileView
This commit is contained in:
parent
272e37a408
commit
af04cbe359
5 changed files with 103 additions and 62 deletions
|
@ -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) {
|
||||
|
|
Reference in a new issue