UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

1 lines • 357 kB
"use strict";const r=require("./three.umd.cjs");class mo extends r.Mesh{constructor(e,t,s,n=128){if(t<=0||s<=0||n<=0)throw new Error("GroundedSkybox height, radius, and resolution must be positive.");const i=new r.SphereGeometry(s,2*n,n);i.scale(1,1,-1);const o=i.getAttribute("position"),a=new r.Vector3;for(let A=0;A<o.count;++A)if(a.fromBufferAttribute(o,A),a.y<0){const l=-t*3/2,h=a.y<l?-t/a.y:1-a.y*a.y/(3*l*l);a.multiplyScalar(h),a.toArray(o.array,3*A)}o.needsUpdate=!0,super(i,new r.MeshBasicMaterial({map:e,depthWrite:!1}))}}function bo(c,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},s=c.getIndex(),n=c.getAttribute("position"),i=s?s.count:n.count;let o=0;const a=Object.keys(c.attributes),A={},l={},h=[],u=["getX","getY","getZ","getW"],g=["setX","setY","setZ","setW"];for(let w=0,C=a.length;w<C;w++){const y=a[w],x=c.attributes[y];A[y]=new x.constructor(new x.array.constructor(x.count*x.itemSize),x.itemSize,x.normalized);const R=c.morphAttributes[y];R&&(l[y]||(l[y]=[]),R.forEach((D,S)=>{const v=new D.array.constructor(D.count*D.itemSize);l[y][S]=new D.constructor(v,D.itemSize,D.normalized)}))}const f=e*.5,I=Math.log10(1/e),m=Math.pow(10,I),b=f*m;for(let w=0;w<i;w++){const C=s?s.getX(w):w;let y="";for(let x=0,R=a.length;x<R;x++){const D=a[x],S=c.getAttribute(D),v=S.itemSize;for(let N=0;N<v;N++)y+=`${~~(S[u[N]](C)*m+b)},`}if(y in t)h.push(t[y]);else{for(let x=0,R=a.length;x<R;x++){const D=a[x],S=c.getAttribute(D),v=c.morphAttributes[D],N=S.itemSize,G=A[D],H=l[D];for(let X=0;X<N;X++){const U=u[X],Y=g[X];if(G[Y](o,S[U](C)),v)for(let O=0,Z=v.length;O<Z;O++)H[O][Y](o,v[O][U](C))}}t[y]=o,h.push(o),o++}}const B=c.clone();for(const w in c.attributes){const C=A[w];if(B.setAttribute(w,new C.constructor(C.array.slice(0,o*C.itemSize),C.itemSize,C.normalized)),w in l)for(let y=0;y<l[w].length;y++){const x=l[w][y];B.morphAttributes[w][y]=new x.constructor(x.array.slice(0,o*x.itemSize),x.itemSize,x.normalized)}}return B.setIndex(h),B}function As(c,e){if(e===r.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),c;if(e===r.TriangleFanDrawMode||e===r.TriangleStripDrawMode){let t=c.getIndex();if(t===null){const o=[],a=c.getAttribute("position");if(a!==void 0){for(let A=0;A<a.count;A++)o.push(A);c.setIndex(o),t=c.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),c}const s=t.count-2,n=[];if(e===r.TriangleFanDrawMode)for(let o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=c.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),c}class Vn extends r.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new wo(t)}),this.register(function(t){return new Qo(t)}),this.register(function(t){return new Fo(t)}),this.register(function(t){return new Lo(t)}),this.register(function(t){return new ko(t)}),this.register(function(t){return new So(t)}),this.register(function(t){return new To(t)}),this.register(function(t){return new vo(t)}),this.register(function(t){return new Mo(t)}),this.register(function(t){return new yo(t)}),this.register(function(t){return new Ro(t)}),this.register(function(t){return new xo(t)}),this.register(function(t){return new _o(t)}),this.register(function(t){return new Do(t)}),this.register(function(t){return new Co(t)}),this.register(function(t){return new Go(t)}),this.register(function(t){return new Uo(t)})}load(e,t,s,n){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const l=r.LoaderUtils.extractUrlBase(e);o=r.LoaderUtils.resolveURL(l,this.path)}else o=r.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){n?n(l):console.error(l),i.manager.itemError(e),i.manager.itemEnd(e)},A=new r.FileLoader(this.manager);A.setPath(this.path),A.setResponseType("arraybuffer"),A.setRequestHeader(this.requestHeader),A.setWithCredentials(this.withCredentials),A.load(e,function(l){try{i.parse(l,o,function(h){t(h),i.manager.itemEnd(e)},a)}catch(h){a(h)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let i,o;const a={},A={},l=new TextDecoder;if(typeof e=="string")try{i=JSON.parse(e)}catch(u){o=e,n&&n(u);return}else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Zs){try{a[re.KHR_BINARY_GLTF]=new No(e)}catch(g){n&&n(g);return}try{i=JSON.parse(a[re.KHR_BINARY_GLTF].content)}catch(g){o=a[re.KHR_BINARY_GLTF].content,n&&n(g);return}}else try{i=JSON.parse(l.decode(e))}catch(g){o=l.decode(e),n&&n(g);return}else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}this.json=i,this.jsonErrorData=o;const h=new Zo(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const g=this.pluginCallbacks[u](h);g.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),A[g.name]=g,a[g.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const g=i.extensionsUsed[u],f=i.extensionsRequired||[];switch(g){case re.KHR_MATERIALS_UNLIT:a[g]=new Bo;break;case re.KHR_DRACO_MESH_COMPRESSION:a[g]=new Po(i,this.dracoLoader);break;case re.KHR_TEXTURE_TRANSFORM:a[g]=new Oo;break;case re.KHR_MESH_QUANTIZATION:a[g]=new Ho;break;default:f.indexOf(g)>=0&&A[g]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+g+'".')}}h.setExtensions(a),h.setPlugins(A),h.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function Eo(){let c={};return{get:function(e){return c[e]},add:function(e,t){c[e]=t},remove:function(e){delete c[e]},removeAll:function(){c={}}}}const re={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Co{constructor(e){this.parser=e,this.name=re.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,A=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let l;const h=new r.Color(16777215);A.color!==void 0&&h.setRGB(A.color[0],A.color[1],A.color[2],r.LinearSRGBColorSpace);const u=A.range!==void 0?A.range:0;switch(A.type){case"directional":l=new r.DirectionalLight(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new r.PointLight(h),l.distance=u;break;case"spot":l=new r.SpotLight(h),l.distance=u,A.spot=A.spot||{},A.spot.innerConeAngle=A.spot.innerConeAngle!==void 0?A.spot.innerConeAngle:0,A.spot.outerConeAngle=A.spot.outerConeAngle!==void 0?A.spot.outerConeAngle:Math.PI/4,l.angle=A.spot.outerConeAngle,l.penumbra=1-A.spot.innerConeAngle/A.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+A.type)}return l.position.set(0,0,0),l.decay=2,at(l,A),A.intensity!==void 0&&(l.intensity=A.intensity),l.name=t.createUniqueName(A.name||"light_"+e),n=Promise.resolve(l),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(A){return s._getNodeRef(t.cache,a,A)})}}let Bo=class{constructor(){this.name=re.KHR_MATERIALS_UNLIT}getMaterialType(){return r.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new r.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],r.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,r.SRGBColorSpace))}return Promise.all(n)}},yo=class{constructor(e){this.parser=e,this.name=re.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}},wo=class{constructor(e){this.parser=e,this.name=re.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:r.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new r.Vector2(a,a)}return Promise.all(i)}},Qo=class{constructor(e){this.parser=e,this.name=re.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:r.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}},xo=class{constructor(e){this.parser=e,this.name=re.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:r.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}},So=class{constructor(e){this.parser=e,this.name=re.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:r.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new r.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],r.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,r.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}},To=class{constructor(e){this.parser=e,this.name=re.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:r.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}},vo=class{constructor(e){this.parser=e,this.name=re.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:r.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new r.Color().setRGB(a[0],a[1],a[2],r.LinearSRGBColorSpace),Promise.all(i)}},Mo=class{constructor(e){this.parser=e,this.name=re.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:r.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}},Ro=class{constructor(e){this.parser=e,this.name=re.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:r.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new r.Color().setRGB(a[0],a[1],a[2],r.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,r.SRGBColorSpace)),Promise.all(i)}},Do=class{constructor(e){this.parser=e,this.name=re.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:r.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(i)}},_o=class{constructor(e){this.parser=e,this.name=re.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:r.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}};class Fo{constructor(e){this.parser=e,this.name=re.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class Lo{constructor(e){this.parser=e,this.name=re.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=n.images[o.source];let A=s.textureLoader;if(a.uri){const l=s.options.manager.getHandler(a.uri);l!==null&&(A=l)}return this.detectSupport().then(function(l){if(l)return s.loadTextureImage(e,o.source,A);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ko{constructor(e){this.parser=e,this.name=re.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=n.images[o.source];let A=s.textureLoader;if(a.uri){const l=s.options.manager.getHandler(a.uri);l!==null&&(A=l)}return this.detectSupport().then(function(l){if(l)return s.loadTextureImage(e,o.source,A);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Go{constructor(e){this.name=re.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const A=n.byteOffset||0,l=n.byteLength||0,h=n.count,u=n.byteStride,g=new Uint8Array(a,A,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,g,n.mode,n.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(f),h,u,g,n.mode,n.filter),f})})}else return null}}let Uo=class{constructor(e){this.name=re.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const l of n.primitives)if(l.mode!==Ve.TRIANGLES&&l.mode!==Ve.TRIANGLE_STRIP&&l.mode!==Ve.TRIANGLE_FAN&&l.mode!==void 0)return null;const o=s.extensions[this.name].attributes,a=[],A={};for(const l in o)a.push(this.parser.getDependency("accessor",o[l]).then(h=>(A[l]=h,A[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],g=l[0].count,f=[];for(const I of u){const m=new r.Matrix4,b=new r.Vector3,B=new r.Quaternion,w=new r.Vector3(1,1,1),C=new r.InstancedMesh(I.geometry,I.material,g);for(let y=0;y<g;y++)A.TRANSLATION&&b.fromBufferAttribute(A.TRANSLATION,y),A.ROTATION&&B.fromBufferAttribute(A.ROTATION,y),A.SCALE&&w.fromBufferAttribute(A.SCALE,y),C.setMatrixAt(y,m.compose(b,B,w));for(const y in A)if(y==="_COLOR_0"){const x=A[y];C.instanceColor=new r.InstancedBufferAttribute(x.array,x.itemSize,x.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&I.geometry.setAttribute(y,A[y]);r.Object3D.prototype.copy.call(C,I),this.parser.assignFinalMaterial(C),f.push(C)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}};const Zs="glTF",Rt=12,cs={JSON:1313821514,BIN:5130562};class No{constructor(e){this.name=re.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Rt),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Zs)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-Rt,i=new DataView(e,Rt);let o=0;for(;o<n;){const a=i.getUint32(o,!0);o+=4;const A=i.getUint32(o,!0);if(o+=4,A===cs.JSON){const l=new Uint8Array(e,Rt+o,a);this.content=s.decode(l)}else if(A===cs.BIN){const l=Rt+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Po{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=re.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},A={},l={};for(const h in o){const u=Un[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=Un[h]||h.toLowerCase();if(o[h]!==void 0){const g=s.accessors[e.attributes[h]],f=Tt[g.componentType];l[u]=f.name,A[u]=g.normalized===!0}}return t.getDependency("bufferView",i).then(function(h){return new Promise(function(u,g){n.decodeDracoFile(h,function(f){for(const I in f.attributes){const m=f.attributes[I],b=A[I];b!==void 0&&(m.normalized=b)}u(f)},a,l,r.LinearSRGBColorSpace,g)})})}}class Oo{constructor(){this.name=re.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Ho{constructor(){this.name=re.KHR_MESH_QUANTIZATION}}class $s extends r.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[i+o];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,A=a*2,l=a*3,h=n-t,u=(s-t)/h,g=u*u,f=g*u,I=e*l,m=I-l,b=-2*f+3*g,B=f-g,w=1-b,C=B-g+u;for(let y=0;y!==a;y++){const x=o[m+y+a],R=o[m+y+A]*h,D=o[I+y+a],S=o[I+y]*h;i[y]=w*x+C*R+b*D+B*S}return i}}const jo=new r.Quaternion;class qo extends $s{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return jo.fromArray(i).normalize().toArray(i),i}}const Ve={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Tt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ls={9728:r.NearestFilter,9729:r.LinearFilter,9984:r.NearestMipmapNearestFilter,9985:r.LinearMipmapNearestFilter,9986:r.NearestMipmapLinearFilter,9987:r.LinearMipmapLinearFilter},hs={33071:r.ClampToEdgeWrapping,33648:r.MirroredRepeatWrapping,10497:r.RepeatWrapping},pn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Un={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"},lt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},zo={CUBICSPLINE:void 0,LINEAR:r.InterpolateLinear,STEP:r.InterpolateDiscrete},gn={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Yo(c){return c.DefaultMaterial===void 0&&(c.DefaultMaterial=new r.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:r.FrontSide})),c.DefaultMaterial}function dt(c,e,t){for(const s in t.extensions)c[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function at(c,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(c.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Ko(c,e,t){let s=!1,n=!1,i=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(c);const o=[],a=[],A=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(s){const g=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):c.attributes.position;o.push(g)}if(n){const g=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):c.attributes.normal;a.push(g)}if(i){const g=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):c.attributes.color;A.push(g)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(A)]).then(function(l){const h=l[0],u=l[1],g=l[2];return s&&(c.morphAttributes.position=h),n&&(c.morphAttributes.normal=u),i&&(c.morphAttributes.color=g),c.morphTargetsRelative=!0,c})}function Vo(c,e){if(c.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)c.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(c.morphTargetInfluences.length===t.length){c.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)c.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Jo(c){let e;const t=c.extensions&&c.extensions[re.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+fn(t.attributes):e=c.indices+":"+fn(c.attributes)+":"+c.mode,c.targets!==void 0)for(let s=0,n=c.targets.length;s<n;s++)e+=":"+fn(c.targets[s]);return e}function fn(c){let e="";const t=Object.keys(c).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+c[t[s]]+";";return e}function Nn(c){switch(c){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Wo(c){return c.search(/\.jpe?g($|\?)/i)>0||c.search(/^data\:image\/jpeg/)===0?"image/jpeg":c.search(/\.webp($|\?)/i)>0||c.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Xo=new r.Matrix4;class Zo{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Eo,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,i=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const A=a.match(/Version\/(\d+)/);n=s&&A?parseInt(A[1],10):-1,i=a.indexOf("Firefox")>-1,o=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&o<98?this.textureLoader=new r.TextureLoader(this.options.manager):this.textureLoader=new r.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new r.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const a={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return dt(i,a,n),at(a,n),Promise.all(s._invokeAll(function(A){return A.afterRoot&&A.afterRoot(a)})).then(function(){for(const A of a.scenes)A.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n].joints;for(let a=0,A=o.length;a<A;a++)e[o[a]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(o,a)=>{const A=this.associations.get(o);A!=null&&this.associations.set(a,A);for(const[l,h]of o.children.entries())i(h,a.children[l])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[re.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(r.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=pn[n.type],a=Tt[n.componentType],A=n.normalized===!0,l=new a(n.count*o);return Promise.resolve(new r.BufferAttribute(l,o,A))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(o){const a=o[0],A=pn[n.type],l=Tt[n.componentType],h=l.BYTES_PER_ELEMENT,u=h*A,g=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,I=n.normalized===!0;let m,b;if(f&&f!==u){const B=Math.floor(g/f),w="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+B+":"+n.count;let C=t.cache.get(w);C||(m=new l(a,B*f,n.count*f/h),C=new r.InterleavedBuffer(m,f/h),t.cache.add(w,C)),b=new r.InterleavedBufferAttribute(C,A,g%f/h,I)}else a===null?m=new l(n.count*A):m=new l(a,g,n.count*A),b=new r.BufferAttribute(m,A,I);if(n.sparse!==void 0){const B=pn.SCALAR,w=Tt[n.sparse.indices.componentType],C=n.sparse.indices.byteOffset||0,y=n.sparse.values.byteOffset||0,x=new w(o[1],C,n.sparse.count*B),R=new l(o[2],y,n.sparse.count*A);a!==null&&(b=new r.BufferAttribute(b.array.slice(),b.itemSize,b.normalized)),b.normalized=!1;for(let D=0,S=x.length;D<S;D++){const v=x[D];if(b.setX(v,R[D*A]),A>=2&&b.setY(v,R[D*A+1]),A>=3&&b.setZ(v,R[D*A+2]),A>=4&&b.setW(v,R[D*A+3]),A>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}b.normalized=I}return b})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,o=t.images[i];let a=this.textureLoader;if(o.uri){const A=s.manager.getHandler(o.uri);A!==null&&(a=A)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,s){const n=this,i=this.json,o=i.textures[e],a=i.images[t],A=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[A])return this.textureCache[A];const l=this.loadImageSource(t,s).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const g=(i.samplers||{})[o.sampler]||{};return h.magFilter=ls[g.magFilter]||r.LinearFilter,h.minFilter=ls[g.minFilter]||r.LinearMipmapLinearFilter,h.wrapS=hs[g.wrapS]||r.RepeatWrapping,h.wrapT=hs[g.wrapT]||r.RepeatWrapping,h.anisotropy=4,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[A]=l,l}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=n.images[e],a=self.URL||self.webkitURL;let A=o.uri||"",l=!1;if(o.bufferView!==void 0)A=s.getDependency("bufferView",o.bufferView).then(function(u){l=!0;const g=new Blob([u],{type:o.mimeType});return A=a.createObjectURL(g),A});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(A).then(function(u){return new Promise(function(g,f){let I=g;t.isImageBitmapLoader===!0&&(I=function(m){const b=new r.Texture(m);b.needsUpdate=!0,g(b)}),t.load(r.LoaderUtils.resolveURL(u,i.path),I,void 0,f)})}).then(function(u){return l===!0&&a.revokeObjectURL(A),at(u,o),u.userData.mimeType=o.mimeType||Wo(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",A),u});return this.sourceCache[e]=h,h}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[re.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[re.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const A=i.associations.get(o);o=i.extensions[re.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),i.associations.set(o,A)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let A=this.cache.get(a);A||(A=new r.PointsMaterial,r.Material.prototype.copy.call(A,s),A.color.copy(s.color),A.map=s.map,A.sizeAttenuation=!1,this.cache.add(a,A)),s=A}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let A=this.cache.get(a);A||(A=new r.LineBasicMaterial,r.Material.prototype.copy.call(A,s),A.color.copy(s.color),A.map=s.map,this.cache.add(a,A)),s=A}if(n||i||o){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let A=this.cache.get(a);A||(A=s.clone(),i&&(A.vertexColors=!0),o&&(A.flatShading=!0),n&&(A.normalScale&&(A.normalScale.y*=-1),A.clearcoatNormalScale&&(A.clearcoatNormalScale.y*=-1)),this.cache.add(a,A),this.associations.set(A,this.associations.get(s))),s=A}e.material=s}getMaterialType(){return r.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let o;const a={},A=i.extensions||{},l=[];if(A[re.KHR_MATERIALS_UNLIT]){const u=n[re.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),l.push(u.extendParams(a,i,t))}else{const u=i.pbrMetallicRoughness||{};if(a.color=new r.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const g=u.baseColorFactor;a.color.setRGB(g[0],g[1],g[2],r.LinearSRGBColorSpace),a.opacity=g[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",u.baseColorTexture,r.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,a)})))}i.doubleSided===!0&&(a.side=r.DoubleSide);const h=i.alphaMode||gn.OPAQUE;if(h===gn.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===gn.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==r.MeshBasicMaterial&&(l.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new r.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;a.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&o!==r.MeshBasicMaterial&&(l.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==r.MeshBasicMaterial){const u=i.emissiveFactor;a.emissive=new r.Color().setRGB(u[0],u[1],u[2],r.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==r.MeshBasicMaterial&&l.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,r.SRGBColorSpace)),Promise.all(l).then(function(){const u=new o(a);return i.name&&(u.name=i.name),at(u,i),t.associations.set(u,{materials:e}),i.extensions&&dt(n,u,i),u})}createUniqueName(e){const t=r.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(a){return s[re.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(A){return us(A,a,t)})}const o=[];for(let a=0,A=e.length;a<A;a++){const l=e[a],h=Jo(l),u=n[h];if(u)o.push(u.promise);else{let g;l.extensions&&l.extensions[re.KHR_DRACO_MESH_COMPRESSION]?g=i(l):g=us(new r.BufferGeometry,l,t),n[h]={primitive:l,promise:g},o.push(g)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],o=i.primitives,a=[];for(let A=0,l=o.length;A<l;A++){const h=o[A].material===void 0?Yo(this.cache):this.getDependency("material",o[A].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(A){const l=A.slice(0,A.length-1),h=A[A.length-1],u=[];for(let f=0,I=h.length;f<I;f++){const m=h[f],b=o[f];let B;const w=l[f];if(b.mode===Ve.TRIANGLES||b.mode===Ve.TRIANGLE_STRIP||b.mode===Ve.TRIANGLE_FAN||b.mode===void 0)B=i.isSkinnedMesh===!0?new r.SkinnedMesh(m,w):new r.Mesh(m,w),B.isSkinnedMesh===!0&&B.normalizeSkinWeights(),b.mode===Ve.TRIANGLE_STRIP?B.geometry=As(B.geometry,r.TriangleStripDrawMode):b.mode===Ve.TRIANGLE_FAN&&(B.geometry=As(B.geometry,r.TriangleFanDrawMode));else if(b.mode===Ve.LINES)B=new r.LineSegments(m,w);else if(b.mode===Ve.LINE_STRIP)B=new r.Line(m,w);else if(b.mode===Ve.LINE_LOOP)B=new r.LineLoop(m,w);else if(b.mode===Ve.POINTS)B=new r.Points(m,w);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+b.mode);Object.keys(B.geometry.morphAttributes).length>0&&Vo(B,i),B.name=t.createUniqueName(i.name||"mesh_"+e),at(B,i),b.extensions&&dt(n,B,b),t.assignFinalMaterial(B),u.push(B)}for(let f=0,I=u.length;f<I;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return i.extensions&&dt(n,u[0],i),u[0];const g=new r.Group;i.extensions&&dt(n,g,i),t.associations.set(g,{meshes:e});for(let f=0,I=u.length;f<I;f++)g.add(u[f]);return g})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new r.PerspectiveCamera(r.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new r.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),at(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,a=[],A=[];for(let l=0,h=o.length;l<h;l++){const u=o[l];if(u){a.push(u);const g=new r.Matrix4;i!==null&&g.fromArray(i.array,l*16),A.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new r.Skeleton(a,A)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,o=[],a=[],A=[],l=[],h=[];let u=0,g=n.channels.length;for(u=0,g=n.channels.length;u<g;u++){const f=n.channels[u],I=n.samplers[f.sampler],m=f.target,b=m.node,B=n.parameters!==void 0?n.parameters[I.input]:I.input,w=n.parameters!==void 0?n.parameters[I.output]:I.output;m.node!==void 0&&(o.push(this.getDependency("node",b)),a.push(this.getDependency("accessor",B)),A.push(this.getDependency("accessor",w)),l.push(I),h.push(m))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(A),Promise.all(l),Promise.all(h)]).then(function(f){const I=f[0],m=f[1],b=f[2],B=f[3],w=f[4],C=[];for(u=0,g=I.length;u<g;u++){const y=I[u],x=m[u],R=b[u],D=B[u],S=w[u];if(y===void 0)continue;y.updateMatrix&&y.updateMatrix();const v=s._createAnimationTracks(y,x,R,D,S);if(v)for(let N=0;N<v.length;N++)C.push(v[N])}return new r.AnimationClip(i,void 0,C)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let A=0,l=n.weights.length;A<l;A++)a.morphTargetInfluences[A]=n.weights[A]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),o=[],a=n.children||[];for(let l=0,h=a.length;l<h;l++)o.push(s.getDependency("node",a[l]));const A=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),A]).then(function(l){const h=l[0],u=l[1],g=l[2];g!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(g,Xo)});for(let f=0,I=u.length;f<I;f++)h.add(u[f]);return h})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",a=[],A=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return A&&a.push(A),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(l){return n._getNodeRef(n.cameraCache,i.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let h;if(i.isBone===!0?h=new r.Bone:l.length>1?h=new r.Group:l.length===1?h=l[0]:h=new r.Object3D,h!==l[0])for(let u=0,g=l.length;u<g;u++)h.add(l[u]);if(i.name&&(h.userData.name=i.name,h.name=o),at(h,i),i.extensions&&dt(s,h,i),i.matrix!==void 0){const u=new r.Matrix4;u.fromArray(i.matrix),h.applyMatrix4(u)}else i.translation!==void 0&&h.position.fromArray(i.translation),i.rotation!==void 0&&h.quaternion.fromArray(i.rotation),i.scale!==void 0&&h.scale.fromArray(i.scale);return n.associations.has(h)||n.associations.set(h,{}),n.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new r.Group;s.name&&(i.name=n.createUniqueName(s.name)),at(i,s),s.extensions&&dt(t,i,s);const o=s.nodes||[],a=[];for(let A=0,l=o.length;A<l;A++)a.push(n.getDependency("node",o[A]));return Promise.all(a).then(function(A){for(let h=0,u=A.length;h<u;h++)i.add(A[h]);const l=h=>{const u=new Map;for(const[g,f]of n.associations)(g instanceof r.Material||g instanceof r.Texture)&&u.set(g,f);return h.traverse(g=>{const f=n.associations.get(g);f!=null&&u.set(g,f)}),u};return n.associations=l(i),i})}_createAnimationTracks(e,t,s,n,i){const o=[],a=e.name?e.name:e.uuid,A=[];lt[i.path]===lt.weights?e.traverse(function(g){g.morphTargetInfluences&&A.push(g.name?g.name:g.uuid)}):A.push(a);let l;switch(lt[i.path]){case lt.weights:l=r.NumberKeyframeTrack;break;case lt.rotation:l=r.QuaternionKeyframeTrack;break;case lt.position:case lt.scale:l=r.VectorKeyframeTrack;break;default:s.itemSize===1?l=r.NumberKeyframeTrack:l=r.VectorKeyframeTrack;break}const h=n.interpolation!==void 0?zo[n.interpolation]:r.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let g=0,f=A.length;g<f;g++){const I=new l(A[g]+"."+lt[i.path],t.array,u,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(I),o.push(I)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=Nn(t.constructor),n=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof r.QuaternionKeyframeTrack?qo:$s;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function $o(c,e,t){const s=e.attributes,n=new r.Box3;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],A=a.min,l=a.max;if(A!==void 0&&l!==void 0){if(n.set(new r.Vector3(A[0],A[1],A[2]),new r.Vector3(l[0],l[1],l[2])),a.normalized){const h=Nn(Tt[a.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const a=new r.Vector3,A=new r.Vector3;for(let l=0,h=i.length;l<h;l++){const u=i[l];if(u.POSITION!==void 0){const g=t.json.accessors[u.POSITION],f=g.min,I=g.max;if(f!==void 0&&I!==void 0){if(A.setX(Math.max(Math.abs(f[0]),Math.abs(I[0]))),A.setY(Math.max(Math.abs(f[1]),Math.abs(I[1]))),A.setZ(Math.max(Math.abs(f[2]),Math.abs(I[2]))),g.normalized){const m=Nn(Tt[g.componentType]);A.multiplyScalar(m)}a.max(A)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}c.boundingBox=n;const o=new r.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,c.boundingSphere=o}function us(c,e,t){const s=e.attributes,n=[];function i(o,a){return t.getDependency("accessor",o).then(function(A){c.setAttribute(a,A)})}for(const o in s){const a=Un[o]||o.toLowerCase();a in c.attributes||n.push(i(s[o],a))}if(e.indices!==void 0&&!c.index){const o=t.getDependency("accessor",e.indices).then(function(a){c.setIndex(a)});n.push(o)}return r.ColorManagement.workingColorSpace!==r.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${r.ColorManagement.workingColorSpace}" not supported.`),at(c,e),$o(c,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Ko(c,e.targets,t):c})}var er=(function(){var c="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WF