Improve game initialization by ensuring the stage is visible before Pixi.js initialization; synchronize renderer on menu to game switch for better rendering performance.
This commit is contained in:
@@ -139,6 +139,9 @@ async function ensureMap(): Promise<void> {
|
||||
async function openWorld(id: string): Promise<void> {
|
||||
try {
|
||||
setStatus('Loading map…', 'busy');
|
||||
// Stage must be visible before Pixi init / camera.fit — a hidden host measures as 0×0 and
|
||||
// leaves the canvas stuck as a thin strip.
|
||||
showGame();
|
||||
await ensureMap();
|
||||
const map = await api.getMap(id);
|
||||
|
||||
@@ -148,10 +151,10 @@ async function openWorld(id: string): Promise<void> {
|
||||
view.showWorld(map);
|
||||
elements.worldTitle.textContent = map.name;
|
||||
elements.hud.textContent = '';
|
||||
showGame();
|
||||
setStatus('');
|
||||
await refreshWorldList();
|
||||
} catch (error) {
|
||||
showMenu();
|
||||
setStatus(`Could not open world: ${message(error)}`, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,9 @@ export class MapView {
|
||||
this.labels.clear();
|
||||
this.worldSizeMeters = map.sizeMeters;
|
||||
|
||||
// Host may have just become visible after a menu → game switch; sync the renderer before fitting.
|
||||
this.app.resize();
|
||||
|
||||
this.paintBackground();
|
||||
this.camera.fit(map.sizeMeters, this.viewport);
|
||||
this.chunks.setWorld(map.id, map.chunks);
|
||||
|
||||
Reference in New Issue
Block a user