@needle-tools/engine 4.7.3-next.65e7878 → 4.7.3-next.b448b7a
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.
- package/dist/gltf-progressive-BMJtMiwp.js +1204 -0
- package/dist/gltf-progressive-DMJSXxbo.umd.cjs +8 -0
- package/dist/gltf-progressive-zQ2CaD2H.min.js +8 -0
- package/dist/{needle-engine.bundle-B0QYYufM.js → needle-engine.bundle-BQzYQCWt.js} +36 -10
- package/dist/{needle-engine.bundle-BCAZfCyl.min.js → needle-engine.bundle-BUgKFz_t.min.js} +7 -7
- package/dist/{needle-engine.bundle-C6yScKUU.umd.cjs → needle-engine.bundle-CmHXdQmP.umd.cjs} +8 -8
- package/dist/needle-engine.js +3 -3
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-TkXiVrjY.min.js → postprocessing-BzY0H7ry.min.js} +8 -8
- package/dist/{postprocessing-CNCT892s.umd.cjs → postprocessing-Dw2OCMp4.umd.cjs} +8 -8
- package/dist/{postprocessing-qvgDnYKK.js → postprocessing-vKBVFpSz.js} +9 -9
- package/lib/engine/engine_lods.js +1 -1
- package/lib/engine/engine_lods.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +19 -1
- package/lib/engine-components/OrbitControls.js +30 -1
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/lib/engine-components/postprocessing/Volume.d.ts +3 -1
- package/lib/engine-components/postprocessing/Volume.js +2 -0
- package/lib/engine-components/postprocessing/Volume.js.map +1 -1
- package/package.json +2 -2
- package/plugins/vite/logger.client.js +68 -30
- package/plugins/vite/logger.js +5 -5
- package/src/engine/engine_lods.ts +3 -3
- package/src/engine-components/OrbitControls.ts +34 -2
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +1 -1
- package/src/engine-components/postprocessing/Volume.ts +2 -1
- package/dist/gltf-progressive-BCZdu3Gc.min.js +0 -8
- package/dist/gltf-progressive-C6QbvrB4.umd.cjs +0 -8
- package/dist/gltf-progressive-CCddD-3B.js +0 -1159
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";var Xe=Object.defineProperty;var Ge=o=>{throw TypeError(o)};var Ke=(o,e,t)=>e in o?Xe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var u=(o,e,t)=>Ke(o,typeof e!="symbol"?e+"":e,t),Be=(o,e,t)=>e.has(o)||Ge("Cannot "+t);var x=(o,e,t)=>(Be(o,e,"read from private field"),t?t.call(o):e.get(o)),Y=(o,e,t)=>e.has(o)?Ge("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(o):e.set(o,t),z=(o,e,t,s)=>(Be(o,e,"write to private field"),s?s.call(o,t):e.set(o,t),t);const y=require("./three-B_hneGZr.umd.cjs"),te=require("./three-examples-DUcCNw9s.umd.cjs"),Ye="";globalThis.GLTF_PROGRESSIVE_VERSION=Ye;console.debug("[gltf-progressive] version -");let q="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",se="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";const He=q,Qe=se,Re=new URL(q+"draco_decoder.js");Re.searchParams.append("range","true");fetch(Re,{method:"GET",headers:{Range:"bytes=0-1"}}).catch(o=>{console.debug(`Failed to fetch remote Draco decoder from ${q} (offline: ${typeof navigator<"u"?navigator.onLine:"unknown"})`),q===He&&Ie("./include/draco/"),se===Qe&&Fe("./include/ktx2/")}).finally(()=>{Ue()});function Ie(o){q=o,k&&k[be]!=q?(console.debug("Updating Draco decoder path to "+o),k[be]=q,k.setDecoderPath(q),k.preload()):console.debug("Setting Draco decoder path to "+o)}function Fe(o){se=o,U&&U.transcoderPath!=se?(console.debug("Updating KTX2 transcoder path to "+o),U.setTranscoderPath(se),U.init()):console.debug("Setting KTX2 transcoder path to "+o)}const be=Symbol("dracoDecoderPath");let k,ye,U;function Ue(){k||(k=new te.DRACOLoader,k[be]=q,k.setDecoderPath(q),k.setDecoderConfig({type:"js"}),k.preload()),U||(U=new te.KTX2Loader,U.setTranscoderPath(se),U.init()),ye||(ye=te.MeshoptDecoder)}function Te(o){return Ue(),o?U.detectSupport(o):o!==null&&console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"),{dracoLoader:k,ktx2Loader:U,meshoptDecoder:ye}}function Ae(o){o.dracoLoader||o.setDRACOLoader(k),o.ktx2Loader||o.setKTX2Loader(U),o.meshoptDecoder||o.setMeshoptDecoder(ye)}const Se=new WeakMap;function Ce(o,e){let t=Se.get(o);t?t=Object.assign(t,e):t=e,Se.set(o,t)}const Me=te.GLTFLoader.prototype.load;function je(...o){const e=Se.get(this);let t=o[0];const s=new URL(t,window.location.href);if(s.hostname.endsWith("needle.tools")){const r=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,i=e!=null&&e.usecase?e.usecase:"default";r?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${i}`:this.requestHeader.Accept=`*/*;usecase=${i}`,t=s.toString()}return o[0]=t,Me==null?void 0:Me.call(this,...o)}te.GLTFLoader.prototype.load=je;de("debugprogressive");function de(o){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(o);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function Je(o,e){if(e===void 0||e.startsWith("./")||e.startsWith("http")||o===void 0)return e;const t=o.lastIndexOf("/");if(t>=0){const s=o.substring(0,t+1);for(;s.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return s+e}return e}let oe;function Ze(){return oe!==void 0||(oe=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),de("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",oe)),oe}function et(){if(typeof window>"u")return!1;const o=new URL(window.location.href),e=o.hostname==="localhost"||/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o.hostname);return o.hostname==="127.0.0.1"||e}class tt{constructor(e=100,t={}){u(this,"_running",new Map);u(this,"_queue",[]);u(this,"debug",!1);u(this,"tick",()=>{this.internalUpdate(),setTimeout(this.tick,10)});this.maxConcurrent=e,this.debug=t.debug??!1,window.requestAnimationFrame(this.tick)}slot(e){return this.debug&&console.debug(`[PromiseQueue]: Requesting slot for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`),new Promise(t=>{this._queue.push({key:e,resolve:t})})}add(e,t){this._running.has(e)||(this._running.set(e,t),t.finally(()=>{this._running.delete(e),this.debug&&console.debug(`[PromiseQueue]: Promise for key ${e} finished, running: ${this._running.size}, waiting: ${this._queue.length}`)}),this.debug&&console.debug(`[PromiseQueue]: Adding promise for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`))}internalUpdate(){const e=this.maxConcurrent-this._running.size;for(let t=0;t<e&&this._queue.length>0;t++){this.debug&&console.debug(`[PromiseQueue]: Running ${this._running.size} promises, waiting for ${this._queue.length} more.`);const{key:s,resolve:n}=this._queue.shift();n({use:r=>this.add(s,r)})}}}const st=typeof window>"u"&&typeof document>"u",Pe=Symbol("needle:raycast-mesh");function ie(o){return(o==null?void 0:o[Pe])instanceof y.BufferGeometry?o[Pe]:null}function rt(o,e){if((o.type==="Mesh"||o.type==="SkinnedMesh")&&!ie(o)){const s=nt(e);s.userData={isRaycastMesh:!0},o[Pe]=s}}function it(o=!0){if(o){if(ae)return;const e=ae=y.Mesh.prototype.raycast;y.Mesh.prototype.raycast=function(t,s){const n=this,r=ie(n);let i;r&&n.isMesh&&(i=n.geometry,n.geometry=r),e.call(this,t,s),i&&(n.geometry=i)}}else{if(!ae)return;y.Mesh.prototype.raycast=ae,ae=null}}let ae=null;function nt(o){const e=new y.BufferGeometry;for(const t in o.attributes)e.setAttribute(t,o.getAttribute(t));return e.setIndex(o.getIndex()),e}const Q=new Array,w=de("debugprogressive");let pe,ee=-1;if(w){let o=function(){ee+=1,ee>=e&&(ee=-1),console.log(`Toggle LOD level [${ee}]`)},e=6;window.addEventListener("keyup",t=>{t.key==="p"&&o(),t.key==="w"&&(pe=!pe,console.log(`Toggle wireframe [${pe}]`));const s=parseInt(t.key);!isNaN(s)&&s>=0&&(ee=s,console.log(`Set LOD level to [${ee}]`))})}function Ne(o){if(w)if(Array.isArray(o))for(const e of o)Ne(e);else o&&"wireframe"in o&&(o.wireframe=pe===!0)}const W="NEEDLE_progressive",De=Symbol("needle-progressive-texture"),M=class M{constructor(e,t){u(this,"parser");u(this,"url");u(this,"_isLoadingMesh");u(this,"loadMesh",e=>{var s,n;if(this._isLoadingMesh)return null;const t=(n=(s=this.parser.json.meshes[e])==null?void 0:s.extensions)==null?void 0:n[W];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(r=>{var i;return this._isLoadingMesh=!1,r&&M.registerMesh(this.url,t.guid,r,(i=t.lods)==null?void 0:i.length,0,t),r})):null});w&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return W}static getMeshLODExtension(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getPrimitiveIndex(e){var s;const t=(s=this.getAssignedLODInformation(e))==null?void 0:s.index;return t??-1}static getMaterialMinMaxLODsCount(e,t){const s=this,n="LODS:minmax",r=e[n];if(r!=null)return r;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(w==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const a=e;for(const l of Object.keys(a.uniforms)){const c=a.uniforms[l].value;(c==null?void 0:c.isTexture)===!0&&i(c,t)}}else if(e.isMaterial)for(const a of Object.keys(e)){const l=e[a];(l==null?void 0:l.isTexture)===!0&&i(l,t)}return e[n]=t,t;function i(a,l){const c=s.getAssignedLODInformation(a);if(c){const d=s.lodInfos.get(c.key);if(d&&d.lods){l.min_count=Math.min(l.min_count,d.lods.length),l.max_count=Math.max(l.max_count,d.lods.length);for(let p=0;p<d.lods.length;p++){const f=d.lods[p];f.width&&(l.lods[p]=l.lods[p]||{min_height:1/0,max_height:0},l.lods[p].min_height=Math.min(l.lods[p].min_height,f.height),l.lods[p].max_height=Math.max(l.lods[p].max_height,f.height))}}}}}static hasLODLevelAvailable(e,t){var r;if(Array.isArray(e)){for(const i of e)if(this.hasLODLevelAvailable(i,t))return!0;return!1}if(e.isMaterial===!0){for(const i of Object.keys(e)){const a=e[i];if(a&&a.isTexture&&this.hasLODLevelAvailable(a,t))return!0}return!1}else if(e.isGroup===!0){for(const i of e.children)if(i.isMesh===!0&&this.hasLODLevelAvailable(i,t))return!0}let s,n;if(e.isMesh?s=e.geometry:(e.isBufferGeometry||e.isTexture)&&(s=e),s&&(r=s==null?void 0:s.userData)!=null&&r.LODS){const i=s.userData.LODS;if(n=this.lodInfos.get(i.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 s;if(!e)return Promise.resolve(null);if(e instanceof y.Mesh||e.isMesh===!0){const n=e.geometry,r=this.getAssignedLODInformation(n);if(!r)return Promise.resolve(null);for(const i of Q)(s=i.onBeforeGetLODMesh)==null||s.call(i,e,t);return e["LOD:requested level"]=t,M.getOrLoadLOD(n,t).then(i=>{if(Array.isArray(i)){const a=r.index||0;i=i[a]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],i&&n!=i&&((i==null?void 0:i.isBufferGeometry)?e.geometry=i:w&&console.error("Invalid LOD geometry",i))),i}).catch(i=>(console.error("Error loading mesh LOD",e,i),null))}else w&&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 s=e;if(Array.isArray(s.material)){const n=new Array;for(const r of s.material){const i=this.assignTextureLOD(r,t);n.push(i)}return Promise.all(n).then(r=>{const i=new Array;for(const a of r)Array.isArray(a)&&i.push(...a);return i})}else return this.assignTextureLOD(s.material,t)}if(e.isMaterial===!0){const s=e,n=[],r=new Array;if(s.uniforms&&(s.isRawShaderMaterial||s.isShaderMaterial===!0)){const i=s;for(const a of Object.keys(i.uniforms)){const l=i.uniforms[a].value;if((l==null?void 0:l.isTexture)===!0){const c=this.assignTextureLODForSlot(l,t,s,a).then(d=>(d&&i.uniforms[a].value!=d&&(i.uniforms[a].value=d,i.uniformsNeedUpdate=!0),d));n.push(c),r.push(a)}}}else for(const i of Object.keys(s)){const a=s[i];if((a==null?void 0:a.isTexture)===!0){const l=this.assignTextureLODForSlot(a,t,s,i);n.push(l),r.push(i)}}return Promise.all(n).then(i=>{const a=new Array;for(let l=0;l<i.length;l++){const c=i[l],d=r[l];c&&c.isTexture===!0?a.push({material:s,slot:d,texture:c,level:t}):a.push({material:s,slot:d,texture:null,level:t})}return a})}if(e instanceof y.Texture||e.isTexture===!0){const s=e;return this.assignTextureLODForSlot(s,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,s,n){return(e==null?void 0:e.isTexture)!==!0?Promise.resolve(null):n==="glyphMap"?Promise.resolve(e):M.getOrLoadLOD(e,t).then(r=>{if(Array.isArray(r))return null;if((r==null?void 0:r.isTexture)===!0){if(r!=e&&s&&n){const i=s[n];if(i&&!w){const a=this.getAssignedLODInformation(i);if(a&&(a==null?void 0:a.level)<t)return w==="verbose"&&console.warn("Assigned texture level is already higher: ",a.level,t,s,i,r),null}s[n]=r}return r}else w=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(r=>(console.error("Error loading LOD",e,r),null))}afterRoot(e){var t,s;return w&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((n,r)=>{var i;if(n!=null&&n.extensions){const a=n==null?void 0:n.extensions[W];if(a){if(!a.lods){w&&console.warn("Texture has no LODs",a);return}let l=!1;for(const c of this.parser.associations.keys())if(c.isTexture===!0){const d=this.parser.associations.get(c);(d==null?void 0:d.textures)===r&&(l=!0,M.registerTexture(this.url,c,(i=a.lods)==null?void 0:i.length,r,a))}l||this.parser.getDependency("texture",r).then(c=>{var d;c&&M.registerTexture(this.url,c,(d=a.lods)==null?void 0:d.length,r,a)})}}}),(s=this.parser.json.meshes)==null||s.forEach((n,r)=>{if(n!=null&&n.extensions){const i=n==null?void 0:n.extensions[W];if(i&&i.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)===r&&M.registerMesh(this.url,i.guid,a,i.lods.length,l.primitives,i)}}}}),null}static async getOrLoadLOD(e,t){var a,l,c,d;const s=w=="verbose",n=e.userData.LODS;if(!n)return null;const r=n==null?void 0:n.key;let i;if(e.isTexture===!0){const p=e;p.source&&p.source[De]&&(i=p.source[De])}if(i||(i=M.lodInfos.get(r)),i){if(t>0){let v=!1;const b=Array.isArray(i.lods);if(b&&t>=i.lods.length?v=!0:b||(v=!0),v)return this.lowresCache.get(r)}const p=Array.isArray(i.lods)?(a=i.lods[t])==null?void 0:a.path:i.lods;if(!p)return w&&!i["missing:uri"]&&(i["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,i)),null;const f=Je(n.url,p);if(f.endsWith(".glb")||f.endsWith(".gltf")){if(!i.guid)return console.warn("missing pointer for glb/gltf texture",i),null;const v=f+"_"+i.guid,b=this.previouslyLoaded.get(v);if(b!==void 0){s&&console.log(`LOD ${t} was already loading/loaded: ${v}`);let h=await b.catch(A=>(console.error(`Error loading LOD ${t} from ${f}
|
|
2
|
+
`,A),null)),_=!1;if(h==null||(h instanceof y.Texture&&e instanceof y.Texture?(l=h.image)!=null&&l.data||(c=h.source)!=null&&c.data?h=this.copySettings(e,h):(_=!0,this.previouslyLoaded.delete(v)):h instanceof y.BufferGeometry&&e instanceof y.BufferGeometry&&((d=h.attributes.position)!=null&&d.array||(_=!0,this.previouslyLoaded.delete(v)))),!_)return h}const T=await this.queue.slot(f);if(!T.use)return w&&console.log(`LOD ${t} was aborted: ${f}`),null;const S=i,R=new Promise(async(h,_)=>{const A=new te.GLTFLoader;Ae(A),w&&(await new Promise(O=>setTimeout(O,1e3)),s&&console.warn("Start loading (delayed) "+f,S.guid));let N=f;if(S&&Array.isArray(S.lods)){const O=S.lods[t];O.hash&&(N+="?v="+O.hash)}const P=await A.loadAsync(N).catch(O=>(console.error(`Error loading LOD ${t} from ${f}
|
|
3
|
+
`,O),h(null)));if(!P)return h(null);const Z=P.parser;s&&console.log("Loading finished "+f,S.guid);let C=0;if(P.parser.json.textures){let O=!1;for(const m of P.parser.json.textures){if(m!=null&&m.extensions){const g=m==null?void 0:m.extensions[W];if(g!=null&&g.guid&&g.guid===S.guid){O=!0;break}}C++}if(O){let m=await Z.getDependency("texture",C);return m&&M.assignLODInformation(n.url,m,r,t,void 0),s&&console.log('change "'+e.name+'" → "'+m.name+'"',f,C,m,v),e instanceof y.Texture&&(m=this.copySettings(e,m)),m&&(m.guid=S.guid),h(m)}else w&&console.warn("Could not find texture with guid",S.guid,P.parser.json)}if(C=0,P.parser.json.meshes){let O=!1;for(const m of P.parser.json.meshes){if(m!=null&&m.extensions){const g=m==null?void 0:m.extensions[W];if(g!=null&&g.guid&&g.guid===S.guid){O=!0;break}}C++}if(O){const m=await Z.getDependency("mesh",C);if(s&&console.log(`Loaded Mesh "${m.name}"`,f,C,m,v),m.isMesh===!0){const g=m.geometry;return M.assignLODInformation(n.url,g,r,t,0),h(g)}else{const g=new Array;for(let D=0;D<m.children.length;D++){const G=m.children[D];if(G.isMesh===!0){const B=G.geometry;M.assignLODInformation(n.url,B,r,t,D),g.push(B)}}return h(g)}}else w&&console.warn("Could not find mesh with guid",S.guid,P.parser.json)}return h(null)});return this.previouslyLoaded.set(v,R),T.use(R),await R}else if(e instanceof y.Texture){s&&console.log("Load texture from uri: "+f);const b=await new y.TextureLoader().loadAsync(f);return b?(b.guid=i.guid,b.flipY=!1,b.needsUpdate=!0,b.colorSpace=e.colorSpace,s&&console.log(i,b)):w&&console.warn("failed loading",f),b}}else w&&console.warn(`Can not load LOD ${t}: no LOD info found for "${r}" ${e.name}`,e.type);return null}static assignLODInformation(e,t,s,n,r){if(!t)return;t.userData||(t.userData={});const i=new ot(e,s,n,r);t.userData.LODS=i}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?(w&&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}};u(M,"registerTexture",(e,t,s,n,r)=>{if(w&&console.log("> Progressive: register texture",n,t.name,t.uuid,t,r),!t){w&&console.error("gltf-progressive: Register texture without texture");return}t.source&&(t.source[De]=r);const i=r.guid;M.assignLODInformation(e,t,i,s,n),M.lodInfos.set(i,r),M.lowresCache.set(i,t)}),u(M,"registerMesh",(e,t,s,n,r,i)=>{var c;const a=s.geometry;if(!a){w&&console.warn("gltf-progressive: Register mesh without geometry");return}a.userData||(a.userData={}),w&&console.log("> Progressive: register mesh "+s.name,{index:r,uuid:s.uuid},i,s),M.assignLODInformation(e,a,t,n,r),M.lodInfos.set(t,i);let l=M.lowresCache.get(t);l?l.push(s.geometry):l=[s.geometry],M.lowresCache.set(t,l),n>0&&!ie(s)&&rt(s,a);for(const d of Q)(c=d.onRegisteredNewMesh)==null||c.call(d,s,i)}),u(M,"lodInfos",new Map),u(M,"previouslyLoaded",new Map),u(M,"lowresCache",new Map),u(M,"queue",new tt(100,{debug:w!=!1}));let F=M;class ot{constructor(e,t,s,n){u(this,"url");u(this,"key");u(this,"level");u(this,"index");this.url=e,this.key=t,this.level=s,n!=null&&(this.index=n)}}class me{constructor(e,t){u(this,"frame_start");u(this,"frame_capture_end");u(this,"ready");u(this,"_resolve");u(this,"_signal");u(this,"_resolved",!1);u(this,"_addedCount",0);u(this,"_resolvedCount",0);u(this,"_awaiting",[]);u(this,"_maxPromisesPerObject",1);u(this,"_currentFrame",0);u(this,"_seen",new WeakMap);var r;const n=Math.max(t.frames??2,2);this.frame_start=e,this.frame_capture_end=e+n,this.ready=new Promise(i=>{this._resolve=i}),this.ready.finally(()=>{this._resolved=!0,this._awaiting.length=0}),this._signal=t.signal,(r=this._signal)==null||r.addEventListener("abort",()=>{this.resolveNow()}),this._maxPromisesPerObject=Math.max(1,t.maxPromisesPerObject??1)}get awaitedCount(){return this._addedCount}get resolvedCount(){return this._resolvedCount}get currentlyAwaiting(){return this._awaiting.length}update(e){var t;this._currentFrame=e,((t=this._signal)!=null&&t.aborted||this._currentFrame>this.frame_capture_end&&this._awaiting.length===0)&&this.resolveNow()}add(e,t,s){if(this._resolved){w&&console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");return}if(!(this._currentFrame>this.frame_capture_end)){if(this._maxPromisesPerObject>=1)if(this._seen.has(t)){let n=this._seen.get(t);if(n>=this._maxPromisesPerObject){w&&console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");return}this._seen.set(t,n+1)}else this._seen.set(t,1);this._awaiting.push(s),this._addedCount++,s.finally(()=>{this._resolvedCount++,this._awaiting.splice(this._awaiting.indexOf(s),1)})}}resolveNow(){var e,t;this._resolved||(t=this._resolve)==null||t.call(this,{awaited_count:this._addedCount,resolved_count:this._resolvedCount,cancelled:((e=this._signal)==null?void 0:e.aborted)??!1})}}u(me,"addPromise",(e,t,s,n)=>{n.forEach(r=>{r.add(e,t,s)})});const I=de("debugprogressive"),at=de("noprogressive"),ve=Symbol("Needle:LODSManager"),Oe=Symbol("Needle:LODState"),H=Symbol("Needle:CurrentLOD"),E={mesh_lod:-1,texture_lod:-1};var L,$,X,Le,j,re,xe,K;let ue=(L=class{constructor(e,t){u(this,"renderer");u(this,"context");u(this,"projectionScreenMatrix",new y.Matrix4);u(this,"targetTriangleDensity",2e5);u(this,"skinnedMeshAutoUpdateBoundsInterval",30);u(this,"updateInterval","auto");Y(this,$,1);u(this,"pause",!1);u(this,"manual",!1);u(this,"_newPromiseGroups",[]);u(this,"_promiseGroupIds",0);u(this,"_lodchangedlisteners",[]);Y(this,X);Y(this,Le,new y.Clock);Y(this,j,0);Y(this,re,0);Y(this,xe,0);Y(this,K,0);u(this,"_fpsBuffer",[60,60,60,60,60]);u(this,"_sphere",new y.Sphere);u(this,"_tempBox",new y.Box3);u(this,"_tempBox2",new y.Box3);u(this,"tempMatrix",new y.Matrix4);u(this,"_tempWorldPosition",new y.Vector3);u(this,"_tempBoxSize",new y.Vector3);u(this,"_tempBox2Size",new y.Vector3);this.renderer=e,this.context={...t}}static getObjectLODState(e){return e[Oe]}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[ve])return console.debug("[gltf-progressive] LODsManager already exists for this renderer"),e[ve];const s=new L(e,{engine:"unknown",...t});return e[ve]=s,s}get plugins(){return Q}awaitLoading(e){const t=this._promiseGroupIds++,s=new me(x(this,j),{...e});this._newPromiseGroups.push(s);const n=performance.now();return s.ready.finally(()=>{const r=this._newPromiseGroups.indexOf(s);r>=0&&(this._newPromiseGroups.splice(r,1),et()&&performance.measure("LODsManager:awaitLoading",{start:n,detail:{id:t,name:e==null?void 0:e.name,awaited:s.awaitedCount,resolved:s.resolvedCount}}))}),s.ready}_postprocessPromiseGroups(){if(this._newPromiseGroups.length!==0)for(let e=this._newPromiseGroups.length-1;e>=0;e--)this._newPromiseGroups[e].update(x(this,j))}addEventListener(e,t){e==="changed"&&this._lodchangedlisteners.push(t)}removeEventListener(e,t){if(e==="changed"){const s=this._lodchangedlisteners.indexOf(t);s>=0&&this._lodchangedlisteners.splice(s,1)}}enable(){if(x(this,X))return;console.debug("[gltf-progressive] Enabling LODsManager for renderer");let e=0;z(this,X,this.renderer.render);const t=this;Te(this.renderer),this.renderer.render=function(s,n){const r=t.renderer.getRenderTarget();(r==null||"isXRRenderTarget"in r&&r.isXRRenderTarget)&&(e=0,z(t,j,x(t,j)+1),z(t,re,x(t,Le).getDelta()),z(t,xe,x(t,xe)+x(t,re)),t._fpsBuffer.shift(),t._fpsBuffer.push(1/x(t,re)),z(t,K,t._fpsBuffer.reduce((a,l)=>a+l)/t._fpsBuffer.length),I&&x(t,j)%200===0&&console.log("FPS",Math.round(x(t,K)),"Interval:",x(t,$)));const i=e++;x(t,X).call(this,s,n),t.onAfterRender(s,n,i)}}disable(){x(this,X)&&(console.debug("[gltf-progressive] Disabling LODsManager for renderer"),this.renderer.render=x(this,X),z(this,X,void 0))}update(e,t){this.internalUpdate(e,t)}onAfterRender(e,t,s){if(this.pause)return;const r=this.renderer.renderLists.get(e,0).opaque;let i=!0;if(r.length===1){const a=r[0].material;(a.name==="EffectMaterial"||a.name==="CopyShader")&&(i=!1)}if((t.parent&&t.parent.type==="CubeCamera"||s>=1&&t.type==="OrthographicCamera")&&(i=!1),i){if(at||(this.updateInterval==="auto"?x(this,K)<40&&x(this,$)<10?(z(this,$,x(this,$)+1),I&&console.warn("↓ Reducing LOD updates",x(this,$),x(this,K).toFixed(0))):x(this,K)>=60&&x(this,$)>1&&(z(this,$,x(this,$)-1),I&&console.warn("↑ Increasing LOD updates",x(this,$),x(this,K).toFixed(0))):z(this,$,this.updateInterval),x(this,$)>0&&x(this,j)%x(this,$)!=0))return;this.internalUpdate(e,t),this._postprocessPromiseGroups()}}internalUpdate(e,t){var l,c;const s=this.renderer.renderLists.get(e,0),n=s.opaque;this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);const r=this.targetTriangleDensity;for(const d of n){if(d.material&&(((l=d.geometry)==null?void 0:l.type)==="BoxGeometry"||((c=d.geometry)==null?void 0:c.type)==="BufferGeometry")&&(d.material.name==="SphericalGaussianBlur"||d.material.name=="BackgroundCubeMaterial"||d.material.name==="CubemapFromEquirect"||d.material.name==="EquirectangularToCubeUV")){I&&(d.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]||(d.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]=!0,console.warn("Ignoring skybox or BLIT object",d,d.material.name,d.material.type)));continue}switch(d.material.type){case"LineBasicMaterial":case"LineDashedMaterial":case"PointsMaterial":case"ShadowMaterial":case"MeshDistanceMaterial":case"MeshDepthMaterial":continue}if(I==="color"&&d.material&&!d.object.progressive_debug_color){d.object.progressive_debug_color=!0;const f=Math.random()*16777215,v=new y.MeshStandardMaterial({color:f});d.object.material=v}const p=d.object;(p instanceof y.Mesh||p.isMesh)&&this.updateLODs(e,t,p,r)}const i=s.transparent;for(const d of i){const p=d.object;(p instanceof y.Mesh||p.isMesh)&&this.updateLODs(e,t,p,r)}const a=s.transmissive;for(const d of a){const p=d.object;(p instanceof y.Mesh||p.isMesh)&&this.updateLODs(e,t,p,r)}}updateLODs(e,t,s,n){var a,l;s.userData||(s.userData={});let r=s[Oe];if(r||(r=new lt,s[Oe]=r),r.frames++<2)return;for(const c of Q)(a=c.onBeforeUpdateLOD)==null||a.call(c,this.renderer,e,t,s);const i=L.overrideGlobalLodLevel!==void 0?L.overrideGlobalLodLevel:ee;i>=0?(E.mesh_lod=i,E.texture_lod=i):(this.calculateLodLevel(t,s,r,n,E),E.mesh_lod=Math.round(E.mesh_lod),E.texture_lod=Math.round(E.texture_lod)),E.mesh_lod>=0&&this.loadProgressiveMeshes(s,E.mesh_lod),s.material&&E.texture_lod>=0&&this.loadProgressiveTextures(s.material,E.texture_lod),w&&s.material&&!s.isGizmo&&Ne(s.material);for(const c of Q)(l=c.onAfterUpdatedLOD)==null||l.call(c,this.renderer,e,t,s,E);r.lastLodLevel_Mesh=E.mesh_lod,r.lastLodLevel_Texture=E.texture_lod}loadProgressiveTextures(e,t){if(!e)return;if(Array.isArray(e)){for(const r of e)this.loadProgressiveTextures(r,t);return}let s=!1;(e[H]===void 0||t<e[H])&&(s=!0);const n=e["DEBUG:LOD"];if(n!=null&&(s=e[H]!=n,t=n),s){e[H]=t;const r=F.assignTextureLOD(e,t).then(i=>{this._lodchangedlisteners.forEach(a=>a({type:"texture",level:t,object:e}))});me.addPromise("texture",e,r,this._newPromiseGroups)}}loadProgressiveMeshes(e,t){if(!e)return Promise.resolve(null);let s=e[H]!==t;const n=e["DEBUG:LOD"];if(n!=null&&(s=e[H]!=n,t=n),s){e[H]=t;const r=e.geometry,i=F.assignMeshLOD(e,t).then(a=>(a&&e[H]==t&&r!=e.geometry&&this._lodchangedlisteners.forEach(l=>l({type:"mesh",level:t,object:e})),a));return me.addPromise("mesh",e,i,this._newPromiseGroups),i}return Promise.resolve(null)}static isInside(e,t){const s=e.min,n=e.max,r=(s.x+n.x)*.5,i=(s.y+n.y)*.5;return this._tempPtInside.set(r,i,s.z).applyMatrix4(t).z<0}calculateLodLevel(e,t,s,n,r){var S,R,J;if(!t){r.mesh_lod=-1,r.texture_lod=-1;return}if(!e){r.mesh_lod=-1,r.texture_lod=-1;return}let a=10+1,l=!1;if(I&&t["DEBUG:LOD"]!=null)return t["DEBUG:LOD"];const c=(S=F.getMeshLODExtension(t.geometry))==null?void 0:S.lods,d=F.getPrimitiveIndex(t.geometry),p=c&&c.length>0,f=F.getMaterialMinMaxLODsCount(t.material),v=(f==null?void 0:f.min_count)!=1/0&&f.min_count>0&&f.max_count>0;if(!p&&!v){r.mesh_lod=0,r.texture_lod=0;return}p||(l=!0,a=0);const b=this.renderer.domElement.clientHeight||this.renderer.domElement.height;let T=t.geometry.boundingBox;if(t.type==="SkinnedMesh"){const h=t;if(!h.boundingBox)h.computeBoundingBox();else if(this.skinnedMeshAutoUpdateBoundsInterval>0){if(!h[L.$skinnedMeshBoundsOffset]){const A=L.skinnedMeshBoundsFrameOffsetCounter++;h[L.$skinnedMeshBoundsOffset]=A}const _=h[L.$skinnedMeshBoundsOffset];if((s.frames+_)%this.skinnedMeshAutoUpdateBoundsInterval===0){const A=ie(h),N=h.geometry;A&&(h.geometry=A),h.computeBoundingBox(),h.geometry=N}}T=h.boundingBox}if(T){const h=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 g=e.getWorldPosition(this._tempWorldPosition);if(this._sphere.containsPoint(g)){r.mesh_lod=0,r.texture_lod=0;return}}if(this._tempBox.copy(T),this._tempBox.applyMatrix4(t.matrixWorld),h.isPerspectiveCamera&&L.isInside(this._tempBox,this.projectionScreenMatrix)){r.mesh_lod=0,r.texture_lod=0;return}if(this._tempBox.applyMatrix4(this.projectionScreenMatrix),this.renderer.xr.enabled&&h.isPerspectiveCamera&&h.fov>70){const g=this._tempBox.min,D=this._tempBox.max;let G=g.x,B=g.y,V=D.x,ne=D.y;const ce=2,we=1.5,fe=(g.x+D.x)*.5,he=(g.y+D.y)*.5;G=(G-fe)*ce+fe,B=(B-he)*ce+he,V=(V-fe)*ce+fe,ne=(ne-he)*ce+he;const qe=G<0&&V>0?0:Math.min(Math.abs(g.x),Math.abs(D.x)),We=B<0&&ne>0?0:Math.min(Math.abs(g.y),Math.abs(D.y)),_e=Math.max(qe,We);s.lastCentrality=(we-_e)*(we-_e)*(we-_e)}else s.lastCentrality=1;const _=this._tempBox.getSize(this._tempBoxSize);_.multiplyScalar(.5),screen.availHeight>0&&b>0&&_.multiplyScalar(b/screen.availHeight),e.isPerspectiveCamera?_.x*=e.aspect:e.isOrthographicCamera;const A=e.matrixWorldInverse,N=this._tempBox2;N.copy(T),N.applyMatrix4(t.matrixWorld),N.applyMatrix4(A);const P=N.getSize(this._tempBox2Size),Z=Math.max(P.x,P.y);if(Math.max(_.x,_.y)!=0&&Z!=0&&(_.z=P.z/Math.max(P.x,P.y)*Math.max(_.x,_.y)),s.lastScreenCoverage=Math.max(_.x,_.y,_.z),s.lastScreenspaceVolume.copy(_),s.lastScreenCoverage*=s.lastCentrality,I&&L.debugDrawLine){const g=this.tempMatrix.copy(this.projectionScreenMatrix);g.invert();const D=L.corner0,G=L.corner1,B=L.corner2,V=L.corner3;D.copy(this._tempBox.min),G.copy(this._tempBox.max),G.x=D.x,B.copy(this._tempBox.max),B.y=D.y,V.copy(this._tempBox.max);const ne=(D.z+V.z)*.5;D.z=G.z=B.z=V.z=ne,D.applyMatrix4(g),G.applyMatrix4(g),B.applyMatrix4(g),V.applyMatrix4(g),L.debugDrawLine(D,G,255),L.debugDrawLine(D,B,255),L.debugDrawLine(G,V,255),L.debugDrawLine(B,V,255)}let O=999;if(c&&s.lastScreenCoverage>0)for(let g=0;g<c.length;g++){const D=c[g];if((((R=D.densities)==null?void 0:R[d])||D.density||1e-5)/s.lastScreenCoverage<n){O=g;break}}O<a&&(a=O,l=!0)}if(l?r.mesh_lod=a:r.mesh_lod=s.lastLodLevel_Mesh,I&&r.mesh_lod!=s.lastLodLevel_Mesh){const _=c==null?void 0:c[r.mesh_lod];_&&console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (${_.density.toFixed(0)}) - ${t.name}`)}if(v){const h="saveData"in globalThis.navigator&&globalThis.navigator.saveData===!0;if(s.lastLodLevel_Texture<0){if(r.texture_lod=f.max_count-1,I){const _=f.lods[f.max_count-1];I&&console.log(`First Texture LOD ${r.texture_lod} (${_.max_height}px) - ${t.name}`)}}else{const _=s.lastScreenspaceVolume.x+s.lastScreenspaceVolume.y+s.lastScreenspaceVolume.z;let A=s.lastScreenCoverage*4;((J=this.context)==null?void 0:J.engine)==="model-viewer"&&(A*=1.5);const P=b/window.devicePixelRatio*A;let Z=!1;for(let C=f.lods.length-1;C>=0;C--){const O=f.lods[C];if(!(h&&O.max_height>=2048)&&!(Ze()&&O.max_height>4096)&&(O.max_height>P||!Z&&C===0)){if(Z=!0,r.texture_lod=C,r.texture_lod<s.lastLodLevel_Texture){const m=O.max_height;I&&console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${m}px
|
|
6
|
+
Screensize: ${P.toFixed(0)}px, Coverage: ${(100*s.lastScreenCoverage).toFixed(2)}%, Volume ${_.toFixed(1)}
|
|
7
|
+
${t.name}`)}break}}}}else r.texture_lod=0}},$=new WeakMap,X=new WeakMap,Le=new WeakMap,j=new WeakMap,re=new WeakMap,xe=new WeakMap,K=new WeakMap,u(L,"debugDrawLine"),u(L,"overrideGlobalLodLevel"),u(L,"corner0",new y.Vector3),u(L,"corner1",new y.Vector3),u(L,"corner2",new y.Vector3),u(L,"corner3",new y.Vector3),u(L,"_tempPtInside",new y.Vector3),u(L,"skinnedMeshBoundsFrameOffsetCounter",0),u(L,"$skinnedMeshBoundsOffset",Symbol("gltf-progressive-skinnedMeshBoundsOffset")),L);class lt{constructor(){u(this,"frames",0);u(this,"lastLodLevel_Mesh",-1);u(this,"lastLodLevel_Texture",-1);u(this,"lastScreenCoverage",0);u(this,"lastScreenspaceVolume",new y.Vector3);u(this,"lastCentrality",0)}}const Ee=Symbol("NEEDLE_mesh_lod"),ge=Symbol("NEEDLE_texture_lod");let le=null;function Ve(){const o=ut();o&&(o.mapURLs(function(e){return $e(),e}),$e(),le==null||le.disconnect(),le=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(s=>{s instanceof HTMLElement&&s.tagName.toLowerCase()==="model-viewer"&&ze(s)})})}),le.observe(document,{childList:!0,subtree:!0}))}function ut(){if(typeof customElements>"u")return null;const o=customElements.get("model-viewer");return o||(customElements.whenDefined("model-viewer").then(()=>{console.debug("[gltf-progressive] model-viewer defined"),Ve()}),null)}function $e(){if(typeof document>"u")return;document.querySelectorAll("model-viewer").forEach(e=>{ze(e)})}const ke=new WeakSet;let dt=0;function ze(o){if(!o||ke.has(o))return null;ke.add(o),console.debug("[gltf-progressive] found new model-viewer..."+ ++dt+`
|
|
8
|
+
`,o.getAttribute("src"));let e=null,t=null,s=null;for(let n=o;n!=null;n=Object.getPrototypeOf(n)){const r=Object.getOwnPropertySymbols(n),i=r.find(c=>c.toString()=="Symbol(renderer)"),a=r.find(c=>c.toString()=="Symbol(scene)"),l=r.find(c=>c.toString()=="Symbol(needsRender)");!e&&i!=null&&(e=o[i].threeRenderer),!t&&a!=null&&(t=o[a]),!s&&l!=null&&(s=o[l])}if(e&&t){let n=function(){if(s){let i=0,a=setInterval(()=>{if(i++>5){clearInterval(a);return}s==null||s.call(o)},300)}};console.debug("[gltf-progressive] setup model-viewer");const r=ue.get(e,{engine:"model-viewer"});return ue.addPlugin(new ct),r.enable(),r.addEventListener("changed",()=>{s==null||s.call(o)}),o.addEventListener("model-visibility",i=>{i.detail.visible&&(s==null||s.call(o))}),o.addEventListener("load",()=>{n()}),()=>{r.disable()}}return null}class ct{constructor(){u(this,"_didWarnAboutMissingUrl",!1)}onBeforeUpdateLOD(e,t,s,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[ge]==!0)return;t[ge]=!0;const s=this.tryGetCurrentGLTF(e),n=this.tryGetCurrentModelViewer(e),r=this.getUrl(n);if(r&&s&&t.material){let i=function(l){var d,p,f;if(l[ge]==!0)return;l[ge]=!0,l.userData&&(l.userData.LOD=-1);const c=Object.keys(l);for(let v=0;v<c.length;v++){const b=c[v],T=l[b];if((T==null?void 0:T.isTexture)===!0){const S=(p=(d=T.userData)==null?void 0:d.associations)==null?void 0:p.textures;if(S==null)continue;const R=s.parser.json.textures[S];if(!R){console.warn("Texture data not found for texture index "+S);continue}if((f=R==null?void 0:R.extensions)!=null&&f[W]){const J=R.extensions[W];J&&r&&F.registerTexture(r,T,J.lods.length,S,J)}}}};const a=t.material;if(Array.isArray(a))for(const l of a)i(l);else i(a)}}tryParseMeshLOD(e,t){var i,a;if(t[Ee]==!0)return;t[Ee]=!0;const s=this.tryGetCurrentModelViewer(e),n=this.getUrl(s);if(!n)return;const r=(a=(i=t.userData)==null?void 0:i.gltfExtensions)==null?void 0:a[W];if(r&&n){const l=t.uuid;F.registerMesh(n,l,t,0,r.lods.length,r)}}}function ft(o,e,t,s){Te(e),Ae(t),Ce(t,{progressive:!0,...s==null?void 0:s.hints}),t.register(r=>new F(r,o));const n=ue.get(e);return(s==null?void 0:s.enableLODsManager)!==!1&&n.enable(),n}Ve();if(!st){const o={gltfProgressive:{useNeedleProgressive:ft,LODsManager:ue,configureLoader:Ce,getRaycastMesh:ie,useRaycastMeshes:it}};if(!globalThis.Needle)globalThis.Needle=o;else for(const e in o)globalThis.Needle[e]=o[e]}exports.LODsManager=ue;exports.NEEDLE_progressive=F;exports.addDracoAndKTX2Loaders=Ae;exports.configureLoader=Ce;exports.createLoaders=Te;exports.getRaycastMesh=ie;exports.setDracoDecoderLocation=Ie;exports.setKTX2TranscoderLocation=Fe;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var Ke=Object.defineProperty,Ee=s=>{throw TypeError(s)},He=(s,e,t)=>e in s?Ke(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,u=(s,e,t)=>He(s,typeof e!="symbol"?e+"":e,t),Ce=(s,e,t)=>e.has(s)||Ee("Cannot "+t),_=(s,e,t)=>(Ce(s,e,"read from private field"),t?t.call(s):e.get(s)),Z=(s,e,t)=>e.has(s)?Ee("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),N=(s,e,t,n)=>(Ce(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);import{BufferGeometry as de,Mesh as J,Texture as re,TextureLoader as Qe,Matrix4 as ke,Clock as Ye,MeshStandardMaterial as Ze,Sphere as Je,Box3 as Be,Vector3 as U}from"./three-DuDKwKB8.min.js";import{DRACOLoader as et,KTX2Loader as tt,MeshoptDecoder as st,GLTFLoader as we}from"./three-examples-BMOhDaYR.min.js";const rt="";globalThis.GLTF_PROGRESSIVE_VERSION=rt,console.debug("[gltf-progressive] version -");let F="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",te="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";const nt=F,ot=te,Ie=new URL(F+"draco_decoder.js");Ie.searchParams.append("range","true"),fetch(Ie,{method:"GET",headers:{Range:"bytes=0-1"}}).catch(s=>{console.debug(`Failed to fetch remote Draco decoder from ${F} (offline: ${typeof navigator<"u"?navigator.onLine:"unknown"})`),F===nt&&Ge("./include/draco/"),te===ot&&$e("./include/ktx2/")}).finally(()=>{je()});function Ge(s){F=s,C&&C[_e]!=F?(console.debug("Updating Draco decoder path to "+s),C[_e]=F,C.setDecoderPath(F),C.preload()):console.debug("Setting Draco decoder path to "+s)}function $e(s){te=s,G&&G.transcoderPath!=te?(console.debug("Updating KTX2 transcoder path to "+s),G.setTranscoderPath(te),G.init()):console.debug("Setting KTX2 transcoder path to "+s)}const _e=Symbol("dracoDecoderPath");let C,ce,G;function je(){C||(C=new et,C[_e]=F,C.setDecoderPath(F),C.setDecoderConfig({type:"js"}),C.preload()),G||(G=new tt,G.setTranscoderPath(te),G.init()),ce||(ce=st)}function Le(s){return je(),s?G.detectSupport(s):s!==null&&console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"),{dracoLoader:C,ktx2Loader:G,meshoptDecoder:ce}}function Me(s){s.dracoLoader||s.setDRACOLoader(C),s.ktx2Loader||s.setKTX2Loader(G),s.meshoptDecoder||s.setMeshoptDecoder(ce)}const De=new WeakMap;function be(s,e){let t=De.get(s);t?t=Object.assign(t,e):t=e,De.set(s,t)}const Re=we.prototype.load;function it(...s){const e=De.get(this);let t=s[0];const n=new URL(t,window.location.href);if(n.hostname.endsWith("needle.tools")){const r=e?.progressive!==void 0?e.progressive:!0,i=e!=null&&e.usecase?e.usecase:"default";r?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${i}`:this.requestHeader.Accept=`*/*;usecase=${i}`,t=n.toString()}return s[0]=t,Re?.call(this,...s)}we.prototype.load=it,ne("debugprogressive");function ne(s){if(typeof window>"u")return!1;const e=new URL(window.location.href).searchParams.get(s);return e==null||e==="0"||e==="false"?!1:e===""?!0:e}function at(s,e){if(e===void 0||e.startsWith("./")||e.startsWith("http")||s===void 0)return e;const t=s.lastIndexOf("/");if(t>=0){const n=s.substring(0,t+1);for(;n.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return n+e}return e}let he;function lt(){return he!==void 0||(he=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),ne("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",he)),he}function ut(){if(typeof window>"u")return!1;const s=new URL(window.location.href),e=s.hostname==="localhost"||/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(s.hostname);return s.hostname==="127.0.0.1"||e}class dt{constructor(e=100,t={}){u(this,"_running",new Map),u(this,"_queue",[]),u(this,"debug",!1),u(this,"tick",()=>{this.internalUpdate(),setTimeout(this.tick,10)}),this.maxConcurrent=e,this.debug=t.debug??!1,window.requestAnimationFrame(this.tick)}slot(e){return this.debug&&console.debug(`[PromiseQueue]: Requesting slot for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`),new Promise(t=>{this._queue.push({key:e,resolve:t})})}add(e,t){this._running.has(e)||(this._running.set(e,t),t.finally(()=>{this._running.delete(e),this.debug&&console.debug(`[PromiseQueue]: Promise for key ${e} finished, running: ${this._running.size}, waiting: ${this._queue.length}`)}),this.debug&&console.debug(`[PromiseQueue]: Adding promise for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`))}internalUpdate(){const e=this.maxConcurrent-this._running.size;for(let t=0;t<e&&this._queue.length>0;t++){this.debug&&console.debug(`[PromiseQueue]: Running ${this._running.size} promises, waiting for ${this._queue.length} more.`);const{key:n,resolve:r}=this._queue.shift();r({use:i=>this.add(n,i)})}}}const ct=typeof window>"u"&&typeof document>"u",Oe=Symbol("needle:raycast-mesh");function se(s){return s?.[Oe]instanceof de?s[Oe]:null}function ht(s,e){if((s.type==="Mesh"||s.type==="SkinnedMesh")&&!se(s)){const t=ft(e);t.userData={isRaycastMesh:!0},s[Oe]=t}}function gt(s=!0){if(s){if(oe)return;const e=oe=J.prototype.raycast;J.prototype.raycast=function(t,n){const r=this,i=se(r);let o;i&&r.isMesh&&(o=r.geometry,r.geometry=i),e.call(this,t,n),o&&(r.geometry=o)}}else{if(!oe)return;J.prototype.raycast=oe,oe=null}}let oe=null;function ft(s){const e=new de;for(const t in s.attributes)e.setAttribute(t,s.getAttribute(t));return e.setIndex(s.getIndex()),e}const V=new Array,x=ne("debugprogressive");let ge,ee=-1;if(x){let s=function(){ee+=1,ee>=e&&(ee=-1),console.log(`Toggle LOD level [${ee}]`)},e=6;window.addEventListener("keyup",t=>{t.key==="p"&&s(),t.key==="w"&&(ge=!ge,console.log(`Toggle wireframe [${ge}]`));const n=parseInt(t.key);!isNaN(n)&&n>=0&&(ee=n,console.log(`Set LOD level to [${ee}]`))})}function Fe(s){if(x)if(Array.isArray(s))for(const e of s)Fe(e);else s&&"wireframe"in s&&(s.wireframe=ge===!0)}const W="NEEDLE_progressive",Pe=Symbol("needle-progressive-texture"),T=class j{constructor(e,t){u(this,"parser"),u(this,"url"),u(this,"_isLoadingMesh"),u(this,"loadMesh",n=>{var r,i;if(this._isLoadingMesh)return null;const o=(i=(r=this.parser.json.meshes[n])==null?void 0:r.extensions)==null?void 0:i[W];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,0,o),a})):null}),x&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return W}static getMeshLODExtension(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getPrimitiveIndex(e){var t;return((t=this.getAssignedLODInformation(e))==null?void 0:t.index)??-1}static getMaterialMinMaxLODsCount(e,t){const n=this,r="LODS:minmax",i=e[r];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[r]=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 d=a.uniforms[l].value;d?.isTexture===!0&&o(d,t)}}else if(e.isMaterial)for(const a of Object.keys(e)){const l=e[a];l?.isTexture===!0&&o(l,t)}return e[r]=t,t;function o(a,l){const d=n.getAssignedLODInformation(a);if(d){const c=n.lodInfos.get(d.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 M=0;M<c.lods.length;M++){const w=c.lods[M];w.width&&(l.lods[M]=l.lods[M]||{min_height:1/0,max_height:0},l.lods[M].min_height=Math.min(l.lods[M].min_height,w.height),l.lods[M].max_height=Math.max(l.lods[M].max_height,w.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 r,i;if(e.isMesh?r=e.geometry:(e.isBufferGeometry||e.isTexture)&&(r=e),r&&(n=r?.userData)!=null&&n.LODS){const o=r.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 r=e.geometry,i=this.getAssignedLODInformation(r);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(r,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&&r!=o&&(o?.isBufferGeometry?e.geometry=o: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 n=e;if(Array.isArray(n.material)){const r=new Array;for(const i of n.material){const o=this.assignTextureLOD(i,t);r.push(o)}return Promise.all(r).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,r=[],i=new Array;if(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 d=this.assignTextureLODForSlot(l,t,n,a).then(c=>(c&&o.uniforms[a].value!=c&&(o.uniforms[a].value=c,o.uniformsNeedUpdate=!0),c));r.push(d),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);r.push(l),i.push(o)}}return Promise.all(r).then(o=>{const a=new Array;for(let l=0;l<o.length;l++){const d=o[l],c=i[l];d&&d.isTexture===!0?a.push({material:n,slot:c,texture:d,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,r){return e?.isTexture!==!0?Promise.resolve(null):r==="glyphMap"?Promise.resolve(e):j.getOrLoadLOD(e,t).then(i=>{if(Array.isArray(i))return null;if(i?.isTexture===!0){if(i!=e&&n&&r){const o=n[r];if(o&&!x){const a=this.getAssignedLODInformation(o);if(a&&a?.level<t)return x==="verbose"&&console.warn("Assigned texture level is already higher: ",a.level,t,n,o,i),null}n[r]=i}return i}else x=="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 x&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((r,i)=>{var o;if(r!=null&&r.extensions){const a=r?.extensions[W];if(a){if(!a.lods){x&&console.warn("Texture has no LODs",a);return}let l=!1;for(const d of this.parser.associations.keys())if(d.isTexture===!0){const c=this.parser.associations.get(d);c?.textures===i&&(l=!0,j.registerTexture(this.url,d,(o=a.lods)==null?void 0:o.length,i,a))}l||this.parser.getDependency("texture",i).then(d=>{var c;d&&j.registerTexture(this.url,d,(c=a.lods)==null?void 0:c.length,i,a)})}}}),(n=this.parser.json.meshes)==null||n.forEach((r,i)=>{if(r!=null&&r.extensions){const o=r?.extensions[W];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,r,i,o;const a=x=="verbose",l=e.userData.LODS;if(!l)return null;const d=l?.key;let c;if(e.isTexture===!0){const M=e;M.source&&M.source[Pe]&&(c=M.source[Pe])}if(c||(c=j.lodInfos.get(d)),c){if(t>0){let f=!1;const R=Array.isArray(c.lods);if(R&&t>=c.lods.length?f=!0:R||(f=!0),f)return this.lowresCache.get(d)}const M=Array.isArray(c.lods)?(n=c.lods[t])==null?void 0:n.path:c.lods;if(!M)return x&&!c["missing:uri"]&&(c["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,c)),null;const w=at(l.url,M);if(w.endsWith(".glb")||w.endsWith(".gltf")){if(!c.guid)return console.warn("missing pointer for glb/gltf texture",c),null;const f=w+"_"+c.guid,R=this.previouslyLoaded.get(f);if(R!==void 0){a&&console.log(`LOD ${t} was already loading/loaded: ${f}`);let h=await R.catch(S=>(console.error(`Error loading LOD ${t} from ${w}
|
|
2
|
+
`,S),null)),P=!1;if(h==null||(h instanceof re&&e instanceof re?(r=h.image)!=null&&r.data||(i=h.source)!=null&&i.data?h=this.copySettings(e,h):(P=!0,this.previouslyLoaded.delete(f)):h instanceof de&&e instanceof de&&((o=h.attributes.position)!=null&&o.array||(P=!0,this.previouslyLoaded.delete(f)))),!P)return h}const k=await this.queue.slot(w);if(!k.use)return x&&console.log(`LOD ${t} was aborted: ${w}`),null;const D=c,p=new Promise(async(h,P)=>{const S=new we;Me(S),x&&(await new Promise(m=>setTimeout(m,1e3)),a&&console.warn("Start loading (delayed) "+w,D.guid));let B=w;if(D&&Array.isArray(D.lods)){const m=D.lods[t];m.hash&&(B+="?v="+m.hash)}const b=await S.loadAsync(B).catch(m=>(console.error(`Error loading LOD ${t} from ${w}
|
|
3
|
+
`,m),h(null)));if(!b)return h(null);const I=b.parser;a&&console.log("Loading finished "+w,D.guid);let v=0;if(b.parser.json.textures){let m=!1;for(const g of b.parser.json.textures){if(g!=null&&g.extensions){const L=g?.extensions[W];if(L!=null&&L.guid&&L.guid===D.guid){m=!0;break}}v++}if(m){let g=await I.getDependency("texture",v);return g&&j.assignLODInformation(l.url,g,d,t,void 0),a&&console.log('change "'+e.name+'" \u2192 "'+g.name+'"',w,v,g,f),e instanceof re&&(g=this.copySettings(e,g)),g&&(g.guid=D.guid),h(g)}else x&&console.warn("Could not find texture with guid",D.guid,b.parser.json)}if(v=0,b.parser.json.meshes){let m=!1;for(const g of b.parser.json.meshes){if(g!=null&&g.extensions){const L=g?.extensions[W];if(L!=null&&L.guid&&L.guid===D.guid){m=!0;break}}v++}if(m){const g=await I.getDependency("mesh",v);if(a&&console.log(`Loaded Mesh "${g.name}"`,w,v,g,f),g.isMesh===!0){const L=g.geometry;return j.assignLODInformation(l.url,L,d,t,0),h(L)}else{const L=new Array;for(let O=0;O<g.children.length;O++){const q=g.children[O];if(q.isMesh===!0){const Y=q.geometry;j.assignLODInformation(l.url,Y,d,t,O),L.push(Y)}}return h(L)}}else x&&console.warn("Could not find mesh with guid",D.guid,b.parser.json)}return h(null)});return this.previouslyLoaded.set(f,p),k.use(p),await p}else if(e instanceof re){a&&console.log("Load texture from uri: "+w);const f=await new Qe().loadAsync(w);return f?(f.guid=c.guid,f.flipY=!1,f.needsUpdate=!0,f.colorSpace=e.colorSpace,a&&console.log(c,f)):x&&console.warn("failed loading",w),f}}else x&&console.warn(`Can not load LOD ${t}: no LOD info found for "${d}" ${e.name}`,e.type);return null}static assignLODInformation(e,t,n,r,i){if(!t)return;t.userData||(t.userData={});const o=new mt(e,n,r,i);t.userData.LODS=o}static getAssignedLODInformation(e){var t;return((t=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}};u(T,"registerTexture",(s,e,t,n,r)=>{if(x&&console.log("> Progressive: register texture",n,e.name,e.uuid,e,r),!e){x&&console.error("gltf-progressive: Register texture without texture");return}e.source&&(e.source[Pe]=r);const i=r.guid;T.assignLODInformation(s,e,i,t,n),T.lodInfos.set(i,r),T.lowresCache.set(i,e)}),u(T,"registerMesh",(s,e,t,n,r,i)=>{var o;const a=t.geometry;if(!a){x&&console.warn("gltf-progressive: Register mesh without geometry");return}a.userData||(a.userData={}),x&&console.log("> Progressive: register mesh "+t.name,{index:r,uuid:t.uuid},i,t),T.assignLODInformation(s,a,e,n,r),T.lodInfos.set(e,i);let l=T.lowresCache.get(e);l?l.push(t.geometry):l=[t.geometry],T.lowresCache.set(e,l),n>0&&!se(t)&&ht(t,a);for(const d of V)(o=d.onRegisteredNewMesh)==null||o.call(d,t,i)}),u(T,"lodInfos",new Map),u(T,"previouslyLoaded",new Map),u(T,"lowresCache",new Map),u(T,"queue",new dt(100,{debug:x!=!1}));let z=T;class mt{constructor(e,t,n,r){u(this,"url"),u(this,"key"),u(this,"level"),u(this,"index"),this.url=e,this.key=t,this.level=n,r!=null&&(this.index=r)}}class fe{constructor(e,t){u(this,"frame_start"),u(this,"frame_capture_end"),u(this,"ready"),u(this,"_resolve"),u(this,"_signal"),u(this,"_resolved",!1),u(this,"_addedCount",0),u(this,"_resolvedCount",0),u(this,"_awaiting",[]),u(this,"_maxPromisesPerObject",1),u(this,"_currentFrame",0),u(this,"_seen",new WeakMap);var n;const r=Math.max(t.frames??2,2);this.frame_start=e,this.frame_capture_end=e+r,this.ready=new Promise(i=>{this._resolve=i}),this.ready.finally(()=>{this._resolved=!0,this._awaiting.length=0}),this._signal=t.signal,(n=this._signal)==null||n.addEventListener("abort",()=>{this.resolveNow()}),this._maxPromisesPerObject=Math.max(1,t.maxPromisesPerObject??1)}get awaitedCount(){return this._addedCount}get resolvedCount(){return this._resolvedCount}get currentlyAwaiting(){return this._awaiting.length}update(e){var t;this._currentFrame=e,((t=this._signal)!=null&&t.aborted||this._currentFrame>this.frame_capture_end&&this._awaiting.length===0)&&this.resolveNow()}add(e,t,n){if(this._resolved){x&&console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");return}if(!(this._currentFrame>this.frame_capture_end)){if(this._maxPromisesPerObject>=1)if(this._seen.has(t)){let r=this._seen.get(t);if(r>=this._maxPromisesPerObject){x&&console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");return}this._seen.set(t,r+1)}else this._seen.set(t,1);this._awaiting.push(n),this._addedCount++,n.finally(()=>{this._resolvedCount++,this._awaiting.splice(this._awaiting.indexOf(n),1)})}}resolveNow(){var e,t;this._resolved||(t=this._resolve)==null||t.call(this,{awaited_count:this._addedCount,resolved_count:this._resolvedCount,cancelled:((e=this._signal)==null?void 0:e.aborted)??!1})}}u(fe,"addPromise",(s,e,t,n)=>{n.forEach(r=>{r.add(s,e,t)})});const $=ne("debugprogressive"),pt=ne("noprogressive"),Se=Symbol("Needle:LODSManager"),Te=Symbol("Needle:LODState"),X=Symbol("Needle:CurrentLOD"),A={mesh_lod:-1,texture_lod:-1};var y,E,K,Ae,H,ie,me,Q;let ae=(y=class{constructor(s,e){u(this,"renderer"),u(this,"context"),u(this,"projectionScreenMatrix",new ke),u(this,"targetTriangleDensity",2e5),u(this,"skinnedMeshAutoUpdateBoundsInterval",30),u(this,"updateInterval","auto"),Z(this,E,1),u(this,"pause",!1),u(this,"manual",!1),u(this,"_newPromiseGroups",[]),u(this,"_promiseGroupIds",0),u(this,"_lodchangedlisteners",[]),Z(this,K),Z(this,Ae,new Ye),Z(this,H,0),Z(this,ie,0),Z(this,me,0),Z(this,Q,0),u(this,"_fpsBuffer",[60,60,60,60,60]),u(this,"_sphere",new Je),u(this,"_tempBox",new Be),u(this,"_tempBox2",new Be),u(this,"tempMatrix",new ke),u(this,"_tempWorldPosition",new U),u(this,"_tempBoxSize",new U),u(this,"_tempBox2Size",new U),this.renderer=s,this.context={...e}}static getObjectLODState(s){return s[Te]}static addPlugin(s){V.push(s)}static removePlugin(s){const e=V.indexOf(s);e>=0&&V.splice(e,1)}static get(s,e){if(s[Se])return console.debug("[gltf-progressive] LODsManager already exists for this renderer"),s[Se];const t=new y(s,{engine:"unknown",...e});return s[Se]=t,t}get plugins(){return V}awaitLoading(s){const e=this._promiseGroupIds++,t=new fe(_(this,H),{...s});this._newPromiseGroups.push(t);const n=performance.now();return t.ready.finally(()=>{const r=this._newPromiseGroups.indexOf(t);r>=0&&(this._newPromiseGroups.splice(r,1),ut()&&performance.measure("LODsManager:awaitLoading",{start:n,detail:{id:e,name:s?.name,awaited:t.awaitedCount,resolved:t.resolvedCount}}))}),t.ready}_postprocessPromiseGroups(){if(this._newPromiseGroups.length!==0)for(let s=this._newPromiseGroups.length-1;s>=0;s--)this._newPromiseGroups[s].update(_(this,H))}addEventListener(s,e){s==="changed"&&this._lodchangedlisteners.push(e)}removeEventListener(s,e){if(s==="changed"){const t=this._lodchangedlisteners.indexOf(e);t>=0&&this._lodchangedlisteners.splice(t,1)}}enable(){if(_(this,K))return;console.debug("[gltf-progressive] Enabling LODsManager for renderer");let s=0;N(this,K,this.renderer.render);const e=this;Le(this.renderer),this.renderer.render=function(t,n){const r=e.renderer.getRenderTarget();(r==null||"isXRRenderTarget"in r&&r.isXRRenderTarget)&&(s=0,N(e,H,_(e,H)+1),N(e,ie,_(e,Ae).getDelta()),N(e,me,_(e,me)+_(e,ie)),e._fpsBuffer.shift(),e._fpsBuffer.push(1/_(e,ie)),N(e,Q,e._fpsBuffer.reduce((o,a)=>o+a)/e._fpsBuffer.length),$&&_(e,H)%200===0&&console.log("FPS",Math.round(_(e,Q)),"Interval:",_(e,E)));const i=s++;_(e,K).call(this,t,n),e.onAfterRender(t,n,i)}}disable(){_(this,K)&&(console.debug("[gltf-progressive] Disabling LODsManager for renderer"),this.renderer.render=_(this,K),N(this,K,void 0))}update(s,e){this.internalUpdate(s,e)}onAfterRender(s,e,t){if(this.pause)return;const n=this.renderer.renderLists.get(s,0).opaque;let r=!0;if(n.length===1){const i=n[0].material;(i.name==="EffectMaterial"||i.name==="CopyShader")&&(r=!1)}if((e.parent&&e.parent.type==="CubeCamera"||t>=1&&e.type==="OrthographicCamera")&&(r=!1),r){if(pt||(this.updateInterval==="auto"?_(this,Q)<40&&_(this,E)<10?(N(this,E,_(this,E)+1),$&&console.warn("\u2193 Reducing LOD updates",_(this,E),_(this,Q).toFixed(0))):_(this,Q)>=60&&_(this,E)>1&&(N(this,E,_(this,E)-1),$&&console.warn("\u2191 Increasing LOD updates",_(this,E),_(this,Q).toFixed(0))):N(this,E,this.updateInterval),_(this,E)>0&&_(this,H)%_(this,E)!=0))return;this.internalUpdate(s,e),this._postprocessPromiseGroups()}}internalUpdate(s,e){var t,n;const r=this.renderer.renderLists.get(s,0),i=r.opaque;this.projectionScreenMatrix.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse);const o=this.targetTriangleDensity;for(const d of i){if(d.material&&(((t=d.geometry)==null?void 0:t.type)==="BoxGeometry"||((n=d.geometry)==null?void 0:n.type)==="BufferGeometry")&&(d.material.name==="SphericalGaussianBlur"||d.material.name=="BackgroundCubeMaterial"||d.material.name==="CubemapFromEquirect"||d.material.name==="EquirectangularToCubeUV")){$&&(d.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]||(d.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]=!0,console.warn("Ignoring skybox or BLIT object",d,d.material.name,d.material.type)));continue}switch(d.material.type){case"LineBasicMaterial":case"LineDashedMaterial":case"PointsMaterial":case"ShadowMaterial":case"MeshDistanceMaterial":case"MeshDepthMaterial":continue}if($==="color"&&d.material&&!d.object.progressive_debug_color){d.object.progressive_debug_color=!0;const M=Math.random()*16777215,w=new Ze({color:M});d.object.material=w}const c=d.object;(c instanceof J||c.isMesh)&&this.updateLODs(s,e,c,o)}const a=r.transparent;for(const d of a){const c=d.object;(c instanceof J||c.isMesh)&&this.updateLODs(s,e,c,o)}const l=r.transmissive;for(const d of l){const c=d.object;(c instanceof J||c.isMesh)&&this.updateLODs(s,e,c,o)}}updateLODs(s,e,t,n){var r,i;t.userData||(t.userData={});let o=t[Te];if(o||(o=new vt,t[Te]=o),o.frames++<2)return;for(const l of V)(r=l.onBeforeUpdateLOD)==null||r.call(l,this.renderer,s,e,t);const a=y.overrideGlobalLodLevel!==void 0?y.overrideGlobalLodLevel:ee;a>=0?(A.mesh_lod=a,A.texture_lod=a):(this.calculateLodLevel(e,t,o,n,A),A.mesh_lod=Math.round(A.mesh_lod),A.texture_lod=Math.round(A.texture_lod)),A.mesh_lod>=0&&this.loadProgressiveMeshes(t,A.mesh_lod),t.material&&A.texture_lod>=0&&this.loadProgressiveTextures(t.material,A.texture_lod),x&&t.material&&!t.isGizmo&&Fe(t.material);for(const l of V)(i=l.onAfterUpdatedLOD)==null||i.call(l,this.renderer,s,e,t,A);o.lastLodLevel_Mesh=A.mesh_lod,o.lastLodLevel_Texture=A.texture_lod}loadProgressiveTextures(s,e){if(!s)return;if(Array.isArray(s)){for(const r of s)this.loadProgressiveTextures(r,e);return}let t=!1;(s[X]===void 0||e<s[X])&&(t=!0);const n=s["DEBUG:LOD"];if(n!=null&&(t=s[X]!=n,e=n),t){s[X]=e;const r=z.assignTextureLOD(s,e).then(i=>{this._lodchangedlisteners.forEach(o=>o({type:"texture",level:e,object:s}))});fe.addPromise("texture",s,r,this._newPromiseGroups)}}loadProgressiveMeshes(s,e){if(!s)return Promise.resolve(null);let t=s[X]!==e;const n=s["DEBUG:LOD"];if(n!=null&&(t=s[X]!=n,e=n),t){s[X]=e;const r=s.geometry,i=z.assignMeshLOD(s,e).then(o=>(o&&s[X]==e&&r!=s.geometry&&this._lodchangedlisteners.forEach(a=>a({type:"mesh",level:e,object:s})),o));return fe.addPromise("mesh",s,i,this._newPromiseGroups),i}return Promise.resolve(null)}static isInside(s,e){const t=s.min,n=s.max,r=(t.x+n.x)*.5,i=(t.y+n.y)*.5;return this._tempPtInside.set(r,i,t.z).applyMatrix4(e).z<0}calculateLodLevel(s,e,t,n,r){var i,o,a;if(!e){r.mesh_lod=-1,r.texture_lod=-1;return}if(!s){r.mesh_lod=-1,r.texture_lod=-1;return}let l=10+1,d=!1;if($&&e["DEBUG:LOD"]!=null)return e["DEBUG:LOD"];const c=(i=z.getMeshLODExtension(e.geometry))==null?void 0:i.lods,M=z.getPrimitiveIndex(e.geometry),w=c&&c.length>0,f=z.getMaterialMinMaxLODsCount(e.material),R=f?.min_count!=1/0&&f.min_count>0&&f.max_count>0;if(!w&&!R){r.mesh_lod=0,r.texture_lod=0;return}w||(d=!0,l=0);const k=this.renderer.domElement.clientHeight||this.renderer.domElement.height;let D=e.geometry.boundingBox;if(e.type==="SkinnedMesh"){const p=e;if(!p.boundingBox)p.computeBoundingBox();else if(this.skinnedMeshAutoUpdateBoundsInterval>0){if(!p[y.$skinnedMeshBoundsOffset]){const P=y.skinnedMeshBoundsFrameOffsetCounter++;p[y.$skinnedMeshBoundsOffset]=P}const h=p[y.$skinnedMeshBoundsOffset];if((t.frames+h)%this.skinnedMeshAutoUpdateBoundsInterval===0){const P=se(p),S=p.geometry;P&&(p.geometry=P),p.computeBoundingBox(),p.geometry=S}}D=p.boundingBox}if(D){const p=s;if(e.geometry.attributes.color&&e.geometry.attributes.color.count<100&&e.geometry.boundingSphere){this._sphere.copy(e.geometry.boundingSphere),this._sphere.applyMatrix4(e.matrixWorld);const v=s.getWorldPosition(this._tempWorldPosition);if(this._sphere.containsPoint(v)){r.mesh_lod=0,r.texture_lod=0;return}}if(this._tempBox.copy(D),this._tempBox.applyMatrix4(e.matrixWorld),p.isPerspectiveCamera&&y.isInside(this._tempBox,this.projectionScreenMatrix)){r.mesh_lod=0,r.texture_lod=0;return}if(this._tempBox.applyMatrix4(this.projectionScreenMatrix),this.renderer.xr.enabled&&p.isPerspectiveCamera&&p.fov>70){const v=this._tempBox.min,m=this._tempBox.max;let g=v.x,L=v.y,O=m.x,q=m.y;const Y=2,xe=1.5,le=(v.x+m.x)*.5,ue=(v.y+m.y)*.5;g=(g-le)*Y+le,L=(L-ue)*Y+ue,O=(O-le)*Y+le,q=(q-ue)*Y+ue;const Ve=g<0&&O>0?0:Math.min(Math.abs(v.x),Math.abs(m.x)),Xe=L<0&&q>0?0:Math.min(Math.abs(v.y),Math.abs(m.y)),ye=Math.max(Ve,Xe);t.lastCentrality=(xe-ye)*(xe-ye)*(xe-ye)}else t.lastCentrality=1;const h=this._tempBox.getSize(this._tempBoxSize);h.multiplyScalar(.5),screen.availHeight>0&&k>0&&h.multiplyScalar(k/screen.availHeight),s.isPerspectiveCamera?h.x*=s.aspect:s.isOrthographicCamera;const P=s.matrixWorldInverse,S=this._tempBox2;S.copy(D),S.applyMatrix4(e.matrixWorld),S.applyMatrix4(P);const B=S.getSize(this._tempBox2Size),b=Math.max(B.x,B.y);if(Math.max(h.x,h.y)!=0&&b!=0&&(h.z=B.z/Math.max(B.x,B.y)*Math.max(h.x,h.y)),t.lastScreenCoverage=Math.max(h.x,h.y,h.z),t.lastScreenspaceVolume.copy(h),t.lastScreenCoverage*=t.lastCentrality,$&&y.debugDrawLine){const v=this.tempMatrix.copy(this.projectionScreenMatrix);v.invert();const m=y.corner0,g=y.corner1,L=y.corner2,O=y.corner3;m.copy(this._tempBox.min),g.copy(this._tempBox.max),g.x=m.x,L.copy(this._tempBox.max),L.y=m.y,O.copy(this._tempBox.max);const q=(m.z+O.z)*.5;m.z=g.z=L.z=O.z=q,m.applyMatrix4(v),g.applyMatrix4(v),L.applyMatrix4(v),O.applyMatrix4(v),y.debugDrawLine(m,g,255),y.debugDrawLine(m,L,255),y.debugDrawLine(g,O,255),y.debugDrawLine(L,O,255)}let I=999;if(c&&t.lastScreenCoverage>0)for(let v=0;v<c.length;v++){const m=c[v];if((((o=m.densities)==null?void 0:o[M])||m.density||1e-5)/t.lastScreenCoverage<n){I=v;break}}I<l&&(l=I,d=!0)}if(d?r.mesh_lod=l:r.mesh_lod=t.lastLodLevel_Mesh,$&&r.mesh_lod!=t.lastLodLevel_Mesh){const p=c?.[r.mesh_lod];p&&console.log(`Mesh LOD changed: ${t.lastLodLevel_Mesh} \u2192 ${r.mesh_lod} (${p.density.toFixed(0)}) - ${e.name}`)}if(R){const p="saveData"in globalThis.navigator&&globalThis.navigator.saveData===!0;if(t.lastLodLevel_Texture<0){if(r.texture_lod=f.max_count-1,$){const h=f.lods[f.max_count-1];$&&console.log(`First Texture LOD ${r.texture_lod} (${h.max_height}px) - ${e.name}`)}}else{const h=t.lastScreenspaceVolume.x+t.lastScreenspaceVolume.y+t.lastScreenspaceVolume.z;let P=t.lastScreenCoverage*4;((a=this.context)==null?void 0:a.engine)==="model-viewer"&&(P*=1.5);const S=k/window.devicePixelRatio*P;let B=!1;for(let b=f.lods.length-1;b>=0;b--){const I=f.lods[b];if(!(p&&I.max_height>=2048)&&!(lt()&&I.max_height>4096)&&(I.max_height>S||!B&&b===0)){if(B=!0,r.texture_lod=b,r.texture_lod<t.lastLodLevel_Texture){const v=I.max_height;$&&console.log(`Texture LOD changed: ${t.lastLodLevel_Texture} \u2192 ${r.texture_lod} = ${v}px
|
|
6
|
+
Screensize: ${S.toFixed(0)}px, Coverage: ${(100*t.lastScreenCoverage).toFixed(2)}%, Volume ${h.toFixed(1)}
|
|
7
|
+
${e.name}`)}break}}}}else r.texture_lod=0}},E=new WeakMap,K=new WeakMap,Ae=new WeakMap,H=new WeakMap,ie=new WeakMap,me=new WeakMap,Q=new WeakMap,u(y,"debugDrawLine"),u(y,"overrideGlobalLodLevel"),u(y,"corner0",new U),u(y,"corner1",new U),u(y,"corner2",new U),u(y,"corner3",new U),u(y,"_tempPtInside",new U),u(y,"skinnedMeshBoundsFrameOffsetCounter",0),u(y,"$skinnedMeshBoundsOffset",Symbol("gltf-progressive-skinnedMeshBoundsOffset")),y);class vt{constructor(){u(this,"frames",0),u(this,"lastLodLevel_Mesh",-1),u(this,"lastLodLevel_Texture",-1),u(this,"lastScreenCoverage",0),u(this,"lastScreenspaceVolume",new U),u(this,"lastCentrality",0)}}const Ne=Symbol("NEEDLE_mesh_lod"),pe=Symbol("NEEDLE_texture_lod");let ve=null;function Ue(){const s=xt();s&&(s.mapURLs(function(e){return We(),e}),We(),ve?.disconnect(),ve=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(n=>{n instanceof HTMLElement&&n.tagName.toLowerCase()==="model-viewer"&&qe(n)})})}),ve.observe(document,{childList:!0,subtree:!0}))}function xt(){return typeof customElements>"u"?null:customElements.get("model-viewer")||(customElements.whenDefined("model-viewer").then(()=>{console.debug("[gltf-progressive] model-viewer defined"),Ue()}),null)}function We(){typeof document>"u"||document.querySelectorAll("model-viewer").forEach(s=>{qe(s)})}const ze=new WeakSet;let yt=0;function qe(s){if(!s||ze.has(s))return null;ze.add(s),console.debug("[gltf-progressive] found new model-viewer..."+ ++yt+`
|
|
8
|
+
`,s.getAttribute("src"));let e=null,t=null,n=null;for(let r=s;r!=null;r=Object.getPrototypeOf(r)){const i=Object.getOwnPropertySymbols(r),o=i.find(d=>d.toString()=="Symbol(renderer)"),a=i.find(d=>d.toString()=="Symbol(scene)"),l=i.find(d=>d.toString()=="Symbol(needsRender)");!e&&o!=null&&(e=s[o].threeRenderer),!t&&a!=null&&(t=s[a]),!n&&l!=null&&(n=s[l])}if(e&&t){let r=function(){if(n){let o=0,a=setInterval(()=>{if(o++>5){clearInterval(a);return}n?.call(s)},300)}};console.debug("[gltf-progressive] setup model-viewer");const i=ae.get(e,{engine:"model-viewer"});return ae.addPlugin(new wt),i.enable(),i.addEventListener("changed",()=>{n?.call(s)}),s.addEventListener("model-visibility",o=>{o.detail.visible&&n?.call(s)}),s.addEventListener("load",()=>{r()}),()=>{i.disable()}}return null}class wt{constructor(){u(this,"_didWarnAboutMissingUrl",!1)}onBeforeUpdateLOD(e,t,n,r){this.tryParseMeshLOD(t,r),this.tryParseTextureLOD(t,r)}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[pe]==!0)return;t[pe]=!0;const n=this.tryGetCurrentGLTF(e),r=this.tryGetCurrentModelViewer(e),i=this.getUrl(r);if(i&&n&&t.material){let o=function(l){var d,c,M;if(l[pe]==!0)return;l[pe]=!0,l.userData&&(l.userData.LOD=-1);const w=Object.keys(l);for(let f=0;f<w.length;f++){const R=w[f],k=l[R];if(k?.isTexture===!0){const D=(c=(d=k.userData)==null?void 0:d.associations)==null?void 0:c.textures;if(D==null)continue;const p=n.parser.json.textures[D];if(!p){console.warn("Texture data not found for texture index "+D);continue}if((M=p?.extensions)!=null&&M[W]){const h=p.extensions[W];h&&i&&z.registerTexture(i,k,h.lods.length,D,h)}}}};const a=t.material;if(Array.isArray(a))for(const l of a)o(l);else o(a)}}tryParseMeshLOD(e,t){var n,r;if(t[Ne]==!0)return;t[Ne]=!0;const i=this.tryGetCurrentModelViewer(e),o=this.getUrl(i);if(!o)return;const a=(r=(n=t.userData)==null?void 0:n.gltfExtensions)==null?void 0:r[W];if(a&&o){const l=t.uuid;z.registerMesh(o,l,t,0,a.lods.length,a)}}}function _t(s,e,t,n){Le(e),Me(t),be(t,{progressive:!0,...n?.hints}),t.register(i=>new z(i,s));const r=ae.get(e);return n?.enableLODsManager!==!1&&r.enable(),r}if(Ue(),!ct){const s={gltfProgressive:{useNeedleProgressive:_t,LODsManager:ae,configureLoader:be,getRaycastMesh:se,useRaycastMeshes:gt}};if(!globalThis.Needle)globalThis.Needle=s;else for(const e in s)globalThis.Needle[e]=s[e]}export{ae as LODsManager,z as NEEDLE_progressive,Me as addDracoAndKTX2Loaders,be as configureLoader,Le as createLoaders,se as getRaycastMesh,Ge as setDracoDecoderLocation,$e as setKTX2TranscoderLocation};
|
|
@@ -6,11 +6,11 @@ var aS = (o, t, e) => t in o ? rS(o, t, { enumerable: !0, configurable: !0, writ
|
|
|
6
6
|
var r = (o, t, e) => aS(o, typeof t != "symbol" ? t + "" : t, e), Xf = (o, t, e) => t.has(o) || t_("Cannot " + e);
|
|
7
7
|
var ue = (o, t, e) => (Xf(o, t, "read from private field"), e ? e.call(o) : t.get(o)), mn = (o, t, e) => t.has(o) ? t_("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e), gn = (o, t, e, i) => (Xf(o, t, "write to private field"), i ? i.call(o, e) : t.set(o, e), e), $l = (o, t, e) => (Xf(o, t, "access private method"), e);
|
|
8
8
|
import { Vector2 as ne, Vector3 as w, Vector4 as ye, Quaternion as W, PlaneGeometry as ls, WebGLRenderer as Kr, PerspectiveCamera as ve, OrthographicCamera as Lu, Scene as ji, Mesh as G, Texture as Fe, Uniform$1 as tn, Color as ae, ShaderMaterial as ns, Box3 as Li, ShadowMaterial as b0, Euler as Ft, MeshStandardMaterial as yt, Box3Helper as lS, GridHelper as gg, Object3D as D, Material as Pe, Matrix3 as v0, Matrix4 as re, Layers as $o, Ray as Wo, MathUtils as zs, AxesHelper as Di, MeshBasicMaterial as Me, DoubleSide as Bi, BufferGeometry as es, Group as Do, CylinderGeometry as w0, SphereGeometry as Du, BoxGeometry as Za, SpriteMaterial as cS, Sprite as hS, Shape as dS, ExtrudeGeometry as uS, Fog as x0, DirectionalLight as rm, PointLight as yg, EdgesGeometry as fS, LineSegments as S0, LineBasicMaterial as C0, Line as Wc, BufferAttribute as _t, Raycaster as ju, Sphere as Bu, ArrayCamera as pS, Plane as Vr, SkinnedMesh as Us, InterleavedBufferAttribute as P0, Skeleton as mS, Bone as gS, Source as yS, WebGLCubeRenderTarget as _S, CubeCamera as bS, AnimationClip as jo, FileLoader as _g, TextureLoader as $a, PropertyBinding as Ja, LinearSRGBColorSpace as Gs, ShaderChunk as ni, UniformsLib as vS, DataTexture as bg, RGBAFormat as Fu, EquirectangularReflectionMapping as Ns, SRGBColorSpace as qs, Clock as wS, NeutralToneMapping as el, AgXToneMapping as zu, ACESFilmicToneMapping as Uu, NoToneMapping as jd, PCFSoftShadowMap$1 as xS, BasicNodeLibrary as SS, WebGLRenderTarget as ss, DepthTexture as O0, NearestFilter as Bd, LoopRepeat as CS, LoopOnce as am, AnimationMixer as vg, CompressedTexture as PS, FrontSide as Vo, Camera as OS, Frustum as i_, AudioListener as kS, PositionalAudio as MS, AudioLoader as lm, EventDispatcher as wg, BackSide as Nu, MeshDepthMaterial as RS, CustomBlending as TS, MaxEquation as ES, AmbientLight as AS, HemisphereLight as IS, AlwaysStencilFunc as LS, GreaterEqualStencilFunc as DS, NotEqualStencilFunc as jS, GreaterStencilFunc as BS, LessEqualStencilFunc as FS, EqualStencilFunc as zS, LessStencilFunc as US, NeverStencilFunc as n_, InvertStencilOp as NS, DecrementWrapStencilOp as $S, IncrementWrapStencilOp as WS, DecrementStencilOp as VS, IncrementStencilOp as HS, ReplaceStencilOp as GS, ZeroStencilOp as qS, KeepStencilOp as XS, RawShaderMaterial as k0, GLSL3 as QS, AlwaysDepth as YS, GreaterEqualDepth as KS, GreaterDepth as ZS, LessEqualDepth as JS, LessDepth as eC, NotEqualDepth as tC, EqualDepth as iC, BatchedMesh as s_, MeshPhysicalMaterial as cm, LinearFilter as Fd, UnsignedByteType as nC, RingGeometry as sC, Line3 as oC, AdditiveBlending as M0, BoxHelper as rC, SpotLight as aC, DirectionalLightHelper as lC, CameraHelper as cC, LOD as hC, Triangle as dC, NormalBlending as uC, ReinhardToneMapping as xg, LinearToneMapping as Sg, HalfFloatType as Qf, VideoTexture as fC, CubeTexture as pC, CompressedCubeTexture as mC, EquirectangularRefractionMapping as gC, VectorKeyframeTrack as yC, QuaternionKeyframeTrack as _C, Audio as bC, ShaderLib as zd, UniformsUtils as R0, MirroredRepeatWrapping as o_, MeshNormalMaterial as vC, AudioContext as wC, PMREMGenerator$1 as xC } from "./three-DrqIzZTH.js";
|
|
9
|
-
import { createLoaders as Cg, getRaycastMesh as T0, LODsManager as fa, NEEDLE_progressive as Ze, addDracoAndKTX2Loaders as SC, configureLoader as CC, setKTX2TranscoderLocation as PC, setDracoDecoderLocation as OC } from "./gltf-progressive-
|
|
9
|
+
import { createLoaders as Cg, getRaycastMesh as T0, LODsManager as fa, NEEDLE_progressive as Ze, addDracoAndKTX2Loaders as SC, configureLoader as CC, setKTX2TranscoderLocation as PC, setDracoDecoderLocation as OC } from "./gltf-progressive-BMJtMiwp.js";
|
|
10
10
|
import { GroundedSkybox as tl, Font as kC, TextGeometry as MC, FontLoader as RC, GLTFLoader as Xs, TransformControlsGizmo as E0, EXRLoader as Ud, RGBELoader as hm, Stats as TC, nodeFrame as EC, OrbitControls as A0, PositionalAudioHelper as AC, HorizontalBlurShader as IC, VerticalBlurShader as LC, GLTFExporter as I0, strToU8 as L0, zipSync as DC, XRControllerModelFactory as jC, XRHandMeshModel as BC, Line2 as FC, LineGeometry as zC, LineMaterial as UC, KTX2Loader as NC, TransformControls as $C, InteractiveGroup as WC, HTMLMesh as VC, VertexNormalsHelper as HC, OBJLoader as Pg, FBXLoader as D0, mergeVertices as GC } from "./three-examples-tvuhV8Ne.js";
|
|
11
11
|
import { fetchProfile as qC, MotionController as XC, $70d766613f57b014$export$2e2bcd8739ae039 as r_, ByteBuffer as QC, v5 as a_, md5 as l_, SIZE_PREFIX_LENGTH as j0, Builder as Og, createNoise4D as YC, Matrix4 as Yf, BatchedParticleRenderer as KC, ParticleSystem as ZC, RenderMode as Ps, ConstantColor as JC, Vector4 as e1, ConstantValue as t1, TrailParticle as c_, WorkerBase as i1, MeshBVH as n1 } from "./vendor-BmYIgaS1.js";
|
|
12
12
|
import { __webpack_exports__default as Ee, __webpack_exports__Text as B0, __webpack_exports__Block as F0, __webpack_exports__update as s1, SimpleStateBehavior as o1, __webpack_exports__Inline as Kf, __webpack_exports__FontLibrary as h_, ThreeMeshUI as d_ } from "./three-mesh-ui-CxuWt7m-.js";
|
|
13
|
-
import { EffectAttribute as r1 } from "./postprocessing-
|
|
13
|
+
import { EffectAttribute as r1 } from "./postprocessing-vKBVFpSz.js";
|
|
14
14
|
const Zf = /* @__PURE__ */ new Map();
|
|
15
15
|
function bi(o = ((t) => (t = globalThis.location) == null ? void 0 : t.hostname)()) {
|
|
16
16
|
if (Zf.has(o)) return Zf.get(o);
|
|
@@ -1806,9 +1806,9 @@ Go('if(!globalThis["NEEDLE_PROJECT_BUILD_TIME"]) globalThis["NEEDLE_PROJECT_BUIL
|
|
|
1806
1806
|
Go('if(!globalThis["NEEDLE_PUBLIC_KEY"]) globalThis["NEEDLE_PUBLIC_KEY"] = "unknown";');
|
|
1807
1807
|
Go('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.7.3-alpha";');
|
|
1808
1808
|
Go('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');
|
|
1809
|
-
Go('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "
|
|
1809
|
+
Go('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Aug 06 2025 11:20:05 GMT+0000 (Coordinated Universal Time)";');
|
|
1810
1810
|
Go('globalThis["__NEEDLE_PUBLIC_KEY__"] = "' + NEEDLE_PUBLIC_KEY + '";');
|
|
1811
|
-
const ts = "4.7.3-alpha", Eg = "undefined", av = "
|
|
1811
|
+
const ts = "4.7.3-alpha", Eg = "undefined", av = "Wed Aug 06 2025 11:20:05 GMT+0000 (Coordinated Universal Time)";
|
|
1812
1812
|
rv && console.log(`Engine version: ${ts} (generator: ${Eg})
|
|
1813
1813
|
Project built at ${av}`);
|
|
1814
1814
|
const hc = NEEDLE_PUBLIC_KEY, Fo = "needle_isActiveInHierarchy", Sa = "builtin_components", vd = "needle_editor_guid";
|
|
@@ -8630,7 +8630,7 @@ class ok {
|
|
|
8630
8630
|
/** @internal */
|
|
8631
8631
|
setRenderer(t) {
|
|
8632
8632
|
var e;
|
|
8633
|
-
(e = this._lodsManager) == null || e.disable(), fa.removePlugin(this), fa.addPlugin(this), fa.debugDrawLine = H.DrawLine, this._lodsManager = fa.get(t), this.applySettings(), this._lodsManager.enable();
|
|
8633
|
+
(e = this._lodsManager) == null || e.disable(), fa.removePlugin(this), fa.addPlugin(this), fa.debugDrawLine = H.DrawLine, this._lodsManager = fa.get(t, { engine: "needle-engine" }), this.applySettings(), this._lodsManager.enable();
|
|
8634
8634
|
}
|
|
8635
8635
|
disable() {
|
|
8636
8636
|
var t;
|
|
@@ -14510,7 +14510,7 @@ var j;
|
|
|
14510
14510
|
t.ready = i;
|
|
14511
14511
|
async function n() {
|
|
14512
14512
|
if (t.MODULE) return t.MODULE;
|
|
14513
|
-
const s = await import("./postprocessing-
|
|
14513
|
+
const s = await import("./postprocessing-vKBVFpSz.js").then((a) => a.index);
|
|
14514
14514
|
return t.MODULE = s, t.MAYBEMODULE = s, e.forEach((a) => a(s)), e.length = 0, s;
|
|
14515
14515
|
}
|
|
14516
14516
|
t.load = n;
|
|
@@ -14525,7 +14525,7 @@ var j;
|
|
|
14525
14525
|
t.ready = i;
|
|
14526
14526
|
async function n() {
|
|
14527
14527
|
if (t.MODULE) return t.MODULE;
|
|
14528
|
-
const s = await import("./postprocessing-
|
|
14528
|
+
const s = await import("./postprocessing-vKBVFpSz.js").then((a) => a.N8AO);
|
|
14529
14529
|
return t.MODULE = s, t.MAYBEMODULE = s, e.forEach((a) => a(s)), e.length = 0, s;
|
|
14530
14530
|
}
|
|
14531
14531
|
t.load = n;
|
|
@@ -16217,6 +16217,7 @@ class xe extends B {
|
|
|
16217
16217
|
r(this, "middleClickToFocus", !0);
|
|
16218
16218
|
r(this, "doubleClickToFocus", !0);
|
|
16219
16219
|
r(this, "clickBackgroundToFitScene", 2);
|
|
16220
|
+
r(this, "_targetElement", null);
|
|
16220
16221
|
/**
|
|
16221
16222
|
* @internal If true debug information will be logged to the console
|
|
16222
16223
|
* @default false
|
|
@@ -16249,7 +16250,6 @@ class xe extends B {
|
|
|
16249
16250
|
r(this, "_camera", null);
|
|
16250
16251
|
r(this, "_syncedTransform");
|
|
16251
16252
|
r(this, "_didSetTarget", 0);
|
|
16252
|
-
r(this, "targetElement", null);
|
|
16253
16253
|
r(this, "_activePointerEvents");
|
|
16254
16254
|
r(this, "_lastTimeClickOnBackground", -1);
|
|
16255
16255
|
r(this, "_clickOnBackgroundCount", 0);
|
|
@@ -16327,6 +16327,17 @@ class xe extends B {
|
|
|
16327
16327
|
var i;
|
|
16328
16328
|
(i = this.controls) == null || i.addEventListener("start", e);
|
|
16329
16329
|
}
|
|
16330
|
+
/**
|
|
16331
|
+
* This is the DOM element that the OrbitControls will listen to for input events. By default this is the renderer's canvas element.
|
|
16332
|
+
* Set this to a different element to make the OrbitControls listen to that element instead.
|
|
16333
|
+
*/
|
|
16334
|
+
get targetElement() {
|
|
16335
|
+
var e;
|
|
16336
|
+
return ((e = this._controls) == null ? void 0 : e.domElement) ?? this._targetElement;
|
|
16337
|
+
}
|
|
16338
|
+
set targetElement(e) {
|
|
16339
|
+
this._targetElement = e, this._controls && this._controls.domElement !== e && (this._controls.disconnect(), this._controls.domElement = e, this._controls.connect());
|
|
16340
|
+
}
|
|
16330
16341
|
/**
|
|
16331
16342
|
* @deprecated use `targetLerpDuration` instead
|
|
16332
16343
|
* ~~The speed at which the camera target and the camera will be lerping to their destinations (if set via script or user input)~~
|
|
@@ -16352,6 +16363,21 @@ class xe extends B {
|
|
|
16352
16363
|
var i;
|
|
16353
16364
|
(i = this._controls) == null || i._rotateLeft(e);
|
|
16354
16365
|
}
|
|
16366
|
+
/**
|
|
16367
|
+
* Rotate the camera up (or down) by the specified angle in radians.
|
|
16368
|
+
* For positive angles the camera will rotate up, for negative angles it will rotate down.
|
|
16369
|
+
* Tip: Use Mathf to convert between degrees and radians.
|
|
16370
|
+
* @param angleInRadians The angle in radians to rotate the camera up
|
|
16371
|
+
* @example
|
|
16372
|
+
* ```typescript
|
|
16373
|
+
* // Rotate the camera up by 0.1 radians
|
|
16374
|
+
* orbitControls.rotateUp(0.1);
|
|
16375
|
+
* ```
|
|
16376
|
+
*/
|
|
16377
|
+
rotateUp(e) {
|
|
16378
|
+
var i;
|
|
16379
|
+
(i = this._controls) == null || i._rotateUp(e);
|
|
16380
|
+
}
|
|
16355
16381
|
/**
|
|
16356
16382
|
* Pan the camera by the specified amount in the x and y direction in pixels.
|
|
16357
16383
|
* @param dx The amount to pan the camera in the x direction in pixels.
|
|
@@ -34407,7 +34433,7 @@ class Sx {
|
|
|
34407
34433
|
}
|
|
34408
34434
|
ws && console.log("[PostProcessing] Passes →", [...a.passes], `
|
|
34409
34435
|
---------------------------------
|
|
34410
|
-
• ` + a.passes.map((u) => u.name).join(`
|
|
34436
|
+
• ` + a.passes.map((u) => u.name || u.constructor.name + "*").join(`
|
|
34411
34437
|
• `) + `
|
|
34412
34438
|
`), ws && this._onCreateEffectsDebug(this._composer, s);
|
|
34413
34439
|
}
|
|
@@ -34494,7 +34520,7 @@ class Eh extends B {
|
|
|
34494
34520
|
*/
|
|
34495
34521
|
addEffect(e) {
|
|
34496
34522
|
let i = e;
|
|
34497
|
-
return i instanceof ft || (i = new _u(i)), i.gameObject === void 0 && this.gameObject.addComponent(i), this._effects.includes(i) || (this._effects.push(i), this._isDirty = !0), e;
|
|
34523
|
+
return i instanceof ft || (i = new _u(i), typeof e.order == "number" && (i.order = e.order)), i.gameObject === void 0 && this.gameObject.addComponent(i), this._effects.includes(i) || (this._effects.push(i), this._isDirty = !0), e;
|
|
34498
34524
|
}
|
|
34499
34525
|
/**
|
|
34500
34526
|
* Remove a post processing effect from the stack and schedules the effect stack to be re-created.
|