@needle-tools/engine 4.7.0-next.da47826 → 4.7.0-next.fe38209

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 (60) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{gltf-progressive-Bl4okF1b.min.js → gltf-progressive-60Qk5ebF.min.js} +6 -6
  3. package/dist/{gltf-progressive-DSpdn0QT.js → gltf-progressive-DM5ZiecW.js} +176 -170
  4. package/dist/gltf-progressive-wxtaVmio.umd.cjs +8 -0
  5. package/dist/{needle-engine.bundle-CO1Ub9sm.js → needle-engine.bundle-9cpwwMWz.js} +3929 -3906
  6. package/dist/{needle-engine.bundle-Bu88IoKB.umd.cjs → needle-engine.bundle-B5YoLPqw.umd.cjs} +117 -114
  7. package/dist/{needle-engine.bundle-D95XN5pP.min.js → needle-engine.bundle-DlHpd9LP.min.js} +115 -112
  8. package/dist/needle-engine.js +3 -3
  9. package/dist/needle-engine.min.js +1 -1
  10. package/dist/needle-engine.umd.cjs +1 -1
  11. package/lib/engine/engine_addressables.d.ts +1 -3
  12. package/lib/engine/engine_addressables.js +5 -12
  13. package/lib/engine/engine_addressables.js.map +1 -1
  14. package/lib/engine/engine_context.js +4 -3
  15. package/lib/engine/engine_context.js.map +1 -1
  16. package/lib/engine/engine_lightdata.js +12 -2
  17. package/lib/engine/engine_lightdata.js.map +1 -1
  18. package/lib/engine/engine_lods.d.ts +4 -0
  19. package/lib/engine/engine_lods.js +19 -5
  20. package/lib/engine/engine_lods.js.map +1 -1
  21. package/lib/engine/engine_three_utils.js +4 -0
  22. package/lib/engine/engine_three_utils.js.map +1 -1
  23. package/lib/engine/webcomponents/needle-engine.attributes.d.ts +1 -1
  24. package/lib/engine-components/Camera.js +1 -1
  25. package/lib/engine-components/Camera.js.map +1 -1
  26. package/lib/engine-components/CameraUtils.js +5 -3
  27. package/lib/engine-components/CameraUtils.js.map +1 -1
  28. package/lib/engine-components/Skybox.js +4 -4
  29. package/lib/engine-components/Skybox.js.map +1 -1
  30. package/lib/engine-components/postprocessing/Effects/Antialiasing.js +8 -1
  31. package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
  32. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +1 -1
  33. package/lib/engine-components/postprocessing/PostProcessingHandler.js +15 -1
  34. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  35. package/lib/engine-components/postprocessing/Volume.js +1 -1
  36. package/lib/engine-components/postprocessing/Volume.js.map +1 -1
  37. package/package.json +2 -2
  38. package/plugins/common/logger.js +328 -0
  39. package/plugins/types/userconfig.d.ts +6 -2
  40. package/plugins/vite/alias.js +55 -40
  41. package/plugins/vite/imports-logger.js +1 -1
  42. package/plugins/vite/index.js +4 -0
  43. package/plugins/vite/logger.client.js +272 -0
  44. package/plugins/vite/logger.js +101 -0
  45. package/plugins/vite/materialx.js +32 -0
  46. package/plugins/vite/transform.js +1 -0
  47. package/src/engine/engine_addressables.ts +6 -15
  48. package/src/engine/engine_context.ts +4 -3
  49. package/src/engine/engine_lightdata.ts +10 -2
  50. package/src/engine/engine_lods.ts +23 -5
  51. package/src/engine/engine_three_utils.ts +3 -0
  52. package/src/engine/webcomponents/needle-engine.attributes.ts +1 -1
  53. package/src/engine-components/Camera.ts +1 -1
  54. package/src/engine-components/CameraUtils.ts +5 -3
  55. package/src/engine-components/Skybox.ts +5 -5
  56. package/src/engine-components/postprocessing/Effects/Antialiasing.ts +8 -1
  57. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -1
  58. package/src/engine-components/postprocessing/PostProcessingHandler.ts +14 -2
  59. package/src/engine-components/postprocessing/Volume.ts +1 -1
  60. package/dist/gltf-progressive-P8b8a0qY.umd.cjs +0 -8
@@ -1,10 +1,13 @@
1
1
  import { MODULES } from "../../../engine/engine_modules.js";
2
2
  import { serializable } from "../../../engine/engine_serialization.js";
3
+ import { getParam } from "../../../engine/engine_utils.js";
3
4
  import { type EffectProviderResult, PostProcessingEffect } from "../PostProcessingEffect.js";
4
5
  import { VolumeParameter } from "../VolumeParameter.js";
5
6
  import { registerCustomEffectType } from "../VolumeProfile.js";
6
7
 
7
8
 
9
+ const debug = getParam("debugpost");
10
+
8
11
 
9
12
  export enum QualityLevel {
10
13
  LOW = 0,
@@ -32,15 +35,19 @@ export class Antialiasing extends PostProcessingEffect {
32
35
 
33
36
  onCreateEffect(): EffectProviderResult {
34
37
  const effect = new MODULES.POSTPROCESSING.MODULE.SMAAEffect({
35
- preset: MODULES.POSTPROCESSING.MODULE.SMAAPreset.HIGH,
38
+ preset: this.preset?.value ?? MODULES.POSTPROCESSING.MODULE.SMAAPreset.HIGH,
36
39
  edgeDetectionMode: MODULES.POSTPROCESSING.MODULE.EdgeDetectionMode.LUMA,
37
40
  // Keep predication mode disabled (default) since it looks better
38
41
  // predicationMode: MODULES.POSTPROCESSING.MODULE.PredicationMode.DEPTH,
39
42
  });
40
43
 
41
44
  this.preset.onValueChanged = (newValue) => {
45
+ if(debug) console.log("Antialiasing preset changed to", newValue);
42
46
  effect.applyPreset(newValue);
43
47
  };
48
+ // setInterval(()=> {
49
+ // effect.applyPreset(Math.floor(Math.random()*3))
50
+ // }, 1000)
44
51
 
45
52
  // effect.edgeDetectionMaterial.edgeDetectionThreshold = .01;
46
53
 
@@ -124,7 +124,7 @@ export class ScreenSpaceAmbientOcclusionN8 extends PostProcessingEffect {
124
124
  cam,
125
125
  width, height
126
126
  ) as N8AOPostPass;
127
- ssao.name = "SSAO N8";
127
+ ssao.name = "SSAO_N8";
128
128
 
129
129
  const mode = ScreenSpaceAmbientOcclusionN8QualityMode[this.quality];
130
130
  ssao.setQualityMode(mode);
@@ -162,9 +162,11 @@ export class PostProcessingHandler {
162
162
  const res = component.apply(ctx);
163
163
  if (!res) continue;
164
164
 
165
+ const name = component.typeName || component.constructor.name;
165
166
 
166
167
  if (Array.isArray(res)) {
167
168
  for (const effect of res) {
169
+ if (!validateEffect(name, effect)) continue;
168
170
  this._effects.push({
169
171
  effect,
170
172
  typeName: component.typeName,
@@ -173,12 +175,23 @@ export class PostProcessingHandler {
173
175
  }
174
176
  }
175
177
  else {
178
+ if (!validateEffect(name, res)) continue;
176
179
  this._effects.push({
177
180
  effect: res,
178
181
  typeName: component.typeName,
179
182
  priority: component.order
180
183
  });
181
184
  }
185
+
186
+ function validateEffect(source: string, effect: Effect | Pass): boolean {
187
+ if (!effect) {
188
+ return false;
189
+ }
190
+ if (!(effect instanceof MODULES.POSTPROCESSING.MODULE.Effect || effect instanceof MODULES.POSTPROCESSING.MODULE.Pass)) {
191
+ console.warn(`PostprocessingEffect ${source} created neither Effect nor Pass - this might be caused by a bundler error or false import. Below you find some possible solutions:\n- If you create custom effect try creating it like this: 'new NEEDLE_ENGINE_MODULES.POSTPROCESSING.MODULE.Effect(...)' instead of 'new Effect(...)'`);
192
+ }
193
+ return true;
194
+ }
182
195
  }
183
196
  }
184
197
  else {
@@ -403,7 +416,7 @@ export class PostProcessingHandler {
403
416
  if (attributes & convolution) {
404
417
  if (debug) console.log("[PostProcessing] Convolution effect: " + ef.name);
405
418
  if (hasConvolutionEffectInArray) {
406
- if (debug) console.log("[PostProcessing] Merging effects with convolution", effectsToMerge.map(e => e.name).join(", "));
419
+ if (debug) console.log("[PostProcessing] Merging effects [" + effectsToMerge.map(e => e.name).join(", ") + "]");
407
420
  this.createPassForMergeableEffects(effectsToMerge, composer, cam, scene);
408
421
  }
409
422
  hasConvolutionEffectInArray = true;
@@ -448,7 +461,6 @@ export class PostProcessingHandler {
448
461
  }
449
462
  foundEnabled = true;
450
463
  }
451
-
452
464
  pass.renderToScreen = renderToScreen;
453
465
 
454
466
  if ((pass as any)?.configuration !== undefined) {
@@ -194,7 +194,7 @@ export class Volume extends Behaviour implements IEditorModificationReceiver, IP
194
194
  if (this._postprocessing.multisampling !== 0) {
195
195
  this._postprocessing.multisampling = 0;
196
196
  if (debug || isDevEnvironment()) {
197
- console.warn(`[PostProcessing] Disabling multisampling you're using SMAA and have set the 'multisampling: auto' on your PostprocessingManager/Volume component. If you need anti-aliasing, consider adding an Antialiasing component or SMAA effect to the PostprocessingManager.`);
197
+ console.log(`[PostProcessing] multisampling is disabled because it's set to 'auto' on your PostprocessingManager/Volume component that also has an SMAA effect.\n\nIf you need multisampling consider changing 'auto' to a fixed value (e.g. 4).`);
198
198
  }
199
199
  }
200
200
  }
@@ -1,8 +0,0 @@
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
- `,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
- `,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
- `,e.uuid,`
5
- `,t.uuid),t=t.clone(),t.offset=e.offset,t.repeat=e.repeat,t.colorSpace=e.colorSpace,t.magFilter=e.magFilter,t.minFilter=e.minFilter,t.wrapS=e.wrapS,t.wrapT=e.wrapT,t.flipY=e.flipY,t.anisotropy=e.anisotropy,t.mipmaps||(t.generateMipmaps=e.generateMipmaps),t):e}};d(D,"registerTexture",(e,t,r,n,s)=>{if(x&&console.log("> Progressive: register texture",n,t.name,t.uuid,t,s),!t){x&&console.error("gltf-progressive: Register texture without texture");return}t.source&&(t.source[xe]=s);const o=s.guid;D.assignLODInformation(e,t,o,r,n,void 0),D.lodInfos.set(o,s),D.lowresCache.set(o,t)}),d(D,"registerMesh",(e,t,r,n,s,o)=>{var u;x&&console.log("> Progressive: register mesh",s,r.name,o,r.uuid,r);const a=r.geometry;if(!a){x&&console.warn("gltf-progressive: Register mesh without geometry");return}a.userData||(a.userData={}),D.assignLODInformation(e,a,t,n,s,o.density),D.lodInfos.set(t,o);let l=D.lowresCache.get(t);l?l.push(r.geometry):l=[r.geometry],D.lowresCache.set(t,l),n>0&&!re(r)&&Ze(r,a);for(const c of Q)(u=c.onRegisteredNewMesh)==null||u.call(c,r,o)}),d(D,"lodInfos",new Map),d(D,"previouslyLoaded",new Map),d(D,"lowresCache",new Map);let F=D;class tt{constructor(e,t,r,n,s){d(this,"url");d(this,"key");d(this,"level");d(this,"index");d(this,"density");this.url=e,this.key=t,this.level=r,n!=null&&(this.index=n),s!=null&&(this.density=s)}}const G=le("debugprogressive"),rt=le("noprogressive"),De=Symbol("Needle:LODSManager"),Me=Symbol("Needle:LODState"),J=Symbol("Needle:CurrentLOD"),I={mesh_lod:-1,texture_lod:-1};var v,C,q,ge,ee,te,pe,K;let ae=(v=class{constructor(e,t){d(this,"context");d(this,"renderer");d(this,"projectionScreenMatrix",new y.Matrix4);d(this,"targetTriangleDensity",2e5);d(this,"updateInterval","auto");H(this,C,1);d(this,"pause",!1);d(this,"manual",!1);d(this,"_lodchangedlisteners",[]);H(this,q);H(this,ge,new y.Clock);H(this,ee,0);H(this,te,0);H(this,pe,0);H(this,K,0);d(this,"_fpsBuffer",[60,60,60,60,60]);d(this,"_sphere",new y.Sphere);d(this,"_tempBox",new y.Box3);d(this,"_tempBox2",new y.Box3);d(this,"tempMatrix",new y.Matrix4);d(this,"_tempWorldPosition",new y.Vector3);d(this,"_tempBoxSize",new y.Vector3);d(this,"_tempBox2Size",new y.Vector3);this.renderer=e,this.context={...t}}static getObjectLODState(e){return e[Me]}static addPlugin(e){Q.push(e)}static removePlugin(e){const t=Q.indexOf(e);t>=0&&Q.splice(t,1)}static get(e,t){if(e[De])return console.debug("[gltf-progressive] LODsManager already exists for this renderer"),e[De];const r=new v(e,{engine:"unknown",...t});return e[De]=r,r}get plugins(){return Q}addEventListener(e,t){e==="changed"&&this._lodchangedlisteners.push(t)}removeEventListener(e,t){if(e==="changed"){const r=this._lodchangedlisteners.indexOf(t);r>=0&&this._lodchangedlisteners.splice(r,1)}}enable(){if(m(this,q))return;console.debug("[gltf-progressive] Enabling LODsManager for renderer");let e=0;N(this,q,this.renderer.render);const t=this;be(this.renderer),this.renderer.render=function(r,n){const s=t.renderer.getRenderTarget();(s==null||"isXRRenderTarget"in s&&s.isXRRenderTarget)&&(e=0,N(t,ee,m(t,ee)+1),N(t,te,m(t,ge).getDelta()),N(t,pe,m(t,pe)+m(t,te)),t._fpsBuffer.shift(),t._fpsBuffer.push(1/m(t,te)),N(t,K,t._fpsBuffer.reduce((a,l)=>a+l)/t._fpsBuffer.length),G&&m(t,ee)%200===0&&console.log("FPS",Math.round(m(t,K)),"Interval:",m(t,C)));const o=e++;m(t,q).call(this,r,n),t.onAfterRender(r,n,o)}}disable(){m(this,q)&&(console.debug("[gltf-progressive] Disabling LODsManager for renderer"),this.renderer.render=m(this,q),N(this,q,void 0))}update(e,t){this.internalUpdate(e,t)}onAfterRender(e,t,r){if(this.pause)return;const s=this.renderer.renderLists.get(e,0).opaque;let o=!0;if(s.length===1){const a=s[0].material;(a.name==="EffectMaterial"||a.name==="CopyShader")&&(o=!1)}if((t.parent&&t.parent.type==="CubeCamera"||r>=1&&t.type==="OrthographicCamera")&&(o=!1),o){if(rt||(this.updateInterval==="auto"?m(this,K)<40&&m(this,C)<10?(N(this,C,m(this,C)+1),G&&console.warn("↓ Reducing LOD updates",m(this,C),m(this,K).toFixed(0))):m(this,K)>=60&&m(this,C)>1&&(N(this,C,m(this,C)-1),G&&console.warn("↑ Increasing LOD updates",m(this,C),m(this,K).toFixed(0))):N(this,C,this.updateInterval),m(this,C)>0&&m(this,ee)%m(this,C)!=0))return;this.internalUpdate(e,t)}}internalUpdate(e,t){var l,u;const r=this.renderer.renderLists.get(e,0),n=r.opaque;this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);const s=this.targetTriangleDensity;for(const c of n){if(c.material&&(((l=c.geometry)==null?void 0:l.type)==="BoxGeometry"||((u=c.geometry)==null?void 0:u.type)==="BufferGeometry")&&(c.material.name==="SphericalGaussianBlur"||c.material.name=="BackgroundCubeMaterial"||c.material.name==="CubemapFromEquirect"||c.material.name==="EquirectangularToCubeUV")){G&&(c.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]||(c.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]=!0,console.warn("Ignoring skybox or BLIT object",c,c.material.name,c.material.type)));continue}switch(c.material.type){case"LineBasicMaterial":case"LineDashedMaterial":case"PointsMaterial":case"ShadowMaterial":case"MeshDistanceMaterial":case"MeshDepthMaterial":continue}if(G==="color"&&c.material&&!c.object.progressive_debug_color){c.object.progressive_debug_color=!0;const p=Math.random()*16777215,O=new y.MeshStandardMaterial({color:p});c.object.material=O}const g=c.object;(g instanceof y.Mesh||g.isMesh)&&this.updateLODs(e,t,g,s)}const o=r.transparent;for(const c of o){const g=c.object;(g instanceof y.Mesh||g.isMesh)&&this.updateLODs(e,t,g,s)}const a=r.transmissive;for(const c of a){const g=c.object;(g instanceof y.Mesh||g.isMesh)&&this.updateLODs(e,t,g,s)}}updateLODs(e,t,r,n){var a,l;r.userData||(r.userData={});let s=r[Me];if(s||(s=new st,r[Me]=s),s.frames++<2)return;for(const u of Q)(a=u.onBeforeUpdateLOD)==null||a.call(u,this.renderer,e,t,r);this.calculateLodLevel(t,r,s,n,I),I.mesh_lod=Math.round(I.mesh_lod),I.texture_lod=Math.round(I.texture_lod),I.mesh_lod>=0&&this.loadProgressiveMeshes(r,I.mesh_lod);let o=I.texture_lod;r.material&&o>=0&&this.loadProgressiveTextures(r.material,o);for(const u of Q)(l=u.onAfterUpdatedLOD)==null||l.call(u,this.renderer,e,t,r,I);s.lastLodLevel_Mesh=I.mesh_lod,s.lastLodLevel_Texture=I.texture_lod}loadProgressiveTextures(e,t){if(!e)return;if(Array.isArray(e)){for(const s of e)this.loadProgressiveTextures(s,t);return}let r=!1;(e[J]===void 0||t<e[J])&&(r=!0);const n=e["DEBUG:LOD"];n!=null&&(r=e[J]!=n,t=n),r&&(e[J]=t,F.assignTextureLOD(e,t).then(s=>{this._lodchangedlisteners.forEach(o=>o({type:"texture",level:t,object:e}))}))}loadProgressiveMeshes(e,t){if(!e)return Promise.resolve(null);let r=e[J]!==t;const n=e["DEBUG:LOD"];if(n!=null&&(r=e[J]!=n,t=n),r){e[J]=t;const s=e.geometry;return F.assignMeshLOD(e,t).then(o=>(o&&e[J]==t&&s!=e.geometry&&this._lodchangedlisteners.forEach(a=>a({type:"mesh",level:t,object:e})),o))}return Promise.resolve(null)}static isInside(e,t){const r=e.min,n=e.max,s=(r.x+n.x)*.5,o=(r.y+n.y)*.5;return this._tempPtInside.set(s,o,r.z).applyMatrix4(t).z<0}calculateLodLevel(e,t,r,n,s){var U;if(!t){s.mesh_lod=-1,s.texture_lod=-1;return}if(!e){s.mesh_lod=-1,s.texture_lod=-1;return}let a=10+1,l=!1;if(G&&t["DEBUG:LOD"]!=null)return t["DEBUG:LOD"];const u=F.getMeshLODInformation(t.geometry),c=u==null?void 0:u.lods,g=c&&c.length>0,p=F.getMaterialMinMaxLODsCount(t.material),O=(p==null?void 0:p.min_count)!=1/0&&p.min_count>0&&p.max_count>0;if(!g&&!O){s.mesh_lod=0,s.texture_lod=0;return}g||(l=!0,a=0);const _=this.renderer.domElement.clientHeight||this.renderer.domElement.height;let M=t.geometry.boundingBox;if(t.type==="SkinnedMesh"){const w=t;if(!w.boundingBox)w.computeBoundingBox();else if(r.frames%30===0){const h=re(w),R=w.geometry;h&&(w.geometry=h),w.computeBoundingBox(),w.geometry=R}M=w.boundingBox}if(M){const w=e;if(t.geometry.attributes.color&&t.geometry.attributes.color.count<100&&t.geometry.boundingSphere){this._sphere.copy(t.geometry.boundingSphere),this._sphere.applyMatrix4(t.matrixWorld);const f=e.getWorldPosition(this._tempWorldPosition);if(this._sphere.containsPoint(f)){s.mesh_lod=0,s.texture_lod=0;return}}if(this._tempBox.copy(M),this._tempBox.applyMatrix4(t.matrixWorld),w.isPerspectiveCamera&&v.isInside(this._tempBox,this.projectionScreenMatrix)){s.mesh_lod=0,s.texture_lod=0;return}if(this._tempBox.applyMatrix4(this.projectionScreenMatrix),this.renderer.xr.enabled&&w.isPerspectiveCamera&&w.fov>70){const f=this._tempBox.min,L=this._tempBox.max;let b=f.x,A=f.y,E=L.x,Y=L.y;const ce=2,ye=1.5,ue=(f.x+L.x)*.5,fe=(f.y+L.y)*.5;b=(b-ue)*ce+ue,A=(A-fe)*ce+fe,E=(E-ue)*ce+ue,Y=(Y-fe)*ce+fe;const Ve=b<0&&E>0?0:Math.min(Math.abs(f.x),Math.abs(L.x)),Ne=A<0&&Y>0?0:Math.min(Math.abs(f.y),Math.abs(L.y)),Le=Math.max(Ve,Ne);r.lastCentrality=(ye-Le)*(ye-Le)*(ye-Le)}else r.lastCentrality=1;const h=this._tempBox.getSize(this._tempBoxSize);h.multiplyScalar(.5),screen.availHeight>0&&_>0&&h.multiplyScalar(_/screen.availHeight),e.isPerspectiveCamera?h.x*=e.aspect:e.isOrthographicCamera;const R=e.matrixWorldInverse,V=this._tempBox2;V.copy(M),V.applyMatrix4(t.matrixWorld),V.applyMatrix4(R);const k=V.getSize(this._tempBox2Size),P=Math.max(k.x,k.y);if(Math.max(h.x,h.y)!=0&&P!=0&&(h.z=k.z/Math.max(k.x,k.y)*Math.max(h.x,h.y)),r.lastScreenCoverage=Math.max(h.x,h.y,h.z),r.lastScreenspaceVolume.copy(h),r.lastScreenCoverage*=r.lastCentrality,G&&v.debugDrawLine){const f=this.tempMatrix.copy(this.projectionScreenMatrix);f.invert();const L=v.corner0,b=v.corner1,A=v.corner2,E=v.corner3;L.copy(this._tempBox.min),b.copy(this._tempBox.max),b.x=L.x,A.copy(this._tempBox.max),A.y=L.y,E.copy(this._tempBox.max);const Y=(L.z+E.z)*.5;L.z=b.z=A.z=E.z=Y,L.applyMatrix4(f),b.applyMatrix4(f),A.applyMatrix4(f),E.applyMatrix4(f),v.debugDrawLine(L,b,255),v.debugDrawLine(L,A,255),v.debugDrawLine(b,E,255),v.debugDrawLine(A,E,255)}let S=999;if(c&&r.lastScreenCoverage>0){for(let f=0;f<c.length;f++)if(c[f].density/r.lastScreenCoverage<n){S=f;break}}S<a&&(a=S,l=!0)}if(l?s.mesh_lod=a:s.mesh_lod=r.lastLodLevel_Mesh,G&&s.mesh_lod!=r.lastLodLevel_Mesh){const h=c==null?void 0:c[s.mesh_lod];h&&console.log(`Mesh LOD changed: ${r.lastLodLevel_Mesh} → ${s.mesh_lod} (${h.density.toFixed(0)}) - ${t.name}`)}if(O){const w="saveData"in globalThis.navigator&&globalThis.navigator.saveData===!0;if(r.lastLodLevel_Texture<0){if(s.texture_lod=p.max_count-1,G){const h=p.lods[p.max_count-1];G&&console.log(`First Texture LOD ${s.texture_lod} (${h.max_height}px) - ${t.name}`)}}else{const h=r.lastScreenspaceVolume.x+r.lastScreenspaceVolume.y+r.lastScreenspaceVolume.z;let R=r.lastScreenCoverage*4;((U=this.context)==null?void 0:U.engine)==="model-viewer"&&(R*=1.5);const k=_/window.devicePixelRatio*R;let P=!1;for(let W=p.lods.length-1;W>=0;W--){let S=p.lods[W];if(!(w&&S.max_height>=2048)&&!(Je()&&S.max_height>4096)&&(S.max_height>k||!P&&W===0)){if(P=!0,s.texture_lod=W,s.texture_lod<r.lastLodLevel_Texture){const T=S.max_height;G&&console.log(`Texture LOD changed: ${r.lastLodLevel_Texture} → ${s.texture_lod} = ${T}px
6
- Screensize: ${k.toFixed(0)}px, Coverage: ${(100*r.lastScreenCoverage).toFixed(2)}%, Volume ${h.toFixed(1)}
7
- ${t.name}`)}break}}}}else s.texture_lod=0}},C=new WeakMap,q=new WeakMap,ge=new WeakMap,ee=new WeakMap,te=new WeakMap,pe=new WeakMap,K=new WeakMap,d(v,"debugDrawLine"),d(v,"corner0",new y.Vector3),d(v,"corner1",new y.Vector3),d(v,"corner2",new y.Vector3),d(v,"corner3",new y.Vector3),d(v,"_tempPtInside",new y.Vector3),v);class st{constructor(){d(this,"frames",0);d(this,"lastLodLevel_Mesh",-1);d(this,"lastLodLevel_Texture",-1);d(this,"lastScreenCoverage",0);d(this,"lastScreenspaceVolume",new y.Vector3);d(this,"lastCentrality",0)}}const Ce=Symbol("NEEDLE_mesh_lod"),de=Symbol("NEEDLE_texture_lod");let ne=null;function Fe(){const i=ot();i&&(i.mapURLs(function(e){return Be(),e}),Be(),ne==null||ne.disconnect(),ne=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(r=>{r instanceof HTMLElement&&r.tagName.toLowerCase()==="model-viewer"&&Ue(r)})})}),ne.observe(document,{childList:!0,subtree:!0}))}function ot(){if(typeof customElements>"u")return null;const i=customElements.get("model-viewer");return i||(customElements.whenDefined("model-viewer").then(()=>{console.debug("[gltf-progressive] model-viewer defined"),Fe()}),null)}function Be(){if(typeof document>"u")return;document.querySelectorAll("model-viewer").forEach(e=>{Ue(e)})}const Re=new WeakSet;let nt=0;function Ue(i){if(!i||Re.has(i))return null;Re.add(i),console.debug("[gltf-progressive] found new model-viewer..."+ ++nt+`
8
- `,i.getAttribute("src"));let e=null,t=null,r=null;for(let n=i;n!=null;n=Object.getPrototypeOf(n)){const s=Object.getOwnPropertySymbols(n),o=s.find(u=>u.toString()=="Symbol(renderer)"),a=s.find(u=>u.toString()=="Symbol(scene)"),l=s.find(u=>u.toString()=="Symbol(needsRender)");!e&&o!=null&&(e=i[o].threeRenderer),!t&&a!=null&&(t=i[a]),!r&&l!=null&&(r=i[l])}if(e&&t){let n=function(){if(r){let o=0,a=setInterval(()=>{if(o++>5){clearInterval(a);return}r==null||r.call(i)},300)}};console.debug("[gltf-progressive] setup model-viewer");const s=ae.get(e,{engine:"model-viewer"});return ae.addPlugin(new it),s.enable(),s.addEventListener("changed",()=>{r==null||r.call(i)}),i.addEventListener("model-visibility",o=>{o.detail.visible&&(r==null||r.call(i))}),i.addEventListener("load",()=>{n()}),()=>{s.disable()}}return null}class it{constructor(){d(this,"_didWarnAboutMissingUrl",!1)}onBeforeUpdateLOD(e,t,r,n){this.tryParseMeshLOD(t,n),this.tryParseTextureLOD(t,n)}getUrl(e){if(!e)return null;let t=e.getAttribute("src");return t||(t=e.src),t||(this._didWarnAboutMissingUrl||console.warn("No url found in modelviewer",e),this._didWarnAboutMissingUrl=!0),t}tryGetCurrentGLTF(e){return e._currentGLTF}tryGetCurrentModelViewer(e){return e.element}tryParseTextureLOD(e,t){if(t[de]==!0)return;t[de]=!0;const r=this.tryGetCurrentGLTF(e),n=this.tryGetCurrentModelViewer(e),s=this.getUrl(n);if(s&&r&&t.material){let o=function(l){var c,g,p;if(l[de]==!0)return;l[de]=!0,l.userData&&(l.userData.LOD=-1);const u=Object.keys(l);for(let O=0;O<u.length;O++){const _=u[O],M=l[_];if((M==null?void 0:M.isTexture)===!0){const U=(g=(c=M.userData)==null?void 0:c.associations)==null?void 0:g.textures;if(U==null)continue;const w=r.parser.json.textures[U];if(!w){console.warn("Texture data not found for texture index "+U);continue}if((p=w==null?void 0:w.extensions)!=null&&p[X]){const h=w.extensions[X];h&&s&&F.registerTexture(s,M,h.lods.length,U,h)}}}};const a=t.material;if(Array.isArray(a))for(const l of a)o(l);else o(a)}}tryParseMeshLOD(e,t){var o,a;if(t[Ce]==!0)return;t[Ce]=!0;const r=this.tryGetCurrentModelViewer(e),n=this.getUrl(r);if(!n)return;const s=(a=(o=t.userData)==null?void 0:o.gltfExtensions)==null?void 0:a[X];if(s&&n){const l=t.uuid;F.registerMesh(n,l,t,0,s.lods.length,s)}}}function at(i,e,t,r){be(e),Se(t),Te(t,{progressive:!0,...r==null?void 0:r.hints}),t.register(s=>new F(s,i));const n=ae.get(e);return(r==null?void 0:r.enableLODsManager)!==!1&&n.enable(),n}Fe();if(!Qe){const i={gltfProgressive:{useNeedleProgressive:at,LODsManager:ae,configureLoader:Te,getRaycastMesh:re,useRaycastMeshes:je}};if(!globalThis.Needle)globalThis.Needle=i;else for(const e in i)globalThis.Needle[e]=i[e]}exports.LODsManager=ae;exports.NEEDLE_progressive=F;exports.addDracoAndKTX2Loaders=Se;exports.configureLoader=Te;exports.createLoaders=be;exports.getRaycastMesh=re;exports.setDracoDecoderLocation=Ge;exports.setKTX2TranscoderLocation=Ie;