1 Star 0 Fork 0

show-case/introduce

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
864.91523b359f283740.js 52.93 KB
一键复制 编辑 原始数据 按行查看 历史
Mel 提交于 2023-10-25 14:37 . :art:
"use strict";(self.webpackChunkintroduce=self.webpackChunkintroduce||[]).push([[864],{9011:(ze,Me,pe)=>{pe.d(Me,{_:()=>Be});var d=pe(6682);const be=new WeakMap;class Be extends d.aNw{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,I,M,_){const k=new d.hH6(this.manager);k.setPath(this.path),k.setResponseType("arraybuffer"),k.setRequestHeader(this.requestHeader),k.setWithCredentials(this.withCredentials),k.load(E,y=>{this.parse(y,I,_)},M,_)}parse(E,I,M){this.decodeDracoFile(E,I,null,null,d.KI_).catch(M)}decodeDracoFile(E,I,M,_,k=d.GUF){return this.decodeGeometry(E,{attributeIDs:M||this.defaultAttributeIDs,attributeTypes:_||this.defaultAttributeTypes,useUniqueIDs:!!M,vertexColorSpace:k}).then(I)}decodeGeometry(E,I){const M=JSON.stringify(I);if(be.has(E)){const F=be.get(E);if(F.key===M)return F.promise;if(0===E.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let _;const k=this.workerNextTaskID++,B=this._getWorker(k,E.byteLength).then(F=>(_=F,new Promise((J,X)=>{_._callbacks[k]={resolve:J,reject:X},_.postMessage({type:"decode",id:k,taskConfig:I,buffer:E},[E])}))).then(F=>this._createGeometry(F.geometry));return B.catch(()=>!0).then(()=>{_&&k&&this._releaseTask(_,k)}),be.set(E,{key:M,promise:B}),B}_createGeometry(E){const I=new d.u9r;E.index&&I.setIndex(new d.TlE(E.index.array,1));for(let M=0;M<E.attributes.length;M++){const _=E.attributes[M],k=_.name,y=_.array,F=new d.TlE(y,_.itemSize);"color"===k&&(this._assignVertexColorSpace(F,_.vertexColorSpace),F.normalized=!(y instanceof Float32Array)),I.setAttribute(k,F)}return I}_assignVertexColorSpace(E,I){if(I!==d.KI_)return;const M=new d.Ilk;for(let _=0,k=E.count;_<k;_++)M.fromBufferAttribute(E,_).convertSRGBToLinear(),E.setXYZ(_,M.r,M.g,M.b)}_loadLibrary(E,I){const M=new d.hH6(this.manager);return M.setPath(this.decoderPath),M.setResponseType(I),M.setWithCredentials(this.withCredentials),new Promise((_,k)=>{M.load(E,_,void 0,k)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const E="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,I=[];return E?I.push(this._loadLibrary("draco_decoder.js","text")):(I.push(this._loadLibrary("draco_wasm_wrapper.js","text")),I.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(I).then(M=>{const _=M[0];E||(this.decoderConfig.wasmBinary=M[1]);const k=Q.toString(),y=["/* draco decoder */",_,"","/* worker */",k.substring(k.indexOf("{")+1,k.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([y]))}),this.decoderPending}_getWorker(E,I){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const _=new Worker(this.workerSourceURL);_._callbacks={},_._taskCosts={},_._taskLoad=0,_.postMessage({type:"init",decoderConfig:this.decoderConfig}),_.onmessage=function(k){const y=k.data;switch(y.type){case"decode":_._callbacks[y.id].resolve(y);break;case"error":_._callbacks[y.id].reject(y);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+y.type+'"')}},this.workerPool.push(_)}else this.workerPool.sort(function(_,k){return _._taskLoad>k._taskLoad?-1:1});const M=this.workerPool[this.workerPool.length-1];return M._taskCosts[E]=I,M._taskLoad+=I,M})}_releaseTask(E,I){E._taskLoad-=E._taskCosts[I],delete E._callbacks[I],delete E._taskCosts[I]}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 Q(){let fe,E;function _(y,B,F,J,X,Y){const U=Y.num_components(),w=F.num_points()*U,q=w*X.BYTES_PER_ELEMENT,ee=function k(y,B){switch(B){case Float32Array:return y.DT_FLOAT32;case Int8Array:return y.DT_INT8;case Int16Array:return y.DT_INT16;case Int32Array:return y.DT_INT32;case Uint8Array:return y.DT_UINT8;case Uint16Array:return y.DT_UINT16;case Uint32Array:return y.DT_UINT32}}(y,X),le=y._malloc(q);B.GetAttributeDataArrayForAllPoints(F,Y,ee,q,le);const te=new X(y.HEAPF32.buffer,le,w).slice();return y._free(le),{name:J,array:te,itemSize:U}}onmessage=function(y){const B=y.data;switch(B.type){case"init":fe=B.decoderConfig,E=new Promise(function(X){fe.onModuleLoaded=function(Y){X({draco:Y})},DracoDecoderModule(fe)});break;case"decode":const F=B.buffer,J=B.taskConfig;E.then(X=>{const Y=X.draco,U=new Y.Decoder;try{const W=function I(y,B,F,J){const X=J.attributeIDs,Y=J.attributeTypes;let U,W;const w=B.GetEncodedGeometryType(F);if(w===y.TRIANGULAR_MESH)U=new y.Mesh,W=B.DecodeArrayToMesh(F,F.byteLength,U);else{if(w!==y.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");U=new y.PointCloud,W=B.DecodeArrayToPointCloud(F,F.byteLength,U)}if(!W.ok()||0===U.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+W.error_msg());const q={index:null,attributes:[]};for(const ee in X){const le=self[Y[ee]];let te,re;if(J.useUniqueIDs)re=X[ee],te=B.GetAttributeByUniqueId(U,re);else{if(re=B.GetAttributeId(U,y[X[ee]]),-1===re)continue;te=B.GetAttribute(U,re)}const me=_(y,B,U,ee,le,te);"color"===ee&&(me.vertexColorSpace=J.vertexColorSpace),q.attributes.push(me)}return w===y.TRIANGULAR_MESH&&(q.index=function M(y,B,F){const X=3*F.num_faces(),Y=4*X,U=y._malloc(Y);B.GetTrianglesUInt32Array(F,Y,U);const W=new Uint32Array(y.HEAPF32.buffer,U,X).slice();return y._free(U),{array:W,itemSize:1}}(y,B,U)),y.destroy(U),q}(Y,U,new Int8Array(F),J),w=W.attributes.map(q=>q.array.buffer);W.index&&w.push(W.index.array.buffer),self.postMessage({type:"decode",id:B.id,geometry:W},w)}catch(W){console.error(W),self.postMessage({type:"error",id:B.id,error:W.message})}finally{Y.destroy(U)}})}}}},6497:(ze,Me,pe)=>{pe.d(Me,{E:()=>U});var d=pe(6682);function y(u,t){if(t===d.WwZ)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),u;if(t===d.z$h||t===d.UlW){let e=u.getIndex();if(null===e){const s=[],a=u.getAttribute("position");if(void 0===a)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),u;for(let i=0;i<a.count;i++)s.push(i);u.setIndex(s),e=u.getIndex()}const o=e.count-2,n=[];if(t===d.z$h)for(let s=1;s<=o;s++)n.push(e.getX(0)),n.push(e.getX(s)),n.push(e.getX(s+1));else for(let s=0;s<o;s++)s%2==0?(n.push(e.getX(s)),n.push(e.getX(s+1)),n.push(e.getX(s+2))):(n.push(e.getX(s+2)),n.push(e.getX(s+1)),n.push(e.getX(s)));n.length/3!==o&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=u.clone();return r.setIndex(n),r.clearGroups(),r}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),u}class U extends d.aNw{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new te(e)}),this.register(function(e){return new z(e)}),this.register(function(e){return new j(e)}),this.register(function(e){return new N(e)}),this.register(function(e){return new me(e)}),this.register(function(e){return new ge(e)}),this.register(function(e){return new L(e)}),this.register(function(e){return new G(e)}),this.register(function(e){return new le(e)}),this.register(function(e){return new O(e)}),this.register(function(e){return new re(e)}),this.register(function(e){return new V(e)}),this.register(function(e){return new q(e)}),this.register(function(e){return new K(e)}),this.register(function(e){return new D(e)})}load(t,e,o,n){const r=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:d.Zp0.extractUrlBase(t),this.manager.itemStart(t);const a=function(c){n?n(c):console.error(c),r.manager.itemError(t),r.manager.itemEnd(t)},i=new d.hH6(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(t,function(c){try{r.parse(c,s,function(l){e(l),r.manager.itemEnd(t)},a)}catch(l){a(l)}},o,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,o,n){let r;const s={},a={},i=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer)if(i.decode(new Uint8Array(t,0,4))===de){try{s[w.KHR_BINARY_GLTF]=new oe(t)}catch(f){return void(n&&n(f))}r=JSON.parse(s[w.KHR_BINARY_GLTF].content)}else r=JSON.parse(i.decode(t));else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=new rt(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){const f=this.pluginCallbacks[l](c);a[f.name]=f,s[f.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){const f=r.extensionsUsed[l],h=r.extensionsRequired||[];switch(f){case w.KHR_MATERIALS_UNLIT:s[f]=new ee;break;case w.KHR_DRACO_MESH_COMPRESSION:s[f]=new Oe(r,this.dracoLoader);break;case w.KHR_TEXTURE_TRANSFORM:s[f]=new ie;break;case w.KHR_MESH_QUANTIZATION:s[f]=new ae;break;default:h.indexOf(f)>=0&&void 0===a[f]&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(s),c.setPlugins(a),c.parse(o,n)}parseAsync(t,e){const o=this;return new Promise(function(n,r){o.parse(t,e,n,r)})}}function W(){let u={};return{get:function(t){return u[t]},add:function(t,e){u[t]=e},remove:function(t){delete u[t]},removeAll:function(){u={}}}}const w={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_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_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 q{constructor(t){this.parser=t,this.name=w.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let o=0,n=e.length;o<n;o++){const r=e[o];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const e=this.parser,o="light:"+t;let n=e.cache.get(o);if(n)return n;const r=e.json,i=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let c;const l=new d.Ilk(16777215);void 0!==i.color&&l.setRGB(i.color[0],i.color[1],i.color[2],d.GUF);const f=void 0!==i.range?i.range:0;switch(i.type){case"directional":c=new d.Ox3(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new d.cek(l),c.distance=f;break;case"spot":c=new d.PMe(l),c.distance=f,i.spot=i.spot||{},i.spot.innerConeAngle=void 0!==i.spot.innerConeAngle?i.spot.innerConeAngle:0,i.spot.outerConeAngle=void 0!==i.spot.outerConeAngle?i.spot.outerConeAngle:Math.PI/4,c.angle=i.spot.outerConeAngle,c.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return c.position.set(0,0,0),c.decay=2,Ee(c,i),void 0!==i.intensity&&(c.intensity=i.intensity),c.name=e.createUniqueName(i.name||"light_"+t),n=Promise.resolve(c),e.cache.add(o,n),n}getDependency(t,e){if("light"===t)return this._loadLight(e)}createNodeAttachment(t){const e=this,o=this.parser,r=o.json.nodes[t],a=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===a?null:this._loadLight(a).then(function(i){return o._getNodeRef(e.cache,a,i)})}}class ee{constructor(){this.name=w.KHR_MATERIALS_UNLIT}getMaterialType(){return d.vBJ}extendParams(t,e,o){const n=[];t.color=new d.Ilk(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const s=r.baseColorFactor;t.color.setRGB(s[0],s[1],s[2],d.GUF),t.opacity=s[3]}void 0!==r.baseColorTexture&&n.push(o.assignTexture(t,"map",r.baseColorTexture,d.KI_))}return Promise.all(n)}}class le{constructor(t){this.parser=t,this.name=w.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 r=n.extensions[this.name].emissiveStrength;return void 0!==r&&(e.emissiveIntensity=r),Promise.resolve()}}class te{constructor(t){this.parser=t,this.name=w.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const o=this.parser.json.materials[t];return o.extensions&&o.extensions[this.name]?d.EJi:null}extendMaterialParams(t,e){const o=this.parser,n=o.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];if(void 0!==s.clearcoatFactor&&(e.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(o.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(o.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(o.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const a=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new d.FM8(a,a)}return Promise.all(r)}}class re{constructor(t){this.parser=t,this.name=w.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const o=this.parser.json.materials[t];return o.extensions&&o.extensions[this.name]?d.EJi:null}extendMaterialParams(t,e){const o=this.parser,n=o.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return void 0!==s.iridescenceFactor&&(e.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(o.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(e.iridescenceIOR=s.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(o.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class me{constructor(t){this.parser=t,this.name=w.KHR_MATERIALS_SHEEN}getMaterialType(t){const o=this.parser.json.materials[t];return o.extensions&&o.extensions[this.name]?d.EJi:null}extendMaterialParams(t,e){const o=this.parser,n=o.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new d.Ilk(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=n.extensions[this.name];if(void 0!==s.sheenColorFactor){const a=s.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],d.GUF)}return void 0!==s.sheenRoughnessFactor&&(e.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(o.assignTexture(e,"sheenColorMap",s.sheenColorTexture,d.KI_)),void 0!==s.sheenRoughnessTexture&&r.push(o.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class ge{constructor(t){this.parser=t,this.name=w.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const o=this.parser.json.materials[t];return o.extensions&&o.extensions[this.name]?d.EJi:null}extendMaterialParams(t,e){const o=this.parser,n=o.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(o.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class L{constructor(t){this.parser=t,this.name=w.KHR_MATERIALS_VOLUME}getMaterialType(t){const o=this.parser.json.materials[t];return o.extensions&&o.extensions[this.name]?d.EJi:null}extendMaterialParams(t,e){const o=this.parser,n=o.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];e.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(o.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return e.attenuationColor=(new d.Ilk).setRGB(a[0],a[1],a[2],d.GUF),Promise.all(r)}}class G{constructor(t){this.parser=t,this.name=w.KHR_MATERIALS_IOR}getMaterialType(t){const o=this.parser.json.materials[t];return o.extensions&&o.extensions[this.name]?d.EJi:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return e.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class O{constructor(t){this.parser=t,this.name=w.KHR_MATERIALS_SPECULAR}getMaterialType(t){const o=this.parser.json.materials[t];return o.extensions&&o.extensions[this.name]?d.EJi:null}extendMaterialParams(t,e){const o=this.parser,n=o.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];e.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(o.assignTexture(e,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return e.specularColor=(new d.Ilk).setRGB(a[0],a[1],a[2],d.GUF),void 0!==s.specularColorTexture&&r.push(o.assignTexture(e,"specularColorMap",s.specularColorTexture,d.KI_)),Promise.all(r)}}class V{constructor(t){this.parser=t,this.name=w.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const o=this.parser.json.materials[t];return o.extensions&&o.extensions[this.name]?d.EJi:null}extendMaterialParams(t,e){const o=this.parser,n=o.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],s=n.extensions[this.name];return void 0!==s.anisotropyStrength&&(e.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(e.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(o.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class z{constructor(t){this.parser=t,this.name=w.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,o=e.json,n=o.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(o.extensionsRequired&&o.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class j{constructor(t){this.parser=t,this.name=w.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,o=this.parser,n=o.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let i=o.textureLoader;if(a.uri){const c=o.options.manager.getHandler(a.uri);null!==c&&(i=c)}return this.detectSupport().then(function(c){if(c)return o.loadTextureImage(t,s.source,i);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return o.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(1===e.height)}})),this.isSupported}}class N{constructor(t){this.parser=t,this.name=w.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,o=this.parser,n=o.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let i=o.textureLoader;if(a.uri){const c=o.options.manager.getHandler(a.uri);null!==c&&(i=c)}return this.detectSupport().then(function(c){if(c)return o.loadTextureImage(t,s.source,i);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return o.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(1===e.height)}})),this.isSupported}}class K{constructor(t){this.name=w.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,o=e.bufferViews[t];if(o.extensions&&o.extensions[this.name]){const n=o.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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 r.then(function(a){const l=n.count,f=n.byteStride,h=new Uint8Array(a,n.byteOffset||0,n.byteLength||0);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(l,f,h,n.mode,n.filter).then(function(p){return p.buffer}):s.ready.then(function(){const p=new ArrayBuffer(l*f);return s.decodeGltfBuffer(new Uint8Array(p),l,f,h,n.mode,n.filter),p})})}return null}}class D{constructor(t){this.name=w.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,o=e.nodes[t];if(!o.extensions||!o.extensions[this.name]||void 0===o.mesh)return null;const n=e.meshes[o.mesh];for(const c of n.primitives)if(c.mode!==ne.TRIANGLES&&c.mode!==ne.TRIANGLE_STRIP&&c.mode!==ne.TRIANGLE_FAN&&void 0!==c.mode)return null;const s=o.extensions[this.name].attributes,a=[],i={};for(const c in s)a.push(this.parser.getDependency("accessor",s[c]).then(l=>(i[c]=l,i[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const l=c.pop(),f=l.isGroup?l.children:[l],h=c[0].count,p=[];for(const A of f){const g=new d.yGw,m=new d.Pa4,T=new d._fP,R=new d.Pa4(1,1,1),x=new d.SPe(A.geometry,A.material,h);for(let b=0;b<h;b++)i.TRANSLATION&&m.fromBufferAttribute(i.TRANSLATION,b),i.ROTATION&&T.fromBufferAttribute(i.ROTATION,b),i.SCALE&&R.fromBufferAttribute(i.SCALE,b),x.setMatrixAt(b,g.compose(m,T,R));for(const b in i)"TRANSLATION"!==b&&"ROTATION"!==b&&"SCALE"!==b&&A.geometry.setAttribute(b,i[b]);d.Tme.prototype.copy.call(x,A),this.parser.assignFinalMaterial(x),p.push(x)}return l.isGroup?(l.clear(),l.add(...p),l):p[0]}))}}const de="glTF";class oe{constructor(t){this.name=w.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),o=new TextDecoder;if(this.header={magic:o.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.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-12,r=new DataView(t,12);let s=0;for(;s<n;){const a=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,1313821514===i){const c=new Uint8Array(t,12+s,a);this.content=o.decode(c)}else if(5130562===i){const c=12+s;this.body=t.slice(c,c+a)}s+=a}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Oe{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=w.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const o=this.json,n=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},i={},c={};for(const l in s){const f=Fe[l]||l.toLowerCase();a[f]=s[l]}for(const l in t.attributes){const f=Fe[l]||l.toLowerCase();if(void 0!==s[l]){const h=o.accessors[t.attributes[l]];c[f]=xe[h.componentType].name,i[f]=!0===h.normalized}}return e.getDependency("bufferView",r).then(function(l){return new Promise(function(f){n.decodeDracoFile(l,function(h){for(const p in h.attributes){const A=h.attributes[p],g=i[p];void 0!==g&&(A.normalized=g)}f(h)},a,c)})})}}class ie{constructor(){this.name=w.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(void 0===e.texCoord||e.texCoord===t.channel)&&void 0===e.offset&&void 0===e.rotation&&void 0===e.scale||(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class ae{constructor(){this.name=w.KHR_MESH_QUANTIZATION}}class Ne extends d._C8{constructor(t,e,o,n){super(t,e,o,n)}copySampleValue_(t){const e=this.resultBuffer,o=this.sampleValues,n=this.valueSize,r=t*n*3+n;for(let s=0;s!==n;s++)e[s]=o[r+s];return e}interpolate_(t,e,o,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,i=2*a,c=3*a,l=n-e,f=(o-e)/l,h=f*f,p=h*f,A=t*c,g=A-c,m=-2*p+3*h,T=p-h,R=1-m,x=T-h+f;for(let b=0;b!==a;b++)r[b]=R*s[g+b+a]+x*(s[g+b+i]*l)+m*s[A+b+a]+T*(s[A+b]*l);return r}}const qe=new d._fP;class Ze extends Ne{interpolate_(t,e,o,n){const r=super.interpolate_(t,e,o,n);return qe.fromArray(r).normalize().toArray(r),r}}const ne={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},xe={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ke={9728:d.TyD,9729:d.wem,9984:d.YLQ,9985:d.qyh,9986:d.aH4,9987:d.D1R},Xe={33071:d.uWy,33648:d.OoA,10497:d.rpg},De={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"},_e={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Je={CUBICSPLINE:void 0,LINEAR:d.NMF,STEP:d.Syv};function Re(u,t,e){for(const o in e.extensions)void 0===u[o]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[o]=e.extensions[o])}function Ee(u,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(u.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function et(u,t){if(u.updateMorphTargets(),void 0!==t.weights)for(let e=0,o=t.weights.length;e<o;e++)u.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(u.morphTargetInfluences.length===e.length){u.morphTargetDictionary={};for(let o=0,n=e.length;o<n;o++)u.morphTargetDictionary[e[o]]=o}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function tt(u){let t;const e=u.extensions&&u.extensions[w.KHR_DRACO_MESH_COMPRESSION];if(t=e?"draco:"+e.bufferView+":"+e.indices+":"+Ue(e.attributes):u.indices+":"+Ue(u.attributes)+":"+u.mode,void 0!==u.targets)for(let o=0,n=u.targets.length;o<n;o++)t+=":"+Ue(u.targets[o]);return t}function Ue(u){let t="";const e=Object.keys(u).sort();for(let o=0,n=e.length;o<n;o++)t+=e[o]+":"+u[e[o]]+";";return t}function He(u){switch(u){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.")}}const st=new d.yGw;class rt{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new W,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 o=!1,n=!1,r=-1;typeof navigator<"u"&&(o=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),n=navigator.userAgent.indexOf("Firefox")>-1,r=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),this.textureLoader=typeof createImageBitmap>"u"||o||n&&r<98?new d.dpR(this.options.manager):new d.QRU(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.hH6(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const o=this,n=this.json,r=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([o.getDependencies("scene"),o.getDependencies("animation"),o.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:o,userData:{}};Re(r,a,n),Ee(a,n),Promise.all(o._invokeAll(function(i){return i.afterRoot&&i.afterRoot(a)})).then(function(){t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],o=this.json.meshes||[];for(let n=0,r=e.length;n<r;n++){const s=e[n].joints;for(let a=0,i=s.length;a<i;a++)t[s[a]].isBone=!0}for(let n=0,r=t.length;n<r;n++){const s=t[n];void 0!==s.mesh&&(this._addNodeRef(this.meshCache,s.mesh),void 0!==s.skin&&(o[s.mesh].isSkinnedMesh=!0)),void 0!==s.camera&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,o){if(t.refs[e]<=1)return o;const n=o.clone(),r=(s,a)=>{const i=this.associations.get(s);null!=i&&this.associations.set(a,i);for(const[c,l]of s.children.entries())r(l,a.children[c])};return r(o,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let o=0;o<e.length;o++){const n=t(e[o]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const o=[];for(let n=0;n<e.length;n++){const r=t(e[n]);r&&o.push(r)}return o}getDependency(t,e){const o=t+":"+e;let n=this.cache.get(o);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case"mesh":n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t)}this.cache.add(o,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const o=this;e=Promise.all((this.json[t+("mesh"===t?"es":"s")]||[]).map(function(r,s){return o.getDependency(t,s)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],o=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[w.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(r,s){o.load(d.Zp0.resolveURL(e.uri,n.path),r,void 0,function(){s(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(o){const r=e.byteOffset||0;return o.slice(r,r+(e.byteLength||0))})}loadAccessor(t){const e=this,o=this.json,n=this.json.accessors[t];if(void 0===n.bufferView&&void 0===n.sparse){const s=De[n.type],i=!0===n.normalized,c=new(0,xe[n.componentType])(n.count*s);return Promise.resolve(new d.TlE(c,s,i))}const r=[];return r.push(void 0!==n.bufferView?this.getDependency("bufferView",n.bufferView):null),void 0!==n.sparse&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(s){const a=s[0],i=De[n.type],c=xe[n.componentType],l=c.BYTES_PER_ELEMENT,h=n.byteOffset||0,p=void 0!==n.bufferView?o.bufferViews[n.bufferView].byteStride:void 0,A=!0===n.normalized;let g,m;if(p&&p!==l*i){const T=Math.floor(h/p),R="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+T+":"+n.count;let x=e.cache.get(R);x||(g=new c(a,T*p,n.count*p/l),x=new d.vpT(g,p/l),e.cache.add(R,x)),m=new d.kB5(x,i,h%p/l,A)}else g=null===a?new c(n.count*i):new c(a,h,n.count*i),m=new d.TlE(g,i,A);if(void 0!==n.sparse){const b=n.sparse.values.byteOffset||0,H=new(0,xe[n.sparse.indices.componentType])(s[1],n.sparse.indices.byteOffset||0,n.sparse.count*De.SCALAR),v=new c(s[2],b,n.sparse.count*i);null!==a&&(m=new d.TlE(m.array.slice(),m.itemSize,m.normalized));for(let C=0,S=H.length;C<S;C++){const P=H[C];if(m.setX(P,v[C*i]),i>=2&&m.setY(P,v[C*i+1]),i>=3&&m.setZ(P,v[C*i+2]),i>=4&&m.setW(P,v[C*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(t){const e=this.json,r=e.textures[t].source,s=e.images[r];let a=this.textureLoader;if(s.uri){const i=this.options.manager.getHandler(s.uri);null!==i&&(a=i)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,o){const n=this,r=this.json,s=r.textures[t],a=r.images[e],i=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[i])return this.textureCache[i];const c=this.loadImageSource(e,o).then(function(l){l.flipY=!1,l.name=s.name||a.name||"",""===l.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(l.name=a.uri);const h=(r.samplers||{})[s.sampler]||{};return l.magFilter=Ke[h.magFilter]||d.wem,l.minFilter=Ke[h.minFilter]||d.D1R,l.wrapS=Xe[h.wrapS]||d.rpg,l.wrapT=Xe[h.wrapT]||d.rpg,n.associations.set(l,{textures:t}),l}).catch(function(){return null});return this.textureCache[i]=c,c}loadImageSource(t,e){const n=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then(f=>f.clone());const s=n.images[t],a=self.URL||self.webkitURL;let i=s.uri||"",c=!1;if(void 0!==s.bufferView)i=this.getDependency("bufferView",s.bufferView).then(function(f){c=!0;const h=new Blob([f],{type:s.mimeType});return i=a.createObjectURL(h),i});else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(i).then(function(f){return new Promise(function(h,p){let A=h;!0===e.isImageBitmapLoader&&(A=function(g){const m=new d.xEZ(g);m.needsUpdate=!0,h(m)}),e.load(d.Zp0.resolveURL(f,r.path),A,void 0,p)})}).then(function(f){return!0===c&&a.revokeObjectURL(i),f.userData.mimeType=s.mimeType||function nt(u){return u.search(/\.jpe?g($|\?)/i)>0||0===u.search(/^data\:image\/jpeg/)?"image/jpeg":u.search(/\.webp($|\?)/i)>0||0===u.search(/^data\:image\/webp/)?"image/webp":"image/png"}(s.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),f});return this.sourceCache[t]=l,l}assignTexture(t,e,o,n){const r=this;return this.getDependency("texture",o.index).then(function(s){if(!s)return null;if(void 0!==o.texCoord&&o.texCoord>0&&((s=s.clone()).channel=o.texCoord),r.extensions[w.KHR_TEXTURE_TRANSFORM]){const a=void 0!==o.extensions?o.extensions[w.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const i=r.associations.get(s);s=r.extensions[w.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),r.associations.set(s,i)}}return void 0!==n&&(s.colorSpace=n),t[e]=s,s})}assignFinalMaterial(t){const e=t.geometry;let o=t.material;const n=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const a="PointsMaterial:"+o.uuid;let i=this.cache.get(a);i||(i=new d.UY4,d.F5T.prototype.copy.call(i,o),i.color.copy(o.color),i.map=o.map,i.sizeAttenuation=!1,this.cache.add(a,i)),o=i}else if(t.isLine){const a="LineBasicMaterial:"+o.uuid;let i=this.cache.get(a);i||(i=new d.nls,d.F5T.prototype.copy.call(i,o),i.color.copy(o.color),i.map=o.map,this.cache.add(a,i)),o=i}if(n||r||s){let a="ClonedMaterial:"+o.uuid+":";n&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),s&&(a+="flat-shading:");let i=this.cache.get(a);i||(i=o.clone(),r&&(i.vertexColors=!0),s&&(i.flatShading=!0),n&&(i.normalScale&&(i.normalScale.y*=-1),i.clearcoatNormalScale&&(i.clearcoatNormalScale.y*=-1)),this.cache.add(a,i),this.associations.set(i,this.associations.get(o))),o=i}t.material=o}getMaterialType(){return d.Wid}loadMaterial(t){const e=this,n=this.extensions,r=this.json.materials[t];let s;const a={},c=[];if((r.extensions||{})[w.KHR_MATERIALS_UNLIT]){const f=n[w.KHR_MATERIALS_UNLIT];s=f.getMaterialType(),c.push(f.extendParams(a,r,e))}else{const f=r.pbrMetallicRoughness||{};if(a.color=new d.Ilk(1,1,1),a.opacity=1,Array.isArray(f.baseColorFactor)){const h=f.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],d.GUF),a.opacity=h[3]}void 0!==f.baseColorTexture&&c.push(e.assignTexture(a,"map",f.baseColorTexture,d.KI_)),a.metalness=void 0!==f.metallicFactor?f.metallicFactor:1,a.roughness=void 0!==f.roughnessFactor?f.roughnessFactor:1,void 0!==f.metallicRoughnessTexture&&(c.push(e.assignTexture(a,"metalnessMap",f.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",f.metallicRoughnessTexture))),s=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(t,a)})))}!0===r.doubleSided&&(a.side=d.ehD);const l=r.alphaMode||"OPAQUE";if("BLEND"===l?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,"MASK"===l&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==d.vBJ&&(c.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new d.FM8(1,1),void 0!==r.normalTexture.scale)){const f=r.normalTexture.scale;a.normalScale.set(f,f)}if(void 0!==r.occlusionTexture&&s!==d.vBJ&&(c.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==d.vBJ){const f=r.emissiveFactor;a.emissive=(new d.Ilk).setRGB(f[0],f[1],f[2],d.GUF)}return void 0!==r.emissiveTexture&&s!==d.vBJ&&c.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,d.KI_)),Promise.all(c).then(function(){const f=new s(a);return r.name&&(f.name=r.name),Ee(f,r),e.associations.set(f,{materials:t}),r.extensions&&Re(n,f,r),f})}createUniqueName(t){const e=d.iUV.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,o=this.extensions,n=this.primitiveCache;function r(a){return o[w.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(i){return We(i,a,e)})}const s=[];for(let a=0,i=t.length;a<i;a++){const c=t[a],l=tt(c),f=n[l];if(f)s.push(f.promise);else{let h;h=c.extensions&&c.extensions[w.KHR_DRACO_MESH_COMPRESSION]?r(c):We(new d.u9r,c,e),n[l]={primitive:c,promise:h},s.push(h)}}return Promise.all(s)}loadMesh(t){const e=this,n=this.extensions,r=this.json.meshes[t],s=r.primitives,a=[];for(let i=0,c=s.length;i<c;i++){const l=void 0===s[i].material?(void 0===(u=this.cache).DefaultMaterial&&(u.DefaultMaterial=new d.Wid({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:d.Wl3})),u.DefaultMaterial):this.getDependency("material",s[i].material);a.push(l)}var u;return a.push(e.loadGeometries(s)),Promise.all(a).then(function(i){const c=i.slice(0,i.length-1),l=i[i.length-1],f=[];for(let p=0,A=l.length;p<A;p++){const g=l[p],m=s[p];let T;const R=c[p];if(m.mode===ne.TRIANGLES||m.mode===ne.TRIANGLE_STRIP||m.mode===ne.TRIANGLE_FAN||void 0===m.mode)T=!0===r.isSkinnedMesh?new d.TUv(g,R):new d.Kj0(g,R),!0===T.isSkinnedMesh&&T.normalizeSkinWeights(),m.mode===ne.TRIANGLE_STRIP?T.geometry=y(T.geometry,d.UlW):m.mode===ne.TRIANGLE_FAN&&(T.geometry=y(T.geometry,d.z$h));else if(m.mode===ne.LINES)T=new d.ejS(g,R);else if(m.mode===ne.LINE_STRIP)T=new d.x12(g,R);else if(m.mode===ne.LINE_LOOP)T=new d.blk(g,R);else{if(m.mode!==ne.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);T=new d.woe(g,R)}Object.keys(T.geometry.morphAttributes).length>0&&et(T,r),T.name=e.createUniqueName(r.name||"mesh_"+t),Ee(T,r),m.extensions&&Re(n,T,m),e.assignFinalMaterial(T),f.push(T)}for(let p=0,A=f.length;p<A;p++)e.associations.set(f[p],{meshes:t,primitives:p});if(1===f.length)return r.extensions&&Re(n,f[0],r),f[0];const h=new d.ZAu;r.extensions&&Re(n,h,r),e.associations.set(h,{meshes:t});for(let p=0,A=f.length;p<A;p++)h.add(f[p]);return h})}loadCamera(t){let e;const o=this.json.cameras[t],n=o[o.type];if(n)return"perspective"===o.type?e=new d.cPb(d.M8C.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===o.type&&(e=new d.iKG(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),o.name&&(e.name=this.createUniqueName(o.name)),Ee(e,o),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],o=[];for(let n=0,r=e.joints.length;n<r;n++)o.push(this._loadNodeShallow(e.joints[n]));return o.push(void 0!==e.inverseBindMatrices?this.getDependency("accessor",e.inverseBindMatrices):null),Promise.all(o).then(function(n){const r=n.pop(),s=n,a=[],i=[];for(let c=0,l=s.length;c<l;c++){const f=s[c];if(f){a.push(f);const h=new d.yGw;null!==r&&h.fromArray(r.array,16*c),i.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new d.OdW(a,i)})}loadAnimation(t){const o=this,n=this.json.animations[t],r=n.name?n.name:"animation_"+t,s=[],a=[],i=[],c=[],l=[];for(let f=0,h=n.channels.length;f<h;f++){const p=n.channels[f],A=n.samplers[p.sampler],g=p.target,m=g.node,T=void 0!==n.parameters?n.parameters[A.input]:A.input,R=void 0!==n.parameters?n.parameters[A.output]:A.output;void 0!==g.node&&(s.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",T)),i.push(this.getDependency("accessor",R)),c.push(A),l.push(g))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(i),Promise.all(c),Promise.all(l)]).then(function(f){const h=f[0],p=f[1],A=f[2],g=f[3],m=f[4],T=[];for(let R=0,x=h.length;R<x;R++){const b=h[R],H=p[R],v=A[R],C=g[R],S=m[R];if(void 0===b)continue;b.updateMatrix&&b.updateMatrix();const P=o._createAnimationTracks(b,H,v,C,S);if(P)for(let Z=0;Z<P.length;Z++)T.push(P[Z])}return new d.m7l(r,void 0,T)})}createNodeMesh(t){const o=this,n=this.json.nodes[t];return void 0===n.mesh?null:o.getDependency("mesh",n.mesh).then(function(r){const s=o._getNodeRef(o.meshCache,n.mesh,r);return void 0!==n.weights&&s.traverse(function(a){if(a.isMesh)for(let i=0,c=n.weights.length;i<c;i++)a.morphTargetInfluences[i]=n.weights[i]}),s})}loadNode(t){const o=this,n=this.json.nodes[t],r=o._loadNodeShallow(t),s=[],a=n.children||[];for(let c=0,l=a.length;c<l;c++)s.push(o.getDependency("node",a[c]));const i=void 0===n.skin?Promise.resolve(null):o.getDependency("skin",n.skin);return Promise.all([r,Promise.all(s),i]).then(function(c){const l=c[0],f=c[1],h=c[2];null!==h&&l.traverse(function(p){!p.isSkinnedMesh||p.bind(h,st)});for(let p=0,A=f.length;p<A;p++)l.add(f[p]);return l})}_loadNodeShallow(t){const o=this.extensions,n=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const r=this.json.nodes[t],s=r.name?n.createUniqueName(r.name):"",a=[],i=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return i&&a.push(i),void 0!==r.camera&&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(t)}).forEach(function(c){a.push(c)}),this.nodeCache[t]=Promise.all(a).then(function(c){let l;if(l=!0===r.isBone?new d.N$j:c.length>1?new d.ZAu:1===c.length?c[0]:new d.Tme,l!==c[0])for(let f=0,h=c.length;f<h;f++)l.add(c[f]);if(r.name&&(l.userData.name=r.name,l.name=s),Ee(l,r),r.extensions&&Re(o,l,r),void 0!==r.matrix){const f=new d.yGw;f.fromArray(r.matrix),l.applyMatrix4(f)}else void 0!==r.translation&&l.position.fromArray(r.translation),void 0!==r.rotation&&l.quaternion.fromArray(r.rotation),void 0!==r.scale&&l.scale.fromArray(r.scale);return n.associations.has(l)||n.associations.set(l,{}),n.associations.get(l).nodes=t,l}),this.nodeCache[t]}loadScene(t){const e=this.extensions,o=this.json.scenes[t],n=this,r=new d.ZAu;o.name&&(r.name=n.createUniqueName(o.name)),Ee(r,o),o.extensions&&Re(e,r,o);const s=o.nodes||[],a=[];for(let i=0,c=s.length;i<c;i++)a.push(n.getDependency("node",s[i]));return Promise.all(a).then(function(i){for(let l=0,f=i.length;l<f;l++)r.add(i[l]);return n.associations=(l=>{const f=new Map;for(const[h,p]of n.associations)(h instanceof d.F5T||h instanceof d.xEZ)&&f.set(h,p);return l.traverse(h=>{const p=n.associations.get(h);null!=p&&f.set(h,p)}),f})(r),r})}_createAnimationTracks(t,e,o,n,r){const s=[],a=t.name?t.name:t.uuid,i=[];let c;switch(_e[r.path]===_e.weights?t.traverse(function(h){h.morphTargetInfluences&&i.push(h.name?h.name:h.uuid)}):i.push(a),_e[r.path]){case _e.weights:c=d.dUE;break;case _e.rotation:c=d.iLg;break;case _e.position:case _e.scale:c=d.yC1;break;default:c=1===o.itemSize?d.dUE:d.yC1}const l=void 0!==n.interpolation?Je[n.interpolation]:d.NMF,f=this._getArrayFromAccessor(o);for(let h=0,p=i.length;h<p;h++){const A=new c(i[h]+"."+_e[r.path],e.array,f,l);"CUBICSPLINE"===n.interpolation&&this._createCubicSplineTrackInterpolant(A),s.push(A)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const o=He(e.constructor),n=new Float32Array(e.length);for(let r=0,s=e.length;r<s;r++)n[r]=e[r]*o;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(o){return new(this instanceof d.iLg?Ze:Ne)(this.times,this.values,this.getValueSize()/3,o)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function We(u,t,e){const o=t.attributes,n=[];function r(s,a){return e.getDependency("accessor",s).then(function(i){u.setAttribute(a,i)})}for(const s in o){const a=Fe[s]||s.toLowerCase();a in u.attributes||n.push(r(o[s],a))}if(void 0!==t.indices&&!u.index){const s=e.getDependency("accessor",t.indices).then(function(a){u.setIndex(a)});n.push(s)}return d.epp.workingColorSpace!==d.GUF&&"COLOR_0"in o&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${d.epp.workingColorSpace}" not supported.`),Ee(u,t),function ot(u,t,e){const o=t.attributes,n=new d.ZzF;if(void 0===o.POSITION)return;{const a=e.json.accessors[o.POSITION],i=a.min,c=a.max;if(void 0===i||void 0===c)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(n.set(new d.Pa4(i[0],i[1],i[2]),new d.Pa4(c[0],c[1],c[2])),a.normalized){const l=He(xe[a.componentType]);n.min.multiplyScalar(l),n.max.multiplyScalar(l)}}const r=t.targets;if(void 0!==r){const a=new d.Pa4,i=new d.Pa4;for(let c=0,l=r.length;c<l;c++){const f=r[c];if(void 0!==f.POSITION){const h=e.json.accessors[f.POSITION],p=h.min,A=h.max;if(void 0!==p&&void 0!==A){if(i.setX(Math.max(Math.abs(p[0]),Math.abs(A[0]))),i.setY(Math.max(Math.abs(p[1]),Math.abs(A[1]))),i.setZ(Math.max(Math.abs(p[2]),Math.abs(A[2]))),h.normalized){const g=He(xe[h.componentType]);i.multiplyScalar(g)}a.max(i)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}u.boundingBox=n;const s=new d.aLr;n.getCenter(s.center),s.radius=n.min.distanceTo(n.max)/2,u.boundingSphere=s}(u,t,e),Promise.all(n).then(function(){return void 0!==t.targets?function $e(u,t,e){let o=!1,n=!1,r=!1;for(let c=0,l=t.length;c<l;c++){const f=t[c];if(void 0!==f.POSITION&&(o=!0),void 0!==f.NORMAL&&(n=!0),void 0!==f.COLOR_0&&(r=!0),o&&n&&r)break}if(!o&&!n&&!r)return Promise.resolve(u);const s=[],a=[],i=[];for(let c=0,l=t.length;c<l;c++){const f=t[c];if(o){const h=void 0!==f.POSITION?e.getDependency("accessor",f.POSITION):u.attributes.position;s.push(h)}if(n){const h=void 0!==f.NORMAL?e.getDependency("accessor",f.NORMAL):u.attributes.normal;a.push(h)}if(r){const h=void 0!==f.COLOR_0?e.getDependency("accessor",f.COLOR_0):u.attributes.color;i.push(h)}}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(i)]).then(function(c){const f=c[1],h=c[2];return o&&(u.morphAttributes.position=c[0]),n&&(u.morphAttributes.normal=f),r&&(u.morphAttributes.color=h),u.morphTargetsRelative=!0,u})}(u,t.targets,e):u})}},3025:(ze,Me,pe)=>{pe.d(Me,{x:()=>be});var d=pe(6682);class be extends d.yxD{constructor(Q){super(Q),this.type=d.cLu}parse(Q){const _=function(L,G){switch(L){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(G||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(G||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(G||""));default:throw new Error("THREE.RGBELoader: Memory Error: "+(G||""))}},J=function(L,G,O){G=G||1024;let z=L.pos,j=-1,N=0,K="",D=String.fromCharCode.apply(null,new Uint16Array(L.subarray(z,z+128)));for(;0>(j=D.indexOf("\n"))&&N<G&&z<L.byteLength;)K+=D,N+=D.length,z+=128,D+=String.fromCharCode.apply(null,new Uint16Array(L.subarray(z,z+128)));return-1<j&&(!1!==O&&(L.pos+=N+j+1),K+D.slice(0,j))},U=function(L,G,O,V){const j=Math.pow(2,L[G+3]-128)/255;O[V+0]=L[G+0]*j,O[V+1]=L[G+1]*j,O[V+2]=L[G+2]*j,O[V+3]=1},W=function(L,G,O,V){const j=Math.pow(2,L[G+3]-128)/255;O[V+0]=d.A5E.toHalfFloat(Math.min(L[G+0]*j,65504)),O[V+1]=d.A5E.toHalfFloat(Math.min(L[G+1]*j,65504)),O[V+2]=d.A5E.toHalfFloat(Math.min(L[G+2]*j,65504)),O[V+3]=d.A5E.toHalfFloat(1)},w=new Uint8Array(Q);w.pos=0;const q=function(L){const G=/^#\?(\S+)/,O=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,V=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,z=/^\s*FORMAT=(\S+)\s*$/,j=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,N={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let K,D;for((L.pos>=L.byteLength||!(K=J(L)))&&_(1,"no header found"),(D=K.match(G))||_(3,"bad initial token"),N.valid|=1,N.programtype=D[1],N.string+=K+"\n";K=J(L),!1!==K;)if(N.string+=K+"\n","#"!==K.charAt(0)){if((D=K.match(O))&&(N.gamma=parseFloat(D[1])),(D=K.match(V))&&(N.exposure=parseFloat(D[1])),(D=K.match(z))&&(N.valid|=2,N.format=D[1]),(D=K.match(j))&&(N.valid|=4,N.height=parseInt(D[1],10),N.width=parseInt(D[2],10)),2&N.valid&&4&N.valid)break}else N.comments+=K+"\n";return 2&N.valid||_(3,"missing format specifier"),4&N.valid||_(3,"missing image size specifier"),N}(w),ee=q.width,le=q.height,te=function(L,G,O){const V=G;if(V<8||V>32767||2!==L[0]||2!==L[1]||128&L[2])return new Uint8Array(L);V!==(L[2]<<8|L[3])&&_(3,"wrong scanline width");const z=new Uint8Array(4*G*O);z.length||_(4,"unable to allocate buffer space");let j=0,N=0;const K=4*V,D=new Uint8Array(4),de=new Uint8Array(K);let Ae=O;for(;Ae>0&&N<L.byteLength;){N+4>L.byteLength&&_(1),D[0]=L[N++],D[1]=L[N++],D[2]=L[N++],D[3]=L[N++],(2!=D[0]||2!=D[1]||(D[2]<<8|D[3])!=V)&&_(3,"bad rgbe scanline format");let oe,Te=0;for(;Te<K&&N<L.byteLength;){oe=L[N++];const ie=oe>128;if(ie&&(oe-=128),(0===oe||Te+oe>K)&&_(3,"bad scanline data"),ie){const ae=L[N++];for(let Ne=0;Ne<oe;Ne++)de[Te++]=ae}else de.set(L.subarray(N,N+oe),Te),Te+=oe,N+=oe}const Oe=V;for(let ie=0;ie<Oe;ie++){let ae=0;z[j]=de[ie+ae],ae+=V,z[j+1]=de[ie+ae],ae+=V,z[j+2]=de[ie+ae],ae+=V,z[j+3]=de[ie+ae],j+=4}Ae--}return z}(w.subarray(w.pos),ee,le);let re,me,ge;switch(this.type){case d.VzW:ge=te.length/4;const L=new Float32Array(4*ge);for(let O=0;O<ge;O++)U(te,4*O,L,4*O);re=L,me=d.VzW;break;case d.cLu:ge=te.length/4;const G=new Uint16Array(4*ge);for(let O=0;O<ge;O++)W(te,4*O,G,4*O);re=G,me=d.cLu;break;default:throw new Error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:ee,height:le,data:re,header:q.string,gamma:q.gamma,exposure:q.exposure,type:me}}setDataType(Q){return this.type=Q,this}load(Q,fe,E,I){return super.load(Q,function M(_,k){switch(_.type){case d.VzW:case d.cLu:_.colorSpace=d.GUF,_.minFilter=d.wem,_.magFilter=d.wem,_.generateMipmaps=!1,_.flipY=!0}fe&&fe(_,k)},E,I)}}}}]);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/show-case/introduce.git
[email protected]:show-case/introduce.git
show-case
introduce
introduce
master

搜索帮助