mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 10:35:16 +01:00
Set fallback void color to black, pause high fps redraws if nothing changes to save GPU usage
This commit is contained in:
parent
c69b31ce84
commit
6d3774f24e
@ -113,6 +113,9 @@ export class MapViewer {
|
|||||||
this.markers = new MarkerSet("bm-root");
|
this.markers = new MarkerSet("bm-root");
|
||||||
|
|
||||||
this.lastFrame = 0;
|
this.lastFrame = 0;
|
||||||
|
this.lastRedrawChange = 0;
|
||||||
|
events.addEventListener("bluemapCameraMoved", () => this.lastRedrawChange = Date.now())
|
||||||
|
events.addEventListener("bluemapTileLoaded", () => this.lastRedrawChange = Date.now())
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
this.initializeRootElement();
|
this.initializeRootElement();
|
||||||
@ -272,7 +275,6 @@ export class MapViewer {
|
|||||||
// calculate delta time
|
// calculate delta time
|
||||||
if (this.lastFrame <= 0) this.lastFrame = now;
|
if (this.lastFrame <= 0) this.lastFrame = now;
|
||||||
let delta = now - this.lastFrame;
|
let delta = now - this.lastFrame;
|
||||||
this.lastFrame = now;
|
|
||||||
|
|
||||||
// update stats
|
// update stats
|
||||||
this.stats.begin();
|
this.stats.begin();
|
||||||
@ -283,7 +285,10 @@ export class MapViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// render
|
// render
|
||||||
this.render(delta);
|
if (delta >= 1000 || Date.now() - this.lastRedrawChange < 1000) {
|
||||||
|
this.lastFrame = now;
|
||||||
|
this.render(delta);
|
||||||
|
}
|
||||||
|
|
||||||
// update stats
|
// update stats
|
||||||
this.stats.update();
|
this.stats.update();
|
||||||
|
@ -63,7 +63,7 @@ export class Map {
|
|||||||
name: id,
|
name: id,
|
||||||
startPos: {x: 0, z: 0},
|
startPos: {x: 0, z: 0},
|
||||||
skyColor: new Color(),
|
skyColor: new Color(),
|
||||||
voidColor: new Color(),
|
voidColor: new Color(0, 0, 0),
|
||||||
ambientLight: 0,
|
ambientLight: 0,
|
||||||
hires: {
|
hires: {
|
||||||
tileSize: {x: 32, z: 32},
|
tileSize: {x: 32, z: 32},
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
import { Vector2, Scene, Group } from 'three';
|
import { Vector2, Scene, Group } from 'three';
|
||||||
import { Tile } from './Tile.js';
|
import { Tile } from './Tile.js';
|
||||||
import {alert, hashTile} from '../util/Utils.js';
|
import {alert, dispatchEvent, hashTile} from '../util/Utils.js';
|
||||||
import {TileMap} from "./TileMap";
|
import {TileMap} from "./TileMap";
|
||||||
|
|
||||||
export class TileManager {
|
export class TileManager {
|
||||||
@ -194,6 +194,11 @@ export class TileManager {
|
|||||||
this.tiles.set(tileHash, tile);
|
this.tiles.set(tileHash, tile);
|
||||||
tile.load(this.tileLoader)
|
tile.load(this.tileLoader)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
dispatchEvent(this.events, "bluemapTileLoaded", {
|
||||||
|
tileManager: this,
|
||||||
|
tile: tile
|
||||||
|
});
|
||||||
|
|
||||||
if (this.loadTimeout) clearTimeout(this.loadTimeout);
|
if (this.loadTimeout) clearTimeout(this.loadTimeout);
|
||||||
this.loadTimeout = setTimeout(this.loadCloseTiles, 0);
|
this.loadTimeout = setTimeout(this.loadCloseTiles, 0);
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user