@ridp/threejs 0.2.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ImageLoader-CB_URfeZ.js +860 -0
- package/dist/ImageLoader-DwvBWW6h.cjs +5 -0
- package/dist/common-BHi3qsZW.cjs +15 -0
- package/dist/{common-DESmndxO.js → common-fbJUHqlj.js} +1 -1
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.js +7 -9
- package/dist/threejs.cjs +1 -1
- package/dist/threejs.js +17 -15
- package/dist/useGLTFLoader-DHxBLucO.js +5629 -0
- package/dist/useGLTFLoader-DM3-7jdq.cjs +4 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +15 -12
- package/esdoc/ast/source/.external-ecmascript.js.json +2802 -0
- package/esdoc/ast/source/hooks/index.js.json +739 -0
- package/esdoc/ast/source/hooks/useGLTFLoader.js.json +9111 -0
- package/esdoc/ast/source/hooks/useObb.js.json +16463 -0
- package/esdoc/ast/source/hooks/useRaycaster.js.json +15556 -0
- package/esdoc/ast/source/hooks/useThreeJs.js.json +52887 -0
- package/esdoc/ast/source/index.js.json +570 -0
- package/esdoc/ast/source/instance/IDBCache.js.json +40978 -0
- package/esdoc/ast/source/instance/index.js.json +232 -0
- package/esdoc/ast/source/utils/ImageLoader.js.json +7037 -0
- package/esdoc/ast/source/utils/common.js.json +5134 -0
- package/esdoc/ast/source/utils/css3dHelper.js.json +9101 -0
- package/esdoc/ast/source/utils/disposeObject.js.json +5978 -0
- package/esdoc/ast/source/utils/helper.js.json +10522 -0
- package/esdoc/ast/source/utils/index.js.json +908 -0
- package/esdoc/badge.svg +17 -0
- package/esdoc/class/src/instance/IDBCache.js~IDBCache.html +1299 -0
- package/esdoc/coverage.json +86 -0
- package/esdoc/css/github.css +83 -0
- package/esdoc/css/identifiers.css +37 -0
- package/esdoc/css/manual.css +134 -0
- package/esdoc/css/prettify-tomorrow.css +132 -0
- package/esdoc/css/search.css +84 -0
- package/esdoc/css/source.css +55 -0
- package/esdoc/css/style.css +608 -0
- package/esdoc/css/test.css +58 -0
- package/esdoc/file/src/hooks/index.js.html +79 -0
- package/esdoc/file/src/hooks/useGLTFLoader.js.html +146 -0
- package/esdoc/file/src/hooks/useObb.js.html +149 -0
- package/esdoc/file/src/hooks/useRaycaster.js.html +153 -0
- package/esdoc/file/src/hooks/useThreeJs.js.html +362 -0
- package/esdoc/file/src/index.js.html +78 -0
- package/esdoc/file/src/instance/IDBCache.js.html +312 -0
- package/esdoc/file/src/instance/index.js.html +76 -0
- package/esdoc/file/src/utils/ImageLoader.js.html +118 -0
- package/esdoc/file/src/utils/common.js.html +102 -0
- package/esdoc/file/src/utils/css3dHelper.js.html +131 -0
- package/esdoc/file/src/utils/disposeObject.js.html +114 -0
- package/esdoc/file/src/utils/helper.js.html +138 -0
- package/esdoc/file/src/utils/index.js.html +80 -0
- package/esdoc/function/index.html +2019 -0
- package/esdoc/identifiers.html +738 -0
- package/esdoc/image/badge.svg +17 -0
- package/esdoc/image/esdoc-logo-mini-black.png +0 -0
- package/esdoc/image/esdoc-logo-mini.png +0 -0
- package/esdoc/image/manual-badge.svg +17 -0
- package/esdoc/image/search.png +0 -0
- package/esdoc/index.html +153 -0
- package/esdoc/index.json +2051 -0
- package/esdoc/inject/css/0-cus-style.css +1 -0
- package/esdoc/lint.json +1 -0
- package/esdoc/script/inherited-summary.js +28 -0
- package/esdoc/script/inner-link.js +32 -0
- package/esdoc/script/manual.js +12 -0
- package/esdoc/script/patch-for-local.js +8 -0
- package/esdoc/script/prettify/Apache-License-2.0.txt +202 -0
- package/esdoc/script/prettify/prettify.js +46 -0
- package/esdoc/script/pretty-print.js +25 -0
- package/esdoc/script/search.js +117 -0
- package/esdoc/script/search_index.js +572 -0
- package/esdoc/script/test-summary.js +54 -0
- package/esdoc/source.html +213 -0
- package/esdoc/variable/index.html +225 -0
- package/package.json +13 -3
- package/readme.md +93 -0
- package/dist/common-nMt4tIRA.cjs +0 -15
- package/dist/disposeObject-BuI3II7v.cjs +0 -1
- package/dist/disposeObject-CmFSSgi7.js +0 -616
- package/dist/useGLTFLoader-BAoIZjEX.js +0 -2645
- package/dist/useGLTFLoader-CGOxhEOO.cjs +0 -6
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";const l=require("three"),Ae=require("vue"),se=require("./disposeObject-BuI3II7v.cjs");var ie=function(){var f=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(u){u.preventDefault(),r(++f%e.children.length)},!1);function t(u){return e.appendChild(u.dom),u}function r(u){for(var d=0;d<e.children.length;d++)e.children[d].style.display=d===u?"block":"none";f=u}var n=(performance||Date).now(),i=n,s=0,a=t(new ie.Panel("FPS","#0ff","#002")),o=t(new ie.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=t(new ie.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:t,showPanel:r,begin:function(){n=(performance||Date).now()},end:function(){s++;var u=(performance||Date).now();if(o.update(u-n,200),u>=i+1e3&&(a.update(s*1e3/(u-i),100),i=u,s=0,c)){var d=performance.memory;c.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return u},update:function(){n=this.end()},domElement:e,setMode:r}};ie.Panel=function(f,e,t){var r=1/0,n=0,i=Math.round,s=i(window.devicePixelRatio||1),a=80*s,o=48*s,c=3*s,u=2*s,d=3*s,h=15*s,p=74*s,g=30*s,y=document.createElement("canvas");y.width=a,y.height=o,y.style.cssText="width:80px;height:48px";var m=y.getContext("2d");return m.font="bold "+9*s+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=t,m.fillRect(0,0,a,o),m.fillStyle=e,m.fillText(f,c,u),m.fillRect(d,h,p,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(d,h,p,g),{dom:y,update:function(T,_){r=Math.min(r,T),n=Math.max(n,T),m.fillStyle=t,m.globalAlpha=1,m.fillRect(0,0,a,h),m.fillStyle=e,m.fillText(i(T)+" "+f+" ("+i(r)+"-"+i(n)+")",c,u),m.drawImage(y,d+s,h,p-s,g,d,h,p-s,g),m.fillRect(d+p-s,h,s,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(d+p-s,h,s,i((1-T/_)*g))}}};function Te(f,e){if(e===l.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(e===l.TriangleFanDrawMode||e===l.TriangleStripDrawMode){let t=f.getIndex();if(t===null){const s=[],a=f.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)s.push(o);f.setIndex(s),t=f.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),f}const r=t.count-2,n=[];if(e===l.TriangleFanDrawMode)for(let s=1;s<=r;s++)n.push(t.getX(0)),n.push(t.getX(s)),n.push(t.getX(s+1));else for(let s=0;s<r;s++)s%2===0?(n.push(t.getX(s)),n.push(t.getX(s+1)),n.push(t.getX(s+2))):(n.push(t.getX(s+2)),n.push(t.getX(s+1)),n.push(t.getX(s)));n.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=f.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),f}const ce=new WeakMap;class Pe extends l.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,r,n){const i=new l.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,s=>{this.parse(s,t,n)},r,n)}parse(e,t,r=()=>{}){this.decodeDracoFile(e,t,null,null,l.SRGBColorSpace,r).catch(r)}decodeDracoFile(e,t,r,n,i=l.LinearSRGBColorSpace,s=()=>{}){const a={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:i};return this.decodeGeometry(e,a).then(t).catch(s)}decodeGeometry(e,t){const r=JSON.stringify(t);if(ce.has(e)){const o=ce.get(e);if(o.key===r)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 i=this.workerNextTaskID++,s=e.byteLength,a=this._getWorker(i,s).then(o=>(n=o,new Promise((c,u)=>{n._callbacks[i]={resolve:c,reject:u},n.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{n&&i&&this._releaseTask(n,i)}),ce.set(e,{key:r,promise:a}),a}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let r=0;r<e.attributes.length;r++){const n=e.attributes[r],i=n.name,s=n.array,a=n.itemSize,o=new l.BufferAttribute(s,a);i==="color"&&(this._assignVertexColorSpace(o,n.vertexColorSpace),o.normalized=!(s instanceof Float32Array)),t.setAttribute(i,o)}return t}_assignVertexColorSpace(e,t){if(t!==l.SRGBColorSpace)return;const r=new l.Color;for(let n=0,i=e.count;n<i;n++)r.fromBufferAttribute(e,n),l.ColorManagement.toWorkingColorSpace(r,l.SRGBColorSpace),e.setXYZ(n,r.r,r.g,r.b)}_loadLibrary(e,t){const r=new l.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise((n,i)=>{r.load(e,n,void 0,i)})}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(r=>{const n=r[0];e||(this.decoderConfig.wasmBinary=r[1]);const i=Oe.toString(),s=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
|
|
2
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),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(i){const s=i.data;switch(s.type){case"decode":n._callbacks[s.id].resolve(s);break;case"error":n._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,i){return n._taskLoad>i._taskLoad?-1:1});const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r})}_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 Oe(){let f,e;onmessage=function(s){const a=s.data;switch(a.type){case"init":f=a.decoderConfig,e=new Promise(function(u){f.onModuleLoaded=function(d){u({draco:d})},DracoDecoderModule(f)});break;case"decode":const o=a.buffer,c=a.taskConfig;e.then(u=>{const d=u.draco,h=new d.Decoder;try{const p=t(d,h,new Int8Array(o),c),g=p.attributes.map(y=>y.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(h)}});break}};function t(s,a,o,c){const u=c.attributeIDs,d=c.attributeTypes;let h,p;const g=a.GetEncodedGeometryType(o);if(g===s.TRIANGULAR_MESH)h=new s.Mesh,p=a.DecodeArrayToMesh(o,o.byteLength,h);else if(g===s.POINT_CLOUD)h=new s.PointCloud,p=a.DecodeArrayToPointCloud(o,o.byteLength,h);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||h.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const y={index:null,attributes:[]};for(const m in u){const T=self[d[m]];let _,N;if(c.useUniqueIDs)N=u[m],_=a.GetAttributeByUniqueId(h,N);else{if(N=a.GetAttributeId(h,s[u[m]]),N===-1)continue;_=a.GetAttribute(h,N)}const S=n(s,a,h,m,T,_);m==="color"&&(S.vertexColorSpace=c.vertexColorSpace),y.attributes.push(S)}return g===s.TRIANGULAR_MESH&&(y.index=r(s,a,h)),s.destroy(h),y}function r(s,a,o){const u=o.num_faces()*3,d=u*4,h=s._malloc(d);a.GetTrianglesUInt32Array(o,d,h);const p=new Uint32Array(s.HEAPF32.buffer,h,u).slice();return s._free(h),{array:p,itemSize:1}}function n(s,a,o,c,u,d){const h=d.num_components(),g=o.num_points()*h,y=g*u.BYTES_PER_ELEMENT,m=i(s,u),T=s._malloc(y);a.GetAttributeDataArrayForAllPoints(o,d,m,y,T);const _=new u(s.HEAPF32.buffer,T,g).slice();return s._free(T),{name:c,array:_,itemSize:h}}function i(s,a){switch(a){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}class De extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new He(t)}),this.register(function(t){return new ve(t)}),this.register(function(t){return new Ye(t)}),this.register(function(t){return new Qe(t)}),this.register(function(t){return new Je(t)}),this.register(function(t){return new je(t)}),this.register(function(t){return new ze(t)}),this.register(function(t){return new Ve(t)}),this.register(function(t){return new Ke(t)}),this.register(function(t){return new Ge(t)}),this.register(function(t){return new Xe(t)}),this.register(function(t){return new Ue(t)}),this.register(function(t){return new qe(t)}),this.register(function(t){return new We(t)}),this.register(function(t){return new Fe(t)}),this.register(function(t){return new Ze(t)}),this.register(function(t){return new $e(t)})}load(e,t,r,n){const i=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const c=l.LoaderUtils.extractUrlBase(e);s=l.LoaderUtils.resolveURL(c,this.path)}else s=l.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){n?n(c):console.error(c),i.manager.itemError(e),i.manager.itemEnd(e)},o=new l.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{i.parse(c,s,function(u){t(u),i.manager.itemEnd(e)},a)}catch(u){a(u)}},r,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,r,n){let i;const s={},a={},o=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===Le){try{s[E.KHR_BINARY_GLTF]=new et(e)}catch(d){n&&n(d);return}i=JSON.parse(s[E.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new ft(i,{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 u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,s[d.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const d=i.extensionsUsed[u],h=i.extensionsRequired||[];switch(d){case E.KHR_MATERIALS_UNLIT:s[d]=new Be;break;case E.KHR_DRACO_MESH_COMPRESSION:s[d]=new tt(i,this.dracoLoader);break;case E.KHR_TEXTURE_TRANSFORM:s[d]=new nt;break;case E.KHR_MESH_QUANTIZATION:s[d]=new st;break;default:h.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(s),c.setPlugins(a),c.parse(r,n)}parseAsync(e,t){const r=this;return new Promise(function(n,i){r.parse(e,t,n,i)})}}function ke(){let f={};return{get:function(e){return f[e]},add:function(e,t){f[e]=t},remove:function(e){delete f[e]},removeAll:function(){f={}}}}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 Fe{constructor(e){this.parser=e,this.name=E.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,n=t.length;r<n;r++){const i=t[r];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let n=t.cache.get(r);if(n)return n;const i=t.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let c;const u=new l.Color(16777215);o.color!==void 0&&u.setRGB(o.color[0],o.color[1],o.color[2],l.LinearSRGBColorSpace);const d=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new l.DirectionalLight(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new l.PointLight(u),c.distance=d;break;case"spot":c=new l.SpotLight(u),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),Y(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(r,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,i=r.json.nodes[e],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return r._getNodeRef(t.cache,a,o)})}}class Be{constructor(){this.name=E.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,r){const n=[];e.color=new l.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const s=i.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],l.LinearSRGBColorSpace),e.opacity=s[3]}i.baseColorTexture!==void 0&&n.push(r.assignTexture(e,"map",i.baseColorTexture,l.SRGBColorSpace))}return Promise.all(n)}}class Ge{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class He{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&i.push(r.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&i.push(r.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(i.push(r.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const a=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(a,a)}return Promise.all(i)}}class ve{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_DISPERSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Ue{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&i.push(r.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&i.push(r.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(i)}}class je{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_SHEEN}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=n.extensions[this.name];if(s.sheenColorFactor!==void 0){const a=s.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&i.push(r.assignTexture(t,"sheenColorMap",s.sheenColorTexture,l.SRGBColorSpace)),s.sheenRoughnessTexture!==void 0&&i.push(r.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class ze{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&i.push(r.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class Ve{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&i.push(r.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return t.attenuationColor=new l.Color().setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace),Promise.all(i)}}class Ke{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Xe{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&i.push(r.assignTexture(t,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return t.specularColor=new l.Color().setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace),s.specularColorTexture!==void 0&&i.push(r.assignTexture(t,"specularColorMap",s.specularColorTexture,l.SRGBColorSpace)),Promise.all(i)}}class We{constructor(e){this.parser=e,this.name=E.EXT_MATERIALS_BUMP}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&i.push(r.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(i)}}class qe{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&i.push(r.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(i)}}class Ye{constructor(e){this.parser=e,this.name=E.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,n=r.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,s)}}class Qe{constructor(e){this.parser=e,this.name=E.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,n=r.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],a=n.images[s.source];let o=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(e,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.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 Je{constructor(e){this.parser=e,this.name=E.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,n=r.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],a=n.images[s.source];let o=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(e,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.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 Ze{constructor(e){this.name=E.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const n=r.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,u=n.count,d=n.byteStride,h=new Uint8Array(a,o,c);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(u,d,h,n.mode,n.filter).then(function(p){return p.buffer}):s.ready.then(function(){const p=new ArrayBuffer(u*d);return s.decodeGltfBuffer(new Uint8Array(p),u,d,h,n.mode,n.filter),p})})}else return null}}class $e{constructor(e){this.name=E.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const n=t.meshes[r.mesh];for(const c of n.primitives)if(c.mode!==j.TRIANGLES&&c.mode!==j.TRIANGLE_STRIP&&c.mode!==j.TRIANGLE_FAN&&c.mode!==void 0)return null;const s=r.extensions[this.name].attributes,a=[],o={};for(const c in s)a.push(this.parser.getDependency("accessor",s[c]).then(u=>(o[c]=u,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const u=c.pop(),d=u.isGroup?u.children:[u],h=c[0].count,p=[];for(const g of d){const y=new l.Matrix4,m=new l.Vector3,T=new l.Quaternion,_=new l.Vector3(1,1,1),N=new l.InstancedMesh(g.geometry,g.material,h);for(let S=0;S<h;S++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,S),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,S),o.SCALE&&_.fromBufferAttribute(o.SCALE,S),N.setMatrixAt(S,y.compose(m,T,_));for(const S in o)if(S==="_COLOR_0"){const H=o[S];N.instanceColor=new l.InstancedBufferAttribute(H.array,H.itemSize,H.normalized)}else S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"&&g.geometry.setAttribute(S,o[S]);l.Object3D.prototype.copy.call(N,g),this.parser.assignFinalMaterial(N),p.push(N)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}}const Le="glTF",re=12,ye={JSON:1313821514,BIN:5130562};class et{constructor(e){this.name=E.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,re),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Le)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-re,i=new DataView(e,re);let s=0;for(;s<n;){const a=i.getUint32(s,!0);s+=4;const o=i.getUint32(s,!0);if(s+=4,o===ye.JSON){const c=new Uint8Array(e,re+s,a);this.content=r.decode(c)}else if(o===ye.BIN){const c=re+s;this.body=e.slice(c,c+a)}s+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class tt{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=E.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,a={},o={},c={};for(const u in s){const d=fe[u]||u.toLowerCase();a[d]=s[u]}for(const u in e.attributes){const d=fe[u]||u.toLowerCase();if(s[u]!==void 0){const h=r.accessors[e.attributes[u]],p=ne[h.componentType];c[d]=p.name,o[d]=h.normalized===!0}}return t.getDependency("bufferView",i).then(function(u){return new Promise(function(d,h){n.decodeDracoFile(u,function(p){for(const g in p.attributes){const y=p.attributes[g],m=o[g];m!==void 0&&(y.normalized=m)}d(p)},a,c,l.LinearSRGBColorSpace,h)})})}}class nt{constructor(){this.name=E.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 st{constructor(){this.name=E.KHR_MESH_QUANTIZATION}}class Ie extends l.Interpolant{constructor(e,t,r,n){super(e,t,r,n)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let s=0;s!==n;s++)t[s]=r[i+s];return t}interpolate_(e,t,r,n){const i=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,u=n-t,d=(r-t)/u,h=d*d,p=h*d,g=e*c,y=g-c,m=-2*p+3*h,T=p-h,_=1-m,N=T-h+d;for(let S=0;S!==a;S++){const H=s[y+S+a],U=s[y+S+o]*u,I=s[g+S+a],A=s[g+S]*u;i[S]=_*H+N*U+m*I+T*A}return i}}const rt=new l.Quaternion;class it extends Ie{interpolate_(e,t,r,n){const i=super.interpolate_(e,t,r,n);return rt.fromArray(i).normalize().toArray(i),i}}const j={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ne={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Re={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},xe={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},le={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fe={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"},J={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ot={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},ue={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function at(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),f.DefaultMaterial}function Z(f,e,t){for(const r in t.extensions)f[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function Y(f,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(f.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ct(f,e,t){let r=!1,n=!1,i=!1;for(let c=0,u=e.length;c<u;c++){const d=e[c];if(d.POSITION!==void 0&&(r=!0),d.NORMAL!==void 0&&(n=!0),d.COLOR_0!==void 0&&(i=!0),r&&n&&i)break}if(!r&&!n&&!i)return Promise.resolve(f);const s=[],a=[],o=[];for(let c=0,u=e.length;c<u;c++){const d=e[c];if(r){const h=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):f.attributes.position;s.push(h)}if(n){const h=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):f.attributes.normal;a.push(h)}if(i){const h=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):f.attributes.color;o.push(h)}}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o)]).then(function(c){const u=c[0],d=c[1],h=c[2];return r&&(f.morphAttributes.position=u),n&&(f.morphAttributes.normal=d),i&&(f.morphAttributes.color=h),f.morphTargetsRelative=!0,f})}function lt(f,e){if(f.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;t++)f.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(f.morphTargetInfluences.length===t.length){f.morphTargetDictionary={};for(let r=0,n=t.length;r<n;r++)f.morphTargetDictionary[t[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ut(f){let e;const t=f.extensions&&f.extensions[E.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+de(t.attributes):e=f.indices+":"+de(f.attributes)+":"+f.mode,f.targets!==void 0)for(let r=0,n=f.targets.length;r<n;r++)e+=":"+de(f.targets[r]);return e}function de(f){let e="";const t=Object.keys(f).sort();for(let r=0,n=t.length;r<n;r++)e+=t[r]+":"+f[t[r]]+";";return e}function pe(f){switch(f){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 dt(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const ht=new l.Matrix4;class ft{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ke,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 r=!1,n=-1,i=!1,s=-1;if(typeof navigator<"u"){const a=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=r&&o?parseInt(o[1],10):-1,i=a.indexOf("Firefox")>-1,s=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&n<17||i&&s<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.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 r=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(s){const a={scene:s[0][n.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:n.asset,parser:r,userData:{}};return Z(i,a,n),Y(a,n),Promise.all(r._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||[],r=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n].joints;for(let a=0,o=s.length;a<o;a++)e[s[a]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const s=e[n];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(r[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.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,r){if(e.refs[t]<=1)return r;const n=r.clone(),i=(s,a)=>{const o=this.associations.get(s);o!=null&&this.associations.set(a,o);for(const[c,u]of s.children.entries())i(u,a.children[c])};return i(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const n=e(t[r]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&r.push(i)}return r}getDependency(e,t){const r=e+":"+t;let n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(r,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,s){return r.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=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[E.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,s){r.load(l.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){s(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(r){const n=t.byteLength||0,i=t.byteOffset||0;return r.slice(i,i+n)})}loadAccessor(e){const t=this,r=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const s=le[n.type],a=ne[n.componentType],o=n.normalized===!0,c=new a(n.count*s);return Promise.resolve(new l.BufferAttribute(c,s,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(s){const a=s[0],o=le[n.type],c=ne[n.componentType],u=c.BYTES_PER_ELEMENT,d=u*o,h=n.byteOffset||0,p=n.bufferView!==void 0?r.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let y,m;if(p&&p!==d){const T=Math.floor(h/p),_="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+T+":"+n.count;let N=t.cache.get(_);N||(y=new c(a,T*p,n.count*p/u),N=new l.InterleavedBuffer(y,p/u),t.cache.add(_,N)),m=new l.InterleavedBufferAttribute(N,o,h%p/u,g)}else a===null?y=new c(n.count*o):y=new c(a,h,n.count*o),m=new l.BufferAttribute(y,o,g);if(n.sparse!==void 0){const T=le.SCALAR,_=ne[n.sparse.indices.componentType],N=n.sparse.indices.byteOffset||0,S=n.sparse.values.byteOffset||0,H=new _(s[1],N,n.sparse.count*T),U=new c(s[2],S,n.sparse.count*o);a!==null&&(m=new l.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let I=0,A=H.length;I<A;I++){const R=H[I];if(m.setX(R,U[I*o]),o>=2&&m.setY(R,U[I*o+1]),o>=3&&m.setZ(R,U[I*o+2]),o>=4&&m.setW(R,U[I*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){const t=this.json,r=this.options,i=t.textures[e].source,s=t.images[i];let a=this.textureLoader;if(s.uri){const o=r.manager.getHandler(s.uri);o!==null&&(a=o)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,r){const n=this,i=this.json,s=i.textures[e],a=i.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(t,r).then(function(u){u.flipY=!1,u.name=s.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const h=(i.samplers||{})[s.sampler]||{};return u.magFilter=Re[h.magFilter]||l.LinearFilter,u.minFilter=Re[h.minFilter]||l.LinearMipmapLinearFilter,u.wrapS=xe[h.wrapS]||l.RepeatWrapping,u.wrapT=xe[h.wrapT]||l.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==l.NearestFilter&&u.minFilter!==l.LinearFilter,n.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(e,t){const r=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const s=n.images[e],a=self.URL||self.webkitURL;let o=s.uri||"",c=!1;if(s.bufferView!==void 0)o=r.getDependency("bufferView",s.bufferView).then(function(d){c=!0;const h=new Blob([d],{type:s.mimeType});return o=a.createObjectURL(h),o});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(o).then(function(d){return new Promise(function(h,p){let g=h;t.isImageBitmapLoader===!0&&(g=function(y){const m=new l.Texture(y);m.needsUpdate=!0,h(m)}),t.load(l.LoaderUtils.resolveURL(d,i.path),g,void 0,p)})}).then(function(d){return c===!0&&a.revokeObjectURL(o),Y(d,s),d.userData.mimeType=s.mimeType||dt(s.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),d});return this.sourceCache[e]=u,u}assignTexture(e,t,r,n){const i=this;return this.getDependency("texture",r.index).then(function(s){if(!s)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(s=s.clone(),s.channel=r.texCoord),i.extensions[E.KHR_TEXTURE_TRANSFORM]){const a=r.extensions!==void 0?r.extensions[E.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=i.associations.get(s);s=i.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),i.associations.set(s,o)}}return n!==void 0&&(s.colorSpace=n),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+r.uuid;let o=this.cache.get(a);o||(o=new l.PointsMaterial,l.Material.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,o.sizeAttenuation=!1,this.cache.add(a,o)),r=o}else if(e.isLine){const a="LineBasicMaterial:"+r.uuid;let o=this.cache.get(a);o||(o=new l.LineBasicMaterial,l.Material.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,this.cache.add(a,o)),r=o}if(n||i||s){let a="ClonedMaterial:"+r.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),s&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=r.clone(),i&&(o.vertexColors=!0),s&&(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(r))),r=o}e.material=r}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,r=this.json,n=this.extensions,i=r.materials[e];let s;const a={},o=i.extensions||{},c=[];if(o[E.KHR_MATERIALS_UNLIT]){const d=n[E.KHR_MATERIALS_UNLIT];s=d.getMaterialType(),c.push(d.extendParams(a,i,t))}else{const d=i.pbrMetallicRoughness||{};if(a.color=new l.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const h=d.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],l.LinearSRGBColorSpace),a.opacity=h[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,l.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))),s=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,a)})))}i.doubleSided===!0&&(a.side=l.DoubleSide);const u=i.alphaMode||ue.OPAQUE;if(u===ue.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===ue.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&s!==l.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new l.Vector2(1,1),i.normalTexture.scale!==void 0)){const d=i.normalTexture.scale;a.normalScale.set(d,d)}if(i.occlusionTexture!==void 0&&s!==l.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&s!==l.MeshBasicMaterial){const d=i.emissiveFactor;a.emissive=new l.Color().setRGB(d[0],d[1],d[2],l.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&s!==l.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,l.SRGBColorSpace)),Promise.all(c).then(function(){const d=new s(a);return i.name&&(d.name=i.name),Y(d,i),t.associations.set(d,{materials:e}),i.extensions&&Z(n,d,i),d})}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,r=this.extensions,n=this.primitiveCache;function i(a){return r[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(o){return _e(o,a,t)})}const s=[];for(let a=0,o=e.length;a<o;a++){const c=e[a],u=ut(c),d=n[u];if(d)s.push(d.promise);else{let h;c.extensions&&c.extensions[E.KHR_DRACO_MESH_COMPRESSION]?h=i(c):h=_e(new l.BufferGeometry,c,t),n[u]={primitive:c,promise:h},s.push(h)}}return Promise.all(s)}loadMesh(e){const t=this,r=this.json,n=this.extensions,i=r.meshes[e],s=i.primitives,a=[];for(let o=0,c=s.length;o<c;o++){const u=s[o].material===void 0?at(this.cache):this.getDependency("material",s[o].material);a.push(u)}return a.push(t.loadGeometries(s)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),u=o[o.length-1],d=[];for(let p=0,g=u.length;p<g;p++){const y=u[p],m=s[p];let T;const _=c[p];if(m.mode===j.TRIANGLES||m.mode===j.TRIANGLE_STRIP||m.mode===j.TRIANGLE_FAN||m.mode===void 0)T=i.isSkinnedMesh===!0?new l.SkinnedMesh(y,_):new l.Mesh(y,_),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),m.mode===j.TRIANGLE_STRIP?T.geometry=Te(T.geometry,l.TriangleStripDrawMode):m.mode===j.TRIANGLE_FAN&&(T.geometry=Te(T.geometry,l.TriangleFanDrawMode));else if(m.mode===j.LINES)T=new l.LineSegments(y,_);else if(m.mode===j.LINE_STRIP)T=new l.Line(y,_);else if(m.mode===j.LINE_LOOP)T=new l.LineLoop(y,_);else if(m.mode===j.POINTS)T=new l.Points(y,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(T.geometry.morphAttributes).length>0&<(T,i),T.name=t.createUniqueName(i.name||"mesh_"+e),Y(T,i),m.extensions&&Z(n,T,m),t.assignFinalMaterial(T),d.push(T)}for(let p=0,g=d.length;p<g;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return i.extensions&&Z(n,d[0],i),d[0];const h=new l.Group;i.extensions&&Z(n,h,i),t.associations.set(h,{meshes:e});for(let p=0,g=d.length;p<g;p++)h.add(d[p]);return h})}loadCamera(e){let t;const r=this.json.cameras[e],n=r[r.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):r.type==="orthographic"&&(t=new l.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),Y(t,r),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],r=[];for(let n=0,i=t.joints.length;n<i;n++)r.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(n){const i=n.pop(),s=n,a=[],o=[];for(let c=0,u=s.length;c<u;c++){const d=s[c];if(d){a.push(d);const h=new l.Matrix4;i!==null&&h.fromArray(i.array,c*16),o.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new l.Skeleton(a,o)})}loadAnimation(e){const t=this.json,r=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,s=[],a=[],o=[],c=[],u=[];for(let d=0,h=n.channels.length;d<h;d++){const p=n.channels[d],g=n.samplers[p.sampler],y=p.target,m=y.node,T=n.parameters!==void 0?n.parameters[g.input]:g.input,_=n.parameters!==void 0?n.parameters[g.output]:g.output;y.node!==void 0&&(s.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",T)),o.push(this.getDependency("accessor",_)),c.push(g),u.push(y))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(u)]).then(function(d){const h=d[0],p=d[1],g=d[2],y=d[3],m=d[4],T=[];for(let _=0,N=h.length;_<N;_++){const S=h[_],H=p[_],U=g[_],I=y[_],A=m[_];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const R=r._createAnimationTracks(S,H,U,I,A);if(R)for(let M=0;M<R.length;M++)T.push(R[M])}return new l.AnimationClip(i,void 0,T)})}createNodeMesh(e){const t=this.json,r=this,n=t.nodes[e];return n.mesh===void 0?null:r.getDependency("mesh",n.mesh).then(function(i){const s=r._getNodeRef(r.meshCache,n.mesh,i);return n.weights!==void 0&&s.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),s})}loadNode(e){const t=this.json,r=this,n=t.nodes[e],i=r._loadNodeShallow(e),s=[],a=n.children||[];for(let c=0,u=a.length;c<u;c++)s.push(r.getDependency("node",a[c]));const o=n.skin===void 0?Promise.resolve(null):r.getDependency("skin",n.skin);return Promise.all([i,Promise.all(s),o]).then(function(c){const u=c[0],d=c[1],h=c[2];h!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(h,ht)});for(let p=0,g=d.length;p<g;p++)u.add(d[p]);return u})}_loadNodeShallow(e){const t=this.json,r=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],s=i.name?n.createUniqueName(i.name):"",a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return o&&a.push(o),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(c){return n._getNodeRef(n.cameraCache,i.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 u;if(i.isBone===!0?u=new l.Bone:c.length>1?u=new l.Group:c.length===1?u=c[0]:u=new l.Object3D,u!==c[0])for(let d=0,h=c.length;d<h;d++)u.add(c[d]);if(i.name&&(u.userData.name=i.name,u.name=s),Y(u,i),i.extensions&&Z(r,u,i),i.matrix!==void 0){const d=new l.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=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],n=this,i=new l.Group;r.name&&(i.name=n.createUniqueName(r.name)),Y(i,r),r.extensions&&Z(t,i,r);const s=r.nodes||[],a=[];for(let o=0,c=s.length;o<c;o++)a.push(n.getDependency("node",s[o]));return Promise.all(a).then(function(o){for(let u=0,d=o.length;u<d;u++)i.add(o[u]);const c=u=>{const d=new Map;for(const[h,p]of n.associations)(h instanceof l.Material||h instanceof l.Texture)&&d.set(h,p);return u.traverse(h=>{const p=n.associations.get(h);p!=null&&d.set(h,p)}),d};return n.associations=c(i),i})}_createAnimationTracks(e,t,r,n,i){const s=[],a=e.name?e.name:e.uuid,o=[];J[i.path]===J.weights?e.traverse(function(h){h.morphTargetInfluences&&o.push(h.name?h.name:h.uuid)}):o.push(a);let c;switch(J[i.path]){case J.weights:c=l.NumberKeyframeTrack;break;case J.rotation:c=l.QuaternionKeyframeTrack;break;case J.translation:case J.scale:c=l.VectorKeyframeTrack;break;default:switch(r.itemSize){case 1:c=l.NumberKeyframeTrack;break;case 2:case 3:default:c=l.VectorKeyframeTrack;break}break}const u=n.interpolation!==void 0?ot[n.interpolation]:l.InterpolateLinear,d=this._getArrayFromAccessor(r);for(let h=0,p=o.length;h<p;h++){const g=new c(o[h]+"."+J[i.path],t.array,d,u);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const r=pe(t.constructor),n=new Float32Array(t.length);for(let i=0,s=t.length;i<s;i++)n[i]=t[i]*r;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){const n=this instanceof l.QuaternionKeyframeTrack?it:Ie;return new n(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function pt(f,e,t){const r=e.attributes,n=new l.Box3;if(r.POSITION!==void 0){const a=t.json.accessors[r.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new l.Vector3(o[0],o[1],o[2]),new l.Vector3(c[0],c[1],c[2])),a.normalized){const u=pe(ne[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=e.targets;if(i!==void 0){const a=new l.Vector3,o=new l.Vector3;for(let c=0,u=i.length;c<u;c++){const d=i[c];if(d.POSITION!==void 0){const h=t.json.accessors[d.POSITION],p=h.min,g=h.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]))),h.normalized){const y=pe(ne[h.componentType]);o.multiplyScalar(y)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}f.boundingBox=n;const s=new l.Sphere;n.getCenter(s.center),s.radius=n.min.distanceTo(n.max)/2,f.boundingSphere=s}function _e(f,e,t){const r=e.attributes,n=[];function i(s,a){return t.getDependency("accessor",s).then(function(o){f.setAttribute(a,o)})}for(const s in r){const a=fe[s]||s.toLowerCase();a in f.attributes||n.push(i(r[s],a))}if(e.indices!==void 0&&!f.index){const s=t.getDependency("accessor",e.indices).then(function(a){f.setIndex(a)});n.push(s)}return l.ColorManagement.workingColorSpace!==l.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${l.ColorManagement.workingColorSpace}" not supported.`),Y(f,e),pt(f,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ct(f,e.targets,t):f})}class mt extends l.DataTextureLoader{constructor(e){super(e),this.type=l.HalfFloatType}parse(e){const s=function(A,R){switch(A){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(R||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(R||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(R||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(R||""))}},u=`
|
|
3
|
-
`,d=function(A,R,M){R=R||1024;let F=A.pos,P=-1,w=0,B="",C=String.fromCharCode.apply(null,new Uint16Array(A.subarray(F,F+128)));for(;0>(P=C.indexOf(u))&&w<R&&F<A.byteLength;)B+=C,w+=C.length,F+=128,C+=String.fromCharCode.apply(null,new Uint16Array(A.subarray(F,F+128)));return-1<P?(A.pos+=w+P+1,B+C.slice(0,P)):!1},h=function(A){const R=/^#\?(\S+)/,M=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,O=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,F=/^\s*FORMAT=(\S+)\s*$/,P=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,w={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let B,C;for((A.pos>=A.byteLength||!(B=d(A)))&&s(1,"no header found"),(C=B.match(R))||s(3,"bad initial token"),w.valid|=1,w.programtype=C[1],w.string+=B+`
|
|
4
|
-
`;B=d(A),B!==!1;){if(w.string+=B+`
|
|
5
|
-
`,B.charAt(0)==="#"){w.comments+=B+`
|
|
6
|
-
`;continue}if((C=B.match(M))&&(w.gamma=parseFloat(C[1])),(C=B.match(O))&&(w.exposure=parseFloat(C[1])),(C=B.match(F))&&(w.valid|=2,w.format=C[1]),(C=B.match(P))&&(w.valid|=4,w.height=parseInt(C[1],10),w.width=parseInt(C[2],10)),w.valid&2&&w.valid&4)break}return w.valid&2||s(3,"missing format specifier"),w.valid&4||s(3,"missing image size specifier"),w},p=function(A,R,M){const O=R;if(O<8||O>32767||A[0]!==2||A[1]!==2||A[2]&128)return new Uint8Array(A);O!==(A[2]<<8|A[3])&&s(3,"wrong scanline width");const F=new Uint8Array(4*R*M);F.length||s(4,"unable to allocate buffer space");let P=0,w=0;const B=4*O,C=new Uint8Array(4),Q=new Uint8Array(B);let ae=M;for(;ae>0&&w<A.byteLength;){w+4>A.byteLength&&s(1),C[0]=A[w++],C[1]=A[w++],C[2]=A[w++],C[3]=A[w++],(C[0]!=2||C[1]!=2||(C[2]<<8|C[3])!=O)&&s(3,"bad rgbe scanline format");let K=0,v;for(;K<B&&w<A.byteLength;){v=A[w++];const X=v>128;if(X&&(v-=128),(v===0||K+v>B)&&s(3,"bad scanline data"),X){const W=A[w++];for(let ge=0;ge<v;ge++)Q[K++]=W}else Q.set(A.subarray(w,w+v),K),K+=v,w+=v}const Ne=O;for(let X=0;X<Ne;X++){let W=0;F[P]=Q[X+W],W+=O,F[P+1]=Q[X+W],W+=O,F[P+2]=Q[X+W],W+=O,F[P+3]=Q[X+W],P+=4}ae--}return F},g=function(A,R,M,O){const F=A[R+3],P=Math.pow(2,F-128)/255;M[O+0]=A[R+0]*P,M[O+1]=A[R+1]*P,M[O+2]=A[R+2]*P,M[O+3]=1},y=function(A,R,M,O){const F=A[R+3],P=Math.pow(2,F-128)/255;M[O+0]=l.DataUtils.toHalfFloat(Math.min(A[R+0]*P,65504)),M[O+1]=l.DataUtils.toHalfFloat(Math.min(A[R+1]*P,65504)),M[O+2]=l.DataUtils.toHalfFloat(Math.min(A[R+2]*P,65504)),M[O+3]=l.DataUtils.toHalfFloat(1)},m=new Uint8Array(e);m.pos=0;const T=h(m),_=T.width,N=T.height,S=p(m.subarray(m.pos),_,N);let H,U,I;switch(this.type){case l.FloatType:I=S.length/4;const A=new Float32Array(I*4);for(let M=0;M<I;M++)g(S,M*4,A,M*4);H=A,U=l.FloatType;break;case l.HalfFloatType:I=S.length/4;const R=new Uint16Array(I*4);for(let M=0;M<I;M++)y(S,M*4,R,M*4);H=R,U=l.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:_,height:N,data:H,header:T.string,gamma:T.gamma,exposure:T.exposure,type:U}}setDataType(e){return this.type=e,this}load(e,t,r,n){function i(s,a){switch(s.type){case l.FloatType:case l.HalfFloatType:s.colorSpace=l.LinearSRGBColorSpace,s.minFilter=l.LinearFilter,s.magFilter=l.LinearFilter,s.generateMipmaps=!1,s.flipY=!0;break}t&&t(s,a)}return super.load(e,i,r,n)}}const b={c:null,u:[new l.Vector3,new l.Vector3,new l.Vector3],e:[]},L={c:null,u:[new l.Vector3,new l.Vector3,new l.Vector3],e:[]},k=[[],[],[]],x=[[],[],[]],D=[],$=new l.Vector3,ee=new l.Vector3,te=new l.Vector3,G=new l.Vector3,Se=new l.Vector3,Ee=new l.Vector3,z=new l.Matrix3,we=new l.Box3,oe=new l.Matrix4,be=new l.Matrix4,Me=new l.Ray;class me{constructor(e=new l.Vector3,t=new l.Vector3,r=new l.Matrix3){this.center=e,this.halfSize=t,this.rotation=r}set(e,t,r){return this.center=e,this.halfSize=t,this.rotation=r,this}copy(e){return this.center.copy(e.center),this.halfSize.copy(e.halfSize),this.rotation.copy(e.rotation),this}clone(){return new this.constructor().copy(this)}getSize(e){return e.copy(this.halfSize).multiplyScalar(2)}clampPoint(e,t){const r=this.halfSize;G.subVectors(e,this.center),this.rotation.extractBasis($,ee,te),t.copy(this.center);const n=l.MathUtils.clamp(G.dot($),-r.x,r.x);t.add($.multiplyScalar(n));const i=l.MathUtils.clamp(G.dot(ee),-r.y,r.y);t.add(ee.multiplyScalar(i));const s=l.MathUtils.clamp(G.dot(te),-r.z,r.z);return t.add(te.multiplyScalar(s)),t}containsPoint(e){return G.subVectors(e,this.center),this.rotation.extractBasis($,ee,te),Math.abs(G.dot($))<=this.halfSize.x&&Math.abs(G.dot(ee))<=this.halfSize.y&&Math.abs(G.dot(te))<=this.halfSize.z}intersectsBox3(e){return this.intersectsOBB(gt.fromBox3(e))}intersectsSphere(e){return this.clampPoint(e.center,Ee),Ee.distanceToSquared(e.center)<=e.radius*e.radius}intersectsOBB(e,t=Number.EPSILON){b.c=this.center,b.e[0]=this.halfSize.x,b.e[1]=this.halfSize.y,b.e[2]=this.halfSize.z,this.rotation.extractBasis(b.u[0],b.u[1],b.u[2]),L.c=e.center,L.e[0]=e.halfSize.x,L.e[1]=e.halfSize.y,L.e[2]=e.halfSize.z,e.rotation.extractBasis(L.u[0],L.u[1],L.u[2]);for(let i=0;i<3;i++)for(let s=0;s<3;s++)k[i][s]=b.u[i].dot(L.u[s]);G.subVectors(L.c,b.c),D[0]=G.dot(b.u[0]),D[1]=G.dot(b.u[1]),D[2]=G.dot(b.u[2]);for(let i=0;i<3;i++)for(let s=0;s<3;s++)x[i][s]=Math.abs(k[i][s])+t;let r,n;for(let i=0;i<3;i++)if(r=b.e[i],n=L.e[0]*x[i][0]+L.e[1]*x[i][1]+L.e[2]*x[i][2],Math.abs(D[i])>r+n)return!1;for(let i=0;i<3;i++)if(r=b.e[0]*x[0][i]+b.e[1]*x[1][i]+b.e[2]*x[2][i],n=L.e[i],Math.abs(D[0]*k[0][i]+D[1]*k[1][i]+D[2]*k[2][i])>r+n)return!1;return r=b.e[1]*x[2][0]+b.e[2]*x[1][0],n=L.e[1]*x[0][2]+L.e[2]*x[0][1],!(Math.abs(D[2]*k[1][0]-D[1]*k[2][0])>r+n||(r=b.e[1]*x[2][1]+b.e[2]*x[1][1],n=L.e[0]*x[0][2]+L.e[2]*x[0][0],Math.abs(D[2]*k[1][1]-D[1]*k[2][1])>r+n)||(r=b.e[1]*x[2][2]+b.e[2]*x[1][2],n=L.e[0]*x[0][1]+L.e[1]*x[0][0],Math.abs(D[2]*k[1][2]-D[1]*k[2][2])>r+n)||(r=b.e[0]*x[2][0]+b.e[2]*x[0][0],n=L.e[1]*x[1][2]+L.e[2]*x[1][1],Math.abs(D[0]*k[2][0]-D[2]*k[0][0])>r+n)||(r=b.e[0]*x[2][1]+b.e[2]*x[0][1],n=L.e[0]*x[1][2]+L.e[2]*x[1][0],Math.abs(D[0]*k[2][1]-D[2]*k[0][1])>r+n)||(r=b.e[0]*x[2][2]+b.e[2]*x[0][2],n=L.e[0]*x[1][1]+L.e[1]*x[1][0],Math.abs(D[0]*k[2][2]-D[2]*k[0][2])>r+n)||(r=b.e[0]*x[1][0]+b.e[1]*x[0][0],n=L.e[1]*x[2][2]+L.e[2]*x[2][1],Math.abs(D[1]*k[0][0]-D[0]*k[1][0])>r+n)||(r=b.e[0]*x[1][1]+b.e[1]*x[0][1],n=L.e[0]*x[2][2]+L.e[2]*x[2][0],Math.abs(D[1]*k[0][1]-D[0]*k[1][1])>r+n)||(r=b.e[0]*x[1][2]+b.e[1]*x[0][2],n=L.e[0]*x[2][1]+L.e[1]*x[2][0],Math.abs(D[1]*k[0][2]-D[0]*k[1][2])>r+n))}intersectsPlane(e){this.rotation.extractBasis($,ee,te);const t=this.halfSize.x*Math.abs(e.normal.dot($))+this.halfSize.y*Math.abs(e.normal.dot(ee))+this.halfSize.z*Math.abs(e.normal.dot(te)),r=e.normal.dot(this.center)-e.constant;return Math.abs(r)<=t}intersectRay(e,t){return this.getSize(Se),we.setFromCenterAndSize(G.set(0,0,0),Se),oe.setFromMatrix3(this.rotation),oe.setPosition(this.center),be.copy(oe).invert(),Me.copy(e).applyMatrix4(be),Me.intersectBox(we,t)?t.applyMatrix4(oe):null}intersectsRay(e){return this.intersectRay(e,G)!==null}fromBox3(e){return e.getCenter(this.center),e.getSize(this.halfSize).multiplyScalar(.5),this.rotation.identity(),this}equals(e){return e.center.equals(this.center)&&e.halfSize.equals(this.halfSize)&&e.rotation.equals(this.rotation)}applyMatrix4(e){const t=e.elements;let r=G.set(t[0],t[1],t[2]).length();const n=G.set(t[4],t[5],t[6]).length(),i=G.set(t[8],t[9],t[10]).length();e.determinant()<0&&(r=-r),z.setFromMatrix4(e);const a=1/r,o=1/n,c=1/i;return z.elements[0]*=a,z.elements[1]*=a,z.elements[2]*=a,z.elements[3]*=o,z.elements[4]*=o,z.elements[5]*=o,z.elements[6]*=c,z.elements[7]*=c,z.elements[8]*=c,this.rotation.multiply(z),this.halfSize.x*=r,this.halfSize.y*=n,this.halfSize.z*=i,G.setFromMatrixPosition(e),this.center.add(G),this}}const gt=new me,At=new mt,he={},Tt={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:Math.PI/2},q=new l.WebGLRenderer({antialias:!0,alpha:!0,precision:"mediump",logarithmicDepthBuffer:!0});function yt(f,e){const t=Object.assign({css3d:!1,stats:!1,axesHelper:{init:!1,size:10},gridHelper:{init:!1},control:{init:!0,options:{}},envImage:!0},e||{});let r,n,i,s,a=[];const o=Ae.ref(0),c=Ae.ref(0),u=new l.Scene({});u.background=new l.Color("#222b38");const d=new l.Group;u.add(d),q.setPixelRatio(window.devicePixelRatio);const h=new l.PerspectiveCamera(50,1,.1,2e3),p=Math.tan(Math.PI/180*h.fov/2);function g(){const I=_();if(o.value=I[0],c.value=I[1],h.aspect=o.value/c.value,h.position.set(47,39,100),h.fov=360/Math.PI*Math.atan(p*(c.value/o.value)),h.updateProjectionMatrix(),q.setSize(o.value,c.value),r.appendChild(q.domElement),t.envImage&&Ce(u),t.stats&&N(),t.css3d&&H(),t.axesHelper&&t.axesHelper.init){const A=se.createAxesHelper(t.axesHelper.size||10);u.add(A)}if(t.gridHelper&&t.gridHelper.init){const A=se.createGridHelper(t.gridHelper.size||150,t.gridHelper.options||{});u.add(A)}if(t.control&&t.control.init){s=se.createOrbitControl(h,q.domElement);const A=t.control.options||Tt;Object.keys(A).forEach(R=>{s[R]=A[R]})}return{control:s,scene:u,camera:h,renderer:q}}function y(I){a.push(I)}function m(I){a&&a.length&&a.forEach(A=>{typeof A=="function"&&A()}),s&&s.update(),q.render(u,h),n&&n.update(),i&&i.render(u,h),requestAnimationFrame(m)}function T(){nextTick(()=>{const I=_();o.value=I[0],c.value=I[1],h.aspect=o.value/c.value,h.fov=360/Math.PI*Math.atan(p*(c.value/o.value)),h.updateProjectionMatrix(),h.lookAt(u.position),q.render(u,h),q.setSize(o.value,c.value),i&&i.setSize(o.value,c.value)})}function _(){return r=document.querySelector(f),[r.clientWidth,r.clientHeight]}function N(){n=new ie,n.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.appendChild(n.dom)}function S(I,A,R,M){const O=new l.Box3().setFromObject(I),F=O.getSize(new l.Vector3).length(),P=O.getCenter(new l.Vector3),B=F*A*.5,C=l.MathUtils.degToRad(R.fov*.5),Q=B/Math.tan(C),K=new l.Vector3().subVectors(R.position,P).multiply(new l.Vector3(1,1,1)).normalize().multiplyScalar(Q).add(P),v={x:K.x,y:K.y,z:K.z,lookAt_x:P.x,lookAt_y:P.y,lookAt_z:P.z};return R.position.set(v.x,v.y,v.z),R.lookAt(v.lookAt_x,v.lookAt_y,v.lookAt_z),R.updateProjectionMatrix(),M.target.copy(P),M.update(),F}function H(){i=new se.CSS3DRenderer,i.setSize(o.value,c.value),i.domElement.style.position="absolute",i.domElement.style.top=0,i.domElement.style.left=0,i.domElement.style.pointerEvents="none",r.appendChild(i.domElement)}function U(){se.disposeThreeObject(u)}return{init:g,dispose:U,animate:m,onResize:T,addAnimate:y,frameArea:S,objectGroup:d,scene:u,camera:h,control:s,renderer:q,domWidth:o,domHeight:c}}async function Ce(f,e){if(e){if(he[e]){const t=he[e];f.environment=t;return}return new Promise((t,r)=>{At.load(e,t,void 0,r)}).then(t=>{t.mapping=l.EquirectangularReflectionMapping,f.environment=t,he[e]=t}).catch(t=>{console.log(" =====> e:",t)})}}const Rt=(f="app")=>{const e=new l.Raycaster;e.params.Line.threshold=8;const t=new l.Vector2,r=document.getElementById(f);function n(a,o){const{scaleX:c,scaleY:u}=s(r),{clientWidth:d,clientHeight:h}=o,p=o.getBoundingClientRect(),g=d*c,y=h*u,m=a.clientX-p.left,T=a.clientY-p.top;return t.x=(a.clientX-p.left)/g*2-1,t.y=-((a.clientY-p.top)/y)*2+1,{pointer:t,x:m,y:T}}function i(a,o,c,u){const{pointer:d,x:h,y:p}=n(a,o);return e.setFromCamera(d,c),{intersects:e.intersectObjects(u),pointer:d,x:h,y:p}}function s(a){const o=window.getComputedStyle(a),c=o.transform||o.webkitTransform||o.mozTransform;if(c&&c!=="none"){const u=c.match(/^matrix\((.+)\)$/);if(u){const d=u[1].split(", "),h=parseFloat(d[0]),p=parseFloat(d[3]);return{scaleX:h,scaleY:p}}}return{scaleX:1,scaleY:1}}return{raycaster:e,pointer:t,getPointer:n,getScale:s,getIntersects:i}},V=[],xt=new l.Color(16711680),_t=()=>{const f=()=>{V.splice(0)},e=(a,o)=>{o.traverse(c=>{c&&t(a,c)})},t=(a,o)=>{if(o.userData.needCheck&&(o.autoUpdateMatrix=!1,o.updateMatrix(),o.updateMatrixWorld(),o.isMesh)){const c=new l.Box3(new l.Vector3).setFromObject(o);o.geometry.userData.obb=new me,o.geometry.userData.obb.halfSize.copy(c.getSize(new l.Vector3)).multiplyScalar(.5).multiplyScalar(.88),o.userData.obb=new me,o.userData.originColor=o.material.color.clone(),o.userData.parentUid=a,V.push({object:o,parentUid:a})}};return{resetObbs:f,initObb:e,getObbObjectByParentUid:a=>V.filter(o=>o.parentUid===a),addObbFromArray:(a,o)=>{for(let c=0,u=o.length;c<u;c++)t(a,o[c])},removeObbFromArray:a=>{const o=V.filter(c=>!a.includes(c.object));V.splice(0,V.length,...o)},removeUidObb:a=>{for(let o=V.length-1;o>=0;o--)V[o].parentUid===a&&V.splice(o,1)}}},St=()=>{const f=new l.AmbientLight(16777215,1),e=new l.SpotLight(16777215,1,0);e.position.set(0,50,100),e.angle=Math.PI/8,e.penumbra=1,e.decay=0,e.distance=0;const t=e.clone();return t.position.set(-100,50,-100),t.angle=Math.PI/8,t.penumbra=1,t.decay=0,t.distance=0,[f,e,t]},Et=()=>{const f=new De,e=new Pe;e.setDecoderPath("/draco/"),f.setDRACOLoader(e);function t(n,i,s,a){return f.load(n,i,s,a)}function r(n,i){return new Promise((s,a)=>{f.load(n,s,i,a)})}return{load:t,asyncLoad:r}};exports.initEnvImage=Ce;exports.intersectColor=xt;exports.obbObjects=V;exports.useGLTFLoader=Et;exports.useLight=St;exports.useObb=_t;exports.useRaycaster=Rt;exports.useThreeJs=yt;
|