@needle-tools/engine 4.6.1 → 4.6.2

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 (103) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/generateMeshBVH.worker-BaNp_Xtp.js +25 -0
  3. package/dist/{gltf-progressive-Bm9eEfgu.min.js → gltf-progressive-Bl4okF1b.min.js} +1 -1
  4. package/dist/{gltf-progressive-GjIqwSG3.js → gltf-progressive-DSpdn0QT.js} +2 -2
  5. package/dist/{gltf-progressive-Dn6o99rH.umd.cjs → gltf-progressive-P8b8a0qY.umd.cjs} +1 -1
  6. package/dist/needle-engine.bundle-D0XWaCQs.min.js +1575 -0
  7. package/dist/{needle-engine.bundle-BVg46UWZ.js → needle-engine.bundle-DGcStTA7.js} +9715 -9555
  8. package/dist/needle-engine.bundle-DmYMLdWP.umd.cjs +1575 -0
  9. package/dist/needle-engine.js +352 -351
  10. package/dist/needle-engine.min.js +1 -1
  11. package/dist/needle-engine.umd.cjs +1 -1
  12. package/dist/{postprocessing-CRQa6Qxn.umd.cjs → postprocessing-CjW23fio.umd.cjs} +18 -18
  13. package/dist/{postprocessing-D6W1EyZ-.js → postprocessing-DYLNOL3W.js} +4 -3
  14. package/dist/{postprocessing-DF8AlRgW.min.js → postprocessing-xYQWCHFu.min.js} +26 -26
  15. package/dist/{three-DMrv-4ar.umd.cjs → three-B_hneGZr.umd.cjs} +4 -4
  16. package/dist/{three-Bz6X1mrw.js → three-DrqIzZTH.js} +4198 -4198
  17. package/dist/{three-Boa-jOq-.min.js → three-DuDKwKB8.min.js} +33 -33
  18. package/dist/{three-examples-GggCDHv0.js → three-examples-B50TT3Iu.js} +5 -5
  19. package/dist/{three-examples-DuVhxqft.min.js → three-examples-DaDLBuy6.min.js} +14 -14
  20. package/dist/{three-examples-C7ryg8vN.umd.cjs → three-examples-X3OadjXB.umd.cjs} +3 -3
  21. package/dist/{three-mesh-ui-CY6Izc7C.min.js → three-mesh-ui-B3p3gyUz.min.js} +1 -1
  22. package/dist/{three-mesh-ui-CwlN0FUC.umd.cjs → three-mesh-ui-CQiIQIlA.umd.cjs} +1 -1
  23. package/dist/{three-mesh-ui-CLNOfsWn.js → three-mesh-ui-CxuWt7m-.js} +1 -1
  24. package/dist/{vendor-zxXa3Dmr.min.js → vendor-BlSxe9JJ.min.js} +3 -3
  25. package/dist/{vendor-BSD1RQIh.js → vendor-BmYIgaS1.js} +3 -3
  26. package/dist/{vendor-DHr4aqIZ.umd.cjs → vendor-Cavtu3CP.umd.cjs} +3 -3
  27. package/lib/engine/engine_context.d.ts +4 -1
  28. package/lib/engine/engine_context.js +9 -2
  29. package/lib/engine/engine_context.js.map +1 -1
  30. package/lib/engine/engine_three_utils.d.ts +17 -14
  31. package/lib/engine/engine_three_utils.js +106 -53
  32. package/lib/engine/engine_three_utils.js.map +1 -1
  33. package/lib/engine/engine_tonemapping.d.ts +4 -0
  34. package/lib/engine/engine_tonemapping.js +21 -18
  35. package/lib/engine/engine_tonemapping.js.map +1 -1
  36. package/lib/engine/engine_utils.js.map +1 -1
  37. package/lib/engine/engine_utils_screenshot.d.ts +1 -1
  38. package/lib/engine/engine_utils_screenshot.js +11 -2
  39. package/lib/engine/engine_utils_screenshot.js.map +1 -1
  40. package/lib/engine/webcomponents/needle-engine.d.ts +4 -1
  41. package/lib/engine/webcomponents/needle-engine.extras.js +3 -3
  42. package/lib/engine/webcomponents/needle-engine.extras.js.map +1 -1
  43. package/lib/engine/webcomponents/needle-engine.js +11 -21
  44. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  45. package/lib/engine-components/CameraUtils.js.map +1 -1
  46. package/lib/engine-components/postprocessing/Effects/Antialiasing.js +3 -1
  47. package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
  48. package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +2 -2
  49. package/lib/engine-components/postprocessing/Effects/BloomEffect.js +5 -2
  50. package/lib/engine-components/postprocessing/Effects/BloomEffect.js.map +1 -1
  51. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +8 -0
  52. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +27 -8
  53. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js.map +1 -1
  54. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +1 -0
  55. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js.map +1 -1
  56. package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +1 -0
  57. package/lib/engine-components/postprocessing/Effects/Sharpening.js +4 -0
  58. package/lib/engine-components/postprocessing/Effects/Sharpening.js.map +1 -1
  59. package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +2 -9
  60. package/lib/engine-components/postprocessing/Effects/Tonemapping.js +23 -71
  61. package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -1
  62. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +13 -0
  63. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.js +52 -0
  64. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.js.map +1 -0
  65. package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +18 -0
  66. package/lib/engine-components/postprocessing/PostProcessingEffect.js +22 -3
  67. package/lib/engine-components/postprocessing/PostProcessingEffect.js.map +1 -1
  68. package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +20 -4
  69. package/lib/engine-components/postprocessing/PostProcessingHandler.js +209 -112
  70. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  71. package/lib/engine-components/postprocessing/Volume.d.ts +2 -1
  72. package/lib/engine-components/postprocessing/Volume.js +51 -33
  73. package/lib/engine-components/postprocessing/Volume.js.map +1 -1
  74. package/lib/engine-components/postprocessing/index.d.ts +1 -0
  75. package/lib/engine-components/postprocessing/index.js +1 -0
  76. package/lib/engine-components/postprocessing/index.js.map +1 -1
  77. package/lib/engine-components/postprocessing/utils.d.ts +43 -0
  78. package/lib/engine-components/postprocessing/utils.js +82 -0
  79. package/lib/engine-components/postprocessing/utils.js.map +1 -1
  80. package/package.json +1 -1
  81. package/src/engine/engine_context.ts +13 -4
  82. package/src/engine/engine_three_utils.ts +134 -58
  83. package/src/engine/engine_tonemapping.ts +23 -24
  84. package/src/engine/engine_utils.ts +2 -2
  85. package/src/engine/engine_utils_screenshot.ts +13 -3
  86. package/src/engine/webcomponents/needle-engine.extras.ts +3 -3
  87. package/src/engine/webcomponents/needle-engine.ts +14 -25
  88. package/src/engine-components/CameraUtils.ts +3 -3
  89. package/src/engine-components/postprocessing/Effects/Antialiasing.ts +3 -1
  90. package/src/engine-components/postprocessing/Effects/BloomEffect.ts +6 -4
  91. package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +24 -13
  92. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -0
  93. package/src/engine-components/postprocessing/Effects/Sharpening.ts +5 -0
  94. package/src/engine-components/postprocessing/Effects/Tonemapping.ts +26 -80
  95. package/src/engine-components/postprocessing/Effects/Tonemapping.utils.ts +60 -0
  96. package/src/engine-components/postprocessing/PostProcessingEffect.ts +23 -3
  97. package/src/engine-components/postprocessing/PostProcessingHandler.ts +239 -119
  98. package/src/engine-components/postprocessing/Volume.ts +54 -38
  99. package/src/engine-components/postprocessing/index.ts +2 -1
  100. package/src/engine-components/postprocessing/utils.ts +102 -2
  101. package/dist/generateMeshBVH.worker-Cdfpaq5W.js +0 -25
  102. package/dist/needle-engine.bundle-AOXFIsYk.umd.cjs +0 -1563
  103. package/dist/needle-engine.bundle-Dt52m2jf.min.js +0 -1563
@@ -1,4 +1,4 @@
1
- var Ve=Object.defineProperty,Te=r=>{throw TypeError(r)},qe=(r,e,t)=>e in r?Ve(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e,t)=>qe(r,typeof e!="symbol"?e+"":e,t),Ee=(r,e,t)=>e.has(r)||Te("Cannot "+t),L=(r,e,t)=>(Ee(r,e,"read from private field"),t?t.call(r):e.get(r)),Y=(r,e,t)=>e.has(r)?Te("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),N=(r,e,t,n)=>(Ee(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);import{BufferGeometry as ue,Mesh as J,Texture as re,TextureLoader as Xe,Matrix4 as Ae,Clock as Ke,MeshStandardMaterial as He,Sphere as Ye,Box3 as Pe,Vector3 as U}from"./three-Boa-jOq-.min.js";import{DRACOLoader as Je,KTX2Loader as Qe,MeshoptDecoder as Ze,GLTFLoader as pe}from"./three-examples-DuVhxqft.min.js";const et="";globalThis.GLTF_PROGRESSIVE_VERSION=et,console.debug("[gltf-progressive] version -");let W="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",Z="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";const tt=W,rt=Z,Be=new URL(W+"draco_decoder.js");Be.searchParams.append("range","true"),fetch(Be,{method:"GET",headers:{Range:"bytes=0-1"}}).catch(r=>{console.debug(`Failed to fetch remote Draco decoder from ${W} (offline: ${typeof navigator<"u"?navigator.onLine:"unknown"})`),W===tt&&Ie("./include/draco/"),Z===rt&&ke("./include/ktx2/")}).finally(()=>{Ce()});function Ie(r){W=r,A&&A[ve]!=W?(console.debug("Updating Draco decoder path to "+r),A[ve]=W,A.setDecoderPath(W),A.preload()):console.debug("Setting Draco decoder path to "+r)}function ke(r){Z=r,k&&k.transcoderPath!=Z?(console.debug("Updating KTX2 transcoder path to "+r),k.setTranscoderPath(Z),k.init()):console.debug("Setting KTX2 transcoder path to "+r)}const ve=Symbol("dracoDecoderPath");let A,ce,k;function Ce(){A||(A=new Je,A[ve]=W,A.setDecoderPath(W),A.setDecoderConfig({type:"js"}),A.preload()),k||(k=new Qe,k.setTranscoderPath(Z),k.init()),ce||(ce=Ze)}function ye(r){return Ce(),r?k.detectSupport(r):r!==null&&console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"),{dracoLoader:A,ktx2Loader:k,meshoptDecoder:ce}}function xe(r){r.dracoLoader||r.setDRACOLoader(A),r.ktx2Loader||r.setKTX2Loader(k),r.meshoptDecoder||r.setMeshoptDecoder(ce)}const Le=new WeakMap;function De(r,e){let t=Le.get(r);t?t=Object.assign(t,e):t=e,Le.set(r,t)}const Re=pe.prototype.load;function st(...r){const e=Le.get(this);let t=r[0];const n=new URL(t,window.location.href);if(n.hostname.endsWith("needle.tools")){const s=e?.progressive!==void 0?e.progressive:!0,i=e!=null&&e.usecase?e.usecase:"default";s?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${i}`:this.requestHeader.Accept=`*/*;usecase=${i}`,t=n.toString()}return r[0]=t,Re?.call(this,...r)}pe.prototype.load=st,se("debugprogressive");function se(r){if(typeof window>"u")return!1;const e=new URL(window.location.href).searchParams.get(r);return e==null||e==="0"||e==="false"?!1:e===""?!0:e}function nt(r,e){if(e===void 0||e.startsWith("./")||e.startsWith("http")||r===void 0)return e;const t=r.lastIndexOf("/");if(t>=0){const n=r.substring(0,t+1);for(;n.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return n+e}return e}let de;function ot(){return de!==void 0||(de=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),se("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",de)),de}const it=typeof window>"u"&&typeof document>"u",Me=Symbol("needle:raycast-mesh");function ee(r){return r?.[Me]instanceof ue?r[Me]:null}function at(r,e){if((r.type==="Mesh"||r.type==="SkinnedMesh")&&!ee(r)){const t=ut(e);t.userData={isRaycastMesh:!0},r[Me]=t}}function lt(r=!0){if(r){if(ne)return;const e=ne=J.prototype.raycast;J.prototype.raycast=function(t,n){const s=this,i=ee(s);let o;i&&s.isMesh&&(o=s.geometry,s.geometry=i),e.call(this,t,n),o&&(s.geometry=o)}}else{if(!ne)return;J.prototype.raycast=ne,ne=null}}let ne=null;function ut(r){const e=new ue;for(const t in r.attributes)e.setAttribute(t,r.getAttribute(t));return e.setIndex(r.getIndex()),e}const V=new Array,F="NEEDLE_progressive",y=se("debugprogressive"),we=Symbol("needle-progressive-texture"),oe=new Map,be=new Set;if(y){let r=function(){e+=1,console.log("Toggle LOD level",e,oe),oe.forEach((s,i)=>{for(const o of s.keys){const a=i[o];if(a!=null)if(a.isBufferGeometry===!0){const l=z.getMeshLODInformation(a),u=l?Math.min(e,l.lods.length):0;i["DEBUG:LOD"]=u,l&&(t=Math.max(t,l.lods.length-1))}else i.isMaterial===!0&&(i["DEBUG:LOD"]=e)}}),e>=t&&(e=-1)},e=-1,t=2,n=!1;window.addEventListener("keyup",s=>{s.key==="p"&&r(),s.key==="w"&&(n=!n,be&&be.forEach(i=>{i.name!="BackgroundCubeMaterial"&&i.glyphMap==null&&"wireframe"in i&&(i.wireframe=n)}))})}function je(r,e,t){var n;if(!y)return;oe.has(r)||oe.set(r,{keys:[],sourceId:t});const s=oe.get(r);((n=s?.keys)==null?void 0:n.includes(e))==!1&&s.keys.push(e)}const P=class j{constructor(e,t){d(this,"parser"),d(this,"url"),d(this,"_isLoadingMesh"),d(this,"loadMesh",n=>{var s,i;if(this._isLoadingMesh)return null;const o=(i=(s=this.parser.json.meshes[n])==null?void 0:s.extensions)==null?void 0:i[F];return o?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",n).then(a=>{var l;return this._isLoadingMesh=!1,a&&j.registerMesh(this.url,o.guid,a,(l=o.lods)==null?void 0:l.length,void 0,o),a})):null}),y&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return F}static getMeshLODInformation(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getMaterialMinMaxLODsCount(e,t){const n=this,s="LODS:minmax",i=e[s];if(i!=null)return i;if(t||(t={min_count:1/0,max_count:0,lods:[]}),Array.isArray(e)){for(const a of e)this.getMaterialMinMaxLODsCount(a,t);return e[s]=t,t}if(y==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const a=e;for(const l of Object.keys(a.uniforms)){const u=a.uniforms[l].value;u?.isTexture===!0&&o(u,t)}}else if(e.isMaterial)for(const a of Object.keys(e)){const l=e[a];l?.isTexture===!0&&o(l,t)}return e[s]=t,t;function o(a,l){const u=n.getAssignedLODInformation(a);if(u){const c=n.lodInfos.get(u.key);if(c&&c.lods){l.min_count=Math.min(l.min_count,c.lods.length),l.max_count=Math.max(l.max_count,c.lods.length);for(let f=0;f<c.lods.length;f++){const x=c.lods[f];x.width&&(l.lods[f]=l.lods[f]||{min_height:1/0,max_height:0},l.lods[f].min_height=Math.min(l.lods[f].min_height,x.height),l.lods[f].max_height=Math.max(l.lods[f].max_height,x.height))}}}}}static hasLODLevelAvailable(e,t){var n;if(Array.isArray(e)){for(const o of e)if(this.hasLODLevelAvailable(o,t))return!0;return!1}if(e.isMaterial===!0){for(const o of Object.keys(e)){const a=e[o];if(a&&a.isTexture&&this.hasLODLevelAvailable(a,t))return!0}return!1}else if(e.isGroup===!0){for(const o of e.children)if(o.isMesh===!0&&this.hasLODLevelAvailable(o,t))return!0}let s,i;if(e.isMesh?s=e.geometry:(e.isBufferGeometry||e.isTexture)&&(s=e),s&&(n=s?.userData)!=null&&n.LODS){const o=s.userData.LODS;if(i=this.lodInfos.get(o.key),t===void 0)return i!=null;if(i)return Array.isArray(i.lods)?t<i.lods.length:t===0}return!1}static assignMeshLOD(e,t){var n;if(!e)return Promise.resolve(null);if(e instanceof J||e.isMesh===!0){const s=e.geometry,i=this.getAssignedLODInformation(s);if(!i)return Promise.resolve(null);for(const o of V)(n=o.onBeforeGetLODMesh)==null||n.call(o,e,t);return e["LOD:requested level"]=t,j.getOrLoadLOD(s,t).then(o=>{if(Array.isArray(o)){const a=i.index||0;o=o[a]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],o&&s!=o&&(o?.isBufferGeometry?(e.geometry=o,y&&je(e,"geometry",i.url)):y&&console.error("Invalid LOD geometry",o))),o}).catch(o=>(console.error("Error loading mesh LOD",e,o),null))}else y&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(e,t=0){if(!e)return Promise.resolve(null);if(e.isMesh===!0){const n=e;if(Array.isArray(n.material)){const s=new Array;for(const i of n.material){const o=this.assignTextureLOD(i,t);s.push(o)}return Promise.all(s).then(i=>{const o=new Array;for(const a of i)Array.isArray(a)&&o.push(...a);return o})}else return this.assignTextureLOD(n.material,t)}if(e.isMaterial===!0){const n=e,s=[],i=new Array;if(y&&be.add(n),n.uniforms&&(n.isRawShaderMaterial||n.isShaderMaterial===!0)){const o=n;for(const a of Object.keys(o.uniforms)){const l=o.uniforms[a].value;if(l?.isTexture===!0){const u=this.assignTextureLODForSlot(l,t,n,a).then(c=>(c&&o.uniforms[a].value!=c&&(o.uniforms[a].value=c,o.uniformsNeedUpdate=!0),c));s.push(u),i.push(a)}}}else for(const o of Object.keys(n)){const a=n[o];if(a?.isTexture===!0){const l=this.assignTextureLODForSlot(a,t,n,o);s.push(l),i.push(o)}}return Promise.all(s).then(o=>{const a=new Array;for(let l=0;l<o.length;l++){const u=o[l],c=i[l];u&&u.isTexture===!0?a.push({material:n,slot:c,texture:u,level:t}):a.push({material:n,slot:c,texture:null,level:t})}return a})}if(e instanceof re||e.isTexture===!0){const n=e;return this.assignTextureLODForSlot(n,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,n,s){return e?.isTexture!==!0?Promise.resolve(null):s==="glyphMap"?Promise.resolve(e):j.getOrLoadLOD(e,t).then(i=>{if(Array.isArray(i))return null;if(i?.isTexture===!0){if(i!=e){if(n&&s){const o=n[s];if(o&&!y){const a=this.getAssignedLODInformation(o);if(a&&a?.level<t)return y==="verbose"&&console.warn("Assigned texture level is already higher: ",a.level,t,n,o,i),null}n[s]=i}if(y&&s&&n){const o=this.getAssignedLODInformation(e);o?je(n,s,o.url):console.warn("No LOD info for texture",e)}}return i}else y=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(i=>(console.error("Error loading LOD",e,i),null))}afterRoot(e){var t,n;return y&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((s,i)=>{var o;if(s!=null&&s.extensions){const a=s?.extensions[F];if(a){if(!a.lods){y&&console.warn("Texture has no LODs",a);return}let l=!1;for(const u of this.parser.associations.keys())if(u.isTexture===!0){const c=this.parser.associations.get(u);c?.textures===i&&(l=!0,j.registerTexture(this.url,u,(o=a.lods)==null?void 0:o.length,i,a))}l||this.parser.getDependency("texture",i).then(u=>{var c;u&&j.registerTexture(this.url,u,(c=a.lods)==null?void 0:c.length,i,a)})}}}),(n=this.parser.json.meshes)==null||n.forEach((s,i)=>{if(s!=null&&s.extensions){const o=s?.extensions[F];if(o&&o.lods){for(const a of this.parser.associations.keys())if(a.isMesh){const l=this.parser.associations.get(a);l?.meshes===i&&j.registerMesh(this.url,o.guid,a,o.lods.length,l.primitives,o)}}}}),null}static async getOrLoadLOD(e,t){var n,s,i,o;const a=y=="verbose",l=e.userData.LODS;if(!l)return null;const u=l?.key;let c;if(e.isTexture===!0){const f=e;f.source&&f.source[we]&&(c=f.source[we])}if(c||(c=j.lodInfos.get(u)),c){if(t>0){let m=!1;const B=Array.isArray(c.lods);if(B&&t>=c.lods.length?m=!0:B||(m=!0),m)return this.lowresCache.get(u)}const f=Array.isArray(c.lods)?(n=c.lods[t])==null?void 0:n.path:c.lods;if(!f)return y&&!c["missing:uri"]&&(c["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,c)),null;const x=nt(l.url,f);if(x.endsWith(".glb")||x.endsWith(".gltf")){if(!c.guid)return console.warn("missing pointer for glb/gltf texture",c),null;const m=x+"_"+c.guid,B=this.previouslyLoaded.get(m);if(B!==void 0){a&&console.log(`LOD ${t} was already loading/loaded: ${m}`);let v=await B.catch(E=>(console.error(`Error loading LOD ${t} from ${x}
1
+ var Ve=Object.defineProperty,Te=r=>{throw TypeError(r)},qe=(r,e,t)=>e in r?Ve(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e,t)=>qe(r,typeof e!="symbol"?e+"":e,t),Ee=(r,e,t)=>e.has(r)||Te("Cannot "+t),L=(r,e,t)=>(Ee(r,e,"read from private field"),t?t.call(r):e.get(r)),Y=(r,e,t)=>e.has(r)?Te("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),N=(r,e,t,n)=>(Ee(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);import{BufferGeometry as ue,Mesh as J,Texture as re,TextureLoader as Xe,Matrix4 as Ae,Clock as Ke,MeshStandardMaterial as He,Sphere as Ye,Box3 as Pe,Vector3 as U}from"./three-DuDKwKB8.min.js";import{DRACOLoader as Je,KTX2Loader as Qe,MeshoptDecoder as Ze,GLTFLoader as pe}from"./three-examples-DaDLBuy6.min.js";const et="";globalThis.GLTF_PROGRESSIVE_VERSION=et,console.debug("[gltf-progressive] version -");let W="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",Z="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";const tt=W,rt=Z,Be=new URL(W+"draco_decoder.js");Be.searchParams.append("range","true"),fetch(Be,{method:"GET",headers:{Range:"bytes=0-1"}}).catch(r=>{console.debug(`Failed to fetch remote Draco decoder from ${W} (offline: ${typeof navigator<"u"?navigator.onLine:"unknown"})`),W===tt&&Ie("./include/draco/"),Z===rt&&ke("./include/ktx2/")}).finally(()=>{Ce()});function Ie(r){W=r,A&&A[ve]!=W?(console.debug("Updating Draco decoder path to "+r),A[ve]=W,A.setDecoderPath(W),A.preload()):console.debug("Setting Draco decoder path to "+r)}function ke(r){Z=r,k&&k.transcoderPath!=Z?(console.debug("Updating KTX2 transcoder path to "+r),k.setTranscoderPath(Z),k.init()):console.debug("Setting KTX2 transcoder path to "+r)}const ve=Symbol("dracoDecoderPath");let A,ce,k;function Ce(){A||(A=new Je,A[ve]=W,A.setDecoderPath(W),A.setDecoderConfig({type:"js"}),A.preload()),k||(k=new Qe,k.setTranscoderPath(Z),k.init()),ce||(ce=Ze)}function ye(r){return Ce(),r?k.detectSupport(r):r!==null&&console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"),{dracoLoader:A,ktx2Loader:k,meshoptDecoder:ce}}function xe(r){r.dracoLoader||r.setDRACOLoader(A),r.ktx2Loader||r.setKTX2Loader(k),r.meshoptDecoder||r.setMeshoptDecoder(ce)}const Le=new WeakMap;function De(r,e){let t=Le.get(r);t?t=Object.assign(t,e):t=e,Le.set(r,t)}const Re=pe.prototype.load;function st(...r){const e=Le.get(this);let t=r[0];const n=new URL(t,window.location.href);if(n.hostname.endsWith("needle.tools")){const s=e?.progressive!==void 0?e.progressive:!0,i=e!=null&&e.usecase?e.usecase:"default";s?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${i}`:this.requestHeader.Accept=`*/*;usecase=${i}`,t=n.toString()}return r[0]=t,Re?.call(this,...r)}pe.prototype.load=st,se("debugprogressive");function se(r){if(typeof window>"u")return!1;const e=new URL(window.location.href).searchParams.get(r);return e==null||e==="0"||e==="false"?!1:e===""?!0:e}function nt(r,e){if(e===void 0||e.startsWith("./")||e.startsWith("http")||r===void 0)return e;const t=r.lastIndexOf("/");if(t>=0){const n=r.substring(0,t+1);for(;n.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return n+e}return e}let de;function ot(){return de!==void 0||(de=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),se("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",de)),de}const it=typeof window>"u"&&typeof document>"u",Me=Symbol("needle:raycast-mesh");function ee(r){return r?.[Me]instanceof ue?r[Me]:null}function at(r,e){if((r.type==="Mesh"||r.type==="SkinnedMesh")&&!ee(r)){const t=ut(e);t.userData={isRaycastMesh:!0},r[Me]=t}}function lt(r=!0){if(r){if(ne)return;const e=ne=J.prototype.raycast;J.prototype.raycast=function(t,n){const s=this,i=ee(s);let o;i&&s.isMesh&&(o=s.geometry,s.geometry=i),e.call(this,t,n),o&&(s.geometry=o)}}else{if(!ne)return;J.prototype.raycast=ne,ne=null}}let ne=null;function ut(r){const e=new ue;for(const t in r.attributes)e.setAttribute(t,r.getAttribute(t));return e.setIndex(r.getIndex()),e}const V=new Array,F="NEEDLE_progressive",y=se("debugprogressive"),we=Symbol("needle-progressive-texture"),oe=new Map,be=new Set;if(y){let r=function(){e+=1,console.log("Toggle LOD level",e,oe),oe.forEach((s,i)=>{for(const o of s.keys){const a=i[o];if(a!=null)if(a.isBufferGeometry===!0){const l=z.getMeshLODInformation(a),u=l?Math.min(e,l.lods.length):0;i["DEBUG:LOD"]=u,l&&(t=Math.max(t,l.lods.length-1))}else i.isMaterial===!0&&(i["DEBUG:LOD"]=e)}}),e>=t&&(e=-1)},e=-1,t=2,n=!1;window.addEventListener("keyup",s=>{s.key==="p"&&r(),s.key==="w"&&(n=!n,be&&be.forEach(i=>{i.name!="BackgroundCubeMaterial"&&i.glyphMap==null&&"wireframe"in i&&(i.wireframe=n)}))})}function je(r,e,t){var n;if(!y)return;oe.has(r)||oe.set(r,{keys:[],sourceId:t});const s=oe.get(r);((n=s?.keys)==null?void 0:n.includes(e))==!1&&s.keys.push(e)}const P=class j{constructor(e,t){d(this,"parser"),d(this,"url"),d(this,"_isLoadingMesh"),d(this,"loadMesh",n=>{var s,i;if(this._isLoadingMesh)return null;const o=(i=(s=this.parser.json.meshes[n])==null?void 0:s.extensions)==null?void 0:i[F];return o?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",n).then(a=>{var l;return this._isLoadingMesh=!1,a&&j.registerMesh(this.url,o.guid,a,(l=o.lods)==null?void 0:l.length,void 0,o),a})):null}),y&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return F}static getMeshLODInformation(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getMaterialMinMaxLODsCount(e,t){const n=this,s="LODS:minmax",i=e[s];if(i!=null)return i;if(t||(t={min_count:1/0,max_count:0,lods:[]}),Array.isArray(e)){for(const a of e)this.getMaterialMinMaxLODsCount(a,t);return e[s]=t,t}if(y==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const a=e;for(const l of Object.keys(a.uniforms)){const u=a.uniforms[l].value;u?.isTexture===!0&&o(u,t)}}else if(e.isMaterial)for(const a of Object.keys(e)){const l=e[a];l?.isTexture===!0&&o(l,t)}return e[s]=t,t;function o(a,l){const u=n.getAssignedLODInformation(a);if(u){const c=n.lodInfos.get(u.key);if(c&&c.lods){l.min_count=Math.min(l.min_count,c.lods.length),l.max_count=Math.max(l.max_count,c.lods.length);for(let f=0;f<c.lods.length;f++){const x=c.lods[f];x.width&&(l.lods[f]=l.lods[f]||{min_height:1/0,max_height:0},l.lods[f].min_height=Math.min(l.lods[f].min_height,x.height),l.lods[f].max_height=Math.max(l.lods[f].max_height,x.height))}}}}}static hasLODLevelAvailable(e,t){var n;if(Array.isArray(e)){for(const o of e)if(this.hasLODLevelAvailable(o,t))return!0;return!1}if(e.isMaterial===!0){for(const o of Object.keys(e)){const a=e[o];if(a&&a.isTexture&&this.hasLODLevelAvailable(a,t))return!0}return!1}else if(e.isGroup===!0){for(const o of e.children)if(o.isMesh===!0&&this.hasLODLevelAvailable(o,t))return!0}let s,i;if(e.isMesh?s=e.geometry:(e.isBufferGeometry||e.isTexture)&&(s=e),s&&(n=s?.userData)!=null&&n.LODS){const o=s.userData.LODS;if(i=this.lodInfos.get(o.key),t===void 0)return i!=null;if(i)return Array.isArray(i.lods)?t<i.lods.length:t===0}return!1}static assignMeshLOD(e,t){var n;if(!e)return Promise.resolve(null);if(e instanceof J||e.isMesh===!0){const s=e.geometry,i=this.getAssignedLODInformation(s);if(!i)return Promise.resolve(null);for(const o of V)(n=o.onBeforeGetLODMesh)==null||n.call(o,e,t);return e["LOD:requested level"]=t,j.getOrLoadLOD(s,t).then(o=>{if(Array.isArray(o)){const a=i.index||0;o=o[a]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],o&&s!=o&&(o?.isBufferGeometry?(e.geometry=o,y&&je(e,"geometry",i.url)):y&&console.error("Invalid LOD geometry",o))),o}).catch(o=>(console.error("Error loading mesh LOD",e,o),null))}else y&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(e,t=0){if(!e)return Promise.resolve(null);if(e.isMesh===!0){const n=e;if(Array.isArray(n.material)){const s=new Array;for(const i of n.material){const o=this.assignTextureLOD(i,t);s.push(o)}return Promise.all(s).then(i=>{const o=new Array;for(const a of i)Array.isArray(a)&&o.push(...a);return o})}else return this.assignTextureLOD(n.material,t)}if(e.isMaterial===!0){const n=e,s=[],i=new Array;if(y&&be.add(n),n.uniforms&&(n.isRawShaderMaterial||n.isShaderMaterial===!0)){const o=n;for(const a of Object.keys(o.uniforms)){const l=o.uniforms[a].value;if(l?.isTexture===!0){const u=this.assignTextureLODForSlot(l,t,n,a).then(c=>(c&&o.uniforms[a].value!=c&&(o.uniforms[a].value=c,o.uniformsNeedUpdate=!0),c));s.push(u),i.push(a)}}}else for(const o of Object.keys(n)){const a=n[o];if(a?.isTexture===!0){const l=this.assignTextureLODForSlot(a,t,n,o);s.push(l),i.push(o)}}return Promise.all(s).then(o=>{const a=new Array;for(let l=0;l<o.length;l++){const u=o[l],c=i[l];u&&u.isTexture===!0?a.push({material:n,slot:c,texture:u,level:t}):a.push({material:n,slot:c,texture:null,level:t})}return a})}if(e instanceof re||e.isTexture===!0){const n=e;return this.assignTextureLODForSlot(n,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,n,s){return e?.isTexture!==!0?Promise.resolve(null):s==="glyphMap"?Promise.resolve(e):j.getOrLoadLOD(e,t).then(i=>{if(Array.isArray(i))return null;if(i?.isTexture===!0){if(i!=e){if(n&&s){const o=n[s];if(o&&!y){const a=this.getAssignedLODInformation(o);if(a&&a?.level<t)return y==="verbose"&&console.warn("Assigned texture level is already higher: ",a.level,t,n,o,i),null}n[s]=i}if(y&&s&&n){const o=this.getAssignedLODInformation(e);o?je(n,s,o.url):console.warn("No LOD info for texture",e)}}return i}else y=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(i=>(console.error("Error loading LOD",e,i),null))}afterRoot(e){var t,n;return y&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((s,i)=>{var o;if(s!=null&&s.extensions){const a=s?.extensions[F];if(a){if(!a.lods){y&&console.warn("Texture has no LODs",a);return}let l=!1;for(const u of this.parser.associations.keys())if(u.isTexture===!0){const c=this.parser.associations.get(u);c?.textures===i&&(l=!0,j.registerTexture(this.url,u,(o=a.lods)==null?void 0:o.length,i,a))}l||this.parser.getDependency("texture",i).then(u=>{var c;u&&j.registerTexture(this.url,u,(c=a.lods)==null?void 0:c.length,i,a)})}}}),(n=this.parser.json.meshes)==null||n.forEach((s,i)=>{if(s!=null&&s.extensions){const o=s?.extensions[F];if(o&&o.lods){for(const a of this.parser.associations.keys())if(a.isMesh){const l=this.parser.associations.get(a);l?.meshes===i&&j.registerMesh(this.url,o.guid,a,o.lods.length,l.primitives,o)}}}}),null}static async getOrLoadLOD(e,t){var n,s,i,o;const a=y=="verbose",l=e.userData.LODS;if(!l)return null;const u=l?.key;let c;if(e.isTexture===!0){const f=e;f.source&&f.source[we]&&(c=f.source[we])}if(c||(c=j.lodInfos.get(u)),c){if(t>0){let m=!1;const B=Array.isArray(c.lods);if(B&&t>=c.lods.length?m=!0:B||(m=!0),m)return this.lowresCache.get(u)}const f=Array.isArray(c.lods)?(n=c.lods[t])==null?void 0:n.path:c.lods;if(!f)return y&&!c["missing:uri"]&&(c["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,c)),null;const x=nt(l.url,f);if(x.endsWith(".glb")||x.endsWith(".gltf")){if(!c.guid)return console.warn("missing pointer for glb/gltf texture",c),null;const m=x+"_"+c.guid,B=this.previouslyLoaded.get(m);if(B!==void 0){a&&console.log(`LOD ${t} was already loading/loaded: ${m}`);let v=await B.catch(E=>(console.error(`Error loading LOD ${t} from ${x}
2
2
  `,E),null)),S=!1;if(v==null||(v instanceof re&&e instanceof re?(s=v.image)!=null&&s.data||(i=v.source)!=null&&i.data?v=this.copySettings(e,v):(S=!0,this.previouslyLoaded.delete(m)):v instanceof ue&&e instanceof ue&&((o=v.attributes.position)!=null&&o.array||(S=!0,this.previouslyLoaded.delete(m)))),!S)return v}const g=c,p=new Promise(async(v,S)=>{const E=new pe;xe(E),y&&(await new Promise(w=>setTimeout(w,1e3)),a&&console.warn("Start loading (delayed) "+x,g.guid));let G=x;if(g&&Array.isArray(g.lods)){const w=g.lods[t];w.hash&&(G+="?v="+w.hash)}const _=await E.loadAsync(G).catch(w=>(console.error(`Error loading LOD ${t} from ${x}
3
3
  `,w),null));if(!_)return null;const D=_.parser;a&&console.log("Loading finished "+x,g.guid);let M=0;if(_.parser.json.textures){let w=!1;for(const h of _.parser.json.textures){if(h!=null&&h.extensions){const b=h?.extensions[F];if(b!=null&&b.guid&&b.guid===g.guid){w=!0;break}}M++}if(w){let h=await D.getDependency("texture",M);return h&&j.assignLODInformation(l.url,h,u,t,void 0,void 0),a&&console.log('change "'+e.name+'" \u2192 "'+h.name+'"',x,M,h,m),e instanceof re&&(h=this.copySettings(e,h)),h&&(h.guid=g.guid),v(h)}else y&&console.warn("Could not find texture with guid",g.guid,_.parser.json)}if(M=0,_.parser.json.meshes){let w=!1;for(const h of _.parser.json.meshes){if(h!=null&&h.extensions){const b=h?.extensions[F];if(b!=null&&b.guid&&b.guid===g.guid){w=!0;break}}M++}if(w){const h=await D.getDependency("mesh",M),b=g;if(a&&console.log(`Loaded Mesh "${h.name}"`,x,M,h,m),h.isMesh===!0){const I=h.geometry;return j.assignLODInformation(l.url,I,u,t,void 0,b.density),v(I)}else{const I=new Array;for(let $=0;$<h.children.length;$++){const Q=h.children[$];if(Q.isMesh===!0){const H=Q.geometry;j.assignLODInformation(l.url,H,u,t,$,b.density),I.push(H)}}return v(I)}}else y&&console.warn("Could not find mesh with guid",g.guid,_.parser.json)}return v(null)});return this.previouslyLoaded.set(m,p),await p}else if(e instanceof re){a&&console.log("Load texture from uri: "+x);const m=await new Xe().loadAsync(x);return m?(m.guid=c.guid,m.flipY=!1,m.needsUpdate=!0,m.colorSpace=e.colorSpace,a&&console.log(c,m)):y&&console.warn("failed loading",x),m}}else y&&console.warn(`Can not load LOD ${t}: no LOD info found for "${u}" ${e.name}`,e.type);return null}static assignLODInformation(e,t,n,s,i,o){if(!t)return;t.userData||(t.userData={});const a=new ct(e,n,s,i,o);t.userData.LODS=a}static getAssignedLODInformation(e){var t;return((t=e?.userData)==null?void 0:t.LODS)||null}static copySettings(e,t){return t?(y&&console.warn(`Copy texture settings
4
4
  `,e.uuid,`
@@ -5,8 +5,8 @@ var Ae = (o) => {
5
5
  var Ke = (o, e, t) => e in o ? qe(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
6
6
  var d = (o, e, t) => Ke(o, typeof e != "symbol" ? e + "" : e, t), Pe = (o, e, t) => e.has(o) || Ae("Cannot " + t);
7
7
  var m = (o, e, t) => (Pe(o, e, "read from private field"), t ? t.call(o) : e.get(o)), H = (o, e, t) => e.has(o) ? Ae("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), F = (o, e, t, s) => (Pe(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t);
8
- import { BufferGeometry as he, Mesh as Z, Texture as se, TextureLoader as Ye, Matrix4 as Ee, Clock as He, MeshStandardMaterial as Je, Sphere as Qe, Box3 as Ce, Vector3 as W } from "./three-Bz6X1mrw.js";
9
- import { DRACOLoader as Ze, KTX2Loader as je, MeshoptDecoder as et, GLTFLoader as Te } from "./three-examples-GggCDHv0.js";
8
+ import { BufferGeometry as he, Mesh as Z, Texture as se, TextureLoader as Ye, Matrix4 as Ee, Clock as He, MeshStandardMaterial as Je, Sphere as Qe, Box3 as Ce, Vector3 as W } from "./three-DrqIzZTH.js";
9
+ import { DRACOLoader as Ze, KTX2Loader as je, MeshoptDecoder as et, GLTFLoader as Te } from "./three-examples-B50TT3Iu.js";
10
10
  const tt = "";
11
11
  globalThis.GLTF_PROGRESSIVE_VERSION = tt;
12
12
  console.debug("[gltf-progressive] version -");
@@ -1,4 +1,4 @@
1
- "use strict";var ze=Object.defineProperty;var Ae=i=>{throw TypeError(i)};var We=(i,e,t)=>e in i?ze(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var d=(i,e,t)=>We(i,typeof e!="symbol"?e+"":e,t),Pe=(i,e,t)=>e.has(i)||Ae("Cannot "+t);var m=(i,e,t)=>(Pe(i,e,"read from private field"),t?t.call(i):e.get(i)),H=(i,e,t)=>e.has(i)?Ae("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),N=(i,e,t,r)=>(Pe(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);const y=require("./three-DMrv-4ar.umd.cjs"),Z=require("./three-examples-C7ryg8vN.umd.cjs"),Xe="";globalThis.GLTF_PROGRESSIVE_VERSION=Xe;console.debug("[gltf-progressive] version -");let z="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",j="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";const qe=z,Ke=j,ke=new URL(z+"draco_decoder.js");ke.searchParams.append("range","true");fetch(ke,{method:"GET",headers:{Range:"bytes=0-1"}}).catch(i=>{console.debug(`Failed to fetch remote Draco decoder from ${z} (offline: ${typeof navigator<"u"?navigator.onLine:"unknown"})`),z===qe&&Ge("./include/draco/"),j===Ke&&Ie("./include/ktx2/")}).finally(()=>{$e()});function Ge(i){z=i,B&&B[we]!=z?(console.debug("Updating Draco decoder path to "+i),B[we]=z,B.setDecoderPath(z),B.preload()):console.debug("Setting Draco decoder path to "+i)}function Ie(i){j=i,$&&$.transcoderPath!=j?(console.debug("Updating KTX2 transcoder path to "+i),$.setTranscoderPath(j),$.init()):console.debug("Setting KTX2 transcoder path to "+i)}const we=Symbol("dracoDecoderPath");let B,he,$;function $e(){B||(B=new Z.DRACOLoader,B[we]=z,B.setDecoderPath(z),B.setDecoderConfig({type:"js"}),B.preload()),$||($=new Z.KTX2Loader,$.setTranscoderPath(j),$.init()),he||(he=Z.MeshoptDecoder)}function be(i){return $e(),i?$.detectSupport(i):i!==null&&console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"),{dracoLoader:B,ktx2Loader:$,meshoptDecoder:he}}function Se(i){i.dracoLoader||i.setDRACOLoader(B),i.ktx2Loader||i.setKTX2Loader($),i.meshoptDecoder||i.setMeshoptDecoder(he)}const ve=new WeakMap;function Te(i,e){let t=ve.get(i);t?t=Object.assign(t,e):t=e,ve.set(i,t)}const me=Z.GLTFLoader.prototype.load;function Ye(...i){const e=ve.get(this);let t=i[0];const r=new URL(t,window.location.href);if(r.hostname.endsWith("needle.tools")){const s=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,o=e!=null&&e.usecase?e.usecase:"default";s?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${o}`:this.requestHeader.Accept=`*/*;usecase=${o}`,t=r.toString()}return i[0]=t,me==null?void 0:me.call(this,...i)}Z.GLTFLoader.prototype.load=Ye;le("debugprogressive");function le(i){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(i);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function He(i,e){if(e===void 0||e.startsWith("./")||e.startsWith("http")||i===void 0)return e;const t=i.lastIndexOf("/");if(t>=0){const r=i.substring(0,t+1);for(;r.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return r+e}return e}let se;function Je(){return se!==void 0||(se=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),le("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",se)),se}const Qe=typeof window>"u"&&typeof document>"u",Oe=Symbol("needle:raycast-mesh");function re(i){return(i==null?void 0:i[Oe])instanceof y.BufferGeometry?i[Oe]:null}function Ze(i,e){if((i.type==="Mesh"||i.type==="SkinnedMesh")&&!re(i)){const r=et(e);r.userData={isRaycastMesh:!0},i[Oe]=r}}function je(i=!0){if(i){if(oe)return;const e=oe=y.Mesh.prototype.raycast;y.Mesh.prototype.raycast=function(t,r){const n=this,s=re(n);let o;s&&n.isMesh&&(o=n.geometry,n.geometry=s),e.call(this,t,r),o&&(n.geometry=o)}}else{if(!oe)return;y.Mesh.prototype.raycast=oe,oe=null}}let oe=null;function et(i){const e=new y.BufferGeometry;for(const t in i.attributes)e.setAttribute(t,i.getAttribute(t));return e.setIndex(i.getIndex()),e}const Q=new Array,X="NEEDLE_progressive",x=le("debugprogressive"),xe=Symbol("needle-progressive-texture"),ie=new Map,_e=new Set;if(x){let i=function(){e+=1,console.log("Toggle LOD level",e,ie),ie.forEach((n,s)=>{for(const o of n.keys){const a=s[o];if(a!=null)if(a.isBufferGeometry===!0){const l=F.getMeshLODInformation(a),u=l?Math.min(e,l.lods.length):0;s["DEBUG:LOD"]=u,l&&(t=Math.max(t,l.lods.length-1))}else s.isMaterial===!0&&(s["DEBUG:LOD"]=e)}}),e>=t&&(e=-1)},e=-1,t=2,r=!1;window.addEventListener("keyup",n=>{n.key==="p"&&i(),n.key==="w"&&(r=!r,_e&&_e.forEach(s=>{s.name!="BackgroundCubeMaterial"&&s.glyphMap==null&&"wireframe"in s&&(s.wireframe=r)}))})}function Ee(i,e,t){var n;if(!x)return;ie.has(i)||ie.set(i,{keys:[],sourceId:t});const r=ie.get(i);((n=r==null?void 0:r.keys)==null?void 0:n.includes(e))==!1&&r.keys.push(e)}const D=class D{constructor(e,t){d(this,"parser");d(this,"url");d(this,"_isLoadingMesh");d(this,"loadMesh",e=>{var r,n;if(this._isLoadingMesh)return null;const t=(n=(r=this.parser.json.meshes[e])==null?void 0:r.extensions)==null?void 0:n[X];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(s=>{var o;return this._isLoadingMesh=!1,s&&D.registerMesh(this.url,t.guid,s,(o=t.lods)==null?void 0:o.length,void 0,t),s})):null});x&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return X}static getMeshLODInformation(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getMaterialMinMaxLODsCount(e,t){const r=this,n="LODS:minmax",s=e[n];if(s!=null)return s;if(t||(t={min_count:1/0,max_count:0,lods:[]}),Array.isArray(e)){for(const a of e)this.getMaterialMinMaxLODsCount(a,t);return e[n]=t,t}if(x==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const a=e;for(const l of Object.keys(a.uniforms)){const u=a.uniforms[l].value;(u==null?void 0:u.isTexture)===!0&&o(u,t)}}else if(e.isMaterial)for(const a of Object.keys(e)){const l=e[a];(l==null?void 0:l.isTexture)===!0&&o(l,t)}return e[n]=t,t;function o(a,l){const u=r.getAssignedLODInformation(a);if(u){const c=r.lodInfos.get(u.key);if(c&&c.lods){l.min_count=Math.min(l.min_count,c.lods.length),l.max_count=Math.max(l.max_count,c.lods.length);for(let g=0;g<c.lods.length;g++){const p=c.lods[g];p.width&&(l.lods[g]=l.lods[g]||{min_height:1/0,max_height:0},l.lods[g].min_height=Math.min(l.lods[g].min_height,p.height),l.lods[g].max_height=Math.max(l.lods[g].max_height,p.height))}}}}}static hasLODLevelAvailable(e,t){var s;if(Array.isArray(e)){for(const o of e)if(this.hasLODLevelAvailable(o,t))return!0;return!1}if(e.isMaterial===!0){for(const o of Object.keys(e)){const a=e[o];if(a&&a.isTexture&&this.hasLODLevelAvailable(a,t))return!0}return!1}else if(e.isGroup===!0){for(const o of e.children)if(o.isMesh===!0&&this.hasLODLevelAvailable(o,t))return!0}let r,n;if(e.isMesh?r=e.geometry:(e.isBufferGeometry||e.isTexture)&&(r=e),r&&(s=r==null?void 0:r.userData)!=null&&s.LODS){const o=r.userData.LODS;if(n=this.lodInfos.get(o.key),t===void 0)return n!=null;if(n)return Array.isArray(n.lods)?t<n.lods.length:t===0}return!1}static assignMeshLOD(e,t){var r;if(!e)return Promise.resolve(null);if(e instanceof y.Mesh||e.isMesh===!0){const n=e.geometry,s=this.getAssignedLODInformation(n);if(!s)return Promise.resolve(null);for(const o of Q)(r=o.onBeforeGetLODMesh)==null||r.call(o,e,t);return e["LOD:requested level"]=t,D.getOrLoadLOD(n,t).then(o=>{if(Array.isArray(o)){const a=s.index||0;o=o[a]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],o&&n!=o&&((o==null?void 0:o.isBufferGeometry)?(e.geometry=o,x&&Ee(e,"geometry",s.url)):x&&console.error("Invalid LOD geometry",o))),o}).catch(o=>(console.error("Error loading mesh LOD",e,o),null))}else x&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(e,t=0){if(!e)return Promise.resolve(null);if(e.isMesh===!0){const r=e;if(Array.isArray(r.material)){const n=new Array;for(const s of r.material){const o=this.assignTextureLOD(s,t);n.push(o)}return Promise.all(n).then(s=>{const o=new Array;for(const a of s)Array.isArray(a)&&o.push(...a);return o})}else return this.assignTextureLOD(r.material,t)}if(e.isMaterial===!0){const r=e,n=[],s=new Array;if(x&&_e.add(r),r.uniforms&&(r.isRawShaderMaterial||r.isShaderMaterial===!0)){const o=r;for(const a of Object.keys(o.uniforms)){const l=o.uniforms[a].value;if((l==null?void 0:l.isTexture)===!0){const u=this.assignTextureLODForSlot(l,t,r,a).then(c=>(c&&o.uniforms[a].value!=c&&(o.uniforms[a].value=c,o.uniformsNeedUpdate=!0),c));n.push(u),s.push(a)}}}else for(const o of Object.keys(r)){const a=r[o];if((a==null?void 0:a.isTexture)===!0){const l=this.assignTextureLODForSlot(a,t,r,o);n.push(l),s.push(o)}}return Promise.all(n).then(o=>{const a=new Array;for(let l=0;l<o.length;l++){const u=o[l],c=s[l];u&&u.isTexture===!0?a.push({material:r,slot:c,texture:u,level:t}):a.push({material:r,slot:c,texture:null,level:t})}return a})}if(e instanceof y.Texture||e.isTexture===!0){const r=e;return this.assignTextureLODForSlot(r,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,r,n){return(e==null?void 0:e.isTexture)!==!0?Promise.resolve(null):n==="glyphMap"?Promise.resolve(e):D.getOrLoadLOD(e,t).then(s=>{if(Array.isArray(s))return null;if((s==null?void 0:s.isTexture)===!0){if(s!=e){if(r&&n){const o=r[n];if(o&&!x){const a=this.getAssignedLODInformation(o);if(a&&(a==null?void 0:a.level)<t)return x==="verbose"&&console.warn("Assigned texture level is already higher: ",a.level,t,r,o,s),null}r[n]=s}if(x&&n&&r){const o=this.getAssignedLODInformation(e);o?Ee(r,n,o.url):console.warn("No LOD info for texture",e)}}return s}else x=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(s=>(console.error("Error loading LOD",e,s),null))}afterRoot(e){var t,r;return x&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((n,s)=>{var o;if(n!=null&&n.extensions){const a=n==null?void 0:n.extensions[X];if(a){if(!a.lods){x&&console.warn("Texture has no LODs",a);return}let l=!1;for(const u of this.parser.associations.keys())if(u.isTexture===!0){const c=this.parser.associations.get(u);(c==null?void 0:c.textures)===s&&(l=!0,D.registerTexture(this.url,u,(o=a.lods)==null?void 0:o.length,s,a))}l||this.parser.getDependency("texture",s).then(u=>{var c;u&&D.registerTexture(this.url,u,(c=a.lods)==null?void 0:c.length,s,a)})}}}),(r=this.parser.json.meshes)==null||r.forEach((n,s)=>{if(n!=null&&n.extensions){const o=n==null?void 0:n.extensions[X];if(o&&o.lods){for(const a of this.parser.associations.keys())if(a.isMesh){const l=this.parser.associations.get(a);(l==null?void 0:l.meshes)===s&&D.registerMesh(this.url,o.guid,a,o.lods.length,l.primitives,o)}}}}),null}static async getOrLoadLOD(e,t){var a,l,u,c;const r=x=="verbose",n=e.userData.LODS;if(!n)return null;const s=n==null?void 0:n.key;let o;if(e.isTexture===!0){const g=e;g.source&&g.source[xe]&&(o=g.source[xe])}if(o||(o=D.lodInfos.get(s)),o){if(t>0){let O=!1;const _=Array.isArray(o.lods);if(_&&t>=o.lods.length?O=!0:_||(O=!0),O)return this.lowresCache.get(s)}const g=Array.isArray(o.lods)?(a=o.lods[t])==null?void 0:a.path:o.lods;if(!g)return x&&!o["missing:uri"]&&(o["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,o)),null;const p=He(n.url,g);if(p.endsWith(".glb")||p.endsWith(".gltf")){if(!o.guid)return console.warn("missing pointer for glb/gltf texture",o),null;const O=p+"_"+o.guid,_=this.previouslyLoaded.get(O);if(_!==void 0){r&&console.log(`LOD ${t} was already loading/loaded: ${O}`);let h=await _.catch(V=>(console.error(`Error loading LOD ${t} from ${p}
1
+ "use strict";var ze=Object.defineProperty;var Ae=i=>{throw TypeError(i)};var We=(i,e,t)=>e in i?ze(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var d=(i,e,t)=>We(i,typeof e!="symbol"?e+"":e,t),Pe=(i,e,t)=>e.has(i)||Ae("Cannot "+t);var m=(i,e,t)=>(Pe(i,e,"read from private field"),t?t.call(i):e.get(i)),H=(i,e,t)=>e.has(i)?Ae("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),N=(i,e,t,r)=>(Pe(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);const y=require("./three-B_hneGZr.umd.cjs"),Z=require("./three-examples-X3OadjXB.umd.cjs"),Xe="";globalThis.GLTF_PROGRESSIVE_VERSION=Xe;console.debug("[gltf-progressive] version -");let z="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",j="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";const qe=z,Ke=j,ke=new URL(z+"draco_decoder.js");ke.searchParams.append("range","true");fetch(ke,{method:"GET",headers:{Range:"bytes=0-1"}}).catch(i=>{console.debug(`Failed to fetch remote Draco decoder from ${z} (offline: ${typeof navigator<"u"?navigator.onLine:"unknown"})`),z===qe&&Ge("./include/draco/"),j===Ke&&Ie("./include/ktx2/")}).finally(()=>{$e()});function Ge(i){z=i,B&&B[we]!=z?(console.debug("Updating Draco decoder path to "+i),B[we]=z,B.setDecoderPath(z),B.preload()):console.debug("Setting Draco decoder path to "+i)}function Ie(i){j=i,$&&$.transcoderPath!=j?(console.debug("Updating KTX2 transcoder path to "+i),$.setTranscoderPath(j),$.init()):console.debug("Setting KTX2 transcoder path to "+i)}const we=Symbol("dracoDecoderPath");let B,he,$;function $e(){B||(B=new Z.DRACOLoader,B[we]=z,B.setDecoderPath(z),B.setDecoderConfig({type:"js"}),B.preload()),$||($=new Z.KTX2Loader,$.setTranscoderPath(j),$.init()),he||(he=Z.MeshoptDecoder)}function be(i){return $e(),i?$.detectSupport(i):i!==null&&console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"),{dracoLoader:B,ktx2Loader:$,meshoptDecoder:he}}function Se(i){i.dracoLoader||i.setDRACOLoader(B),i.ktx2Loader||i.setKTX2Loader($),i.meshoptDecoder||i.setMeshoptDecoder(he)}const ve=new WeakMap;function Te(i,e){let t=ve.get(i);t?t=Object.assign(t,e):t=e,ve.set(i,t)}const me=Z.GLTFLoader.prototype.load;function Ye(...i){const e=ve.get(this);let t=i[0];const r=new URL(t,window.location.href);if(r.hostname.endsWith("needle.tools")){const s=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,o=e!=null&&e.usecase?e.usecase:"default";s?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${o}`:this.requestHeader.Accept=`*/*;usecase=${o}`,t=r.toString()}return i[0]=t,me==null?void 0:me.call(this,...i)}Z.GLTFLoader.prototype.load=Ye;le("debugprogressive");function le(i){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(i);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function He(i,e){if(e===void 0||e.startsWith("./")||e.startsWith("http")||i===void 0)return e;const t=i.lastIndexOf("/");if(t>=0){const r=i.substring(0,t+1);for(;r.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return r+e}return e}let se;function Je(){return se!==void 0||(se=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),le("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",se)),se}const Qe=typeof window>"u"&&typeof document>"u",Oe=Symbol("needle:raycast-mesh");function re(i){return(i==null?void 0:i[Oe])instanceof y.BufferGeometry?i[Oe]:null}function Ze(i,e){if((i.type==="Mesh"||i.type==="SkinnedMesh")&&!re(i)){const r=et(e);r.userData={isRaycastMesh:!0},i[Oe]=r}}function je(i=!0){if(i){if(oe)return;const e=oe=y.Mesh.prototype.raycast;y.Mesh.prototype.raycast=function(t,r){const n=this,s=re(n);let o;s&&n.isMesh&&(o=n.geometry,n.geometry=s),e.call(this,t,r),o&&(n.geometry=o)}}else{if(!oe)return;y.Mesh.prototype.raycast=oe,oe=null}}let oe=null;function et(i){const e=new y.BufferGeometry;for(const t in i.attributes)e.setAttribute(t,i.getAttribute(t));return e.setIndex(i.getIndex()),e}const Q=new Array,X="NEEDLE_progressive",x=le("debugprogressive"),xe=Symbol("needle-progressive-texture"),ie=new Map,_e=new Set;if(x){let i=function(){e+=1,console.log("Toggle LOD level",e,ie),ie.forEach((n,s)=>{for(const o of n.keys){const a=s[o];if(a!=null)if(a.isBufferGeometry===!0){const l=F.getMeshLODInformation(a),u=l?Math.min(e,l.lods.length):0;s["DEBUG:LOD"]=u,l&&(t=Math.max(t,l.lods.length-1))}else s.isMaterial===!0&&(s["DEBUG:LOD"]=e)}}),e>=t&&(e=-1)},e=-1,t=2,r=!1;window.addEventListener("keyup",n=>{n.key==="p"&&i(),n.key==="w"&&(r=!r,_e&&_e.forEach(s=>{s.name!="BackgroundCubeMaterial"&&s.glyphMap==null&&"wireframe"in s&&(s.wireframe=r)}))})}function Ee(i,e,t){var n;if(!x)return;ie.has(i)||ie.set(i,{keys:[],sourceId:t});const r=ie.get(i);((n=r==null?void 0:r.keys)==null?void 0:n.includes(e))==!1&&r.keys.push(e)}const D=class D{constructor(e,t){d(this,"parser");d(this,"url");d(this,"_isLoadingMesh");d(this,"loadMesh",e=>{var r,n;if(this._isLoadingMesh)return null;const t=(n=(r=this.parser.json.meshes[e])==null?void 0:r.extensions)==null?void 0:n[X];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(s=>{var o;return this._isLoadingMesh=!1,s&&D.registerMesh(this.url,t.guid,s,(o=t.lods)==null?void 0:o.length,void 0,t),s})):null});x&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return X}static getMeshLODInformation(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getMaterialMinMaxLODsCount(e,t){const r=this,n="LODS:minmax",s=e[n];if(s!=null)return s;if(t||(t={min_count:1/0,max_count:0,lods:[]}),Array.isArray(e)){for(const a of e)this.getMaterialMinMaxLODsCount(a,t);return e[n]=t,t}if(x==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const a=e;for(const l of Object.keys(a.uniforms)){const u=a.uniforms[l].value;(u==null?void 0:u.isTexture)===!0&&o(u,t)}}else if(e.isMaterial)for(const a of Object.keys(e)){const l=e[a];(l==null?void 0:l.isTexture)===!0&&o(l,t)}return e[n]=t,t;function o(a,l){const u=r.getAssignedLODInformation(a);if(u){const c=r.lodInfos.get(u.key);if(c&&c.lods){l.min_count=Math.min(l.min_count,c.lods.length),l.max_count=Math.max(l.max_count,c.lods.length);for(let g=0;g<c.lods.length;g++){const p=c.lods[g];p.width&&(l.lods[g]=l.lods[g]||{min_height:1/0,max_height:0},l.lods[g].min_height=Math.min(l.lods[g].min_height,p.height),l.lods[g].max_height=Math.max(l.lods[g].max_height,p.height))}}}}}static hasLODLevelAvailable(e,t){var s;if(Array.isArray(e)){for(const o of e)if(this.hasLODLevelAvailable(o,t))return!0;return!1}if(e.isMaterial===!0){for(const o of Object.keys(e)){const a=e[o];if(a&&a.isTexture&&this.hasLODLevelAvailable(a,t))return!0}return!1}else if(e.isGroup===!0){for(const o of e.children)if(o.isMesh===!0&&this.hasLODLevelAvailable(o,t))return!0}let r,n;if(e.isMesh?r=e.geometry:(e.isBufferGeometry||e.isTexture)&&(r=e),r&&(s=r==null?void 0:r.userData)!=null&&s.LODS){const o=r.userData.LODS;if(n=this.lodInfos.get(o.key),t===void 0)return n!=null;if(n)return Array.isArray(n.lods)?t<n.lods.length:t===0}return!1}static assignMeshLOD(e,t){var r;if(!e)return Promise.resolve(null);if(e instanceof y.Mesh||e.isMesh===!0){const n=e.geometry,s=this.getAssignedLODInformation(n);if(!s)return Promise.resolve(null);for(const o of Q)(r=o.onBeforeGetLODMesh)==null||r.call(o,e,t);return e["LOD:requested level"]=t,D.getOrLoadLOD(n,t).then(o=>{if(Array.isArray(o)){const a=s.index||0;o=o[a]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],o&&n!=o&&((o==null?void 0:o.isBufferGeometry)?(e.geometry=o,x&&Ee(e,"geometry",s.url)):x&&console.error("Invalid LOD geometry",o))),o}).catch(o=>(console.error("Error loading mesh LOD",e,o),null))}else x&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(e,t=0){if(!e)return Promise.resolve(null);if(e.isMesh===!0){const r=e;if(Array.isArray(r.material)){const n=new Array;for(const s of r.material){const o=this.assignTextureLOD(s,t);n.push(o)}return Promise.all(n).then(s=>{const o=new Array;for(const a of s)Array.isArray(a)&&o.push(...a);return o})}else return this.assignTextureLOD(r.material,t)}if(e.isMaterial===!0){const r=e,n=[],s=new Array;if(x&&_e.add(r),r.uniforms&&(r.isRawShaderMaterial||r.isShaderMaterial===!0)){const o=r;for(const a of Object.keys(o.uniforms)){const l=o.uniforms[a].value;if((l==null?void 0:l.isTexture)===!0){const u=this.assignTextureLODForSlot(l,t,r,a).then(c=>(c&&o.uniforms[a].value!=c&&(o.uniforms[a].value=c,o.uniformsNeedUpdate=!0),c));n.push(u),s.push(a)}}}else for(const o of Object.keys(r)){const a=r[o];if((a==null?void 0:a.isTexture)===!0){const l=this.assignTextureLODForSlot(a,t,r,o);n.push(l),s.push(o)}}return Promise.all(n).then(o=>{const a=new Array;for(let l=0;l<o.length;l++){const u=o[l],c=s[l];u&&u.isTexture===!0?a.push({material:r,slot:c,texture:u,level:t}):a.push({material:r,slot:c,texture:null,level:t})}return a})}if(e instanceof y.Texture||e.isTexture===!0){const r=e;return this.assignTextureLODForSlot(r,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,r,n){return(e==null?void 0:e.isTexture)!==!0?Promise.resolve(null):n==="glyphMap"?Promise.resolve(e):D.getOrLoadLOD(e,t).then(s=>{if(Array.isArray(s))return null;if((s==null?void 0:s.isTexture)===!0){if(s!=e){if(r&&n){const o=r[n];if(o&&!x){const a=this.getAssignedLODInformation(o);if(a&&(a==null?void 0:a.level)<t)return x==="verbose"&&console.warn("Assigned texture level is already higher: ",a.level,t,r,o,s),null}r[n]=s}if(x&&n&&r){const o=this.getAssignedLODInformation(e);o?Ee(r,n,o.url):console.warn("No LOD info for texture",e)}}return s}else x=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(s=>(console.error("Error loading LOD",e,s),null))}afterRoot(e){var t,r;return x&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((n,s)=>{var o;if(n!=null&&n.extensions){const a=n==null?void 0:n.extensions[X];if(a){if(!a.lods){x&&console.warn("Texture has no LODs",a);return}let l=!1;for(const u of this.parser.associations.keys())if(u.isTexture===!0){const c=this.parser.associations.get(u);(c==null?void 0:c.textures)===s&&(l=!0,D.registerTexture(this.url,u,(o=a.lods)==null?void 0:o.length,s,a))}l||this.parser.getDependency("texture",s).then(u=>{var c;u&&D.registerTexture(this.url,u,(c=a.lods)==null?void 0:c.length,s,a)})}}}),(r=this.parser.json.meshes)==null||r.forEach((n,s)=>{if(n!=null&&n.extensions){const o=n==null?void 0:n.extensions[X];if(o&&o.lods){for(const a of this.parser.associations.keys())if(a.isMesh){const l=this.parser.associations.get(a);(l==null?void 0:l.meshes)===s&&D.registerMesh(this.url,o.guid,a,o.lods.length,l.primitives,o)}}}}),null}static async getOrLoadLOD(e,t){var a,l,u,c;const r=x=="verbose",n=e.userData.LODS;if(!n)return null;const s=n==null?void 0:n.key;let o;if(e.isTexture===!0){const g=e;g.source&&g.source[xe]&&(o=g.source[xe])}if(o||(o=D.lodInfos.get(s)),o){if(t>0){let O=!1;const _=Array.isArray(o.lods);if(_&&t>=o.lods.length?O=!0:_||(O=!0),O)return this.lowresCache.get(s)}const g=Array.isArray(o.lods)?(a=o.lods[t])==null?void 0:a.path:o.lods;if(!g)return x&&!o["missing:uri"]&&(o["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,o)),null;const p=He(n.url,g);if(p.endsWith(".glb")||p.endsWith(".gltf")){if(!o.guid)return console.warn("missing pointer for glb/gltf texture",o),null;const O=p+"_"+o.guid,_=this.previouslyLoaded.get(O);if(_!==void 0){r&&console.log(`LOD ${t} was already loading/loaded: ${O}`);let h=await _.catch(V=>(console.error(`Error loading LOD ${t} from ${p}
2
2
  `,V),null)),R=!1;if(h==null||(h instanceof y.Texture&&e instanceof y.Texture?(l=h.image)!=null&&l.data||(u=h.source)!=null&&u.data?h=this.copySettings(e,h):(R=!0,this.previouslyLoaded.delete(O)):h instanceof y.BufferGeometry&&e instanceof y.BufferGeometry&&((c=h.attributes.position)!=null&&c.array||(R=!0,this.previouslyLoaded.delete(O)))),!R)return h}const M=o,U=new Promise(async(h,R)=>{const V=new Z.GLTFLoader;Se(V),x&&(await new Promise(T=>setTimeout(T,1e3)),r&&console.warn("Start loading (delayed) "+p,M.guid));let k=p;if(M&&Array.isArray(M.lods)){const T=M.lods[t];T.hash&&(k+="?v="+T.hash)}const P=await V.loadAsync(k).catch(T=>(console.error(`Error loading LOD ${t} from ${p}
3
3
  `,T),null));if(!P)return null;const W=P.parser;r&&console.log("Loading finished "+p,M.guid);let S=0;if(P.parser.json.textures){let T=!1;for(const f of P.parser.json.textures){if(f!=null&&f.extensions){const L=f==null?void 0:f.extensions[X];if(L!=null&&L.guid&&L.guid===M.guid){T=!0;break}}S++}if(T){let f=await W.getDependency("texture",S);return f&&D.assignLODInformation(n.url,f,s,t,void 0,void 0),r&&console.log('change "'+e.name+'" → "'+f.name+'"',p,S,f,O),e instanceof y.Texture&&(f=this.copySettings(e,f)),f&&(f.guid=M.guid),h(f)}else x&&console.warn("Could not find texture with guid",M.guid,P.parser.json)}if(S=0,P.parser.json.meshes){let T=!1;for(const f of P.parser.json.meshes){if(f!=null&&f.extensions){const L=f==null?void 0:f.extensions[X];if(L!=null&&L.guid&&L.guid===M.guid){T=!0;break}}S++}if(T){const f=await W.getDependency("mesh",S),L=M;if(r&&console.log(`Loaded Mesh "${f.name}"`,p,S,f,O),f.isMesh===!0){const b=f.geometry;return D.assignLODInformation(n.url,b,s,t,void 0,L.density),h(b)}else{const b=new Array;for(let A=0;A<f.children.length;A++){const E=f.children[A];if(E.isMesh===!0){const Y=E.geometry;D.assignLODInformation(n.url,Y,s,t,A,L.density),b.push(Y)}}return h(b)}}else x&&console.warn("Could not find mesh with guid",M.guid,P.parser.json)}return h(null)});return this.previouslyLoaded.set(O,U),await U}else if(e instanceof y.Texture){r&&console.log("Load texture from uri: "+p);const _=await new y.TextureLoader().loadAsync(p);return _?(_.guid=o.guid,_.flipY=!1,_.needsUpdate=!0,_.colorSpace=e.colorSpace,r&&console.log(o,_)):x&&console.warn("failed loading",p),_}}else x&&console.warn(`Can not load LOD ${t}: no LOD info found for "${s}" ${e.name}`,e.type);return null}static assignLODInformation(e,t,r,n,s,o){if(!t)return;t.userData||(t.userData={});const a=new tt(e,r,n,s,o);t.userData.LODS=a}static getAssignedLODInformation(e){var t;return((t=e==null?void 0:e.userData)==null?void 0:t.LODS)||null}static copySettings(e,t){return t?(x&&console.warn(`Copy texture settings
4
4
  `,e.uuid,`