diff --git a/app.js b/app.js index 46b6e0c1..5eec7f19 100644 --- a/app.js +++ b/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');