Files
martinfencl.eu/locenice2/js/bootstrap.js
T
martin.fencl ba7790daba
continuous-integration/drone/push Build is passing
feat: Add legacy shaders, model I/O, and project panel functionality
- Introduced `legacy-shaders.js` containing vertex and fragment shaders for rendering.
- Implemented `model-io.js` for parsing and encoding GLB files, ensuring compatibility with glTF 2.0.
- Created `project-panel.js` to manage project resources and survey overlays, enhancing user interaction.
- Added `solar.js` for calculating solar positions based on UTC time, latitude, and longitude.
- Developed `three-renderer.js` as a standard backend for Three.js, managing scene rendering and material synchronization.
- Included a new GLB model `dum.glb` for testing and demonstration purposes.
- Established `data_checks.mjs` for validating model data and ensuring integrity of assets.
- Created `prepare_export.py` to facilitate Blender GLB exports, maintaining material and node references.
- Added `vendor_three.py` to download and configure a local version of Three.js for the project.
2026-10-22 01:04:21 +02:00

24 lines
2.1 KiB
JavaScript

/** 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';
}