function setText(node, text) { if (node) node.textContent = text; } function setHtml(node, html) { if (node) node.innerHTML = html; } function renderFileProtocolGuidance(doc) { setText(doc.querySelector('.loader-subtitle'), 'Serve this world over HTTP to initialize Three.js.'); const bootMessage = doc.getElementById('boot-message'); if (bootMessage) { bootMessage.style.display = 'block'; setHtml( bootMessage, [ 'Three.js modules cannot boot from file://.', 'Serve the Nexus over HTTP, for example:', 'python3 -m http.server 8888', ].join('
') ); } } function injectModuleBootstrap(doc, src = './bootstrap.mjs') { const script = doc.createElement('script'); script.type = 'module'; script.src = src; doc.body.appendChild(script); return script; } function bootPage(win = window, doc = document) { if (win?.location?.protocol === 'file:') { renderFileProtocolGuidance(doc); return { mode: 'file' }; } injectModuleBootstrap(doc); return { mode: 'module' }; } if (typeof window !== 'undefined' && typeof document !== 'undefined') { bootPage(window, document); } if (typeof module !== 'undefined') { module.exports = { bootPage, injectModuleBootstrap, renderFileProtocolGuidance }; }