fix: #1536 - Portal hot-reload from portals.json
This commit is contained in:
27
app.js
27
app.js
@@ -735,6 +735,33 @@ async function init() {
|
||||
addChatMessage('error', 'Portal registry offline. Check logs.');
|
||||
}
|
||||
|
||||
// Hot-reload portals.json every 5 seconds
|
||||
let lastPortalHash = '';
|
||||
setInterval(async () => {
|
||||
try {
|
||||
const response = await fetch('./portals.json?' + Date.now());
|
||||
const text = await response.text();
|
||||
const hash = text.length + '-' + text.slice(0, 100);
|
||||
|
||||
if (hash !== lastPortalHash && lastPortalHash !== '') {
|
||||
console.log('[Portal Hot-Reload] portals.json changed, reloading...');
|
||||
const portalData = JSON.parse(text);
|
||||
|
||||
// Remove existing portals from scene
|
||||
portals.forEach(p => scene.remove(p));
|
||||
portals.length = 0;
|
||||
|
||||
// Create new portals
|
||||
createPortals(portalData);
|
||||
addChatMessage('system', `Portals hot-reloaded: ${portalData.length} portals active`);
|
||||
}
|
||||
|
||||
lastPortalHash = hash;
|
||||
} catch (e) {
|
||||
// Silent fail - file might not be available
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
// Load Vision Points
|
||||
try {
|
||||
const response = await fetch('./vision.json');
|
||||
|
||||
Reference in New Issue
Block a user