stack3js 0.0.0-stage → 0.2.0

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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -2
  3. package/THIRD-PARTY-LICENSES.md +100 -0
  4. package/bin/stack3.mjs +4237 -0
  5. package/examples/future-tank.stack3.json +1 -0
  6. package/examples/traffic-cone-4view.png +0 -0
  7. package/package.json +25 -4
  8. package/viewer/dist/THIRD-PARTY-LICENSES.md +174 -0
  9. package/viewer/dist/assets/GLTFExporter--hziUXc8.js +1 -0
  10. package/viewer/dist/assets/ant-mech-angled-leg-4view-BO2qt1_k.png +0 -0
  11. package/viewer/dist/assets/ant-mech-body-4view-D9xVPpbc.png +0 -0
  12. package/viewer/dist/assets/ant-mech-center-leg-4view-BcphjF_G.png +0 -0
  13. package/viewer/dist/assets/compare-B6DWTZS9.css +1 -0
  14. package/viewer/dist/assets/compare-DJ8rV3Rn.js +6 -0
  15. package/viewer/dist/assets/compare.worker-DK2lJl0n.js +21 -0
  16. package/viewer/dist/assets/concrete-barrier-4view-7PsO3Ftq.png +0 -0
  17. package/viewer/dist/assets/emscripten-module-uFzwHH0Y.wasm +0 -0
  18. package/viewer/dist/assets/emscripten-module.browser-BcR5qphc.js +1 -0
  19. package/viewer/dist/assets/ffi-Boa1QuFa.js +1 -0
  20. package/viewer/dist/assets/fillet-rover-body-4-view-Chk8Mx4R.png +0 -0
  21. package/viewer/dist/assets/fillet-rover-wheel-4-view-B-F8flOC.png +0 -0
  22. package/viewer/dist/assets/hull-4view-BPPqJYUz.png +0 -0
  23. package/viewer/dist/assets/hull-base-color-4view-DrQmdT3h.png +0 -0
  24. package/viewer/dist/assets/hull-clay-4view-3Cu-4Hvr.png +0 -0
  25. package/viewer/dist/assets/hull-depth-4view-DCOdT5ev.png +0 -0
  26. package/viewer/dist/assets/hull-normal-4view-CvLaFITy.png +0 -0
  27. package/viewer/dist/assets/inspection-robot-body-4-view-CLMaHFYm.png +0 -0
  28. package/viewer/dist/assets/inspection-robot-wheel-4-view-27wRsxcs.png +0 -0
  29. package/viewer/dist/assets/plastic-barrier-4view-DQkTBW_i.png +0 -0
  30. package/viewer/dist/assets/presets-DwdZVYhs.js +1 -0
  31. package/viewer/dist/assets/preview-cache-DRF_H5pq.js +58 -0
  32. package/viewer/dist/assets/project-BzR9Ensg.css +1 -0
  33. package/viewer/dist/assets/project-D8tR6U-_.js +17 -0
  34. package/viewer/dist/assets/reconstruct.worker-Cf8iZwT3.js +21 -0
  35. package/viewer/dist/assets/script-engine-CLj7QMLe.js +6 -0
  36. package/viewer/dist/assets/style-CMUT8CmM.css +1 -0
  37. package/viewer/dist/assets/style-CWGgpweN.js +3947 -0
  38. package/viewer/dist/assets/tank-hull-4view-B4sMMkP5.png +0 -0
  39. package/viewer/dist/assets/tank-track-4view-DAIiMTy3.png +0 -0
  40. package/viewer/dist/assets/tank-turret-4view-Cx0FuNFu.png +0 -0
  41. package/viewer/dist/assets/traffic-cone-4view-DG-TkITx.png +0 -0
  42. package/viewer/dist/assets/viewer-CyGodHLY.js +2 -0
  43. package/viewer/dist/assets/wet-floor-sign-4view-CWJDyeTX.png +0 -0
  44. package/viewer/dist/compare.html +47 -0
  45. package/viewer/dist/examples/traffic-cone-4view.png +0 -0
  46. package/viewer/dist/index.html +147 -0
  47. package/viewer/dist/playground/index.html +3342 -0
  48. package/viewer/dist/project.html +83 -0
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./GLTFExporter--hziUXc8.js","./style-CWGgpweN.js","./style-CMUT8CmM.css"])))=>i.map(i=>d[i]);
2
+ import{T as zt,v as Pe,w as gt,x as Xt,y as se,F as Tt,z as D,E as xt,C as z,H as U,f as oe,J as qt,K as Wt,s as bt,M as he,V as I,U as $t,Q as wt,X as Yt,Y as Et,Z as Jt,_ as Qt,B as Se,$ as Zt,k as yt,i as en,j as tn,h as nn,L as Fe,g as Rt,m as De,n as sn,l as rn,a0 as on,a1 as ve,a2 as an,r as At,D as cn,a3 as te,P as ln,a4 as un,a5 as dn,a6 as fn,a7 as hn,a8 as pn,a9 as mn,aa as gn,G as _e,ab as Tn,b as xn,O as Lt,ac as bn,ad as wn,ae as En,d as yn,o as St,af as Rn,ag as rt,ah as it,ai as ot,aj as at,ak as ct,al as An,am as Ln,q as be,an as Sn,e as vn,ao as _n,A as Mn,ap as We,W as Nn,aq as Cn,p as In,ar as vt,as as On}from"./style-CWGgpweN.js";import{r as kn,C as Pn,O as Fn,c as Dn,D as _t,p as Hn,a as Un,s as Gn,f as lt,b as jn,e as Bn,_ as Kn,d as Vn}from"./preview-cache-DRF_H5pq.js";import{m as zn,s as Mt,q as Nt,c as Ct,i as Xn,b as qn}from"./presets-DwdZVYhs.js";function ut(o,e){if(e===zt)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===Pe||e===gt){let t=o.getIndex();if(t===null){const r=[],c=o.getAttribute("position");if(c!==void 0){for(let a=0;a<c.count;a++)r.push(a);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const s=t.count-2,n=[];if(e===Pe)for(let r=1;r<=s;r++)n.push(t.getX(0)),n.push(t.getX(r)),n.push(t.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(n.push(t.getX(r)),n.push(t.getX(r+1)),n.push(t.getX(r+2))):(n.push(t.getX(r+2)),n.push(t.getX(r+1)),n.push(t.getX(r)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=o.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Wn extends Xt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Zn(t)}),this.register(function(t){return new es(t)}),this.register(function(t){return new ls(t)}),this.register(function(t){return new us(t)}),this.register(function(t){return new ds(t)}),this.register(function(t){return new ns(t)}),this.register(function(t){return new ss(t)}),this.register(function(t){return new rs(t)}),this.register(function(t){return new is(t)}),this.register(function(t){return new Qn(t)}),this.register(function(t){return new os(t)}),this.register(function(t){return new ts(t)}),this.register(function(t){return new cs(t)}),this.register(function(t){return new as(t)}),this.register(function(t){return new Yn(t)}),this.register(function(t){return new fs(t)}),this.register(function(t){return new hs(t)})}load(e,t,s,n){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const l=se.extractUrlBase(e);r=se.resolveURL(l,this.path)}else r=se.extractUrlBase(e);this.manager.itemStart(e);const c=function(l){n?n(l):console.error(l),i.manager.itemError(e),i.manager.itemEnd(e)},a=new Tt(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{i.parse(l,r,function(u){t(u),i.manager.itemEnd(e)},c)}catch(u){c(u)}},s,c)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let i;const r={},c={},a=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===It){try{r[T.KHR_BINARY_GLTF]=new ps(e)}catch(d){n&&n(d);return}i=JSON.parse(r[T.KHR_BINARY_GLTF].content)}else i=JSON.parse(a.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new vs(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](l);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[d.name]=d,r[d.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const d=i.extensionsUsed[u],f=i.extensionsRequired||[];switch(d){case T.KHR_MATERIALS_UNLIT:r[d]=new Jn;break;case T.KHR_DRACO_MESH_COMPRESSION:r[d]=new ms(i,this.dracoLoader);break;case T.KHR_TEXTURE_TRANSFORM:r[d]=new gs;break;case T.KHR_MESH_QUANTIZATION:r[d]=new Ts;break;default:f.indexOf(d)>=0&&c[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}l.setExtensions(r),l.setPlugins(c),l.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function $n(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const T={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Yn{constructor(e){this.parser=e,this.name=T.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let l;const u=new z(16777215);a.color!==void 0&&u.setRGB(a.color[0],a.color[1],a.color[2],U);const d=a.range!==void 0?a.range:0;switch(a.type){case"directional":l=new bt(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new Wt(u),l.distance=d;break;case"spot":l=new qt(u),l.distance=d,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,l.angle=a.spot.outerConeAngle,l.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return l.position.set(0,0,0),F(l,a),a.intensity!==void 0&&(l.intensity=a.intensity),l.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(l),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],c=(i.extensions&&i.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(a){return s._getNodeRef(t.cache,c,a)})}}class Jn{constructor(){this.name=T.KHR_MATERIALS_UNLIT}getMaterialType(){return te}extendParams(e,t,s){const n=[];e.color=new z(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],U),e.opacity=r[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,oe))}return Promise.all(n)}}class Qn{constructor(e){this.parser=e,this.name=T.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class Zn{constructor(e){this.parser=e,this.name=T.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:D}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const c=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new xt(c,c)}return Promise.all(i)}}class es{constructor(e){this.parser=e,this.name=T.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:D}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class ts{constructor(e){this.parser=e,this.name=T.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:D}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class ns{constructor(e){this.parser=e,this.name=T.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:D}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new z(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=n.extensions[this.name];if(r.sheenColorFactor!==void 0){const c=r.sheenColorFactor;t.sheenColor.setRGB(c[0],c[1],c[2],U)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",r.sheenColorTexture,oe)),r.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(i)}}class ss{constructor(e){this.parser=e,this.name=T.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:D}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class rs{constructor(e){this.parser=e,this.name=T.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:D}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const c=r.attenuationColor||[1,1,1];return t.attenuationColor=new z().setRGB(c[0],c[1],c[2],U),Promise.all(i)}}class is{constructor(e){this.parser=e,this.name=T.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:D}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class os{constructor(e){this.parser=e,this.name=T.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:D}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",r.specularTexture));const c=r.specularColorFactor||[1,1,1];return t.specularColor=new z().setRGB(c[0],c[1],c[2],U),r.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",r.specularColorTexture,oe)),Promise.all(i)}}class as{constructor(e){this.parser=e,this.name=T.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:D}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(i)}}class cs{constructor(e){this.parser=e,this.name=T.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:D}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(i)}}class ls{constructor(e){this.parser=e,this.name=T.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,r)}}class us{constructor(e){this.parser=e,this.name=T.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const r=i.extensions[t],c=n.images[r.source];let a=s.textureLoader;if(c.uri){const l=s.options.manager.getHandler(c.uri);l!==null&&(a=l)}return s.loadTextureImage(e,r.source,a)}}class ds{constructor(e){this.parser=e,this.name=T.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const r=i.extensions[t],c=n.images[r.source];let a=s.textureLoader;if(c.uri){const l=s.options.manager.getHandler(c.uri);l!==null&&(a=l)}return s.loadTextureImage(e,r.source,a)}}class fs{constructor(e){this.name=T.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(c){const a=n.byteOffset||0,l=n.byteLength||0,u=n.count,d=n.byteStride,f=new Uint8Array(c,a,l);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(u,d,f,n.mode,n.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(u*d);return r.decodeGltfBuffer(new Uint8Array(p),u,d,f,n.mode,n.filter),p})})}else return null}}class hs{constructor(e){this.name=T.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const l of n.primitives)if(l.mode!==N.TRIANGLES&&l.mode!==N.TRIANGLE_STRIP&&l.mode!==N.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=s.extensions[this.name].attributes,c=[],a={};for(const l in r)c.push(this.parser.getDependency("accessor",r[l]).then(u=>(a[l]=u,a[l])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(l=>{const u=l.pop(),d=u.isGroup?u.children:[u],f=l[0].count,p=[];for(const g of d){const b=new he,m=new I,x=new wt,y=new I(1,1,1),E=new $t(g.geometry,g.material,f);for(let w=0;w<f;w++)a.TRANSLATION&&m.fromBufferAttribute(a.TRANSLATION,w),a.ROTATION&&x.fromBufferAttribute(a.ROTATION,w),a.SCALE&&y.fromBufferAttribute(a.SCALE,w),E.setMatrixAt(w,b.compose(m,x,y));for(const w in a)if(w==="_COLOR_0"){const M=a[w];E.instanceColor=new Yt(M.array,M.itemSize,M.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&g.geometry.setAttribute(w,a[w]);Et.prototype.copy.call(E,g),this.parser.assignFinalMaterial(E),p.push(E)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}}const It="glTF",ee=12,dt={JSON:1313821514,BIN:5130562};class ps{constructor(e){this.name=T.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ee),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==It)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-ee,i=new DataView(e,ee);let r=0;for(;r<n;){const c=i.getUint32(r,!0);r+=4;const a=i.getUint32(r,!0);if(r+=4,a===dt.JSON){const l=new Uint8Array(e,ee+r,c);this.content=s.decode(l)}else if(a===dt.BIN){const l=ee+r;this.body=e.slice(l,l+c)}r+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ms{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=T.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,c={},a={},l={};for(const u in r){const d=He[u]||u.toLowerCase();c[d]=r[u]}for(const u in e.attributes){const d=He[u]||u.toLowerCase();if(r[u]!==void 0){const f=s.accessors[e.attributes[u]],p=Q[f.componentType];l[d]=p.name,a[d]=f.normalized===!0}}return t.getDependency("bufferView",i).then(function(u){return new Promise(function(d,f){n.decodeDracoFile(u,function(p){for(const g in p.attributes){const b=p.attributes[g],m=a[g];m!==void 0&&(b.normalized=m)}d(p)},c,l,U,f)})})}}class gs{constructor(){this.name=T.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Ts{constructor(){this.name=T.KHR_MESH_QUANTIZATION}}class Ot extends Ln{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let r=0;r!==n;r++)t[r]=s[i+r];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,r=this.sampleValues,c=this.valueSize,a=c*2,l=c*3,u=n-t,d=(s-t)/u,f=d*d,p=f*d,g=e*l,b=g-l,m=-2*p+3*f,x=p-f,y=1-m,E=x-f+d;for(let w=0;w!==c;w++){const M=r[b+w+c],j=r[b+w+a]*u,k=r[g+w+c],Z=r[g+w]*u;i[w]=y*M+E*j+m*k+x*Z}return i}}const xs=new wt;class bs extends Ot{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return xs.fromArray(i).normalize().toArray(i),i}}const N={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Q={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ft={9728:Rt,9729:Fe,9984:nn,9985:tn,9986:en,9987:yt},ht={33071:rn,33648:sn,10497:De},Me={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},He={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},B={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ws={CUBICSPLINE:void 0,LINEAR:St,STEP:yn},Ne={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Es(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new At({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:An})),o.DefaultMaterial}function V(o,e,t){for(const s in t.extensions)o[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function F(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ys(o,e,t){let s=!1,n=!1,i=!1;for(let l=0,u=e.length;l<u;l++){const d=e[l];if(d.POSITION!==void 0&&(s=!0),d.NORMAL!==void 0&&(n=!0),d.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(o);const r=[],c=[],a=[];for(let l=0,u=e.length;l<u;l++){const d=e[l];if(s){const f=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):o.attributes.position;r.push(f)}if(n){const f=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):o.attributes.normal;c.push(f)}if(i){const f=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):o.attributes.color;a.push(f)}}return Promise.all([Promise.all(r),Promise.all(c),Promise.all(a)]).then(function(l){const u=l[0],d=l[1],f=l[2];return s&&(o.morphAttributes.position=u),n&&(o.morphAttributes.normal=d),i&&(o.morphAttributes.color=f),o.morphTargetsRelative=!0,o})}function Rs(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)o.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function As(o){let e;const t=o.extensions&&o.extensions[T.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ce(t.attributes):e=o.indices+":"+Ce(o.attributes)+":"+o.mode,o.targets!==void 0)for(let s=0,n=o.targets.length;s<n;s++)e+=":"+Ce(o.targets[s]);return e}function Ce(o){let e="";const t=Object.keys(o).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+o[t[s]]+";";return e}function Ue(o){switch(o){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Ls(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Ss=new he;class vs{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new $n,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,i=!1,r=-1;if(typeof navigator<"u"){const c=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(c)===!0;const a=c.match(/Version\/(\d+)/);n=s&&a?parseInt(a[1],10):-1,i=c.indexOf("Firefox")>-1,r=i?c.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&r<98?this.textureLoader=new Jt(this.options.manager):this.textureLoader=new Qt(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Tt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const c={scene:r[0][n.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:n.asset,parser:s,userData:{}};return V(i,c,n),F(c,n),Promise.all(s._invokeAll(function(a){return a.afterRoot&&a.afterRoot(c)})).then(function(){for(const a of c.scenes)a.updateMatrixWorld();e(c)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n].joints;for(let c=0,a=r.length;c<a;c++)e[r[c]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const r=e[n];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(r,c)=>{const a=this.associations.get(r);a!=null&&this.associations.set(c,a);for(const[l,u]of r.children.entries())i(u,c.children[l])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,r){return s.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[T.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,r){s.load(se.resolveURL(t.uri,n.path),i,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const r=Me[n.type],c=Q[n.componentType],a=n.normalized===!0,l=new c(n.count*r);return Promise.resolve(new Se(l,r,a))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(r){const c=r[0],a=Me[n.type],l=Q[n.componentType],u=l.BYTES_PER_ELEMENT,d=u*a,f=n.byteOffset||0,p=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let b,m;if(p&&p!==d){const x=Math.floor(f/p),y="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+x+":"+n.count;let E=t.cache.get(y);E||(b=new l(c,x*p,n.count*p/u),E=new Zt(b,p/u),t.cache.add(y,E)),m=new Rn(E,a,f%p/u,g)}else c===null?b=new l(n.count*a):b=new l(c,f,n.count*a),m=new Se(b,a,g);if(n.sparse!==void 0){const x=Me.SCALAR,y=Q[n.sparse.indices.componentType],E=n.sparse.indices.byteOffset||0,w=n.sparse.values.byteOffset||0,M=new y(r[1],E,n.sparse.count*x),j=new l(r[2],w,n.sparse.count*a);c!==null&&(m=new Se(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let k=0,Z=M.length;k<Z;k++){const W=M[k];if(m.setX(W,j[k*a]),a>=2&&m.setY(W,j[k*a+1]),a>=3&&m.setZ(W,j[k*a+2]),a>=4&&m.setW(W,j[k*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,r=t.images[i];let c=this.textureLoader;if(r.uri){const a=s.manager.getHandler(r.uri);a!==null&&(c=a)}return this.loadTextureImage(e,i,c)}loadTextureImage(e,t,s){const n=this,i=this.json,r=i.textures[e],c=i.images[t],a=(c.uri||c.bufferView)+":"+r.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,s).then(function(u){u.flipY=!1,u.name=r.name||c.name||"",u.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(u.name=c.uri);const f=(i.samplers||{})[r.sampler]||{};return u.magFilter=ft[f.magFilter]||Fe,u.minFilter=ft[f.minFilter]||yt,u.wrapS=ht[f.wrapS]||De,u.wrapT=ht[f.wrapT]||De,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Rt&&u.minFilter!==Fe,n.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const r=n.images[e],c=self.URL||self.webkitURL;let a=r.uri||"",l=!1;if(r.bufferView!==void 0)a=s.getDependency("bufferView",r.bufferView).then(function(d){l=!0;const f=new Blob([d],{type:r.mimeType});return a=c.createObjectURL(f),a});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(a).then(function(d){return new Promise(function(f,p){let g=f;t.isImageBitmapLoader===!0&&(g=function(b){const m=new rt(b);m.needsUpdate=!0,f(m)}),t.load(se.resolveURL(d,i.path),g,void 0,p)})}).then(function(d){return l===!0&&c.revokeObjectURL(a),F(d,r),d.userData.mimeType=r.mimeType||Ls(r.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),d});return this.sourceCache[e]=u,u}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[T.KHR_TEXTURE_TRANSFORM]){const c=s.extensions!==void 0?s.extensions[T.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const a=i.associations.get(r);r=i.extensions[T.KHR_TEXTURE_TRANSFORM].extendTexture(r,c),i.associations.set(r,a)}}return n!==void 0&&(r.colorSpace=n),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const c="PointsMaterial:"+s.uuid;let a=this.cache.get(c);a||(a=new on,ve.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,a.sizeAttenuation=!1,this.cache.add(c,a)),s=a}else if(e.isLine){const c="LineBasicMaterial:"+s.uuid;let a=this.cache.get(c);a||(a=new an,ve.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,this.cache.add(c,a)),s=a}if(n||i||r){let c="ClonedMaterial:"+s.uuid+":";n&&(c+="derivative-tangents:"),i&&(c+="vertex-colors:"),r&&(c+="flat-shading:");let a=this.cache.get(c);a||(a=s.clone(),i&&(a.vertexColors=!0),r&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(c,a),this.associations.set(a,this.associations.get(s))),s=a}e.material=s}getMaterialType(){return At}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let r;const c={},a=i.extensions||{},l=[];if(a[T.KHR_MATERIALS_UNLIT]){const d=n[T.KHR_MATERIALS_UNLIT];r=d.getMaterialType(),l.push(d.extendParams(c,i,t))}else{const d=i.pbrMetallicRoughness||{};if(c.color=new z(1,1,1),c.opacity=1,Array.isArray(d.baseColorFactor)){const f=d.baseColorFactor;c.color.setRGB(f[0],f[1],f[2],U),c.opacity=f[3]}d.baseColorTexture!==void 0&&l.push(t.assignTexture(c,"map",d.baseColorTexture,oe)),c.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,c.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(c,"metalnessMap",d.metallicRoughnessTexture)),l.push(t.assignTexture(c,"roughnessMap",d.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,c)})))}i.doubleSided===!0&&(c.side=cn);const u=i.alphaMode||Ne.OPAQUE;if(u===Ne.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,u===Ne.MASK&&(c.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==te&&(l.push(t.assignTexture(c,"normalMap",i.normalTexture)),c.normalScale=new xt(1,1),i.normalTexture.scale!==void 0)){const d=i.normalTexture.scale;c.normalScale.set(d,d)}if(i.occlusionTexture!==void 0&&r!==te&&(l.push(t.assignTexture(c,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==te){const d=i.emissiveFactor;c.emissive=new z().setRGB(d[0],d[1],d[2],U)}return i.emissiveTexture!==void 0&&r!==te&&l.push(t.assignTexture(c,"emissiveMap",i.emissiveTexture,oe)),Promise.all(l).then(function(){const d=new r(c);return i.name&&(d.name=i.name),F(d,i),t.associations.set(d,{materials:e}),i.extensions&&V(n,d,i),d})}createUniqueName(e){const t=ln.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(c){return s[T.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(a){return pt(a,c,t)})}const r=[];for(let c=0,a=e.length;c<a;c++){const l=e[c],u=As(l),d=n[u];if(d)r.push(d.promise);else{let f;l.extensions&&l.extensions[T.KHR_DRACO_MESH_COMPRESSION]?f=i(l):f=pt(new un,l,t),n[u]={primitive:l,promise:f},r.push(f)}}return Promise.all(r)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],r=i.primitives,c=[];for(let a=0,l=r.length;a<l;a++){const u=r[a].material===void 0?Es(this.cache):this.getDependency("material",r[a].material);c.push(u)}return c.push(t.loadGeometries(r)),Promise.all(c).then(function(a){const l=a.slice(0,a.length-1),u=a[a.length-1],d=[];for(let p=0,g=u.length;p<g;p++){const b=u[p],m=r[p];let x;const y=l[p];if(m.mode===N.TRIANGLES||m.mode===N.TRIANGLE_STRIP||m.mode===N.TRIANGLE_FAN||m.mode===void 0)x=i.isSkinnedMesh===!0?new dn(b,y):new fn(b,y),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),m.mode===N.TRIANGLE_STRIP?x.geometry=ut(x.geometry,gt):m.mode===N.TRIANGLE_FAN&&(x.geometry=ut(x.geometry,Pe));else if(m.mode===N.LINES)x=new hn(b,y);else if(m.mode===N.LINE_STRIP)x=new pn(b,y);else if(m.mode===N.LINE_LOOP)x=new mn(b,y);else if(m.mode===N.POINTS)x=new gn(b,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(x.geometry.morphAttributes).length>0&&Rs(x,i),x.name=t.createUniqueName(i.name||"mesh_"+e),F(x,i),m.extensions&&V(n,x,m),t.assignFinalMaterial(x),d.push(x)}for(let p=0,g=d.length;p<g;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return i.extensions&&V(n,d[0],i),d[0];const f=new _e;i.extensions&&V(n,f,i),t.associations.set(f,{meshes:e});for(let p=0,g=d.length;p<g;p++)f.add(d[p]);return f})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new Tn(xn.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new Lt(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),F(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),r=n,c=[],a=[];for(let l=0,u=r.length;l<u;l++){const d=r[l];if(d){c.push(d);const f=new he;i!==null&&f.fromArray(i.array,l*16),a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new bn(c,a)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,r=[],c=[],a=[],l=[],u=[];for(let d=0,f=n.channels.length;d<f;d++){const p=n.channels[d],g=n.samplers[p.sampler],b=p.target,m=b.node,x=n.parameters!==void 0?n.parameters[g.input]:g.input,y=n.parameters!==void 0?n.parameters[g.output]:g.output;b.node!==void 0&&(r.push(this.getDependency("node",m)),c.push(this.getDependency("accessor",x)),a.push(this.getDependency("accessor",y)),l.push(g),u.push(b))}return Promise.all([Promise.all(r),Promise.all(c),Promise.all(a),Promise.all(l),Promise.all(u)]).then(function(d){const f=d[0],p=d[1],g=d[2],b=d[3],m=d[4],x=[];for(let E=0,w=f.length;E<w;E++){const M=f[E],j=p[E],k=g[E],Z=b[E],W=m[E];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const Ae=s._createAnimationTracks(M,j,k,Z,W);if(Ae)for(let Le=0;Le<Ae.length;Le++)x.push(Ae[Le])}const y=new wn(i,void 0,x);return F(y,n),y})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const r=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&r.traverse(function(c){if(c.isMesh)for(let a=0,l=n.weights.length;a<l;a++)c.morphTargetInfluences[a]=n.weights[a]}),r})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),r=[],c=n.children||[];for(let l=0,u=c.length;l<u;l++)r.push(s.getDependency("node",c[l]));const a=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),a]).then(function(l){const u=l[0],d=l[1],f=l[2];f!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(f,Ss)});for(let p=0,g=d.length;p<g;p++)u.add(d[p]);return u})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],r=i.name?n.createUniqueName(i.name):"",c=[],a=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return a&&c.push(a),i.camera!==void 0&&c.push(n.getDependency("camera",i.camera).then(function(l){return n._getNodeRef(n.cameraCache,i.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){c.push(l)}),this.nodeCache[e]=Promise.all(c).then(function(l){let u;if(i.isBone===!0?u=new En:l.length>1?u=new _e:l.length===1?u=l[0]:u=new Et,u!==l[0])for(let d=0,f=l.length;d<f;d++)u.add(l[d]);if(i.name&&(u.userData.name=i.name,u.name=r),F(u,i),i.extensions&&V(s,u,i),i.matrix!==void 0){const d=new he;d.fromArray(i.matrix),u.applyMatrix4(d)}else i.translation!==void 0&&u.position.fromArray(i.translation),i.rotation!==void 0&&u.quaternion.fromArray(i.rotation),i.scale!==void 0&&u.scale.fromArray(i.scale);if(!n.associations.has(u))n.associations.set(u,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const d=n.associations.get(u);n.associations.set(u,{...d})}return n.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new _e;s.name&&(i.name=n.createUniqueName(s.name)),F(i,s),s.extensions&&V(t,i,s);const r=s.nodes||[],c=[];for(let a=0,l=r.length;a<l;a++)c.push(n.getDependency("node",r[a]));return Promise.all(c).then(function(a){for(let u=0,d=a.length;u<d;u++)i.add(a[u]);const l=u=>{const d=new Map;for(const[f,p]of n.associations)(f instanceof ve||f instanceof rt)&&d.set(f,p);return u.traverse(f=>{const p=n.associations.get(f);p!=null&&d.set(f,p)}),d};return n.associations=l(i),i})}_createAnimationTracks(e,t,s,n,i){const r=[],c=e.name?e.name:e.uuid,a=[];B[i.path]===B.weights?e.traverse(function(f){f.morphTargetInfluences&&a.push(f.name?f.name:f.uuid)}):a.push(c);let l;switch(B[i.path]){case B.weights:l=ot;break;case B.rotation:l=at;break;case B.translation:case B.scale:l=it;break;default:s.itemSize===1?l=ot:l=it;break}const u=n.interpolation!==void 0?ws[n.interpolation]:St,d=this._getArrayFromAccessor(s);for(let f=0,p=a.length;f<p;f++){const g=new l(a[f]+"."+B[i.path],t.array,d,u);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),r.push(g)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=Ue(t.constructor),n=new Float32Array(t.length);for(let i=0,r=t.length;i<r;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof at?bs:Ot;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function _s(o,e,t){const s=e.attributes,n=new be;if(s.POSITION!==void 0){const c=t.json.accessors[s.POSITION],a=c.min,l=c.max;if(a!==void 0&&l!==void 0){if(n.set(new I(a[0],a[1],a[2]),new I(l[0],l[1],l[2])),c.normalized){const u=Ue(Q[c.componentType]);n.min.multiplyScalar(u),n.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const c=new I,a=new I;for(let l=0,u=i.length;l<u;l++){const d=i[l];if(d.POSITION!==void 0){const f=t.json.accessors[d.POSITION],p=f.min,g=f.max;if(p!==void 0&&g!==void 0){if(a.setX(Math.max(Math.abs(p[0]),Math.abs(g[0]))),a.setY(Math.max(Math.abs(p[1]),Math.abs(g[1]))),a.setZ(Math.max(Math.abs(p[2]),Math.abs(g[2]))),f.normalized){const b=Ue(Q[f.componentType]);a.multiplyScalar(b)}c.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(c)}o.boundingBox=n;const r=new Sn;n.getCenter(r.center),r.radius=n.min.distanceTo(n.max)/2,o.boundingSphere=r}function pt(o,e,t){const s=e.attributes,n=[];function i(r,c){return t.getDependency("accessor",r).then(function(a){o.setAttribute(c,a)})}for(const r in s){const c=He[r]||r.toLowerCase();c in o.attributes||n.push(i(s[r],c))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(c){o.setIndex(c)});n.push(r)}return ct.workingColorSpace!==U&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ct.workingColorSpace}" not supported.`),F(o,e),_s(o,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ys(o,e.targets,t):o})}function Ms(o,e){if(!Number.isFinite(e)||e<=0||!Number.isFinite(e*o.size[2]))throw new Error("Spacing must be a positive, finite multiplier.");return e===1?o:{...o,spacing:o.spacing*e,size:[o.size[0],o.size[1],o.size[2]*e],pivot:[o.pivot[0],o.pivot[1],o.pivot[2]*e]}}async function Ns(o,e=!1){kn(new Uint8Array(await o.slice(0,33).arrayBuffer()));const t=await createImageBitmap(o,{colorSpaceConversion:e?"none":"default"});try{const s=new OffscreenCanvas(t.width,t.height),n=s.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Could not decode the PNG.");n.drawImage(t,0,0);const i=n.getImageData(0,0,s.width,s.height);return{width:s.width,height:s.height,data:new Uint8Array(i.data.buffer)}}finally{t.close()}}function h(o){const e=document.getElementById(o);if(!e)throw new Error("Missing viewer control "+o);return e}const X=h("viewport"),L=h("status"),kt=h("previewLabel"),q=h("export"),Ge=h("pixelArt"),je=h("smoothEdges"),$e=new Pn,Pt=h("cpuPreview"),ne=h("gpuPreview"),pe=h("materialLighting"),me=h("supersampling"),K=o=>o.getAttribute("aria-pressed")==="true";let P,$="gpu";X.append($e.canvas);const ae=new vn,H=new _n(16,32,4478570,2569798);ae.add(H);const Ft=new bt(16777215,1.5);Ft.position.set(2,3,2);ae.add(new Mn(16777215,.85),Ft);const A=new Lt(-1,1,1,-1,.01,300);A.position.set(2.7,1.8,2.5);const O=new Fn(A,X);O.target.y=.4;O.enableDamping=!0;O.minZoom=.15;O.maxZoom=12;let Be=1.1;function we(){const{clientWidth:o,clientHeight:e}=X;if(!o||!e)return;P?.setPixelRatio(Math.min(devicePixelRatio,2)*(K(me)?2:1)),P?.setSize(o,e,!1);const t=o/e;A.left=-Be*Math.max(1,t),A.right=-A.left,A.top=Be*Math.max(1,1/t),A.bottom=-A.top,A.updateProjectionMatrix()}function Ee(o){if(o==="gpu"&&!P)try{P=new Nn({antialias:!0}),P.setClearColor(1186083),P.domElement.addEventListener("webglcontextlost",e=>{e.preventDefault(),ne.disabled=!0,Ee("cpu")}),P.domElement.addEventListener("webglcontextrestored",()=>{ne.disabled=!1}),X.append(P.domElement)}catch{ne.disabled=!0,h("cacheNotice").textContent="WebGL unavailable. Using CPU.",o="cpu"}$=o,$e.canvas.hidden=$!=="cpu",P&&(P.domElement.hidden=$!=="gpu"),Pt.setAttribute("aria-pressed",String($==="cpu")),ne.setAttribute("aria-pressed",String($==="gpu")),Y=0,de=0,re=performance.now(),we()}Pt.addEventListener("click",()=>Ee("cpu"));ne.addEventListener("click",()=>Ee("gpu"));new ResizeObserver(we).observe(X);let Y=0,re=performance.now(),de=0,mt=re;const Cs=h("performance");function Dt(o){requestAnimationFrame(Dt),O.update(Math.min(.1,(o-mt)/1e3)),mt=o;const e=performance.now();if($==="gpu"?P?.render(ae,A):$e.render(v,A,K(me),H.visible,H.position.y,K(pe)),de+=performance.now()-e,Y++,o-re>=500){const t=o-re;Cs.value=`${Math.round(Y*1e3/t)} FPS · ${(t/Y).toFixed(1)} ms/frame · ${(de/Y).toFixed(1)} ms render CPU`,Y=0,de=0,re=o}}let v=null,R=null,_=[],C=[],ie,ce=null,le=null;const Ke={};let Ve="atlas",J="stack",ue=null,Ht,ge=!0,S=0;const Ut=["targetMesh","targetStack","meshMethod","textureProjection","contourHub","qualityPreset","layers","resolution","threshold","profile","height","pivot","resetReconstruction"].map(o=>h(o)),ze=h("persistentCache"),Te=h("spacing"),Is=h("squash"),Os=h("previewScale");let Gt=3;function Ye(){if(!v)return;const o=new be().setFromObject(v),e=o.getCenter(new I),t=o.getSize(new I),s=Math.max(t.x,t.y,t.z,.01),n=s*2.65;Be=s*.86,Gt=n,O.target.copy(e),A.position.copy(e).addScaledVector(new I(1.35,.95,1).normalize(),n),A.near=Math.max(1e-4,s/200),A.far=Math.max(300,n*50),we(),Je(),Qe()}function Je(){if(!v)return;const o=new be().setFromObject(v),e=o.getSize(new I);H.scale.setScalar(Math.max(e.x,e.y,e.z,.01)),H.position.y=o.min.y-H.scale.x*.002}function Qe(){const o=new On().setFromVector3(A.position.clone().sub(O.target));o.phi=Math.acos(Math.min(.9999,Is.valueAsNumber)),o.radius=Gt,A.zoom=Os.valueAsNumber,A.updateProjectionMatrix(),A.position.copy(O.target).add(new I().setFromSpherical(o)),O.update()}function jt(o,e){v&&(ae.remove(v),We(v)),v=o,ae.add(o),e?Ye():Je(),X.dataset.ready="true"}function Ze(){const o=R?.target==="stack"&&v!==null;Ge.disabled=!o,je.disabled=!o,o&&Cn(v,Ge.getAttribute("aria-pressed")==="true",je.getAttribute("aria-pressed")==="true")}function ye(){Te.disabled=R?.target!=="stack",R?.target==="stack"&&v&&(v.scale.y=Te.valueAsNumber,Je())}for(const o of[Ge,je])o.addEventListener("click",()=>{o.setAttribute("aria-pressed",String(o.getAttribute("aria-pressed")!=="true")),Ze()});h("showGrid").addEventListener("click",o=>{H.visible=!H.visible,o.currentTarget.setAttribute("aria-pressed",String(H.visible))});for(const o of[pe,me,ze])o.addEventListener("click",()=>{o.setAttribute("aria-pressed",String(!K(o))),o===pe&&R&&v&&vt(v,K(o)),o===me&&we()});function Re(o,e,t){const s=h(o),n=h(o+"Value");s.addEventListener("input",()=>{n.value=e(s.valueAsNumber),t()})}Re("spacing",o=>o.toFixed(2)+"×",ye);Re("squash",o=>o.toFixed(2),Qe);Re("previewScale",o=>o.toFixed(2)+"×",Qe);Re("rotationSpeed",o=>o+"°/s",()=>{const o=h("rotationSpeed").valueAsNumber;O.autoRotate=o>0,O.autoRotateSpeed=o/6});function et(){clearTimeout(Ht)}function Xe(o,e){h(o).replaceChildren(...e.map(s=>{const n=document.createElement("li");return n.textContent=s,n}))}function tt(o,e,t=!1,s){R=o,ie=s,C=s?Xn(s,_):[];const n=C.length?Ct(C):In(R);R.target==="stack"&&(n.scale.y=Te.valueAsNumber),K(pe)&&vt(n,!0),jt(n,ge),ge=!1,ye(),Ze(),kt.textContent=R.target==="mesh"?"Mesh preview":"Sprite stack preview",q.disabled=t;const i=new be().setFromObject(n).getSize(new I),r=(C.length?[i.x,i.z,i.y]:R.size).map(a=>a.toFixed(2)).join(" × "),c=R.target==="mesh"?`${(R.indices.length/3).toLocaleString()} triangles`:`${R.layers} slices`;L.value=`${r} units · ${C.length?C.length+" parts · ":""}${c} · ${e}`,X.dataset.partCount=String(C.length||1)}function Ie(o,e,t=!1){tt(o.result,t?e+" · Building full resolution…":e,t,o.parts),Xe("mappedViews",o.inspection.views.map(s=>`${s.direction} ${s.width}×${s.height}`)),Xe("warnings",o.inspection.warnings)}function G(o=125){et();const e=++S;q.disabled=!0;let t;if(Ve==="atlas"&&_.length)t={parts:_.map(({atlas:u,layout:d,size:f})=>({atlas:u,layout:d,size:f}))};else if(Ve==="atlas"){if(!ce){L.value="Load a PNG atlas.";return}const u=h("layout").value;try{Hn(u)}catch(d){L.value=d.message;return}t={atlas:ce,layout:u}}else{const u=Number(h("viewCount").value),d=_t.slice(0,u),f=d.filter(p=>!Ke[p]);if(f.length){L.value="Add views: "+f.join(", ");return}t={files:Object.fromEntries(d.map(p=>[p,Ke[p]]))}}for(const u of Ut)u.disabled=!1;for(const u of["height","pivot","layout","profile"])h(u).disabled="parts"in t;const s=h("meshMethod").value,n=J==="mesh"&&s==="contour",i=n&&h("contourHub").checked;h("meshOptions").hidden=J!=="mesh",h("resolutionName").textContent=i?"Hub segments":"Texture resolution";const r=h("resolution").valueAsNumber;if(h("resolutionValue").value=i?String(r):st(r),h("hubOption").hidden=!n,n){for(const u of["qualityPreset","layers","profile"])h(u).disabled=!0;h("resolution").disabled=!i}const c=u=>h(u).valueAsNumber,a={textureProjection:J==="mesh"?h("textureProjection").value:void 0,meshMethod:n?s:void 0,contourHub:i||void 0,layers:c("layers"),resolution:c("resolution"),threshold:c("threshold"),height:c("height"),pivot:h("pivot").value,profile:"parts"in t?"silhouette":h("profile").value};L.value="Reconstructing…";const l=J;Ht=setTimeout(async()=>{try{await ks(e,t,l,a)}catch(u){e===S&&(L.value=u.message)}},o)}async function ks(o,e,t,s){const n=await Gn(e);if(o!==S)return;const i=K(ze),r=JSON.stringify([n,t,s]),c=await lt(r,i);if(o!==S)return;if(c){Ie(c.value,c.origin);return}let a=s.meshMethod!=="contour"&&(s.layers>45||s.resolution>96)?{...s,layers:Math.min(45,s.layers),resolution:Math.min(96,s.resolution)}:void 0;const l=JSON.stringify([n,t,a]);if(a){const f=await lt(l,i);if(o!==S)return;f&&(Ie(f.value,f.origin,!0),a=void 0)}const u=ue??=new Worker(new URL(""+new URL("reconstruct.worker-Cf8iZwT3.js",import.meta.url).href,import.meta.url),{type:"module"}),d=qe;u.onmessage=({data:f})=>{if(!(ue!==u||f.id!==o||o!==S)){if("error"in f){L.value=f.error;return}d===qe&&jn(f.preview?l:r,f,K(ze)),Ie(f,"Built from source · "+Math.round(f.elapsed)+" ms",f.preview)}},u.onerror=()=>{ue===u&&(u.terminate(),ue=null,o===S&&(L.value="Could not start the reconstruction worker."))},u.postMessage({id:o,sourceKey:n,source:e,target:t,settings:s,preview:a})}let qe=0;h("clearCache").addEventListener("click",async()=>{qe++;const o=h("cacheNotice");try{await Dn(),o.textContent="Cache cleared."}catch{o.textContent="Could not clear the disk cache."}});function nt(o,e=!0){Ve=o,h("atlasFields").hidden=o!=="atlas",h("separateFields").hidden=o!=="files",h("modeAtlas").setAttribute("aria-pressed",String(o==="atlas")),h("modeFiles").setAttribute("aria-pressed",String(o==="files")),e&&G(0)}function xe(o,e,t=[]){ce=o,_=t,Bt(),ge=!0;const s=h("sourceImage");le&&URL.revokeObjectURL(le),le=URL.createObjectURL(o),s.src=le,s.hidden=!1,e&&(h("layout").value=e),nt("atlas")}function Bt(){const o=h("assemblyEditor");o.hidden=!_.length;const e=_.reduce((t,s)=>t+s.mounts.length,0);h("assemblySummary").textContent=`${_.length} atlases · ${e} parts`,h("partMounts").replaceChildren(..._.flatMap((t,s)=>t.mounts.map(n=>Ps(n,s))))}function Ps(o,e){const t=document.createElement("fieldset"),s=document.createElement("legend");s.textContent=o.name;const n=document.createElement("div");for(const[r,c]of["X","Depth","Height","Scale"].entries()){const a=document.createElement("label"),l=document.createElement("input");l.type="number",l.step=".05",l.min=r===3?".05":"-20",l.max="20",l.value=(r===3?o.scale??1:o.position[r]).toFixed(3),a.append(c,l),l.addEventListener("change",()=>{if(!(!Number.isFinite(l.valueAsNumber)||l.validity.rangeUnderflow||l.validity.rangeOverflow)&&(r===3?o.scale=l.valueAsNumber:o.position[r]=l.valueAsNumber,R&&ie&&ie.length===_.length)){const u=!q.disabled;tt(R,"Assembly placement updated",!u,ie)}}),n.append(a)}const i=document.createElement("button");return i.type="button",i.textContent="Remove part",i.disabled=_.reduce((r,c)=>r+c.mounts.length,0)===1,i.addEventListener("click",()=>{const r=_[e];r.mounts=r.mounts.filter(c=>c!==o),r.mounts.length||_.splice(e,1),h("samplePreset").value="",Bt(),G(0)}),t.append(s,n,i),t}const fe=h("partFiles");h("addParts").addEventListener("click",()=>fe.click());fe.addEventListener("change",()=>{const o=Array.from(fe.files??[]);if(fe.value="",!o.length)return;if(o.some(s=>!/\.png$/i.test(s.name))){L.value="Choose four-view PNGs.";return}const e=_.length?_:ce?[{atlas:ce,layout:h("layout").value,name:"Base",mounts:[{name:"Base",position:[0,0,0]}]}]:[];if(e.length+o.length>12){L.value="An assembly supports up to 12 atlases.";return}const t=[...e,...o.map((s,n)=>({atlas:s,name:s.name,layout:"top,left,front,rear",mounts:[{name:s.name,position:[.7*(e.length+n),0,0],scale:e.length+n?.6:1}]}))];h("samplePreset").value="",xe(t[0].atlas,t[0].layout,t)});for(const[o,e]of _t.entries()){const t=document.createElement("div"),s=document.createElement("label");s.htmlFor="view-"+e,s.textContent=e;const n=document.createElement("input");n.id=s.htmlFor,n.type="file",n.accept="image/png,.png",n.addEventListener("change",()=>{n.files?.[0]&&(Ke[e]=n.files[0]),ge=!0,G(0)}),t.append(s,n),t.dataset.direction=e,t.hidden=o>=4,h("viewFiles").append(t)}h("viewCount").addEventListener("change",o=>{const e=o.currentTarget;for(const[t,s]of Array.from(h("viewFiles").children).entries())s.hidden=t>=Number(e.value);G(0)});h("modeAtlas").addEventListener("click",()=>nt("atlas"));h("modeFiles").addEventListener("click",()=>nt("files"));h("atlas").addEventListener("change",o=>{const e=o.currentTarget.files?.[0];e&&(h("samplePreset").value="",h("profile").value="silhouette",xe(e))});h("samplePreset").addEventListener("change",async o=>{const e=++S,t=o.currentTarget.value;if(t){et(),q.disabled=!0,L.value="Loading sample…";try{const s="top,left,front,rear",n=async r=>{const c=await fetch(r);if(!c.ok)throw new Error("Could not load the sample atlas.");return c.blob()},i=zn[t];if(i){const r=await Promise.all(i.map(async c=>({...c,mounts:structuredClone(c.mounts),atlas:await n(c.url),layout:s})));e===S&&(h("profile").value="silhouette",xe(r[0].atlas,s,r))}else{const r=await n(Mt[t]);e===S&&(h("profile").value=t==="cone"?"round-base":"silhouette",xe(r,s))}}catch(s){e===S&&(L.value=s.message)}}});h("resetCamera").addEventListener("click",Ye);for(const[o,e]of[["targetMesh","mesh"],["targetStack","stack"]])h(o).addEventListener("click",()=>{J!==e&&(J=e,h("targetMesh").setAttribute("aria-pressed",String(e==="mesh")),h("targetStack").setAttribute("aria-pressed",String(e==="stack")),q.textContent=e==="mesh"?"Export GLB":"Export stack",G(0))});for(const[o,e]of[["layers","layerValue"],["resolution","resolutionValue"],["threshold","thresholdValue"]]){const t=h(o);t.addEventListener("input",()=>{h(e).value=o==="resolution"?st(t.valueAsNumber):t.value,o!=="threshold"&&(h("qualityPreset").value=""),G()})}for(const o of["height","pivot","layout","profile","meshMethod","textureProjection","contourHub"])h(o).addEventListener("change",()=>G(0));function st(o){return`${o} px · ${(o/Nt.balanced.resolution).toFixed(2)}×`}function Kt(o){const{layers:e,resolution:t}=Nt[o];h("layers").value=h("layerValue").value=String(e),h("resolution").value=String(t),h("resolutionValue").value=st(t)}h("qualityPreset").addEventListener("change",o=>{const e=o.currentTarget.value;e&&(Kt(e),G(0))});h("resetReconstruction").addEventListener("click",()=>{h("meshMethod").value="marching-cubes",h("textureProjection").value="auto",h("contourHub").checked=!1,h("qualityPreset").value="balanced",h("profile").value=h("samplePreset").value==="cone"?"round-base":"silhouette",Kt("balanced");for(const[o,e]of[["height","1"],["pivot","ground"],["threshold","238"],["thresholdValue","238"],["spacing","1"],["squash",".75"],["previewScale","1"],["rotationSpeed","0"]])h(o).value=e;for(const[o,e]of[["spacingValue","1.00×"],["squashValue","0.75"],["previewScaleValue","1.00×"],["rotationSpeedValue","0°/s"]])h(o).value=e;O.autoRotate=!1,ye(),Ye(),G(0)});function Oe(o,e,t){const s=URL.createObjectURL(new Blob([new Uint8Array(o)],{type:t})),n=document.createElement("a");n.href=s,n.download=e,n.click(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}q.addEventListener("click",async()=>{if(R)try{if(R.target==="stack"){const o=C.length?qn(C):R;Oe(Bn(Ms(o,Te.valueAsNumber)),"stack3-stack.zip","application/zip")}else if(C.length){const o=Ct(C);try{const{GLTFExporter:e}=await Kn(async()=>{const{GLTFExporter:s}=await import("./GLTFExporter--hziUXc8.js");return{GLTFExporter:s}},__vite__mapDeps([0,1,2]),import.meta.url),t=await new e().parseAsync(o,{binary:!0});if(!(t instanceof ArrayBuffer))throw new Error("Could not export assembly as GLB.");Oe(new Uint8Array(t),"stack3-assembly.glb","model/gltf-binary")}finally{We(o)}}else Oe(Vn(R),"stack3.glb","model/gltf-binary")}catch(o){L.value=o.message}});h("openGlb").addEventListener("click",()=>h("glb").click());h("glb").addEventListener("change",async o=>{const e=o.currentTarget,t=e.files?.[0];if(e.value="",!t)return;et();const s=++S;R=null,C=[],ie=void 0,ye(),Ze(),q.disabled=!0;try{const n=await t.arrayBuffer(),i=new DataView(n);if(n.byteLength<20||i.getUint32(0,!0)!==1179937895||i.getUint32(12,!0)>n.byteLength-20)throw new Error("Expected a GLB file.");const r=JSON.parse(new TextDecoder().decode(new Uint8Array(n,20,i.getUint32(12,!0))));if([...r.images??[],...r.buffers??[]].some(a=>a.uri&&!a.uri.startsWith("data:")))throw new Error("Open a GLB with embedded textures and buffers.");const c=await new Wn().parseAsync(n,"");if(s!==S){We(c.scene);return}jt(c.scene,!0),kt.textContent="GLB preview",L.value=t.name+" · Opened",Xe("warnings",[])}catch(n){s===S&&(L.value=n.message)}});async function Fs(o){const e=++S;L.value="Opening stack…";try{const t=new URL(`__stack3/${o}/`,location.href),[s,n]=await Promise.all([fetch(new URL("stack.json",t)),fetch(new URL("stack.png",t))]);if(!s.ok||!n.ok)throw new Error("Could not open this CLI stack bundle.");const[i,r]=await Promise.all([s.json(),n.blob().then(Ns)]);if(e!==S)return;tt(Un(i,r),"Opened stack bundle");for(const c of Ut)c.disabled=!0}catch(t){e===S&&(L.value=t.message)}}const Vt=new URLSearchParams(location.search),ke=Vt.get("stack");Ee("gpu");requestAnimationFrame(Dt);if(ke&&/^[a-f0-9-]{36}$/.test(ke))Fs(ke);else{const o=Vt.get("preset");if(o&&Object.hasOwn(Mt,o)){const e=h("samplePreset");e.value=o,e.dispatchEvent(new Event("change"))}}
@@ -0,0 +1,47 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <link rel="icon" href="data:,">
7
+ <title>stack3.js · 4-view comparison</title>
8
+ <script type="module" crossorigin src="./assets/compare-DJ8rV3Rn.js"></script>
9
+ <link rel="modulepreload" crossorigin href="./assets/style-CWGgpweN.js">
10
+ <link rel="modulepreload" crossorigin href="./assets/presets-DwdZVYhs.js">
11
+ <link rel="stylesheet" crossorigin href="./assets/style-CMUT8CmM.css">
12
+ <link rel="stylesheet" crossorigin href="./assets/compare-B6DWTZS9.css">
13
+ </head>
14
+ <body>
15
+ <header class="topbar">
16
+ <h1>4-view comparison</h1>
17
+ <nav class="toolbar" aria-label="Viewer">
18
+ <a id="back" class="button" href="./index.html">Asset viewer</a>
19
+ </nav>
20
+ </header>
21
+ <main class="comparison">
22
+ <div class="compare-controls">
23
+ <div>
24
+ <label for="part">Atlas source</label>
25
+ <select id="part"></select>
26
+ </div>
27
+ <div>
28
+ <label for="atlas">4-view PNG</label>
29
+ <input id="atlas" type="file" accept="image/png,.png">
30
+ </div>
31
+ <div><label for="yaw">Orbit <output id="yaw-value">45°</output></label><input id="yaw" type="range" min="-180" max="180" value="45"></div>
32
+ <div><label for="pitch">Elevation <output id="pitch-value">24°</output></label><input id="pitch" type="range" min="-10" max="90" value="24"></div>
33
+ <div><label for="zoom">Zoom <output id="zoom-value">1×</output></label><input id="zoom" type="range" min="0.75" max="3" step="0.05" value="1"></div>
34
+ <div><label for="layers">Layers <output id="layers-value">80</output></label><input id="layers" type="range" min="8" max="128" value="80" disabled></div>
35
+ <div><label for="spacing">Spacing <output id="spacing-value">1.00×</output></label><input id="spacing" type="range" min="0.50" max="2.50" step="0.05" value="1" disabled></div>
36
+ <div><label for="explode">Explode <output id="explode-value">0%</output></label><input id="explode" type="range" min="0" max="100" step="1" value="0" disabled></div>
37
+ <div class="compare-actions">
38
+ <button id="clay" type="button" aria-pressed="false" title="Show mesh geometry without textures">Clay</button>
39
+ <button id="reset" type="button">Reset camera</button>
40
+ </div>
41
+ </div>
42
+ <output id="comparison-status" role="status" aria-live="polite">Choose a PNG in TOP, LEFT, FRONT, REAR order.</output>
43
+ <ul id="comparison-warnings" aria-label="Atlas alignment warnings"></ul>
44
+ <div class="compare-results" aria-label="Reconstruction thumbnails"></div>
45
+ </main>
46
+ </body>
47
+ </html>
@@ -0,0 +1,147 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <link rel="icon" href="data:,">
7
+ <title>stack3.js · Asset Viewer</title>
8
+ <script type="module" crossorigin src="./assets/viewer-CyGodHLY.js"></script>
9
+ <link rel="modulepreload" crossorigin href="./assets/style-CWGgpweN.js">
10
+ <link rel="modulepreload" crossorigin href="./assets/preview-cache-DRF_H5pq.js">
11
+ <link rel="modulepreload" crossorigin href="./assets/presets-DwdZVYhs.js">
12
+ <link rel="stylesheet" crossorigin href="./assets/style-CMUT8CmM.css">
13
+ </head>
14
+ <body>
15
+ <header class="topbar">
16
+ <h1>stack3<span>.js</span></h1>
17
+ <div class="toolbar">
18
+ <a class="button" href="./compare.html">4-view comparison</a>
19
+ <a class="button" href="./project.html">Scene editor</a>
20
+ <a class="button" href="./project.html?playground=1">Playground</a>
21
+ <a class="button" href="./playground/index.html">Demo yard</a>
22
+ <button id="openGlb" type="button">Open GLB</button><input id="glb" type="file" accept=".glb" hidden>
23
+ <button id="export" class="primary" type="button" disabled>Export stack</button>
24
+ </div>
25
+ </header>
26
+ <main>
27
+ <aside aria-label="Asset settings">
28
+ <section>
29
+ <h2>Source</h2>
30
+ <label for="samplePreset">Sample asset</label>
31
+ <select id="samplePreset">
32
+ <option value="">Choose a sample</option>
33
+ <option value="cone">Traffic Cone</option>
34
+ <option value="rover">Cargo Rover</option>
35
+ <option value="inspection">Inspection Robot</option>
36
+ <option value="ant">Ant Mech</option>
37
+ <option value="tank">Armored Miniature</option>
38
+ <option value="sign">Wet-Floor Sign</option>
39
+ <option value="barrier">Plastic Barrier</option>
40
+ <option value="concrete">Concrete Barrier</option>
41
+ </select>
42
+ <div class="segmented" role="group" aria-label="Input mode">
43
+ <button id="modeAtlas" type="button" aria-pressed="true">Atlas</button>
44
+ <button id="modeFiles" type="button" aria-pressed="false">Individual views</button>
45
+ </div>
46
+ <div id="atlasFields">
47
+ <label for="atlas">PNG atlas</label>
48
+ <input id="atlas" type="file" accept="image/png,.png">
49
+ <label for="layout">Directions in reading order</label>
50
+ <input id="layout" type="text" value="top,left,front,rear" spellcheck="false">
51
+ <img id="sourceImage" alt="Source atlas" hidden>
52
+ <div class="toolbar"><button id="addParts" type="button">Add part atlases</button></div>
53
+ <input id="partFiles" type="file" accept="image/png,.png" multiple hidden>
54
+ <details id="assemblyEditor" hidden open>
55
+ <summary id="assemblySummary">Assembly parts</summary>
56
+ <div id="partMounts"></div>
57
+ </details>
58
+ </div>
59
+ <div id="separateFields" hidden>
60
+ <label for="viewCount">View set</label>
61
+ <select id="viewCount"><option value="4">Four views</option><option value="6">Six views</option></select>
62
+ <div id="viewFiles"></div>
63
+ </div>
64
+ <ul id="mappedViews" aria-label="Mapped view sizes"></ul>
65
+ </section>
66
+ <section>
67
+ <h2>Reconstruction</h2>
68
+ <div class="segmented" role="group" aria-label="Asset type">
69
+ <button id="targetStack" type="button" aria-pressed="true">Sprite stack</button>
70
+ <button id="targetMesh" type="button" aria-pressed="false">3D mesh</button>
71
+ </div>
72
+ <div id="meshOptions" hidden>
73
+ <label for="meshMethod">Mesh method</label>
74
+ <select id="meshMethod"><option value="marching-cubes">Marching Cubes</option><option value="contour">Contour extrusion</option></select>
75
+ <label for="textureProjection">Texture projection</label>
76
+ <select id="textureProjection"><option value="auto">Automatic (multi-view)</option><option value="top-contour">Upper contour from TOP</option></select>
77
+ <label id="hubOption" hidden><input id="contourHub" type="checkbox"> Centered round hub</label>
78
+ </div>
79
+ <label for="qualityPreset">Quality preset</label>
80
+ <select id="qualityPreset">
81
+ <option value="">Custom</option>
82
+ <option value="draft">Draft · 24 layers</option>
83
+ <option value="balanced" selected>Balanced · 48 layers</option>
84
+ <option value="detail">Detail · 90 layers</option>
85
+ </select>
86
+ <label for="layers">Layers <output id="layerValue">48</output></label>
87
+ <input id="layers" type="range" min="8" max="128" value="48">
88
+ <label for="resolution"><span id="resolutionName">Texture resolution</span> <output id="resolutionValue">96 px · 1.00×</output></label>
89
+ <input id="resolution" type="range" min="16" max="192" value="96">
90
+ <label for="threshold">Background threshold <output id="thresholdValue">238</output></label>
91
+ <input id="threshold" type="range" min="180" max="255" value="238">
92
+ <label for="profile">Cross-section</label>
93
+ <select id="profile">
94
+ <option value="silhouette">From silhouettes</option>
95
+ <option value="round">Round</option>
96
+ <option value="round-base">Round above square base</option>
97
+ </select>
98
+ <div class="split">
99
+ <div><label for="height">Asset height</label><input id="height" type="number" min=".01" step=".1" value="1"></div>
100
+ <div><label for="pivot">Pivot</label><select id="pivot"><option value="ground">Ground</option><option value="center">Center</option></select></div>
101
+ </div>
102
+ <div class="toolbar">
103
+ <button id="persistentCache" type="button" aria-pressed="true">Disk cache</button>
104
+ <button id="clearCache" type="button">Clear cache</button>
105
+ <button id="resetReconstruction" type="button">Defaults</button>
106
+ </div>
107
+ <output id="cacheNotice" role="status"></output>
108
+ </section>
109
+ <section>
110
+ <h2>Presentation</h2>
111
+ <label for="spacing">Spacing <output id="spacingValue">1.00×</output></label>
112
+ <input id="spacing" type="range" min=".50" max="2.50" step=".05" value="1" disabled>
113
+ <label for="squash">Squash <output id="squashValue">0.75</output></label>
114
+ <input id="squash" type="range" min=".45" max="1" step=".01" value=".75">
115
+ <label for="previewScale">Scale <output id="previewScaleValue">1.00×</output></label>
116
+ <input id="previewScale" type="range" min=".5" max="2" step=".05" value="1">
117
+ <label for="rotationSpeed">Auto-rotate speed <output id="rotationSpeedValue">0°/s</output></label>
118
+ <input id="rotationSpeed" type="range" min="0" max="135" step="1" value="0">
119
+ </section>
120
+ </aside>
121
+ <section class="viewer" aria-label="Model preview">
122
+ <div class="viewer-toolbar">
123
+ <span id="previewLabel">Sprite stack preview</span>
124
+ <div class="toolbar">
125
+ <div class="toolbar" role="group" aria-label="Preview renderer">
126
+ <button id="cpuPreview" type="button" aria-pressed="false">CPU</button>
127
+ <button id="gpuPreview" type="button" aria-pressed="true">GPU</button>
128
+ </div>
129
+ <button id="materialLighting" type="button" aria-pressed="false">Material lighting</button>
130
+ <button id="supersampling" type="button" aria-pressed="false">Supersampling 2×</button>
131
+ <button id="pixelArt" type="button" aria-pressed="false" disabled>Pixel art</button>
132
+ <button id="smoothEdges" type="button" aria-pressed="true" disabled>Smooth edges</button>
133
+ <button id="showGrid" type="button" aria-pressed="true">Grid</button>
134
+ <button id="resetCamera" type="button">Reset camera</button>
135
+ </div>
136
+ </div>
137
+ <div id="viewport"></div>
138
+ <div class="viewer-status">
139
+ <output id="status" aria-live="polite">Load a PNG atlas or individual views.</output>
140
+ <output id="performance">— FPS</output>
141
+ <span>Drag to orbit · Scroll to zoom</span>
142
+ </div>
143
+ <ul id="warnings" aria-label="Input warnings"></ul>
144
+ </section>
145
+ </main>
146
+ </body>
147
+ </html>