// Serve one pinned viewer bundle for every newly reconstructed scene. const fs = require('node:fs'); const path = require('node:path'); (async () => { const {html, css, js} = await import('@playcanvas/supersplat-viewer'); const anchor = 'const { app, camera, renderer } = await createApp(canvas, config);'; if (!js.includes(anchor)) throw new Error('Unsupported SuperSplat viewer version'); const patched = js.replace(anchor, anchor + '\n app.scene.gsplat.minPixelSize = 0;\n app.scene.gsplat.minContribution = 0;') .replaceAll('gsplat.minContribution = 1;', 'gsplat.minContribution = 0;'); const target = process.argv[2]; fs.mkdirSync(target, {recursive: true}); for (const [name, value] of Object.entries({'index.js': patched, 'index.css': css, 'viewer.html': html})) { fs.writeFileSync(path.join(target, name), value); } })().catch(error => { console.error(error.message); process.exit(1); });