assistant-robot
Version:
An assistant widget, have a 3D robot which can interact with user, have a simple LLM which can chat with user.
1 lines • 369 kB
JavaScript
"use strict";var q=Object.defineProperty;var _=(Q,P,A)=>P in Q?q(Q,P,{enumerable:!0,configurable:!0,writable:!0,value:A}):Q[P]=A;var M=(Q,P,A)=>(_(Q,typeof P!="symbol"?P+"":P,A),A);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("three"),r=require("./utils-_ulwJfGD.js"),$=require("@mediapipe/face_detection"),AA=require("@tensorflow-models/face-detection");function H(Q){const P=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(Q){for(const A in Q)if(A!=="default"){const s=Object.getOwnPropertyDescriptor(Q,A);Object.defineProperty(P,A,s.get?s:{enumerable:!0,get:()=>Q[A]})}}return P.default=Q,Object.freeze(P)}const PA=H($),V=H(AA);function W(Q,P){if(P===B.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),Q;if(P===B.TriangleFanDrawMode||P===B.TriangleStripDrawMode){let A=Q.getIndex();if(A===null){const D=[],g=Q.getAttribute("position");if(g!==void 0){for(let i=0;i<g.count;i++)D.push(i);Q.setIndex(D),A=Q.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),Q}const s=A.count-2,w=[];if(P===B.TriangleFanDrawMode)for(let D=1;D<=s;D++)w.push(A.getX(0)),w.push(A.getX(D)),w.push(A.getX(D+1));else for(let D=0;D<s;D++)D%2===0?(w.push(A.getX(D)),w.push(A.getX(D+1)),w.push(A.getX(D+2))):(w.push(A.getX(D+2)),w.push(A.getX(D+1)),w.push(A.getX(D)));w.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const e=Q.clone();return e.setIndex(w),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",P),Q}class wA extends B.Loader{constructor(P){super(P),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(A){return new gA(A)}),this.register(function(A){return new rA(A)}),this.register(function(A){return new vA(A)}),this.register(function(A){return new cA(A)}),this.register(function(A){return new BA(A)}),this.register(function(A){return new CA(A)}),this.register(function(A){return new nA(A)}),this.register(function(A){return new QA(A)}),this.register(function(A){return new iA(A)}),this.register(function(A){return new oA(A)}),this.register(function(A){return new IA(A)}),this.register(function(A){return new tA(A)}),this.register(function(A){return new eA(A)}),this.register(function(A){return new jA(A)}),this.register(function(A){return new EA(A)})}load(P,A,s,w){const e=this;let D;this.resourcePath!==""?D=this.resourcePath:this.path!==""?D=this.path:D=B.LoaderUtils.extractUrlBase(P),this.manager.itemStart(P);const g=function(I){w?w(I):console.error(I),e.manager.itemError(P),e.manager.itemEnd(P)},i=new B.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(P,function(I){try{e.parse(I,D,function(n){A(n),e.manager.itemEnd(P)},g)}catch(n){g(n)}},s,g)}setDRACOLoader(P){return this.dracoLoader=P,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(P){return this.ktx2Loader=P,this}setMeshoptDecoder(P){return this.meshoptDecoder=P,this}register(P){return this.pluginCallbacks.indexOf(P)===-1&&this.pluginCallbacks.push(P),this}unregister(P){return this.pluginCallbacks.indexOf(P)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(P),1),this}parse(P,A,s,w){let e;const D={},g={},i=new TextDecoder;if(typeof P=="string")e=JSON.parse(P);else if(P instanceof ArrayBuffer)if(i.decode(new Uint8Array(P,0,4))===X){try{D[j.KHR_BINARY_GLTF]=new MA(P)}catch(C){w&&w(C);return}e=JSON.parse(D[j.KHR_BINARY_GLTF].content)}else e=JSON.parse(i.decode(P));else e=P;if(e.asset===void 0||e.asset.version[0]<2){w&&w(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const I=new UA(e,{path:A||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});I.fileLoader.setRequestHeader(this.requestHeader);for(let n=0;n<this.pluginCallbacks.length;n++){const C=this.pluginCallbacks[n](I);C.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),g[C.name]=C,D[C.name]=!0}if(e.extensionsUsed)for(let n=0;n<e.extensionsUsed.length;++n){const C=e.extensionsUsed[n],o=e.extensionsRequired||[];switch(C){case j.KHR_MATERIALS_UNLIT:D[C]=new DA;break;case j.KHR_DRACO_MESH_COMPRESSION:D[C]=new lA(e,this.dracoLoader);break;case j.KHR_TEXTURE_TRANSFORM:D[C]=new zA;break;case j.KHR_MESH_QUANTIZATION:D[C]=new aA;break;default:o.indexOf(C)>=0&&g[C]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+C+'".')}}I.setExtensions(D),I.setPlugins(g),I.parse(s,w)}parseAsync(P,A){const s=this;return new Promise(function(w,e){s.parse(P,A,w,e)})}}function sA(){let Q={};return{get:function(P){return Q[P]},add:function(P,A){Q[P]=A},remove:function(P){delete Q[P]},removeAll:function(){Q={}}}}const j={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 eA{constructor(P){this.parser=P,this.name=j.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const P=this.parser,A=this.parser.json.nodes||[];for(let s=0,w=A.length;s<w;s++){const e=A[s];e.extensions&&e.extensions[this.name]&&e.extensions[this.name].light!==void 0&&P._addNodeRef(this.cache,e.extensions[this.name].light)}}_loadLight(P){const A=this.parser,s="light:"+P;let w=A.cache.get(s);if(w)return w;const e=A.json,i=((e.extensions&&e.extensions[this.name]||{}).lights||[])[P];let I;const n=new B.Color(16777215);i.color!==void 0&&n.setRGB(i.color[0],i.color[1],i.color[2],B.LinearSRGBColorSpace);const C=i.range!==void 0?i.range:0;switch(i.type){case"directional":I=new B.DirectionalLight(n),I.target.position.set(0,0,-1),I.add(I.target);break;case"point":I=new B.PointLight(n),I.distance=C;break;case"spot":I=new B.SpotLight(n),I.distance=C,i.spot=i.spot||{},i.spot.innerConeAngle=i.spot.innerConeAngle!==void 0?i.spot.innerConeAngle:0,i.spot.outerConeAngle=i.spot.outerConeAngle!==void 0?i.spot.outerConeAngle:Math.PI/4,I.angle=i.spot.outerConeAngle,I.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,I.target.position.set(0,0,-1),I.add(I.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return I.position.set(0,0,0),I.decay=2,f(I,i),i.intensity!==void 0&&(I.intensity=i.intensity),I.name=A.createUniqueName(i.name||"light_"+P),w=Promise.resolve(I),A.cache.add(s,w),w}getDependency(P,A){if(P==="light")return this._loadLight(A)}createNodeAttachment(P){const A=this,s=this.parser,e=s.json.nodes[P],g=(e.extensions&&e.extensions[this.name]||{}).light;return g===void 0?null:this._loadLight(g).then(function(i){return s._getNodeRef(A.cache,g,i)})}}class DA{constructor(){this.name=j.KHR_MATERIALS_UNLIT}getMaterialType(){return B.MeshBasicMaterial}extendParams(P,A,s){const w=[];P.color=new B.Color(1,1,1),P.opacity=1;const e=A.pbrMetallicRoughness;if(e){if(Array.isArray(e.baseColorFactor)){const D=e.baseColorFactor;P.color.setRGB(D[0],D[1],D[2],B.LinearSRGBColorSpace),P.opacity=D[3]}e.baseColorTexture!==void 0&&w.push(s.assignTexture(P,"map",e.baseColorTexture,B.SRGBColorSpace))}return Promise.all(w)}}class iA{constructor(P){this.parser=P,this.name=j.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(P,A){const w=this.parser.json.materials[P];if(!w.extensions||!w.extensions[this.name])return Promise.resolve();const e=w.extensions[this.name].emissiveStrength;return e!==void 0&&(A.emissiveIntensity=e),Promise.resolve()}}class gA{constructor(P){this.parser=P,this.name=j.KHR_MATERIALS_CLEARCOAT}getMaterialType(P){const s=this.parser.json.materials[P];return!s.extensions||!s.extensions[this.name]?null:B.MeshPhysicalMaterial}extendMaterialParams(P,A){const s=this.parser,w=s.json.materials[P];if(!w.extensions||!w.extensions[this.name])return Promise.resolve();const e=[],D=w.extensions[this.name];if(D.clearcoatFactor!==void 0&&(A.clearcoat=D.clearcoatFactor),D.clearcoatTexture!==void 0&&e.push(s.assignTexture(A,"clearcoatMap",D.clearcoatTexture)),D.clearcoatRoughnessFactor!==void 0&&(A.clearcoatRoughness=D.clearcoatRoughnessFactor),D.clearcoatRoughnessTexture!==void 0&&e.push(s.assignTexture(A,"clearcoatRoughnessMap",D.clearcoatRoughnessTexture)),D.clearcoatNormalTexture!==void 0&&(e.push(s.assignTexture(A,"clearcoatNormalMap",D.clearcoatNormalTexture)),D.clearcoatNormalTexture.scale!==void 0)){const g=D.clearcoatNormalTexture.scale;A.clearcoatNormalScale=new B.Vector2(g,g)}return Promise.all(e)}}class IA{constructor(P){this.parser=P,this.name=j.KHR_MATERIALS_IRIDESCENCE}getMaterialType(P){const s=this.parser.json.materials[P];return!s.extensions||!s.extensions[this.name]?null:B.MeshPhysicalMaterial}extendMaterialParams(P,A){const s=this.parser,w=s.json.materials[P];if(!w.extensions||!w.extensions[this.name])return Promise.resolve();const e=[],D=w.extensions[this.name];return D.iridescenceFactor!==void 0&&(A.iridescence=D.iridescenceFactor),D.iridescenceTexture!==void 0&&e.push(s.assignTexture(A,"iridescenceMap",D.iridescenceTexture)),D.iridescenceIor!==void 0&&(A.iridescenceIOR=D.iridescenceIor),A.iridescenceThicknessRange===void 0&&(A.iridescenceThicknessRange=[100,400]),D.iridescenceThicknessMinimum!==void 0&&(A.iridescenceThicknessRange[0]=D.iridescenceThicknessMinimum),D.iridescenceThicknessMaximum!==void 0&&(A.iridescenceThicknessRange[1]=D.iridescenceThicknessMaximum),D.iridescenceThicknessTexture!==void 0&&e.push(s.assignTexture(A,"iridescenceThicknessMap",D.iridescenceThicknessTexture)),Promise.all(e)}}class BA{constructor(P){this.parser=P,this.name=j.KHR_MATERIALS_SHEEN}getMaterialType(P){const s=this.parser.json.materials[P];return!s.extensions||!s.extensions[this.name]?null:B.MeshPhysicalMaterial}extendMaterialParams(P,A){const s=this.parser,w=s.json.materials[P];if(!w.extensions||!w.extensions[this.name])return Promise.resolve();const e=[];A.sheenColor=new B.Color(0,0,0),A.sheenRoughness=0,A.sheen=1;const D=w.extensions[this.name];if(D.sheenColorFactor!==void 0){const g=D.sheenColorFactor;A.sheenColor.setRGB(g[0],g[1],g[2],B.LinearSRGBColorSpace)}return D.sheenRoughnessFactor!==void 0&&(A.sheenRoughness=D.sheenRoughnessFactor),D.sheenColorTexture!==void 0&&e.push(s.assignTexture(A,"sheenColorMap",D.sheenColorTexture,B.SRGBColorSpace)),D.sheenRoughnessTexture!==void 0&&e.push(s.assignTexture(A,"sheenRoughnessMap",D.sheenRoughnessTexture)),Promise.all(e)}}class CA{constructor(P){this.parser=P,this.name=j.KHR_MATERIALS_TRANSMISSION}getMaterialType(P){const s=this.parser.json.materials[P];return!s.extensions||!s.extensions[this.name]?null:B.MeshPhysicalMaterial}extendMaterialParams(P,A){const s=this.parser,w=s.json.materials[P];if(!w.extensions||!w.extensions[this.name])return Promise.resolve();const e=[],D=w.extensions[this.name];return D.transmissionFactor!==void 0&&(A.transmission=D.transmissionFactor),D.transmissionTexture!==void 0&&e.push(s.assignTexture(A,"transmissionMap",D.transmissionTexture)),Promise.all(e)}}class nA{constructor(P){this.parser=P,this.name=j.KHR_MATERIALS_VOLUME}getMaterialType(P){const s=this.parser.json.materials[P];return!s.extensions||!s.extensions[this.name]?null:B.MeshPhysicalMaterial}extendMaterialParams(P,A){const s=this.parser,w=s.json.materials[P];if(!w.extensions||!w.extensions[this.name])return Promise.resolve();const e=[],D=w.extensions[this.name];A.thickness=D.thicknessFactor!==void 0?D.thicknessFactor:0,D.thicknessTexture!==void 0&&e.push(s.assignTexture(A,"thicknessMap",D.thicknessTexture)),A.attenuationDistance=D.attenuationDistance||1/0;const g=D.attenuationColor||[1,1,1];return A.attenuationColor=new B.Color().setRGB(g[0],g[1],g[2],B.LinearSRGBColorSpace),Promise.all(e)}}class QA{constructor(P){this.parser=P,this.name=j.KHR_MATERIALS_IOR}getMaterialType(P){const s=this.parser.json.materials[P];return!s.extensions||!s.extensions[this.name]?null:B.MeshPhysicalMaterial}extendMaterialParams(P,A){const w=this.parser.json.materials[P];if(!w.extensions||!w.extensions[this.name])return Promise.resolve();const e=w.extensions[this.name];return A.ior=e.ior!==void 0?e.ior:1.5,Promise.resolve()}}class oA{constructor(P){this.parser=P,this.name=j.KHR_MATERIALS_SPECULAR}getMaterialType(P){const s=this.parser.json.materials[P];return!s.extensions||!s.extensions[this.name]?null:B.MeshPhysicalMaterial}extendMaterialParams(P,A){const s=this.parser,w=s.json.materials[P];if(!w.extensions||!w.extensions[this.name])return Promise.resolve();const e=[],D=w.extensions[this.name];A.specularIntensity=D.specularFactor!==void 0?D.specularFactor:1,D.specularTexture!==void 0&&e.push(s.assignTexture(A,"specularIntensityMap",D.specularTexture));const g=D.specularColorFactor||[1,1,1];return A.specularColor=new B.Color().setRGB(g[0],g[1],g[2],B.LinearSRGBColorSpace),D.specularColorTexture!==void 0&&e.push(s.assignTexture(A,"specularColorMap",D.specularColorTexture,B.SRGBColorSpace)),Promise.all(e)}}class tA{constructor(P){this.parser=P,this.name=j.KHR_MATERIALS_ANISOTROPY}getMaterialType(P){const s=this.parser.json.materials[P];return!s.extensions||!s.extensions[this.name]?null:B.MeshPhysicalMaterial}extendMaterialParams(P,A){const s=this.parser,w=s.json.materials[P];if(!w.extensions||!w.extensions[this.name])return Promise.resolve();const e=[],D=w.extensions[this.name];return D.anisotropyStrength!==void 0&&(A.anisotropy=D.anisotropyStrength),D.anisotropyRotation!==void 0&&(A.anisotropyRotation=D.anisotropyRotation),D.anisotropyTexture!==void 0&&e.push(s.assignTexture(A,"anisotropyMap",D.anisotropyTexture)),Promise.all(e)}}class rA{constructor(P){this.parser=P,this.name=j.KHR_TEXTURE_BASISU}loadTexture(P){const A=this.parser,s=A.json,w=s.textures[P];if(!w.extensions||!w.extensions[this.name])return null;const e=w.extensions[this.name],D=A.options.ktx2Loader;if(!D){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return A.loadTextureImage(P,e.source,D)}}class vA{constructor(P){this.parser=P,this.name=j.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(P){const A=this.name,s=this.parser,w=s.json,e=w.textures[P];if(!e.extensions||!e.extensions[A])return null;const D=e.extensions[A],g=w.images[D.source];let i=s.textureLoader;if(g.uri){const I=s.options.manager.getHandler(g.uri);I!==null&&(i=I)}return this.detectSupport().then(function(I){if(I)return s.loadTextureImage(P,D.source,i);if(w.extensionsRequired&&w.extensionsRequired.indexOf(A)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(P)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(P){const A=new Image;A.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",A.onload=A.onerror=function(){P(A.height===1)}})),this.isSupported}}class cA{constructor(P){this.parser=P,this.name=j.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(P){const A=this.name,s=this.parser,w=s.json,e=w.textures[P];if(!e.extensions||!e.extensions[A])return null;const D=e.extensions[A],g=w.images[D.source];let i=s.textureLoader;if(g.uri){const I=s.options.manager.getHandler(g.uri);I!==null&&(i=I)}return this.detectSupport().then(function(I){if(I)return s.loadTextureImage(P,D.source,i);if(w.extensionsRequired&&w.extensionsRequired.indexOf(A)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(P)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(P){const A=new Image;A.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",A.onload=A.onerror=function(){P(A.height===1)}})),this.isSupported}}class jA{constructor(P){this.name=j.EXT_MESHOPT_COMPRESSION,this.parser=P}loadBufferView(P){const A=this.parser.json,s=A.bufferViews[P];if(s.extensions&&s.extensions[this.name]){const w=s.extensions[this.name],e=this.parser.getDependency("buffer",w.buffer),D=this.parser.options.meshoptDecoder;if(!D||!D.supported){if(A.extensionsRequired&&A.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return e.then(function(g){const i=w.byteOffset||0,I=w.byteLength||0,n=w.count,C=w.byteStride,o=new Uint8Array(g,i,I);return D.decodeGltfBufferAsync?D.decodeGltfBufferAsync(n,C,o,w.mode,w.filter).then(function(t){return t.buffer}):D.ready.then(function(){const t=new ArrayBuffer(n*C);return D.decodeGltfBuffer(new Uint8Array(t),n,C,o,w.mode,w.filter),t})})}else return null}}class EA{constructor(P){this.name=j.EXT_MESH_GPU_INSTANCING,this.parser=P}createNodeMesh(P){const A=this.parser.json,s=A.nodes[P];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const w=A.meshes[s.mesh];for(const I of w.primitives)if(I.mode!==T.TRIANGLES&&I.mode!==T.TRIANGLE_STRIP&&I.mode!==T.TRIANGLE_FAN&&I.mode!==void 0)return null;const D=s.extensions[this.name].attributes,g=[],i={};for(const I in D)g.push(this.parser.getDependency("accessor",D[I]).then(n=>(i[I]=n,i[I])));return g.length<1?null:(g.push(this.parser.createNodeMesh(P)),Promise.all(g).then(I=>{const n=I.pop(),C=n.isGroup?n.children:[n],o=I[0].count,t=[];for(const v of C){const l=new B.Matrix4,c=new B.Vector3,E=new B.Quaternion,a=new B.Vector3(1,1,1),L=new B.InstancedMesh(v.geometry,v.material,o);for(let z=0;z<o;z++)i.TRANSLATION&&c.fromBufferAttribute(i.TRANSLATION,z),i.ROTATION&&E.fromBufferAttribute(i.ROTATION,z),i.SCALE&&a.fromBufferAttribute(i.SCALE,z),L.setMatrixAt(z,l.compose(c,E,a));for(const z in i)if(z==="_COLOR_0"){const m=i[z];L.instanceColor=new B.InstancedBufferAttribute(m.array,m.itemSize,m.normalized)}else z!=="TRANSLATION"&&z!=="ROTATION"&&z!=="SCALE"&&v.geometry.setAttribute(z,i[z]);B.Object3D.prototype.copy.call(L,v),this.parser.assignFinalMaterial(L),t.push(L)}return n.isGroup?(n.clear(),n.add(...t),n):t[0]}))}}const X="glTF",Y=12,S={JSON:1313821514,BIN:5130562};class MA{constructor(P){this.name=j.KHR_BINARY_GLTF,this.content=null,this.body=null;const A=new DataView(P,0,Y),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(P.slice(0,4))),version:A.getUint32(4,!0),length:A.getUint32(8,!0)},this.header.magic!==X)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const w=this.header.length-Y,e=new DataView(P,Y);let D=0;for(;D<w;){const g=e.getUint32(D,!0);D+=4;const i=e.getUint32(D,!0);if(D+=4,i===S.JSON){const I=new Uint8Array(P,Y+D,g);this.content=s.decode(I)}else if(i===S.BIN){const I=Y+D;this.body=P.slice(I,I+g)}D+=g}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class lA{constructor(P,A){if(!A)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=j.KHR_DRACO_MESH_COMPRESSION,this.json=P,this.dracoLoader=A,this.dracoLoader.preload()}decodePrimitive(P,A){const s=this.json,w=this.dracoLoader,e=P.extensions[this.name].bufferView,D=P.extensions[this.name].attributes,g={},i={},I={};for(const n in D){const C=F[n]||n.toLowerCase();g[C]=D[n]}for(const n in P.attributes){const C=F[n]||n.toLowerCase();if(D[n]!==void 0){const o=s.accessors[P.attributes[n]],t=U[o.componentType];I[C]=t.name,i[C]=o.normalized===!0}}return A.getDependency("bufferView",e).then(function(n){return new Promise(function(C){w.decodeDracoFile(n,function(o){for(const t in o.attributes){const v=o.attributes[t],l=i[t];l!==void 0&&(v.normalized=l)}C(o)},g,I)})})}}class zA{constructor(){this.name=j.KHR_TEXTURE_TRANSFORM}extendTexture(P,A){return(A.texCoord===void 0||A.texCoord===P.channel)&&A.offset===void 0&&A.rotation===void 0&&A.scale===void 0||(P=P.clone(),A.texCoord!==void 0&&(P.channel=A.texCoord),A.offset!==void 0&&P.offset.fromArray(A.offset),A.rotation!==void 0&&(P.rotation=A.rotation),A.scale!==void 0&&P.repeat.fromArray(A.scale),P.needsUpdate=!0),P}}class aA{constructor(){this.name=j.KHR_MESH_QUANTIZATION}}class K extends B.Interpolant{constructor(P,A,s,w){super(P,A,s,w)}copySampleValue_(P){const A=this.resultBuffer,s=this.sampleValues,w=this.valueSize,e=P*w*3+w;for(let D=0;D!==w;D++)A[D]=s[e+D];return A}interpolate_(P,A,s,w){const e=this.resultBuffer,D=this.sampleValues,g=this.valueSize,i=g*2,I=g*3,n=w-A,C=(s-A)/n,o=C*C,t=o*C,v=P*I,l=v-I,c=-2*t+3*o,E=t-o,a=1-c,L=E-o+C;for(let z=0;z!==g;z++){const m=D[l+z+g],b=D[l+z+i]*n,u=D[v+z+g],J=D[v+z]*n;e[z]=a*m+L*b+c*u+E*J}return e}}const LA=new B.Quaternion;class TA extends K{interpolate_(P,A,s,w){const e=super.interpolate_(P,A,s,w);return LA.fromArray(e).normalize().toArray(e),e}}const T={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},U={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},k={9728:B.NearestFilter,9729:B.LinearFilter,9984:B.NearestMipmapNearestFilter,9985:B.LinearMipmapNearestFilter,9986:B.NearestMipmapLinearFilter,9987:B.LinearMipmapLinearFilter},x={33071:B.ClampToEdgeWrapping,33648:B.MirroredRepeatWrapping,10497:B.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},F={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"},G={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},uA={CUBICSPLINE:void 0,LINEAR:B.InterpolateLinear,STEP:B.InterpolateDiscrete},y={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function mA(Q){return Q.DefaultMaterial===void 0&&(Q.DefaultMaterial=new B.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:B.FrontSide})),Q.DefaultMaterial}function O(Q,P,A){for(const s in A.extensions)Q[s]===void 0&&(P.userData.gltfExtensions=P.userData.gltfExtensions||{},P.userData.gltfExtensions[s]=A.extensions[s])}function f(Q,P){P.extras!==void 0&&(typeof P.extras=="object"?Object.assign(Q.userData,P.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+P.extras))}function bA(Q,P,A){let s=!1,w=!1,e=!1;for(let I=0,n=P.length;I<n;I++){const C=P[I];if(C.POSITION!==void 0&&(s=!0),C.NORMAL!==void 0&&(w=!0),C.COLOR_0!==void 0&&(e=!0),s&&w&&e)break}if(!s&&!w&&!e)return Promise.resolve(Q);const D=[],g=[],i=[];for(let I=0,n=P.length;I<n;I++){const C=P[I];if(s){const o=C.POSITION!==void 0?A.getDependency("accessor",C.POSITION):Q.attributes.position;D.push(o)}if(w){const o=C.NORMAL!==void 0?A.getDependency("accessor",C.NORMAL):Q.attributes.normal;g.push(o)}if(e){const o=C.COLOR_0!==void 0?A.getDependency("accessor",C.COLOR_0):Q.attributes.color;i.push(o)}}return Promise.all([Promise.all(D),Promise.all(g),Promise.all(i)]).then(function(I){const n=I[0],C=I[1],o=I[2];return s&&(Q.morphAttributes.position=n),w&&(Q.morphAttributes.normal=C),e&&(Q.morphAttributes.color=o),Q.morphTargetsRelative=!0,Q})}function dA(Q,P){if(Q.updateMorphTargets(),P.weights!==void 0)for(let A=0,s=P.weights.length;A<s;A++)Q.morphTargetInfluences[A]=P.weights[A];if(P.extras&&Array.isArray(P.extras.targetNames)){const A=P.extras.targetNames;if(Q.morphTargetInfluences.length===A.length){Q.morphTargetDictionary={};for(let s=0,w=A.length;s<w;s++)Q.morphTargetDictionary[A[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function GA(Q){let P;const A=Q.extensions&&Q.extensions[j.KHR_DRACO_MESH_COMPRESSION];if(A?P="draco:"+A.bufferView+":"+A.indices+":"+R(A.attributes):P=Q.indices+":"+R(Q.attributes)+":"+Q.mode,Q.targets!==void 0)for(let s=0,w=Q.targets.length;s<w;s++)P+=":"+R(Q.targets[s]);return P}function R(Q){let P="";const A=Object.keys(Q).sort();for(let s=0,w=A.length;s<w;s++)P+=A[s]+":"+Q[A[s]]+";";return P}function N(Q){switch(Q){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 fA(Q){return Q.search(/\.jpe?g($|\?)/i)>0||Q.search(/^data\:image\/jpeg/)===0?"image/jpeg":Q.search(/\.webp($|\?)/i)>0||Q.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const OA=new B.Matrix4;class UA{constructor(P={},A={}){this.json=P,this.extensions={},this.plugins={},this.options=A,this.cache=new sA,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,w=!1,e=-1;typeof navigator<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,w=navigator.userAgent.indexOf("Firefox")>-1,e=w?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||w&&e<98?this.textureLoader=new B.TextureLoader(this.options.manager):this.textureLoader=new B.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new B.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(P){this.extensions=P}setPlugins(P){this.plugins=P}parse(P,A){const s=this,w=this.json,e=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(D){return D._markDefs&&D._markDefs()}),Promise.all(this._invokeAll(function(D){return D.beforeRoot&&D.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(D){const g={scene:D[0][w.scene||0],scenes:D[0],animations:D[1],cameras:D[2],asset:w.asset,parser:s,userData:{}};return O(e,g,w),f(g,w),Promise.all(s._invokeAll(function(i){return i.afterRoot&&i.afterRoot(g)})).then(function(){P(g)})}).catch(A)}_markDefs(){const P=this.json.nodes||[],A=this.json.skins||[],s=this.json.meshes||[];for(let w=0,e=A.length;w<e;w++){const D=A[w].joints;for(let g=0,i=D.length;g<i;g++)P[D[g]].isBone=!0}for(let w=0,e=P.length;w<e;w++){const D=P[w];D.mesh!==void 0&&(this._addNodeRef(this.meshCache,D.mesh),D.skin!==void 0&&(s[D.mesh].isSkinnedMesh=!0)),D.camera!==void 0&&this._addNodeRef(this.cameraCache,D.camera)}}_addNodeRef(P,A){A!==void 0&&(P.refs[A]===void 0&&(P.refs[A]=P.uses[A]=0),P.refs[A]++)}_getNodeRef(P,A,s){if(P.refs[A]<=1)return s;const w=s.clone(),e=(D,g)=>{const i=this.associations.get(D);i!=null&&this.associations.set(g,i);for(const[I,n]of D.children.entries())e(n,g.children[I])};return e(s,w),w.name+="_instance_"+P.uses[A]++,w}_invokeOne(P){const A=Object.values(this.plugins);A.push(this);for(let s=0;s<A.length;s++){const w=P(A[s]);if(w)return w}return null}_invokeAll(P){const A=Object.values(this.plugins);A.unshift(this);const s=[];for(let w=0;w<A.length;w++){const e=P(A[w]);e&&s.push(e)}return s}getDependency(P,A){const s=P+":"+A;let w=this.cache.get(s);if(!w){switch(P){case"scene":w=this.loadScene(A);break;case"node":w=this._invokeOne(function(e){return e.loadNode&&e.loadNode(A)});break;case"mesh":w=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(A)});break;case"accessor":w=this.loadAccessor(A);break;case"bufferView":w=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(A)});break;case"buffer":w=this.loadBuffer(A);break;case"material":w=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(A)});break;case"texture":w=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(A)});break;case"skin":w=this.loadSkin(A);break;case"animation":w=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(A)});break;case"camera":w=this.loadCamera(A);break;default:if(w=this._invokeOne(function(e){return e!=this&&e.getDependency&&e.getDependency(P,A)}),!w)throw new Error("Unknown type: "+P);break}this.cache.add(s,w)}return w}getDependencies(P){let A=this.cache.get(P);if(!A){const s=this,w=this.json[P+(P==="mesh"?"es":"s")]||[];A=Promise.all(w.map(function(e,D){return s.getDependency(P,D)})),this.cache.add(P,A)}return A}loadBuffer(P){const A=this.json.buffers[P],s=this.fileLoader;if(A.type&&A.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+A.type+" buffer type is not supported.");if(A.uri===void 0&&P===0)return Promise.resolve(this.extensions[j.KHR_BINARY_GLTF].body);const w=this.options;return new Promise(function(e,D){s.load(B.LoaderUtils.resolveURL(A.uri,w.path),e,void 0,function(){D(new Error('THREE.GLTFLoader: Failed to load buffer "'+A.uri+'".'))})})}loadBufferView(P){const A=this.json.bufferViews[P];return this.getDependency("buffer",A.buffer).then(function(s){const w=A.byteLength||0,e=A.byteOffset||0;return s.slice(e,e+w)})}loadAccessor(P){const A=this,s=this.json,w=this.json.accessors[P];if(w.bufferView===void 0&&w.sparse===void 0){const D=Z[w.type],g=U[w.componentType],i=w.normalized===!0,I=new g(w.count*D);return Promise.resolve(new B.BufferAttribute(I,D,i))}const e=[];return w.bufferView!==void 0?e.push(this.getDependency("bufferView",w.bufferView)):e.push(null),w.sparse!==void 0&&(e.push(this.getDependency("bufferView",w.sparse.indices.bufferView)),e.push(this.getDependency("bufferView",w.sparse.values.bufferView))),Promise.all(e).then(function(D){const g=D[0],i=Z[w.type],I=U[w.componentType],n=I.BYTES_PER_ELEMENT,C=n*i,o=w.byteOffset||0,t=w.bufferView!==void 0?s.bufferViews[w.bufferView].byteStride:void 0,v=w.normalized===!0;let l,c;if(t&&t!==C){const E=Math.floor(o/t),a="InterleavedBuffer:"+w.bufferView+":"+w.componentType+":"+E+":"+w.count;let L=A.cache.get(a);L||(l=new I(g,E*t,w.count*t/n),L=new B.InterleavedBuffer(l,t/n),A.cache.add(a,L)),c=new B.InterleavedBufferAttribute(L,i,o%t/n,v)}else g===null?l=new I(w.count*i):l=new I(g,o,w.count*i),c=new B.BufferAttribute(l,i,v);if(w.sparse!==void 0){const E=Z.SCALAR,a=U[w.sparse.indices.componentType],L=w.sparse.indices.byteOffset||0,z=w.sparse.values.byteOffset||0,m=new a(D[1],L,w.sparse.count*E),b=new I(D[2],z,w.sparse.count*i);g!==null&&(c=new B.BufferAttribute(c.array.slice(),c.itemSize,c.normalized));for(let u=0,J=m.length;u<J;u++){const d=m[u];if(c.setX(d,b[u*i]),i>=2&&c.setY(d,b[u*i+1]),i>=3&&c.setZ(d,b[u*i+2]),i>=4&&c.setW(d,b[u*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return c})}loadTexture(P){const A=this.json,s=this.options,e=A.textures[P].source,D=A.images[e];let g=this.textureLoader;if(D.uri){const i=s.manager.getHandler(D.uri);i!==null&&(g=i)}return this.loadTextureImage(P,e,g)}loadTextureImage(P,A,s){const w=this,e=this.json,D=e.textures[P],g=e.images[A],i=(g.uri||g.bufferView)+":"+D.sampler;if(this.textureCache[i])return this.textureCache[i];const I=this.loadImageSource(A,s).then(function(n){n.flipY=!1,n.name=D.name||g.name||"",n.name===""&&typeof g.uri=="string"&&g.uri.startsWith("data:image/")===!1&&(n.name=g.uri);const o=(e.samplers||{})[D.sampler]||{};return n.magFilter=k[o.magFilter]||B.LinearFilter,n.minFilter=k[o.minFilter]||B.LinearMipmapLinearFilter,n.wrapS=x[o.wrapS]||B.RepeatWrapping,n.wrapT=x[o.wrapT]||B.RepeatWrapping,w.associations.set(n,{textures:P}),n}).catch(function(){return null});return this.textureCache[i]=I,I}loadImageSource(P,A){const s=this,w=this.json,e=this.options;if(this.sourceCache[P]!==void 0)return this.sourceCache[P].then(C=>C.clone());const D=w.images[P],g=self.URL||self.webkitURL;let i=D.uri||"",I=!1;if(D.bufferView!==void 0)i=s.getDependency("bufferView",D.bufferView).then(function(C){I=!0;const o=new Blob([C],{type:D.mimeType});return i=g.createObjectURL(o),i});else if(D.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+P+" is missing URI and bufferView");const n=Promise.resolve(i).then(function(C){return new Promise(function(o,t){let v=o;A.isImageBitmapLoader===!0&&(v=function(l){const c=new B.Texture(l);c.needsUpdate=!0,o(c)}),A.load(B.LoaderUtils.resolveURL(C,e.path),v,void 0,t)})}).then(function(C){return I===!0&&g.revokeObjectURL(i),C.userData.mimeType=D.mimeType||fA(D.uri),C}).catch(function(C){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),C});return this.sourceCache[P]=n,n}assignTexture(P,A,s,w){const e=this;return this.getDependency("texture",s.index).then(function(D){if(!D)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(D=D.clone(),D.channel=s.texCoord),e.extensions[j.KHR_TEXTURE_TRANSFORM]){const g=s.extensions!==void 0?s.extensions[j.KHR_TEXTURE_TRANSFORM]:void 0;if(g){const i=e.associations.get(D);D=e.extensions[j.KHR_TEXTURE_TRANSFORM].extendTexture(D,g),e.associations.set(D,i)}}return w!==void 0&&(D.colorSpace=w),P[A]=D,D})}assignFinalMaterial(P){const A=P.geometry;let s=P.material;const w=A.attributes.tangent===void 0,e=A.attributes.color!==void 0,D=A.attributes.normal===void 0;if(P.isPoints){const g="PointsMaterial:"+s.uuid;let i=this.cache.get(g);i||(i=new B.PointsMaterial,B.Material.prototype.copy.call(i,s),i.color.copy(s.color),i.map=s.map,i.sizeAttenuation=!1,this.cache.add(g,i)),s=i}else if(P.isLine){const g="LineBasicMaterial:"+s.uuid;let i=this.cache.get(g);i||(i=new B.LineBasicMaterial,B.Material.prototype.copy.call(i,s),i.color.copy(s.color),i.map=s.map,this.cache.add(g,i)),s=i}if(w||e||D){let g="ClonedMaterial:"+s.uuid+":";w&&(g+="derivative-tangents:"),e&&(g+="vertex-colors:"),D&&(g+="flat-shading:");let i=this.cache.get(g);i||(i=s.clone(),e&&(i.vertexColors=!0),D&&(i.flatShading=!0),w&&(i.normalScale&&(i.normalScale.y*=-1),i.clearcoatNormalScale&&(i.clearcoatNormalScale.y*=-1)),this.cache.add(g,i),this.associations.set(i,this.associations.get(s))),s=i}P.material=s}getMaterialType(){return B.MeshStandardMaterial}loadMaterial(P){const A=this,s=this.json,w=this.extensions,e=s.materials[P];let D;const g={},i=e.extensions||{},I=[];if(i[j.KHR_MATERIALS_UNLIT]){const C=w[j.KHR_MATERIALS_UNLIT];D=C.getMaterialType(),I.push(C.extendParams(g,e,A))}else{const C=e.pbrMetallicRoughness||{};if(g.color=new B.Color(1,1,1),g.opacity=1,Array.isArray(C.baseColorFactor)){const o=C.baseColorFactor;g.color.setRGB(o[0],o[1],o[2],B.LinearSRGBColorSpace),g.opacity=o[3]}C.baseColorTexture!==void 0&&I.push(A.assignTexture(g,"map",C.baseColorTexture,B.SRGBColorSpace)),g.metalness=C.metallicFactor!==void 0?C.metallicFactor:1,g.roughness=C.roughnessFactor!==void 0?C.roughnessFactor:1,C.metallicRoughnessTexture!==void 0&&(I.push(A.assignTexture(g,"metalnessMap",C.metallicRoughnessTexture)),I.push(A.assignTexture(g,"roughnessMap",C.metallicRoughnessTexture))),D=this._invokeOne(function(o){return o.getMaterialType&&o.getMaterialType(P)}),I.push(Promise.all(this._invokeAll(function(o){return o.extendMaterialParams&&o.extendMaterialParams(P,g)})))}e.doubleSided===!0&&(g.side=B.DoubleSide);const n=e.alphaMode||y.OPAQUE;if(n===y.BLEND?(g.transparent=!0,g.depthWrite=!1):(g.transparent=!1,n===y.MASK&&(g.alphaTest=e.alphaCutoff!==void 0?e.alphaCutoff:.5)),e.normalTexture!==void 0&&D!==B.MeshBasicMaterial&&(I.push(A.assignTexture(g,"normalMap",e.normalTexture)),g.normalScale=new B.Vector2(1,1),e.normalTexture.scale!==void 0)){const C=e.normalTexture.scale;g.normalScale.set(C,C)}if(e.occlusionTexture!==void 0&&D!==B.MeshBasicMaterial&&(I.push(A.assignTexture(g,"aoMap",e.occlusionTexture)),e.occlusionTexture.strength!==void 0&&(g.aoMapIntensity=e.occlusionTexture.strength)),e.emissiveFactor!==void 0&&D!==B.MeshBasicMaterial){const C=e.emissiveFactor;g.emissive=new B.Color().setRGB(C[0],C[1],C[2],B.LinearSRGBColorSpace)}return e.emissiveTexture!==void 0&&D!==B.MeshBasicMaterial&&I.push(A.assignTexture(g,"emissiveMap",e.emissiveTexture,B.SRGBColorSpace)),Promise.all(I).then(function(){const C=new D(g);return e.name&&(C.name=e.name),f(C,e),A.associations.set(C,{materials:P}),e.extensions&&O(w,C,e),C})}createUniqueName(P){const A=B.PropertyBinding.sanitizeNodeName(P||"");return A in this.nodeNamesUsed?A+"_"+ ++this.nodeNamesUsed[A]:(this.nodeNamesUsed[A]=0,A)}loadGeometries(P){const A=this,s=this.extensions,w=this.primitiveCache;function e(g){return s[j.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(g,A).then(function(i){return p(i,g,A)})}const D=[];for(let g=0,i=P.length;g<i;g++){const I=P[g],n=GA(I),C=w[n];if(C)D.push(C.promise);else{let o;I.extensions&&I.extensions[j.KHR_DRACO_MESH_COMPRESSION]?o=e(I):o=p(new B.BufferGeometry,I,A),w[n]={primitive:I,promise:o},D.push(o)}}return Promise.all(D)}loadMesh(P){const A=this,s=this.json,w=this.extensions,e=s.meshes[P],D=e.primitives,g=[];for(let i=0,I=D.length;i<I;i++){const n=D[i].material===void 0?mA(this.cache):this.getDependency("material",D[i].material);g.push(n)}return g.push(A.loadGeometries(D)),Promise.all(g).then(function(i){const I=i.slice(0,i.length-1),n=i[i.length-1],C=[];for(let t=0,v=n.length;t<v;t++){const l=n[t],c=D[t];let E;const a=I[t];if(c.mode===T.TRIANGLES||c.mode===T.TRIANGLE_STRIP||c.mode===T.TRIANGLE_FAN||c.mode===void 0)E=e.isSkinnedMesh===!0?new B.SkinnedMesh(l,a):new B.Mesh(l,a),E.isSkinnedMesh===!0&&E.normalizeSkinWeights(),c.mode===T.TRIANGLE_STRIP?E.geometry=W(E.geometry,B.TriangleStripDrawMode):c.mode===T.TRIANGLE_FAN&&(E.geometry=W(E.geometry,B.TriangleFanDrawMode));else if(c.mode===T.LINES)E=new B.LineSegments(l,a);else if(c.mode===T.LINE_STRIP)E=new B.Line(l,a);else if(c.mode===T.LINE_LOOP)E=new B.LineLoop(l,a);else if(c.mode===T.POINTS)E=new B.Points(l,a);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);Object.keys(E.geometry.morphAttributes).length>0&&dA(E,e),E.name=A.createUniqueName(e.name||"mesh_"+P),f(E,e),c.extensions&&O(w,E,c),A.assignFinalMaterial(E),C.push(E)}for(let t=0,v=C.length;t<v;t++)A.associations.set(C[t],{meshes:P,primitives:t});if(C.length===1)return e.extensions&&O(w,C[0],e),C[0];const o=new B.Group;e.extensions&&O(w,o,e),A.associations.set(o,{meshes:P});for(let t=0,v=C.length;t<v;t++)o.add(C[t]);return o})}loadCamera(P){let A;const s=this.json.cameras[P],w=s[s.type];if(!w){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?A=new B.PerspectiveCamera(B.MathUtils.radToDeg(w.yfov),w.aspectRatio||1,w.znear||1,w.zfar||2e6):s.type==="orthographic"&&(A=new B.OrthographicCamera(-w.xmag,w.xmag,w.ymag,-w.ymag,w.znear,w.zfar)),s.name&&(A.name=this.createUniqueName(s.name)),f(A,s),Promise.resolve(A)}loadSkin(P){const A=this.json.skins[P],s=[];for(let w=0,e=A.joints.length;w<e;w++)s.push(this._loadNodeShallow(A.joints[w]));return A.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",A.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(w){const e=w.pop(),D=w,g=[],i=[];for(let I=0,n=D.length;I<n;I++){const C=D[I];if(C){g.push(C);const o=new B.Matrix4;e!==null&&o.fromArray(e.array,I*16),i.push(o)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',A.joints[I])}return new B.Skeleton(g,i)})}loadAnimation(P){const A=this.json,s=this,w=A.animations[P],e=w.name?w.name:"animation_"+P,D=[],g=[],i=[],I=[],n=[];for(let C=0,o=w.channels.length;C<o;C++){const t=w.channels[C],v=w.samplers[t.sampler],l=t.target,c=l.node,E=w.parameters!==void 0?w.parameters[v.input]:v.input,a=w.parameters!==void 0?w.parameters[v.output]:v.output;l.node!==void 0&&(D.push(this.getDependency("node",c)),g.push(this.getDependency("accessor",E)),i.push(this.getDependency("accessor",a)),I.push(v),n.push(l))}return Promise.all([Promise.all(D),Promise.all(g),Promise.all(i),Promise.all(I),Promise.all(n)]).then(function(C){const o=C[0],t=C[1],v=C[2],l=C[3],c=C[4],E=[];for(let a=0,L=o.length;a<L;a++){const z=o[a],m=t[a],b=v[a],u=l[a],J=c[a];if(z===void 0)continue;z.updateMatrix&&z.updateMatrix();const d=s._createAnimationTracks(z,m,b,u,J);if(d)for(let h=0;h<d.length;h++)E.push(d[h])}return new B.AnimationClip(e,void 0,E)})}createNodeMesh(P){const A=this.json,s=this,w=A.nodes[P];return w.mesh===void 0?null:s.getDependency("mesh",w.mesh).then(function(e){const D=s._getNodeRef(s.meshCache,w.mesh,e);return w.weights!==void 0&&D.traverse(function(g){if(g.isMesh)for(let i=0,I=w.weights.length;i<I;i++)g.morphTargetInfluences[i]=w.weights[i]}),D})}loadNode(P){const A=this.json,s=this,w=A.nodes[P],e=s._loadNodeShallow(P),D=[],g=w.children||[];for(let I=0,n=g.length;I<n;I++)D.push(s.getDependency("node",g[I]));const i=w.skin===void 0?Promise.resolve(null):s.getDependency("skin",w.skin);return Promise.all([e,Promise.all(D),i]).then(function(I){const n=I[0],C=I[1],o=I[2];o!==null&&n.traverse(function(t){t.isSkinnedMesh&&t.bind(o,OA)});for(let t=0,v=C.length;t<v;t++)n.add(C[t]);return n})}_loadNodeShallow(P){const A=this.json,s=this.extensions,w=this;if(this.nodeCache[P]!==void 0)return this.nodeCache[P];const e=A.nodes[P],D=e.name?w.createUniqueName(e.name):"",g=[],i=w._invokeOne(function(I){return I.createNodeMesh&&I.createNodeMesh(P)});return i&&g.push(i),e.camera!==void 0&&g.push(w.getDependency("camera",e.camera).then(function(I){return w._getNodeRef(w.cameraCache,e.camera,I)})),w._invokeAll(function(I){return I.createNodeAttachment&&I.createNodeAttachment(P)}).forEach(function(I){g.push(I)}),this.nodeCache[P]=Promise.all(g).then(function(I){let n;if(e.isBone===!0?n=new B.Bone:I.length>1?n=new B.Group:I.length===1?n=I[0]:n=new B.Object3D,n!==I[0])for(let C=0,o=I.length;C<o;C++)n.add(I[C]);if(e.name&&(n.userData.name=e.name,n.name=D),f(n,e),e.extensions&&O(s,n,e),e.matrix!==void 0){const C=new B.Matrix4;C.fromArray(e.matrix),n.applyMatrix4(C)}else e.translation!==void 0&&n.position.fromArray(e.translation),e.rotation!==void 0&&n.quaternion.fromArray(e.rotation),e.scale!==void 0&&n.scale.fromArray(e.scale);return w.associations.has(n)||w.associations.set(n,{}),w.associations.get(n).nodes=P,n}),this.nodeCache[P]}loadScene(P){const A=this.extensions,s=this.json.scenes[P],w=this,e=new B.Group;s.name&&(e.name=w.createUniqueName(s.name)),f(e,s),s.extensions&&O(A,e,s);const D=s.nodes||[],g=[];for(let i=0,I=D.length;i<I;i++)g.push(w.getDependency("node",D[i]));return Promise.all(g).then(function(i){for(let n=0,C=i.length;n<C;n++)e.add(i[n]);const I=n=>{const C=new Map;for(const[o,t]of w.associations)(o instanceof B.Material||o instanceof B.Texture)&&C.set(o,t);return n.traverse(o=>{const t=w.associations.get(o);t!=null&&C.set(o,t)}),C};return w.associations=I(e),e})}_createAnimationTracks(P,A,s,w,e){const D=[],g=P.name?P.name:P.uuid,i=[];G[e.path]===G.weights?P.traverse(function(o){o.morphTargetInfluences&&i.push(o.name?o.name:o.uuid)}):i.push(g);let I;switch(G[e.path]){case G.weights:I=B.NumberKeyframeTrack;break;case G.rotation:I=B.QuaternionKeyframeTrack;break;case G.position:case G.scale:I=B.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:I=B.NumberKeyframeTrack;break;case 2:case 3:default:I=B.VectorKeyframeTrack;break}break}const n=w.interpolation!==void 0?uA[w.interpolation]:B.InterpolateLinear,C=this._getArrayFromAccessor(s);for(let o=0,t=i.length;o<t;o++){const v=new I(i[o]+"."+G[e.path],A.array,C,n);w.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(v),D.push(v)}return D}_getArrayFromAccessor(P){let A=P.array;if(P.normalized){const s=N(A.constructor),w=new Float32Array(A.length);for(let e=0,D=A.length;e<D;e++)w[e]=A[e]*s;A=w}return A}_createCubicSplineTrackInterpolant(P){P.createInterpolant=function(s){const w=this instanceof B.QuaternionKeyframeTrack?TA:K;return new w(this.times,this.values,this.getValueSize()/3,s)},P.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function JA(Q,P,A){const s=P.attributes,w=new B.Box3;if(s.POSITION!==void 0){const g=A.json.accessors[s.POSITION],i=g.min,I=g.max;if(i!==void 0&&I!==void 0){if(w.set(new B.Vector3(i[0],i[1],i[2]),new B.Vector3(I[0],I[1],I[2])),g.normalized){const n=N(U[g.componentType]);w.min.multiplyScalar(n),w.max.multiplyScalar(n)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const e=P.targets;if(e!==void 0){const g=new B.Vector3,i=new B.Vector3;for(let I=0,n=e.length;I<n;I++){const C=e[I];if(C.POSITION!==void 0){const o=A.json.accessors[C.POSITION],t=o.min,v=o.max;if(t!==void 0&&v!==void 0){if(i.setX(Math.max(Math.abs(t[0]),Math.abs(v[0]))),i.setY(Math.max(Math.abs(t[1]),Math.abs(v[1]))),i.setZ(Math.max(Math.abs(t[2]),Math.abs(v[2]))),o.normalized){const l=N(U[o.componentType]);i.multiplyScalar(l)}g.max(i)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}w.expandByVector(g)}Q.boundingBox=w;const D=new B.Sphere;w.getCenter(D.center),D.radius=w.min.distanceTo(w.max)/2,Q.boundingSphere=D}function p(Q,P,A){const s=P.attributes,w=[];function e(D,g){return A.getDependency("accessor",D).then(function(i){Q.setAttribute(g,i)})}for(const D in s){const g=F[D]||D.toLowerCase();g in Q.attributes||w.push(e(s[D],g))}if(P.indices!==void 0&&!Q.index){const D=A.getDependency("accessor",P.indices).then(function(g){Q.setIndex(g)});w.push(D)}return B.ColorManagement.workingColorSpace!==B.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${B.ColorManagement.workingColorSpace}" not supported.`),f(Q,P),JA(Q,P,A),Promise.all(w).then(function(){return P.targets!==void 0?bA(Q,P.targets,A):Q})}const YA="data:model/gltf-binary;base64,Z2xURgIAAAA4kwMAWIUAAEpTT057ImFzc2V0Ijp7Imdl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