Vendored
+23
@@ -0,0 +1,23 @@
|
||||
/** Only application startup. All paths are relative to /locenice/index.php. */
|
||||
async function json(path){const response=await fetch(path,{cache:'no-cache'});if(!response.ok)throw Error(path+' / HTTP '+response.status);return response.json();}
|
||||
try{
|
||||
const config=await json('./data/app-config.json');
|
||||
const [catalog,assets,references,scene,site]=await Promise.all([config.catalog,config.assets,config.references,config.sceneMetadata,config.site].map(json));
|
||||
const response=await fetch(config.model);if(!response.ok)throw Error('Model / HTTP '+response.status);
|
||||
const modelBytes=new Uint8Array(await response.arrayBuffer());
|
||||
config.threeModule=new URL(config.threeModule,location.href).href;config.threeLoader=new URL(config.threeLoader,location.href).href;
|
||||
// The standard GLTFLoader imports the same pinned Three.js copy.
|
||||
const map=document.createElement('script');map.type='importmap';map.textContent=JSON.stringify({imports:{three:config.threeModule}});document.head.appendChild(map);
|
||||
const hash=location.hash;
|
||||
if(hash.startsWith('#vyber='))try{
|
||||
let text=hash.slice(7).replace(/-/g,'+').replace(/_/g,'/');text+='='.repeat((4-text.length%4)%4);
|
||||
if(text.length>32000)throw Error('Too large');const bytes=Uint8Array.from(atob(text),ch=>ch.charCodeAt(0));const payload=JSON.parse(new TextDecoder().decode(bytes));
|
||||
if(payload.schema!=='allstav-rd-config'||payload.version!==1||!payload.selection)throw Error('Invalid selection');
|
||||
document.getElementById('stdSavedState').textContent=JSON.stringify({selection:payload.selection});
|
||||
}catch(error){console.warn('Invalid shared selection:',error);}
|
||||
window.LOCENICE_RESOURCES={config,catalog,assets,references,scene,site,modelBytes};
|
||||
await import('./app.js');
|
||||
}catch(error){
|
||||
console.error(error);const box=document.getElementById('loading');box.className='error';box.innerHTML='<div class="errorDetail"></div><p>Nahrajte celou slozku vcetne js, css, data, models a assets. Otevrete ji pres HTTP(S), nikoli dvojklikem na HTML.</p><a href="./models/dum.glb" download>Stahnout model GLB</a>';
|
||||
box.querySelector('.errorDetail').textContent=error.message;document.getElementById('webStatus').textContent='Chyba nacitani';
|
||||
}
|
||||
Reference in New Issue
Block a user