stack3js 0.0.0-stage → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/COMMAND.md +145 -0
  2. package/LICENSE +21 -0
  3. package/README.md +304 -2
  4. package/THIRD-PARTY-LICENSES.md +100 -0
  5. package/bin/stack3.mjs +5437 -0
  6. package/blender/import_stack.py +89 -0
  7. package/examples/future-tank.stack3.json +1 -0
  8. package/examples/traffic-cone-4view.png +0 -0
  9. package/meshing/blocks.py +82 -0
  10. package/meshing/branches.py +62 -0
  11. package/meshing/dexel.py +67 -0
  12. package/meshing/field_data.py +19 -0
  13. package/meshing/finish_blender.py +203 -0
  14. package/meshing/finishing.py +155 -0
  15. package/meshing/geometry.py +71 -0
  16. package/meshing/guided.py +150 -0
  17. package/meshing/implicit.py +178 -0
  18. package/meshing/intersection.py +33 -0
  19. package/meshing/material.py +115 -0
  20. package/meshing/mesh.py +103 -0
  21. package/meshing/network.py +136 -0
  22. package/meshing/regularization.py +213 -0
  23. package/meshing/sections.py +165 -0
  24. package/meshing/signed_distance.py +93 -0
  25. package/package.json +32 -4
  26. package/references/hard-surface/README.md +40 -0
  27. package/references/hard-surface/atlas/concrete-barrier-4view.png +0 -0
  28. package/references/hard-surface/atlas/preview.pipeline.yaml +14 -0
  29. package/references/hard-surface/case-studies/benchmark/README.md +22 -0
  30. package/references/hard-surface/case-studies/benchmark/lod-bevel.pipeline.yaml +258 -0
  31. package/references/hard-surface/finishing/exports.yaml +10 -0
  32. package/references/hard-surface/finishing/finish-lod.pipeline.yaml +33 -0
  33. package/references/hard-surface/finishing/inputs/stack/stack.json +1 -0
  34. package/references/hard-surface/finishing/inputs/stack/stack.png +0 -0
  35. package/references/hard-surface/finishing/regularize.pipeline.yaml +46 -0
  36. package/references/hard-surface/measured-depth/sdf/compare.pipeline.yaml +12 -0
  37. package/references/hard-surface/measured-depth/sdf/inputs/field.npy +0 -0
  38. package/references/hard-surface/measured-depth/sdf/inputs/stack/stack.json +1 -0
  39. package/references/hard-surface/measured-depth/sdf/inputs/stack/stack.png +0 -0
  40. package/references/hard-surface/measured-depth/sdf/inputs/truth.json +1 -0
  41. package/references/hard-surface/measured-depth/sdf/sdf.guide.json +3 -0
  42. package/references/hard-surface/measured-depth/triple-dexel/compare.pipeline.yaml +12 -0
  43. package/references/hard-surface/measured-depth/triple-dexel/dexel.guide.json +3 -0
  44. package/references/hard-surface/measured-depth/triple-dexel/inputs/fixture.json +22 -0
  45. package/references/hard-surface/measured-depth/triple-dexel/inputs/stack/stack.json +22 -0
  46. package/references/hard-surface/measured-depth/triple-dexel/inputs/stack/stack.png +0 -0
  47. package/references/hard-surface/measured-depth/triple-dexel/inputs/triple-dexel.npz +0 -0
  48. package/references/hard-surface/schema/pipeline-fragment.schema.json +5 -0
  49. package/references/hard-surface/schema/pipeline.schema.json +181 -0
  50. package/schema/pipeline-fragment.schema.json +5 -0
  51. package/schema/pipeline.schema.json +181 -0
  52. package/verification/assembly.py +96 -0
  53. package/verification/landmarks.py +53 -0
  54. package/verification/panels.py +137 -0
  55. package/verification/projections.py +135 -0
  56. package/verification/verify.py +108 -0
  57. package/viewer/dist/THIRD-PARTY-LICENSES.md +174 -0
  58. package/viewer/dist/assets/GLTFExporter-xdVCArY-.js +1 -0
  59. package/viewer/dist/assets/ant-mech-angled-leg-4view-BO2qt1_k.png +0 -0
  60. package/viewer/dist/assets/ant-mech-body-4view-D9xVPpbc.png +0 -0
  61. package/viewer/dist/assets/ant-mech-center-leg-4view-BcphjF_G.png +0 -0
  62. package/viewer/dist/assets/compare-B6DWTZS9.css +1 -0
  63. package/viewer/dist/assets/compare-Du4RoRQO.js +6 -0
  64. package/viewer/dist/assets/compare.worker-CgJq-znx.js +21 -0
  65. package/viewer/dist/assets/concrete-barrier-4view-7PsO3Ftq.png +0 -0
  66. package/viewer/dist/assets/emscripten-module-uFzwHH0Y.wasm +0 -0
  67. package/viewer/dist/assets/emscripten-module.browser-BcR5qphc.js +1 -0
  68. package/viewer/dist/assets/ffi-Boa1QuFa.js +1 -0
  69. package/viewer/dist/assets/fillet-rover-body-4-view-Chk8Mx4R.png +0 -0
  70. package/viewer/dist/assets/fillet-rover-wheel-4-view-B-F8flOC.png +0 -0
  71. package/viewer/dist/assets/hull-4view-BPPqJYUz.png +0 -0
  72. package/viewer/dist/assets/hull-base-color-4view-DrQmdT3h.png +0 -0
  73. package/viewer/dist/assets/hull-clay-4view-3Cu-4Hvr.png +0 -0
  74. package/viewer/dist/assets/hull-depth-4view-DCOdT5ev.png +0 -0
  75. package/viewer/dist/assets/hull-normal-4view-CvLaFITy.png +0 -0
  76. package/viewer/dist/assets/inspection-robot-body-4-view-CLMaHFYm.png +0 -0
  77. package/viewer/dist/assets/inspection-robot-wheel-4-view-27wRsxcs.png +0 -0
  78. package/viewer/dist/assets/plastic-barrier-4view-DQkTBW_i.png +0 -0
  79. package/viewer/dist/assets/presets-jXE0t1fU.js +1 -0
  80. package/viewer/dist/assets/preview-cache-BKV0EZl9.js +1 -0
  81. package/viewer/dist/assets/project-BzR9Ensg.css +1 -0
  82. package/viewer/dist/assets/project-DtHHhfo-.js +17 -0
  83. package/viewer/dist/assets/reconstruct.worker-ONc9GyFO.js +21 -0
  84. package/viewer/dist/assets/script-engine-Bs3azDYZ.js +6 -0
  85. package/viewer/dist/assets/style-CMUT8CmM.css +1 -0
  86. package/viewer/dist/assets/style-D6eZHs3D.js +4004 -0
  87. package/viewer/dist/assets/tank-hull-4view-B4sMMkP5.png +0 -0
  88. package/viewer/dist/assets/tank-track-4view-DAIiMTy3.png +0 -0
  89. package/viewer/dist/assets/tank-turret-4view-Cx0FuNFu.png +0 -0
  90. package/viewer/dist/assets/traffic-cone-4view-DG-TkITx.png +0 -0
  91. package/viewer/dist/assets/viewer-DIjS0No7.js +2 -0
  92. package/viewer/dist/assets/wet-floor-sign-4view-CWJDyeTX.png +0 -0
  93. package/viewer/dist/compare.html +47 -0
  94. package/viewer/dist/examples/traffic-cone-4view.png +0 -0
  95. package/viewer/dist/index.html +148 -0
  96. package/viewer/dist/playground/index.html +3342 -0
  97. package/viewer/dist/project.html +83 -0
@@ -0,0 +1,6 @@
1
+ import{G as ae,b as P,p as oe,V as y,W as he,O as we,e as fe,C as be,q as $,r as ye,A as Me,M as ne,g as ve,L as re,s as xe,t as Le,u as Ze}from"./style-D6eZHs3D.js";import{m as Se,D as De,i as We,c as Be}from"./presets-jXE0t1fU.js";const A=e=>document.getElementById(e),se=A("comparison-status"),Q=A("atlas"),w=A("part"),X=A("yaw"),V=A("pitch"),z=A("zoom"),D=A("layers"),F=A("spacing"),M=A("explode"),Y=A("clay"),Ke=document.querySelector(".compare-results"),le=new URLSearchParams(location.search),E=le.get("session"),O=E&&/^[a-f0-9-]{36}$/.test(E)?"./__stack3_project/"+E:void 0;let L,v=0,N,ge,k,R=[],Ie,U=1;const _=new y;let Ce=[],T=0;const ee="top,left,front,rear",W={layers:De,resolution:144},q=Se.tank,ce="Future Tank · hull material passes",S={source:new URL(""+new URL("hull-4view-BPPqJYUz.png",import.meta.url).href,import.meta.url),clay:new URL(""+new URL("hull-clay-4view-3Cu-4Hvr.png",import.meta.url).href,import.meta.url),depth:new URL(""+new URL("hull-depth-4view-DCOdT5ev.png",import.meta.url).href,import.meta.url),baseColor:new URL(""+new URL("hull-base-color-4view-DrQmdT3h.png",import.meta.url).href,import.meta.url),normal:new URL(""+new URL("hull-normal-4view-CvLaFITy.png",import.meta.url).href,import.meta.url),calibration:new URL("data:application/json;base64,ewogICJzb3VyY2VBdGxhcyI6ICJodWxsLTR2aWV3LnBuZyIsCiAgImdlb21ldHJ5IjogInN0YWNrMyByZWd1bGFyaXplZCB2aXN1YWwgaHVsbCBmcm9tIHRoZSBSR0IgYXRsYXMgc2lsaG91ZXR0ZXMsIHdpdGggdGhlIHR1cm50YWJsZSBhbmQgbGFyZ2UgaGF0Y2ggcmVsaWVmIGd1aWRlZCBieSB2aXNpYmxlIHNvdXJjZSBnZW9tZXRyeSIsCiAgImRpbWVuc2lvbnMiOiBbCiAgICAxODc0LAogICAgNjkyCiAgXSwKICAibGF5b3V0IjogWwogICAgInRvcCIsCiAgICAibGVmdCIsCiAgICAiZnJvbnQiLAogICAgInJlYXIiCiAgXSwKICAicGl4ZWxzUGVyVW5pdCI6IDIwMCwKICAiZ3JvdW5kWSI6IDQ0MCwKICAiY2xheSI6IHsKICAgICJmaWxlIjogImh1bGwtY2xheS00dmlldy5wbmciLAogICAgImJhY2tncm91bmQiOiAidHJhbnNwYXJlbnQiCiAgfSwKICAiZGVwdGgiOiB7CiAgICAiZmlsZSI6ICJodWxsLWRlcHRoLTR2aWV3LnBuZyIsCiAgICAiZW5jb2RpbmciOiAiMTYtYml0IHVuc2lnbmVkIGdyYXlzY2FsZSwgbGluZWFyIGludmVyc2UgY2FtZXJhIGRpc3RhbmNlIiwKICAgICJiYWNrZ3JvdW5kIjogMCwKICAgICJ2YWxpZFJhbmdlIjogWwogICAgICAxLAogICAgICA2NTUzNQogICAgXSwKICAgICJkZWNvZGUiOiAiZGlzdGFuY2UgPSBuZWFyICsgKGZhciAtIG5lYXIpICogKDY1NTM1IC0gdmFsdWUpIC8gNjU1MzQiLAogICAgInVuaXRzIjogInN0YWNrMyBzY2VuZSB1bml0cyIsCiAgICAicGl4ZWxDZW50ZXJPZmZzZXQiOiAwLjUKICB9LAogICJ2aWV3cyI6IHsKICAgICJ0b3AiOiB7CiAgICAgICJyZWN0IjogWwogICAgICAgIDAsCiAgICAgICAgMCwKICAgICAgICAzOTYsCiAgICAgICAgNjkyCiAgICAgIF0sCiAgICAgICJhbmNob3IiOiBbCiAgICAgICAgMTk5LAogICAgICAgIDM0NgogICAgICBdLAogICAgICAib3JpZ2luIjogWwogICAgICAgIDAsCiAgICAgICAgMS4wNCwKICAgICAgICAwCiAgICAgIF0sCiAgICAgICJyaWdodCI6IFsKICAgICAgICAtMSwKICAgICAgICAwLAogICAgICAgIDAKICAgICAgXSwKICAgICAgInVwIjogWwogICAgICAgIDAsCiAgICAgICAgMCwKICAgICAgICAxCiAgICAgIF0sCiAgICAgICJmb3J3YXJkIjogWwogICAgICAgIDAsCiAgICAgICAgLTEsCiAgICAgICAgMAogICAgICBdLAogICAgICAibmVhciI6IDAsCiAgICAgICJmYXIiOiAxLjE0CiAgICB9LAogICAgImxlZnQiOiB7CiAgICAgICJyZWN0IjogWwogICAgICAgIDM5NiwKICAgICAgICAwLAogICAgICAgIDY4OCwKICAgICAgICA2OTIKICAgICAgXSwKICAgICAgImFuY2hvciI6IFsKICAgICAgICA3NDAsCiAgICAgICAgNDQwCiAgICAgIF0sCiAgICAgICJvcmlnaW4iOiBbCiAgICAgICAgLTAuOTQ1LAogICAgICAgIDAsCiAgICAgICAgMAogICAgICBdLAogICAgICAicmlnaHQiOiBbCiAgICAgICAgMCwKICAgICAgICAwLAogICAgICAgIDEKICAgICAgXSwKICAgICAgInVwIjogWwogICAgICAgIDAsCiAgICAgICAgMSwKICAgICAgICAwCiAgICAgIF0sCiAgICAgICJmb3J3YXJkIjogWwogICAgICAgIDEsCiAgICAgICAgMCwKICAgICAgICAwCiAgICAgIF0sCiAgICAgICJuZWFyIjogMCwKICAgICAgImZhciI6IDEuODkKICAgIH0sCiAgICAiZnJvbnQiOiB7CiAgICAgICJyZWN0IjogWwogICAgICAgIDEwODQsCiAgICAgICAgMCwKICAgICAgICAzOTQsCiAgICAgICAgNjkyCiAgICAgIF0sCiAgICAgICJhbmNob3IiOiBbCiAgICAgICAgMTI4MSwKICAgICAgICA0NDAKICAgICAgXSwKICAgICAgIm9yaWdpbiI6IFsKICAgICAgICAwLAogICAgICAgIDAsCiAgICAgICAgLTEuNjgwMDAwMDAwMDAwMDAwMgogICAgICBdLAogICAgICAicmlnaHQiOiBbCiAgICAgICAgLTEsCiAgICAgICAgMCwKICAgICAgICAwCiAgICAgIF0sCiAgICAgICJ1cCI6IFsKICAgICAgICAwLAogICAgICAgIDEsCiAgICAgICAgMAogICAgICBdLAogICAgICAiZm9yd2FyZCI6IFsKICAgICAgICAwLAogICAgICAgIDAsCiAgICAgICAgMQogICAgICBdLAogICAgICAibmVhciI6IDAsCiAgICAgICJmYXIiOiAzLjM2MDAwMDAwMDAwMDAwMDMKICAgIH0sCiAgICAicmVhciI6IHsKICAgICAgInJlY3QiOiBbCiAgICAgICAgMTQ3OCwKICAgICAgICAwLAogICAgICAgIDM5NiwKICAgICAgICA2OTIKICAgICAgXSwKICAgICAgImFuY2hvciI6IFsKICAgICAgICAxNjc1LAogICAgICAgIDQ0MAogICAgICBdLAogICAgICAib3JpZ2luIjogWwogICAgICAgIDAsCiAgICAgICAgMCwKICAgICAgICAxLjY4MDAwMDAwMDAwMDAwMDIKICAgICAgXSwKICAgICAgInJpZ2h0IjogWwogICAgICAgIDEsCiAgICAgICAgMCwKICAgICAgICAwCiAgICAgIF0sCiAgICAgICJ1cCI6IFsKICAgICAgICAwLAogICAgICAgIDEsCiAgICAgICAgMAogICAgICBdLAogICAgICAiZm9yd2FyZCI6IFsKICAgICAgICAwLAogICAgICAgIDAsCiAgICAgICAgLTEKICAgICAgXSwKICAgICAgIm5lYXIiOiAwLAogICAgICAiZmFyIjogMy4zNjAwMDAwMDAwMDAwMDAzCiAgICB9CiAgfSwKICAiYmFzZUNvbG9yIjogewogICAgImZpbGUiOiAiaHVsbC1iYXNlLWNvbG9yLTR2aWV3LnBuZyIsCiAgICAiZW5jb2RpbmciOiAiUkdCQTggc1JHQiIsCiAgICAic291cmNlIjogImdlbmVyYXRlZCBtYXRlcmlhbCBwYXNzIHJlZ2lzdGVyZWQgcGVyIHZpZXcgdG8gdGhlIENsYXkgc2lsaG91ZXR0ZXMiCiAgfSwKICAibm9ybWFsIjogewogICAgImZpbGUiOiAiaHVsbC1ub3JtYWwtNHZpZXcucG5nIiwKICAgICJlbmNvZGluZyI6ICJSR0JBOCBsaW5lYXIgZGF0YSIsCiAgICAic3BhY2UiOiAidmlldyIsCiAgICAiYXhlcyI6IHsKICAgICAgInJlZCI6ICIrWCBpbWFnZSByaWdodCIsCiAgICAgICJncmVlbiI6ICIrWSBpbWFnZSB1cCIsCiAgICAgICJibHVlIjogIitaIHRvd2FyZCB0aGUgY2FtZXJhIgogICAgfSwKICAgICJkZWNvZGUiOiAibm9ybWFsID0gbm9ybWFsaXplKDIgKiBSR0IgLyAyNTUgLSAxKSIsCiAgICAiYmFja2dyb3VuZCI6ICJhbHBoYSAwIgogIH0sCiAgInNpemUiOiBbCiAgICAxLjY5LAogICAgMy4xNiwKICAgIDAuOTQKICBdCn0K",import.meta.url)},Ae=["Armored tank · full (assembled)",...q.map(e=>"Armored tank · "+e.name.toLowerCase()),ce],B=["Voxel surface","Marching Cubes","Finer grid","RGB · nearest","RGB · linear","RGB + ID","RGB + ID + depth"];function Z(e,s=!1){se.value=e,se.dataset.error=String(s)}function Ne(){const e=new he({antialias:!0}),s=Math.min(devicePixelRatio,2),t=new we(-1,1,1,-1,.01,50),a=new fe;a.background=new be("#121923");const n=new $({color:"#b4bac3",roughness:.85}),o=new ye("#fff2e5",2.6);o.position.set(3,6,-4),a.add(o,new Me("#b6c9e4",1.5));let r=0,i=0;return{gray:n,draw(g,l,C){const c=Math.round(l.clientWidth*s),d=Math.round(l.clientHeight*s);if(!c||!d)return;const b=c/d,I=U/Math.min(1,b)/Number(z.value);t.left=-I*b,t.right=I*b,t.top=I,t.bottom=-I;const p=P.degToRad(Number(X.value)),u=P.degToRad(Number(V.value)),m=Math.max(8,U*4);t.far=m+U*3,t.position.set(Math.sin(p)*Math.cos(u)*m,Math.sin(u)*m,-Math.cos(p)*Math.cos(u)*m).add(_),t.lookAt(_),t.updateProjectionMatrix(),(c!==r||d!==i)&&(e.setSize(c,d,!1),r=c,i=d),(l.width!==c||l.height!==d)&&(l.width=c,l.height=d),a.add(g),e.render(a,t),C.drawImage(e.domElement,0,0),a.remove(g)}}}function je(e,s){const t=new $({map:e.map,roughness:.82});if(e.dispose(),!s)return t;const a=new Le(s.data,s.width,s.height);return a.minFilter=a.magFilter=re,a.needsUpdate=!0,t.normalMap=a,t.normalMapType=Ze,t.onBeforeCompile=n=>{n.fragmentShader=n.fragmentShader.replace("#include <normal_fragment_maps>",`
2
+ vec3 geometricNormal = normal;
3
+ #include <normal_fragment_maps>
4
+ float coverage = texture2D(normalMap, vNormalMapUv).a;
5
+ normal = normalize(mix(geometricNormal, normal, coverage));
6
+ `)},t}function Fe(e,s,t){const a=s.getContext("2d",{alpha:!1});if(!a)throw new Error("Could not create a thumbnail surface.");const n=We(e.parts.map(I=>I.asset),e.parts),o=e.parts.flatMap(I=>I.mounts),r=e.parts.flatMap(I=>I.mounts.map(()=>I.normalMap)),i=Be(n),g=e.nearest?ve:re,l=[],C=[];for(const[I,{asset:p}]of n.entries()){const u=i.children[I],m=o[I].matrix;if(m&&(u.matrix.fromArray(m),u.matrixAutoUpdate=!1,u.matrixWorldNeedsUpdate=!0),p.target==="stack"){C.push({object:u,asset:p});continue}const h=u,f=h.material,x=e.lit?je(f,r[I]):f;x.map&&(x.map.minFilter=x.map.magFilter=g,x.map.needsUpdate=!0);const te=!e.geometryOnly&&p.frontAccents,G=te?xe(te):void 0;G&&(G.material.alphaTest=.4,h.add(G)),l.push({mesh:h,textured:x,accent:G})}const c=i.children.map(I=>(I.matrixAutoUpdate&&I.updateMatrix(),I.matrixAutoUpdate=!1,I.matrix.clone()));let d=1,b=0;return{surface:s,isStack:C.length>0,draw(){const I=M.valueAsNumber/100;if(I!==b){for(const[m,h]of i.children.entries()){const f=Ce[m];h.matrix.copy(c[m]),h.matrix.elements[12]+=f.x*I,h.matrix.elements[13]+=f.y*I,h.matrix.elements[14]+=f.z*I,h.matrixWorldNeedsUpdate=!0}b=I}const p=F.valueAsNumber;if(C.length&&p!==d){for(const{object:m,asset:h}of C)for(const[f,x]of m.children.entries())x.position.y=((f+.5)*h.spacing-h.pivot[2])*p;d=p}const u=e.geometryOnly||Y.getAttribute("aria-pressed")==="true";for(const{mesh:m,textured:h,accent:f}of l)m.material=u?t.gray:h,f&&(f.visible=!u);t.draw(i,s,a)},dispose(){for(const{object:I}of C){const p=I.children;p[0]?.geometry.dispose();for(const u of p){const m=u.material;m.map?.dispose(),m.dispose()}}for(const{mesh:I,textured:p,accent:u}of l){if(I.geometry.dispose(),p.map?.dispose(),p instanceof $&&p.normalMap?.dispose(),p.dispose(),!u)continue;u.geometry.dispose();const m=u.material;m.map?.dispose(),m.dispose()}}}}function Oe(e){const s=r=>e.map(i=>({name:i.name,mounts:i.mounts,asset:typeof r=="number"?i.meshes[r]:i[r],grid:r==="voxel"||r==="marching"?i.coarseGrid:i.fullGrid})),t=s(0),a=e.every(r=>r.fullGrid.every((i,g)=>i===r.coarseGrid[g])),n=[{title:"RGB only",detail:"Visual hull and RGB projection",parts:t},{title:"RGB + ID",detail:"Keeps accent colors on visible source-facing surfaces",parts:s(1)},{title:"RGB + ID + depth",detail:"Rebuilds the surface with smoother depth transitions",parts:s(2)}],o=[{title:"Sprite Stack",detail:"Spacing changes the distance between these horizontal slices.",parts:s("stack")},{title:B[0],detail:"Exposed faces of the occupied cells.",parts:s("voxel"),geometryOnly:!0},{title:B[1],detail:"Interpolated surface from the same occupied cells.",parts:s("marching"),geometryOnly:!0},{title:B[2],detail:a?"Only one occupied grid was available at these settings.":"Marching Cubes rebuilt with the full sampling grid.",parts:t,geometryOnly:!0},{title:B[3],detail:"Projects the atlas onto that mesh, using the closest texel.",parts:t,nearest:!0},{title:B[4],detail:"Blends nearby texels on the same textured mesh.",parts:t},n[1],n[2]];if(e.some(r=>r.mapped)){const r=e.map(l=>({name:l.name,mounts:l.mounts,asset:l.mapped?.mesh??l.meshes[0],grid:l.mapped?.grid??l.fullGrid})),i=r.map((l,C)=>({...l,normalMap:e[C].mapped?.normalMap})),g=r.map((l,C)=>({...l,asset:e[C].mapped?.silhouetteMesh??l.asset}));o.unshift({title:"Clay Silhouette Only",detail:"Uses the same calibrated Clay views, grid, and lighting.",parts:g,geometryOnly:!0},{title:"Clay + Depth Map",detail:"Uses the 16-bit depth pass to carve the registered Clay silhouettes.",parts:r,geometryOnly:!0},{title:"Depth + Base Color",detail:"Projects the generated color pass onto the depth-carved mesh.",parts:r,lit:!0},{title:"Depth + Base Color + Normal",detail:"Uses the view-space normal pass for per-pixel lighting on the same mesh.",parts:i,lit:!0})}return o}function Re(e,s){const t=document.createElement("figure"),a=document.createElement("canvas");a.className="model",a.setAttribute("role","img"),a.setAttribute("aria-label",e.title),t.append(a);const n=document.createElement("figcaption"),o=document.createElement("small"),r=e.parts.map(({name:l,grid:C})=>(l?l+" ":"")+C.join(" × ")).join(" · "),i=e.parts.reduce((l,{asset:C,mounts:c})=>l+(C.target==="stack"?C.layers:C.indices.length/3)*c.length,0),g=e.parts[0].asset.target==="stack"?" slices":" triangles";o.textContent=r+" cells · "+i.toLocaleString()+g,n.append(o),t.append(n),s.append(t),R.push(Fe(e,a,Ie)),ue.observe(a)}function Je(e){const s=document.createElement("section");s.className="depth-fit";const t=document.createElement("h2");t.textContent="Depth Fit",s.append(t);const a=c=>c===null?"—":c.toFixed(3),n=document.createElement("strong");n.textContent=a(e.baselineMae)+" → "+a(e.carvedMae)+" units",s.append(n);const o=document.createElement("p"),r=e.baselineMae&&e.carvedMae!==null?100*(e.carvedMae/e.baselineMae-1):null;o.textContent="Mean absolute distance error against the supplied depth map"+(r===null?".":" · "+(r>0?"+":"−")+Math.abs(r).toFixed(1)+"%"),s.append(o);const i=document.createElement("table");i.setAttribute("aria-label","Mean absolute depth error by camera");const g=i.createTHead().insertRow();for(const c of["View","Clay only","+ Depth"]){const d=document.createElement("th");d.scope="col",d.textContent=c,g.append(d)}const l=i.createTBody();for(const c of e.byView){const d=l.insertRow();for(const b of[c.view.toUpperCase(),a(c.baselineMae),a(c.carvedMae)])d.insertCell().textContent=b}s.append(i);const C=document.createElement("p");return C.textContent=e.sharedPixels.toLocaleString()+" shared visible pixels · "+(100*e.sharedPixels/Math.max(1,e.referencePixels)).toFixed(1)+"% of reference",s.append(C),s}function Ge(e){for(const n of R)ue.unobserve(n.surface),n.dispose();R=[];const s=Oe(e.parts),t=e.parts.find(n=>n.mapped)?.mapped?.fit,a=document.createDocumentFragment();for(const n of s){const o=document.createElement("section"),r=document.createElement("h2"),i=document.createElement("p");r.textContent=n.title,i.textContent=n.detail,o.append(r),Re(n,o),o.append(i),a.append(o),t&&n.title==="Clay + Depth Map"&&a.append(Je(t))}Ke.replaceChildren(a),J()}function J(){T||(T=requestAnimationFrame(()=>{T=0,A("yaw-value").textContent=X.value+"°",A("pitch-value").textContent=V.value+"°",A("zoom-value").textContent=z.value+"×",A("explode-value").textContent=M.value+"%",R.forEach(e=>e.draw())}))}function me(){return window.clearTimeout(ge),N?.terminate(),N=void 0,++v}function de(e,s,t){const a=new Worker(new URL(""+new URL("compare.worker-CgJq-znx.js",import.meta.url).href,import.meta.url),{type:"module"});N=a,a.onerror=()=>{a.terminate(),t===v&&(N=void 0,Z("The comparison worker could not start.",!0))},a.onmessage=({data:n})=>{if(a.terminate(),t===v){if(N=void 0,"error"in n){Z(n.error,!0);return}try{Ue(n,s)}catch(o){Z(o instanceof Error?o.message:String(o),!0)}}},a.postMessage(e)}function K(e,s){const t=me();k=void 0,D.disabled=!0,F.disabled=!0,M.disabled=!0,Z("Building comparison from "+s+"…"),A("comparison-warnings").replaceChildren(),e().then(a=>{if(t!==v)return;k={job:a,name:s};const n="parts"in a?a.parts.map(r=>r.settings):[a.settings],o=n[0].layers??W.layers;D.value=String(o),A("layers-value").textContent=n.every(r=>(r.layers??W.layers)===o)?String(o):"Per part",D.disabled=!1,de(a,s,t)}).catch(a=>{t===v&&Z(String(a),!0)})}function Ye(e){return e.flatMap(s=>{const{size:[t,a,n],pivot:o}=s.meshes[0],r=new oe(new y(-t/2,-o[2],-a/2),new y(t/2,n-o[2],a/2));return s.mounts.map(({position:[i,g,l],scale:C=1,matrix:c})=>{const d=c?new ne().fromArray(c):new ne().makeScale(C,C,C).setPosition(i,l,-g);return r.clone().applyMatrix4(d)})})}function Ee(e,s){const t=e.map(i=>i.getSize(new y)),a=t.reduce((i,g,l)=>g.x*g.z>t[i].x*t[i].z?l:i,0),n=e[a].getCenter(new y),o=t[a],r=Math.max(s.x,s.y,s.z)*.12;return e.map((i,g)=>{if(g===a)return new y;const l=i.getCenter(new y).sub(n),C=l.y>o.y*.18;l.y=0;const c=Math.hypot(l.x/o.x,l.z/o.z);return c>.16?l.normalize().multiplyScalar(r):l.set(0,0,0),(C||c<=.16)&&(l.y=r),l})}function Ue(e,s){Ie??=Ne();const t=Ye(e.parts),a=t.reduce((r,i)=>r.union(i),new oe),n=a.getSize(new y);U=n.length()*.53,a.getCenter(_),Ce=Ee(t,n),M.disabled=t.length<2,M.disabled&&(M.value=M.defaultValue),A("comparison-warnings").replaceChildren(...e.warnings.map(r=>{const i=document.createElement("li");return i.textContent=r,i})),Ge(e),F.disabled=!1;const o=e.parts.length>1?" "+e.parts.length+" atlases reconstructed separately.":"";Z(s+" · Comparison ready."+o+" Camera settings are shared.")}function pe(){const e=L?.nodes.filter(n=>n.atlasId)??[],s=document.createElement("optgroup");s.label="Built-in atlases",s.append(...Ae.map((n,o)=>new Option(n,"sample:"+o)));const t=document.createElement("optgroup");t.label=L?.name??"Project",t.append(...e.map(n=>new Option(n.name,n.id))),e.length>1&&t.append(new Option("Project · full (assembled)","project:assembly"));const a=e.length?[t,s]:[s];w.replaceChildren(...a)}function ke(e){const s=new ae,t=new Map(e.map(n=>{const o=new ae;return o.position.set(...n.position),o.rotation.set(...n.rotation.map(P.degToRad)),o.scale.set(...n.scale),o.visible=n.visible,[n.id,o]}));for(const n of e)((n.parentId?t.get(n.parentId):void 0)??s).add(t.get(n.id));s.updateMatrixWorld(!0);const a=new Set;return s.traverseVisible(n=>a.add(n)),e.flatMap(n=>{const o=t.get(n.id);return n.atlasId&&a.has(o)?[{node:n,matrix:o.matrixWorld.toArray()}]:[]})}async function ie(e){const s=O+"/atlas/"+encodeURIComponent(e.id),t=await fetch(s);if(!t.ok)throw new Error("Could not load the project atlas.");return{file:await t.blob(),layout:e.layout}}async function Xe(){async function e(i){const g=await fetch(i);if(!g.ok)throw new Error("Could not load the hull material passes.");return g}const[s,t,a,n,o,r]=await Promise.all([e(S.source).then(i=>i.blob()),e(S.clay).then(i=>i.blob()),e(S.depth).then(i=>i.blob()),e(S.baseColor).then(i=>i.blob()),e(S.normal).then(i=>i.blob()),e(S.calibration).then(i=>i.json())]);return{file:s,layout:ee,settings:{...W,size:r.size},maps:{clay:t,depth:a,baseColor:n,normal:o,calibration:r}}}function j(){if(w.value.startsWith("sample:")){const t=Number(w.value.slice(7)),a=Ae[t];if(!a)return;if(a===ce){K(Xe,a);return}K(async()=>{async function n(r){const i=await fetch(r);if(!i.ok)throw new Error("Could not load the built-in atlas.");return{file:await i.blob(),layout:ee}}if(t===0)return{parts:await Promise.all(q.map(async({name:i,url:g,size:l,mounts:C})=>({...await n(g),name:i,mounts:C,settings:{...W,size:l,height:l?.[2]}})))};const o=q[t-1].url;return{...await n(o),settings:W}},a);return}if(w.value==="project:assembly"&&L&&O){const t=L;K(async()=>{const a=ke(t.nodes);if(!a.length)throw new Error("No visible atlas parts in the project.");const n=new Map;return{parts:await Promise.all(a.map(async({node:r,matrix:i})=>{const g=t.atlases.find(l=>l.id===r.atlasId);if(!g)throw new Error("Missing atlas for "+r.name);return n.has(g.id)||n.set(g.id,ie(g)),{...await n.get(g.id),name:r.name,mounts:[{name:r.name,position:[0,0,0],matrix:i}],settings:r.settings}}))}},t.name+" · full (assembled)");return}const e=L?.nodes.find(t=>t.id===w.value),s=L?.atlases.find(t=>t.id===e?.atlasId);!O||!e||!s||K(async()=>({...await ie(s),settings:e.settings}),e.name)}Q.addEventListener("change",()=>{const e=Q.files?.[0];e&&(w.selectedIndex=-1,K(async()=>({file:e,layout:ee,settings:W}),e.name))});w.addEventListener("change",()=>{Q.value="",j()});D.addEventListener("input",()=>{if(!k)return;const{job:e,name:s}=k,t=D.valueAsNumber;if(!D.validity.valid||!Number.isFinite(t))return;const a=me();A("layers-value").textContent=String(t),Z("Rebuilding "+s+" at "+t+" layers…");const n="parts"in e?{parts:e.parts.map(o=>({...o,settings:{...o.settings,layers:t}}))}:{...e,settings:{...e.settings,layers:t}};ge=window.setTimeout(()=>de(n,s,a),85)});F.addEventListener("input",()=>{A("spacing-value").textContent=F.valueAsNumber.toFixed(2)+"×",R.find(e=>e.isStack)?.draw()});for(const e of[X,V,z,M])e.addEventListener("input",J);Y.addEventListener("click",()=>{Y.setAttribute("aria-pressed",String(Y.getAttribute("aria-pressed")!=="true")),J()});A("reset").addEventListener("click",()=>{for(const e of[X,V,z])e.value=e.defaultValue;J()});const ue=new ResizeObserver(J);pe();const H=le.get("sample");H!==null&&[...w.options].some(e=>e.value==="sample:"+H)&&(w.value="sample:"+H,j());if(O){const e=A("back");e.href="./project.html?session="+E+"&playground=1",e.textContent="Playground",fetch(O+"/state").then(async s=>{if(!s.ok)throw new Error("Could not read the project.");L=await s.json();const t=w.value;pe(),v?w.value=t:([...w.options].some(a=>a.value==="project:assembly")&&(w.value="project:assembly"),j())}).catch(()=>{v||j()})}else v||j();
@@ -0,0 +1,21 @@
1
+ (function(){"use strict";const ct=["top","left","front","rear","right","bottom"];function fn(n){const t=[137,80,78,71,13,10,26,10];if(n.length<33||t.some((c,l)=>n[l]!==c)||String.fromCharCode(...n.subarray(12,16))!=="IHDR")throw new Error("Expected a PNG image.");const e=new DataView(n.buffer,n.byteOffset,n.byteLength),s=e.getUint32(16),o=e.getUint32(20);if(!s||!o||!Number.isSafeInteger(s*o*4))throw new Error("Invalid PNG dimensions.");return{width:s,height:o}}function Ht(n){const{width:t,height:e}=fn(n);if(t>8192||e>8192||t*e>16e6)throw new Error("PNG dimensions exceed the 8192 px or 16 MP input limit.");return{width:t,height:e}}function bt(n){const t=n.split(",").map(e=>e.trim());if(t.some(e=>!ct.includes(e)))throw new Error("Use directions top, left, front, rear, right, and bottom.");if(t.length!==4&&t.length!==6||new Set(t).size!==t.length||ct.slice(0,t.length).some(e=>!t.includes(e)))throw new Error("A layout needs the four required directions or all six, with no duplicates.");return t}function Kt(n,t){const{width:e,height:s}=n,o=new Uint8Array(n.data),c=e*s;for(let r=3;r<o.length;r+=4)if(o[r]<128)return{width:e,height:s,data:o};const l=new Uint8Array(c),a=new Uint32Array(c);let i=0,g=0;function f(r){if(l[r])return;l[r]=1;const h=r*4;Math.min(o[h],o[h+1],o[h+2])>=t&&(a[g++]=r)}for(let r=0;r<e;r++)f(r),f((s-1)*e+r);for(let r=1;r<s-1;r++)f(r*e),f(r*e+e-1);for(;i<g;){const r=a[i++];o[r*4+3]=0;const h=r%e;h&&f(r-1),h+1<e&&f(r+1),r>=e&&f(r-e),r+e<c&&f(r+e)}return{width:e,height:s,data:o}}function Jt(n,t){const{left:e,top:s,width:o,height:c}=t,l=new Uint8Array(o*c*4);for(let a=0;a<c;a++){const i=((s+a)*n.width+e)*4;l.set(n.data.subarray(i,i+o*4),a*o*4)}return{width:o,height:c,data:l}}function Yt(n,t){const{left:e,top:s,width:o,height:c}=t;let l=e+o,a=-1,i=s+c,g=-1;for(let f=s;f<s+c;f++)for(let r=e;r<e+o;r++)n.data[(f*n.width+r)*4+3]<128||(l=Math.min(l,r),a=Math.max(a,r),i=Math.min(i,f),g=Math.max(g,f));return a<0?null:{left:l,top:i,width:a-l+1,height:g-i+1}}function Pt(n){const t=[];let e=-1;for(let s=0;s<=n.length;s++)n[s]?e<0&&(e=s):e>=0&&(t.push([e,s]),e=-1);return t}function St(n,t,e){const s=new Uint8Array(n.width);for(let o=t;o<e;o++)for(let c=0;c<n.width;c++)n.data[(o*n.width+c)*4+3]>=128&&(s[c]=1);return Pt(s)}function An(n,t){bt(t.join(","));let e=St(n,0,n.height).map(([s,o])=>({left:s,top:0,width:o-s,height:n.height}));if(e.length!==t.length){const s=new Uint8Array(n.height);for(let o=0;o<n.height;o++)for(let c=0;c<n.width;c++)if(n.data[(o*n.width+c)*4+3]>=128){s[o]=1;break}e=Pt(s).flatMap(([o,c])=>St(n,o,c).map(([l,a])=>({left:l,top:o,width:a-l,height:c-o})))}if(e.length!==t.length)throw new Error(`Expected ${t.length} separated views, found ${e.length}. Use clear gutters or individual PNGs.`);return e.map(s=>Yt(n,s))}function hn(n,t,e=238){const s=Kt(n,e);return Object.fromEntries(An(s,t).map((o,c)=>{const l=Jt(s,o),a=l.width+2,i=l.height+2,g=new Uint8Array(a*i*4);for(let f=0;f<l.height;f++)g.set(l.data.subarray(f*l.width*4,(f+1)*l.width*4),((f+1)*a+1)*4);return[t[c],{width:a,height:i,data:g}]}))}function Nt(n,t=238){bt(Object.keys(n).join(","));const e=Object.entries(n);return Object.fromEntries(e.map(([s,o])=>{const c=Kt(o,t),l=Yt(c,{left:0,top:0,width:c.width,height:c.height});if(!l)throw new Error(`The ${s} view has an empty silhouette.`);return[s,Jt(c,l)]}))}function ln(n){const{top:t,left:e,front:s,rear:o}=n,c=e.width/e.height*t.width/t.height,l=s.width/s.height,a=[];Math.abs(c/l-1)>.2&&a.push("Top, left, and front proportions differ by more than 20%. Check alignment."),Math.abs(o.width/o.height/l-1)>.2&&a.push("Front and rear proportions differ by more than 20%.");const i=Object.entries(n).map(([f,r])=>({direction:f,width:r.width,height:r.height})),g={x:Math.max(t.width,s.width,o.width,n.bottom?.width??0),y:Math.max(t.height,e.width,n.right?.width??0,n.bottom?.height??0),z:Math.max(e.height,s.height,o.height,n.right?.height??0)};return{views:i,nativeSamples:g,warnings:a}}const zt=128;function Tt(n,t,e,s){if(!Number.isSafeInteger(s)||s<8)throw new Error("Layers must be a safe integer of at least 8.");if(!Number.isSafeInteger(e)||e<16)throw new Error("Resolution must be a safe integer of at least 16.");const o=Math.max(n,t),c=Math.max(2,Math.round(n/o*e)),l=Math.max(2,Math.round(t/o*e));if(!Number.isSafeInteger(c*l*s*4))throw new Error("Requested grid is too large to address its RGBA samples.");return{width:c,depth:l,layers:s}}var Ut={exports:{}},Ot;function gn(){return Ot||(Ot=1,(function(n){(function(){function t(a,i){var g=a.x-i.x,f=a.y-i.y;return g*g+f*f}function e(a,i,g){var f=i.x,r=i.y,h=g.x-f,u=g.y-r;if(h!==0||u!==0){var C=((a.x-f)*h+(a.y-r)*u)/(h*h+u*u);C>1?(f=g.x,r=g.y):C>0&&(f+=h*C,r+=u*C)}return h=a.x-f,u=a.y-r,h*h+u*u}function s(a,i){for(var g=a[0],f=[g],r,h=1,u=a.length;h<u;h++)r=a[h],t(r,g)>i&&(f.push(r),g=r);return g!==r&&f.push(r),f}function o(a,i,g,f,r){for(var h=f,u,C=i+1;C<g;C++){var p=e(a[C],a[i],a[g]);p>h&&(u=C,h=p)}h>f&&(u-i>1&&o(a,i,u,f,r),r.push(a[u]),g-u>1&&o(a,u,g,f,r))}function c(a,i){var g=a.length-1,f=[a[0]];return o(a,0,g,i,f),f.push(a[g]),f}function l(a,i,g){if(a.length<=2)return a;var f=i!==void 0?i*i:1;return a=g?a:s(a,f),a=c(a,f),a}n.exports=l,n.exports.default=l})()})(Ut)),Ut.exports}gn();function wn(n){const{width:t,height:e}=n,s=n.data.slice(),o=new Int32Array(t*e);let c=0,l=0;for(let i=0;i<o.length;i++)s[i*4+3]>=128&&(o[l++]=i);function a(i,g){s[g*4+3]>=128||(s.set(s.subarray(i*4,i*4+3),g*4),s[g*4+3]=255,o[l++]=g)}for(;c<l;){const i=o[c++],g=i%t;g&&a(i,i-1),g+1<t&&a(i,i+1),i>=t&&a(i,i-t),i+t<o.length&&a(i,i+t)}return{width:t,height:e,data:s}}const jt={top:[2,!0],bottom:[2,!1],left:[0,!1],right:[0,!0],front:[1,!0],rear:[1,!1]},un=[0,1,2];function dn(n,t){const e=n[t],s=n[t+1],o=n[t+2];return n[t+3]<128?0:e>145&&e-o>70&&s-o>20&&e-s>22?1:s>95&&o>105&&Math.min(s,o)-e>46&&o-s>-20?2:0}function Cn(n){const t={},e={},s=new Map,o=new Map;for(const[c,l]of Object.entries(n)){let a=function(A,w){!r[w]||h[w]>=0||(h[w]=h[A]+1,C.set(C.subarray(A*4,A*4+3),w*4),u[d++]=w)};const{width:i,height:g,data:f}=l,r=new Uint8Array(i*g),h=new Int32Array(r.length).fill(-1),u=new Int32Array(r.length),C=new Uint8Array(f),p=[0,0,0];for(let A=0;A<r.length;A++){const w=r[A]=dn(f,A*4);w&&p[w]++}const B=r.slice();for(let A=0;A<B.length;A++){const w=B[A];if(!w)continue;const m=A%i,Q=Math.floor(A/i);for(let M=-3;M<=3;M++)for(let x=-3;x<=3;x++){if(x*x+M*M>9||m+x<0||m+x>=i||Q+M<0||Q+M>=g)continue;const y=A+M*i+x,I=y*4;if(r[y]||f[I+3]<128)continue;const U=f[I],F=f[I+1],v=f[I+2];(w===1?U-v>12&&F-v>5&&U>=F-8:Math.min(F,v)-U>12)&&(r[y]=w)}}let d=0;for(let A=0;A<r.length;A++)r[A]||f[A*4+3]<128||(h[A]=0,u[d++]=A);for(let A=0;A<d;A++){const w=u[A],m=w%i;m>0&&a(w,w-1),m+1<i&&a(w,w+1),w>=i&&a(w,w-i),w+i<r.length&&a(w,w+i)}for(const A of[1,2]){const w=p[A]/(i*g)*(c==="front"?1.35:1);w<=(o.get(A)??0)||(o.set(A,w),s.set(A,c))}e[c]=r,t[c]={width:i,height:g,data:C}}return{clean:t,masks:e,owner:s}}function Bn(n,t,e){const s={};for(const a of e){const[i,g]=jt[a],f=un.filter(p=>p!==i),r=t[f[0]],h=t[f[1]],u=new Int32Array(r*h).fill(-1),C=[0,0,0];for(let p=0;p<h;p++)for(let B=0;B<r;B++){C[f[0]]=B,C[f[1]]=p;for(let d=0;d<t[i];d++)if(C[i]=g?t[i]-1-d:d,!!n[(C[2]*t[1]+C[1])*t[0]+C[0]]){u[p*r+B]=C[i]+Number(g);break}}s[a]={axis:i,axes:f,width:r,height:h,values:u}}function o(a,i){return[Math.max(0,Math.min(a.width-1,Math.floor(i[a.axes[0]]))),Math.max(0,Math.min(a.height-1,Math.floor(i[a.axes[1]])))]}function c(a,i){const g=s[a];if(!g)return-1;const[f,r]=o(g,i);return g.values[r*g.width+f]}function l(a,i,g=1.5){const f=c(a,i);return f>=0&&Math.abs(f-i[jt[a][0]])<=g}return{visible:l,firstHit:c}}function pn(n,t,e,s,o,c){const{width:l,height:a,data:i}=n,g=new Uint8Array(t.length),f=new Uint8Array(t.length),r=new Uint8Array(i.length),h=[],u=[],C=[],p=[];for(let d=0;d<t.length;d++){if(t[d]!==1||f[d])continue;const A=[d],w=new Map;let m=l,Q=0,M=a,x=0;f[d]=1;for(const I of A){const U=I%l,F=Math.floor(I/l);m=Math.min(m,U),Q=Math.max(Q,U),M=Math.min(M,F),x=Math.max(x,F);const v=w.get(F)??[U,U];w.set(F,[Math.min(v[0],U),Math.max(v[1],U)]);for(const b of[U>0?I-1:-1,U+1<l?I+1:-1,I-l,I+l])t[b]!==1||f[b]||(f[b]=1,A.push(b))}if(A.length<5||Q-m>l/4||x-M>a/4)continue;const y=new Map;for(const[I,[U,F]]of w){let v=-1;for(let b=U;b<=F;b++){const D=[(b+.5)/l*e[0],0,(1-(I+.5)/a)*e[2]];v=Math.max(v,c("front",D))}v>=0&&y.set(I,v)}if(!(y.size<2)){for(const I of A)y.has(Math.floor(I/l))&&(g[I]=1,r.set(i.subarray(I*4,I*4+4),I*4));for(const[I,U]of y){const[F,v]=w.get(I),b=F/l,D=(v+1)/l,H=I/a,k=(I+1)/a,G=(b-.5)*s[0],N=(D-.5)*s[0],J=(1-H)*s[2]-o[2],j=(1-k)*s[2]-o[2],_=(.5-(U+.65)/e[1])*s[1],S=h.length/3;h.push(G,J,_,N,J,_,N,j,_,G,j,_),u.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1),C.push(S,S+1,S+2,S,S+2,S+3),p.push(b,H,D,H,D,k,b,k)}}}return{mesh:C.length?{target:"mesh",size:s,pivot:o,texture:{width:l,height:a,data:r},positions:Float32Array.from(h),normals:Float32Array.from(u),indices:Uint32Array.from(C),uvs:Float32Array.from(p)}:void 0,marked:g}}const Rt=Int8Array.from(atob("/////////////////////wAIA/////////////////8AAQn/////////////////AQgDCQgB/////////////wECCv////////////////8ACAMBAgr/////////////CQIKAAIJ/////////////wIIAwIKCAoJCP////////8DCwL/////////////////AAsCCAsA/////////////wEJAAIDC/////////////8BCwIBCQsJCAv/////////AwoBCwoD/////////////wAKAQAICggLCv////////8DCQADCwkLCgn/////////CQgKCggL/////////////wQHCP////////////////8EAwAHAwT/////////////AAEJCAQH/////////////wQBCQQHAQcDAf////////8BAgoIBAf/////////////AwQHAwAEAQIK/////////wkCCgkAAggEB/////////8CCgkCCQcCBwMHCQT/////CAQHAwsC/////////////wsEBwsCBAIABP////////8JAAEIBAcCAwv/////////BAcLCQQLCQsCCQIB/////wMKAQMLCgcIBP////////8BCwoBBAsBAAQHCwT/////BAcICQALCQsKCwAD/////wQHCwQLCQkLCv////////8JBQT/////////////////CQUEAAgD/////////////wAFBAEFAP////////////8IBQQIAwUDAQX/////////AQIKCQUE/////////////wMACAECCgQJBf////////8FAgoFBAIEAAL/////////AgoFAwIFAwUEAwQI/////wkFBAIDC/////////////8ACwIACAsECQX/////////AAUEAAEFAgML/////////wIBBQIFCAIICwQIBf////8KAwsKAQMJBQT/////////BAkFAAgBCAoBCAsK/////wUEAAUACwULCgsAA/////8FBAgFCAoKCAv/////////CQcIBQcJ/////////////wkDAAkFAwUHA/////////8ABwgAAQcBBQf/////////AQUDAwUH/////////////wkHCAkFBwoBAv////////8KAQIJBQAFAwAFBwP/////CAACCAIFCAUHCgUC/////wIKBQIFAwMFB/////////8HCQUHCAkDCwL/////////CQUHCQcCCQIAAgcL/////wIDCwABCAEHCAEFB/////8LAgELAQcHAQX/////////CQUICAUHCgEDCgML/////wUHAAUACQcLAAEACgsKAP8LCgALAAMKBQAIAAcFBwD/CwoFBwsF/////////////woGBf////////////////8ACAMFCgb/////////////CQABBQoG/////////////wEIAwEJCAUKBv////////8BBgUCBgH/////////////AQYFAQIGAwAI/////////wkGBQkABgACBv////////8FCQgFCAIFAgYDAgj/////AgMLCgYF/////////////wsACAsCAAoGBf////////8AAQkCAwsFCgb/////////BQoGAQkCCQsCCQgL/////wYDCwYFAwUBA/////////8ACAsACwUABQEFCwb/////AwsGAAMGAAYFAAUJ/////wYFCQYJCwsJCP////////8FCgYEBwj/////////////BAMABAcDBgUK/////////wEJAAUKBggEB/////////8KBgUBCQcBBwMHCQT/////BgECBgUBBAcI/////////wECBQUCBgMABAMEB/////8IBAcJAAUABgUAAgb/////BwMJBwkEAwIJBQkGAgYJ/wMLAgcIBAoGBf////////8FCgYEBwIEAgACBwv/////AAEJBAcIAgMLBQoG/////wkCAQkLAgkECwcLBAUKBv8IBAcDCwUDBQEFCwb/////BQELBQsGAQALBwsEAAQL/wAFCQAGBQADBgsGAwgEB/8GBQkGCQsEBwkHCwn/////CgQJBgQK/////////////wQKBgQJCgAIA/////////8KAAEKBgAGBAD/////////CAMBCAEGCAYEBgEK/////wEECQECBAIGBP////////8DAAgBAgkCBAkCBgT/////AAIEBAIG/////////////wgDAggCBAQCBv////////8KBAkKBgQLAgP/////////AAgCAggLBAkKBAoG/////wMLAgABBgAGBAYBCv////8GBAEGAQoECAECAQsICwH/CQYECQMGCQEDCwYD/////wgLAQgBAAsGAQkBBAYEAf8DCwYDBgAABgT/////////BgQICwYI/////////////wcKBgcICggJCv////////8ABwMACgcACQoGBwr/////CgYHAQoHAQcIAQgA/////woGBwoHAQEHA/////////8BAgYBBggBCAkIBgf/////AgYJAgkBBgcJAAkDBwMJ/wcIAAcABgYAAv////////8HAwIGBwL/////////////AgMLCgYICggJCAYH/////wIABwIHCwAJBwYHCgkKB/8BCAABBwgBCgcGBwoCAwv/CwIBCwEHCgYBBgcB/////wgJBggGBwkBBgsGAwEDBv8ACQELBgf/////////////BwgABwAGAwsACwYA/////wcLBv////////////////8HBgv/////////////////AwAICwcG/////////////wABCQsHBv////////////8IAQkIAwELBwb/////////CgECBgsH/////////////wECCgMACAYLB/////////8CCQACCgkGCwf/////////BgsHAgoDCggDCgkI/////wcCAwYCB/////////////8HAAgHBgAGAgD/////////AgcGAgMHAAEJ/////////wEGAgEIBgEJCAgHBv////8KBwYKAQcBAwf/////////CgcGAQcKAQgHAQAI/////wADBwAHCgAKCQYKB/////8HBgoHCggICgn/////////BggECwgG/////////////wMGCwMABgAEBv////////8IBgsIBAYJAAH/////////CQQGCQYDCQMBCwMG/////wYIBAYLCAIKAf////////8BAgoDAAsABgsABAb/////BAsIBAYLAAIJAgoJ/////woJAwoDAgkEAwsDBgQGA/8IAgMIBAIEBgL/////////AAQCBAYC/////////////wEJAAIDBAIEBgQDCP////8BCQQBBAICBAb/////////CAEDCAYBCAQGBgoB/////woBAAoABgYABP////////8EBgMEAwgGCgMAAwkKCQP/CgkEBgoE/////////////wQJBQcGC/////////////8ACAMECQULBwb/////////BQABBQQABwYL/////////wsHBggDBAMFBAMBBf////8JBQQKAQIHBgv/////////BgsHAQIKAAgDBAkF/////wcGCwUECgQCCgQAAv////8DBAgDBQQDAgUKBQILBwb/BwIDBwYCBQQJ/////////wkFBAAIBgAGAgYIB/////8DBgIDBwYBBQAFBAD/////BgIIBggHAgEIBAgFAQUI/wkFBAoBBgEHBgEDB/////8BBgoBBwYBAAcIBwAJBQT/BAAKBAoFAAMKBgoHAwcK/wcGCgcKCAUECgQICv////8GCQUGCwkLCAn/////////AwYLAAYDAAUGAAkF/////wALCAAFCwABBQUGC/////8GCwMGAwUFAwH/////////AQIKCQULCQsICwUG/////wALAwAGCwAJBgUGCQECCv8LCAULBQYIAAUKBQIAAgX/BgsDBgMFAgoDCgUD/////wUICQUCCAUGAgMIAv////8JBQYJBgAABgL/////////AQUIAQgABQYIAwgCBgII/wEFBgIBBv////////////8BAwYBBgoDCAYFBgkICQb/CgEACgAGCQUABQYA/////wADCAUGCv////////////8KBQb/////////////////CwUKBwUL/////////////wsFCgsHBQgDAP////////8FCwcFCgsBCQD/////////CgcFCgsHCQgBCAMB/////wsBAgsHAQcFAf////////8ACAMBAgcBBwUHAgv/////CQcFCQIHCQACAgsH/////wcFAgcCCwUJAgMCCAkIAv8CBQoCAwUDBwX/////////CAIACAUCCAcFCgIF/////wkAAQUKAwUDBwMKAv////8JCAIJAgEIBwIKAgUHBQL/AQMFAwcF/////////////wAIBwAHAQEHBf////////8JAAMJAwUFAwf/////////CQgHBQkH/////////////wUIBAUKCAoLCP////////8FAAQFCwAFCgsLAwD/////AAEJCAQKCAoLCgQF/////woLBAoEBQsDBAkEAQMBBP8CBQECCAUCCwgEBQj/////AAQLAAsDBAULAgsBBQEL/wACBQAFCQILBQQFCAsIBf8JBAUCCwP/////////////AgUKAwUCAwQFAwgE/////wUKAgUCBAQCAP////////8DCgIDBQoDCAUEBQgAAQn/BQoCBQIEAQkCCQQC/////wgEBQgFAwMFAf////////8ABAUBAAX/////////////CAQFCAUDCQAFAAMF/////wkEBf////////////////8ECwcECQsJCgv/////////AAgDBAkHCQsHCQoL/////wEKCwELBAEEAAcEC/////8DAQQDBAgBCgQHBAsKCwT/BAsHCQsECQILCQEC/////wkHBAkLBwkBCwILAQAIA/8LBwQLBAICBAD/////////CwcECwQCCAMEAwIE/////wIJCgIHCQIDBwcECf////8JCgcJBwQKAgcIBwACAAf/AwcKAwoCBwQKAQoABAAK/wEKAggHBP////////////8ECQEEAQcHAQP/////////BAkBBAEHAAgBCAcB/////wQAAwcEA/////////////8ECAf/////////////////CQoICgsI/////////////wMACQMJCwsJCv////////8AAQoACggICgv/////////AwEKCwMK/////////////wECCwELCQkLCP////////8DAAkDCQsBAgkCCwn/////AAILCAAL/////////////wMCC/////////////////8CAwgCCAoKCAn/////////CQoCAAkC/////////////wIDCAIICgABCAEKCP////8BCgL/////////////////AQMICQEI/////////////wAJAf////////////////8AAwj//////////////////////////////////////w=="),n=>n.charCodeAt(0)),ht=[[0,0,0],[1,0,0],[1,1,0],[0,1,0],[0,0,1],[1,0,1],[1,1,1],[0,1,1]],Vt=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]];function mn(n,t,e){const s=Math.min(e[2]*(t[2]-2)*.042,Math.max(e[0],e[1])*1.65),o=[1,t[0],t[0]*t[1]];let c=Float32Array.from(n),l=new Float32Array(c.length);for(let a=0;a<t.length;a++){const i=Math.max(.6,Math.min(5,s/e[a])),g=Math.ceil(i*2.5),f=Array.from({length:g+1},(p,B)=>Math.exp(-B*B/(2*i*i))),r=f[0]+2*f.slice(1).reduce((p,B)=>p+B,0),h=o[a],u=t[a],C=h*u;for(let p=0;p<c.length;p+=C)for(let B=0;B<h;B++)for(let d=0;d<u;d++){const A=p+B+d*h;let w=f[0]*c[A];for(let m=1;m<=g;m++)d>=m&&(w+=f[m]*c[A-m*h]),d+m<u&&(w+=f[m]*c[A+m*h]);l[A]=w/r}[c,l]=[l,c]}return c}function qt(n,t,e,s){const o=t+2,c=e+2,l=s+2,a=o*c,i=a*l,g=new Uint8Array(i);for(let f=0;f<s;f++)for(let r=0;r<e;r++){const h=(f*e+r)*t;g.set(n.subarray(h,h+t),(f+1)*a+(r+1)*o+1)}return{nx:o,ny:c,nz:l,plane:a,count:i,occupancy:g}}function Ft(n,t,e,s,o){const{nx:c,ny:l,nz:a,plane:i,count:g,occupancy:f}=qt(n,t,e,s),r=o?mn(f,[c,l,a],[o[0]/t,o[1]/e,o[2]/s]):new Float32Array(g);for(let w=0;w<a;w++)for(let m=0;m<l;m++)for(let Q=0;Q<c;Q++){const M=w*i+m*c+Q,x=(Q>0?f[M-1]:0)+(Q+1<c?f[M+1]:0)+(m>0?f[M-c]:0)+(m+1<l?f[M+c]:0)+(w>0?f[M-i]:0)+(w+1<a?f[M+i]:0),y=f[M]*.64+x*.06;r[M]=o?r[M]*.92+y*.08:y}const h=[0,1,c+1,c,i,i+1,i+c+1,i+c],u=new Int32Array(g*3).fill(-1),C=[],p=[],B=[];function d(w,m){return(r[w-m]??0)-(r[w+m]??0)}function A(w,m,Q,M,x){const[y,I]=Vt[x],U=ht[y],F=ht[I],v=M+h[y],b=M+h[I],D=U[0]!==F[0]?0:U[1]!==F[1]?1:2,H=Math.min(v,b)*3+D;if(u[H]>=0)return u[H];const k=C.length/3,G=(.5-r[v])/(r[b]-r[v]);return C.push(w-.5+U[0]+(F[0]-U[0])*G,m-.5+U[1]+(F[1]-U[1])*G,Q-.5+U[2]+(F[2]-U[2])*G),p.push(...[1,c,i].map(N=>d(v,N)*(1-G)+d(b,N)*G)),u[H]=k,k}for(let w=0;w<a-1;w++)for(let m=0;m<l-1;m++)for(let Q=0;Q<c-1;Q++){const M=w*i+m*c+Q;let x=0;for(let y=0;y<8;y++)r[M+h[y]]<.5&&(x|=1<<y);if(!(x===0||x===255))for(let y=x*16;Rt[y]>=0;y++)B.push(A(Q,m,w,M,Rt[y]))}return{positions:C,gradients:p,indices:B}}function Xt(n,t,e,s){const o=[t,e,s],c=[1,t,t*e],l=[],a=[],i=[],g=[[0,0],[1,0],[1,1],[0,1]];for(let f=0;f<s;f++)for(let r=0;r<e;r++)for(let h=0;h<t;h++){const u=(f*e+r)*t+h;if(!n[u])continue;const C=[h,r,f];for(let p=0;p<3;p++){const B=(p+1)%3,d=(p+2)%3;for(const A of[-1,1]){const w=C[p]+A;if(w>=0&&w<o[p]&&n[u+A*c[p]])continue;const m=[0,0,0];m[p]=A;const Q=l.length/3;for(const[U,F]of g){const v=[...C];v[p]+=+(A>0),v[B]+=U,v[d]+=F,l.push(...v),a.push(...m)}const M=Q,x=Q+1,y=Q+2,I=Q+3;A>0?i.push(M,x,y,M,y,I):i.push(M,y,x,M,I,y)}}}return{positions:l,gradients:a,indices:i}}function Qn(n,t,e,s){const{nx:o,ny:c,nz:l,plane:a,count:i,occupancy:g}=qt(n,t,e,s),f=[1,o,a],r=ht.map(([A,w,m])=>A+o*w+a*m),h=new Int32Array(i),u=[],C=[],p=[];function B(A,w,m){const Q=u[w*3]-u[A*3],M=u[w*3+1]-u[A*3+1],x=u[w*3+2]-u[A*3+2],y=u[m*3]-u[A*3],I=u[m*3+1]-u[A*3+1],U=u[m*3+2]-u[A*3+2];return[M*U-x*I,x*y-Q*U,Q*I-M*y]}function d(A,w,m){p.push(A,w,m);const[Q,M,x]=B(A,w,m);for(const y of[A,w,m])C[y*3]+=Q,C[y*3+1]+=M,C[y*3+2]+=x}for(let A=0;A<l-1;A++)for(let w=0;w<c-1;w++)for(let m=0;m<o-1;m++){const Q=A*a+w*o+m;let M=0;for(let v=0;v<8;v++)M|=g[Q+r[v]]<<v;if(M===0||M===255)continue;let x=0,y=0,I=0,U=0;for(const[v,b]of Vt)(M>>v&1)!==(M>>b&1)&&(x+=(ht[v][0]+ht[b][0])/2,y+=(ht[v][1]+ht[b][1])/2,I+=(ht[v][2]+ht[b][2])/2,U++);const F=u.length/3;h[Q]=F,u.push(m-.5+x/U,w-.5+y/U,A-.5+I/U),C.push(0,0,0);for(let v=0;v<3;v++){if(g[Q]===g[Q+f[v]])continue;const b=f[(v+1)%3],D=f[(v+2)%3],H=h[Q-b],k=h[Q-b-D],G=h[Q-D];g[Q]?(d(F,H,k),d(F,k,G)):(d(F,G,k),d(F,k,H))}}for(let A=0;A<p.length;A++){const w=p[A]*3;if(Math.abs(C[w])+Math.abs(C[w+1])+Math.abs(C[w+2])>1e-10)continue;const m=A-A%3;[C[w],C[w+1],C[w+2]]=B(p[m],p[m+1],p[m+2])}return{positions:u,gradients:C,indices:p}}const gt=(n,t,e)=>Math.min(e,Math.max(t,n));function mt(n,t,e,s){switch(n){case"top":return[t,e];case"bottom":return[t,1-e];case"left":return[1-e,1-s];case"right":return[e,1-s];case"front":return[t,1-s];case"rear":return[1-t,1-s]}}function Qt(n,t,e){return(gt(Math.floor(e*n.height),0,n.height-1)*n.width+gt(Math.floor(t*n.width),0,n.width-1))*4}function _t(n,t,e){if(n.width===t&&n.height===e)return n;const s=new Uint8Array(t*e*4);for(let o=0;o<e;o++)for(let c=0;c<t;c++){const l=Qt(n,(c+.5)/t,(o+.5)/e),a=(o*t+c)*4;for(let i=0;i<4;i++)s[a+i]=n.data[l+i]}return{width:t,height:e,data:s}}function Mt(n,t,e,s){const o=[Math.max(0,s),Math.max(0,-t),Math.max(0,e),Math.max(0,-e),Math.max(0,t),Math.max(0,-s)];return n.right||(o[1]=Math.abs(t)),n.bottom||(o[0]=Math.abs(s)),[...ct].filter(c=>n[c]).sort((c,l)=>o[ct.indexOf(l)]-o[ct.indexOf(c)])}function Mn(n,t){const e=n.top,s=n.front,o=n.left,c=t.layers??zt,l=t.resolution??96,a=t.height??1;if(!Number.isFinite(a)||a<=0)throw new Error("Height must be positive.");if(t.pivot&&t.pivot!=="center"&&t.pivot!=="ground")throw new Error("Pivot must be ground or center.");const i=o.width/o.height*a,[g,f,r]=t.size??[(s.width/s.height*a+i*e.width/e.height)/2,i,a];if(![g,f,r].every(B=>Number.isFinite(B)&&B>0))throw new Error("Part dimensions must be positive.");const{width:h,depth:u}=Tt(g,f,l,c),C=[g,f,r],p=[0,0,t.pivot==="center"?r/2:0];return{width:h,depth:u,layers:c,size:C,pivot:p}}function $t(n,t,e){const{width:s,depth:o,layers:c,size:l,pivot:a}=Mn(n,t),i={};for(const C of ct){const p=n[C];if(!p)continue;const B=C!=="top"&&C!=="bottom";i[C]=_t(p,C==="left"||C==="right"?o:s,B?c:o)}const g=Object.entries(i),f=(C,p,B,d,A)=>p.data[Qt(p,...mt(C,B,d,A))+3]>=128,r=new Uint8Array(s*o*c);let h=0;const u=t.profile==="round"||t.profile==="round-base";for(let C=0;C<c;C++)for(let p=0;p<o;p++)for(let B=0;B<s;B++){const d=(B+.5)/s,A=(p+.5)/o,w=(C+.5)/c;(n.right?g.every(([Q,M])=>f(Q,M,d,A,w)):f("top",i.top,d,A,w)&&f("left",i.left,d,A,w)&&(f("front",i.front,d,A,w)||f("rear",i.rear,d,A,w)))&&(r[(C*o+p)*s+B]=1,h++)}if(u){const C=s*o;for(let p=0;p<c;p++){if(t.profile==="round-base"&&(p+.5)/c<.03)continue;let B=s,d=-1,A=o,w=-1;const m=p*C;for(let Q=0;Q<o;Q++)for(let M=0;M<s;M++)r[m+Q*s+M]&&(B=Math.min(B,M),d=Math.max(d,M),A=Math.min(A,Q),w=Math.max(w,Q));if(!(d<B))for(let Q=A;Q<=w;Q++)for(let M=B;M<=d;M++){if(((2*M-B-d)/(d-B+1))**2+((2*Q-A-w)/(w-A+1))**2<=1)continue;const x=m+Q*s+M;h-=r[x],r[x]=0}}}if(!h){if(e)return e;throw new Error("The aligned views have no common volume.")}return{width:s,depth:o,layers:c,size:l,pivot:a,volume:r,aligned:i}}function vn(n,t={},e=!1){const s=new Map,o=new Map(s);let c=0,l=0;for(const[i,g]of[[n,s],[t,o]])for(const f of ct){const r=i[f];if(!r)continue;const h=Math.min(1,512/Math.max(r.width,r.height)),u=_t(r,Math.max(1,Math.round(r.width*h)),Math.max(1,Math.round(r.height*h)));g.set(f,{image:e?wn(u):u,left:c+1}),c+=u.width+2,l=Math.max(l,u.height+2)}const a=new Uint8Array(c*l*4).fill(255);for(const{image:i,left:g}of[...s.values(),...o.values()])for(let f=-1;f<=i.height;f++)for(let r=-1;r<=i.width;r++){const h=(gt(f,0,i.height-1)*i.width+gt(r,0,i.width-1))*4,u=((f+1)*c+g+r)*4;for(let C=0;C<3;C++)a[u+C]=i.data[h+3]>=128?i.data[h+C]:137}return{tiles:s,accents:o,texture:{width:c,height:l,data:a}}}function Wt(n,t,e="rgb",s="marching-cubes"){const{width:o,depth:c,layers:l,size:a,pivot:i,volume:g}=n,f={"marching-cubes":Ft,"surface-nets":Qn,voxel:Xt}[s],r=f(g,o,c,l,e==="depth"?a:void 0);if(!r.indices.length&&e==="depth")return Wt(n,t,"id");const h=new Int32Array(o*c).fill(-1),u=new Int32Array(o*c).fill(l),C=o*c;for(let v=0;v<l;v++)for(let b=0;b<C;b++)g[v*C+b]&&(h[b]=v,u[b]=Math.min(u[b],v));function p(v,b,D,H){const k=gt(Math.floor(b*o),0,o-1),G=gt(Math.floor(D*c),0,c-1),N=v[G*o+k];if(Math.abs(N+.5-H*l)>2)return!1;let J=0;for(const[j,_]of[[2,0],[-2,0],[0,2],[0,-2]]){const S=k+j,$=G+_;if(!(S<0||S>=o||$<0||$>=c)){if(Math.abs(v[$*o+S]-N)>(t.bottom?2:1))return!1;J++}}return J>=(t.bottom?2:3)}const B=e==="rgb"?void 0:Cn(t),d={};for(const v of B?.owner.values()??[])d[v]=t[v];const A=B?Bn(g,[o,c,l],ct):void 0,w=B?.owner.get(1)==="front"&&A&&t.front&&B.masks.front?pn(t.front,B.masks.front,[o,c,l],a,i,A.firstHit):void 0,{texture:m,tiles:Q,accents:M}=vn(B?.clean??t,d),x=[],y=[],I=[],U=[],F=new Map;for(let v=0;v<r.indices.length;v+=3){const b=r.indices.slice(v,v+3),D=[0,1,2].map(R=>b.reduce((V,E)=>V+r.gradients[E*3+R],0)),H=[0,1,2].map(R=>b.reduce((V,E)=>V+r.positions[E*3+R],0)),k=[H[0]/(3*o),H[1]/(3*c),H[2]/(3*l)];let G=Mt(t,D[0],D[1],D[2]);const N=D[2]<0&&t.bottom?"bottom":"top",J=D[2]<0?u:h,j=e==="depth"&&A&&Math.abs(D[2])*l/a[2]>1.55*Math.max(Math.abs(D[0])*o/a[0],Math.abs(D[1])*c/a[1])&&A.visible(N,H.map(R=>R/3),3);if(!j&&!p(J,k[0],k[1],k[2])){const R=D[0],V=D[1];G=Math.hypot(R,V)>.1?Mt(t,R,V,0):Mt(t,k[0]-.5,k[1]-.5,0),G=[...G.filter(E=>E!=="top"&&E!=="bottom"),N]}const _=R=>{const V=t[R];return V.data[Qt(V,...mt(R,...k))+3]>=128};let S=j&&_(N)?N:G.find(_)??G[0],$=!1;if(B&&A){const R=H.map(K=>K/3),V=e==="depth"?3:1.5,E=Mt(t,D[0],D[1],D[2]),L=[Math.max(0,D[2]),Math.max(0,-D[0]),Math.max(0,D[1]),Math.max(0,-D[1]),Math.max(0,D[0]),Math.max(0,-D[2])],P=Math.max(...L);for(const K of E){if(!d[K]||L[ct.indexOf(K)]<=P*.45||!A.visible(K,R,V))continue;const Y=d[K],O=Qt(Y,...mt(K,...k))/4,q=B.masks[K][O];if(!(B.owner.get(q)!==K||K==="front"&&w?.marked[O])){S=K,$=!0;break}}}const{image:lt,left:ft}=($?M:Q).get(S);for(const R of b){const V=R*12+ct.indexOf(S)+($?6:0);let E=F.get(V);if(E===void 0){E=x.length/3,F.set(V,E);const L=R*3,P=r.positions[L]/o,K=r.positions[L+1]/c,Y=r.positions[L+2]/l;x.push((P-.5)*a[0]-i[0],Y*a[2]-i[2],(.5-K)*a[1]+i[1]);const O=r.gradients[L]*o/a[0],q=r.gradients[L+1]*c/a[1],X=r.gradients[L+2]*l/a[2],T=Math.hypot(O,q,X)||1;y.push(O/T,X/T,-q/T);const[W,st]=mt(S,P,K,Y);U.push((ft+.5+gt(W,0,1)*(lt.width-1))/m.width,(1.5+gt(st,0,1)*(lt.height-1))/m.height)}I.push(E)}}return{target:"mesh",size:a,pivot:i,texture:m,positions:Float32Array.from(x),normals:Float32Array.from(y),indices:Uint32Array.from(I),uvs:Float32Array.from(U),...w?.mesh&&{frontAccents:w.mesh}}}function xn(n,t){const{width:e,depth:s,layers:o,size:c,pivot:l,volume:a}=n,i=Math.min(o,Math.max(1,Math.floor(4096/e))),g=e*i,f=s*Math.ceil(o/i),r=new Uint8Array(g*f*4),h=(B,d,A)=>+(B>=0&&B<e&&d>=0&&d<s&&A>=0&&A<o&&a[(A*s+d)*e+B]>0),u=new Int32Array(e*s).fill(-1);for(let B=0;B<o;B++)for(let d=0;d<u.length;d++)a[B*u.length+d]&&(u[d]=B);const C=Array.from({length:27},(B,d)=>Mt(t,d%3-1,Math.floor(d/3)%3-1,Math.floor(d/9)-1)),p=(B,d,A)=>B<0||B>=e||d<0||d>=s||Math.abs(u[d*e+B]-A)<=1;for(let B=0;B<o;B++)for(let d=0;d<s;d++)for(let A=0;A<e;A++){if(!h(A,d,B))continue;const w=h(A-1,d,B)-h(A+1,d,B),m=h(A,d-1,B)-h(A,d+1,B),Q=h(A,d,B-1)-h(A,d,B+1),M=w+1+(m+1)*3+(Q+1)*9,x=((Math.floor(B/i)*s+d)*g+B%i*e+A)*4,y=u[d*e+A],I=B===y&&p(A-2,d,B)&&p(A+2,d,B)&&p(A,d-2,B)&&p(A,d+2,B),U=C[M],F=I||Q<0&&t.bottom?U:C[M-Q*9];let v=0,b=0,D=0,H=0;for(const k of F){if(!I&&k==="top")continue;const G=t[k],N=Qt(G,...mt(k,(A+.5)/e,(d+.5)/s,(B+.5)/o));if(G.data[N+3]<128)continue;const J=G.data[N],j=G.data[N+1],_=G.data[N+2];if(v&&Math.max(Math.abs(J-b/v),Math.abs(j-D/v),Math.abs(_-H/v))>66)continue;const S=k==="front"||k==="rear"?.1+Math.abs(m):k==="left"||k==="right"?.1+Math.abs(w):.1+Math.abs(Q);b+=J*S,D+=j*S,H+=_*S,v+=S}v&&(r[x]=Math.round(b/v),r[x+1]=Math.round(D/v),r[x+2]=Math.round(H/v),r[x+3]=255)}return{target:"stack",size:c,pivot:l,width:e,depth:s,layers:o,columns:i,spacing:c[2]/o,texture:{width:g,height:f,data:r}}}function yn(n,t){return["rgb","id","depth"].map(e=>Wt(t,n,e))}function Zt(n,t){const{size:e,pivot:s,width:o,depth:c,layers:l}=n,a=new Float32Array(t.positions.length),i=new Float32Array(a.length);for(let g=0;g<a.length;g+=3){a[g]=(t.positions[g]/o-.5)*e[0],a[g+1]=t.positions[g+2]/l*e[2]-s[2],a[g+2]=(.5-t.positions[g+1]/c)*e[1];const f=t.gradients[g]*o/e[0],r=t.gradients[g+2]*l/e[2],h=-t.gradients[g+1]*c/e[1],u=Math.hypot(f,r,h)||1;i.set([f/u,r/u,h/u],g)}return{target:"mesh",size:e,pivot:s,positions:a,normals:i,indices:Uint32Array.from(t.indices),uvs:new Float32Array(a.length/3*2),texture:{width:1,height:1,data:Uint8Array.of(255,255,255,255)}}}function En(n,t={}){const e=Nt(n,t.threshold),s=$t(e,t),o=$t(e,{...t,size:s.size,resolution:Math.max(16,Math.min(48,Math.floor((t.resolution??96)/2))),layers:Math.max(8,Math.min(32,Math.floor(s.layers/2)))},s),{volume:c,width:l,depth:a,layers:i}=o,g=Zt(o,Xt(c,l,a,i)),f=Zt(o,Ft(c,l,a,i)),r=h=>[h.width,h.depth,h.layers];return{voxel:g,marching:f,meshes:yn(e,s),stack:xn(s,s.aligned),coarseGrid:r(o),fullGrid:r(s)}}var ot=Uint8Array,Bt=Uint16Array,In=Int32Array,tn=new ot([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),nn=new ot([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),bn=new ot([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),en=function(n,t){for(var e=new Bt(31),s=0;s<31;++s)e[s]=t+=1<<n[s-1];for(var o=new In(e[30]),s=1;s<30;++s)for(var c=e[s];c<e[s+1];++c)o[c]=c-e[s]<<5|s;return{b:e,r:o}},on=en(tn,2),rn=on.b,Un=on.r;rn[28]=258,Un[258]=28;for(var Fn=en(nn,0),kn=Fn.b,kt=new Bt(32768),z=0;z<32768;++z){var wt=(z&43690)>>1|(z&21845)<<1;wt=(wt&52428)>>2|(wt&13107)<<2,wt=(wt&61680)>>4|(wt&3855)<<4,kt[z]=((wt&65280)>>8|(wt&255)<<8)>>1}for(var vt=(function(n,t,e){for(var s=n.length,o=0,c=new Bt(t);o<s;++o)n[o]&&++c[n[o]-1];var l=new Bt(t);for(o=1;o<t;++o)l[o]=l[o-1]+c[o-1]<<1;var a;if(e){a=new Bt(1<<t);var i=15-t;for(o=0;o<s;++o)if(n[o])for(var g=o<<4|n[o],f=t-n[o],r=l[n[o]-1]++<<f,h=r|(1<<f)-1;r<=h;++r)a[kt[r]>>i]=g}else for(a=new Bt(s),o=0;o<s;++o)n[o]&&(a[o]=kt[l[n[o]-1]++]>>15-n[o]);return a}),xt=new ot(288),z=0;z<144;++z)xt[z]=8;for(var z=144;z<256;++z)xt[z]=9;for(var z=256;z<280;++z)xt[z]=7;for(var z=280;z<288;++z)xt[z]=8;for(var sn=new ot(32),z=0;z<32;++z)sn[z]=5;var Dn=vt(xt,9,1),Ln=vt(sn,5,1),Dt=function(n){for(var t=n[0],e=1;e<n.length;++e)n[e]>t&&(t=n[e]);return t},rt=function(n,t,e){var s=t/8|0;return(n[s]|n[s+1]<<8)>>(t&7)&e},Lt=function(n,t){var e=t/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(t&7)},Gn=function(n){return(n+7)/8|0},Hn=function(n,t,e){return(e==null||e>n.length)&&(e=n.length),new ot(n.subarray(t,e))},Kn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],it=function(n,t,e){var s=new Error(t||Kn[n]);if(s.code=n,Error.captureStackTrace&&Error.captureStackTrace(s,it),!e)throw s;return s},Jn=function(n,t,e,s){var o=n.length,c=s?s.length:0;if(!o||t.f&&!t.l)return e||new ot(0);var l=!e,a=l||t.i!=2,i=t.i;l&&(e=new ot(o*3));var g=function(K){var Y=e.length;if(K>Y){var O=new ot(Math.max(Y*2,K));O.set(e),e=O}},f=t.f||0,r=t.p||0,h=t.b||0,u=t.l,C=t.d,p=t.m,B=t.n,d=o*8;do{if(!u){f=rt(n,r,1);var A=rt(n,r+1,3);if(r+=3,A)if(A==1)u=Dn,C=Ln,p=9,B=5;else if(A==2){var M=rt(n,r,31)+257,x=rt(n,r+10,15)+4,y=M+rt(n,r+5,31)+1;r+=14;for(var I=new ot(y),U=new ot(19),F=0;F<x;++F)U[bn[F]]=rt(n,r+F*3,7);r+=x*3;for(var v=Dt(U),b=(1<<v)-1,D=vt(U,v,1),F=0;F<y;){var H=D[rt(n,r,b)];r+=H&15;var w=H>>4;if(w<16)I[F++]=w;else{var k=0,G=0;for(w==16?(G=3+rt(n,r,3),r+=2,k=I[F-1]):w==17?(G=3+rt(n,r,7),r+=3):w==18&&(G=11+rt(n,r,127),r+=7);G--;)I[F++]=k}}var N=I.subarray(0,M),J=I.subarray(M);p=Dt(N),B=Dt(J),u=vt(N,p,1),C=vt(J,B,1)}else it(1);else{var w=Gn(r)+4,m=n[w-4]|n[w-3]<<8,Q=w+m;if(Q>o){i&&it(0);break}a&&g(h+m),e.set(n.subarray(w,Q),h),t.b=h+=m,t.p=r=Q*8,t.f=f;continue}if(r>d){i&&it(0);break}}a&&g(h+131072);for(var j=(1<<p)-1,_=(1<<B)-1,S=r;;S=r){var k=u[Lt(n,r)&j],$=k>>4;if(r+=k&15,r>d){i&&it(0);break}if(k||it(2),$<256)e[h++]=$;else if($==256){S=r,u=null;break}else{var lt=$-254;if($>264){var F=$-257,ft=tn[F];lt=rt(n,r,(1<<ft)-1)+rn[F],r+=ft}var R=C[Lt(n,r)&_],V=R>>4;R||it(3),r+=R&15;var J=kn[V];if(V>3){var ft=nn[V];J+=Lt(n,r)&(1<<ft)-1,r+=ft}if(r>d){i&&it(0);break}a&&g(h+131072);var E=h+lt;if(h<J){var L=c-J,P=Math.min(J,E);for(L+h<0&&it(3);h<P;++h)e[h]=s[L+h]}for(;h<E;++h)e[h]=e[h-J]}}t.l=u,t.p=S,t.b=h,t.f=f,u&&(f=1,t.m=p,t.d=C,t.n=B)}while(!f);return h!=e.length&&l?Hn(e,0,h):e.subarray(0,h)},Yn=new ot(0),Pn=function(n,t){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&it(6,"invalid zlib data"),(n[1]>>5&1)==+!t&&it(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function Sn(n,t){return Jn(n.subarray(Pn(n,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var Nn=typeof TextDecoder<"u"&&new TextDecoder,zn=0;try{Nn.decode(Yn,{stream:!0}),zn=1}catch{}new TextEncoder,Uint32Array.from({length:256},(n,t)=>{let e=t;for(let s=0;s<8;s++)e=e>>>1^(e&1?3988292384:0);return e});function Tn(n){return`function update({ dt, keys, fields, state, rotation }) {
2
+ const tracks = ${JSON.stringify(n)};
3
+ const held = (...codes) => codes.some(code => keys.includes(code));
4
+ const throttle = Number(held('KeyW', 'ArrowUp')) - Number(held('KeyS', 'ArrowDown'));
5
+ const direction = Number(held('KeyA', 'ArrowLeft')) - Number(held('KeyD', 'ArrowRight'));
6
+ const target = throttle * (throttle < 0 ? fields.reverseSpeed : fields.forwardSpeed);
7
+ const oldSpeed = state.speed ?? 0;
8
+ const speed = oldSpeed + (target - oldSpeed) * (1 - Math.exp(-fields.response * dt));
9
+ const distance = (oldSpeed + speed) * .5 * dt;
10
+ const turn = direction * fields.turnRate * dt;
11
+ const radians = Math.PI / 180;
12
+ const previous = state.yaw ?? 0;
13
+ const heading = (rotation[1] + previous + turn * .5) * radians;
14
+ const yaw = (previous + turn) % 360;
15
+ const x = (state.x ?? 0) - Math.sin(heading) * distance;
16
+ const z = (state.z ?? 0) - Math.cos(heading) * distance;
17
+ const travel = tracks.map((track, i) => (state.travel?.[i] ?? 0) + distance + turn * radians * track[1]);
18
+ return { translation: [x, 0, z], rotation: [0, yaw, 0],
19
+ childTrackTravel: Object.fromEntries(tracks.map((track, i) => [track[0], travel[i]])),
20
+ state: { speed, yaw, x, z, travel } };
21
+ }`}Tn([]);const On=(n,t,e="number")=>({type:e,minimum:n,maximum:t}),Ct=(...n)=>({...On(...n),type:"array"});Ct(-1e4,1e4),Ct(-360,360),Ct(.01,100),Ct(-100,100),Ct(-720,720),Ct(-100,100),Ct(-360,360);function jn(n){const{width:t,height:e}=Ht(n);if(n[24]!==16||n[25]!==0||n[26]||n[27]||n[28])throw new Error("Depth maps must be non-interlaced 16-bit grayscale PNGs.");const s=new DataView(n.buffer,n.byteOffset,n.byteLength),o=[];let c=0;for(let C=8;C+12<=n.length;){const p=s.getUint32(C),B=s.getUint32(C+4),d=C+12+p;if(d>n.length)throw new Error("Truncated depth PNG.");if(B===1229209940&&(o.push(n.subarray(C+8,C+8+p)),c+=p),B===1229278788)break;C=d}if(!c)throw new Error("Depth PNG is missing image data.");const l=new Uint8Array(c);let a=0;for(const C of o)l.set(C,a),a+=C.length;const i=t*2,g=(i+1)*e,f=Sn(l,{out:new Uint8Array(g+1)});if(f.length!==g)throw new Error("Invalid depth PNG scanline length.");const r=new Uint16Array(t*e);let h=new Uint8Array(i),u=new Uint8Array(i);for(let C=0;C<e;C++){const p=C*(i+1),B=f[p];if(B>4)throw new Error("Invalid depth PNG filter.");for(let d=0;d<i;d++){const A=d>=2?h[d-2]:0,w=u[d],m=d>=2?u[d-2]:0;let Q=0;switch(B){case 1:Q=A;break;case 2:Q=w;break;case 3:Q=A+w>>1;break;case 4:{const M=A+w-m,x=Math.abs(M-A),y=Math.abs(M-w),I=Math.abs(M-m);Q=x<=y&&x<=I?A:y<=I?w:m;break}}h[d]=f[p+1+d]+Q}for(let d=0;d<t;d++)r[C*t+d]=h[d*2]*256+h[d*2+1];[h,u]=[u,h]}return{width:t,height:e,data:r}}function an(n,t,e){return t+(e-t)*(65535-n)/65534}function cn(n,t,e){const[s,o,c,l]=t.rect,a=new Float32Array(n.positions.length),i=n.positions,g=(u,C)=>i[u]*C[0]+i[u+1]*C[1]+i[u+2]*C[2],f=t.origin.reduce((u,C,p)=>u+C*t.forward[p],0);for(let u=0;u<i.length;u+=3)a[u]=t.anchor[0]-s+g(u,t.right)*e,a[u+1]=t.anchor[1]-o-g(u,t.up)*e,a[u+2]=g(u,t.forward)-f;const r=new Float32Array(c*l).fill(1/0),h=n.indices;for(let u=0;u<h.length;u+=3){const C=h[u]*3,p=h[u+1]*3,B=h[u+2]*3,d=a[C],A=a[C+1],w=a[p],m=a[p+1],Q=a[B],M=a[B+1],x=(w-d)*(M-A)-(m-A)*(Q-d);if(Math.abs(x)<1e-8)continue;const y=Math.max(0,Math.ceil(Math.min(d,w,Q)-.5)),I=Math.min(c-1,Math.floor(Math.max(d,w,Q)-.5)),U=Math.max(0,Math.ceil(Math.min(A,m,M)-.5)),F=Math.min(l-1,Math.floor(Math.max(A,m,M)-.5));for(let v=U;v<=F;v++)for(let b=y;b<=I;b++){const D=b+.5,H=v+.5,k=((w-D)*(M-H)-(m-H)*(Q-D))/x,G=((Q-D)*(A-H)-(M-H)*(d-D))/x,N=1-k-G;if(Math.min(k,G,N)<-1e-6)continue;const J=k*a[C+2]+G*a[p+2]+N*a[B+2],j=v*c+b;J>=t.near&&J<=t.far&&J<r[j]&&(r[j]=J)}}return r}function Rn(n,t,e,s){let o=0,c=0,l=0,a=0;const i=Object.entries(s.views).map(([g,f])=>{const r=cn(n,f,s.pixelsPerUnit),h=cn(t,f,s.pixelsPerUnit),[u,C,p,B]=f.rect;let d=0,A=0,w=0,m=0;for(let Q=0;Q<B;Q++)for(let M=0;M<p;M++){const x=e.data[(Q+C)*e.width+M+u];if(!x)continue;d++;const y=Q*p+M;if(!Number.isFinite(r[y])||!Number.isFinite(h[y]))continue;const I=an(x,f.near,f.far);w+=Math.abs(r[y]-I),m+=Math.abs(h[y]-I),A++}return l+=w,a+=m,o+=d,c+=A,{view:g,sharedPixels:A,referencePixels:d,baselineMae:A?w/A:null,carvedMae:A?m/A:null}});return{referencePixels:o,sharedPixels:c,byView:i,baselineMae:c?l/c:null,carvedMae:c?a/c:null}}const Vn=["top","left","front","rear"],ut=(n,t,e,s)=>n*s[0]+t*s[1]+e*s[2],Gt=n=>Math.max(0,Math.min(255,Math.round(127.5*(1+n))));function qn({calibration:n,depth:t,clay:e,baseColor:s,normal:o},c={}){const{size:l,pixelsPerUnit:a,views:i}=n,[g,f]=n.dimensions;if(![t,e,s,o].every(E=>E.width===g&&E.height===f)||!l.every(E=>Number.isFinite(E)&&E>0)||!Number.isFinite(a)||a<=0)throw new Error("Material passes must match the calibrated atlas dimensions.");const[r,h,u]=l,{width:C,depth:p,layers:B}=Tt(r,h,c.resolution??144,c.layers??zt),d=Math.max(r/C,h/p,u/B)*.75+1/a,A=[0,0,c.pivot==="center"?u/2:0],w=Vn.map(E=>i[E]),m=w.map(E=>ut(...E.origin,E.forward)),Q=w.length,M=[...w,i.left],x=g+i.left.rect[2]+1,y=new Uint8Array(x*f*4),I=new Uint8Array(y.length);for(let E=0;E<y.length;E+=4)y.set([146,149,154,255],E);function U(E,L,P,K){const Y=E.anchor[0]+ut(L,P,K,E.right)*a,O=E.anchor[1]-ut(L,P,K,E.up)*a,[q,X,T,W]=E.rect;return Y<q||Y>=q+T||O<X||O>=X+W?-1:Math.floor(O)*g+Math.floor(Y)}function F(E,L){return an(t.data[L],E.near,E.far)}function v(E,L){const[P,K,Y,O]=E.rect;for(let q=K;q<K+O;q++)for(let X=P;X<P+Y;X++){const T=(q*g+X)*4;if(s.data[T+3]<128)continue;const W=(q*x+(L?g+X-P:X))*4;if(y.set(s.data.subarray(T,T+4),W),o.data[T+3]<128)continue;const st=o.data[T]/127.5-1,Z=o.data[T+1]/127.5-1,nt=o.data[T+2]/127.5-1,tt=E.right.map((at,dt)=>st*at+Z*E.up[dt]-nt*E.forward[dt]),et=Math.hypot(...tt)||1;I.set([Gt(tt[0]*(L?-1:1)/et),Gt(tt[1]/et),Gt(tt[2]/et),255],W)}}for(const E of w)v(E,!1);v(i.left,!0);const b=new Uint8Array(C*p*B),D=new Uint8Array(b.length);for(let E=0;E<B;E++)for(let L=0;L<p;L++)for(let P=0;P<C;P++){const K=((P+.5)/C-.5)*r,Y=(E+.5)/B*u,O=(.5-(L+.5)/p)*h;let q=!0,X=!0;for(const[T,W]of w.entries()){const st=U(W,K,Y,O);if(st<0||e.data[st*4+3]<128){q=!1;break}const Z=ut(K,Y,O,W.forward)-m[T];(!t.data[st]||Z+d<F(W,st))&&(X=!1)}if(q){const T=(E*p+L)*C+P;D[T]=1,X&&(b[T]=1)}}function H(E){const L=Ft(E,C,p,B);if(!L.indices.length)throw new Error("The calibrated views have no common surface.");const P=new Float32Array(L.positions.length),K=new Float32Array(L.positions.length);for(let Y=0;Y<P.length;Y+=3){P.set([(L.positions[Y]/C-.5)*r,L.positions[Y+2]/B*u,(.5-L.positions[Y+1]/p)*h],Y);const O=L.gradients[Y]*C/r,q=L.gradients[Y+2]*B/u,X=-L.gradients[Y+1]*p/h,T=Math.hypot(O,q,X)||1;K.set([O/T,q/T,X/T],Y)}return{positions:P,normals:K,indices:L.indices}}const k=H(D),G=H(b),N=Rn(k,G,t,n),{positions:J,normals:j}=G,_=new Map,S=[],$=[],lt=[],ft=[];for(let E=0;E<G.indices.length;E+=3){const L=G.indices.slice(E,E+3),P=(Z,nt)=>(Z[L[0]*3+nt]+Z[L[1]*3+nt]+Z[L[2]*3+nt])/3,K=P(J,0),Y=P(J,1),O=P(J,2),q=P(j,0),X=P(j,1),T=P(j,2);let W=-1,st=0;for(const[Z,nt]of M.entries()){const tt=Z===Q?-1:1,et=-ut(q*tt,X,T,nt.forward);if(et<=.04)continue;const at=U(nt,K*tt,Y,O);if(at<0||!t.data[at])continue;const dt=F(nt,at),Et=ut(K*tt,Y,O,nt.forward)-m[tt===-1?1:Z],At=Math.abs(Et-dt)/d;if(At>3.5)continue;const pt=et/(1+At*At);pt>st&&(W=Z,st=pt)}for(const Z of L){const nt=Z*(M.length+1)+W+1;let tt=_.get(nt);if(tt===void 0){tt=S.length/3,_.set(nt,tt);const et=Z*3,at=J[et],dt=J[et+1],Et=J[et+2];S.push(at,dt-A[2],Et),$.push(j[et],j[et+1],j[et+2]);const At=M[W];if(!At)lt.push((x-.5)/x,.5/f);else{const pt=W===Q,Xn=At.anchor[0]+a*ut(pt?-at:at,dt,Et,At.right),_n=At.anchor[1]-a*ut(pt?-at:at,dt,Et,At.up);lt.push((Xn+(pt?g-At.rect[0]:0))/x,_n/f)}}ft.push(tt)}}const R={target:"mesh",size:l,pivot:A,positions:Float32Array.from(S),normals:Float32Array.from($),uvs:Float32Array.from(lt),indices:Uint32Array.from(ft),texture:{width:x,height:f,data:y}},V={target:"mesh",size:l,pivot:A,positions:k.positions.map((E,L)=>L%3===1?E-A[2]:E),normals:k.normals,indices:Uint32Array.from(k.indices),uvs:new Float32Array(k.positions.length/3*2),texture:{width:1,height:1,data:Uint8Array.of(255,255,255,255)}};return{mesh:R,silhouetteMesh:V,fit:N,normalMap:{width:x,height:f,data:I},grid:[C,p,B]}}async function It(n,t=!1,e){const s=new Uint8Array(await n.slice(0,33).arrayBuffer());Ht(s);const o=await createImageBitmap(n,{colorSpaceConversion:t?"none":"default"});try{const c=new OffscreenCanvas(o.width,o.height),l=c.getContext("2d",{willReadFrequently:!0});if(!l)throw new Error("Could not decode the PNG.");l.drawImage(o,0,0);const a=l.getImageData(0,0,c.width,c.height);return{width:c.width,height:c.height,data:new Uint8Array(a.data.buffer)}}finally{o.close()}}function yt(n){return[n.positions,n.normals,n.indices,n.uvs,n.texture.data].map(t=>t.buffer)}self.onmessage=async({data:n})=>{try{const t=i=>({...i,name:"",mounts:[{name:"",position:[0,0,0]}]}),e="parts"in n?n.parts:[t(n)],s=[];async function o({file:i,layout:g,settings:f,name:r,mounts:h,maps:u}){const C=hn(await It(i),bt(g),f.threshold),p=En(C,f),B=ln(Nt(C,f.threshold));s.push(...B.warnings.map(A=>r?r+" · "+A:A));let d;if(u){const[A,w,m,Q]=await Promise.all([It(u.clay),u.depth.arrayBuffer(),It(u.baseColor),It(u.normal,!0)]);d=qn({calibration:u.calibration,clay:A,depth:jn(new Uint8Array(w)),baseColor:m,normal:Q},f)}return{...p,name:r,mounts:h,mapped:d}}const c=[];for(const i of e)c.push(await o(i));const a=c.flatMap(i=>[i.voxel,i.marching,...i.meshes]).flatMap(i=>i.frontAccents?[...yt(i),...yt(i.frontAccents)]:yt(i));for(const i of c)a.push(i.stack.texture.data.buffer),i.mapped&&a.push(...yt(i.mapped.mesh),...yt(i.mapped.silhouetteMesh),i.mapped.normalMap.data.buffer);self.postMessage({parts:c,warnings:s},a)}catch(t){self.postMessage({error:t instanceof Error?t.message:String(t)})}}})();
@@ -0,0 +1 @@
1
+ async function ge(ae={}){var M,r=ae,ie=!!globalThis.window,B=!!globalThis.WorkerGlobalScope;function h(e){e={log:e||function(){}};for(const n of h.Pa)n(e);return r.quickJSEmscriptenExtensions=e}h.Pa=[],r.quickjsEmscriptenInit=h,h.Pa.push(e=>{e.getWasmMemory=function(){return T}});var x="./this.program",oe=import.meta.url,P="",H,I;if(ie||B){try{P=new URL(".",oe).href}catch{}B&&(I=e=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)}),H=async e=>{if(e=await fetch(e,{credentials:"same-origin"}),e.ok)return e.arrayBuffer();throw Error(e.status+" : "+e.url)}}var k=console.log.bind(console),g=console.error.bind(console),p,R=!1,F,z,C,W,y,_,m,$=!1;function j(){var e=T.buffer;r.HEAP8=W=new Int8Array(e),new Int16Array(e),r.HEAPU8=y=new Uint8Array(e),new Uint16Array(e),_=new Int32Array(e),m=new Uint32Array(e),new Float32Array(e),new Float64Array(e),new BigInt64Array(e),new BigUint64Array(e)}function N(e){throw r.onAbort?.(e),e="Aborted("+e+")",g(e),R=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),C?.(e),e}var G;async function ue(e){if(!p)try{var n=await H(e);return new Uint8Array(n)}catch{}if(e==G&&p)e=new Uint8Array(p);else if(I)e=I(e);else throw"both async and sync fetching of the wasm failed";return e}async function se(e,n){try{var t=await ue(e);return await WebAssembly.instantiate(t,n)}catch(a){g(`failed to asynchronously prepare wasm: ${a}`),N(a)}}async function le(e){var n=G;if(!p)try{var t=fetch(n,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(t,e)}catch(a){g(`wasm streaming compile failed: ${a}`),g("falling back to ArrayBuffer instantiation")}return se(n,e)}class Y{name="ExitStatus";constructor(n){this.message=`Program terminated with exit(${n})`,this.status=n}}var q=e=>{for(;0<e.length;)e.shift()(r)},J=[],V=[],fe=()=>{var e=r.preRun.shift();V.push(e)},A=!0,T,K=new TextDecoder,X=(e,n,t,a)=>{if(t=n+t,a)return t;for(;e[n]&&!(n>=t);)++n;return n},S=(e,n,t)=>e?K.decode(y.subarray(e,X(y,e,n,t))):"",d=0,_e=[0,31,60,91,121,152,182,213,244,274,305,335],ce=[0,31,59,90,120,151,181,212,243,273,304,334],v={},Z=e=>{if(!(e instanceof Y||e=="unwind"))throw e},b=e=>{throw F=e,A||0<d||(r.onExit?.(e),R=!0),new Y(e)},me=e=>{if(!R)try{e()}catch(n){Z(n)}finally{if(!(A||0<d))try{F=e=F,b(e)}catch(n){Z(n)}}},w=(e,n,t)=>{var a=y;if(!(0<t))return 0;var i=n;t=n+t-1;for(var o=0;o<e.length;++o){var u=e.codePointAt(o);if(127>=u){if(n>=t)break;a[n++]=u}else if(2047>=u){if(n+1>=t)break;a[n++]=192|u>>6,a[n++]=128|u&63}else if(65535>=u){if(n+2>=t)break;a[n++]=224|u>>12,a[n++]=128|u>>6&63,a[n++]=128|u&63}else{if(n+3>=t)break;a[n++]=240|u>>18,a[n++]=128|u>>12&63,a[n++]=128|u>>6&63,a[n++]=128|u&63,o++}}return a[n]=0,n-i},D={},ee=()=>{if(!U){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:x||"./this.program"},n;for(n in D)D[n]===void 0?delete e[n]:e[n]=D[n];var t=[];for(n in e)t.push(`${n}=${e[n]}`);U=t}return U},U,L=e=>{for(var n=0,t=0;t<e.length;++t){var a=e.charCodeAt(t);127>=a?n++:2047>=a?n+=2:55296<=a&&57343>=a?(n+=4,++t):n+=3}return n},Se=[null,[],[]],Te=(e,n,t,a)=>{var i={string:s=>{var l=0;if(s!=null&&s!==0){l=L(s)+1;var c=O(l);w(s,c,l),l=c}return l},array:s=>{var l=O(s.length);return W.set(s,l),l}};e=r["_"+e];var o=[],u=0;if(a)for(var f=0;f<a.length;f++){var Q=i[t[f]];Q?(u===0&&(u=ne()),o[f]=Q(a[f])):o[f]=a[f]}return t=e(...o),t=(function(s){return u!==0&&re(u),n==="string"?S(s):n==="boolean"?!!s:s})(t)};if(r.wasmMemory?T=r.wasmMemory:T=new WebAssembly.Memory({initial:(r.INITIAL_MEMORY||16777216)/65536,maximum:32768}),j(),r.noExitRuntime&&(A=r.noExitRuntime),r.print&&(k=r.print),r.printErr&&(g=r.printErr),r.wasmBinary&&(p=r.wasmBinary),r.thisProgram&&(x=r.thisProgram),r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);0<r.preInit.length;)r.preInit.shift()();r.cwrap=(e,n,t,a)=>{var i=!t||t.every(o=>o==="number"||o==="boolean");return n!=="string"&&i&&!a?r["_"+e]:(...o)=>Te(e,n,t,o)},r.UTF8ToString=S,r.stringToUTF8=(e,n,t)=>w(e,n,t),r.lengthBytesUTF8=L;var te,re,O,ne,we={b:(e,n,t,a)=>N(`Assertion failed: ${S(e)}, at: `+[n?S(n):"unknown filename",t,a?S(a):"unknown function"]),q:()=>N(""),l:()=>{A=!1,d=0},m:function(e,n){e=-9007199254740992>e||9007199254740992<e?NaN:Number(e),e=new Date(1e3*e),_[n>>2]=e.getSeconds(),_[n+4>>2]=e.getMinutes(),_[n+8>>2]=e.getHours(),_[n+12>>2]=e.getDate(),_[n+16>>2]=e.getMonth(),_[n+20>>2]=e.getFullYear()-1900,_[n+24>>2]=e.getDay();var t=e.getFullYear();_[n+28>>2]=(t%4!==0||t%100===0&&t%400!==0?ce:_e)[e.getMonth()]+e.getDate()-1|0,_[n+36>>2]=-(60*e.getTimezoneOffset()),t=new Date(e.getFullYear(),6,1).getTimezoneOffset();var a=new Date(e.getFullYear(),0,1).getTimezoneOffset();_[n+32>>2]=(t!=a&&e.getTimezoneOffset()==Math.min(a,t))|0},j:(e,n)=>{if(v[e]&&(clearTimeout(v[e].id),delete v[e]),!n)return 0;var t=setTimeout(()=>{delete v[e],me(()=>te(e,performance.now()))},n);return v[e]={id:t,Qa:n},0},n:(e,n,t,a)=>{var i=new Date().getFullYear(),o=new Date(i,0,1).getTimezoneOffset();i=new Date(i,6,1).getTimezoneOffset(),m[e>>2]=60*Math.max(o,i),_[n>>2]=+(o!=i),n=u=>{var f=Math.abs(u);return`UTC${0<=u?"-":"+"}${String(Math.floor(f/60)).padStart(2,"0")}${String(f%60).padStart(2,"0")}`},e=n(o),n=n(i),i<o?(w(e,t,17),w(n,a,17)):(w(e,a,17),w(n,t,17))},p:()=>Date.now(),k:e=>{var n=y.length;if(e>>>=0,2147483648<e)return!1;for(var t=1;4>=t;t*=2){var a=n*(1+.2/t);a=Math.min(a,e+100663296);e:{a=(Math.min(2147483648,65536*Math.ceil(Math.max(e,a)/65536))-T.buffer.byteLength+65535)/65536|0;try{T.grow(a),j();var i=1;break e}catch{}i=void 0}if(i)return!0}return!1},e:(e,n)=>{var t=0,a=0,i;for(i of ee()){var o=n+t;m[e+a>>2]=o,t+=w(i,o,1/0)+1,a+=4}return 0},f:(e,n)=>{var t=ee();m[e>>2]=t.length,e=0;for(var a of t)e+=L(a)+1;return m[n>>2]=e,0},d:()=>52,o:function(){return 70},c:(e,n,t,a)=>{for(var i=0,o=0;o<t;o++){var u=m[n>>2],f=m[n+4>>2];n+=8;for(var Q=0;Q<f;Q++){var s=e,l=y[u+Q],c=Se[s];l===0||l===10?(s=s===1?k:g,l=X(c,0),l=K.decode(c.buffer?c.subarray(0,l):new Uint8Array(c.slice(0,l))),s(l),c.length=0):c.push(l)}i+=f}return m[a>>2]=i,0},a:T,r:b,s:function(e,n,t,a,i){return r.callbacks.callFunction(void 0,e,n,t,a,i)},i:function(e){return r.callbacks.shouldInterrupt(void 0,e)},h:function(e,n,t){return t=S(t),r.callbacks.loadModuleSource(void 0,e,n,t)},g:function(e,n,t,a){return t=S(t),a=S(a),r.callbacks.normalizeModule(void 0,e,n,t,a)},t:function(e,n){r.callbacks.freeHostRef(void 0,e,n)}},E;return E=await(async function(){function e(t){return t=E=t.exports,r._malloc=t.v,r._QTS_Throw=t.w,r._QTS_NewError=t.x,r._QTS_RuntimeSetMemoryLimit=t.y,r._QTS_RuntimeComputeMemoryUsage=t.z,r._QTS_RuntimeDumpMemoryUsage=t.A,r._QTS_RecoverableLeakCheck=t.B,r._QTS_BuildIsSanitizeLeak=t.C,r._QTS_RuntimeSetMaxStackSize=t.D,r._QTS_GetUndefined=t.E,r._QTS_GetNull=t.F,r._QTS_GetFalse=t.G,r._QTS_GetTrue=t.H,r._QTS_NewHostRef=t.I,r._QTS_GetHostRefId=t.J,r._QTS_NewRuntime=t.K,r._QTS_FreeRuntime=t.L,r._free=t.M,r._QTS_NewContext=t.N,r._QTS_FreeContext=t.O,r._QTS_FreeValuePointer=t.P,r._QTS_FreeValuePointerRuntime=t.Q,r._QTS_FreeVoidPointer=t.R,r._QTS_FreeCString=t.S,r._QTS_DupValuePointer=t.T,r._QTS_NewObject=t.U,r._QTS_NewObjectProto=t.V,r._QTS_NewArray=t.W,r._QTS_NewArrayBuffer=t.X,r._QTS_NewFloat64=t.Y,r._QTS_GetFloat64=t.Z,r._QTS_NewString=t._,r._QTS_GetString=t.$,r._QTS_GetArrayBuffer=t.aa,r._QTS_GetArrayBufferLength=t.ba,r._QTS_NewSymbol=t.ca,r._QTS_GetSymbolDescriptionOrKey=t.da,r._QTS_IsGlobalSymbol=t.ea,r._QTS_IsJobPending=t.fa,r._QTS_ExecutePendingJob=t.ga,r._QTS_GetProp=t.ha,r._QTS_GetPropNumber=t.ia,r._QTS_SetProp=t.ja,r._QTS_DefineProp=t.ka,r._QTS_GetOwnPropertyNames=t.la,r._QTS_Call=t.ma,r._QTS_ResolveException=t.na,r._QTS_Dump=t.oa,r._QTS_Eval=t.pa,r._QTS_GetModuleNamespace=t.qa,r._QTS_Typeof=t.ra,r._QTS_GetLength=t.sa,r._QTS_IsEqual=t.ta,r._QTS_GetGlobalObject=t.ua,r._QTS_NewPromiseCapability=t.va,r._QTS_PromiseState=t.wa,r._QTS_PromiseResult=t.xa,r._QTS_TestStringArg=t.ya,r._QTS_GetDebugLogEnabled=t.za,r._QTS_SetDebugLogEnabled=t.Aa,r._QTS_BuildIsDebug=t.Ba,r._QTS_BuildIsAsyncify=t.Ca,r._QTS_NewFunction=t.Da,r._QTS_ArgvGetJSValueConstPointer=t.Ea,r._QTS_RuntimeEnableInterruptHandler=t.Fa,r._QTS_RuntimeDisableInterruptHandler=t.Ga,r._QTS_RuntimeEnableModuleLoader=t.Ha,r._QTS_RuntimeDisableModuleLoader=t.Ia,r._QTS_bjson_encode=t.Ja,r._QTS_bjson_decode=t.Ka,te=t.La,re=t.Ma,O=t.Na,ne=t.Oa,E}var n={a:we};return r.instantiateWasm?new Promise(t=>{r.instantiateWasm(n,(a,i)=>{t(e(a))})}):(G??=r.locateFile?r.locateFile?r.locateFile("emscripten-module.wasm",P):P+"emscripten-module.wasm":new URL(""+new URL("emscripten-module-uFzwHH0Y.wasm",import.meta.url).href,import.meta.url).href,e((await le(n)).instance))})(),(function(){function e(){if(r.calledRun=!0,!R){if($=!0,E.u(),z?.(r),r.onRuntimeInitialized?.(),r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;){var n=r.postRun.shift();J.push(n)}q(J)}}if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)fe();q(V),r.setStatus?(r.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>r.setStatus(""),1),e()},1)):e()})(),$?M=r:M=new Promise((e,n)=>{z=e,C=n}),M}export{ge as default};
@@ -0,0 +1 @@
1
+ var r=class{constructor(e){this.module=e,this.DEBUG=!1,this.QTS_Throw=this.module.cwrap("QTS_Throw","number",["number","number"]),this.QTS_NewError=this.module.cwrap("QTS_NewError","number",["number"]),this.QTS_RuntimeSetMemoryLimit=this.module.cwrap("QTS_RuntimeSetMemoryLimit",null,["number","number"]),this.QTS_RuntimeComputeMemoryUsage=this.module.cwrap("QTS_RuntimeComputeMemoryUsage","number",["number","number"]),this.QTS_RuntimeDumpMemoryUsage=this.module.cwrap("QTS_RuntimeDumpMemoryUsage","number",["number"]),this.QTS_RecoverableLeakCheck=this.module.cwrap("QTS_RecoverableLeakCheck","number",[]),this.QTS_BuildIsSanitizeLeak=this.module.cwrap("QTS_BuildIsSanitizeLeak","number",[]),this.QTS_RuntimeSetMaxStackSize=this.module.cwrap("QTS_RuntimeSetMaxStackSize",null,["number","number"]),this.QTS_GetUndefined=this.module.cwrap("QTS_GetUndefined","number",[]),this.QTS_GetNull=this.module.cwrap("QTS_GetNull","number",[]),this.QTS_GetFalse=this.module.cwrap("QTS_GetFalse","number",[]),this.QTS_GetTrue=this.module.cwrap("QTS_GetTrue","number",[]),this.QTS_NewHostRef=this.module.cwrap("QTS_NewHostRef","number",["number","number"]),this.QTS_GetHostRefId=this.module.cwrap("QTS_GetHostRefId","number",["number"]),this.QTS_NewRuntime=this.module.cwrap("QTS_NewRuntime","number",[]),this.QTS_FreeRuntime=this.module.cwrap("QTS_FreeRuntime",null,["number"]),this.QTS_NewContext=this.module.cwrap("QTS_NewContext","number",["number","number"]),this.QTS_FreeContext=this.module.cwrap("QTS_FreeContext",null,["number"]),this.QTS_FreeValuePointer=this.module.cwrap("QTS_FreeValuePointer",null,["number","number"]),this.QTS_FreeValuePointerRuntime=this.module.cwrap("QTS_FreeValuePointerRuntime",null,["number","number"]),this.QTS_FreeVoidPointer=this.module.cwrap("QTS_FreeVoidPointer",null,["number","number"]),this.QTS_FreeCString=this.module.cwrap("QTS_FreeCString",null,["number","number"]),this.QTS_DupValuePointer=this.module.cwrap("QTS_DupValuePointer","number",["number","number"]),this.QTS_NewObject=this.module.cwrap("QTS_NewObject","number",["number"]),this.QTS_NewObjectProto=this.module.cwrap("QTS_NewObjectProto","number",["number","number"]),this.QTS_NewArray=this.module.cwrap("QTS_NewArray","number",["number"]),this.QTS_NewArrayBuffer=this.module.cwrap("QTS_NewArrayBuffer","number",["number","number","number"]),this.QTS_NewFloat64=this.module.cwrap("QTS_NewFloat64","number",["number","number"]),this.QTS_GetFloat64=this.module.cwrap("QTS_GetFloat64","number",["number","number"]),this.QTS_NewString=this.module.cwrap("QTS_NewString","number",["number","number"]),this.QTS_GetString=this.module.cwrap("QTS_GetString","number",["number","number"]),this.QTS_GetArrayBuffer=this.module.cwrap("QTS_GetArrayBuffer","number",["number","number"]),this.QTS_GetArrayBufferLength=this.module.cwrap("QTS_GetArrayBufferLength","number",["number","number"]),this.QTS_NewSymbol=this.module.cwrap("QTS_NewSymbol","number",["number","number","number"]),this.QTS_GetSymbolDescriptionOrKey=this.module.cwrap("QTS_GetSymbolDescriptionOrKey","number",["number","number"]),this.QTS_IsGlobalSymbol=this.module.cwrap("QTS_IsGlobalSymbol","number",["number","number"]),this.QTS_IsJobPending=this.module.cwrap("QTS_IsJobPending","number",["number"]),this.QTS_ExecutePendingJob=this.module.cwrap("QTS_ExecutePendingJob","number",["number","number","number"]),this.QTS_GetProp=this.module.cwrap("QTS_GetProp","number",["number","number","number"]),this.QTS_GetPropNumber=this.module.cwrap("QTS_GetPropNumber","number",["number","number","number"]),this.QTS_SetProp=this.module.cwrap("QTS_SetProp",null,["number","number","number","number"]),this.QTS_DefineProp=this.module.cwrap("QTS_DefineProp",null,["number","number","number","number","number","number","boolean","boolean","boolean"]),this.QTS_GetOwnPropertyNames=this.module.cwrap("QTS_GetOwnPropertyNames","number",["number","number","number","number","number"]),this.QTS_Call=this.module.cwrap("QTS_Call","number",["number","number","number","number","number"]),this.QTS_ResolveException=this.module.cwrap("QTS_ResolveException","number",["number","number"]),this.QTS_Dump=this.module.cwrap("QTS_Dump","number",["number","number"]),this.QTS_Eval=this.module.cwrap("QTS_Eval","number",["number","number","number","string","number","number"]),this.QTS_GetModuleNamespace=this.module.cwrap("QTS_GetModuleNamespace","number",["number","number"]),this.QTS_Typeof=this.module.cwrap("QTS_Typeof","number",["number","number"]),this.QTS_GetLength=this.module.cwrap("QTS_GetLength","number",["number","number","number"]),this.QTS_IsEqual=this.module.cwrap("QTS_IsEqual","number",["number","number","number","number"]),this.QTS_GetGlobalObject=this.module.cwrap("QTS_GetGlobalObject","number",["number"]),this.QTS_NewPromiseCapability=this.module.cwrap("QTS_NewPromiseCapability","number",["number","number"]),this.QTS_PromiseState=this.module.cwrap("QTS_PromiseState","number",["number","number"]),this.QTS_PromiseResult=this.module.cwrap("QTS_PromiseResult","number",["number","number"]),this.QTS_TestStringArg=this.module.cwrap("QTS_TestStringArg",null,["string"]),this.QTS_GetDebugLogEnabled=this.module.cwrap("QTS_GetDebugLogEnabled","number",["number"]),this.QTS_SetDebugLogEnabled=this.module.cwrap("QTS_SetDebugLogEnabled",null,["number","number"]),this.QTS_BuildIsDebug=this.module.cwrap("QTS_BuildIsDebug","number",[]),this.QTS_BuildIsAsyncify=this.module.cwrap("QTS_BuildIsAsyncify","number",[]),this.QTS_NewFunction=this.module.cwrap("QTS_NewFunction","number",["number","string","number","boolean","number"]),this.QTS_ArgvGetJSValueConstPointer=this.module.cwrap("QTS_ArgvGetJSValueConstPointer","number",["number","number"]),this.QTS_RuntimeEnableInterruptHandler=this.module.cwrap("QTS_RuntimeEnableInterruptHandler",null,["number"]),this.QTS_RuntimeDisableInterruptHandler=this.module.cwrap("QTS_RuntimeDisableInterruptHandler",null,["number"]),this.QTS_RuntimeEnableModuleLoader=this.module.cwrap("QTS_RuntimeEnableModuleLoader",null,["number","number"]),this.QTS_RuntimeDisableModuleLoader=this.module.cwrap("QTS_RuntimeDisableModuleLoader",null,["number"]),this.QTS_bjson_encode=this.module.cwrap("QTS_bjson_encode","number",["number","number"]),this.QTS_bjson_decode=this.module.cwrap("QTS_bjson_decode","number",["number","number"])}};export{r as QuickJSFFI};
@@ -0,0 +1 @@
1
+ import{G as q,s as G}from"./style-D6eZHs3D.js";const H=128;function Q(e,n){return n.flatMap((l,i)=>l.mounts.map(w=>({...w,asset:e[i]})))}function V(e){const n=new q;for(const{asset:l,name:i,position:[w,c,f],scale:m=1,mirrorX:p,mirrorY:h}of e){const u=G(l);u.name=i,u.position.set(w,f,-c),u.scale.set(p?-m:m,m,h?-m:m),n.add(u)}return n}function K(e){if(e.length===0||e.some(({asset:r})=>r.target!=="stack"))throw new Error("A stack assembly needs reconstructed stack parts.");const n=e,l=n.map(({asset:r,position:[t,y,B],scale:R=1})=>{const[U,L,v]=r.size.map(s=>s*R),d=B-r.pivot[2]*R;return{min:[t-U/2,y-L/2,d],max:[t+U/2,y+L/2,d+v]}}),i=[0,1,2].map(r=>Math.min(...l.map(({min:t})=>t[r]))),c=[0,1,2].map(r=>Math.max(...l.map(({max:t})=>t[r]))).map((r,t)=>r-i[t]),f=Math.max(...n.map(({asset:r,scale:t=1})=>Math.max(r.width/r.size[0],r.depth/r.size[1])/t)),m=Math.max(1,Math.round(c[0]*f)),p=Math.max(1,Math.round(c[1]*f)),h=Math.min(...n.map(({asset:r,scale:t=1})=>r.spacing*t)),u=Math.max(1,Math.ceil(c[2]/h)),g=[c[0]/m,c[1]/p,c[2]/u],M=Math.min(u,Math.max(1,Math.floor(4096/m))),A=m*M,T=p*Math.ceil(u/M),C=new Uint8Array(4*A*T);for(const[r,{asset:t,mirrorX:y,mirrorY:B}]of n.entries()){const{min:R,max:U}=l[r],L=R.map((s,o)=>Math.ceil((s-i[o])/g[o]-.5)),v=U.map((s,o)=>Math.ceil((s-i[o])/g[o]-.5)),d=(s,o,k)=>Math.max(0,Math.min(k-1,Math.floor((i[o]+(s+.5)*g[o]-R[o])*k/(U[o]-R[o]))));for(let s=L[2];s<v[2];s++)for(let o=L[1];o<v[1];o++){const k=d(s,2,t.layers),D=d(o,1,t.depth),P=(Math.floor(k/t.columns)*t.depth+(B?t.depth-1-D:D))*t.texture.width,Y=(Math.floor(s/M)*p+o)*A;for(let b=L[0];b<v[0];b++){const F=d(b,0,t.width),X=4*(P+k%t.columns*t.width+(y?t.width-1-F:F));if(t.texture.data[X+3]<128)continue;const j=4*(Y+s%M*m+b);for(let x=0;x<4;x++)C[j+x]=t.texture.data[X+x]}}}return{target:"stack",width:m,depth:p,layers:u,columns:M,spacing:g[2],size:c,pivot:[0,0,-i[2]],texture:{width:A,height:T,data:C}}}const z={cone:new URL(""+new URL("traffic-cone-4view-DG-TkITx.png",import.meta.url).href,import.meta.url),rover:new URL(""+new URL("fillet-rover-body-4-view-Chk8Mx4R.png",import.meta.url).href,import.meta.url),inspection:new URL(""+new URL("inspection-robot-body-4-view-CLMaHFYm.png",import.meta.url).href,import.meta.url),ant:new URL(""+new URL("ant-mech-body-4view-D9xVPpbc.png",import.meta.url).href,import.meta.url),tank:new URL(""+new URL("tank-hull-4view-B4sMMkP5.png",import.meta.url).href,import.meta.url),sign:new URL(""+new URL("wet-floor-sign-4view-CWJDyeTX.png",import.meta.url).href,import.meta.url),barrier:new URL(""+new URL("plastic-barrier-4view-DQkTBW_i.png",import.meta.url).href,import.meta.url),concrete:new URL(""+new URL("concrete-barrier-4view-7PsO3Ftq.png",import.meta.url).href,import.meta.url)},Z={standard:{layers:H,resolution:96},draft:{layers:24,resolution:72},balanced:{layers:48,resolution:96},detail:{layers:90,resolution:144}},W=new URL(""+new URL("fillet-rover-wheel-4-view-B-F8flOC.png",import.meta.url).href,import.meta.url),_=new URL(""+new URL("inspection-robot-wheel-4-view-27wRsxcs.png",import.meta.url).href,import.meta.url),E=new URL(""+new URL("ant-mech-center-leg-4view-BcphjF_G.png",import.meta.url).href,import.meta.url),I=new URL(""+new URL("ant-mech-angled-leg-4view-BO2qt1_k.png",import.meta.url).href,import.meta.url),S=new URL(""+new URL("tank-turret-4view-Cx0FuNFu.png",import.meta.url).href,import.meta.url),J=new URL(""+new URL("tank-track-4view-DAIiMTy3.png",import.meta.url).href,import.meta.url),a=(e,n,l,i)=>[e/i,n/i,l/i];function O(e,n,l,i,w,c,f,m){const p=l[2];return[{name:"Body",url:e,size:a(...l,p),mounts:[{name:"Body",position:a(0,0,w,p)}]},{name:"Wheel",url:n,size:a(...i,p),mounts:[-1,1].flatMap(h=>[c,f].map((u,g)=>({name:(h<0?"Left ":"Right ")+(g?"rear wheel":"front wheel"),position:a(h*m,u,0,p),mirrorX:h<0})))}]}const $={rover:O(z.rover,W,[80,188,90],[20,44,44],13,48.5,-56.5,36.5),inspection:O(z.inspection,_,[92,194,150],[30,74,74],14,45,-63,46.5),ant:[{name:"Body",url:z.ant,size:a(50,114,56,56),mounts:[{name:"Body",position:a(0,0,26,56)}]},{name:"Center leg",url:E,size:a(23,17,41,56),mounts:[-1,1].map(e=>({name:e<0?"Left center leg":"Right center leg",position:a(e*27,0,0,56),mirrorX:e<0}))},{name:"Angled leg",url:I,size:a(23,30,41,56),mounts:[-1,1].flatMap(e=>[-1,1].map(n=>({name:(e<0?"Left ":"Right ")+(n<0?"rear leg":"front leg"),position:a(e*27,n*42,0,56),mirrorX:e<0,mirrorY:n<0})))}],tank:[{name:"Hull",url:z.tank,size:a(86,166,49,49),mounts:[{name:"Hull",position:a(0,0,13,49)}]},{name:"Turret",url:S,size:a(60,120,33,49),mounts:[{name:"Turret",position:a(0,15,60,49)}]},{name:"Track",url:J,size:a(23,163,34,49),mounts:[-1,1].map(e=>({name:e<0?"Left track":"Right track",position:a(e*45,0,0,49),mirrorX:e<0}))}]};export{H as D,K as b,V as c,Q as i,$ as m,Z as q,z as s};
@@ -0,0 +1 @@
1
+ import{aA as he,V as P,aB as Q,aC as G,Q as Yt,ax as Nt,E as N,aD as re,aE as le,b as ce,aF as It,aG as Ft,M as ue,aH as de,a6 as pe,aI as me,g as fe,al as _e,au as zt,ar as ge}from"./style-D6eZHs3D.js";const ye="modulepreload",be=function(o,t){return new URL(o,t).href},Xt={},Xe=function(t,e,s){let i=Promise.resolve();if(e&&e.length>0){let u=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};const n=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),r=l?.nonce||l?.getAttribute("nonce");i=u(e.map(h=>{if(h=be(h,s),h in Xt)return;Xt[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(s)for(let y=n.length-1;y>=0;y--){const b=n[y];if(b.href===h&&(!f||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=f?"stylesheet":ye,f||(g.as="script"),g.crossOrigin="",g.href=h,r&&g.setAttribute("nonce",r),document.head.appendChild(g),f)return new Promise((y,b)=>{g.addEventListener("load",y),g.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${h}`)))})}))}function a(n){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=n,window.dispatchEvent(l),!l.defaultPrevented)throw n}return i.then(n=>{for(const l of n||[])l.status==="rejected"&&a(l.reason);return t().catch(a)})},Ut={type:"change"},Pt={type:"start"},Vt={type:"end"},ct=new re,Zt=new le,Me=Math.cos(70*ce.DEG2RAD),S=new P,C=2*Math.PI,w={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Mt=1e-6;class Ue extends he{constructor(t,e=null){super(t,e),this.state=w.NONE,this.target=new P,this.cursor=new P,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Q.ROTATE,MIDDLE:Q.DOLLY,RIGHT:Q.PAN},this.touches={ONE:G.ROTATE,TWO:G.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new P,this._lastQuaternion=new Yt,this._lastTargetPosition=new P,this._quat=new Yt().setFromUnitVectors(t.up,new P(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Nt,this._sphericalDelta=new Nt,this._scale=1,this._panOffset=new P,this._rotateStart=new N,this._rotateEnd=new N,this._rotateDelta=new N,this._panStart=new N,this._panEnd=new N,this._panDelta=new N,this._dollyStart=new N,this._dollyEnd=new N,this._dollyDelta=new N,this._dollyDirection=new P,this._mouse=new N,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=xe.bind(this),this._onPointerDown=we.bind(this),this._onPointerUp=Ee.bind(this),this._onContextMenu=Oe.bind(this),this._onMouseWheel=De.bind(this),this._onKeyDown=Te.bind(this),this._onTouchStart=Ae.bind(this),this._onTouchMove=ve.bind(this),this._onMouseDown=Pe.bind(this),this._onMouseMove=Se.bind(this),this._interceptControlDown=Ce.bind(this),this._interceptControlUp=Re.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ut),this.update(),this.state=w.NONE}update(t=null){const e=this.object.position;S.copy(e).sub(this.target),S.applyQuaternion(this._quat),this._spherical.setFromVector3(S),this.autoRotate&&this.state===w.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(s)&&isFinite(i)&&(s<-Math.PI?s+=C:s>Math.PI&&(s-=C),i<-Math.PI?i+=C:i>Math.PI&&(i-=C),s<=i?this._spherical.theta=Math.max(s,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+i)/2?Math.max(s,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const n=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=n!=this._spherical.radius}if(S.setFromSpherical(this._spherical),S.applyQuaternion(this._quatInverse),e.copy(this.target).add(S),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let n=null;if(this.object.isPerspectiveCamera){const l=S.length();n=this._clampDistance(l*this._scale);const r=l-n;this.object.position.addScaledVector(this._dollyDirection,r),this.object.updateMatrixWorld(),a=!!r}else if(this.object.isOrthographicCamera){const l=new P(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=r!==this.object.zoom;const u=new P(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),n=S.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;n!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(n).add(this.object.position):(ct.origin.copy(this.object.position),ct.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ct.direction))<Me?this.object.lookAt(this.target):(Zt.setFromNormalAndCoplanarPoint(this.object.up,this.target),ct.intersectPlane(Zt,this.target))))}else if(this.object.isOrthographicCamera){const n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),n!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>Mt||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Mt||this._lastTargetPosition.distanceToSquared(this.target)>Mt?(this.dispatchEvent(Ut),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?C/60*this.autoRotateSpeed*t:C/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){S.setFromMatrixColumn(e,0),S.multiplyScalar(-t),this._panOffset.add(S)}_panUp(t,e){this.screenSpacePanning===!0?S.setFromMatrixColumn(e,1):(S.setFromMatrixColumn(e,0),S.crossVectors(this.object.up,S)),S.multiplyScalar(t),this._panOffset.add(S)}_pan(t,e){const s=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;S.copy(i).sub(this.target);let a=S.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*a/s.clientHeight,this.object.matrix),this._panUp(2*e*a/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),i=t-s.left,a=e-s.top,n=s.width,l=s.height;this._mouse.x=i/n*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(C*this._rotateDelta.x/e.clientHeight),this._rotateUp(C*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(C*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-C*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(C*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-C*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._rotateStart.set(s,i)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panStart.set(s,i)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),s=t.pageX-e.x,i=t.pageY-e.y,a=Math.sqrt(s*s+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const s=this._getSecondPointerPosition(t),i=.5*(t.pageX+s.x),a=.5*(t.pageY+s.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(C*this._rotateDelta.x/e.clientHeight),this._rotateUp(C*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),s=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panEnd.set(s,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),s=t.pageX-e.x,i=t.pageY-e.y,a=Math.sqrt(s*s+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const n=(t.pageX+e.x)*.5,l=(t.pageY+e.y)*.5;this._updateZoomParameters(n,l)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new N,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,s={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function we(o){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(o)&&(this._addPointer(o),o.pointerType==="touch"?this._onTouchStart(o):this._onMouseDown(o)))}function xe(o){this.enabled!==!1&&(o.pointerType==="touch"?this._onTouchMove(o):this._onMouseMove(o))}function Ee(o){switch(this._removePointer(o),this._pointers.length){case 0:this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Vt),this.state=w.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function Pe(o){let t;switch(o.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Q.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(o),this.state=w.DOLLY;break;case Q.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=w.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=w.ROTATE}break;case Q.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=w.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=w.PAN}break;default:this.state=w.NONE}this.state!==w.NONE&&this.dispatchEvent(Pt)}function Se(o){switch(this.state){case w.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(o);break;case w.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(o);break;case w.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(o);break}}function De(o){this.enabled===!1||this.enableZoom===!1||this.state!==w.NONE||(o.preventDefault(),this.dispatchEvent(Pt),this._handleMouseWheel(this._customWheelEvent(o)),this.dispatchEvent(Vt))}function Te(o){this.enabled!==!1&&this._handleKeyDown(o)}function Ae(o){switch(this._trackPointer(o),this._pointers.length){case 1:switch(this.touches.ONE){case G.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(o),this.state=w.TOUCH_ROTATE;break;case G.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(o),this.state=w.TOUCH_PAN;break;default:this.state=w.NONE}break;case 2:switch(this.touches.TWO){case G.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(o),this.state=w.TOUCH_DOLLY_PAN;break;case G.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(o),this.state=w.TOUCH_DOLLY_ROTATE;break;default:this.state=w.NONE}break;default:this.state=w.NONE}this.state!==w.NONE&&this.dispatchEvent(Pt)}function ve(o){switch(this._trackPointer(o),this.state){case w.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(o),this.update();break;case w.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(o),this.update();break;case w.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(o),this.update();break;case w.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(o),this.update();break;default:this.state=w.NONE}}function Oe(o){this.enabled!==!1&&o.preventDefault()}function Ce(o){o.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Re(o){o.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Ht=new WeakMap;function ke(o){const t=Ht.get(o);if(t)return t;const{width:e,depth:s,layers:i,texture:a,columns:n,size:l}=o,r=e*s,u=r*i,h=new Uint8Array(u),f=new Int8Array(u*3),p=new Uint8Array(u);for(let d=0;d<i;d++){const _=d%n*e,m=Math.floor(d/n)*s;for(let c=0;c<s;c++)for(let x=0;x<e;x++)h[d*r+c*e+x]=+(a.data[((m+c)*a.width+_+x)*4+3]>=128)}const g=(d,_,m,c)=>{const x=m>0?h[d-_]:0,A=m+1<c?h[d+_]:0,v=m>1?h[d-_*2]:0,k=m+2<c?h[d+_*2]:0;return 2*(x-A)+v-k};for(let d=0;d<i;d++)for(let _=0;_<s;_++)for(let m=0;m<e;m++){const c=d*r+_*e+m;if(!h[c]||m>0&&m+1<e&&_>0&&_+1<s&&d>0&&d+1<i&&h[c-1]&&h[c+1]&&h[c-e]&&h[c+e]&&h[c-r]&&h[c+r])continue;const x=g(c,1,m,e)*e/l[0],A=g(c,r,d,i)*i/l[2],v=-g(c,e,_,s)*s/l[1],k=127/(Math.hypot(x,A,v)||1);f[c*3]=Math.round(x*k),f[c*3+1]=Math.round(A*k),f[c*3+2]=Math.round(v*k)}const y=new Int32Array(6);for(let d=0;d<i;d++)for(let _=0;_<s;_++)for(let m=0;m<e;m++){const c=d*r+_*e+m,x=c*3,A=f[x],v=f[x+1],k=f[x+2];if(!(A||v||k))continue;y[0]=m>0?c-1:-1,y[1]=m+1<e?c+1:-1,y[2]=_>0?c-e:-1,y[3]=_+1<s?c+e:-1,y[4]=d>0?c-r:-1,y[5]=d+1<i?c+r:-1;let D=0,L=0;for(const B of y){if(B<0)continue;const K=B*3,M=(A*f[K]+v*f[K+1]+k*f[K+2])/16129;M<.18||(D+=Math.max(0,1-M),L++)}p[c]=L?Math.min(255,Math.round(D/L*680)):0}const b={normals:f,variance:p};return Ht.set(o,b),b}const Kt=new P(.45,.7,.5).normalize();function je(o,t,e){const s=Math.min(1,o**4+e),i=t*t*(s-1)+1;return Math.min(2.4/(1+4*e),s/(i*i)*.63)}class Le{normalMatrix=new It;worldMatrix=new It;half=new P;n=new P;tangent=new P;bitangent=new P;uEdge=new P;vEdge=new P;normal=new P;normals=new Float32Array(0);variance=0;detail=!1;specularAA=!1;minX=0;minY=0;maxX=0;maxY=0;slice;camera(t){t.getWorldDirection(this.half).negate().add(Kt).normalize()}mesh(t,e,s,i,a){this.detail=!!a.detailNormals,this.specularAA=!!a.specularAA;const n=Ft(t);this.slice=n?{width:n.stack.width,row:n.layer*n.stack.depth,roll:n.roll,spacing:t.parent?.scale.y??1,lighting:ke(n.roll?.source??n.stack)}:void 0,this.normals.length<e.count*3&&(this.normals=new Float32Array(e.count*3)),this.normalMatrix.getNormalMatrix(t.matrixWorld),this.worldMatrix.setFromMatrix4(t.matrixWorld);for(let u=0;u<e.count;u++)this.n.fromBufferAttribute(e,u).applyNormalMatrix(this.normalMatrix).toArray(this.normals,u*3);this.minX=Math.max(0,Math.round(s.offset.x*i.width-.5)),this.maxX=Math.min(i.width-1,Math.round((s.offset.x+s.repeat.x)*i.width-.5));const l=s.offset.y,r=l+s.repeat.y;this.minY=Math.max(0,Math.round((s.flipY?1-r:l)*i.height-.5)),this.maxY=Math.min(i.height-1,Math.round((s.flipY?1-l:r)*i.height-.5))}triangle(t,e,s,i,a,n,l){if(this.detail){const r=e.getX(i)-e.getX(s),u=e.getY(i)-e.getY(s),h=e.getX(a)-e.getX(s),f=e.getY(a)-e.getY(s),p=r*f-h*u;this.tangent.set(0,0,0),this.bitangent.set(0,0,0),Math.abs(p)>1e-12&&(this.n.fromBufferAttribute(t,s),this.uEdge.fromBufferAttribute(t,i).sub(this.n).applyMatrix3(this.worldMatrix),this.vEdge.fromBufferAttribute(t,a).sub(this.n).applyMatrix3(this.worldMatrix),this.tangent.copy(this.uEdge).multiplyScalar(f/p).addScaledVector(this.vEdge,-u/p).normalize(),this.bitangent.copy(this.uEdge).multiplyScalar(-h/p).addScaledVector(this.vEdge,r/p).normalize().multiplyScalar(l?-1:1))}if(this.variance=0,this.specularAA&&!this.slice){const r=this.normals,u=s*3,h=i*3,f=a*3,p=(g,y)=>r[g]*r[y]+r[g+1]*r[y+1]+r[g+2]*r[y+2];this.variance=Math.min(.14,Math.max(0,3-p(u,h)-p(h,f)-p(f,u))/Math.max(3,Math.sqrt(Math.abs(n))*3))}}shade(t,e,s,i,a,n,l,r,u,h,f){const p=a*3,g=n*3,y=l*3,b=this.normals,d=this.normal.set(b[p]*r+b[g]*u+b[y]*h,b[p+1]*r+b[g+1]*u+b[y+1]*h,b[p+2]*r+b[g+2]*u+b[y+2]*h).normalize();f&&d.negate();const _=(t[0]*.2126+t[1]*.7152+t[2]*.0722)/255;let m=this.variance;if(this.detail||this.slice){const D=Math.min(this.maxX,Math.max(this.minX,Math.floor(s*e.width))),L=Math.min(this.maxY,Math.max(this.minY,Math.floor(i*e.height)));if(this.slice){const{row:B,width:K,roll:M,spacing:T,lighting:E}=this.slice,I=B+L-this.minY,j=M?M.rows[I]:I;if(j>=0){const O=j*K+D-this.minX,R=E.normals[O*3],Y=E.normals[O*3+1],U=E.normals[O*3+2];(R||Y||U)&&(d.set(R,Y,U),M&&d.set(R,Y*M.cos-U*M.sin*T,Y*M.sin/T+U*M.cos),d.applyNormalMatrix(this.normalMatrix)),this.specularAA&&(m=E.variance[O]/255*.24)}}this.detail&&(m=this.perturb(d,e,D,L,_,m))}const c=Math.max(0,d.dot(Kt)),x=.38+.23*(1-_),A=je(x,Math.max(0,d.dot(this.half)),m)*c,v=.68+.31*c+.06*Math.max(0,d.y),k=(12+22*_)*A;for(let D=0;D<3;D++){const L=t[D]*v;t[D]=L+k*(1-L/340)}}perturb(t,e,s,i,a,n){const l=this.luma(e,s,i,a),r=this.luma(e,s-1,i,l),u=this.luma(e,s+1,i,l),h=this.luma(e,s,i-1,l),f=this.luma(e,s,i+1,l),p=.76*(u-r)+.12*(this.luma(e,s+2,i,u)-this.luma(e,s-2,i,r)),g=.76*(f-h)+.12*(this.luma(e,s,i+2,f)-this.luma(e,s,i-2,h)),y=Math.min(1.7,.38/Math.max(.001,Math.hypot(p,g)));if(this.n.copy(this.tangent).multiplyScalar(p).addScaledVector(this.bitangent,g),this.n.addScaledVector(t,-this.n.dot(t)),t.addScaledVector(this.n,-y).normalize(),!this.specularAA)return n;const b=r+u-2*l,d=h+f-2*l;return Math.min(.24,n+.45*(b*b+d*d))}luma(t,e,s,i){if(e<this.minX||e>this.maxX||s<this.minY||s>this.maxY)return i;const a=(s*t.width+e)*4,n=t.data;return n[a+3]>=128?(n[a]*.2126+n[a+1]*.7152+n[a+2]*.0722)/255:i}}const wt=(o,t,e,s,i,a)=>(e-o)*(a-t)-(s-t)*(i-o);class Ze{canvas=document.createElement("canvas");ctx=this.canvas.getContext("2d");textures=new WeakMap;transform=new ue;vertex=new de;lighting=new Le;frame;sampleColors=new Uint8ClampedArray(0);depth=new Float32Array(0);pixels(t){const e=t.image;if(!e?.width||!e.height)return;if("data"in e)return e;const s=this.textures.get(e);if(s)return s;try{const a=new OffscreenCanvas(e.width,e.height).getContext("2d");a.drawImage(e,0,0);const n=a.getImageData(0,0,e.width,e.height);return this.textures.set(e,n),n}catch{return}}render(t,e,s,i,a,n,l){const r=Math.min(1,512/Math.max(this.canvas.clientWidth,this.canvas.clientHeight,1))*(s?2:1),u=Math.max(1,Math.round(this.canvas.clientWidth*r)),h=Math.max(1,Math.round(this.canvas.clientHeight*r));(!this.frame||this.frame.width!==u||this.frame.height!==h)&&(this.canvas.width=u,this.canvas.height=h,this.frame=this.ctx.createImageData(u,h));const{data:f}=this.frame,p=l?.subpixelAA?4:1,g=u*h*p;this.depth.length!==g&&(this.depth=new Float32Array(g));const y=p===4?g*4:0;this.sampleColors.length!==y&&(this.sampleColors=new Uint8ClampedArray(y));const b=p===4?this.sampleColors:f;b.fill(0),this.depth.fill(1/0),e.updateMatrixWorld(),l&&this.lighting.camera(e),t?.updateMatrixWorld(!0);const d=[],_=e.matrixWorldInverse.elements;t?.traverseVisible(m=>{if(!(m instanceof pe)||!m.visible||Array.isArray(m.material))return;const c=m.material;if(!c.map)return;const x=m.matrixWorld.elements,A=_[2]*x[12]+_[6]*x[13]+_[10]*x[14];d.push({mesh:m,material:c,viewZ:A})}),l&&d.sort((m,c)=>c.viewZ-m.viewZ);for(const{mesh:m,material:c}of d)this.draw(m,c,e,u,h,b,n||c instanceof me,p,l);p===4&&this.resolveSubpixels(f),this.ctx.putImageData(this.frame,0,0),this.ctx.save(),this.ctx.globalCompositeOperation="destination-over",i&&t&&this.drawGrid(e,u,h,a),this.ctx.fillStyle="#121923",this.ctx.fillRect(0,0,u,h),this.ctx.restore()}resolveSubpixels(t){const e=this.sampleColors;for(let s=0,i=0;s<t.length;s+=4,i+=16){const a=e[i+3],n=e[i+7],l=e[i+11],r=e[i+15],u=a+n+l+r;if(t[s+3]=u*.25,!u){t[s]=t[s+1]=t[s+2]=0;continue}for(let h=0;h<3;h++)t[s+h]=(e[i+h]*a+e[i+4+h]*n+e[i+8+h]*l+e[i+12+h]*r)/u}}drawGrid(t,e,s,i){const a=new P,n=new P;this.ctx.strokeStyle="#29394b",this.ctx.beginPath();for(let l=-12;l<=12;l++)for(let r=0;r<2;r++){const u=l*.25;a.set(r?u:-3,i,r?-3:u).project(t),n.set(r?u:3,i,r?3:u).project(t),!(a.z<-1||a.z>1||n.z<-1||n.z>1)&&(this.ctx.moveTo((a.x+1)*e/2,(1-a.y)*s/2),this.ctx.lineTo((n.x+1)*e/2,(1-n.y)*s/2))}this.ctx.stroke()}draw(t,e,s,i,a,n,l,r,u){const h=e.map,f=this.pixels(h),p=t.geometry.getAttribute("position"),g=t.geometry.getAttribute("uv");if(!f||!p||!g)return;this.transform.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse).multiply(t.matrixWorld);const y=u&&Ft(t);let b=0,d=i-1,_=0,m=a-1;if(y){if(!y.bounds)return;const[M,T,E,I]=y.bounds;let j=1/0,O=-1/0,R=1/0,Y=-1/0;for(const U of[M,E])for(const it of[T,I]){const z=this.vertex.set((U-.5)*y.stack.size[0],0,(.5-it)*y.stack.size[1],1).applyMatrix4(this.transform),Z=(1+z.x/z.w)*i*.5,H=(1-z.y/z.w)*a*.5;j=Math.min(j,Z),O=Math.max(O,Z),R=Math.min(R,H),Y=Math.max(Y,H)}if(b=Math.max(b,Math.floor(j)),d=Math.min(d,Math.ceil(O)),_=Math.max(_,Math.floor(R)),m=Math.min(m,Math.ceil(Y)),b>d||_>m)return}const c=new Float32Array(p.count*4);for(let M=0;M<p.count;M++){const T=M*4,E=this.vertex.set(p.getX(M),p.getY(M),p.getZ(M),1).applyMatrix4(this.transform);c[T]=(1+E.x/E.w)*i*.5,c[T+1]=(1-E.y/E.w)*a*.5,c[T+2]=E.z/E.w,c[T+3]=E.w>0?1/E.w:0}const x=t.geometry.getAttribute("normal"),A=!!(l&&x&&u);l&&x&&u&&this.lighting.mesh(t,x,h,f,u);const v=t.geometry.index,k=v?.count??p.count,D=new Float32Array(4),L=h.magFilter===fe,B=t.matrixWorld.determinant()<0,K=Math.max(1,e.alphaTest*255);for(let M=0;M<k;M+=3){const T=v?.getX(M)??M,E=v?.getX(M+1)??M+1,I=v?.getX(M+2)??M+2,j=T*4,O=E*4,R=I*4,Y=c[j+2],U=c[O+2],it=c[R+2];if(!c[j+3]||!c[O+3]||!c[R+3]||Math.min(Y,U,it)>1)continue;const z=c[j],Z=c[j+1],H=c[O],$=c[O+1],W=c[R],F=c[R+1],X=wt(z,Z,H,$,W,F),Dt=B?X<0:X>0;if(!X||Dt&&e.side===_e)continue;const Bt=Math.max(b,Math.floor(Math.min(z,H,W))),qt=Math.min(d,Math.ceil(Math.max(z,H,W))),Gt=Math.max(_,Math.floor(Math.min(Z,$,F))),Qt=Math.min(m,Math.ceil(Math.max(Z,$,F))),ut=l&&x&&!A?.65+.35*Math.max(0,x.getY(T)*.7+x.getZ(T)*.5+x.getX(T)*.45):1;A&&this.lighting.triangle(p,g,T,E,I,X,h.flipY);const dt=($-F)/X,pt=(W-H)/X,mt=(F-Z)/X,ft=(z-W)/X,_t=r===4?.25:0,$t=(Math.abs(dt)+Math.abs(pt))*_t,Jt=(Math.abs(mt)+Math.abs(ft))*_t,te=(Math.abs(dt+mt)+Math.abs(pt+ft))*_t,ee=g.getX(T),se=g.getX(E),ie=g.getX(I),oe=g.getY(T),ne=g.getY(E),ae=g.getY(I);for(let J=Gt;J<=Qt;J++)for(let tt=Bt;tt<=qt;tt++){const gt=wt(H,$,W,F,tt+.5,J+.5)/X,yt=wt(W,F,z,Z,tt+.5,J+.5)/X;if(gt<-$t||yt<-Jt||1-gt-yt<-te)continue;let Tt=!1,At=0,vt=0,Ot=0;for(let et=0;et<r;et++){const Ct=r===1?0:et&1?.25:-.25,Rt=r===1?0:et&2?.25:-.25,ot=gt+Ct*dt+Rt*pt,nt=yt+Ct*mt+Rt*ft,bt=1-ot-nt;if(ot<0||nt<0||bt<0)continue;const at=ot*Y+nt*U+bt*it,q=(J*i+tt)*r+et;if(at<-1||at>1||at>=this.depth[q])continue;const ht=ot*c[j+3],rt=nt*c[O+3],lt=bt*c[R+3],st=1/(ht+rt+lt),kt=(ee*ht+se*rt+ie*lt)*st*h.repeat.x+h.offset.x,jt=(oe*ht+ne*rt+ae*lt)*st*h.repeat.y+h.offset.y,Lt=h.flipY?1-jt:jt;this.sample(f,kt,Lt,L,D),!(D[3]<K)&&(Tt||(A&&this.lighting.shade(D,f,kt,Lt,T,E,I,ht*st,rt*st,lt*st,Dt),At=D[0]*ut,vt=D[1]*ut,Ot=D[2]*ut,Tt=!0),this.depth[q]=at,n[q*4]=At,n[q*4+1]=vt,n[q*4+2]=Ot,n[q*4+3]=e.alphaToCoverage?D[3]:255)}}}}sample(t,e,s,i,a){const{width:n,height:l,data:r}=t,u=Math.min(n-1,Math.max(0,e*n-.5)),h=Math.min(l-1,Math.max(0,s*l-.5));if(i){const _=(Math.round(h)*n+Math.round(u))*4;for(let m=0;m<4;m++)a[m]=r[_+m];return}const f=Math.floor(u),p=Math.floor(h),g=Math.min(n-1,f+1),y=Math.min(l-1,p+1),b=u-f,d=h-p;for(let _=0;_<4;_++)a[_]=(r[(p*n+f)*4+_]*(1-b)+r[(p*n+g)*4+_]*b)*(1-d)+(r[(y*n+f)*4+_]*(1-b)+r[(y*n+g)*4+_]*b)*d}}const Ye="stack3-preview-5",Wt=new WeakMap;let Ne=0;function xt(o){let t=Wt.get(o);return t||(t=crypto.subtle?o.arrayBuffer().then(e=>crypto.subtle.digest("SHA-256",e)).then(e=>Array.from(new Uint8Array(e),s=>s.toString(16).padStart(2,"0")).join("")):Promise.resolve("session:"+Ne++),Wt.set(o,t),t)}async function He(o){return"parts"in o?JSON.stringify(await Promise.all(o.parts.map(async t=>[zt(t.layout),t.size??null,await xt(t.atlas)]))):"atlas"in o?JSON.stringify([zt(o.layout),await xt(o.atlas)]):JSON.stringify(await Promise.all(ge.map(t=>{const e=o.files[t];return e?xt(e):null})))}const V=new Map;let Ie;function St(){return Ie??=new Promise(o=>{try{const t=indexedDB.open(Ye,1);t.onupgradeneeded=()=>t.result.createObjectStore("results",{keyPath:"key"}).createIndex("savedAt","savedAt"),t.onsuccess=()=>o(t.result),t.onerror=t.onblocked=()=>o(null)}catch{o(null)}})}function Et(o,t){V.delete(o),V.set(o,t),V.size>4&&V.delete(V.keys().next().value)}async function Ke(o,t){const e=V.get(o);if(e)return Et(o,e),{value:e,origin:"Memory cache"};if(!t||!crypto.subtle)return null;const s=await St();return s?new Promise(i=>{const a=s.transaction("results").objectStore("results").get(o);a.onsuccess=()=>{const n=a.result;n&&Et(o,n.value),i(n?{value:n.value,origin:"Disk cache"}:null)},a.onerror=()=>i(null)}).catch(()=>null):null}async function We(o,t,e){if(Et(o,t),!e||!crypto.subtle)return;const s=await St();if(s)try{const a=s.transaction("results","readwrite").objectStore("results");a.put({key:o,value:t,savedAt:Date.now()});let n=0;const l=a.index("savedAt").openKeyCursor(null,"prev");l.onsuccess=()=>{const r=l.result;r&&(++n>12&&a.delete(r.primaryKey),r.continue())}}catch{}}async function Fe(){V.clear();const o=await St();o&&await new Promise((t,e)=>{const s=o.transaction("results","readwrite");s.objectStore("results").clear(),s.oncomplete=()=>t(),s.onabort=()=>e(s.error)})}export{Ze as C,Ue as O,Xe as _,We as a,Fe as c,Ke as f,He as s};
@@ -0,0 +1 @@
1
+ .scene-editor .topbar{min-height:60px;padding:8px clamp(12px,2vw,25px)}.scene-editor a[aria-current=page]{border-color:var(--accent);color:var(--accent)}.project-title{display:flex;align-items:center;gap:14px;min-width:0}#projectName{color:var(--muted);overflow-wrap:anywhere}.workspace{max-width:none;grid-template-columns:minmax(225px,.95fr) minmax(310px,3.2fr) minmax(232px,1fr);gap:0;padding:0;align-items:stretch;min-height:calc(100dvh - 60px)}.workspace aside{border:0;border-radius:0;overflow-wrap:anywhere;max-height:calc(100dvh - 60px);overflow-y:auto;scrollbar-color:var(--border) var(--surface)}.workspace aside section{padding:12px}.inspector-header{position:sticky;top:0;z-index:1;background:var(--surface);border-bottom:1px solid var(--border)}.inspector-tabs{display:grid;grid-template-columns:1fr 1fr;gap:4px;margin-top:8px}.inspector-tabs [aria-selected=true]{color:var(--accent);border-color:var(--accent)}#renderingPanel>h3:first-child{margin-top:0}#renderingPanel details{margin:8px 0}#renderingPanel summary{cursor:pointer}#renderingPanel select{max-width:100%}#renderingPanel .field:has(>input[type=checkbox]){display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:8px;padding-block:3px}.scene-stage{display:flex;flex-direction:column;min-width:0;border-inline:1px solid var(--border)}.stage-controls,.stage-status{padding:7px 10px;background:var(--surface)}.stage-status{display:flex;flex-wrap:wrap;gap:3px 14px;font-size:12px}#playTime{margin-inline-start:auto}.scene-editor #viewport{display:grid;flex:1;place-items:stretch;min-height:420px;height:calc(100dvh - 140px);touch-action:none;overflow:hidden}.scene-editor #viewport canvas{grid-area:1 / 1;min-width:0;min-height:0}.empty-stage{z-index:1;grid-area:1 / 1;align-self:center;justify-self:center;text-align:center;color:var(--muted);padding:18px;pointer-events:none}.scene-editor .hierarchy button,.scene-editor .inspector button{min-height:30px;padding:4px 8px}.scene-tree{margin-top:6px}.scene-tree .scene-tree{margin:0 0 0 8px;padding-left:6px;border-left:1px solid var(--border)}.scene-tree button{width:100%;text-align:left;background:transparent;border-color:transparent;overflow-wrap:anywhere}.scene-tree button:hover{background:#273647}.scene-tree button[aria-pressed=true]{background:#344539;color:#ebf2d6}.scene-tree small,.muted{color:var(--muted);font-size:.86em}.scene-tree small{display:inline-block;min-width:2.2em;margin-right:4px}.atlas-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:4px;margin:6px 0}.field{min-width:0}.field label{align-items:center}.field input[type=checkbox]{width:18px;height:18px;margin:0;accent-color:var(--accent)}.field-vector{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}.field-vector input{padding-inline:3px}.transform-sliders{display:grid;gap:5px}.transform-sliders>div{display:grid;grid-template-columns:1em minmax(0,1fr) 4.5rem;align-items:center;gap:6px}.transform-sliders input{min-width:0;width:100%}.transform-sliders input[type=range]{min-height:24px}.transform-sliders input[type=number]{padding-inline:4px;font-variant-numeric:tabular-nums}.transform-sliders label{color:var(--muted);font-size:.86em}.workspace aside .script-component{border-top:1px solid var(--border);margin:8px 0;padding:8px 0 0}.script-component>h3{margin-top:0}.script-component output{display:block;color:var(--muted);font-size:.86em}.script-component output:empty{display:none}.script-component details{margin:8px 0}.script-component summary{cursor:pointer}.script-component textarea{box-sizing:border-box;width:100%;padding:6px;resize:vertical;color:inherit;background:#161f28;border:1px solid var(--border);border-radius:4px;font-family:monospace}.inspector h3{margin:14px 0 4px;font-size:13px}.inspector .danger{color:#f5bcac;margin-top:10px}.connect{padding:clamp(20px,4vw,62px);max-width:750px;margin-inline:auto}.connect pre{padding:12px;overflow-x:auto;background:var(--surface);border:1px solid var(--border)}@media(max-width:885px){.workspace{grid-template-columns:minmax(173px,1fr) minmax(0,3fr)}.workspace .inspector{grid-column:1 / -1;max-height:none}.scene-editor #viewport{height:65vh;min-height:280px}}@media(max-width:490px){.workspace{display:flex;flex-direction:column}.workspace .hierarchy{order:1;max-height:none}.workspace .inspector{order:2}.scene-editor #viewport{height:48vh}}
@@ -0,0 +1,17 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./script-engine-Bs3azDYZ.js","./preview-cache-BKV0EZl9.js","./style-D6eZHs3D.js","./style-CMUT8CmM.css"])))=>i.map(i=>d[i]);
2
+ import{aJ as ze,aK as Je,aL as Ce,aM as He,aN as Me,V as ke,e as Ve,G as Le,aq as je,A as _e,r as Ze,O as Qe,ax as Te,aO as Xe,aP as $e,aQ as Ye,Q as et,aR as tt,as as Oe,s as nt,aw as ot,at as st,p as it,a6 as rt,an as at,W as ct,aS as lt,aT as dt,au as ut}from"./style-D6eZHs3D.js";import{_ as pt,O as ft,C as mt,f as ht,a as gt}from"./preview-cache-BKV0EZl9.js";function vt(t,l,d){const o=new Set(t.atlases.map(A=>A.id)),g=t.nodes.filter(A=>A.parentId===l.id&&A.atlasId&&o.has(A.atlasId)),y=g.filter(A=>/wheel|tire|tyre|바퀴|타이어/i.test(A.name+" "+A.id)),c=new Map;for(const A of g){const i=c.get(A.atlasId)??[];i.push(A),c.set(A.atlasId,i)}const p=[...c.values()].filter(A=>A.length===4&&y.every(i=>A.includes(i))),N=y.length===4?y:g.length===4?g:p.length===1?p[0]:null;if(!N)throw new Error("Cannot identify four wheels under "+l.id+". Supply --wheels <front-left,front-right,rear-left,rear-right>.");const U=[...N].sort((A,i)=>A.position[2]-i.position[2]),D=(A,i)=>A.position[0]-i.position[0];return[...U.slice(0,2).sort(D),...U.slice(2).sort(D)]}function ve(t,l,d,o){const g=(l.scripts??[]).filter(c=>c.id===d||c.name===o.name||(d==="wasd-vehicle"?Ce(c.source):c.source===o.source));if(g.length>1)throw new Error("Multiple "+o.name+" components on node "+l.id+".");const y=g[0];if(!y)return t.push({action:"script.set",nodeId:l.id,id:d,patch:o}),d;if(y.source!==o.source){if(!(d==="wasd-vehicle"&&Ce(y.source)||d==="tracked-drive"&&He(y.source)))throw new Error("Cannot replace customized "+o.name+" source on node "+l.id+".");t.push({action:"script.set",nodeId:l.id,id:y.id,patch:{source:o.source}})}return y.id}function wt(t,l,d){const o=t.nodes.find(w=>w.id===l);if(!o)throw new Error("Unknown vehicle root: "+l);const g=vt(t,o),[y,c,p,N]=g;if(Math.max(y.position[2],c.position[2])>=Math.min(p.position[2],N.position[2])||Math.max(y.position[0],p.position[0])>=Math.min(c.position[0],N.position[0]))throw new Error("Wheel positions must form two axles facing local −Z, with left wheels at smaller local X.");const U=(p.position[2]+N.position[2]-(y.position[2]+c.position[2]))/2*o.scale[2],D=g.reduce((w,h)=>{const{format:I,height:R,spacing:b}=h.settings;return w+R*h.scale[1]*(I==="stack"?b:1)/2},0)/4*o.scale[1];if(![U,D].every(w=>w>0&&w<=1e5))throw new Error("Vehicle wheelbase and radius must be positive and at most 100000 scene units.");const A=[],i=ve(A,o,"wasd-vehicle",ze(g.map(w=>w.id),U,D)),P=g.map((w,h)=>({role:["front-left","front-right","rear-left","rear-right"][h],node:w.id,component:ve(A,w,"sprite-stack-wheel",Me["sprite-stack-wheel"].script)}));return{actions:A,root:o.id,component:i,wheels:P}}function yt(t,l){const d=t.nodes.find(i=>i.id===l);if(!d)throw new Error("Unknown tank root: "+l);const o=t.nodes.filter(i=>i.parentId===d.id),g=new Map(t.atlases.map(i=>[i.id,i])),y=i=>i.atlasId?g.get(i.atlasId):void 0,c=o.filter(i=>{const P=y(i);return P&&/track|tread|트랙|궤도/i.test([i.name,i.id,P.name].join(" "))}).sort((i,P)=>i.position[0]-P.position[0]);if(c.length!==2||c[0].position[0]>=0||c[1].position[0]<=0)throw new Error("Provide two atlas-backed track children with track or tread in their names, one on each side of the root.");const p=o.filter(i=>{const P=y(i);return/turret|포탑/i.test([i.name,i.id,P?.name].join(" "))?P||t.nodes.some(w=>w.parentId===i.id&&y(w)):!1});if(p.length!==1)throw new Error("Provide one turret child or a named turret pivot with an atlas-backed child.");const N=[],U=ve(N,d,"tracked-drive",Je(c.map(i=>i.id),c.map(i=>i.position[0]*d.scale[0]))),D=ve(N,p[0],"turret-control",Me["turret-control"].script),A=c.map((i,P)=>{if(i.settings.format!=="stack")throw new Error(i.name+" must use Sprite stack to animate its belt.");return{role:P===0?"left":"right",node:i.id,component:ve(N,i,"track-belt",Me["track-belt"].script)}});return{actions:N,root:d.id,component:U,turret:{node:p[0].id,component:D},tracks:A}}const bt=[0,0,0],Se=(t,l)=>t+"/"+l;function kt(t,l){const d=t.newRuntime();d.setMemoryLimit(4*1024*1024),d.setMaxStackSize(256*1024);let o=performance.now()+30;d.setInterruptHandler(()=>performance.now()>=o);const g=d.newContext();try{const y=g.unwrapResult(g.evalCode(`(() => {
3
+ "use strict";
4
+ const parse = JSON.parse, stringify = JSON.stringify;
5
+ const callback = (() => {
6
+ ${l}
7
+ if (typeof update !== 'function') throw new Error('Define function update(input).');
8
+ return update;
9
+ })();
10
+ return json => {
11
+ const output = stringify(callback(parse(json)) ?? {});
12
+ if (!output || output.length > 16384) throw new Error('Script output must be JSON of 16 KB or less.');
13
+ return output;
14
+ };
15
+ })()`,"component.js"));return{runtime:d,context:g,update:y,limit:c=>{o=c}}}catch(y){throw g.dispose(),d.dispose(),y}}function Re(t){t&&(t.update.dispose(),t.context.dispose(),t.runtime.dispose())}function Ae(t){return Array.isArray(t)&&t.length===3&&t.every(l=>typeof l=="number"&&Number.isFinite(l)&&Math.abs(l)<=1e4)}function Et(t){if(!t||typeof t!="object")return!1;const{rollScale:l,steeringScale:d}=t;return[l,d].every(o=>Number.isFinite(o)&&Math.abs(o)<=4)}function De(t,l){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(l)}function St(t,l,d){t.limit(d);const{context:o,update:g}=t,y=o.newString(l);try{const p=o.unwrapResult(o.callFunction(g,o.undefined,y)).consume(N=>JSON.parse(o.getString(N)));if(!p||typeof p!="object"||Array.isArray(p)||p.translation!==void 0&&!Ae(p.translation)||p.rotation!==void 0&&!Ae(p.rotation)||p.stackWheel!==void 0&&!Et(p.stackWheel)||p.childRotations!==void 0&&!De(p.childRotations,Ae)||p.trackBelt!==void 0&&(!Number.isFinite(p.trackBelt)||Math.abs(p.trackBelt)>4)||p.childTrackTravel!==void 0&&!De(p.childTrackTravel,N=>typeof N=="number"&&Number.isFinite(N)&&Math.abs(N)<=1e9))throw new Error("Return valid finite transform, wheel, and track outputs.");return p}finally{y.dispose()}}function At(t){const l=new Set,d=new Map,o=new Map,g=new Map;let y,c,p;function N(i,P){const{node:w,script:h}=i;g.set(Se(w.id,h.id),P),t(w.id,h.id,P)}function U(i){const P=c&&c.play.resetCount!==i.play.resetCount;c=i;const w=new Set;for(const h of i.nodes)for(const I of h.scripts??[]){const R=Se(h.id,I.id);if(!I.enabled)continue;w.add(R);const b=d.get(R);if(!P&&b&&b.script.source===I.source){b.node=h,b.script=I;continue}Re(b?.vm);const q={node:h,script:I};d.set(R,q),N(q,"Loading script…"),y??=pt(()=>import("./script-engine-Bs3azDYZ.js"),__vite__mapDeps([0,1,2,3]),import.meta.url).then(L=>L.createScriptEngine()).catch(L=>{throw y=void 0,L}),y.then(L=>{d.get(R)===q&&(q.vm=kt(L,I.source),N(q,"Ready"))}).catch(L=>{d.get(R)===q&&(q.failed=!0,N(q,String(L).slice(0,500)))})}for(const[h,I]of d)w.has(h)||(Re(I.vm),d.delete(h),g.delete(h));(P||!d.size)&&(l.clear(),o.clear(),p=void 0)}function D(i,P,w){if(!w)return;const h=o.get(i)??{},I=h[P]??bt;h[P]=[I[0]+w[0],I[1]+w[1],I[2]+w[2]],o.set(i,h)}function A(i){const P=p===void 0?0:Math.min(.05,Math.max(0,i-p));if(p=i,!c||!d.size)return o;o.clear();const w=c.play.startedAt!==null&&P>0&&!document.hidden,h=performance.now()+8;for(const I of d.values()){const{node:R,script:b,vm:q}=I;if(!q||I.failed)continue;const L=c.nodes.filter(B=>B.parentId===R.id);if(w&&performance.now()<h)try{I.output=St(q,JSON.stringify({dt:P,time:i,keys:[...l],fields:Object.fromEntries(b.fields.map(B=>[B.name,B.value])),state:I.output?.state??{},position:R.position,rotation:R.rotation,children:L.map(({id:B,name:_,position:oe})=>({id:B,name:_,position:oe}))}),Math.min(h,performance.now()+4))}catch(B){I.failed=!0,N(I,String(B).slice(0,500))}const K=I.output;if(K){if(D(R.id,"translation",K.translation),D(R.id,"rotation",K.rotation),K.stackWheel||K.trackBelt!==void 0){const B=o.get(R.id)??{};K.stackWheel&&(B.stackWheel=K.stackWheel),K.trackBelt!==void 0&&(B.trackBelt=K.trackBelt),o.set(R.id,B)}for(const B of L)if(K.childRotations&&Object.hasOwn(K.childRotations,B.id)&&D(B.id,"wheelRotation",K.childRotations[B.id]),K.childTrackTravel&&Object.hasOwn(K.childTrackTravel,B.id)){const _=o.get(B.id)??{};_.trackTravel=(_.trackTravel??0)+K.childTrackTravel[B.id],o.set(B.id,_)}}}return o}return{sync:U,tick:A,hasScripts:()=>d.size>0,keyDown:i=>l.add(i),keyUp:i=>l.delete(i),clearKeys:()=>l.clear(),status:(i,P)=>g.get(Se(i,P))??""}}const Be=new ke;function It(t,l,d){const o=d*t.scale.y;t.position.add(Be.set(0,o,0).applyQuaternion(t.quaternion)),t.quaternion.multiply(l),t.position.sub(Be.set(0,o,0).applyQuaternion(t.quaternion))}const me=Math.PI/180;function Mt(t,l,d,o,g){const y=new Ve,c=new Le,p=o?At(g):void 0,N=new tt(0,0,0,"YXZ"),U=new et;let D=null;const A=new ke,i=new ke,P=new je(24,48,5334392,3227985);y.add(c,P,new _e(16777215,.85));const w=new Ze(16777215,1.5);w.position.set(2,3,2),y.add(w);const h=new Qe(-2,2,2,-2,.01,1e4);h.position.set(3,3,4);const I=new ft(h,t);I.enablePan=!1,I.minZoom=.1,I.maxZoom=10,I.maxPolarAngle=Math.acos(.2);const R=new mt;t.append(R.canvas);let b,q=!1,L,K,B=new Map,_=2,oe=6,e=0,n=!1,r="";const s=new Map,u=new Map,T=new Map,F=new Map,f=new Worker(new URL(""+new URL("reconstruct.worker-ONc9GyFO.js",import.meta.url).href,import.meta.url),{type:"module"});let W=Promise.resolve(),J=0;function M(){const a=t.clientWidth,S=t.clientHeight;if(!a||!S)return;const O=a/S;if(h.left=-_*Math.max(1,O),h.right=-h.left,h.bottom=-_*Math.max(1,1/O),h.top=-h.bottom,h.updateProjectionMatrix(),!b)return;const G=Math.min(window.devicePixelRatio||1,2)*(L?.view.supersampling?2:1);e!==G&&(e=G,b.setPixelRatio(G)),b.setSize(a,S,!1)}function m(){const a=L?.view.backend==="gpu"&&!q;if(a&&!b)try{b=new ct({antialias:!0}),b.setClearColor(1186083),b.domElement.addEventListener("webglcontextlost",O=>{O.preventDefault(),q=!0,m(),z()}),b.domElement.addEventListener("webglcontextrestored",()=>{q=!1,m(),z()}),t.append(b.domElement)}catch{q=!0}const S=a&&!q&&!!b;R.canvas.hidden=S,b&&(b.domElement.hidden=!S),t.dataset.backend=S?"gpu":"cpu",M()}function E(){const a=L?.view;if(!a)return;const S=Math.acos(Math.min(.99999,a.squash)),O=new ke().setFromSpherical(new Te(oe,S,a.yaw*me));h.position.copy(I.target).add(O),h.zoom=a.scale,h.updateProjectionMatrix(),I.update()}I.addEventListener("end",()=>{const a=new Te().setFromVector3(h.position.clone().sub(I.target));l({yaw:a.theta/me,squash:Math.max(.2,Math.min(1,Math.cos(a.phi))),scale:h.zoom})}),new ResizeObserver(M).observe(t);function ee(){const a=new it;if(c.updateMatrixWorld(!0),c.traverseVisible(O=>{O instanceof rt&&a.expandByObject(O)}),a.isEmpty())return;const S=a.getBoundingSphere(new at);_=Math.max(.05,S.radius)*1.12,oe=Math.max(6,_*3),I.target.copy(S.center),M(),E()}function z(){const a=L?.nodes.filter(k=>k.atlasId)??[],S=a.filter(k=>Q(k.id)).length,O=[...u.values()][0],G=S<a.length?`${S}/${a.length} assets ready`:`${S} assets ready`;d(O||(q&&L?.view.backend==="gpu"?"WebGL unavailable · CPU preview":G),S)}function Q(a){const S=s.get(a);return!!S?.content&&S.key===S.renderedKey}function j(a){const S=a.fingerprint??a.id;let O=T.get(S);if(!O){const G=t.dataset.endpoint+"/atlas/"+a.id+(a.fingerprint?"?fingerprint="+a.fingerprint:"");O=fetch(G).then(k=>{if(!k.ok)throw new Error("Could not read the embedded atlas.");return k.blob()}).catch(k=>{throw T.delete(S),k}),T.set(S,O)}return O}function de(a,S,O,G){const k=F.get(a);if(k)return k;const v=W.then(async()=>{const x=await ht(a,!0);if(x)return x.value;const H={atlas:await j(S),layout:S.layout},te=++J,V=await new Promise((re,ae)=>{f.onmessage=({data:ne})=>{ne.id===te&&("error"in ne?ae(new Error(ne.error)):ne.preview||re(ne))},f.onerror=()=>ae(new Error("Failed to run the reconstruction worker.")),f.postMessage({id:te,sourceKey:"project:"+(S.fingerprint??S.id),source:H,target:G,settings:O,keepTop:G==="stack"})});return gt(a,V,!0),V});return F.set(a,v),W=v.then(()=>{},()=>{}),v.then(()=>F.delete(a),()=>F.delete(a)),v}function fe(a,S){if(!a.content)return;const{spacing:O,pixelArt:G,smoothEdges:k,lighting:v,format:x}=S.settings,H=JSON.stringify([O,G,k,v,x]);a.display!==H&&(a.display=H,a.content.scale.y=x==="stack"?O:1,ot(a.content,v),x==="stack"&&st(a.content,G,k))}function Ee(a,S){a.content&&(a.group.remove(a.content),Oe(a.content)),a.content=S,a.display=void 0,a.group.add(S)}function Ue(a){const S=!L||a.view.backend!==L.view.backend||a.view.supersampling!==L.view.supersampling;n||=!L||a.view.frame!==L.view.frame,L=a,p?.sync(a),K=void 0,B=new Map(a.play.offsets?.map(k=>[k.id,k]));const O=new Map(a.nodes.map(k=>[k.id,k]));for(const[k,v]of s)O.has(k)||(v.group.removeFromParent(),v.content&&Oe(v.content),u.delete(k),s.delete(k));for(const k of a.nodes)s.has(k.id)||s.set(k.id,{group:new Le});for(const k of a.nodes){const v=s.get(k.id),x=k.parentId?s.get(k.parentId)?.group??c:c;v.group.parent!==x&&x.add(v.group),v.group.name=k.name,v.group.visible=k.visible,v.group.scale.set(...k.scale);const H=a.atlases.find($=>$.id===k.atlasId);if(!H)continue;const{format:te,layers:V,resolution:re,threshold:ae,height:ne,pivot:he,profile:ue}=k.settings,X={layers:V,resolution:re,threshold:ae,height:ne,pivot:he,profile:ue,textureProjection:k.settings.textureProjection,meshMethod:k.settings.meshMethod,contourHub:k.settings.contourHub},ce=JSON.stringify(["project-v2",H.fingerprint??H.id,H.layout,te,X]);fe(v,k),v.key!==ce&&(v.key=ce,u.delete(k.id),de(ce,H,X,te==="glb"?"mesh":"stack").then(({result:$,top:we})=>{if(s.get(k.id)!==v||v.key!==ce)return;v.asset=$,v.top=we,v.rolling=void 0,v.belt=void 0,Ee(v,nt($)),v.centerY=$.size[2]*.5-$.pivot[2],v.renderedKey=ce;const xe=L?.nodes.find(Ge=>Ge.id===k.id);xe&&fe(v,xe),n||=!c.userData.framed,z()}).catch($=>{s.get(k.id)!==v||v.key!==ce||(u.set(k.id,k.name+" · "+$.message),z())}))}S&&m();const G=JSON.stringify([a.view.yaw,a.view.squash,a.view.scale]);G!==r&&(r=G,E()),P.visible=a.view.grid,z()}const We=document.getElementById("playTime");function qe(a,S){const O={id:a,patch:S};return K=O,()=>{K===O&&(K=void 0)}}let Ne="";function Pe(){if(requestAnimationFrame(Pe),!L)return;const a=Xe(L.play),S=p?.tick(a),O=a.toFixed(1)+" s";O!==Ne&&(We.value=O,Ne=O);for(const v of L.nodes){const x=s.get(v.id),{group:H}=x,te=B.get(v.id),V=S?.get(v.id),re=V?.stackWheel,ae=V?.trackBelt;if(x.asset?.target==="stack"&&(ae!==void 0&&x.top?x.belt||(x.belt=$e(x.asset,x.top),x.rolling=void 0,Ee(x,x.belt.object),fe(x,v)):re&&!x.rolling&&(x.rolling=Ye(x.asset),x.belt=void 0,Ee(x,x.rolling.object),fe(x,v)),x.belt)){const ue=ae!==void 0&&V?.trackTravel!==void 0?ae*V.trackTravel:void 0,X=H.parent?.scale;x.belt.setTravel(ue,x.asset.size[1]*v.scale[2]*(X?.z??1),x.asset.size[2]*v.settings.spacing*v.scale[1]*(X?.y??1))}const ne=K?.id===v.id?K.patch:void 0,he=ne?.position??v.position;if(H.position.set(he[0]+a*v.velocity[0]+(te?.translation[0]??0)+(V?.translation?.[0]??0),he[1]+a*v.velocity[1]+(te?.translation[1]??0)+(V?.translation?.[1]??0),he[2]+a*v.velocity[2]+(te?.translation[2]??0)+(V?.translation?.[2]??0)),H.rotation.set(...(ne?.rotation??v.rotation).map((ue,X)=>(ue+a*v.angularVelocity[X]+(te?.rotation[X]??0)+(V?.rotation?.[X]??0))*me)),V?.wheelRotation){const[ue,X,ce]=V.wheelRotation,$=ue*(re?.rollScale??1),we=!!(re&&x.rolling);x.rolling?.setRoll(we?$:0,v.settings.spacing),U.setFromEuler(N.set(we?0:$*me,X*(re?.steeringScale??1)*me,ce*me)),It(H,U,(x.centerY??0)*(x.content?.scale.y??1))}else x.rolling?.setRoll(0,v.settings.spacing)}const G=o?L.view.follow??null:null,k=G&&s.get(G)?.group;k&&(k.getWorldPosition(i),G===D?(i.sub(A),I.target.add(i),h.position.add(i),A.add(i)):A.copy(i)),D=G,n&&L.nodes.every(v=>!v.atlasId||Q(v.id)||u.has(v.id))&&(ee(),n=!1,c.userData.framed=!0),t.dataset.backend==="gpu"?b?.render(y,h):R.render(c,h,L.view.supersampling,L.view.grid,0,!1,L.view)}return requestAnimationFrame(Pe),{sync:Ue,previewTransform:qe,scripts:p}}function C(t){return document.getElementById(t)}const Ke=new URLSearchParams(location.search),Ie=Ke.get("session"),pe=Ke.get("playground")==="1";Ie&&/^[a-f0-9-]{36}$/.test(Ie)?Nt(Ie):(pe&&C("openInstruction").append(" --playground"),C("disconnected").hidden=!1);function Nt(t){const l=new URL("./__stack3_project/"+t,location.href).pathname,d=C("viewport");d.dataset.endpoint=l;const o=C("status"),g=C("editorMode"),y=C("playMode");C("compareMode").href="./compare.html?session="+t,g.href="./project.html?session="+t,y.href=g.href+"&playground=1",g.hidden=y.hidden=!1,(pe?y:g).setAttribute("aria-current","page"),C("workspace").hidden=!1,C("stageTitle").textContent=pe?"Playground":"Scene",o.value="Connecting…";let c,p="",N="",U="",D,A=Promise.resolve();const i=Mt(d,e=>b([{action:"view.set",patch:e}]),(e,n)=>{C("buildStatus").value=e,d.dataset.readyCount=String(n)},pe,(e,n,r)=>{const s=document.getElementById(Fe(e,n));s&&(s.textContent=r)}),P=[C("objectTab"),C("renderingTab")];function w(e){for(const[r,s]of P.entries())s.setAttribute("aria-selected",String(r===e)),s.tabIndex=r===e?0:-1,C(s.getAttribute("aria-controls")).hidden=r!==e;const n=e===1?"#rendering":"";g.hash=n,y.hash=n}w(location.hash==="#rendering"?1:0);for(const[e,n]of P.entries())n.addEventListener("click",()=>w(e)),n.addEventListener("keydown",r=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(r.key))return;r.preventDefault(),r.stopPropagation();const s=r.key==="Home"?0:r.key==="End"?P.length-1:(e+1)%P.length;w(s),P[s].focus()});function h(e){const n=e.nodes.filter(f=>f.atlasId),r=n.find(f=>f.id===D)??n[0];D=r?.id;const s=JSON.stringify([r?.id,r?.settings,n.map(({id:f,name:W})=>[f,W])]);if(s===N)return;N=s;const u=C("assetProperties"),T=u.querySelector("details")?.open,F=u.contains(document.activeElement)?document.activeElement?.id:void 0;if(!r){u.replaceChildren(ye("Import an atlas to configure asset rendering."));return}u.replaceChildren(le("Part",r.id,n.map(({id:f,name:W})=>[f,W]),f=>{D=f,c&&h(c)}),...K(r)),T&&(u.querySelector("details").open=!0),F&&document.getElementById(F)?.focus({preventScroll:!0})}function I(e){if(c&&e.revision<=c.revision)return;c?.view.selected!==e.view.selected&&e.nodes.some(M=>M.id===e.view.selected&&M.atlasId)&&(D=e.view.selected),c=e,document.documentElement.dataset.revision=String(e.revision),i.sync(e),C("projectName").textContent=e.name,document.title=e.name+" · "+(pe?"Playground":"Scene editor")+" · stack3.js",C("emptyStage").hidden=e.nodes.some(M=>M.atlasId),C("hierarchy").replaceChildren(q(e,null)),C("atlasLibrary").replaceChildren(...e.atlases.map(M=>{const m=document.createElement("div");m.className="atlas-row";const E=document.createElement("span");E.textContent=M.name;const ee=Z("Instance",()=>{const z=crypto.randomUUID();b([{action:"node.add",id:z,name:M.name,atlasId:M.id,parentId:c?.view.selected??null},{action:"view.set",patch:{selected:z}},{action:"view.frame"}])});return m.append(E,ee),e.nodes.some(z=>z.atlasId===M.id)||m.append(Z("Remove atlas",()=>b([{action:"atlas.remove",id:M.id}]))),m}));const n=e.nodes.find(M=>M.id===e.view.selected),r=i.scripts?.hasScripts();C("playTarget").textContent=r?e.play.startedAt===null?"Press Play to run script components.":"Script components running. Keyboard input is active.":n?n.name+" · Nudge with WASD":"Select an object to nudge it with WASD.",C("moveButtons").hidden=!!r;for(const M of C("moveButtons").querySelectorAll("button"))M.disabled=!n;const s=C("properties"),u=document.activeElement,T=u instanceof HTMLInputElement&&u.dataset.transformNode===n?.id?u.id:"",F=JSON.stringify([n,e.nodes.map(({id:M,name:m,parentId:E})=>[M,m,E])]);if(F!==p){const M=new Set(Array.from(s.querySelectorAll("details[open]")).map(m=>m.dataset.scriptEditor));p=F,s.replaceChildren(...n?L(n,e):[ye("Select an object to edit its properties.")]);for(const m of s.querySelectorAll("details[data-script-editor]"))m.open=M.has(m.dataset.scriptEditor);T&&document.getElementById(T)?.focus({preventScroll:!0})}h(e);const f=C("viewProperties"),W=JSON.stringify([e.view,e.nodes.filter(M=>M.scripts?.length).map(({id:M,name:m})=>[M,m])]);if(U!==W){U=W;const M=f.contains(document.activeElement)?document.activeElement?.id:void 0;f.replaceChildren(..._(e)),M&&document.getElementById(M)?.focus({preventScroll:!0})}const J=C("togglePlay");J.textContent=e.play.startedAt===null?"Play":"Pause",J.setAttribute("aria-pressed",String(e.play.startedAt!==null))}async function R(){try{const e=c?"?after="+c.revision:"",n=await fetch(l+"/state"+e);if(!n.ok)throw new Error("The live project server is unavailable.");n.status!==204&&(I(await n.json()),o.value="")}catch(e){o.value=e.message}}function b(e){return A=A.then(async()=>{if(c)try{const n=typeof e=="function"?e(c):e;if(!n.length){o.value="";return}const r=await fetch(l+"/actions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({revision:c.revision,actions:n})}),s=await r.json();if(r.status===409&&await R(),!r.ok)throw new Error(s.error||"Could not apply the edit.");I(s),o.value=""}catch(n){o.value=n.message}}),A}function q(e,n){const r=document.createElement("ul");r.className="scene-tree";for(const s of e.nodes.filter(u=>u.parentId===n)){const u=document.createElement("li"),T=Z(s.name,()=>b([{action:"view.set",patch:{selected:s.id}}])),F=document.createElement("small");F.textContent=s.atlasId?s.settings.format==="glb"?"3D":"2D":"Group",T.prepend(F),T.dataset.node=s.id,T.setAttribute("aria-pressed",String(s.id===e.view.selected)),u.append(T,q(e,s.id)),r.append(u)}return r}function L(e,n){const r=m=>b([{action:"node.set",id:e.id,patch:m}]),s=new Map(n.nodes.map(m=>[m.id,m.parentId])),u=n.nodes.filter(m=>{for(let E=m.id;E;E=s.get(E))if(E===e.id)return!1;return!0}),T=!e.parentId&&!e.atlasId,F=(m,E)=>{if(!T)return be(m,e[E],z=>r({[E]:z}));const ee=(z,Q,j)=>{const de=[...z];return de[Q]=j,de};return Ct(m,e.id,e[E],E==="position",(z,Q)=>i.previewTransform(e.id,{[E]:ee(e[E],z,Q)}),(z,Q)=>b(j=>{const de=j.nodes.find(fe=>fe.id===e.id);return de?[{action:"node.set",id:e.id,patch:{[E]:ee(de[E],z,Q)}}]:[]}))},f=[xt("Name",e.name,m=>r({name:m})),le("Parent",e.parentId??"",[["","Scene root"],...u.map(m=>[m.id,m.name])],m=>b([{action:"node.move",id:e.id,parentId:m||null}])),Y("Visible",e.visible,m=>r({visible:m})),F("Position","position"),F("Rotation (degrees)","rotation"),be("Scale",e.scale,m=>r({scale:m}))];if(T||n.nodes.some(m=>m.parentId===e.id)){const m=document.createElement("div");m.className="toolbar",m.append(Z("Apply Four-wheel",()=>b(E=>wt(E,e.id).actions)),Z("Apply Tracked Tank",()=>b(E=>yt(E,e.id).actions))),f.push(ge("Presets"),m)}f.push(ge("Motion"),be("Velocity (units/s)",e.velocity,m=>r({velocity:m})),be("Angular velocity (degrees/s)",e.angularVelocity,m=>r({angularVelocity:m}))),f.push(ge("Script components"));for(const m of e.scripts??[])f.push(B(e,m));const W=(m,E=crypto.randomUUID())=>b([{action:"script.set",nodeId:e.id,id:E,patch:m}]),J=document.createElement("div");J.className="toolbar",J.append(Z("Add script",()=>W({name:"Script",enabled:!1,fields:[],source:`function update({ dt, time, keys, fields, state, position, rotation, children }) {
16
+ return {};
17
+ }`})),Z("Add WASD vehicle",()=>W(lt))),e.atlasId&&!e.scripts?.some(m=>m.id==="sprite-stack-wheel")&&J.append(Z("Add Sprite Stack Wheel",()=>W(dt,"sprite-stack-wheel"))),f.push(J);const M=Z("Remove subtree",()=>b([{action:"node.remove",id:e.id}]));return M.className="danger",f.push(M),f}function K(e){const n=e.settings,r=f=>b([{action:"node.set",id:e.id,patch:{settings:f}}]),s=n.format==="stack",u=!s&&n.meshMethod==="contour",T=document.createElement("details"),F=document.createElement("summary");return F.textContent="Reconstruction settings",T.append(F,...u?[]:[se("Layers",n.layers,8,Number.MAX_SAFE_INTEGER,1,f=>r({layers:f}))],...!u||n.contourHub?[se(u?"Hub segments":"Texture resolution",n.resolution,16,Number.MAX_SAFE_INTEGER,1,f=>r({resolution:f}))]:[],...s?[se("Spacing",n.spacing,.05,20,.05,f=>r({spacing:f}))]:[],se("Height",n.height,.01,100,.01,f=>r({height:f})),se("Background threshold",n.threshold,0,255,1,f=>r({threshold:f})),le("Pivot",n.pivot,[["ground","Ground"],["center","Center"]],f=>r({pivot:f})),...u?[]:[le("Cross-section",n.profile,[["silhouette","From silhouettes"],["round","Round"],["round-base","Round above square base"]],f=>r({profile:f}))]),[le("Asset type",u?"contour":n.format,[["stack","Sprite stack"],["glb","Marching Cubes (3D mesh)"],["contour","Contour extrusion (3D mesh)"]],f=>r({format:f==="stack"?"stack":"glb",meshMethod:f==="contour"?"contour":"marching-cubes"})),...s?[]:[le("Texture projection",n.textureProjection??"auto",[["auto","Automatic (multi-view)"],["top-contour","Upper contour from TOP"]],f=>r({textureProjection:f}))],...u?[Y("Centered round hub",n.contourHub??!1,f=>r({contourHub:f}))]:[],ye(s?"Multi-view texturing blends colors from the atlas views.":"Multi-view texturing projects atlas views onto the mesh."),Y("Material lighting",n.lighting,f=>r({lighting:f})),...s?[Y("Pixel art",n.pixelArt,f=>r({pixelArt:f})),Y("Smooth edges",n.smoothEdges,f=>r({smoothEdges:f}))]:[],T]}function B(e,n){const r=document.createElement("section");r.className="script-component";const s=E=>b([{action:"script.set",nodeId:e.id,id:n.id,patch:E}]),u=document.createElement("output");u.id=Fe(e.id,n.id);const T=u.id;u.textContent=n.enabled&&i.scripts?.status(e.id,n.id)||"",r.append(ge(n.name),Y("Enabled",n.enabled,E=>s({enabled:E}),T+"-enabled"),u);for(const E of n.fields)r.append(se(E.label,E.value,E.min,E.max,E.step,ee=>{ee<E.min||ee>E.max||b(z=>{const Q=z.nodes.find(j=>j.id===e.id)?.scripts?.find(j=>j.id===n.id);return Q?[{action:"script.set",nodeId:e.id,id:n.id,patch:{fields:Q.fields.map(j=>j.name===E.name?{...j,value:ee}:j)}}]:[]})},T+"-field-"+E.name));const F=document.createElement("details");F.dataset.scriptEditor=T;const f=document.createElement("summary");f.textContent="Edit script";const W=document.createElement("input");W.type="text",W.value=n.name;const J=document.createElement("textarea");J.value=n.source,J.rows=9,J.spellcheck=!1;const M=document.createElement("textarea");M.value=JSON.stringify(n.fields,null,2),M.rows=6,M.spellcheck=!1,W.id=T+"-name",J.id=T+"-source",M.id=T+"-fields";const m=document.createElement("output");return m.setAttribute("role","status"),F.append(f,ie("Name",W),ie("JavaScript",J),ie("Inspector fields (JSON)",M),m,Z("Save script",()=>{try{const E=JSON.parse(M.value);if(!Array.isArray(E))throw new Error("Use a JSON array for inspector fields.");s({name:W.value,source:J.value,fields:E}),m.textContent=""}catch(E){m.textContent=E.message}})),r.append(F,Z("Remove script",()=>b([{action:"script.remove",nodeId:e.id,id:n.id}]))),r}function _(e){const n=e.view,r=u=>b([{action:"view.set",patch:u}]),s=e.nodes.filter(u=>u.scripts?.length||u.id===n.follow);return[le("Renderer",n.backend,[["cpu","CPU"],["gpu","GPU"]],u=>r({backend:u})),Y("Grid",n.grid,u=>r({grid:u})),Y("Supersampling",n.supersampling,u=>r({supersampling:u})),ge("CPU rendering"),Y("Detail Normals",!!n.detailNormals,u=>r({detailNormals:u,backend:"cpu"})),Y("Subpixel AA",!!n.subpixelAA,u=>r({subpixelAA:u,backend:"cpu"})),Y("Specular AA",!!n.specularAA,u=>r({specularAA:u,backend:"cpu"})),ye("Detail Normals and Specular AA use each part’s Material lighting setting."),...pe&&s.length?[le("Follow object",n.follow??"",[["","None"],...s.map(u=>[u.id,u.name])],u=>r({follow:u||null}))]:[],se("Squash",n.squash,.2,1,.01,u=>r({squash:u})),se("Zoom",n.scale,.1,10,.05,u=>r({scale:u})),se("Heading",n.yaw,-360,360,1,u=>r({yaw:u}))]}if(C("newGroup").addEventListener("click",()=>{const e=crypto.randomUUID();b([{action:"node.add",id:e,name:"Group",parentId:c?.view.selected??null},{action:"view.set",patch:{selected:e}}])}),C("frameScene").addEventListener("click",()=>b([{action:"view.frame"}])),C("stepTime").addEventListener("click",()=>b([{action:"play.step",seconds:1}])),C("resetTime").addEventListener("click",()=>b([{action:"play.reset"}])),C("togglePlay").addEventListener("click",()=>{b([{action:c?.play.startedAt===null?"play.start":"play.pause"}])}),pe){C("playControls").hidden=!1;const e={KeyA:[-.25,0,0],KeyD:[.25,0,0],KeyW:[0,0,-.25],KeyS:[0,0,.25]},n=s=>{const u=c?.view.selected;u&&e[s]&&b([{action:"play.nudge",id:u,translation:e[s]}])};for(const[s,u]of[["KeyA","Left"],["KeyW","Forward"],["KeyS","Back"],["KeyD","Right"]])C("moveButtons").append(Z(u,()=>n(s)));const r=s=>s instanceof Element&&!!s.closest('input:not([type="checkbox"]),select,textarea,[contenteditable]');document.addEventListener("keydown",s=>{if(!(s.altKey||s.ctrlKey||s.metaKey||r(s.target))&&!(s.code==="Space"&&s.target instanceof HTMLInputElement&&s.target.type==="checkbox")){if(i.scripts?.hasScripts()){if(c?.play.startedAt==null)return;(Object.hasOwn(e,s.code)||s.code.startsWith("Arrow")||s.code==="Space")&&s.preventDefault(),i.scripts.keyDown(s.code);return}s.repeat||!Object.hasOwn(e,s.code)||(s.preventDefault(),n(s.code))}}),document.addEventListener("keyup",s=>i.scripts?.keyUp(s.code)),document.addEventListener("focusin",s=>{r(s.target)&&i.scripts?.clearKeys()}),window.addEventListener("blur",()=>i.scripts?.clearKeys()),document.addEventListener("visibilitychange",()=>i.scripts?.clearKeys())}const oe=C("atlasFiles");C("importAtlases").addEventListener("click",()=>oe.click()),oe.addEventListener("change",async()=>{const e=[...oe.files??[]];if(oe.value="",!e.length||!c)return;const n=c.view.selected;try{const r=ut(C("importLayout").value).join(","),s=[];let u;for(const T of e){if(T.size>16*1024*1024)throw new Error("Use PNGs of up to 16 MB per file.");const{png:F,hash:f}=await Pt(T,r),W=crypto.randomUUID(),J=T.name.replace(/\.png$/i,"");s.push({action:"atlas.embed",id:f,name:J,png:F,layout:r},{action:"node.add",id:W,name:J,parentId:n,atlasId:f}),u=W}s.push({action:"view.set",patch:{selected:u}},{action:"view.frame"}),b(s)}catch(r){o.value=r.message}}),R(),window.setInterval(()=>{R()},650)}function Fe(t,l){return"script-status-"+t+":"+l}async function Pt(t,l){const d=new Uint8Array(await t.arrayBuffer()),o=new TextEncoder().encode(l),g=new Uint8Array(o.length+d.length);g.set(o),g.set(d,o.length);const y=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",g)),p=>p.toString(16).padStart(2,"0")).join("");let c="";for(let p=0;p<d.length;p+=8192)c+=String.fromCharCode(...d.subarray(p,p+8192));return{hash:y,png:btoa(c)}}function Z(t,l){const d=document.createElement("button");return d.type="button",d.textContent=t,d.addEventListener("click",l),d}function ge(t){const l=document.createElement("h3");return l.textContent=t,l}function ye(t){const l=document.createElement("p");return l.className="muted",l.textContent=t,l}function ie(t,l){const d=document.createElement("div");d.className="field";const o=document.createElement("label");return o.append(t),l.id||="field-"+t.toLowerCase().replaceAll(/[^a-z0-9]/g,"-"),l.tagName==="DIV"?o.id=l.id+"-label":o.htmlFor=l.id,d.append(o,l),d}function xt(t,l,d){const o=document.createElement("input");return o.type="text",o.value=l,o.addEventListener("change",()=>d(o.value)),ie(t,o)}function se(t,l,d,o,g,y,c=""){const p=document.createElement("input");return p.type="number",p.value=String(Number(l.toFixed(4))),p.min=String(d),p.max=String(o),p.step=String(g),p.id=c,p.addEventListener("change",()=>{Number.isFinite(p.valueAsNumber)&&y(p.valueAsNumber)}),ie(t,p)}function Y(t,l,d,o=""){const g=document.createElement("input");return g.type="checkbox",g.checked=l,g.id=o,g.addEventListener("change",()=>d(g.checked)),ie(t,g)}function le(t,l,d,o){const g=document.createElement("select");for(const[y,c]of d)g.add(new Option(c,y,!1,y===l));return g.addEventListener("change",()=>o(g.value)),ie(t,g)}function Ct(t,l,d,o,g,y){const c=document.createElement("div");c.className="transform-sliders",c.setAttribute("role","group");const p=ie(t,c);c.setAttribute("aria-labelledby",c.id+"-label");const N=o?1e4:360;return d.forEach((U,D)=>{const A=["X","Y","Z"][D],i=document.createElement("div"),P=document.createElement("label"),w=document.createElement("input"),h=document.createElement("input"),I=o?Math.max(5,Math.ceil(Math.abs(U))):N;P.textContent=A,w.type="range",w.id=c.id+"-"+D,P.htmlFor=w.id,w.dataset.transformNode=l,w.setAttribute("aria-label",t+" "+A+" slider"),w.min=String(-I),w.max=String(I),w.step=o?"0.01":"1",w.value=String(U),h.type="number",h.setAttribute("aria-label",t+" "+A),h.min=String(-N),h.max=String(N),h.step="any",h.value=String(U);let R;w.addEventListener("input",()=>{h.value=w.value,R=g(D,w.valueAsNumber)}),w.addEventListener("change",()=>{const b=R;R=void 0,y(D,w.valueAsNumber).finally(b)}),w.addEventListener("pointercancel",()=>{R?.(),R=void 0,w.value=h.value=String(U)}),h.addEventListener("change",()=>{h.validity.valid&&Number.isFinite(h.valueAsNumber)&&y(D,h.valueAsNumber)}),i.append(P,w,h),c.append(i)}),p}function be(t,l,d){const o=document.createElement("div");o.className="field-vector",o.setAttribute("role","group");const g=l.map((c,p)=>{const N=document.createElement("input");return N.type="number",N.step="any",N.value=String(c),N.setAttribute("aria-label",t+" "+["X","Y","Z"][p]),N.addEventListener("change",()=>{const U=g.map(D=>D.valueAsNumber);U.every(Number.isFinite)&&d(U)}),N});o.append(...g);const y=ie(t,o);return o.setAttribute("aria-labelledby",o.id+"-label"),y}