@quick-threejs/reactive 0.1.24 → 0.1.25

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 (55) hide show
  1. package/dist/app.module-BeaCiPyy.mjs +5868 -0
  2. package/dist/app.module-jsu6itlh.js +34 -0
  3. package/dist/common/enums/index.d.ts +0 -1
  4. package/dist/common/index.d.ts +1 -1
  5. package/dist/common/interfaces/event.interface.d.ts +0 -4
  6. package/dist/common/interfaces/index.d.ts +1 -0
  7. package/dist/common/interfaces/module.interface.d.ts +10 -2
  8. package/dist/common/models/launch-app-props.model.d.ts +4 -6
  9. package/dist/common/models/proxy-event-handler.model.d.ts +1 -1
  10. package/dist/common/models/proxy-event-observables.model.d.ts +1 -1
  11. package/dist/common/models/proxy-event-subjects.models.d.ts +1 -1
  12. package/dist/common/models/register-props.model.d.ts +9 -2
  13. package/dist/common/tokens/index.d.ts +1 -0
  14. package/dist/common/tokens/ioc.token.d.ts +1 -0
  15. package/dist/core/app/app.controller.d.ts +3 -7
  16. package/dist/core/app/app.module-worker.d.ts +4 -3
  17. package/dist/core/app/app.module.d.ts +19 -15
  18. package/dist/core/app/{app.component.d.ts → app.service.d.ts} +5 -3
  19. package/dist/core/app/camera/camera.controller.d.ts +4 -8
  20. package/dist/core/app/camera/camera.module.d.ts +6 -7
  21. package/dist/core/app/camera/{camera.component.d.ts → camera.service.d.ts} +4 -4
  22. package/dist/core/app/debug/debug.controller.d.ts +3 -4
  23. package/dist/core/app/debug/debug.module.d.ts +10 -8
  24. package/dist/core/app/debug/{debug.component.d.ts → debug.service.d.ts} +10 -10
  25. package/dist/core/app/renderer/renderer.controller.d.ts +6 -8
  26. package/dist/core/app/renderer/renderer.module.d.ts +6 -8
  27. package/dist/core/app/renderer/renderer.service.d.ts +19 -0
  28. package/dist/core/app/sizes/sizes.controller.d.ts +5 -7
  29. package/dist/core/app/sizes/sizes.module.d.ts +4 -5
  30. package/dist/core/app/sizes/{sizes.component.d.ts → sizes.service.d.ts} +1 -1
  31. package/dist/core/app/timer/timer.controller.d.ts +18 -12
  32. package/dist/core/app/timer/timer.module.d.ts +22 -12
  33. package/dist/core/app/timer/timer.service.d.ts +10 -0
  34. package/dist/core/app/world/world.controller.d.ts +0 -3
  35. package/dist/core/app/world/world.module.d.ts +3 -6
  36. package/dist/core/app/world/{world.component.d.ts → world.service.d.ts} +1 -1
  37. package/dist/core/loader/loader.controller.d.ts +0 -2
  38. package/dist/core/loader/loader.module.d.ts +0 -1
  39. package/dist/core/register/register.controller.d.ts +3 -7
  40. package/dist/core/register/register.module.d.ts +14 -17
  41. package/dist/core/register/register.service.d.ts +9 -0
  42. package/dist/core/register/register.util.d.ts +8 -5
  43. package/dist/main.js +3 -12
  44. package/dist/main.mjs +1318 -1667
  45. package/dist/worker.js +1 -3
  46. package/dist/worker.mjs +32 -315
  47. package/package.json +6 -4
  48. package/dist/app.module-Da11YIUG.js +0 -29
  49. package/dist/app.module-Dg_0i25D.mjs +0 -2640
  50. package/dist/common/enums/lifecycle.enum.d.ts +0 -10
  51. package/dist/common/types/index.d.ts +0 -1
  52. package/dist/core/app/renderer/renderer.component.d.ts +0 -19
  53. package/dist/core/app/timer/timer.component.d.ts +0 -8
  54. package/dist/core/register/register.component.d.ts +0 -13
  55. /package/dist/common/{types/object.type.d.ts → interfaces/object.interface.d.ts} +0 -0
package/dist/main.js CHANGED
@@ -1,12 +1,3 @@
1
- "use strict";var fe=Object.defineProperty;var me=(l,e,t)=>e in l?fe(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var A=(l,e,t)=>me(l,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./app.module-Da11YIUG.js"),u=require("three"),k=require("rxjs"),L=require("@quick-threejs/utils"),se=require("stats.js");function ee(l,e){return function(t){w.injectable()(t),w.instance.register(t,t,{lifecycle:l})}}const j=new WeakMap;class ge extends u.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,s,n){const r=new u.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,i=>{this.parse(i,t,n)},s,n)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,u.SRGBColorSpace,s).catch(s)}decodeDracoFile(e,t,s,n,r=u.LinearSRGBColorSpace,i=()=>{}){const a={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t).catch(i)}decodeGeometry(e,t){const s=JSON.stringify(t);if(j.has(e)){const o=j.get(e);if(o.key===s)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const r=this.workerNextTaskID++,i=e.byteLength,a=this._getWorker(r,i).then(o=>(n=o,new Promise((c,h)=>{n._callbacks[r]={resolve:c,reject:h},n.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{n&&r&&this._releaseTask(n,r)}),j.set(e,{key:s,promise:a}),a}_createGeometry(e){const t=new u.BufferGeometry;e.index&&t.setIndex(new u.BufferAttribute(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const n=e.attributes[s],r=n.name,i=n.array,a=n.itemSize,o=new u.BufferAttribute(i,a);r==="color"&&(this._assignVertexColorSpace(o,n.vertexColorSpace),o.normalized=!(i instanceof Float32Array)),t.setAttribute(r,o)}return t}_assignVertexColorSpace(e,t){if(t!==u.SRGBColorSpace)return;const s=new u.Color;for(let n=0,r=e.count;n<r;n++)s.fromBufferAttribute(e,n),u.ColorManagement.toWorkingColorSpace(s,u.SRGBColorSpace),e.setXYZ(n,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new u.FileLoader(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise((n,r)=>{s.load(e,n,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(s=>{const n=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const r=Ae.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
2
- `);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(r){const i=r.data;switch(i.type){case"decode":n._callbacks[i.id].resolve(i);break;case"error":n._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,r){return n._taskLoad>r._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=t,s._taskLoad+=t,s})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Ae(){let l,e;onmessage=function(i){const a=i.data;switch(a.type){case"init":l=a.decoderConfig,e=new Promise(function(h){l.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(l)});break;case"decode":const o=a.buffer,c=a.taskConfig;e.then(h=>{const d=h.draco,p=new d.Decoder;try{const f=t(d,p,new Int8Array(o),c),m=f.attributes.map(y=>y.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:a.id,error:f.message})}finally{d.destroy(p)}});break}};function t(i,a,o,c){const h=c.attributeIDs,d=c.attributeTypes;let p,f;const m=a.GetEncodedGeometryType(o);if(m===i.TRIANGULAR_MESH)p=new i.Mesh,f=a.DecodeArrayToMesh(o,o.byteLength,p);else if(m===i.POINT_CLOUD)p=new i.PointCloud,f=a.DecodeArrayToPointCloud(o,o.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const y={index:null,attributes:[]};for(const g in h){const b=self[d[g]];let T,E;if(c.useUniqueIDs)E=h[g],T=a.GetAttributeByUniqueId(p,E);else{if(E=a.GetAttributeId(p,i[h[g]]),E===-1)continue;T=a.GetAttribute(p,E)}const x=n(i,a,p,g,b,T);g==="color"&&(x.vertexColorSpace=c.vertexColorSpace),y.attributes.push(x)}return m===i.TRIANGULAR_MESH&&(y.index=s(i,a,p)),i.destroy(p),y}function s(i,a,o){const h=o.num_faces()*3,d=h*4,p=i._malloc(d);a.GetTrianglesUInt32Array(o,d,p);const f=new Uint32Array(i.HEAPF32.buffer,p,h).slice();return i._free(p),{array:f,itemSize:1}}function n(i,a,o,c,h,d){const p=d.num_components(),m=o.num_points()*p,y=m*h.BYTES_PER_ELEMENT,g=r(i,h),b=i._malloc(y);a.GetAttributeDataArrayForAllPoints(o,d,g,y,b);const T=new h(i.HEAPF32.buffer,b,m).slice();return i._free(b),{name:c,array:T,itemSize:p}}function r(i,a){switch(a){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,we=(l,e,t,s)=>{for(var n=s>1?void 0:s?ye(e,t):e,r=l.length-1,i;r>=0;r--)(i=l[r])&&(n=(s?i(e,t,n):i(n))||n);return s&&n&&be(e,t,n),n};let W=class{constructor(){A(this,"lifecycle$$",new k.Subject);A(this,"progress$$",new k.Subject);A(this,"progress$",this.progress$$.pipe());A(this,"lifecycle$",this.lifecycle$$.pipe());A(this,"progressCompleted$",this.progress$.pipe(k.filter(l=>l.toLoad===l.loaded)))}};W=we([ee(w.Lifecycle.ResolutionScoped)],W);function ie(l,e){if(e===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===u.TriangleFanDrawMode||e===u.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const i=[],a=l.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)i.push(o);l.setIndex(i),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const s=t.count-2,n=[];if(e===u.TriangleFanDrawMode)for(let i=1;i<=s;i++)n.push(t.getX(0)),n.push(t.getX(i)),n.push(t.getX(i+1));else for(let i=0;i<s;i++)i%2===0?(n.push(t.getX(i)),n.push(t.getX(i+1)),n.push(t.getX(i+2))):(n.push(t.getX(i+2)),n.push(t.getX(i+1)),n.push(t.getX(i)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=l.clone();return r.setIndex(n),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class _e extends u.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Le(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new Ne(t)}),this.register(function(t){return new $e(t)}),this.register(function(t){return new Fe(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new Ce(t)}),this.register(function(t){return new Ie(t)}),this.register(function(t){return new Pe(t)}),this.register(function(t){return new ve(t)}),this.register(function(t){return new De(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new ke(t)}),this.register(function(t){return new Oe(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new He(t)}),this.register(function(t){return new Be(t)})}load(e,t,s,n){const r=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const c=u.LoaderUtils.extractUrlBase(e);i=u.LoaderUtils.resolveURL(c,this.path)}else i=u.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){n?n(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},o=new u.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{r.parse(c,i,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let r;const i={},a={},o=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===de){try{i[_.KHR_BINARY_GLTF]=new Ge(e)}catch(d){n&&n(d);return}r=JSON.parse(i[_.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new et(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,i[d.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const d=r.extensionsUsed[h],p=r.extensionsRequired||[];switch(d){case _.KHR_MATERIALS_UNLIT:i[d]=new Ee;break;case _.KHR_DRACO_MESH_COMPRESSION:i[d]=new je(r,this.dracoLoader);break;case _.KHR_TEXTURE_TRANSFORM:i[d]=new Ue;break;case _.KHR_MESH_QUANTIZATION:i[d]=new Ve;break;default:p.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(i),c.setPlugins(a),c.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,r){s.parse(e,t,n,r)})}}function Te(){let l={};return{get:function(e){return l[e]},add:function(e,t){l[e]=t},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const _={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class xe{constructor(e){this.parser=e,this.name=_.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const r=t[s];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const r=t.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const h=new u.Color(16777215);o.color!==void 0&&h.setRGB(o.color[0],o.color[1],o.color[2],u.LinearSRGBColorSpace);const d=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new u.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new u.PointLight(h),c.distance=d;break;case"spot":c=new u.SpotLight(h),c.distance=d,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),c.decay=2,C(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=t.createUniqueName(o.name||"light_"+e),n=Promise.resolve(c),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,r=s.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return s._getNodeRef(t.cache,a,o)})}}class Ee{constructor(){this.name=_.KHR_MATERIALS_UNLIT}getMaterialType(){return u.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new u.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const i=r.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],u.LinearSRGBColorSpace),e.opacity=i[3]}r.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",r.baseColorTexture,u.SRGBColorSpace))}return Promise.all(n)}}class ve{constructor(e){this.parser=e,this.name=_.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class Le{constructor(e){this.parser=e,this.name=_.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&r.push(s.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&r.push(s.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(r.push(s.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const a=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new u.Vector2(a,a)}return Promise.all(r)}}class Se{constructor(e){this.parser=e,this.name=_.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class Re{constructor(e){this.parser=e,this.name=_.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&r.push(s.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&r.push(s.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}}class Me{constructor(e){this.parser=e,this.name=_.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new u.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=n.extensions[this.name];if(i.sheenColorFactor!==void 0){const a=i.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],u.LinearSRGBColorSpace)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&r.push(s.assignTexture(t,"sheenColorMap",i.sheenColorTexture,u.SRGBColorSpace)),i.sheenRoughnessTexture!==void 0&&r.push(s.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(r)}}class Ce{constructor(e){this.parser=e,this.name=_.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&r.push(s.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(r)}}class Ie{constructor(e){this.parser=e,this.name=_.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&r.push(s.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=new u.Color().setRGB(a[0],a[1],a[2],u.LinearSRGBColorSpace),Promise.all(r)}}class Pe{constructor(e){this.parser=e,this.name=_.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class De{constructor(e){this.parser=e,this.name=_.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&r.push(s.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=new u.Color().setRGB(a[0],a[1],a[2],u.LinearSRGBColorSpace),i.specularColorTexture!==void 0&&r.push(s.assignTexture(t,"specularColorMap",i.specularColorTexture,u.SRGBColorSpace)),Promise.all(r)}}class Oe{constructor(e){this.parser=e,this.name=_.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&r.push(s.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(r)}}class ke{constructor(e){this.parser=e,this.name=_.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&r.push(s.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(r)}}class Ne{constructor(e){this.parser=e,this.name=_.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,i)}}class $e{constructor(e){this.parser=e,this.name=_.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],a=n.images[i.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(e,i.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Fe{constructor(e){this.parser=e,this.name=_.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],a=n.images[i.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(e,i.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class He{constructor(e){this.name=_.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,h=n.count,d=n.byteStride,p=new Uint8Array(a,o,c);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(h,d,p,n.mode,n.filter).then(function(f){return f.buffer}):i.ready.then(function(){const f=new ArrayBuffer(h*d);return i.decodeGltfBuffer(new Uint8Array(f),h,d,p,n.mode,n.filter),f})})}else return null}}class Be{constructor(e){this.name=_.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==v.TRIANGLES&&c.mode!==v.TRIANGLE_STRIP&&c.mode!==v.TRIANGLE_FAN&&c.mode!==void 0)return null;const i=s.extensions[this.name].attributes,a=[],o={};for(const c in i)a.push(this.parser.getDependency("accessor",i[c]).then(h=>(o[c]=h,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),d=h.isGroup?h.children:[h],p=c[0].count,f=[];for(const m of d){const y=new u.Matrix4,g=new u.Vector3,b=new u.Quaternion,T=new u.Vector3(1,1,1),E=new u.InstancedMesh(m.geometry,m.material,p);for(let x=0;x<p;x++)o.TRANSLATION&&g.fromBufferAttribute(o.TRANSLATION,x),o.ROTATION&&b.fromBufferAttribute(o.ROTATION,x),o.SCALE&&T.fromBufferAttribute(o.SCALE,x),E.setMatrixAt(x,y.compose(g,b,T));for(const x in o)if(x==="_COLOR_0"){const R=o[x];E.instanceColor=new u.InstancedBufferAttribute(R.array,R.itemSize,R.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&m.geometry.setAttribute(x,o[x]);u.Object3D.prototype.copy.call(E,m),this.parser.assignFinalMaterial(E),f.push(E)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}}const de="glTF",F=12,re={JSON:1313821514,BIN:5130562};class Ge{constructor(e){this.name=_.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,F),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==de)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-F,r=new DataView(e,F);let i=0;for(;i<n;){const a=r.getUint32(i,!0);i+=4;const o=r.getUint32(i,!0);if(i+=4,o===re.JSON){const c=new Uint8Array(e,F+i,a);this.content=s.decode(c)}else if(o===re.BIN){const c=F+i;this.body=e.slice(c,c+a)}i+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class je{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},o={},c={};for(const h in i){const d=Y[h]||h.toLowerCase();a[d]=i[h]}for(const h in e.attributes){const d=Y[h]||h.toLowerCase();if(i[h]!==void 0){const p=s.accessors[e.attributes[h]],f=N[p.componentType];c[d]=f.name,o[d]=p.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(d,p){n.decodeDracoFile(h,function(f){for(const m in f.attributes){const y=f.attributes[m],g=o[m];g!==void 0&&(y.normalized=g)}d(f)},a,c,u.LinearSRGBColorSpace,p)})})}}class Ue{constructor(){this.name=_.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Ve{constructor(){this.name=_.KHR_MESH_QUANTIZATION}}class ue extends u.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let i=0;i!==n;i++)t[i]=s[r+i];return t}interpolate_(e,t,s,n){const r=this.resultBuffer,i=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,h=n-t,d=(s-t)/h,p=d*d,f=p*d,m=e*c,y=m-c,g=-2*f+3*p,b=f-p,T=1-g,E=b-p+d;for(let x=0;x!==a;x++){const R=i[y+x+a],I=i[y+x+o]*h,S=i[m+x+a],$=i[m+x]*h;r[x]=T*R+E*I+g*S+b*$}return r}}const Ke=new u.Quaternion;class ze extends ue{interpolate_(e,t,s,n){const r=super.interpolate_(e,t,s,n);return Ke.fromArray(r).normalize().toArray(r),r}}const v={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},N={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},oe={9728:u.NearestFilter,9729:u.LinearFilter,9984:u.NearestMipmapNearestFilter,9985:u.LinearMipmapNearestFilter,9986:u.NearestMipmapLinearFilter,9987:u.LinearMipmapLinearFilter},ae={33071:u.ClampToEdgeWrapping,33648:u.MirroredRepeatWrapping,10497:u.RepeatWrapping},U={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Y={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},D={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Xe={CUBICSPLINE:void 0,LINEAR:u.InterpolateLinear,STEP:u.InterpolateDiscrete},V={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function We(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new u.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:u.FrontSide})),l.DefaultMaterial}function O(l,e,t){for(const s in t.extensions)l[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function C(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Ye(l,e,t){let s=!1,n=!1,r=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(s=!0),d.NORMAL!==void 0&&(n=!0),d.COLOR_0!==void 0&&(r=!0),s&&n&&r)break}if(!s&&!n&&!r)return Promise.resolve(l);const i=[],a=[],o=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(s){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):l.attributes.position;i.push(p)}if(n){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):l.attributes.normal;a.push(p)}if(r){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):l.attributes.color;o.push(p)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o)]).then(function(c){const h=c[0],d=c[1],p=c[2];return s&&(l.morphAttributes.position=h),n&&(l.morphAttributes.normal=d),r&&(l.morphAttributes.color=p),l.morphTargetsRelative=!0,l})}function qe(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)l.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(l.morphTargetInfluences.length===t.length){l.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)l.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Je(l){let e;const t=l.extensions&&l.extensions[_.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+K(t.attributes):e=l.indices+":"+K(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)e+=":"+K(l.targets[s]);return e}function K(l){let e="";const t=Object.keys(l).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+l[t[s]]+";";return e}function q(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Qe(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Ze=new u.Matrix4;class et{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Te,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,r=!1,i=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=s&&o?parseInt(o[1],10):-1,r=a.indexOf("Firefox")>-1,i=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||r&&i<98?this.textureLoader=new u.TextureLoader(this.options.manager):this.textureLoader=new u.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new u.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(i){const a={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:s,userData:{}};return O(r,a,n),C(a,n),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const i=t[n].joints;for(let a=0,o=i.length;a<o;a++)e[i[a]].isBone=!0}for(let n=0,r=e.length;n<r;n++){const i=e[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(s[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),r=(i,a)=>{const o=this.associations.get(i);o!=null&&this.associations.set(a,o);for(const[c,h]of i.children.entries())r(h,a.children[c])};return r(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&s.push(r)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(r,i){return s.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[_.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(r,i){s.load(u.LoaderUtils.resolveURL(t.uri,n.path),r,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,r=t.byteOffset||0;return s.slice(r,r+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const i=U[n.type],a=N[n.componentType],o=n.normalized===!0,c=new a(n.count*i);return Promise.resolve(new u.BufferAttribute(c,i,o))}const r=[];return n.bufferView!==void 0?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(i){const a=i[0],o=U[n.type],c=N[n.componentType],h=c.BYTES_PER_ELEMENT,d=h*o,p=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,m=n.normalized===!0;let y,g;if(f&&f!==d){const b=Math.floor(p/f),T="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+b+":"+n.count;let E=t.cache.get(T);E||(y=new c(a,b*f,n.count*f/h),E=new u.InterleavedBuffer(y,f/h),t.cache.add(T,E)),g=new u.InterleavedBufferAttribute(E,o,p%f/h,m)}else a===null?y=new c(n.count*o):y=new c(a,p,n.count*o),g=new u.BufferAttribute(y,o,m);if(n.sparse!==void 0){const b=U.SCALAR,T=N[n.sparse.indices.componentType],E=n.sparse.indices.byteOffset||0,x=n.sparse.values.byteOffset||0,R=new T(i[1],E,n.sparse.count*b),I=new c(i[2],x,n.sparse.count*o);a!==null&&(g=new u.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let S=0,$=R.length;S<$;S++){const P=R[S];if(g.setX(P,I[S*o]),o>=2&&g.setY(P,I[S*o+1]),o>=3&&g.setZ(P,I[S*o+2]),o>=4&&g.setW(P,I[S*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(e){const t=this.json,s=this.options,r=t.textures[e].source,i=t.images[r];let a=this.textureLoader;if(i.uri){const o=s.manager.getHandler(i.uri);o!==null&&(a=o)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,s){const n=this,r=this.json,i=r.textures[e],a=r.images[t],o=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(t,s).then(function(h){h.flipY=!1,h.name=i.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const p=(r.samplers||{})[i.sampler]||{};return h.magFilter=oe[p.magFilter]||u.LinearFilter,h.minFilter=oe[p.minFilter]||u.LinearMipmapLinearFilter,h.wrapS=ae[p.wrapS]||u.RepeatWrapping,h.wrapT=ae[p.wrapT]||u.RepeatWrapping,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(e,t){const s=this,n=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const i=n.images[e],a=self.URL||self.webkitURL;let o=i.uri||"",c=!1;if(i.bufferView!==void 0)o=s.getDependency("bufferView",i.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:i.mimeType});return o=a.createObjectURL(p),o});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(o).then(function(d){return new Promise(function(p,f){let m=p;t.isImageBitmapLoader===!0&&(m=function(y){const g=new u.Texture(y);g.needsUpdate=!0,p(g)}),t.load(u.LoaderUtils.resolveURL(d,r.path),m,void 0,f)})}).then(function(d){return c===!0&&a.revokeObjectURL(o),C(d,i),d.userData.mimeType=i.mimeType||Qe(i.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),d});return this.sourceCache[e]=h,h}assignTexture(e,t,s,n){const r=this;return this.getDependency("texture",s.index).then(function(i){if(!i)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(i=i.clone(),i.channel=s.texCoord),r.extensions[_.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[_.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=r.associations.get(i);i=r.extensions[_.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),r.associations.set(i,o)}}return n!==void 0&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new u.PointsMaterial,u.Material.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(a,o)),s=o}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new u.LineBasicMaterial,u.Material.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(a,o)),s=o}if(n||r||i){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=s.clone(),r&&(o.vertexColors=!0),i&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(s))),s=o}e.material=s}getMaterialType(){return u.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,r=s.materials[e];let i;const a={},o=r.extensions||{},c=[];if(o[_.KHR_MATERIALS_UNLIT]){const d=n[_.KHR_MATERIALS_UNLIT];i=d.getMaterialType(),c.push(d.extendParams(a,r,t))}else{const d=r.pbrMetallicRoughness||{};if(a.color=new u.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],u.LinearSRGBColorSpace),a.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,u.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),i=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=u.DoubleSide);const h=r.alphaMode||V.OPAQUE;if(h===V.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===V.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&i!==u.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new u.Vector2(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;a.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&i!==u.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&i!==u.MeshBasicMaterial){const d=r.emissiveFactor;a.emissive=new u.Color().setRGB(d[0],d[1],d[2],u.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&i!==u.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,u.SRGBColorSpace)),Promise.all(c).then(function(){const d=new i(a);return r.name&&(d.name=r.name),C(d,r),t.associations.set(d,{materials:e}),r.extensions&&O(n,d,r),d})}createUniqueName(e){const t=u.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function r(a){return s[_.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(o){return le(o,a,t)})}const i=[];for(let a=0,o=e.length;a<o;a++){const c=e[a],h=Je(c),d=n[h];if(d)i.push(d.promise);else{let p;c.extensions&&c.extensions[_.KHR_DRACO_MESH_COMPRESSION]?p=r(c):p=le(new u.BufferGeometry,c,t),n[h]={primitive:c,promise:p},i.push(p)}}return Promise.all(i)}loadMesh(e){const t=this,s=this.json,n=this.extensions,r=s.meshes[e],i=r.primitives,a=[];for(let o=0,c=i.length;o<c;o++){const h=i[o].material===void 0?We(this.cache):this.getDependency("material",i[o].material);a.push(h)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),h=o[o.length-1],d=[];for(let f=0,m=h.length;f<m;f++){const y=h[f],g=i[f];let b;const T=c[f];if(g.mode===v.TRIANGLES||g.mode===v.TRIANGLE_STRIP||g.mode===v.TRIANGLE_FAN||g.mode===void 0)b=r.isSkinnedMesh===!0?new u.SkinnedMesh(y,T):new u.Mesh(y,T),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),g.mode===v.TRIANGLE_STRIP?b.geometry=ie(b.geometry,u.TriangleStripDrawMode):g.mode===v.TRIANGLE_FAN&&(b.geometry=ie(b.geometry,u.TriangleFanDrawMode));else if(g.mode===v.LINES)b=new u.LineSegments(y,T);else if(g.mode===v.LINE_STRIP)b=new u.Line(y,T);else if(g.mode===v.LINE_LOOP)b=new u.LineLoop(y,T);else if(g.mode===v.POINTS)b=new u.Points(y,T);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(b.geometry.morphAttributes).length>0&&qe(b,r),b.name=t.createUniqueName(r.name||"mesh_"+e),C(b,r),g.extensions&&O(n,b,g),t.assignFinalMaterial(b),d.push(b)}for(let f=0,m=d.length;f<m;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return r.extensions&&O(n,d[0],r),d[0];const p=new u.Group;r.extensions&&O(n,p,r),t.associations.set(p,{meshes:e});for(let f=0,m=d.length;f<m;f++)p.add(d[f]);return p})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new u.PerspectiveCamera(u.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new u.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),C(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,r=t.joints.length;n<r;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const r=n.pop(),i=n,a=[],o=[];for(let c=0,h=i.length;c<h;c++){const d=i[c];if(d){a.push(d);const p=new u.Matrix4;r!==null&&p.fromArray(r.array,c*16),o.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new u.Skeleton(a,o)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],r=n.name?n.name:"animation_"+e,i=[],a=[],o=[],c=[],h=[];for(let d=0,p=n.channels.length;d<p;d++){const f=n.channels[d],m=n.samplers[f.sampler],y=f.target,g=y.node,b=n.parameters!==void 0?n.parameters[m.input]:m.input,T=n.parameters!==void 0?n.parameters[m.output]:m.output;y.node!==void 0&&(i.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",b)),o.push(this.getDependency("accessor",T)),c.push(m),h.push(y))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(h)]).then(function(d){const p=d[0],f=d[1],m=d[2],y=d[3],g=d[4],b=[];for(let T=0,E=p.length;T<E;T++){const x=p[T],R=f[T],I=m[T],S=y[T],$=g[T];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const P=s._createAnimationTracks(x,R,I,S,$);if(P)for(let G=0;G<P.length;G++)b.push(P[G])}return new u.AnimationClip(r,void 0,b)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(r){const i=s._getNodeRef(s.meshCache,n.mesh,r);return n.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),i})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],r=s._loadNodeShallow(e),i=[],a=n.children||[];for(let c=0,h=a.length;c<h;c++)i.push(s.getDependency("node",a[c]));const o=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([r,Promise.all(i),o]).then(function(c){const h=c[0],d=c[1],p=c[2];p!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(p,Ze)});for(let f=0,m=d.length;f<m;f++)h.add(d[f]);return h})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],i=r.name?n.createUniqueName(r.name):"",a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return o&&a.push(o),r.camera!==void 0&&a.push(n.getDependency("camera",r.camera).then(function(c){return n._getNodeRef(n.cameraCache,r.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new u.Bone:c.length>1?h=new u.Group:c.length===1?h=c[0]:h=new u.Object3D,h!==c[0])for(let d=0,p=c.length;d<p;d++)h.add(c[d]);if(r.name&&(h.userData.name=r.name,h.name=i),C(h,r),r.extensions&&O(s,h,r),r.matrix!==void 0){const d=new u.Matrix4;d.fromArray(r.matrix),h.applyMatrix4(d)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return n.associations.has(h)||n.associations.set(h,{}),n.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,r=new u.Group;s.name&&(r.name=n.createUniqueName(s.name)),C(r,s),s.extensions&&O(t,r,s);const i=s.nodes||[],a=[];for(let o=0,c=i.length;o<c;o++)a.push(n.getDependency("node",i[o]));return Promise.all(a).then(function(o){for(let h=0,d=o.length;h<d;h++)r.add(o[h]);const c=h=>{const d=new Map;for(const[p,f]of n.associations)(p instanceof u.Material||p instanceof u.Texture)&&d.set(p,f);return h.traverse(p=>{const f=n.associations.get(p);f!=null&&d.set(p,f)}),d};return n.associations=c(r),r})}_createAnimationTracks(e,t,s,n,r){const i=[],a=e.name?e.name:e.uuid,o=[];D[r.path]===D.weights?e.traverse(function(p){p.morphTargetInfluences&&o.push(p.name?p.name:p.uuid)}):o.push(a);let c;switch(D[r.path]){case D.weights:c=u.NumberKeyframeTrack;break;case D.rotation:c=u.QuaternionKeyframeTrack;break;case D.position:case D.scale:c=u.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:c=u.NumberKeyframeTrack;break;case 2:case 3:default:c=u.VectorKeyframeTrack;break}break}const h=n.interpolation!==void 0?Xe[n.interpolation]:u.InterpolateLinear,d=this._getArrayFromAccessor(s);for(let p=0,f=o.length;p<f;p++){const m=new c(o[p]+"."+D[r.path],t.array,d,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),i.push(m)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=q(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof u.QuaternionKeyframeTrack?ze:ue;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function tt(l,e,t){const s=e.attributes,n=new u.Box3;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new u.Vector3(o[0],o[1],o[2]),new u.Vector3(c[0],c[1],c[2])),a.normalized){const h=q(N[a.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new u.Vector3,o=new u.Vector3;for(let c=0,h=r.length;c<h;c++){const d=r[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],f=p.min,m=p.max;if(f!==void 0&&m!==void 0){if(o.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),o.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),o.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),p.normalized){const y=q(N[p.componentType]);o.multiplyScalar(y)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}l.boundingBox=n;const i=new u.Sphere;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,l.boundingSphere=i}function le(l,e,t){const s=e.attributes,n=[];function r(i,a){return t.getDependency("accessor",i).then(function(o){l.setAttribute(a,o)})}for(const i in s){const a=Y[i]||i.toLowerCase();a in l.attributes||n.push(r(s[i],a))}if(e.indices!==void 0&&!l.index){const i=t.getDependency("accessor",e.indices).then(function(a){l.setIndex(a)});n.push(i)}return u.ColorManagement.workingColorSpace!==u.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${u.ColorManagement.workingColorSpace}" not supported.`),C(l,e),tt(l,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Ye(l,e.targets,t):l})}var nt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,it=(l,e,t,s)=>{for(var n=s>1?void 0:s?st(e,t):e,r=l.length-1,i;r>=0;r--)(i=l[r])&&(n=(s?i(e,t,n):i(n))||n);return s&&n&&nt(e,t,n),n};let J=class{constructor(){A(this,"loadingManager",new u.LoadingManager);A(this,"loaders",{});A(this,"resources",[]);A(this,"items",{});A(this,"toLoad",0);A(this,"loaded",0)}get videoLoader(){return{load:(l,e)=>{let t=document.createElement("video");t.muted=!0,t.loop=!0,t.controls=!1,t.playsInline=!0,t.src=l,t.autoplay=!0;const s=()=>{if(!t)return;t.play();const n=new u.VideoTexture(t),r=n.dispose.bind(n);n.dispose=()=>{n.userData.element=void 0,t==null||t.remove(),t=void 0,r()},e(n),n.userData.element=t,t.removeEventListener("canplaythrough",s)};t.addEventListener("canplaythrough",s)}}}_setLoaders(){this.loaders.gltfLoader=new _e(this.loadingManager),this.loaders.textureLoader=new u.ImageBitmapLoader(this.loadingManager),this.loaders.cubeTextureLoader=new u.CubeTextureLoader(this.loadingManager),this.loaders.audioLoader=new u.AudioLoader(this.loadingManager),this.loaders.videoLoader=this.videoLoader}setResources(l){this.resources=l,this.toLoad=this.resources.length,this.loaded=0}init(l=[]){this.resources=l,this._setLoaders()}};J=it([ee(w.Lifecycle.ResolutionScoped)],J);var rt=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,at=(l,e,t,s)=>{for(var n=s>1?void 0:s?ot(e,t):e,r=l.length-1,i;r>=0;r--)(i=l[r])&&(n=(s?i(e,t,n):i(n))||n);return s&&n&&rt(e,t,n),n},ce=(l,e)=>(t,s)=>e(t,s,l);exports.LoaderModule=class{constructor(e,t){this.controller=e,this.component=t,typeof self<"u"&&(self.onmessage=s=>{var r;const n=(r=s==null?void 0:s.data)==null?void 0:r.resources;n&&this.init(n)})}_handleLoadedResource(e,t){this.component.items[e.name]=t,this.component.loaded++,this.controller.progress$$.next({file:t,resource:e,loaded:this.component.loaded,toLoad:this.component.toLoad})}setDracoLoader(e,t=!0){this.component.loaders.dracoLoader=new ge(this.component.loadingManager),this.component.loaders.dracoLoader.setDecoderPath(e),t&&this.component.loaders.gltfLoader&&this.component.loaders.gltfLoader.setDRACOLoader(this.component.loaders.dracoLoader)}load(){var t,s,n,r,i;const e=this.component.resources[0];if(e){this.controller.progress$$.next({resource:e,loaded:this.component.loaded,toLoad:this.component.toLoad});for(const a of this.component.resources)this.component.items[a.name]||(a.type==="gltfModel"&&typeof a.path=="string"&&((t=this.component.loaders.gltfLoader)==null||t.load(a.path,o=>this._handleLoadedResource(a,o))),a.type==="texture"&&typeof a.path=="string"&&((s=this.component.loaders.textureLoader)==null||s.load(a.path,o=>{this._handleLoadedResource(a,new u.CanvasTexture(o))})),a.type==="cubeTexture"&&typeof a.path=="object"&&((n=this.component.loaders.cubeTextureLoader)==null||n.load(a.path,o=>this._handleLoadedResource(a,o))),a.type==="video"&&typeof a.path=="string"&&((r=this.component.loaders.videoLoader)==null||r.load(a.path,o=>this._handleLoadedResource(a,o))),a.type==="audio"&&typeof a.path=="string"&&((i=this.component.loaders.audioLoader)==null||i.load(a.path,o=>{this._handleLoadedResource(a,o)})))}}items(){return this.component.items}loaders(){return this.component.loaders}resources(){return this.component.resources}loaded(){return this.component.loaded}toLoad(){return this.component.toLoad}init(e=[]){this.component.init(e)}dispose(){this.controller.lifecycle$$.complete(),this.controller.progress$$.complete()}lifecycle$(){return this.controller.lifecycle$}progress$(){return this.controller.progress$}progressCompleted$(){return this.controller.progressCompleted$}};exports.LoaderModule=at([ee(w.Lifecycle.ResolutionScoped),ce(0,w.inject(W)),ce(1,w.inject(J))],exports.LoaderModule);const lt=w.instance.resolve(exports.LoaderModule);/**
3
- * lil-gui
4
- * https://lil-gui.georgealways.com
5
- * @version 0.17.0
6
- * @author George Michael Brower
7
- * @license MIT
8
- */class M{constructor(e,t,s,n,r="div"){this.parent=e,this.object=t,this.property=s,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement("div"),this.domElement.classList.add("controller"),this.domElement.classList.add(n),this.$name=document.createElement("div"),this.$name.classList.add("name"),M.nextNameID=M.nextNameID||0,this.$name.id="lil-gui-name-"+ ++M.nextNameID,this.$widget=document.createElement(r),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(s)}name(e){return this._name=e,this.$name.innerHTML=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled||(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e)),this}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const t=this.parent.add(this.object,this.property,e);return t.name(this._name),this.destroy(),t}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.object[this.property]=e,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class ct extends M{constructor(e,t,s){super(e,t,s,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function Q(l){let e,t;return(e=l.match(/(#|0x)?([a-f0-9]{6})/i))?t=e[2]:(e=l.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?t=parseInt(e[1]).toString(16).padStart(2,0)+parseInt(e[2]).toString(16).padStart(2,0)+parseInt(e[3]).toString(16).padStart(2,0):(e=l.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(t=e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),!!t&&"#"+t}const ht={isPrimitive:!0,match:l=>typeof l=="string",fromHexString:Q,toHexString:Q},H={isPrimitive:!0,match:l=>typeof l=="number",fromHexString:l=>parseInt(l.substring(1),16),toHexString:l=>"#"+l.toString(16).padStart(6,0)},dt={isPrimitive:!1,match:Array.isArray,fromHexString(l,e,t=1){const s=H.fromHexString(l);e[0]=(s>>16&255)/255*t,e[1]=(s>>8&255)/255*t,e[2]=(255&s)/255*t},toHexString:([l,e,t],s=1)=>H.toHexString(l*(s=255/s)<<16^e*s<<8^t*s<<0)},ut={isPrimitive:!1,match:l=>Object(l)===l,fromHexString(l,e,t=1){const s=H.fromHexString(l);e.r=(s>>16&255)/255*t,e.g=(s>>8&255)/255*t,e.b=(255&s)/255*t},toHexString:({r:l,g:e,b:t},s=1)=>H.toHexString(l*(s=255/s)<<16^e*s<<8^t*s<<0)},pt=[ht,H,dt,ut];class ft extends M{constructor(e,t,s,n){var r;super(e,t,s,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=(r=this.initialValue,pt.find(i=>i.match(r))),this._rgbScale=n,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const i=Q(this.$text.value);i&&this._setValueFromHexString(i)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const t=this._format.fromHexString(e);this.setValue(t)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class z extends M{constructor(e,t,s){super(e,t,s,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",n=>{n.preventDefault(),this.getValue().call(this.object)}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class mt extends M{constructor(e,t,s,n,r,i){super(e,t,s,"number"),this._initInput(),this.min(n),this.max(r);const a=i!==void 0;this.step(a?i:this._getImplicitStep(),a),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,t=!0){return this._step=e,this._stepExplicit=t,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let t=(e-this._min)/(this._max-this._min);t=Math.max(0,Math.min(t,1)),this.$fill.style.width=100*t+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$disable=this.$input;const e=h=>{const d=parseFloat(this.$input.value);isNaN(d)||(this._snapClampSetValue(d+h),this.$input.value=this.getValue())};let t,s,n,r,i,a=!1;const o=h=>{if(a){const d=h.clientX-t,p=h.clientY-s;Math.abs(p)>5?(h.preventDefault(),this.$input.blur(),a=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(d)>5&&c()}if(!a){const d=h.clientY-n;i-=d*this._step*this._arrowKeyMultiplier(h),r+i>this._max?i=this._max-r:r+i<this._min&&(i=this._min-r),this._snapClampSetValue(r+i)}n=h.clientY},c=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",c)};this.$input.addEventListener("input",()=>{let h=parseFloat(this.$input.value);isNaN(h)||(this._stepExplicit&&(h=this._snap(h)),this.setValue(this._clamp(h)))}),this.$input.addEventListener("keydown",h=>{h.code==="Enter"&&this.$input.blur(),h.code==="ArrowUp"&&(h.preventDefault(),e(this._step*this._arrowKeyMultiplier(h))),h.code==="ArrowDown"&&(h.preventDefault(),e(this._step*this._arrowKeyMultiplier(h)*-1))}),this.$input.addEventListener("wheel",h=>{this._inputFocused&&(h.preventDefault(),e(this._step*this._normalizeMouseWheel(h)))},{passive:!1}),this.$input.addEventListener("mousedown",h=>{t=h.clientX,s=n=h.clientY,a=!0,r=this.getValue(),i=0,window.addEventListener("mousemove",o),window.addEventListener("mouseup",c)}),this.$input.addEventListener("focus",()=>{this._inputFocused=!0}),this.$input.addEventListener("blur",()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=p=>{const f=this.$slider.getBoundingClientRect();let m=(y=p,g=f.left,b=f.right,T=this._min,E=this._max,(y-g)/(b-g)*(E-T)+T);var y,g,b,T,E;this._snapClampSetValue(m)},t=p=>{e(p.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",s)};let n,r,i=!1;const a=p=>{p.preventDefault(),this._setDraggingStyle(!0),e(p.touches[0].clientX),i=!1},o=p=>{if(i){const f=p.touches[0].clientX-n,m=p.touches[0].clientY-r;Math.abs(f)>Math.abs(m)?a(p):(window.removeEventListener("touchmove",o),window.removeEventListener("touchend",c))}else p.preventDefault(),e(p.touches[0].clientX)},c=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",o),window.removeEventListener("touchend",c)},h=this._callOnFinishChange.bind(this);let d;this.$slider.addEventListener("mousedown",p=>{this._setDraggingStyle(!0),e(p.clientX),window.addEventListener("mousemove",t),window.addEventListener("mouseup",s)}),this.$slider.addEventListener("touchstart",p=>{p.touches.length>1||(this._hasScrollBar?(n=p.touches[0].clientX,r=p.touches[0].clientY,i=!0):a(p),window.addEventListener("touchmove",o,{passive:!1}),window.addEventListener("touchend",c))},{passive:!1}),this.$slider.addEventListener("wheel",p=>{if(Math.abs(p.deltaX)<Math.abs(p.deltaY)&&this._hasScrollBar)return;p.preventDefault();const f=this._normalizeMouseWheel(p)*this._step;this._snapClampSetValue(this.getValue()+f),this.$input.value=this.getValue(),clearTimeout(d),d=setTimeout(h,400)},{passive:!1})}_setDraggingStyle(e,t="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle("lil-gui-"+t,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:t,deltaY:s}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(t=0,s=-e.wheelDelta/120,s*=this._stepExplicit?1:10),t+-s}_arrowKeyMultiplier(e){let t=this._stepExplicit?1:10;return e.shiftKey?t*=10:e.altKey&&(t/=10),t}_snap(e){const t=Math.round(e/this._step)*this._step;return parseFloat(t.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class gt extends M{constructor(e,t,s,n){super(e,t,s,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(n)?n:Object.values(n),this._names=Array.isArray(n)?n:Object.keys(n),this._names.forEach(r=>{const i=document.createElement("option");i.innerHTML=r,this.$select.appendChild(i)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){const e=this.getValue(),t=this._values.indexOf(e);return this.$select.selectedIndex=t,this.$display.innerHTML=t===-1?e:this._names[t],this}}class At extends M{constructor(e,t,s){super(e,t,s,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",n=>{n.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}let he=!1;class te{constructor({parent:e,autoPlace:t=e===void 0,container:s,width:n,title:r="Controls",injectStyles:i=!0,touchStyles:a=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",o=>{o.code!=="Enter"&&o.code!=="Space"||(o.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(r),a&&this.domElement.classList.add("allow-touch-styles"),this.parent)return this.parent.children.push(this),this.parent.folders.push(this),void this.parent.$children.appendChild(this.domElement);this.domElement.classList.add("root"),!he&&i&&(function(o){const c=document.createElement("style");c.innerHTML=o;const h=document.querySelector("head link[rel=stylesheet], head style");h?document.head.insertBefore(c,h):document.head.appendChild(c)}('.lil-gui{--background-color:#1f1f1f;--text-color:#ebebeb;--title-background-color:#111;--title-text-color:#ebebeb;--widget-color:#424242;--hover-color:#4f4f4f;--focus-color:#595959;--number-color:#2cc9ff;--string-color:#a2db3c;--font-size:11px;--input-font-size:11px;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;--font-family-mono:Menlo,Monaco,Consolas,"Droid Sans Mono",monospace;--padding:4px;--spacing:4px;--widget-height:20px;--name-width:45%;--slider-knob-width:2px;--slider-input-width:27%;--color-input-width:27%;--slider-input-min-width:45px;--color-input-min-width:45px;--folder-indent:7px;--widget-padding:0 0 0 3px;--widget-border-radius:2px;--checkbox-size:calc(var(--widget-height)*0.75);--scrollbar-width:5px;background-color:var(--background-color);color:var(--text-color);font-family:var(--font-family);font-size:var(--font-size);font-style:normal;font-weight:400;line-height:1;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none}.lil-gui,.lil-gui *{box-sizing:border-box;margin:0;padding:0}.lil-gui.root{display:flex;flex-direction:column;width:var(--width,245px)}.lil-gui.root>.title{background:var(--title-background-color);color:var(--title-text-color)}.lil-gui.root>.children{overflow-x:hidden;overflow-y:auto}.lil-gui.root>.children::-webkit-scrollbar{background:var(--background-color);height:var(--scrollbar-width);width:var(--scrollbar-width)}.lil-gui.root>.children::-webkit-scrollbar-thumb{background:var(--focus-color);border-radius:var(--scrollbar-width)}.lil-gui.force-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}.lil-gui.autoPlace{max-height:100%;position:fixed;right:15px;top:0;z-index:1001}.lil-gui .controller{align-items:center;display:flex;margin:var(--spacing) 0;padding:0 var(--padding)}.lil-gui .controller.disabled{opacity:.5}.lil-gui .controller.disabled,.lil-gui .controller.disabled *{pointer-events:none!important}.lil-gui .controller>.name{flex-shrink:0;line-height:var(--widget-height);min-width:var(--name-width);padding-right:var(--spacing);white-space:pre}.lil-gui .controller .widget{align-items:center;display:flex;min-height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.string input{color:var(--string-color)}.lil-gui .controller.boolean .widget{cursor:pointer}.lil-gui .controller.color .display{border-radius:var(--widget-border-radius);height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.color input[type=color]{cursor:pointer;height:100%;opacity:0;width:100%}.lil-gui .controller.color input[type=text]{flex-shrink:0;font-family:var(--font-family-mono);margin-left:var(--spacing);min-width:var(--color-input-min-width);width:var(--color-input-width)}.lil-gui .controller.option select{max-width:100%;opacity:0;position:absolute;width:100%}.lil-gui .controller.option .display{background:var(--widget-color);border-radius:var(--widget-border-radius);height:var(--widget-height);line-height:var(--widget-height);max-width:100%;overflow:hidden;padding-left:.55em;padding-right:1.75em;pointer-events:none;position:relative;word-break:break-all}.lil-gui .controller.option .display.active{background:var(--focus-color)}.lil-gui .controller.option .display:after{bottom:0;content:"↕";font-family:lil-gui;padding-right:.375em;position:absolute;right:0;top:0}.lil-gui .controller.option .widget,.lil-gui .controller.option select{cursor:pointer}.lil-gui .controller.number input{color:var(--number-color)}.lil-gui .controller.number.hasSlider input{flex-shrink:0;margin-left:var(--spacing);min-width:var(--slider-input-min-width);width:var(--slider-input-width)}.lil-gui .controller.number .slider{background-color:var(--widget-color);border-radius:var(--widget-border-radius);cursor:ew-resize;height:var(--widget-height);overflow:hidden;padding-right:var(--slider-knob-width);touch-action:pan-y;width:100%}.lil-gui .controller.number .slider.active{background-color:var(--focus-color)}.lil-gui .controller.number .slider.active .fill{opacity:.95}.lil-gui .controller.number .fill{border-right:var(--slider-knob-width) solid var(--number-color);box-sizing:content-box;height:100%}.lil-gui-dragging .lil-gui{--hover-color:var(--widget-color)}.lil-gui-dragging *{cursor:ew-resize!important}.lil-gui-dragging.lil-gui-vertical *{cursor:ns-resize!important}.lil-gui .title{--title-height:calc(var(--widget-height) + var(--spacing)*1.25);-webkit-tap-highlight-color:transparent;text-decoration-skip:objects;cursor:pointer;font-weight:600;height:var(--title-height);line-height:calc(var(--title-height) - 4px);outline:none;padding:0 var(--padding)}.lil-gui .title:before{content:"▾";display:inline-block;font-family:lil-gui;padding-right:2px}.lil-gui .title:active{background:var(--title-background-color);opacity:.75}.lil-gui.root>.title:focus{text-decoration:none!important}.lil-gui.closed>.title:before{content:"▸"}.lil-gui.closed>.children{opacity:0;transform:translateY(-7px)}.lil-gui.closed:not(.transition)>.children{display:none}.lil-gui.transition>.children{overflow:hidden;pointer-events:none;transition-duration:.3s;transition-property:height,opacity,transform;transition-timing-function:cubic-bezier(.2,.6,.35,1)}.lil-gui .children:empty:before{content:"Empty";display:block;font-style:italic;height:var(--widget-height);line-height:var(--widget-height);margin:var(--spacing) 0;opacity:.5;padding:0 var(--padding)}.lil-gui.root>.children>.lil-gui>.title{border-width:0;border-bottom:1px solid var(--widget-color);border-left:0 solid var(--widget-color);border-right:0 solid var(--widget-color);border-top:1px solid var(--widget-color);transition:border-color .3s}.lil-gui.root>.children>.lil-gui.closed>.title{border-bottom-color:transparent}.lil-gui+.controller{border-top:1px solid var(--widget-color);margin-top:0;padding-top:var(--spacing)}.lil-gui .lil-gui .lil-gui>.title{border:none}.lil-gui .lil-gui .lil-gui>.children{border:none;border-left:2px solid var(--widget-color);margin-left:var(--folder-indent)}.lil-gui .lil-gui .controller{border:none}.lil-gui input{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:0;border-radius:var(--widget-border-radius);color:var(--text-color);font-family:var(--font-family);font-size:var(--input-font-size);height:var(--widget-height);outline:none;width:100%}.lil-gui input:disabled{opacity:1}.lil-gui input[type=number],.lil-gui input[type=text]{padding:var(--widget-padding)}.lil-gui input[type=number]:focus,.lil-gui input[type=text]:focus{background:var(--focus-color)}.lil-gui input::-webkit-inner-spin-button,.lil-gui input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.lil-gui input[type=number]{-moz-appearance:textfield}.lil-gui input[type=checkbox]{appearance:none;-webkit-appearance:none;border-radius:var(--widget-border-radius);cursor:pointer;height:var(--checkbox-size);text-align:center;width:var(--checkbox-size)}.lil-gui input[type=checkbox]:checked:before{content:"✓";font-family:lil-gui;font-size:var(--checkbox-size);line-height:var(--checkbox-size)}.lil-gui button{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:1px solid var(--widget-color);border-radius:var(--widget-border-radius);color:var(--text-color);cursor:pointer;font-family:var(--font-family);font-size:var(--font-size);height:var(--widget-height);line-height:calc(var(--widget-height) - 4px);outline:none;text-align:center;text-transform:none;width:100%}.lil-gui button:active{background:var(--focus-color)}@font-face{font-family:lil-gui;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff")}@media (pointer:coarse){.lil-gui.allow-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}}@media (hover:hover){.lil-gui .controller.color .display:hover:before{border:1px solid #fff9;border-radius:var(--widget-border-radius);bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0}.lil-gui .controller.option .display.focus{background:var(--focus-color)}.lil-gui .controller.option .widget:hover .display{background:var(--hover-color)}.lil-gui .controller.number .slider:hover{background-color:var(--hover-color)}body:not(.lil-gui-dragging) .lil-gui .title:hover{background:var(--title-background-color);opacity:.85}.lil-gui .title:focus{text-decoration:underline var(--focus-color)}.lil-gui input:hover{background:var(--hover-color)}.lil-gui input:active{background:var(--focus-color)}.lil-gui input[type=checkbox]:focus{box-shadow:inset 0 0 0 1px var(--focus-color)}.lil-gui button:hover{background:var(--hover-color);border-color:var(--hover-color)}.lil-gui button:focus{border-color:var(--focus-color)}}'),he=!0),s?s.appendChild(this.domElement):t&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),n&&this.domElement.style.setProperty("--width",n+"px"),this.domElement.addEventListener("keydown",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.stopPropagation())}add(e,t,s,n,r){if(Object(s)===s)return new gt(this,e,t,s);const i=e[t];switch(typeof i){case"number":return new mt(this,e,t,s,n,r);case"boolean":return new ct(this,e,t);case"string":return new At(this,e,t);case"function":return new z(this,e,t)}console.error(`gui.add failed
9
- property:`,t,`
10
- object:`,e,`
11
- value:`,i)}addColor(e,t,s=1){return new ft(this,e,t,s)}addFolder(e){return new te({parent:this,title:e})}load(e,t=!0){return e.controllers&&this.controllers.forEach(s=>{s instanceof z||s._name in e.controllers&&s.load(e.controllers[s._name])}),t&&e.folders&&this.folders.forEach(s=>{s._title in e.folders&&s.load(e.folders[s._title])}),this}save(e=!0){const t={controllers:{},folders:{}};return this.controllers.forEach(s=>{if(!(s instanceof z)){if(s._name in t.controllers)throw new Error(`Cannot save GUI with duplicate property "${s._name}"`);t.controllers[s._name]=s.save()}}),e&&this.folders.forEach(s=>{if(s._title in t.folders)throw new Error(`Cannot save GUI with duplicate folder "${s._title}"`);t.folders[s._title]=s.save()}),t}open(e=!0){return this._closed=!e,this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._closed=!e,this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const t=this.$children.clientHeight;this.$children.style.height=t+"px",this.domElement.classList.add("transition");const s=r=>{r.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",s))};this.$children.addEventListener("transitionend",s);const n=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=n+"px"})}),this}title(e){return this._title=e,this.$title.innerHTML=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(t=>t.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(t=>{e=e.concat(t.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(t=>{e=e.concat(t.foldersRecursive())}),e}}var bt=Object.defineProperty,yt=Object.getOwnPropertyDescriptor,wt=(l,e,t,s)=>{for(var n=s>1?void 0:s?yt(e,t):e,r=l.length-1,i;r>=0;r--)(i=l[r])&&(n=(s?i(e,t,n):i(n))||n);return s&&n&&bt(e,t,n),n};let B=class{constructor(){A(this,"workerPool",L.createWorkerPool());A(this,"canvas");A(this,"worker");A(this,"thread");A(this,"gui");A(this,"stats")}init(l){this.worker=l.worker,this.thread=l.thread,this.gui=new te,this.stats=se&&new se,this.stats.showPanel(0),window&&(window.document.body.appendChild(this.stats.dom),window.innerWidth<=450&&this.gui.close())}};B=wt([w.singleton()],B);var _t=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,xt=(l,e,t,s)=>{for(var n=s>1?void 0:s?Tt(e,t):e,r=l.length-1,i;r>=0;r--)(i=l[r])&&(n=(s?i(e,t,n):i(n))||n);return s&&n&&_t(e,t,n),n},Et=(l,e)=>(t,s)=>e(t,s,l);let Z=class extends w.ProxyEventHandlersModel{constructor(e){super();A(this,"canvas");A(this,"lifecycle$$",new k.Subject);A(this,"lifecycle$",this.lifecycle$$.pipe());this.component=e}init(e){this.canvas=e;for(const t of w.PROXY_EVENT_LISTENERS){const s=t.startsWith("mouse")||t.startsWith("pointer")||t.startsWith("touch")?this.mouseEventHandler:t.startsWith("key")?this.keyEventHandler:t==="resize"?this.uiEventHandler:t==="wheel"?this.wheelEventHandler:this.preventDefaultHandler;this[`${t}$`]=k.fromEvent(t==="resize"?window:e,t).pipe(k.map(s.bind(this)),k.filter(n=>!(t==="keydown"&&!n))),this[`${t}$`].subscribe(n=>{var r,i;(i=(r=this.component.thread)==null?void 0:r[t])==null||i.call(r,n)})}}preventDefaultHandler(e){return e.preventDefault(),{type:e.type}}getScreenSizes(){return{width:this.canvas.width,height:this.canvas.height,windowWidth:(window==null?void 0:window.innerWidth)??0,windowHeight:(window==null?void 0:window.innerHeight)??0}}uiEventHandler(e){const t=this.canvas.getBoundingClientRect();return{...this.getScreenSizes(),type:e.type,top:t.top,left:t.left}}mouseEventHandler(e){return{...this.getScreenSizes(),...L.copyProperties(e,["ctrlKey","metaKey","shiftKey","button","pointerType","clientX","clientY","pageX","pageY"])}}touchEventHandler(e){const t=[],s={type:e.type,touches:t};for(let n=0;n<e.touches.length;++n){const r=e.touches[n];t.push({pageX:(r==null?void 0:r.pageX)??0,pageY:(r==null?void 0:r.pageY)??0})}return{...this.getScreenSizes(),...s}}wheelEventHandler(e){return e.preventDefault(),{...this.getScreenSizes(),...L.copyProperties(e,["deltaX","deltaY"])}}keyEventHandler(e){if(w.KEYBOARD_EVENT_CODES.includes(e.code))return e.preventDefault(),{...this.getScreenSizes(),...L.copyProperties(e,["ctrlKey","metaKey","shiftKey","keyCode"])}}};Z=xt([w.singleton(),Et(0,w.inject(B))],Z);class ne{constructor(){A(this,"location");A(this,"canvas");A(this,"fullScreen");A(this,"defaultCamera");A(this,"startTimer");A(this,"enableDebug");A(this,"axesSizes");A(this,"gridSizes");A(this,"withMiniCamera");A(this,"onReady")}}class pe{constructor(){A(this,"contextmenu$");A(this,"resize$");A(this,"mousedown$");A(this,"mousemove$");A(this,"mouseup$");A(this,"pointerdown$");A(this,"pointermove$");A(this,"pointercancel$");A(this,"pointerup$");A(this,"touchstart$");A(this,"touchmove$");A(this,"touchend$");A(this,"wheel$");A(this,"keydown$")}}var vt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,St=(l,e,t,s)=>{for(var n=s>1?void 0:s?Lt(e,t):e,r=l.length-1,i;r>=0;r--)(i=l[r])&&(n=(s?i(e,t,n):i(n))||n);return s&&n&&vt(e,t,n),n},X=(l,e)=>(t,s)=>e(t,s,l);exports.RegisterModule=class extends pe{constructor(e,t,s){super(),this.component=e,this.controller=t,this.registerProps=s,this.init()}async _initCanvas(){try{if(this.component.canvas=document.createElement("canvas"),this.registerProps.canvas instanceof HTMLCanvasElement&&(this.component.canvas=this.registerProps.canvas),typeof this.registerProps.canvas=="string"){const e=document.querySelector(this.registerProps.canvas);e instanceof HTMLCanvasElement&&(this.component.canvas=e)}this.component.canvas.parentElement||document.body.appendChild(this.component.canvas)}catch(e){console.error(`🛑 Unable to initialize the canvas:
12
- ${(e==null?void 0:e.message)??"Something went wrong"}`)}}async _initComponent(){this.component.init({worker:this.component.worker,thread:this.component.thread})}async _initController(){var e,t,s;this.controller.init(this.component.canvas),!(!this.component.thread||!this.component.worker)&&((t=(e=this.component.thread)==null?void 0:e.resize)==null||t.call(e,{...this.controller.uiEventHandler({type:"resize"})}),(s=this.component.thread)==null||s.lifecycle$().subscribe(n=>{var r,i;n===w.AppLifecycleState.STEP_STARTED&&((r=this.component.stats)==null||r.begin()),n===w.AppLifecycleState.STEP_ENDED&&((i=this.component.stats)==null||i.end())}))}async _initWorkerThread(){const e=this.component.canvas.transferControlToOffscreen();e.width=this.component.canvas.clientWidth,e.height=this.component.canvas.clientHeight;const t=await this.component.workerPool.run({payload:{path:this.registerProps.location,subject:{...L.excludeProperties(this.registerProps,["canvas","location","onReady"]),canvas:e},transferSubject:[e]}});if(!t.thread||!t.worker)throw new Error("Unable to retrieve app worker info.");this.component.worker=t.worker,this.component.thread=t.thread}async _initProxyEvents(){w.PROXY_EVENT_LISTENERS.forEach(e=>this[`${e}$`]=()=>{var t;return(t=this.controller)==null?void 0:t[`${e}$`]})}async init(){var e,t;await this._initCanvas(),await this._initWorkerThread(),await this._initComponent(),await this._initController(),await this._initProxyEvents(),this.controller.lifecycle$$.next(w.RegisterLifecycleState.INITIALIZED),(t=(e=this.registerProps).onReady)==null||t.call(e,this)}async loadResources(e){var s,n,r,i,a,o,c,h,d;const t=await this.component.workerPool.run({payload:{path:"../loader/loader.module-worker.ts",subject:{resources:e.resources}}});return(s=t.thread)==null||s.progress$().subscribe(p=>{var f;(f=e.onProgress)==null||f.call(e,p)}),(n=t.thread)==null||n.progressCompleted$().subscribe(p=>{var f,m;(f=e.onProgressComplete)==null||f.call(e,p),(e.disposeOnComplete||e.disposeOnComplete===void 0)&&((m=t.thread)==null||m.dispose())}),(e.immediateLoad||e.immediateLoad===void 0)&&await((r=t.thread)==null?void 0:r.load()),{...t,load:await((i=t.thread)==null?void 0:i.load),items:await((a=t.thread)==null?void 0:a.items()),loaders:await((o=t.thread)==null?void 0:o.items()),toLoad:await((c=t.thread)==null?void 0:c.toLoad()),loaded:await((h=t.thread)==null?void 0:h.loaded()),resources:await((d=t.thread)==null?void 0:d.resources())}}workerPool(){return this.component.workerPool}canvas(){return this.component.canvas}worker(){return this.component.worker}thread(){return this.component.thread}gui(){return this.component.gui}dispose(){this.component.workerPool.terminateAll(),this.controller.lifecycle$$.next(w.RegisterLifecycleState.DISPOSED)}lifecycle$(){return this.controller.lifecycle$}};exports.RegisterModule=St([w.singleton(),X(0,w.inject(B)),X(1,w.inject(Z)),X(2,w.inject(ne))],exports.RegisterModule);const Rt=l=>{if(typeof(l==null?void 0:l.location)!="string"&&!((l==null?void 0:l.location)instanceof URL))throw new Error("Invalid register props detected. location path is required");return l.defaultCamera=l!=null&&l.defaultCamera&&l.defaultCamera in w.DefaultCameraType?l.defaultCamera:w.DefaultCameraType.PERSPECTIVE,l.withMiniCamera=L.isUndefined(l.withMiniCamera)||!L.isBoolean(l.withMiniCamera)?!1:l.withMiniCamera,l.startTimer=L.isUndefined(l.startTimer)||!L.isBoolean(l.startTimer)?!0:l.startTimer,l.fullScreen=L.isUndefined(l.fullScreen)||!L.isBoolean(l.fullScreen)?!0:l.fullScreen,l.onReady=L.isFunction(l.onReady)?l.onReady:void 0,w.instance.register(ne,{useValue:l}),w.instance.resolve(exports.RegisterModule)};class Mt{constructor(){A(this,"onReady")}}exports.AppLifecycleState=w.AppLifecycleState;Object.defineProperty(exports,"AppModule",{enumerable:!0,get:()=>w.AppModule});exports.AppProxyEventHandlersModel=w.AppProxyEventHandlersModel;exports.DefaultCameraType=w.DefaultCameraType;exports.KEYBOARD_EVENT_CODES=w.KEYBOARD_EVENT_CODES;exports.PROXY_EVENT_LISTENERS=w.PROXY_EVENT_LISTENERS;exports.ProxyEventHandlersModel=w.ProxyEventHandlersModel;exports.ProxyEventObservablesModel=w.ProxyEventObservablesModel;exports.ProxyEventSubjectsModel=w.ProxyEventSubjectsModel;exports.RegisterLifecycleState=w.RegisterLifecycleState;exports.appModule=w.appModule;exports.LaunchAppProps=Mt;exports.RegisterPropsModel=ne;exports.RegisterProxyEventHandlersModel=pe;exports.loaderModule=lt;exports.register=Rt;
1
+ "use strict";var ae=Object.defineProperty;var ce=(c,t,e)=>t in c?ae(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var y=(c,t,e)=>ce(c,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./app.module-jsu6itlh.js"),h=require("three");class le{constructor(){y(this,"onReady")}}class q{constructor(){y(this,"location");y(this,"initOnConstruct");y(this,"canvas");y(this,"fullScreen");y(this,"defaultCamera");y(this,"startTimer");y(this,"enableDebug");y(this,"axesSizes");y(this,"gridSizes");y(this,"withMiniCamera");y(this,"onReady")}}class se{constructor(){y(this,"contextmenu$");y(this,"resize$");y(this,"mousedown$");y(this,"mousemove$");y(this,"mouseup$");y(this,"pointerdown$");y(this,"pointermove$");y(this,"pointercancel$");y(this,"pointerup$");y(this,"touchstart$");y(this,"touchmove$");y(this,"touchend$");y(this,"wheel$");y(this,"keydown$")}}var ue=Array.isArray;function de(c,t){return ue(t)?c.apply(void 0,m.__spreadArray([],m.__read(t))):c(t)}function he(c){return m.map(function(t){return de(c,t)})}function fe(c,t,e,s,n,i,r,a){var o=[],l=0,u=0,d=!1,f=function(){d&&!o.length&&!l&&t.complete()},p=function(T){return l<s?g(T):o.push(T)},g=function(T){l++;var A=!1;m.innerFrom(e(T,u++)).subscribe(m.createOperatorSubscriber(t,function(_){t.next(_)},function(){A=!0},void 0,function(){if(A)try{l--;for(var _=function(){var R=o.shift();r||g(R)};o.length&&l<s;)_();f()}catch(R){t.error(R)}}))};return c.subscribe(m.createOperatorSubscriber(t,p,function(){d=!0,f()})),function(){}}function re(c,t,e){return e===void 0&&(e=1/0),m.isFunction(t)?re(function(s,n){return m.map(function(i,r){return t(s,i,n,r)})(m.innerFrom(c(s,n)))},e):(typeof t=="number"&&(e=t),m.operate(function(s,n){return fe(s,n,c,e)}))}var pe=["addListener","removeListener"],me=["addEventListener","removeEventListener"],ge=["on","off"];function K(c,t,e,s){if(m.isFunction(e)&&(s=e,e=void 0),s)return K(c,t,e).pipe(he(s));var n=m.__read(_e(c)?me.map(function(a){return function(o){return c[a](t,o,e)}}):Ae(c)?pe.map(Y(c,t)):Te(c)?ge.map(Y(c,t)):[],2),i=n[0],r=n[1];if(!i&&m.isArrayLike(c))return re(function(a){return K(a,t,e)})(m.innerFrom(c));if(!i)throw new TypeError("Invalid event target");return new m.Observable(function(a){var o=function(){for(var l=[],u=0;u<arguments.length;u++)l[u]=arguments[u];return a.next(1<l.length?l:l[0])};return i(o),function(){return r(o)}})}function Y(c,t){return function(e){return function(s){return c[e](t,s)}}}function Ae(c){return m.isFunction(c.addListener)&&m.isFunction(c.removeListener)}function Te(c){return m.isFunction(c.on)&&m.isFunction(c.off)}function _e(c){return m.isFunction(c.addEventListener)&&m.isFunction(c.removeEventListener)}const B=new WeakMap;class ye extends h.Loader{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,s,n){const i=new h.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(t,r=>{this.parse(r,e,n)},s,n)}parse(t,e,s=()=>{}){this.decodeDracoFile(t,e,null,null,h.SRGBColorSpace,s).catch(s)}decodeDracoFile(t,e,s,n,i=h.LinearSRGBColorSpace,r=()=>{}){const a={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:i};return this.decodeGeometry(t,a).then(e).catch(r)}decodeGeometry(t,e){const s=JSON.stringify(e);if(B.has(t)){const o=B.get(t);if(o.key===s)return o.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const i=this.workerNextTaskID++,r=t.byteLength,a=this._getWorker(i,r).then(o=>(n=o,new Promise((l,u)=>{n._callbacks[i]={resolve:l,reject:u},n.postMessage({type:"decode",id:i,taskConfig:e,buffer:t},[t])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{n&&i&&this._releaseTask(n,i)}),B.set(t,{key:s,promise:a}),a}_createGeometry(t){const e=new h.BufferGeometry;t.index&&e.setIndex(new h.BufferAttribute(t.index.array,1));for(let s=0;s<t.attributes.length;s++){const n=t.attributes[s],i=n.name,r=n.array,a=n.itemSize,o=new h.BufferAttribute(r,a);i==="color"&&(this._assignVertexColorSpace(o,n.vertexColorSpace),o.normalized=!(r instanceof Float32Array)),e.setAttribute(i,o)}return e}_assignVertexColorSpace(t,e){if(e!==h.SRGBColorSpace)return;const s=new h.Color;for(let n=0,i=t.count;n<i;n++)s.fromBufferAttribute(t,n),h.ColorManagement.toWorkingColorSpace(s,h.SRGBColorSpace),t.setXYZ(n,s.r,s.g,s.b)}_loadLibrary(t,e){const s=new h.FileLoader(this.manager);return s.setPath(this.decoderPath),s.setResponseType(e),s.setWithCredentials(this.withCredentials),new Promise((n,i)=>{s.load(t,n,void 0,i)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(s=>{const n=s[0];t||(this.decoderConfig.wasmBinary=s[1]);const i=Ee.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
2
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(i){const r=i.data;switch(r.type){case"decode":n._callbacks[r.id].resolve(r);break;case"error":n._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,i){return n._taskLoad>i._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[t]=e,s._taskLoad+=e,s})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Ee(){let c,t;onmessage=function(r){const a=r.data;switch(a.type){case"init":c=a.decoderConfig,t=new Promise(function(u){c.onModuleLoaded=function(d){u({draco:d})},DracoDecoderModule(c)});break;case"decode":const o=a.buffer,l=a.taskConfig;t.then(u=>{const d=u.draco,f=new d.Decoder;try{const p=e(d,f,new Int8Array(o),l),g=p.attributes.map(T=>T.array.buffer);p.index&&g.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},g)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{d.destroy(f)}});break}};function e(r,a,o,l){const u=l.attributeIDs,d=l.attributeTypes;let f,p;const g=a.GetEncodedGeometryType(o);if(g===r.TRIANGULAR_MESH)f=new r.Mesh,p=a.DecodeArrayToMesh(o,o.byteLength,f);else if(g===r.POINT_CLOUD)f=new r.PointCloud,p=a.DecodeArrayToPointCloud(o,o.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const T={index:null,attributes:[]};for(const A in u){const _=self[d[A]];let R,w;if(l.useUniqueIDs)w=u[A],R=a.GetAttributeByUniqueId(f,w);else{if(w=a.GetAttributeId(f,r[u[A]]),w===-1)continue;R=a.GetAttribute(f,w)}const L=n(r,a,f,A,_,R);A==="color"&&(L.vertexColorSpace=l.vertexColorSpace),T.attributes.push(L)}return g===r.TRIANGULAR_MESH&&(T.index=s(r,a,f)),r.destroy(f),T}function s(r,a,o){const u=o.num_faces()*3,d=u*4,f=r._malloc(d);a.GetTrianglesUInt32Array(o,d,f);const p=new Uint32Array(r.HEAPF32.buffer,f,u).slice();return r._free(f),{array:p,itemSize:1}}function n(r,a,o,l,u,d){const f=d.num_components(),g=o.num_points()*f,T=g*u.BYTES_PER_ELEMENT,A=i(r,u),_=r._malloc(T);a.GetAttributeDataArrayForAllPoints(o,d,A,T,_);const R=new u(r.HEAPF32.buffer,_,g).slice();return r._free(_),{name:l,array:R,itemSize:f}}function i(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}var Re=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,we=(c,t,e,s)=>{for(var n=s>1?void 0:s?Le(t,e):t,i=c.length-1,r;i>=0;i--)(r=c[i])&&(n=(s?r(t,e,n):r(n))||n);return s&&n&&Re(t,e,n),n};let V=class{constructor(){y(this,"progress$$",new m.Subject);y(this,"progress$",this.progress$$.pipe());y(this,"progressCompleted$",this.progress$.pipe(m.filter(c=>c.toLoad===c.loaded)))}};V=we([m.scoped(m.Lifecycle.ResolutionScoped)],V);function Q(c,t){if(t===h.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),c;if(t===h.TriangleFanDrawMode||t===h.TriangleStripDrawMode){let e=c.getIndex();if(e===null){const r=[],a=c.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)r.push(o);c.setIndex(r),e=c.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),c}const s=e.count-2,n=[];if(t===h.TriangleFanDrawMode)for(let r=1;r<=s;r++)n.push(e.getX(0)),n.push(e.getX(r)),n.push(e.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(n.push(e.getX(r)),n.push(e.getX(r+1)),n.push(e.getX(r+2))):(n.push(e.getX(r+2)),n.push(e.getX(r+1)),n.push(e.getX(r)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=c.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),c}class xe extends h.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new Ce(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new je(e)}),this.register(function(e){return new Pe(e)}),this.register(function(e){return new Ne(e)}),this.register(function(e){return new De(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Fe(e)}),this.register(function(e){return new Ie(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new He(e)}),this.register(function(e){return new Me(e)}),this.register(function(e){return new Ke(e)}),this.register(function(e){return new Ve(e)})}load(t,e,s,n){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const l=h.LoaderUtils.extractUrlBase(t);r=h.LoaderUtils.resolveURL(l,this.path)}else r=h.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(l){n?n(l):console.error(l),i.manager.itemError(t),i.manager.itemEnd(t)},o=new h.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(l){try{i.parse(l,r,function(u){e(u),i.manager.itemEnd(t)},a)}catch(u){a(u)}},s,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,n){let i;const r={},a={},o=new TextDecoder;if(typeof t=="string")i=JSON.parse(t);else if(t instanceof ArrayBuffer)if(o.decode(new Uint8Array(t,0,4))===ie){try{r[E.KHR_BINARY_GLTF]=new Xe(t)}catch(d){n&&n(d);return}i=JSON.parse(r[E.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(t));else i=t;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new rt(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](l);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,r[d.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const d=i.extensionsUsed[u],f=i.extensionsRequired||[];switch(d){case E.KHR_MATERIALS_UNLIT:r[d]=new be;break;case E.KHR_DRACO_MESH_COMPRESSION:r[d]=new ze(i,this.dracoLoader);break;case E.KHR_TEXTURE_TRANSFORM:r[d]=new $e;break;case E.KHR_MESH_QUANTIZATION:r[d]=new We;break;default:f.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}l.setExtensions(r),l.setPlugins(a),l.parse(s,n)}parseAsync(t,e){const s=this;return new Promise(function(n,i){s.parse(t,e,n,i)})}}function Se(){let c={};return{get:function(t){return c[t]},add:function(t,e){c[t]=e},remove:function(t){delete c[t]},removeAll:function(){c={}}}}const E={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Me{constructor(t){this.parser=t,this.name=E.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,n=e.length;s<n;s++){const i=e[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,s="light:"+t;let n=e.cache.get(s);if(n)return n;const i=e.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let l;const u=new h.Color(16777215);o.color!==void 0&&u.setRGB(o.color[0],o.color[1],o.color[2],h.LinearSRGBColorSpace);const d=o.range!==void 0?o.range:0;switch(o.type){case"directional":l=new h.DirectionalLight(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new h.PointLight(u),l.distance=d;break;case"spot":l=new h.SpotLight(u),l.distance=d,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,l.angle=o.spot.outerConeAngle,l.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return l.position.set(0,0,0),l.decay=2,b(l,o),o.intensity!==void 0&&(l.intensity=o.intensity),l.name=e.createUniqueName(o.name||"light_"+t),n=Promise.resolve(l),e.cache.add(s,n),n}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,s=this.parser,i=s.json.nodes[t],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return s._getNodeRef(e.cache,a,o)})}}class be{constructor(){this.name=E.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(t,e,s){const n=[];t.color=new h.Color(1,1,1),t.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;t.color.setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),t.opacity=r[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(t,"map",i.baseColorTexture,h.SRGBColorSpace))}return Promise.all(n)}}class ve{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(e.emissiveIntensity=i),Promise.resolve()}}class Ce{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];if(r.clearcoatFactor!==void 0&&(e.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(s.assignTexture(e,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(e,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(e,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new h.Vector2(a,a)}return Promise.all(i)}}class Oe{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_DISPERSION}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Ie{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.iridescenceFactor!==void 0&&(e.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&i.push(s.assignTexture(e,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(e.iridescenceIOR=r.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(e,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class Pe{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_SHEEN}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];e.sheenColor=new h.Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const r=n.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(s.assignTexture(e,"sheenColorMap",r.sheenColorTexture,h.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(e,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(i)}}class Ne{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.transmissionFactor!==void 0&&(e.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&i.push(s.assignTexture(e,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class De{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_VOLUME}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];e.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&i.push(s.assignTexture(e,"thicknessMap",r.thicknessTexture)),e.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return e.attenuationColor=new h.Color().setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace),Promise.all(i)}}class ke{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_IOR}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Fe{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_SPECULAR}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];e.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&i.push(s.assignTexture(e,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return e.specularColor=new h.Color().setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&i.push(s.assignTexture(e,"specularColorMap",r.specularColorTexture,h.SRGBColorSpace)),Promise.all(i)}}class He{constructor(t){this.parser=t,this.name=E.EXT_MATERIALS_BUMP}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return e.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&i.push(s.assignTexture(e,"bumpMap",r.bumpTexture)),Promise.all(i)}}class Be{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.anisotropyStrength!==void 0&&(e.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(e.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&i.push(s.assignTexture(e,"anisotropyMap",r.anisotropyTexture)),Promise.all(i)}}class Ge{constructor(t){this.parser=t,this.name=E.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,s=e.json,n=s.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],r=e.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,i.source,r)}}class Ue{constructor(t){this.parser=t,this.name=E.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,s=this.parser,n=s.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=n.images[r.source];let o=s.textureLoader;if(a.uri){const l=s.options.manager.getHandler(a.uri);l!==null&&(o=l)}return this.detectSupport().then(function(l){if(l)return s.loadTextureImage(t,r.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class je{constructor(t){this.parser=t,this.name=E.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,s=this.parser,n=s.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=n.images[r.source];let o=s.textureLoader;if(a.uri){const l=s.options.manager.getHandler(a.uri);l!==null&&(o=l)}return this.detectSupport().then(function(l){if(l)return s.loadTextureImage(t,r.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Ke{constructor(t){this.name=E.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,s=e.bufferViews[t];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const o=n.byteOffset||0,l=n.byteLength||0,u=n.count,d=n.byteStride,f=new Uint8Array(a,o,l);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(u,d,f,n.mode,n.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(u*d);return r.decodeGltfBuffer(new Uint8Array(p),u,d,f,n.mode,n.filter),p})})}else return null}}class Ve{constructor(t){this.name=E.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,s=e.nodes[t];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=e.meshes[s.mesh];for(const l of n.primitives)if(l.mode!==x.TRIANGLES&&l.mode!==x.TRIANGLE_STRIP&&l.mode!==x.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],o={};for(const l in r)a.push(this.parser.getDependency("accessor",r[l]).then(u=>(o[l]=u,o[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(l=>{const u=l.pop(),d=u.isGroup?u.children:[u],f=l[0].count,p=[];for(const g of d){const T=new h.Matrix4,A=new h.Vector3,_=new h.Quaternion,R=new h.Vector3(1,1,1),w=new h.InstancedMesh(g.geometry,g.material,f);for(let L=0;L<f;L++)o.TRANSLATION&&A.fromBufferAttribute(o.TRANSLATION,L),o.ROTATION&&_.fromBufferAttribute(o.ROTATION,L),o.SCALE&&R.fromBufferAttribute(o.SCALE,L),w.setMatrixAt(L,T.compose(A,_,R));for(const L in o)if(L==="_COLOR_0"){const M=o[L];w.instanceColor=new h.InstancedBufferAttribute(M.array,M.itemSize,M.normalized)}else L!=="TRANSLATION"&&L!=="ROTATION"&&L!=="SCALE"&&g.geometry.setAttribute(L,o[L]);h.Object3D.prototype.copy.call(w,g),this.parser.assignFinalMaterial(w),p.push(w)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}}const ie="glTF",D=12,J={JSON:1313821514,BIN:5130562};class Xe{constructor(t){this.name=E.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,D),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==ie)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-D,i=new DataView(t,D);let r=0;for(;r<n;){const a=i.getUint32(r,!0);r+=4;const o=i.getUint32(r,!0);if(r+=4,o===J.JSON){const l=new Uint8Array(t,D+r,a);this.content=s.decode(l)}else if(o===J.BIN){const l=D+r;this.body=t.slice(l,l+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ze{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=E.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const s=this.json,n=this.dracoLoader,i=t.extensions[this.name].bufferView,r=t.extensions[this.name].attributes,a={},o={},l={};for(const u in r){const d=X[u]||u.toLowerCase();a[d]=r[u]}for(const u in t.attributes){const d=X[u]||u.toLowerCase();if(r[u]!==void 0){const f=s.accessors[t.attributes[u]],p=P[f.componentType];l[d]=p.name,o[d]=f.normalized===!0}}return e.getDependency("bufferView",i).then(function(u){return new Promise(function(d,f){n.decodeDracoFile(u,function(p){for(const g in p.attributes){const T=p.attributes[g],A=o[g];A!==void 0&&(T.normalized=A)}d(p)},a,l,h.LinearSRGBColorSpace,f)})})}}class $e{constructor(){this.name=E.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class We{constructor(){this.name=E.KHR_MESH_QUANTIZATION}}class oe extends h.Interpolant{constructor(t,e,s,n){super(t,e,s,n)}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=t*n*3+n;for(let r=0;r!==n;r++)e[r]=s[i+r];return e}interpolate_(t,e,s,n){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=a*2,l=a*3,u=n-e,d=(s-e)/u,f=d*d,p=f*d,g=t*l,T=g-l,A=-2*p+3*f,_=p-f,R=1-A,w=_-f+d;for(let L=0;L!==a;L++){const M=r[T+L+a],v=r[T+L+o]*u,S=r[g+L+a],N=r[g+L]*u;i[L]=R*M+w*v+A*S+_*N}return i}}const qe=new h.Quaternion;class Ye extends oe{interpolate_(t,e,s,n){const i=super.interpolate_(t,e,s,n);return qe.fromArray(i).normalize().toArray(i),i}}const x={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},P={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Z={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},ee={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},G={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},O={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Qe={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},U={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Je(c){return c.DefaultMaterial===void 0&&(c.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),c.DefaultMaterial}function I(c,t,e){for(const s in e.extensions)c[s]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=e.extensions[s])}function b(c,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(c.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Ze(c,t,e){let s=!1,n=!1,i=!1;for(let l=0,u=t.length;l<u;l++){const d=t[l];if(d.POSITION!==void 0&&(s=!0),d.NORMAL!==void 0&&(n=!0),d.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(c);const r=[],a=[],o=[];for(let l=0,u=t.length;l<u;l++){const d=t[l];if(s){const f=d.POSITION!==void 0?e.getDependency("accessor",d.POSITION):c.attributes.position;r.push(f)}if(n){const f=d.NORMAL!==void 0?e.getDependency("accessor",d.NORMAL):c.attributes.normal;a.push(f)}if(i){const f=d.COLOR_0!==void 0?e.getDependency("accessor",d.COLOR_0):c.attributes.color;o.push(f)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o)]).then(function(l){const u=l[0],d=l[1],f=l[2];return s&&(c.morphAttributes.position=u),n&&(c.morphAttributes.normal=d),i&&(c.morphAttributes.color=f),c.morphTargetsRelative=!0,c})}function et(c,t){if(c.updateMorphTargets(),t.weights!==void 0)for(let e=0,s=t.weights.length;e<s;e++)c.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(c.morphTargetInfluences.length===e.length){c.morphTargetDictionary={};for(let s=0,n=e.length;s<n;s++)c.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function tt(c){let t;const e=c.extensions&&c.extensions[E.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+j(e.attributes):t=c.indices+":"+j(c.attributes)+":"+c.mode,c.targets!==void 0)for(let s=0,n=c.targets.length;s<n;s++)t+=":"+j(c.targets[s]);return t}function j(c){let t="";const e=Object.keys(c).sort();for(let s=0,n=e.length;s<n;s++)t+=e[s]+":"+c[e[s]]+";";return t}function z(c){switch(c){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function nt(c){return c.search(/\.jpe?g($|\?)/i)>0||c.search(/^data\:image\/jpeg/)===0?"image/jpeg":c.search(/\.webp($|\?)/i)>0||c.search(/^data\:image\/webp/)===0?"image/webp":c.search(/\.ktx2($|\?)/i)>0||c.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const st=new h.Matrix4;class rt{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Se,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,i=!1,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=s&&o?parseInt(o[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&r<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][n.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:n.asset,parser:s,userData:{}};return I(i,a,n),b(a,n),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const r=e[n].joints;for(let a=0,o=r.length;a<o;a++)t[r[a]].isBone=!0}for(let n=0,i=t.length;n<i;n++){const r=t[n];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,s){if(t.refs[e]<=1)return s;const n=s.clone(),i=(r,a)=>{const o=this.associations.get(r);o!=null&&this.associations.set(a,o);for(const[l,u]of r.children.entries())i(u,a.children[l])};return i(s,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const n=t(e[s]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let n=0;n<e.length;n++){const i=t(e[n]);i&&s.push(i)}return s}getDependency(t,e){const s=t+":"+e;let n=this.cache.get(s);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t);break}this.cache.add(s,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const s=this,n=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(i,r){return s.getDependency(t,r)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[E.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,r){s.load(h.LoaderUtils.resolveURL(e.uri,n.path),i,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(s){const n=e.byteLength||0,i=e.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(t){const e=this,s=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){const r=G[n.type],a=P[n.componentType],o=n.normalized===!0,l=new a(n.count*r);return Promise.resolve(new h.BufferAttribute(l,r,o))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(r){const a=r[0],o=G[n.type],l=P[n.componentType],u=l.BYTES_PER_ELEMENT,d=u*o,f=n.byteOffset||0,p=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let T,A;if(p&&p!==d){const _=Math.floor(f/p),R="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+_+":"+n.count;let w=e.cache.get(R);w||(T=new l(a,_*p,n.count*p/u),w=new h.InterleavedBuffer(T,p/u),e.cache.add(R,w)),A=new h.InterleavedBufferAttribute(w,o,f%p/u,g)}else a===null?T=new l(n.count*o):T=new l(a,f,n.count*o),A=new h.BufferAttribute(T,o,g);if(n.sparse!==void 0){const _=G.SCALAR,R=P[n.sparse.indices.componentType],w=n.sparse.indices.byteOffset||0,L=n.sparse.values.byteOffset||0,M=new R(r[1],w,n.sparse.count*_),v=new l(r[2],L,n.sparse.count*o);a!==null&&(A=new h.BufferAttribute(A.array.slice(),A.itemSize,A.normalized)),A.normalized=!1;for(let S=0,N=M.length;S<N;S++){const C=M[S];if(A.setX(C,v[S*o]),o>=2&&A.setY(C,v[S*o+1]),o>=3&&A.setZ(C,v[S*o+2]),o>=4&&A.setW(C,v[S*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}A.normalized=g}return A})}loadTexture(t){const e=this.json,s=this.options,i=e.textures[t].source,r=e.images[i];let a=this.textureLoader;if(r.uri){const o=s.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(t,i,a)}loadTextureImage(t,e,s){const n=this,i=this.json,r=i.textures[t],a=i.images[e],o=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(e,s).then(function(u){u.flipY=!1,u.name=r.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const f=(i.samplers||{})[r.sampler]||{};return u.magFilter=Z[f.magFilter]||h.LinearFilter,u.minFilter=Z[f.minFilter]||h.LinearMipmapLinearFilter,u.wrapS=ee[f.wrapS]||h.RepeatWrapping,u.wrapT=ee[f.wrapT]||h.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==h.NearestFilter&&u.minFilter!==h.LinearFilter,n.associations.set(u,{textures:t}),u}).catch(function(){return null});return this.textureCache[o]=l,l}loadImageSource(t,e){const s=this,n=this.json,i=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(d=>d.clone());const r=n.images[t],a=self.URL||self.webkitURL;let o=r.uri||"",l=!1;if(r.bufferView!==void 0)o=s.getDependency("bufferView",r.bufferView).then(function(d){l=!0;const f=new Blob([d],{type:r.mimeType});return o=a.createObjectURL(f),o});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const u=Promise.resolve(o).then(function(d){return new Promise(function(f,p){let g=f;e.isImageBitmapLoader===!0&&(g=function(T){const A=new h.Texture(T);A.needsUpdate=!0,f(A)}),e.load(h.LoaderUtils.resolveURL(d,i.path),g,void 0,p)})}).then(function(d){return l===!0&&a.revokeObjectURL(o),b(d,r),d.userData.mimeType=r.mimeType||nt(r.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),d});return this.sourceCache[t]=u,u}assignTexture(t,e,s,n){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[E.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[E.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=i.associations.get(r);r=i.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,o)}}return n!==void 0&&(r.colorSpace=n),t[e]=r,r})}assignFinalMaterial(t){const e=t.geometry;let s=t.material;const n=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,r=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new h.PointsMaterial,h.Material.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(a,o)),s=o}else if(t.isLine){const a="LineBasicMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new h.LineBasicMaterial,h.Material.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(a,o)),s=o}if(n||i||r){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=s.clone(),i&&(o.vertexColors=!0),r&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(s))),s=o}t.material=s}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(t){const e=this,s=this.json,n=this.extensions,i=s.materials[t];let r;const a={},o=i.extensions||{},l=[];if(o[E.KHR_MATERIALS_UNLIT]){const d=n[E.KHR_MATERIALS_UNLIT];r=d.getMaterialType(),l.push(d.extendParams(a,i,e))}else{const d=i.pbrMetallicRoughness||{};if(a.color=new h.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const f=d.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],h.LinearSRGBColorSpace),a.opacity=f[3]}d.baseColorTexture!==void 0&&l.push(e.assignTexture(a,"map",d.baseColorTexture,h.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(l.push(e.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),l.push(e.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,a)})))}i.doubleSided===!0&&(a.side=h.DoubleSide);const u=i.alphaMode||U.OPAQUE;if(u===U.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===U.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==h.MeshBasicMaterial&&(l.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new h.Vector2(1,1),i.normalTexture.scale!==void 0)){const d=i.normalTexture.scale;a.normalScale.set(d,d)}if(i.occlusionTexture!==void 0&&r!==h.MeshBasicMaterial&&(l.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==h.MeshBasicMaterial){const d=i.emissiveFactor;a.emissive=new h.Color().setRGB(d[0],d[1],d[2],h.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&r!==h.MeshBasicMaterial&&l.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture,h.SRGBColorSpace)),Promise.all(l).then(function(){const d=new r(a);return i.name&&(d.name=i.name),b(d,i),e.associations.set(d,{materials:t}),i.extensions&&I(n,d,i),d})}createUniqueName(t){const e=h.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,s=this.extensions,n=this.primitiveCache;function i(a){return s[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return te(o,a,e)})}const r=[];for(let a=0,o=t.length;a<o;a++){const l=t[a],u=tt(l),d=n[u];if(d)r.push(d.promise);else{let f;l.extensions&&l.extensions[E.KHR_DRACO_MESH_COMPRESSION]?f=i(l):f=te(new h.BufferGeometry,l,e),n[u]={primitive:l,promise:f},r.push(f)}}return Promise.all(r)}loadMesh(t){const e=this,s=this.json,n=this.extensions,i=s.meshes[t],r=i.primitives,a=[];for(let o=0,l=r.length;o<l;o++){const u=r[o].material===void 0?Je(this.cache):this.getDependency("material",r[o].material);a.push(u)}return a.push(e.loadGeometries(r)),Promise.all(a).then(function(o){const l=o.slice(0,o.length-1),u=o[o.length-1],d=[];for(let p=0,g=u.length;p<g;p++){const T=u[p],A=r[p];let _;const R=l[p];if(A.mode===x.TRIANGLES||A.mode===x.TRIANGLE_STRIP||A.mode===x.TRIANGLE_FAN||A.mode===void 0)_=i.isSkinnedMesh===!0?new h.SkinnedMesh(T,R):new h.Mesh(T,R),_.isSkinnedMesh===!0&&_.normalizeSkinWeights(),A.mode===x.TRIANGLE_STRIP?_.geometry=Q(_.geometry,h.TriangleStripDrawMode):A.mode===x.TRIANGLE_FAN&&(_.geometry=Q(_.geometry,h.TriangleFanDrawMode));else if(A.mode===x.LINES)_=new h.LineSegments(T,R);else if(A.mode===x.LINE_STRIP)_=new h.Line(T,R);else if(A.mode===x.LINE_LOOP)_=new h.LineLoop(T,R);else if(A.mode===x.POINTS)_=new h.Points(T,R);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(_.geometry.morphAttributes).length>0&&et(_,i),_.name=e.createUniqueName(i.name||"mesh_"+t),b(_,i),A.extensions&&I(n,_,A),e.assignFinalMaterial(_),d.push(_)}for(let p=0,g=d.length;p<g;p++)e.associations.set(d[p],{meshes:t,primitives:p});if(d.length===1)return i.extensions&&I(n,d[0],i),d[0];const f=new h.Group;i.extensions&&I(n,f,i),e.associations.set(f,{meshes:t});for(let p=0,g=d.length;p<g;p++)f.add(d[p]);return f})}loadCamera(t){let e;const s=this.json.cameras[t],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new h.PerspectiveCamera(h.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(e=new h.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),b(e,s),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],s=[];for(let n=0,i=e.joints.length;n<i;n++)s.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),r=n,a=[],o=[];for(let l=0,u=r.length;l<u;l++){const d=r[l];if(d){a.push(d);const f=new h.Matrix4;i!==null&&f.fromArray(i.array,l*16),o.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[l])}return new h.Skeleton(a,o)})}loadAnimation(t){const e=this.json,s=this,n=e.animations[t],i=n.name?n.name:"animation_"+t,r=[],a=[],o=[],l=[],u=[];for(let d=0,f=n.channels.length;d<f;d++){const p=n.channels[d],g=n.samplers[p.sampler],T=p.target,A=T.node,_=n.parameters!==void 0?n.parameters[g.input]:g.input,R=n.parameters!==void 0?n.parameters[g.output]:g.output;T.node!==void 0&&(r.push(this.getDependency("node",A)),a.push(this.getDependency("accessor",_)),o.push(this.getDependency("accessor",R)),l.push(g),u.push(T))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(u)]).then(function(d){const f=d[0],p=d[1],g=d[2],T=d[3],A=d[4],_=[];for(let R=0,w=f.length;R<w;R++){const L=f[R],M=p[R],v=g[R],S=T[R],N=A[R];if(L===void 0)continue;L.updateMatrix&&L.updateMatrix();const C=s._createAnimationTracks(L,M,v,S,N);if(C)for(let H=0;H<C.length;H++)_.push(C[H])}return new h.AnimationClip(i,void 0,_)})}createNodeMesh(t){const e=this.json,s=this,n=e.nodes[t];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const r=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let o=0,l=n.weights.length;o<l;o++)a.morphTargetInfluences[o]=n.weights[o]}),r})}loadNode(t){const e=this.json,s=this,n=e.nodes[t],i=s._loadNodeShallow(t),r=[],a=n.children||[];for(let l=0,u=a.length;l<u;l++)r.push(s.getDependency("node",a[l]));const o=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),o]).then(function(l){const u=l[0],d=l[1],f=l[2];f!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(f,st)});for(let p=0,g=d.length;p<g;p++)u.add(d[p]);return u})}_loadNodeShallow(t){const e=this.json,s=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const i=e.nodes[t],r=i.name?n.createUniqueName(i.name):"",a=[],o=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(t)});return o&&a.push(o),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(l){return n._getNodeRef(n.cameraCache,i.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(t)}).forEach(function(l){a.push(l)}),this.nodeCache[t]=Promise.all(a).then(function(l){let u;if(i.isBone===!0?u=new h.Bone:l.length>1?u=new h.Group:l.length===1?u=l[0]:u=new h.Object3D,u!==l[0])for(let d=0,f=l.length;d<f;d++)u.add(l[d]);if(i.name&&(u.userData.name=i.name,u.name=r),b(u,i),i.extensions&&I(s,u,i),i.matrix!==void 0){const d=new h.Matrix4;d.fromArray(i.matrix),u.applyMatrix4(d)}else i.translation!==void 0&&u.position.fromArray(i.translation),i.rotation!==void 0&&u.quaternion.fromArray(i.rotation),i.scale!==void 0&&u.scale.fromArray(i.scale);return n.associations.has(u)||n.associations.set(u,{}),n.associations.get(u).nodes=t,u}),this.nodeCache[t]}loadScene(t){const e=this.extensions,s=this.json.scenes[t],n=this,i=new h.Group;s.name&&(i.name=n.createUniqueName(s.name)),b(i,s),s.extensions&&I(e,i,s);const r=s.nodes||[],a=[];for(let o=0,l=r.length;o<l;o++)a.push(n.getDependency("node",r[o]));return Promise.all(a).then(function(o){for(let u=0,d=o.length;u<d;u++)i.add(o[u]);const l=u=>{const d=new Map;for(const[f,p]of n.associations)(f instanceof h.Material||f instanceof h.Texture)&&d.set(f,p);return u.traverse(f=>{const p=n.associations.get(f);p!=null&&d.set(f,p)}),d};return n.associations=l(i),i})}_createAnimationTracks(t,e,s,n,i){const r=[],a=t.name?t.name:t.uuid,o=[];O[i.path]===O.weights?t.traverse(function(f){f.morphTargetInfluences&&o.push(f.name?f.name:f.uuid)}):o.push(a);let l;switch(O[i.path]){case O.weights:l=h.NumberKeyframeTrack;break;case O.rotation:l=h.QuaternionKeyframeTrack;break;case O.position:case O.scale:l=h.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:l=h.NumberKeyframeTrack;break;case 2:case 3:default:l=h.VectorKeyframeTrack;break}break}const u=n.interpolation!==void 0?Qe[n.interpolation]:h.InterpolateLinear,d=this._getArrayFromAccessor(s);for(let f=0,p=o.length;f<p;f++){const g=new l(o[f]+"."+O[i.path],e.array,d,u);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),r.push(g)}return r}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const s=z(e.constructor),n=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)n[i]=e[i]*s;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(s){const n=this instanceof h.QuaternionKeyframeTrack?Ye:oe;return new n(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function it(c,t,e){const s=t.attributes,n=new h.Box3;if(s.POSITION!==void 0){const a=e.json.accessors[s.POSITION],o=a.min,l=a.max;if(o!==void 0&&l!==void 0){if(n.set(new h.Vector3(o[0],o[1],o[2]),new h.Vector3(l[0],l[1],l[2])),a.normalized){const u=z(P[a.componentType]);n.min.multiplyScalar(u),n.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=t.targets;if(i!==void 0){const a=new h.Vector3,o=new h.Vector3;for(let l=0,u=i.length;l<u;l++){const d=i[l];if(d.POSITION!==void 0){const f=e.json.accessors[d.POSITION],p=f.min,g=f.max;if(p!==void 0&&g!==void 0){if(o.setX(Math.max(Math.abs(p[0]),Math.abs(g[0]))),o.setY(Math.max(Math.abs(p[1]),Math.abs(g[1]))),o.setZ(Math.max(Math.abs(p[2]),Math.abs(g[2]))),f.normalized){const T=z(P[f.componentType]);o.multiplyScalar(T)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}c.boundingBox=n;const r=new h.Sphere;n.getCenter(r.center),r.radius=n.min.distanceTo(n.max)/2,c.boundingSphere=r}function te(c,t,e){const s=t.attributes,n=[];function i(r,a){return e.getDependency("accessor",r).then(function(o){c.setAttribute(a,o)})}for(const r in s){const a=X[r]||r.toLowerCase();a in c.attributes||n.push(i(s[r],a))}if(t.indices!==void 0&&!c.index){const r=e.getDependency("accessor",t.indices).then(function(a){c.setIndex(a)});n.push(r)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),b(c,t),it(c,t,e),Promise.all(n).then(function(){return t.targets!==void 0?Ze(c,t.targets,e):c})}var ot=Object.defineProperty,at=Object.getOwnPropertyDescriptor,ct=(c,t,e,s)=>{for(var n=s>1?void 0:s?at(t,e):t,i=c.length-1,r;i>=0;i--)(r=c[i])&&(n=(s?r(t,e,n):r(n))||n);return s&&n&&ot(t,e,n),n};let $=class{constructor(){y(this,"loadingManager",new h.LoadingManager);y(this,"loaders",{});y(this,"resources",[]);y(this,"items",{});y(this,"toLoad",0);y(this,"loaded",0)}get videoLoader(){return{load:(c,t)=>{let e=document.createElement("video");e.muted=!0,e.loop=!0,e.controls=!1,e.playsInline=!0,e.src=c,e.autoplay=!0;const s=()=>{if(!e)return;e.play();const n=new h.VideoTexture(e),i=n.dispose.bind(n);n.dispose=()=>{n.userData.element=void 0,e==null||e.remove(),e=void 0,i()},t(n),n.userData.element=e,e.removeEventListener("canplaythrough",s)};e.addEventListener("canplaythrough",s)}}}_setLoaders(){this.loaders.gltfLoader=new xe(this.loadingManager),this.loaders.textureLoader=new h.ImageBitmapLoader(this.loadingManager),this.loaders.cubeTextureLoader=new h.CubeTextureLoader(this.loadingManager),this.loaders.audioLoader=new h.AudioLoader(this.loadingManager),this.loaders.videoLoader=this.videoLoader}setResources(c){this.resources=c,this.toLoad=this.resources.length,this.loaded=0}init(c=[]){this.resources=c,this._setLoaders()}};$=ct([m.scoped(m.Lifecycle.ResolutionScoped)],$);var lt=Object.defineProperty,ut=Object.getOwnPropertyDescriptor,dt=(c,t,e,s)=>{for(var n=s>1?void 0:s?ut(t,e):t,i=c.length-1,r;i>=0;i--)(r=c[i])&&(n=(s?r(t,e,n):r(n))||n);return s&&n&&lt(t,e,n),n},ne=(c,t)=>(e,s)=>t(e,s,c);exports.LoaderModule=class{constructor(t,e){this.controller=t,this.component=e,typeof self<"u"&&(self.onmessage=s=>{var i;const n=(i=s==null?void 0:s.data)==null?void 0:i.resources;n&&this.init(n)})}_handleLoadedResource(t,e){this.component.items[t.name]=e,this.component.loaded++,this.controller.progress$$.next({file:e,resource:t,loaded:this.component.loaded,toLoad:this.component.toLoad})}setDracoLoader(t,e=!0){this.component.loaders.dracoLoader=new ye(this.component.loadingManager),this.component.loaders.dracoLoader.setDecoderPath(t),e&&this.component.loaders.gltfLoader&&this.component.loaders.gltfLoader.setDRACOLoader(this.component.loaders.dracoLoader)}load(){var e,s,n,i,r;const t=this.component.resources[0];if(t){this.controller.progress$$.next({resource:t,loaded:this.component.loaded,toLoad:this.component.toLoad});for(const a of this.component.resources)this.component.items[a.name]||(a.type==="gltfModel"&&typeof a.path=="string"&&((e=this.component.loaders.gltfLoader)==null||e.load(a.path,o=>this._handleLoadedResource(a,o))),a.type==="texture"&&typeof a.path=="string"&&((s=this.component.loaders.textureLoader)==null||s.load(a.path,o=>{this._handleLoadedResource(a,new h.CanvasTexture(o))})),a.type==="cubeTexture"&&typeof a.path=="object"&&((n=this.component.loaders.cubeTextureLoader)==null||n.load(a.path,o=>this._handleLoadedResource(a,o))),a.type==="video"&&typeof a.path=="string"&&((i=this.component.loaders.videoLoader)==null||i.load(a.path,o=>this._handleLoadedResource(a,o))),a.type==="audio"&&typeof a.path=="string"&&((r=this.component.loaders.audioLoader)==null||r.load(a.path,o=>{this._handleLoadedResource(a,o)})))}}items(){return this.component.items}loaders(){return this.component.loaders}resources(){return this.component.resources}loaded(){return this.component.loaded}toLoad(){return this.component.toLoad}init(t=[]){this.component.init(t)}dispose(){this.controller.progress$$.complete()}progress$(){return this.controller.progress$}progressCompleted$(){return this.controller.progressCompleted$}};exports.LoaderModule=dt([m.scoped(m.Lifecycle.ResolutionScoped),ne(0,m.inject(V)),ne(1,m.inject($))],exports.LoaderModule);const ht=m.instance.resolve(exports.LoaderModule);var ft=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,mt=(c,t,e,s)=>{for(var n=s>1?void 0:s?pt(t,e):t,i=c.length-1,r;i>=0;i--)(r=c[i])&&(n=(s?r(t,e,n):r(n))||n);return s&&n&&ft(t,e,n),n};let F=class{constructor(){y(this,"workerPool",m.z(void 0,!0));y(this,"canvas");y(this,"worker");y(this,"thread")}init(c){this.worker=c.worker,this.thread=c.thread}};F=mt([m.singleton()],F);var gt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Tt=(c,t,e,s)=>{for(var n=s>1?void 0:s?At(t,e):t,i=c.length-1,r;i>=0;i--)(r=c[i])&&(n=(s?r(t,e,n):r(n))||n);return s&&n&&gt(t,e,n),n},_t=(c,t)=>(e,s)=>t(e,s,c);let W=class extends m.ProxyEventHandlersModel{constructor(t){super();y(this,"canvas");this._service=t}init(t){this.canvas=t;for(const e of m.PROXY_EVENT_LISTENERS){const s=e.startsWith("mouse")||e.startsWith("pointer")||e.startsWith("touch")?this.mouseEventHandler:e.startsWith("key")?this.keyEventHandler:e==="resize"?this.uiEventHandler:e==="wheel"?this.wheelEventHandler:this.preventDefaultHandler;this[`${e}$`]=K(e==="resize"?window:t,e).pipe(m.map(s.bind(this)),m.filter(n=>!(e==="keydown"&&!n))),this[`${e}$`].subscribe(n=>{var i,r;(r=(i=this._service.thread)==null?void 0:i[e])==null||r.call(i,n)})}}preventDefaultHandler(t){return t.preventDefault(),{type:t.type}}getScreenSizes(){return{width:this.canvas.width,height:this.canvas.height,windowWidth:(window==null?void 0:window.innerWidth)??0,windowHeight:(window==null?void 0:window.innerHeight)??0}}uiEventHandler(t){const e=this.canvas.getBoundingClientRect();return{...this.getScreenSizes(),type:t.type,top:e.top,left:e.left}}mouseEventHandler(t){return{...this.getScreenSizes(),...m.U(t,["ctrlKey","metaKey","shiftKey","button","pointerType","clientX","clientY","pageX","pageY"])}}touchEventHandler(t){const e=[],s={type:t.type,touches:e};for(let n=0;n<t.touches.length;++n){const i=t.touches[n];e.push({pageX:(i==null?void 0:i.pageX)??0,pageY:(i==null?void 0:i.pageY)??0})}return{...this.getScreenSizes(),...s}}wheelEventHandler(t){return t.preventDefault(),{...this.getScreenSizes(),...m.U(t,["deltaX","deltaY"])}}keyEventHandler(t){if(m.KEYBOARD_EVENT_CODES.includes(t.code))return t.preventDefault(),{...this.getScreenSizes(),...m.U(t,["ctrlKey","metaKey","shiftKey","keyCode"])}}};W=Tt([m.singleton(),_t(0,m.inject(F))],W);var yt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Rt=(c,t,e,s)=>{for(var n=s>1?void 0:s?Et(t,e):t,i=c.length-1,r;i>=0;i--)(r=c[i])&&(n=(s?r(t,e,n):r(n))||n);return s&&n&&yt(t,e,n),n},k=(c,t)=>(e,s)=>t(e,s,c);exports.RegisterModule=class extends se{constructor(e,s,n,i){super();y(this,"initialized",!1);this._container=e,this._service=s,this._controller=n,this.registerProps=i,this.registerProps.initOnConstruct&&this.init()}async _initCanvas(){try{if(this.registerProps.canvas instanceof HTMLCanvasElement&&(this._service.canvas=this.registerProps.canvas),typeof this.registerProps.canvas=="string"){const e=document.querySelector(this.registerProps.canvas);e instanceof HTMLCanvasElement&&(this._service.canvas=e)}this._service.canvas||(this._service.canvas=document.createElement("canvas"),this._service.canvas.dataset.reactive="true",document.body.appendChild(this._service.canvas))}catch(e){console.error(`🛑 Unable to initialize the canvas:
3
+ ${e instanceof Error?e.message:"Something went wrong"}`)}}async _initComponent(){this._service.init({worker:this._service.worker,thread:this._service.thread})}async _initController(){var e,s;if(!this._service.canvas)throw new Error("Canvas element is not initialized.");this._controller.init(this._service.canvas),!(!this._service.thread||!this._service.worker)&&((s=(e=this._service.thread)==null?void 0:e.resize)==null||s.call(e,{...this._controller.uiEventHandler({type:"resize"})}))}async _initWorkerThread(){if(!this._service.canvas)throw new Error("Canvas element is not initialized.");const e=this._service.canvas.transferControlToOffscreen();e.width=this._service.canvas.clientWidth,e.height=this._service.canvas.clientHeight;const[s,n]=await this._service.workerPool.run({payload:{path:this.registerProps.location,subject:{...m.$(this.registerProps,["canvas","location","onReady"]),canvas:e},transferSubject:[e]}});if(!s||n)throw new Error("Unable to retrieve the worker-thread info.");this._service.worker=s.worker,this._service.thread=s.thread}async _initObservableProxyEvents(){m.PROXY_EVENT_LISTENERS.forEach(e=>this[`${e}$`]=()=>{var s;return(s=this._controller)==null?void 0:s[`${e}$`]})}async init(){var e,s;await this._initCanvas(),await this._initWorkerThread(),await this._initComponent(),await this._initController(),await this._initObservableProxyEvents(),(s=(e=this.registerProps).onReady)==null||s.call(e,{module:this,container:this._container})}async loadResources(e){var i,r,a,o,l,u,d,f,p;const[s,n]=await this._service.workerPool.run({payload:{path:"../loader/loader.module-worker.ts",subject:{resources:e.resources}}});if(!s||n)throw new Error("Unable to retrieve worker thread info.");return(i=s.thread)==null||i.progress$().subscribe(g=>{var T;(T=e.onProgress)==null||T.call(e,g)}),(r=s.thread)==null||r.progressCompleted$().subscribe(g=>{var T,A;(T=e.onProgressComplete)==null||T.call(e,g),(e.disposeOnComplete||e.disposeOnComplete===void 0)&&((A=s.thread)==null||A.dispose())}),(e.immediateLoad||e.immediateLoad===void 0)&&await((a=s.thread)==null?void 0:a.load()),{...s,load:await((o=s.thread)==null?void 0:o.load),items:await((l=s.thread)==null?void 0:l.items()),loaders:await((u=s.thread)==null?void 0:u.items()),toLoad:await((d=s.thread)==null?void 0:d.toLoad()),loaded:await((f=s.thread)==null?void 0:f.loaded()),resources:await((p=s.thread)==null?void 0:p.resources())}}workerPool(){return this._service.workerPool}canvas(){return this._service.canvas}worker(){return this._service.worker}thread(){return this._service.thread}async dispose(){var e;await this._service.workerPool.terminateAll(),((e=this._service.canvas)==null?void 0:e.dataset.reactive)==="true"&&(this._service.canvas.remove(),this._service.canvas=void 0)}};exports.RegisterModule=Rt([m.scoped(m.Lifecycle.ContainerScoped),k(0,m.inject(m.CONTAINER_TOKEN)),k(1,m.inject(F)),k(2,m.inject(W)),k(3,m.inject(q))],exports.RegisterModule);const Lt=c=>{if(typeof(c==null?void 0:c.location)!="string"&&!((c==null?void 0:c.location)instanceof URL))throw new Error("Invalid register props detected. location path is required");const t=m.instance.createChildContainer();c.initOnConstruct=m.C(c.initOnConstruct)||!m.J(c.initOnConstruct)?!0:c.initOnConstruct,c.defaultCamera=c!=null&&c.defaultCamera&&c.defaultCamera in m.DefaultCameraType?c.defaultCamera:m.DefaultCameraType.PERSPECTIVE,c.withMiniCamera=m.C(c.withMiniCamera)||!m.J(c.withMiniCamera)?!1:c.withMiniCamera,c.startTimer=m.C(c.startTimer)||!m.J(c.startTimer)?!0:c.startTimer,c.fullScreen=m.C(c.fullScreen)||!m.J(c.fullScreen)?!0:c.fullScreen,c.onReady=m.D(c.onReady)?c.onReady:void 0,t.register(m.CONTAINER_TOKEN,{useValue:t}),t.register(q,{useValue:c});const e=t.resolve(exports.RegisterModule);return e.initialized=!0,{container:t,module:e}};Object.defineProperty(exports,"AppModule",{enumerable:!0,get:()=>m.AppModule});exports.AppProxyEventHandlersModel=m.AppProxyEventHandlersModel;exports.CONTAINER_TOKEN=m.CONTAINER_TOKEN;exports.DefaultCameraType=m.DefaultCameraType;exports.KEYBOARD_EVENT_CODES=m.KEYBOARD_EVENT_CODES;exports.PROXY_EVENT_LISTENERS=m.PROXY_EVENT_LISTENERS;exports.ProxyEventHandlersModel=m.ProxyEventHandlersModel;exports.ProxyEventObservablesModel=m.ProxyEventObservablesModel;exports.ProxyEventSubjectsModel=m.ProxyEventSubjectsModel;exports.LaunchAppProps=le;exports.RegisterPropsModel=q;exports.RegisterProxyEventHandlersModel=se;exports.loaderModule=ht;exports.register=Lt;