Improve tile-loading

This commit is contained in:
Lukas Rieger (Blue) 2022-09-02 22:08:00 +02:00
parent 211127e76b
commit a3de6f9122
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
1 changed files with 2 additions and 12 deletions

View File

@ -192,21 +192,11 @@ export class TileManager {
this.tiles.set(tileHash, tile);
tile.load(this.tileLoader)
.then(() => {
if (!tile.unloaded)
this.tileMap.setTile(tile.x - this.centerTile.x + TileManager.tileMapHalfSize, tile.z - this.centerTile.y + TileManager.tileMapHalfSize, TileMap.LOADED);
if (this.loadTimeout) clearTimeout(this.loadTimeout);
this.loadTimeout = setTimeout(this.loadCloseTiles, 0);
})
.catch(error => {
if (error.status && error.status === "empty") return;
if (error.target && error.target.status === 404) return;
if (error.type && error.type === "abort") return;
//alert(this.events, "Failed to load tile: " + error.type, "warning");
})
.catch(error => {})
.finally(() => {
//this.tileMap.setTile(tile.x - this.centerTile.x + TileManager.tileMapHalfSize, tile.z - this.centerTile.y + TileManager.tileMapHalfSize, TileMap.LOADED);
this.currentlyLoading--;
});
@ -214,7 +204,7 @@ export class TileManager {
}
handleLoadedTile = tile => {
//this.tileMap.setTile(tile.x - this.centerTile.x + TileManager.tileMapHalfSize, tile.z - this.centerTile.y + TileManager.tileMapHalfSize, TileMap.LOADED);
this.tileMap.setTile(tile.x - this.centerTile.x + TileManager.tileMapHalfSize, tile.z - this.centerTile.y + TileManager.tileMapHalfSize, TileMap.LOADED);
this.scene.add(tile.model);
this.onTileLoad(tile);