@quick-threejs/reactive 0.1.26 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var re=Object.defineProperty;var ie=(c,t,e)=>t in c?re(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var y=(c,t,e)=>ie(c,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./app.module-Xeth1BSd.js"),u=require("three");class U{constructor(){y(this,"location");y(this,"initOnConstruct");y(this,"canvas");y(this,"fullScreen");y(this,"defaultCamera");y(this,"startTimer");y(this,"loaderDataSources",[]);y(this,"loadResourcesOnInit");y(this,"enableDebug");y(this,"axesSizes");y(this,"gridSizes");y(this,"withMiniCamera");y(this,"onReady")}}class oe{constructor(){y(this,"onReady")}}var ae=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,le=(c,t,e,r)=>{for(var n=r>1?void 0:r?ce(t,e):t,i=c.length-1,s;i>=0;i--)(s=c[i])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&ae(t,e,n),n};let F=class{constructor(){y(this,"workerPool",m.C(void 0,!0));y(this,"canvas");y(this,"worker");y(this,"thread")}init(c){this.worker=c.worker,this.thread=c.thread}};F=le([m.singleton()],F);var ue=Object.defineProperty,de=Object.getOwnPropertyDescriptor,he=(c,t,e,r)=>{for(var n=r>1?void 0:r?de(t,e):t,i=c.length-1,s;i>=0;i--)(s=c[i])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&ue(t,e,n),n},fe=(c,t)=>(e,r)=>t(e,r,c);let $=class extends m.ProxyEventHandlersBlueprint{constructor(t){super();y(this,"canvas");this._service=t}init(t){this.canvas=t;for(const e of m.PROXY_EVENT_LISTENERS){const r=e.startsWith("mouse")||e.startsWith("pointer")||e.startsWith("touch")?this.mouseEventHandler:e.startsWith("key")?this.keyEventHandler:e==="resize"?this.uiEventHandler:e==="wheel"?this.wheelEventHandler:this.preventDefaultHandler;this[`${e}$`]=m.fromEvent(e==="resize"?window:t,e).pipe(m.map(r.bind(this)),m.filter(n=>!(e==="keydown"&&!n))),this[`${e}$`].subscribe(n=>{var i,s;(s=(i=this._service.thread)==null?void 0:i[e])==null||s.call(i,n)})}}preventDefaultHandler(t){return t.preventDefault(),{type:t.type}}getScreenSizes(){return{width:this.canvas.width,height:this.canvas.height,windowWidth:(window==null?void 0:window.innerWidth)??0,windowHeight:(window==null?void 0:window.innerHeight)??0}}uiEventHandler(t){const e=this.canvas.getBoundingClientRect();return{...this.getScreenSizes(),type:t.type,top:e.top,left:e.left}}mouseEventHandler(t){return{...this.getScreenSizes(),...m.J(t,["ctrlKey","metaKey","shiftKey","button","pointerType","clientX","clientY","pageX","pageY"])}}touchEventHandler(t){const e=[],r={type:t.type,touches:e};for(let n=0;n<t.touches.length;++n){const i=t.touches[n];e.push({pageX:(i==null?void 0:i.pageX)??0,pageY:(i==null?void 0:i.pageY)??0})}return{...this.getScreenSizes(),...r}}wheelEventHandler(t){return t.preventDefault(),{...this.getScreenSizes(),...m.J(t,["deltaX","deltaY"])}}keyEventHandler(t){if(m.KEYBOARD_EVENT_CODES.includes(t.code))return t.preventDefault(),{...this.getScreenSizes(),...m.J(t,["ctrlKey","metaKey","shiftKey","keyCode"])}}};$=he([m.singleton(),fe(0,m.inject(F))],$);function Q(c,t){if(t===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),c;if(t===u.TriangleFanDrawMode||t===u.TriangleStripDrawMode){let e=c.getIndex();if(e===null){const s=[],o=c.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);c.setIndex(s),e=c.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),c}const r=e.count-2,n=[];if(t===u.TriangleFanDrawMode)for(let s=1;s<=r;s++)n.push(e.getX(0)),n.push(e.getX(s)),n.push(e.getX(s+1));else for(let s=0;s<r;s++)s%2===0?(n.push(e.getX(s)),n.push(e.getX(s+1)),n.push(e.getX(s+2))):(n.push(e.getX(s+2)),n.push(e.getX(s+1)),n.push(e.getX(s)));n.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=c.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),c}class pe extends u.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new _e(e)}),this.register(function(e){return new Re(e)}),this.register(function(e){return new Ce(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new Le(e)}),this.register(function(e){return new ye(e)}),this.register(function(e){return new we(e)}),this.register(function(e){return new xe(e)}),this.register(function(e){return new Te(e)}),this.register(function(e){return new Se(e)}),this.register(function(e){return new Ee(e)}),this.register(function(e){return new Me(e)}),this.register(function(e){return new be(e)}),this.register(function(e){return new ge(e)}),this.register(function(e){return new Ie(e)}),this.register(function(e){return new Ne(e)})}load(t,e,r,n){const i=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const l=u.LoaderUtils.extractUrlBase(t);s=u.LoaderUtils.resolveURL(l,this.path)}else s=u.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const o=function(l){n?n(l):console.error(l),i.manager.itemError(t),i.manager.itemEnd(t)},a=new u.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(l){try{i.parse(l,s,function(h){e(h),i.manager.itemEnd(t)},o)}catch(h){o(h)}},r,o)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,r,n){let i;const s={},o={},a=new TextDecoder;if(typeof t=="string")i=JSON.parse(t);else if(t instanceof ArrayBuffer)if(a.decode(new Uint8Array(t,0,4))===ne){try{s[R.KHR_BINARY_GLTF]=new Pe(t)}catch(d){n&&n(d);return}i=JSON.parse(s[R.KHR_BINARY_GLTF].content)}else i=JSON.parse(a.decode(t));else i=t;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new We(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](l);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[d.name]=d,s[d.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const d=i.extensionsUsed[h],f=i.extensionsRequired||[];switch(d){case R.KHR_MATERIALS_UNLIT:s[d]=new Ae;break;case R.KHR_DRACO_MESH_COMPRESSION:s[d]=new De(i,this.dracoLoader);break;case R.KHR_TEXTURE_TRANSFORM:s[d]=new ke;break;case R.KHR_MESH_QUANTIZATION:s[d]=new Fe;break;default:f.indexOf(d)>=0&&o[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(r,n)}parseAsync(t,e){const r=this;return new Promise(function(n,i){r.parse(t,e,n,i)})}}function me(){let c={};return{get:function(t){return c[t]},add:function(t,e){c[t]=e},remove:function(t){delete c[t]},removeAll:function(){c={}}}}const R={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 ge{constructor(t){this.parser=t,this.name=R.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let r=0,n=e.length;r<n;r++){const i=e[r];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,r="light:"+t;let n=e.cache.get(r);if(n)return n;const i=e.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let l;const h=new u.Color(16777215);a.color!==void 0&&h.setRGB(a.color[0],a.color[1],a.color[2],u.LinearSRGBColorSpace);const d=a.range!==void 0?a.range:0;switch(a.type){case"directional":l=new u.DirectionalLight(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new u.PointLight(h),l.distance=d;break;case"spot":l=new u.SpotLight(h),l.distance=d,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,M(l,a),a.intensity!==void 0&&(l.intensity=a.intensity),l.name=e.createUniqueName(a.name||"light_"+t),n=Promise.resolve(l),e.cache.add(r,n),n}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,r=this.parser,i=r.json.nodes[t],o=(i.extensions&&i.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(a){return r._getNodeRef(e.cache,o,a)})}}class Ae{constructor(){this.name=R.KHR_MATERIALS_UNLIT}getMaterialType(){return u.MeshBasicMaterial}extendParams(t,e,r){const n=[];t.color=new u.Color(1,1,1),t.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const s=i.baseColorFactor;t.color.setRGB(s[0],s[1],s[2],u.LinearSRGBColorSpace),t.opacity=s[3]}i.baseColorTexture!==void 0&&n.push(r.assignTexture(t,"map",i.baseColorTexture,u.SRGBColorSpace))}return Promise.all(n)}}class Te{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(e.emissiveIntensity=i),Promise.resolve()}}class _e{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&i.push(r.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&i.push(r.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(i.push(r.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const o=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new u.Vector2(o,o)}return Promise.all(i)}}class Re{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_DISPERSION}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Ee{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&i.push(r.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&i.push(r.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(i)}}class Le{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_SHEEN}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];e.sheenColor=new u.Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=n.extensions[this.name];if(s.sheenColorFactor!==void 0){const o=s.sheenColorFactor;e.sheenColor.setRGB(o[0],o[1],o[2],u.LinearSRGBColorSpace)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&i.push(r.assignTexture(e,"sheenColorMap",s.sheenColorTexture,u.SRGBColorSpace)),s.sheenRoughnessTexture!==void 0&&i.push(r.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class ye{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&i.push(r.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class we{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_VOLUME}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&i.push(r.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return e.attenuationColor=new u.Color().setRGB(o[0],o[1],o[2],u.LinearSRGBColorSpace),Promise.all(i)}}class xe{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_IOR}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Se{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_SPECULAR}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&i.push(r.assignTexture(e,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return e.specularColor=new u.Color().setRGB(o[0],o[1],o[2],u.LinearSRGBColorSpace),s.specularColorTexture!==void 0&&i.push(r.assignTexture(e,"specularColorMap",s.specularColorTexture,u.SRGBColorSpace)),Promise.all(i)}}class be{constructor(t){this.parser=t,this.name=R.EXT_MATERIALS_BUMP}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&i.push(r.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(i)}}class Me{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&i.push(r.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(i)}}class Ce{constructor(t){this.parser=t,this.name=R.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,r=e.json,n=r.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,i.source,s)}}class ve{constructor(t){this.parser=t,this.name=R.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,r=this.parser,n=r.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const s=i.extensions[e],o=n.images[s.source];let a=r.textureLoader;if(o.uri){const l=r.options.manager.getHandler(o.uri);l!==null&&(a=l)}return this.detectSupport().then(function(l){if(l)return r.loadTextureImage(t,s.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Oe{constructor(t){this.parser=t,this.name=R.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,r=this.parser,n=r.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const s=i.extensions[e],o=n.images[s.source];let a=r.textureLoader;if(o.uri){const l=r.options.manager.getHandler(o.uri);l!==null&&(a=l)}return this.detectSupport().then(function(l){if(l)return r.loadTextureImage(t,s.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Ie{constructor(t){this.name=R.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,r=e.bufferViews[t];if(r.extensions&&r.extensions[this.name]){const n=r.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(o){const a=n.byteOffset||0,l=n.byteLength||0,h=n.count,d=n.byteStride,f=new Uint8Array(o,a,l);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(h,d,f,n.mode,n.filter).then(function(p){return p.buffer}):s.ready.then(function(){const p=new ArrayBuffer(h*d);return s.decodeGltfBuffer(new Uint8Array(p),h,d,f,n.mode,n.filter),p})})}else return null}}class Ne{constructor(t){this.name=R.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,r=e.nodes[t];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const n=e.meshes[r.mesh];for(const l of n.primitives)if(l.mode!==x.TRIANGLES&&l.mode!==x.TRIANGLE_STRIP&&l.mode!==x.TRIANGLE_FAN&&l.mode!==void 0)return null;const s=r.extensions[this.name].attributes,o=[],a={};for(const l in s)o.push(this.parser.getDependency("accessor",s[l]).then(h=>(a[l]=h,a[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(t)),Promise.all(o).then(l=>{const h=l.pop(),d=h.isGroup?h.children:[h],f=l[0].count,p=[];for(const g of d){const _=new u.Matrix4,A=new u.Vector3,T=new u.Quaternion,E=new u.Vector3(1,1,1),w=new u.InstancedMesh(g.geometry,g.material,f);for(let L=0;L<f;L++)a.TRANSLATION&&A.fromBufferAttribute(a.TRANSLATION,L),a.ROTATION&&T.fromBufferAttribute(a.ROTATION,L),a.SCALE&&E.fromBufferAttribute(a.SCALE,L),w.setMatrixAt(L,_.compose(A,T,E));for(const L in a)if(L==="_COLOR_0"){const b=a[L];w.instanceColor=new u.InstancedBufferAttribute(b.array,b.itemSize,b.normalized)}else L!=="TRANSLATION"&&L!=="ROTATION"&&L!=="SCALE"&&g.geometry.setAttribute(L,a[L]);u.Object3D.prototype.copy.call(w,g),this.parser.assignFinalMaterial(w),p.push(w)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const ne="glTF",k=12,J={JSON:1313821514,BIN:5130562};class Pe{constructor(t){this.name=R.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,k),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==ne)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-k,i=new DataView(t,k);let s=0;for(;s<n;){const o=i.getUint32(s,!0);s+=4;const a=i.getUint32(s,!0);if(s+=4,a===J.JSON){const l=new Uint8Array(t,k+s,o);this.content=r.decode(l)}else if(a===J.BIN){const l=k+s;this.body=t.slice(l,l+o)}s+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class De{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=R.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const r=this.json,n=this.dracoLoader,i=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,o={},a={},l={};for(const h in s){const d=q[h]||h.toLowerCase();o[d]=s[h]}for(const h in t.attributes){const d=q[h]||h.toLowerCase();if(s[h]!==void 0){const f=r.accessors[t.attributes[h]],p=P[f.componentType];l[d]=p.name,a[d]=f.normalized===!0}}return e.getDependency("bufferView",i).then(function(h){return new Promise(function(d,f){n.decodeDracoFile(h,function(p){for(const g in p.attributes){const _=p.attributes[g],A=a[g];A!==void 0&&(_.normalized=A)}d(p)},o,l,u.LinearSRGBColorSpace,f)})})}}class ke{constructor(){this.name=R.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Fe{constructor(){this.name=R.KHR_MESH_QUANTIZATION}}class se extends u.Interpolant{constructor(t,e,r,n){super(t,e,r,n)}copySampleValue_(t){const e=this.resultBuffer,r=this.sampleValues,n=this.valueSize,i=t*n*3+n;for(let s=0;s!==n;s++)e[s]=r[i+s];return e}interpolate_(t,e,r,n){const i=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,l=o*3,h=n-e,d=(r-e)/h,f=d*d,p=f*d,g=t*l,_=g-l,A=-2*p+3*f,T=p-f,E=1-A,w=T-f+d;for(let L=0;L!==o;L++){const b=s[_+L+o],C=s[_+L+a]*h,S=s[g+L+o],D=s[g+L]*h;i[L]=E*b+w*C+A*S+T*D}return i}}const Be=new u.Quaternion;class He extends se{interpolate_(t,e,r,n){const i=super.interpolate_(t,e,r,n);return Be.fromArray(i).normalize().toArray(i),i}}const x={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},P={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Z={9728:u.NearestFilter,9729:u.LinearFilter,9984:u.NearestMipmapNearestFilter,9985:u.LinearMipmapNearestFilter,9986:u.NearestMipmapLinearFilter,9987:u.LinearMipmapLinearFilter},ee={33071:u.ClampToEdgeWrapping,33648:u.MirroredRepeatWrapping,10497:u.RepeatWrapping},K={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},q={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},O={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ge={CUBICSPLINE:void 0,LINEAR:u.InterpolateLinear,STEP:u.InterpolateDiscrete},V={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ue(c){return c.DefaultMaterial===void 0&&(c.DefaultMaterial=new u.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:u.FrontSide})),c.DefaultMaterial}function I(c,t,e){for(const r in e.extensions)c[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=e.extensions[r])}function M(c,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(c.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function je(c,t,e){let r=!1,n=!1,i=!1;for(let l=0,h=t.length;l<h;l++){const d=t[l];if(d.POSITION!==void 0&&(r=!0),d.NORMAL!==void 0&&(n=!0),d.COLOR_0!==void 0&&(i=!0),r&&n&&i)break}if(!r&&!n&&!i)return Promise.resolve(c);const s=[],o=[],a=[];for(let l=0,h=t.length;l<h;l++){const d=t[l];if(r){const f=d.POSITION!==void 0?e.getDependency("accessor",d.POSITION):c.attributes.position;s.push(f)}if(n){const f=d.NORMAL!==void 0?e.getDependency("accessor",d.NORMAL):c.attributes.normal;o.push(f)}if(i){const f=d.COLOR_0!==void 0?e.getDependency("accessor",d.COLOR_0):c.attributes.color;a.push(f)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a)]).then(function(l){const h=l[0],d=l[1],f=l[2];return r&&(c.morphAttributes.position=h),n&&(c.morphAttributes.normal=d),i&&(c.morphAttributes.color=f),c.morphTargetsRelative=!0,c})}function Ke(c,t){if(c.updateMorphTargets(),t.weights!==void 0)for(let e=0,r=t.weights.length;e<r;e++)c.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(c.morphTargetInfluences.length===e.length){c.morphTargetDictionary={};for(let r=0,n=e.length;r<n;r++)c.morphTargetDictionary[e[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Ve(c){let t;const e=c.extensions&&c.extensions[R.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+z(e.attributes):t=c.indices+":"+z(c.attributes)+":"+c.mode,c.targets!==void 0)for(let r=0,n=c.targets.length;r<n;r++)t+=":"+z(c.targets[r]);return t}function z(c){let t="";const e=Object.keys(c).sort();for(let r=0,n=e.length;r<n;r++)t+=e[r]+":"+c[e[r]]+";";return t}function Y(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 ze(c){return c.search(/\.jpe?g($|\?)/i)>0||c.search(/^data\:image\/jpeg/)===0?"image/jpeg":c.search(/\.webp($|\?)/i)>0||c.search(/^data\:image\/webp/)===0?"image/webp":c.search(/\.ktx2($|\?)/i)>0||c.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Xe=new u.Matrix4;class We{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new me,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,n=-1,i=!1,s=-1;if(typeof navigator<"u"){const o=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(o)===!0;const a=o.match(/Version\/(\d+)/);n=r&&a?parseInt(a[1],10):-1,i=o.indexOf("Firefox")>-1,s=i?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&n<17||i&&s<98?this.textureLoader=new u.TextureLoader(this.options.manager):this.textureLoader=new u.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new u.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const r=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(s){const o={scene:s[0][n.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:n.asset,parser:r,userData:{}};return I(i,o,n),M(o,n),Promise.all(r._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(const a of o.scenes)a.updateMatrixWorld();t(o)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],r=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const s=e[n].joints;for(let o=0,a=s.length;o<a;o++)t[s[o]].isBone=!0}for(let n=0,i=t.length;n<i;n++){const s=t[n];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(r[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,r){if(t.refs[e]<=1)return r;const n=r.clone(),i=(s,o)=>{const a=this.associations.get(s);a!=null&&this.associations.set(o,a);for(const[l,h]of s.children.entries())i(h,o.children[l])};return i(r,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let r=0;r<e.length;r++){const n=t(e[r]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const r=[];for(let n=0;n<e.length;n++){const i=t(e[n]);i&&r.push(i)}return r}getDependency(t,e){const r=t+":"+e;let n=this.cache.get(r);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t);break}this.cache.add(r,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const r=this,n=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(i,s){return r.getDependency(t,s)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],r=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[R.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,s){r.load(u.LoaderUtils.resolveURL(e.uri,n.path),i,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(r){const n=e.byteLength||0,i=e.byteOffset||0;return r.slice(i,i+n)})}loadAccessor(t){const e=this,r=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){const s=K[n.type],o=P[n.componentType],a=n.normalized===!0,l=new o(n.count*s);return Promise.resolve(new u.BufferAttribute(l,s,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(s){const o=s[0],a=K[n.type],l=P[n.componentType],h=l.BYTES_PER_ELEMENT,d=h*a,f=n.byteOffset||0,p=n.bufferView!==void 0?r.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let _,A;if(p&&p!==d){const T=Math.floor(f/p),E="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+T+":"+n.count;let w=e.cache.get(E);w||(_=new l(o,T*p,n.count*p/h),w=new u.InterleavedBuffer(_,p/h),e.cache.add(E,w)),A=new u.InterleavedBufferAttribute(w,a,f%p/h,g)}else o===null?_=new l(n.count*a):_=new l(o,f,n.count*a),A=new u.BufferAttribute(_,a,g);if(n.sparse!==void 0){const T=K.SCALAR,E=P[n.sparse.indices.componentType],w=n.sparse.indices.byteOffset||0,L=n.sparse.values.byteOffset||0,b=new E(s[1],w,n.sparse.count*T),C=new l(s[2],L,n.sparse.count*a);o!==null&&(A=new u.BufferAttribute(A.array.slice(),A.itemSize,A.normalized)),A.normalized=!1;for(let S=0,D=b.length;S<D;S++){const v=b[S];if(A.setX(v,C[S*a]),a>=2&&A.setY(v,C[S*a+1]),a>=3&&A.setZ(v,C[S*a+2]),a>=4&&A.setW(v,C[S*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}A.normalized=g}return A})}loadTexture(t){const e=this.json,r=this.options,i=e.textures[t].source,s=e.images[i];let o=this.textureLoader;if(s.uri){const a=r.manager.getHandler(s.uri);a!==null&&(o=a)}return this.loadTextureImage(t,i,o)}loadTextureImage(t,e,r){const n=this,i=this.json,s=i.textures[t],o=i.images[e],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(e,r).then(function(h){h.flipY=!1,h.name=s.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const f=(i.samplers||{})[s.sampler]||{};return h.magFilter=Z[f.magFilter]||u.LinearFilter,h.minFilter=Z[f.minFilter]||u.LinearMipmapLinearFilter,h.wrapS=ee[f.wrapS]||u.RepeatWrapping,h.wrapT=ee[f.wrapT]||u.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==u.NearestFilter&&h.minFilter!==u.LinearFilter,n.associations.set(h,{textures:t}),h}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(t,e){const r=this,n=this.json,i=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(d=>d.clone());const s=n.images[t],o=self.URL||self.webkitURL;let a=s.uri||"",l=!1;if(s.bufferView!==void 0)a=r.getDependency("bufferView",s.bufferView).then(function(d){l=!0;const f=new Blob([d],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(a).then(function(d){return new Promise(function(f,p){let g=f;e.isImageBitmapLoader===!0&&(g=function(_){const A=new u.Texture(_);A.needsUpdate=!0,f(A)}),e.load(u.LoaderUtils.resolveURL(d,i.path),g,void 0,p)})}).then(function(d){return l===!0&&o.revokeObjectURL(a),M(d,s),d.userData.mimeType=s.mimeType||ze(s.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),d});return this.sourceCache[t]=h,h}assignTexture(t,e,r,n){const i=this;return this.getDependency("texture",r.index).then(function(s){if(!s)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(s=s.clone(),s.channel=r.texCoord),i.extensions[R.KHR_TEXTURE_TRANSFORM]){const o=r.extensions!==void 0?r.extensions[R.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const a=i.associations.get(s);s=i.extensions[R.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),i.associations.set(s,a)}}return n!==void 0&&(s.colorSpace=n),t[e]=s,s})}assignFinalMaterial(t){const e=t.geometry;let r=t.material;const n=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,s=e.attributes.normal===void 0;if(t.isPoints){const o="PointsMaterial:"+r.uuid;let a=this.cache.get(o);a||(a=new u.PointsMaterial,u.Material.prototype.copy.call(a,r),a.color.copy(r.color),a.map=r.map,a.sizeAttenuation=!1,this.cache.add(o,a)),r=a}else if(t.isLine){const o="LineBasicMaterial:"+r.uuid;let a=this.cache.get(o);a||(a=new u.LineBasicMaterial,u.Material.prototype.copy.call(a,r),a.color.copy(r.color),a.map=r.map,this.cache.add(o,a)),r=a}if(n||i||s){let o="ClonedMaterial:"+r.uuid+":";n&&(o+="derivative-tangents:"),i&&(o+="vertex-colors:"),s&&(o+="flat-shading:");let a=this.cache.get(o);a||(a=r.clone(),i&&(a.vertexColors=!0),s&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(o,a),this.associations.set(a,this.associations.get(r))),r=a}t.material=r}getMaterialType(){return u.MeshStandardMaterial}loadMaterial(t){const e=this,r=this.json,n=this.extensions,i=r.materials[t];let s;const o={},a=i.extensions||{},l=[];if(a[R.KHR_MATERIALS_UNLIT]){const d=n[R.KHR_MATERIALS_UNLIT];s=d.getMaterialType(),l.push(d.extendParams(o,i,e))}else{const d=i.pbrMetallicRoughness||{};if(o.color=new u.Color(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const f=d.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],u.LinearSRGBColorSpace),o.opacity=f[3]}d.baseColorTexture!==void 0&&l.push(e.assignTexture(o,"map",d.baseColorTexture,u.SRGBColorSpace)),o.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,o.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(l.push(e.assignTexture(o,"metalnessMap",d.metallicRoughnessTexture)),l.push(e.assignTexture(o,"roughnessMap",d.metallicRoughnessTexture))),s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,o)})))}i.doubleSided===!0&&(o.side=u.DoubleSide);const h=i.alphaMode||V.OPAQUE;if(h===V.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===V.MASK&&(o.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&s!==u.MeshBasicMaterial&&(l.push(e.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new u.Vector2(1,1),i.normalTexture.scale!==void 0)){const d=i.normalTexture.scale;o.normalScale.set(d,d)}if(i.occlusionTexture!==void 0&&s!==u.MeshBasicMaterial&&(l.push(e.assignTexture(o,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&s!==u.MeshBasicMaterial){const d=i.emissiveFactor;o.emissive=new u.Color().setRGB(d[0],d[1],d[2],u.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&s!==u.MeshBasicMaterial&&l.push(e.assignTexture(o,"emissiveMap",i.emissiveTexture,u.SRGBColorSpace)),Promise.all(l).then(function(){const d=new s(o);return i.name&&(d.name=i.name),M(d,i),e.associations.set(d,{materials:t}),i.extensions&&I(n,d,i),d})}createUniqueName(t){const e=u.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,r=this.extensions,n=this.primitiveCache;function i(o){return r[R.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,e).then(function(a){return te(a,o,e)})}const s=[];for(let o=0,a=t.length;o<a;o++){const l=t[o],h=Ve(l),d=n[h];if(d)s.push(d.promise);else{let f;l.extensions&&l.extensions[R.KHR_DRACO_MESH_COMPRESSION]?f=i(l):f=te(new u.BufferGeometry,l,e),n[h]={primitive:l,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(t){const e=this,r=this.json,n=this.extensions,i=r.meshes[t],s=i.primitives,o=[];for(let a=0,l=s.length;a<l;a++){const h=s[a].material===void 0?Ue(this.cache):this.getDependency("material",s[a].material);o.push(h)}return o.push(e.loadGeometries(s)),Promise.all(o).then(function(a){const l=a.slice(0,a.length-1),h=a[a.length-1],d=[];for(let p=0,g=h.length;p<g;p++){const _=h[p],A=s[p];let T;const E=l[p];if(A.mode===x.TRIANGLES||A.mode===x.TRIANGLE_STRIP||A.mode===x.TRIANGLE_FAN||A.mode===void 0)T=i.isSkinnedMesh===!0?new u.SkinnedMesh(_,E):new u.Mesh(_,E),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),A.mode===x.TRIANGLE_STRIP?T.geometry=Q(T.geometry,u.TriangleStripDrawMode):A.mode===x.TRIANGLE_FAN&&(T.geometry=Q(T.geometry,u.TriangleFanDrawMode));else if(A.mode===x.LINES)T=new u.LineSegments(_,E);else if(A.mode===x.LINE_STRIP)T=new u.Line(_,E);else if(A.mode===x.LINE_LOOP)T=new u.LineLoop(_,E);else if(A.mode===x.POINTS)T=new u.Points(_,E);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(T.geometry.morphAttributes).length>0&&Ke(T,i),T.name=e.createUniqueName(i.name||"mesh_"+t),M(T,i),A.extensions&&I(n,T,A),e.assignFinalMaterial(T),d.push(T)}for(let p=0,g=d.length;p<g;p++)e.associations.set(d[p],{meshes:t,primitives:p});if(d.length===1)return i.extensions&&I(n,d[0],i),d[0];const f=new u.Group;i.extensions&&I(n,f,i),e.associations.set(f,{meshes:t});for(let p=0,g=d.length;p<g;p++)f.add(d[p]);return f})}loadCamera(t){let e;const r=this.json.cameras[t],n=r[r.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?e=new u.PerspectiveCamera(u.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):r.type==="orthographic"&&(e=new u.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(e.name=this.createUniqueName(r.name)),M(e,r),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],r=[];for(let n=0,i=e.joints.length;n<i;n++)r.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",e.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(n){const i=n.pop(),s=n,o=[],a=[];for(let l=0,h=s.length;l<h;l++){const d=s[l];if(d){o.push(d);const f=new u.Matrix4;i!==null&&f.fromArray(i.array,l*16),a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[l])}return new u.Skeleton(o,a)})}loadAnimation(t){const e=this.json,r=this,n=e.animations[t],i=n.name?n.name:"animation_"+t,s=[],o=[],a=[],l=[],h=[];for(let d=0,f=n.channels.length;d<f;d++){const p=n.channels[d],g=n.samplers[p.sampler],_=p.target,A=_.node,T=n.parameters!==void 0?n.parameters[g.input]:g.input,E=n.parameters!==void 0?n.parameters[g.output]:g.output;_.node!==void 0&&(s.push(this.getDependency("node",A)),o.push(this.getDependency("accessor",T)),a.push(this.getDependency("accessor",E)),l.push(g),h.push(_))}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(h)]).then(function(d){const f=d[0],p=d[1],g=d[2],_=d[3],A=d[4],T=[];for(let E=0,w=f.length;E<w;E++){const L=f[E],b=p[E],C=g[E],S=_[E],D=A[E];if(L===void 0)continue;L.updateMatrix&&L.updateMatrix();const v=r._createAnimationTracks(L,b,C,S,D);if(v)for(let j=0;j<v.length;j++)T.push(v[j])}return new u.AnimationClip(i,void 0,T)})}createNodeMesh(t){const e=this.json,r=this,n=e.nodes[t];return n.mesh===void 0?null:r.getDependency("mesh",n.mesh).then(function(i){const s=r._getNodeRef(r.meshCache,n.mesh,i);return n.weights!==void 0&&s.traverse(function(o){if(o.isMesh)for(let a=0,l=n.weights.length;a<l;a++)o.morphTargetInfluences[a]=n.weights[a]}),s})}loadNode(t){const e=this.json,r=this,n=e.nodes[t],i=r._loadNodeShallow(t),s=[],o=n.children||[];for(let l=0,h=o.length;l<h;l++)s.push(r.getDependency("node",o[l]));const a=n.skin===void 0?Promise.resolve(null):r.getDependency("skin",n.skin);return Promise.all([i,Promise.all(s),a]).then(function(l){const h=l[0],d=l[1],f=l[2];f!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(f,Xe)});for(let p=0,g=d.length;p<g;p++)h.add(d[p]);return h})}_loadNodeShallow(t){const e=this.json,r=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const i=e.nodes[t],s=i.name?n.createUniqueName(i.name):"",o=[],a=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(t)});return a&&o.push(a),i.camera!==void 0&&o.push(n.getDependency("camera",i.camera).then(function(l){return n._getNodeRef(n.cameraCache,i.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(t)}).forEach(function(l){o.push(l)}),this.nodeCache[t]=Promise.all(o).then(function(l){let h;if(i.isBone===!0?h=new u.Bone:l.length>1?h=new u.Group:l.length===1?h=l[0]:h=new u.Object3D,h!==l[0])for(let d=0,f=l.length;d<f;d++)h.add(l[d]);if(i.name&&(h.userData.name=i.name,h.name=s),M(h,i),i.extensions&&I(r,h,i),i.matrix!==void 0){const d=new u.Matrix4;d.fromArray(i.matrix),h.applyMatrix4(d)}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=t,h}),this.nodeCache[t]}loadScene(t){const e=this.extensions,r=this.json.scenes[t],n=this,i=new u.Group;r.name&&(i.name=n.createUniqueName(r.name)),M(i,r),r.extensions&&I(e,i,r);const s=r.nodes||[],o=[];for(let a=0,l=s.length;a<l;a++)o.push(n.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let h=0,d=a.length;h<d;h++)i.add(a[h]);const l=h=>{const d=new Map;for(const[f,p]of n.associations)(f instanceof u.Material||f instanceof u.Texture)&&d.set(f,p);return h.traverse(f=>{const p=n.associations.get(f);p!=null&&d.set(f,p)}),d};return n.associations=l(i),i})}_createAnimationTracks(t,e,r,n,i){const s=[],o=t.name?t.name:t.uuid,a=[];O[i.path]===O.weights?t.traverse(function(f){f.morphTargetInfluences&&a.push(f.name?f.name:f.uuid)}):a.push(o);let l;switch(O[i.path]){case O.weights:l=u.NumberKeyframeTrack;break;case O.rotation:l=u.QuaternionKeyframeTrack;break;case O.position:case O.scale:l=u.VectorKeyframeTrack;break;default:switch(r.itemSize){case 1:l=u.NumberKeyframeTrack;break;case 2:case 3:default:l=u.VectorKeyframeTrack;break}break}const h=n.interpolation!==void 0?Ge[n.interpolation]:u.InterpolateLinear,d=this._getArrayFromAccessor(r);for(let f=0,p=a.length;f<p;f++){const g=new l(a[f]+"."+O[i.path],e.array,d,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),s.push(g)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const r=Y(e.constructor),n=new Float32Array(e.length);for(let i=0,s=e.length;i<s;i++)n[i]=e[i]*r;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(r){const n=this instanceof u.QuaternionKeyframeTrack?He:se;return new n(this.times,this.values,this.getValueSize()/3,r)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function $e(c,t,e){const r=t.attributes,n=new u.Box3;if(r.POSITION!==void 0){const o=e.json.accessors[r.POSITION],a=o.min,l=o.max;if(a!==void 0&&l!==void 0){if(n.set(new u.Vector3(a[0],a[1],a[2]),new u.Vector3(l[0],l[1],l[2])),o.normalized){const h=Y(P[o.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=t.targets;if(i!==void 0){const o=new u.Vector3,a=new u.Vector3;for(let l=0,h=i.length;l<h;l++){const d=i[l];if(d.POSITION!==void 0){const f=e.json.accessors[d.POSITION],p=f.min,g=f.max;if(p!==void 0&&g!==void 0){if(a.setX(Math.max(Math.abs(p[0]),Math.abs(g[0]))),a.setY(Math.max(Math.abs(p[1]),Math.abs(g[1]))),a.setZ(Math.max(Math.abs(p[2]),Math.abs(g[2]))),f.normalized){const _=Y(P[f.componentType]);a.multiplyScalar(_)}o.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(o)}c.boundingBox=n;const s=new u.Sphere;n.getCenter(s.center),s.radius=n.min.distanceTo(n.max)/2,c.boundingSphere=s}function te(c,t,e){const r=t.attributes,n=[];function i(s,o){return e.getDependency("accessor",s).then(function(a){c.setAttribute(o,a)})}for(const s in r){const o=q[s]||s.toLowerCase();o in c.attributes||n.push(i(r[s],o))}if(t.indices!==void 0&&!c.index){const s=e.getDependency("accessor",t.indices).then(function(o){c.setIndex(o)});n.push(s)}return u.ColorManagement.workingColorSpace!==u.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${u.ColorManagement.workingColorSpace}" not supported.`),M(c,t),$e(c,t,e),Promise.all(n).then(function(){return t.targets!==void 0?je(c,t.targets,e):c})}const X=new WeakMap;class qe extends u.Loader{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,r,n){const i=new u.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(t,s=>{this.parse(s,e,n)},r,n)}parse(t,e,r=()=>{}){this.decodeDracoFile(t,e,null,null,u.SRGBColorSpace,r).catch(r)}decodeDracoFile(t,e,r,n,i=u.LinearSRGBColorSpace,s=()=>{}){const o={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:i};return this.decodeGeometry(t,o).then(e).catch(s)}decodeGeometry(t,e){const r=JSON.stringify(e);if(X.has(t)){const a=X.get(t);if(a.key===r)return a.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const i=this.workerNextTaskID++,s=t.byteLength,o=this._getWorker(i,s).then(a=>(n=a,new Promise((l,h)=>{n._callbacks[i]={resolve:l,reject:h},n.postMessage({type:"decode",id:i,taskConfig:e,buffer:t},[t])}))).then(a=>this._createGeometry(a.geometry));return o.catch(()=>!0).then(()=>{n&&i&&this._releaseTask(n,i)}),X.set(t,{key:r,promise:o}),o}_createGeometry(t){const e=new u.BufferGeometry;t.index&&e.setIndex(new u.BufferAttribute(t.index.array,1));for(let r=0;r<t.attributes.length;r++){const n=t.attributes[r],i=n.name,s=n.array,o=n.itemSize,a=new u.BufferAttribute(s,o);i==="color"&&(this._assignVertexColorSpace(a,n.vertexColorSpace),a.normalized=!(s instanceof Float32Array)),e.setAttribute(i,a)}return e}_assignVertexColorSpace(t,e){if(e!==u.SRGBColorSpace)return;const r=new u.Color;for(let n=0,i=t.count;n<i;n++)r.fromBufferAttribute(t,n),u.ColorManagement.toWorkingColorSpace(r,u.SRGBColorSpace),t.setXYZ(n,r.r,r.g,r.b)}_loadLibrary(t,e){const r=new u.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(e),r.setWithCredentials(this.withCredentials),new Promise((n,i)=>{r.load(t,n,void 0,i)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(r=>{const n=r[0];t||(this.decoderConfig.wasmBinary=r[1]);const i=Ye.toString(),s=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
|
|
2
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(i){const s=i.data;switch(s.type){case"decode":n._callbacks[s.id].resolve(s);break;case"error":n._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,i){return n._taskLoad>i._taskLoad?-1:1});const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[t]=e,r._taskLoad+=e,r})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Ye(){let c,t;onmessage=function(s){const o=s.data;switch(o.type){case"init":c=o.decoderConfig,t=new Promise(function(h){c.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(c)});break;case"decode":const a=o.buffer,l=o.taskConfig;t.then(h=>{const d=h.draco,f=new d.Decoder;try{const p=e(d,f,new Int8Array(a),l),g=p.attributes.map(_=>_.array.buffer);p.index&&g.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},g)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{d.destroy(f)}});break}};function e(s,o,a,l){const h=l.attributeIDs,d=l.attributeTypes;let f,p;const g=o.GetEncodedGeometryType(a);if(g===s.TRIANGULAR_MESH)f=new s.Mesh,p=o.DecodeArrayToMesh(a,a.byteLength,f);else if(g===s.POINT_CLOUD)f=new s.PointCloud,p=o.DecodeArrayToPointCloud(a,a.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const _={index:null,attributes:[]};for(const A in h){const T=self[d[A]];let E,w;if(l.useUniqueIDs)w=h[A],E=o.GetAttributeByUniqueId(f,w);else{if(w=o.GetAttributeId(f,s[h[A]]),w===-1)continue;E=o.GetAttribute(f,w)}const L=n(s,o,f,A,T,E);A==="color"&&(L.vertexColorSpace=l.vertexColorSpace),_.attributes.push(L)}return g===s.TRIANGULAR_MESH&&(_.index=r(s,o,f)),s.destroy(f),_}function r(s,o,a){const h=a.num_faces()*3,d=h*4,f=s._malloc(d);o.GetTrianglesUInt32Array(a,d,f);const p=new Uint32Array(s.HEAPF32.buffer,f,h).slice();return s._free(f),{array:p,itemSize:1}}function n(s,o,a,l,h,d){const f=d.num_components(),g=a.num_points()*f,_=g*h.BYTES_PER_ELEMENT,A=i(s,h),T=s._malloc(_);o.GetAttributeDataArrayForAllPoints(a,d,A,_,T);const E=new h(s.HEAPF32.buffer,T,g).slice();return s._free(T),{name:l,array:E,itemSize:f}}function i(s,o){switch(o){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}var Qe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Ze=(c,t,e,r)=>{for(var n=r>1?void 0:r?Je(t,e):t,i=c.length-1,s;i>=0;i--)(s=c[i])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&Qe(t,e,n),n};let B=class{constructor(){y(this,"loadingManager",new u.LoadingManager);y(this,"loaders",{});y(this,"sources",[]);y(this,"loadedResources",{});y(this,"toLoadCount",0);y(this,"loadedCount",0)}get videoLoader(){return{load:(c,t)=>{const e=document.createElement("video");e.muted=!0,e.loop=!0,e.controls=!1,e.playsInline=!0,e.src=c,e.autoplay=!0;const r=()=>{if(!e)return;e.play();const n=new u.VideoTexture(e),i=n.dispose.bind(n);n.dispose=()=>{var s;(s=n.image)==null||s.remove(),i()},t(n),e.removeEventListener("canplaythrough",r)};e.addEventListener("canplaythrough",r)}}}_initLoaders(){this.loaders.gltfLoader=new pe(this.loadingManager),this.loaders.textureLoader=new u.ImageBitmapLoader(this.loadingManager),this.loaders.cubeTextureLoader=new u.CubeTextureLoader(this.loadingManager),this.loaders.audioLoader=new u.AudioLoader(this.loadingManager),this.loaders.dracoLoader=new qe(this.loadingManager),this.loaders.videoLoader=this.videoLoader}_initSources(c){this.sources=c,this.toLoadCount=this.sources.length,this.loadedCount=0}init(c=[]){this._initLoaders(),this._initSources(c)}setDracoDecoder(c){var t;this.loaders.dracoLoader&&(this.loaders.dracoLoader.setDecoderPath(c??"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),(t=this.loaders.gltfLoader)==null||t.setDRACOLoader(this.loaders.dracoLoader))}handleLoad({source:c,resource:t,toLoadCount:e,loadedCount:r}){t&&(this.loadedResources[c.name]=t,this.loadedCount=r,this.toLoadCount=e)}};B=Ze([m.singleton()],B);var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(c,t,e,r)=>{for(var n=r>1?void 0:r?tt(t,e):t,i=c.length-1,s;i>=0;i--)(s=c[i])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&et(t,e,n),n},st=(c,t)=>(e,r)=>t(e,r,c);let H=class{constructor(c){y(this,"load$$",new m.Subject);y(this,"load$",this.load$$.pipe(m.map(c=>({...c,loadedCount:c.resource?this._service.loadedCount+1:this._service.loadedCount,toLoadCount:this._service.toLoadCount})),m.share()));y(this,"serializedLoad$",this.load$.pipe(m.map(c=>{var e;let t=c.resource;if((e=c==null?void 0:c.resource)!=null&&e.parser){const r=c.resource;t={
|
|
1
|
+
"use strict";var re=Object.defineProperty;var ie=(c,t,e)=>t in c?re(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var y=(c,t,e)=>ie(c,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./app.module-BQotCgts.js"),u=require("three");class U{constructor(){y(this,"location");y(this,"initOnConstruct");y(this,"canvas");y(this,"fullScreen");y(this,"defaultCamera");y(this,"startTimer");y(this,"loaderDataSources",[]);y(this,"loadResourcesOnInit");y(this,"enableDebug");y(this,"axesSizes");y(this,"gridSizes");y(this,"withMiniCamera");y(this,"onReady")}}class oe{constructor(){y(this,"onReady")}}var ae=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,le=(c,t,e,r)=>{for(var n=r>1?void 0:r?ce(t,e):t,i=c.length-1,s;i>=0;i--)(s=c[i])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&ae(t,e,n),n};let F=class{constructor(){y(this,"workerPool",m.C(void 0,!0));y(this,"canvas");y(this,"worker");y(this,"thread")}init(c){this.worker=c.worker,this.thread=c.thread}};F=le([m.singleton()],F);var ue=Object.defineProperty,de=Object.getOwnPropertyDescriptor,he=(c,t,e,r)=>{for(var n=r>1?void 0:r?de(t,e):t,i=c.length-1,s;i>=0;i--)(s=c[i])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&ue(t,e,n),n},fe=(c,t)=>(e,r)=>t(e,r,c);let $=class extends m.ProxyEventHandlersBlueprint{constructor(t){super();y(this,"canvas");this._service=t}init(t){this.canvas=t;for(const e of m.PROXY_EVENT_LISTENERS){const r=e.startsWith("mouse")||e.startsWith("pointer")||e.startsWith("touch")?this.mouseEventHandler:e.startsWith("key")?this.keyEventHandler:e==="resize"?this.uiEventHandler:e==="wheel"?this.wheelEventHandler:this.preventDefaultHandler;this[`${e}$`]=m.fromEvent(e==="resize"?window:t,e).pipe(m.map(r.bind(this)),m.filter(n=>!(e==="keydown"&&!n))),this[`${e}$`].subscribe(n=>{var i,s;(s=(i=this._service.thread)==null?void 0:i[e])==null||s.call(i,n)})}}preventDefaultHandler(t){return t.preventDefault(),{type:t.type}}getScreenSizes(){return{width:this.canvas.width,height:this.canvas.height,windowWidth:(window==null?void 0:window.innerWidth)??0,windowHeight:(window==null?void 0:window.innerHeight)??0}}uiEventHandler(t){const e=this.canvas.getBoundingClientRect();return{...this.getScreenSizes(),type:t.type,top:e.top,left:e.left}}mouseEventHandler(t){return{...this.getScreenSizes(),...m.J(t,["ctrlKey","metaKey","shiftKey","button","pointerType","clientX","clientY","pageX","pageY"])}}touchEventHandler(t){const e=[],r={type:t.type,touches:e};for(let n=0;n<t.touches.length;++n){const i=t.touches[n];e.push({pageX:(i==null?void 0:i.pageX)??0,pageY:(i==null?void 0:i.pageY)??0})}return{...this.getScreenSizes(),...r}}wheelEventHandler(t){return t.preventDefault(),{...this.getScreenSizes(),...m.J(t,["deltaX","deltaY"])}}keyEventHandler(t){if(m.KEYBOARD_EVENT_CODES.includes(t.code))return t.preventDefault(),{...this.getScreenSizes(),...m.J(t,["ctrlKey","metaKey","shiftKey","keyCode"])}}};$=he([m.singleton(),fe(0,m.inject(F))],$);function Q(c,t){if(t===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),c;if(t===u.TriangleFanDrawMode||t===u.TriangleStripDrawMode){let e=c.getIndex();if(e===null){const s=[],o=c.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);c.setIndex(s),e=c.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),c}const r=e.count-2,n=[];if(t===u.TriangleFanDrawMode)for(let s=1;s<=r;s++)n.push(e.getX(0)),n.push(e.getX(s)),n.push(e.getX(s+1));else for(let s=0;s<r;s++)s%2===0?(n.push(e.getX(s)),n.push(e.getX(s+1)),n.push(e.getX(s+2))):(n.push(e.getX(s+2)),n.push(e.getX(s+1)),n.push(e.getX(s)));n.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=c.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),c}class pe extends u.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new _e(e)}),this.register(function(e){return new Re(e)}),this.register(function(e){return new Ce(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new Le(e)}),this.register(function(e){return new ye(e)}),this.register(function(e){return new we(e)}),this.register(function(e){return new xe(e)}),this.register(function(e){return new Te(e)}),this.register(function(e){return new Se(e)}),this.register(function(e){return new Ee(e)}),this.register(function(e){return new Me(e)}),this.register(function(e){return new be(e)}),this.register(function(e){return new ge(e)}),this.register(function(e){return new Ie(e)}),this.register(function(e){return new Ne(e)})}load(t,e,r,n){const i=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const l=u.LoaderUtils.extractUrlBase(t);s=u.LoaderUtils.resolveURL(l,this.path)}else s=u.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const o=function(l){n?n(l):console.error(l),i.manager.itemError(t),i.manager.itemEnd(t)},a=new u.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(l){try{i.parse(l,s,function(h){e(h),i.manager.itemEnd(t)},o)}catch(h){o(h)}},r,o)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,r,n){let i;const s={},o={},a=new TextDecoder;if(typeof t=="string")i=JSON.parse(t);else if(t instanceof ArrayBuffer)if(a.decode(new Uint8Array(t,0,4))===ne){try{s[R.KHR_BINARY_GLTF]=new Pe(t)}catch(d){n&&n(d);return}i=JSON.parse(s[R.KHR_BINARY_GLTF].content)}else i=JSON.parse(a.decode(t));else i=t;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new We(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](l);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[d.name]=d,s[d.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const d=i.extensionsUsed[h],f=i.extensionsRequired||[];switch(d){case R.KHR_MATERIALS_UNLIT:s[d]=new Ae;break;case R.KHR_DRACO_MESH_COMPRESSION:s[d]=new De(i,this.dracoLoader);break;case R.KHR_TEXTURE_TRANSFORM:s[d]=new ke;break;case R.KHR_MESH_QUANTIZATION:s[d]=new Fe;break;default:f.indexOf(d)>=0&&o[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(r,n)}parseAsync(t,e){const r=this;return new Promise(function(n,i){r.parse(t,e,n,i)})}}function me(){let c={};return{get:function(t){return c[t]},add:function(t,e){c[t]=e},remove:function(t){delete c[t]},removeAll:function(){c={}}}}const R={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 ge{constructor(t){this.parser=t,this.name=R.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let r=0,n=e.length;r<n;r++){const i=e[r];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,r="light:"+t;let n=e.cache.get(r);if(n)return n;const i=e.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let l;const h=new u.Color(16777215);a.color!==void 0&&h.setRGB(a.color[0],a.color[1],a.color[2],u.LinearSRGBColorSpace);const d=a.range!==void 0?a.range:0;switch(a.type){case"directional":l=new u.DirectionalLight(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new u.PointLight(h),l.distance=d;break;case"spot":l=new u.SpotLight(h),l.distance=d,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,M(l,a),a.intensity!==void 0&&(l.intensity=a.intensity),l.name=e.createUniqueName(a.name||"light_"+t),n=Promise.resolve(l),e.cache.add(r,n),n}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,r=this.parser,i=r.json.nodes[t],o=(i.extensions&&i.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(a){return r._getNodeRef(e.cache,o,a)})}}class Ae{constructor(){this.name=R.KHR_MATERIALS_UNLIT}getMaterialType(){return u.MeshBasicMaterial}extendParams(t,e,r){const n=[];t.color=new u.Color(1,1,1),t.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const s=i.baseColorFactor;t.color.setRGB(s[0],s[1],s[2],u.LinearSRGBColorSpace),t.opacity=s[3]}i.baseColorTexture!==void 0&&n.push(r.assignTexture(t,"map",i.baseColorTexture,u.SRGBColorSpace))}return Promise.all(n)}}class Te{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(e.emissiveIntensity=i),Promise.resolve()}}class _e{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&i.push(r.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&i.push(r.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(i.push(r.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const o=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new u.Vector2(o,o)}return Promise.all(i)}}class Re{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_DISPERSION}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Ee{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&i.push(r.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&i.push(r.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(i)}}class Le{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_SHEEN}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];e.sheenColor=new u.Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=n.extensions[this.name];if(s.sheenColorFactor!==void 0){const o=s.sheenColorFactor;e.sheenColor.setRGB(o[0],o[1],o[2],u.LinearSRGBColorSpace)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&i.push(r.assignTexture(e,"sheenColorMap",s.sheenColorTexture,u.SRGBColorSpace)),s.sheenRoughnessTexture!==void 0&&i.push(r.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class ye{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&i.push(r.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class we{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_VOLUME}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&i.push(r.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return e.attenuationColor=new u.Color().setRGB(o[0],o[1],o[2],u.LinearSRGBColorSpace),Promise.all(i)}}class xe{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_IOR}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Se{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_SPECULAR}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&i.push(r.assignTexture(e,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return e.specularColor=new u.Color().setRGB(o[0],o[1],o[2],u.LinearSRGBColorSpace),s.specularColorTexture!==void 0&&i.push(r.assignTexture(e,"specularColorMap",s.specularColorTexture,u.SRGBColorSpace)),Promise.all(i)}}class be{constructor(t){this.parser=t,this.name=R.EXT_MATERIALS_BUMP}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&i.push(r.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(i)}}class Me{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const r=this.parser.json.materials[t];return!r.extensions||!r.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],s=n.extensions[this.name];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&i.push(r.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(i)}}class Ce{constructor(t){this.parser=t,this.name=R.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,r=e.json,n=r.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,i.source,s)}}class ve{constructor(t){this.parser=t,this.name=R.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,r=this.parser,n=r.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const s=i.extensions[e],o=n.images[s.source];let a=r.textureLoader;if(o.uri){const l=r.options.manager.getHandler(o.uri);l!==null&&(a=l)}return this.detectSupport().then(function(l){if(l)return r.loadTextureImage(t,s.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Oe{constructor(t){this.parser=t,this.name=R.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,r=this.parser,n=r.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const s=i.extensions[e],o=n.images[s.source];let a=r.textureLoader;if(o.uri){const l=r.options.manager.getHandler(o.uri);l!==null&&(a=l)}return this.detectSupport().then(function(l){if(l)return r.loadTextureImage(t,s.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Ie{constructor(t){this.name=R.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,r=e.bufferViews[t];if(r.extensions&&r.extensions[this.name]){const n=r.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(o){const a=n.byteOffset||0,l=n.byteLength||0,h=n.count,d=n.byteStride,f=new Uint8Array(o,a,l);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(h,d,f,n.mode,n.filter).then(function(p){return p.buffer}):s.ready.then(function(){const p=new ArrayBuffer(h*d);return s.decodeGltfBuffer(new Uint8Array(p),h,d,f,n.mode,n.filter),p})})}else return null}}class Ne{constructor(t){this.name=R.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,r=e.nodes[t];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const n=e.meshes[r.mesh];for(const l of n.primitives)if(l.mode!==x.TRIANGLES&&l.mode!==x.TRIANGLE_STRIP&&l.mode!==x.TRIANGLE_FAN&&l.mode!==void 0)return null;const s=r.extensions[this.name].attributes,o=[],a={};for(const l in s)o.push(this.parser.getDependency("accessor",s[l]).then(h=>(a[l]=h,a[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(t)),Promise.all(o).then(l=>{const h=l.pop(),d=h.isGroup?h.children:[h],f=l[0].count,p=[];for(const g of d){const _=new u.Matrix4,A=new u.Vector3,T=new u.Quaternion,E=new u.Vector3(1,1,1),w=new u.InstancedMesh(g.geometry,g.material,f);for(let L=0;L<f;L++)a.TRANSLATION&&A.fromBufferAttribute(a.TRANSLATION,L),a.ROTATION&&T.fromBufferAttribute(a.ROTATION,L),a.SCALE&&E.fromBufferAttribute(a.SCALE,L),w.setMatrixAt(L,_.compose(A,T,E));for(const L in a)if(L==="_COLOR_0"){const b=a[L];w.instanceColor=new u.InstancedBufferAttribute(b.array,b.itemSize,b.normalized)}else L!=="TRANSLATION"&&L!=="ROTATION"&&L!=="SCALE"&&g.geometry.setAttribute(L,a[L]);u.Object3D.prototype.copy.call(w,g),this.parser.assignFinalMaterial(w),p.push(w)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const ne="glTF",k=12,J={JSON:1313821514,BIN:5130562};class Pe{constructor(t){this.name=R.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,k),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==ne)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-k,i=new DataView(t,k);let s=0;for(;s<n;){const o=i.getUint32(s,!0);s+=4;const a=i.getUint32(s,!0);if(s+=4,a===J.JSON){const l=new Uint8Array(t,k+s,o);this.content=r.decode(l)}else if(a===J.BIN){const l=k+s;this.body=t.slice(l,l+o)}s+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class De{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=R.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const r=this.json,n=this.dracoLoader,i=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,o={},a={},l={};for(const h in s){const d=q[h]||h.toLowerCase();o[d]=s[h]}for(const h in t.attributes){const d=q[h]||h.toLowerCase();if(s[h]!==void 0){const f=r.accessors[t.attributes[h]],p=P[f.componentType];l[d]=p.name,a[d]=f.normalized===!0}}return e.getDependency("bufferView",i).then(function(h){return new Promise(function(d,f){n.decodeDracoFile(h,function(p){for(const g in p.attributes){const _=p.attributes[g],A=a[g];A!==void 0&&(_.normalized=A)}d(p)},o,l,u.LinearSRGBColorSpace,f)})})}}class ke{constructor(){this.name=R.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Fe{constructor(){this.name=R.KHR_MESH_QUANTIZATION}}class se extends u.Interpolant{constructor(t,e,r,n){super(t,e,r,n)}copySampleValue_(t){const e=this.resultBuffer,r=this.sampleValues,n=this.valueSize,i=t*n*3+n;for(let s=0;s!==n;s++)e[s]=r[i+s];return e}interpolate_(t,e,r,n){const i=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,l=o*3,h=n-e,d=(r-e)/h,f=d*d,p=f*d,g=t*l,_=g-l,A=-2*p+3*f,T=p-f,E=1-A,w=T-f+d;for(let L=0;L!==o;L++){const b=s[_+L+o],C=s[_+L+a]*h,S=s[g+L+o],D=s[g+L]*h;i[L]=E*b+w*C+A*S+T*D}return i}}const Be=new u.Quaternion;class He extends se{interpolate_(t,e,r,n){const i=super.interpolate_(t,e,r,n);return Be.fromArray(i).normalize().toArray(i),i}}const x={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},P={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Z={9728:u.NearestFilter,9729:u.LinearFilter,9984:u.NearestMipmapNearestFilter,9985:u.LinearMipmapNearestFilter,9986:u.NearestMipmapLinearFilter,9987:u.LinearMipmapLinearFilter},ee={33071:u.ClampToEdgeWrapping,33648:u.MirroredRepeatWrapping,10497:u.RepeatWrapping},K={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},q={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},O={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ge={CUBICSPLINE:void 0,LINEAR:u.InterpolateLinear,STEP:u.InterpolateDiscrete},V={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ue(c){return c.DefaultMaterial===void 0&&(c.DefaultMaterial=new u.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:u.FrontSide})),c.DefaultMaterial}function I(c,t,e){for(const r in e.extensions)c[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=e.extensions[r])}function M(c,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(c.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function je(c,t,e){let r=!1,n=!1,i=!1;for(let l=0,h=t.length;l<h;l++){const d=t[l];if(d.POSITION!==void 0&&(r=!0),d.NORMAL!==void 0&&(n=!0),d.COLOR_0!==void 0&&(i=!0),r&&n&&i)break}if(!r&&!n&&!i)return Promise.resolve(c);const s=[],o=[],a=[];for(let l=0,h=t.length;l<h;l++){const d=t[l];if(r){const f=d.POSITION!==void 0?e.getDependency("accessor",d.POSITION):c.attributes.position;s.push(f)}if(n){const f=d.NORMAL!==void 0?e.getDependency("accessor",d.NORMAL):c.attributes.normal;o.push(f)}if(i){const f=d.COLOR_0!==void 0?e.getDependency("accessor",d.COLOR_0):c.attributes.color;a.push(f)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a)]).then(function(l){const h=l[0],d=l[1],f=l[2];return r&&(c.morphAttributes.position=h),n&&(c.morphAttributes.normal=d),i&&(c.morphAttributes.color=f),c.morphTargetsRelative=!0,c})}function Ke(c,t){if(c.updateMorphTargets(),t.weights!==void 0)for(let e=0,r=t.weights.length;e<r;e++)c.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(c.morphTargetInfluences.length===e.length){c.morphTargetDictionary={};for(let r=0,n=e.length;r<n;r++)c.morphTargetDictionary[e[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Ve(c){let t;const e=c.extensions&&c.extensions[R.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+z(e.attributes):t=c.indices+":"+z(c.attributes)+":"+c.mode,c.targets!==void 0)for(let r=0,n=c.targets.length;r<n;r++)t+=":"+z(c.targets[r]);return t}function z(c){let t="";const e=Object.keys(c).sort();for(let r=0,n=e.length;r<n;r++)t+=e[r]+":"+c[e[r]]+";";return t}function Y(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 ze(c){return c.search(/\.jpe?g($|\?)/i)>0||c.search(/^data\:image\/jpeg/)===0?"image/jpeg":c.search(/\.webp($|\?)/i)>0||c.search(/^data\:image\/webp/)===0?"image/webp":c.search(/\.ktx2($|\?)/i)>0||c.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Xe=new u.Matrix4;class We{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new me,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,n=-1,i=!1,s=-1;if(typeof navigator<"u"){const o=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(o)===!0;const a=o.match(/Version\/(\d+)/);n=r&&a?parseInt(a[1],10):-1,i=o.indexOf("Firefox")>-1,s=i?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&n<17||i&&s<98?this.textureLoader=new u.TextureLoader(this.options.manager):this.textureLoader=new u.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new u.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const r=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(s){const o={scene:s[0][n.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:n.asset,parser:r,userData:{}};return I(i,o,n),M(o,n),Promise.all(r._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(const a of o.scenes)a.updateMatrixWorld();t(o)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],r=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const s=e[n].joints;for(let o=0,a=s.length;o<a;o++)t[s[o]].isBone=!0}for(let n=0,i=t.length;n<i;n++){const s=t[n];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(r[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,r){if(t.refs[e]<=1)return r;const n=r.clone(),i=(s,o)=>{const a=this.associations.get(s);a!=null&&this.associations.set(o,a);for(const[l,h]of s.children.entries())i(h,o.children[l])};return i(r,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let r=0;r<e.length;r++){const n=t(e[r]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const r=[];for(let n=0;n<e.length;n++){const i=t(e[n]);i&&r.push(i)}return r}getDependency(t,e){const r=t+":"+e;let n=this.cache.get(r);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t);break}this.cache.add(r,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const r=this,n=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(i,s){return r.getDependency(t,s)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],r=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[R.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,s){r.load(u.LoaderUtils.resolveURL(e.uri,n.path),i,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(r){const n=e.byteLength||0,i=e.byteOffset||0;return r.slice(i,i+n)})}loadAccessor(t){const e=this,r=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){const s=K[n.type],o=P[n.componentType],a=n.normalized===!0,l=new o(n.count*s);return Promise.resolve(new u.BufferAttribute(l,s,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(s){const o=s[0],a=K[n.type],l=P[n.componentType],h=l.BYTES_PER_ELEMENT,d=h*a,f=n.byteOffset||0,p=n.bufferView!==void 0?r.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let _,A;if(p&&p!==d){const T=Math.floor(f/p),E="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+T+":"+n.count;let w=e.cache.get(E);w||(_=new l(o,T*p,n.count*p/h),w=new u.InterleavedBuffer(_,p/h),e.cache.add(E,w)),A=new u.InterleavedBufferAttribute(w,a,f%p/h,g)}else o===null?_=new l(n.count*a):_=new l(o,f,n.count*a),A=new u.BufferAttribute(_,a,g);if(n.sparse!==void 0){const T=K.SCALAR,E=P[n.sparse.indices.componentType],w=n.sparse.indices.byteOffset||0,L=n.sparse.values.byteOffset||0,b=new E(s[1],w,n.sparse.count*T),C=new l(s[2],L,n.sparse.count*a);o!==null&&(A=new u.BufferAttribute(A.array.slice(),A.itemSize,A.normalized)),A.normalized=!1;for(let S=0,D=b.length;S<D;S++){const v=b[S];if(A.setX(v,C[S*a]),a>=2&&A.setY(v,C[S*a+1]),a>=3&&A.setZ(v,C[S*a+2]),a>=4&&A.setW(v,C[S*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}A.normalized=g}return A})}loadTexture(t){const e=this.json,r=this.options,i=e.textures[t].source,s=e.images[i];let o=this.textureLoader;if(s.uri){const a=r.manager.getHandler(s.uri);a!==null&&(o=a)}return this.loadTextureImage(t,i,o)}loadTextureImage(t,e,r){const n=this,i=this.json,s=i.textures[t],o=i.images[e],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(e,r).then(function(h){h.flipY=!1,h.name=s.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const f=(i.samplers||{})[s.sampler]||{};return h.magFilter=Z[f.magFilter]||u.LinearFilter,h.minFilter=Z[f.minFilter]||u.LinearMipmapLinearFilter,h.wrapS=ee[f.wrapS]||u.RepeatWrapping,h.wrapT=ee[f.wrapT]||u.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==u.NearestFilter&&h.minFilter!==u.LinearFilter,n.associations.set(h,{textures:t}),h}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(t,e){const r=this,n=this.json,i=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(d=>d.clone());const s=n.images[t],o=self.URL||self.webkitURL;let a=s.uri||"",l=!1;if(s.bufferView!==void 0)a=r.getDependency("bufferView",s.bufferView).then(function(d){l=!0;const f=new Blob([d],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(a).then(function(d){return new Promise(function(f,p){let g=f;e.isImageBitmapLoader===!0&&(g=function(_){const A=new u.Texture(_);A.needsUpdate=!0,f(A)}),e.load(u.LoaderUtils.resolveURL(d,i.path),g,void 0,p)})}).then(function(d){return l===!0&&o.revokeObjectURL(a),M(d,s),d.userData.mimeType=s.mimeType||ze(s.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),d});return this.sourceCache[t]=h,h}assignTexture(t,e,r,n){const i=this;return this.getDependency("texture",r.index).then(function(s){if(!s)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(s=s.clone(),s.channel=r.texCoord),i.extensions[R.KHR_TEXTURE_TRANSFORM]){const o=r.extensions!==void 0?r.extensions[R.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const a=i.associations.get(s);s=i.extensions[R.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),i.associations.set(s,a)}}return n!==void 0&&(s.colorSpace=n),t[e]=s,s})}assignFinalMaterial(t){const e=t.geometry;let r=t.material;const n=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,s=e.attributes.normal===void 0;if(t.isPoints){const o="PointsMaterial:"+r.uuid;let a=this.cache.get(o);a||(a=new u.PointsMaterial,u.Material.prototype.copy.call(a,r),a.color.copy(r.color),a.map=r.map,a.sizeAttenuation=!1,this.cache.add(o,a)),r=a}else if(t.isLine){const o="LineBasicMaterial:"+r.uuid;let a=this.cache.get(o);a||(a=new u.LineBasicMaterial,u.Material.prototype.copy.call(a,r),a.color.copy(r.color),a.map=r.map,this.cache.add(o,a)),r=a}if(n||i||s){let o="ClonedMaterial:"+r.uuid+":";n&&(o+="derivative-tangents:"),i&&(o+="vertex-colors:"),s&&(o+="flat-shading:");let a=this.cache.get(o);a||(a=r.clone(),i&&(a.vertexColors=!0),s&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(o,a),this.associations.set(a,this.associations.get(r))),r=a}t.material=r}getMaterialType(){return u.MeshStandardMaterial}loadMaterial(t){const e=this,r=this.json,n=this.extensions,i=r.materials[t];let s;const o={},a=i.extensions||{},l=[];if(a[R.KHR_MATERIALS_UNLIT]){const d=n[R.KHR_MATERIALS_UNLIT];s=d.getMaterialType(),l.push(d.extendParams(o,i,e))}else{const d=i.pbrMetallicRoughness||{};if(o.color=new u.Color(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const f=d.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],u.LinearSRGBColorSpace),o.opacity=f[3]}d.baseColorTexture!==void 0&&l.push(e.assignTexture(o,"map",d.baseColorTexture,u.SRGBColorSpace)),o.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,o.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(l.push(e.assignTexture(o,"metalnessMap",d.metallicRoughnessTexture)),l.push(e.assignTexture(o,"roughnessMap",d.metallicRoughnessTexture))),s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,o)})))}i.doubleSided===!0&&(o.side=u.DoubleSide);const h=i.alphaMode||V.OPAQUE;if(h===V.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===V.MASK&&(o.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&s!==u.MeshBasicMaterial&&(l.push(e.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new u.Vector2(1,1),i.normalTexture.scale!==void 0)){const d=i.normalTexture.scale;o.normalScale.set(d,d)}if(i.occlusionTexture!==void 0&&s!==u.MeshBasicMaterial&&(l.push(e.assignTexture(o,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&s!==u.MeshBasicMaterial){const d=i.emissiveFactor;o.emissive=new u.Color().setRGB(d[0],d[1],d[2],u.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&s!==u.MeshBasicMaterial&&l.push(e.assignTexture(o,"emissiveMap",i.emissiveTexture,u.SRGBColorSpace)),Promise.all(l).then(function(){const d=new s(o);return i.name&&(d.name=i.name),M(d,i),e.associations.set(d,{materials:t}),i.extensions&&I(n,d,i),d})}createUniqueName(t){const e=u.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,r=this.extensions,n=this.primitiveCache;function i(o){return r[R.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,e).then(function(a){return te(a,o,e)})}const s=[];for(let o=0,a=t.length;o<a;o++){const l=t[o],h=Ve(l),d=n[h];if(d)s.push(d.promise);else{let f;l.extensions&&l.extensions[R.KHR_DRACO_MESH_COMPRESSION]?f=i(l):f=te(new u.BufferGeometry,l,e),n[h]={primitive:l,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(t){const e=this,r=this.json,n=this.extensions,i=r.meshes[t],s=i.primitives,o=[];for(let a=0,l=s.length;a<l;a++){const h=s[a].material===void 0?Ue(this.cache):this.getDependency("material",s[a].material);o.push(h)}return o.push(e.loadGeometries(s)),Promise.all(o).then(function(a){const l=a.slice(0,a.length-1),h=a[a.length-1],d=[];for(let p=0,g=h.length;p<g;p++){const _=h[p],A=s[p];let T;const E=l[p];if(A.mode===x.TRIANGLES||A.mode===x.TRIANGLE_STRIP||A.mode===x.TRIANGLE_FAN||A.mode===void 0)T=i.isSkinnedMesh===!0?new u.SkinnedMesh(_,E):new u.Mesh(_,E),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),A.mode===x.TRIANGLE_STRIP?T.geometry=Q(T.geometry,u.TriangleStripDrawMode):A.mode===x.TRIANGLE_FAN&&(T.geometry=Q(T.geometry,u.TriangleFanDrawMode));else if(A.mode===x.LINES)T=new u.LineSegments(_,E);else if(A.mode===x.LINE_STRIP)T=new u.Line(_,E);else if(A.mode===x.LINE_LOOP)T=new u.LineLoop(_,E);else if(A.mode===x.POINTS)T=new u.Points(_,E);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(T.geometry.morphAttributes).length>0&&Ke(T,i),T.name=e.createUniqueName(i.name||"mesh_"+t),M(T,i),A.extensions&&I(n,T,A),e.assignFinalMaterial(T),d.push(T)}for(let p=0,g=d.length;p<g;p++)e.associations.set(d[p],{meshes:t,primitives:p});if(d.length===1)return i.extensions&&I(n,d[0],i),d[0];const f=new u.Group;i.extensions&&I(n,f,i),e.associations.set(f,{meshes:t});for(let p=0,g=d.length;p<g;p++)f.add(d[p]);return f})}loadCamera(t){let e;const r=this.json.cameras[t],n=r[r.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?e=new u.PerspectiveCamera(u.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):r.type==="orthographic"&&(e=new u.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(e.name=this.createUniqueName(r.name)),M(e,r),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],r=[];for(let n=0,i=e.joints.length;n<i;n++)r.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",e.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(n){const i=n.pop(),s=n,o=[],a=[];for(let l=0,h=s.length;l<h;l++){const d=s[l];if(d){o.push(d);const f=new u.Matrix4;i!==null&&f.fromArray(i.array,l*16),a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[l])}return new u.Skeleton(o,a)})}loadAnimation(t){const e=this.json,r=this,n=e.animations[t],i=n.name?n.name:"animation_"+t,s=[],o=[],a=[],l=[],h=[];for(let d=0,f=n.channels.length;d<f;d++){const p=n.channels[d],g=n.samplers[p.sampler],_=p.target,A=_.node,T=n.parameters!==void 0?n.parameters[g.input]:g.input,E=n.parameters!==void 0?n.parameters[g.output]:g.output;_.node!==void 0&&(s.push(this.getDependency("node",A)),o.push(this.getDependency("accessor",T)),a.push(this.getDependency("accessor",E)),l.push(g),h.push(_))}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(h)]).then(function(d){const f=d[0],p=d[1],g=d[2],_=d[3],A=d[4],T=[];for(let E=0,w=f.length;E<w;E++){const L=f[E],b=p[E],C=g[E],S=_[E],D=A[E];if(L===void 0)continue;L.updateMatrix&&L.updateMatrix();const v=r._createAnimationTracks(L,b,C,S,D);if(v)for(let j=0;j<v.length;j++)T.push(v[j])}return new u.AnimationClip(i,void 0,T)})}createNodeMesh(t){const e=this.json,r=this,n=e.nodes[t];return n.mesh===void 0?null:r.getDependency("mesh",n.mesh).then(function(i){const s=r._getNodeRef(r.meshCache,n.mesh,i);return n.weights!==void 0&&s.traverse(function(o){if(o.isMesh)for(let a=0,l=n.weights.length;a<l;a++)o.morphTargetInfluences[a]=n.weights[a]}),s})}loadNode(t){const e=this.json,r=this,n=e.nodes[t],i=r._loadNodeShallow(t),s=[],o=n.children||[];for(let l=0,h=o.length;l<h;l++)s.push(r.getDependency("node",o[l]));const a=n.skin===void 0?Promise.resolve(null):r.getDependency("skin",n.skin);return Promise.all([i,Promise.all(s),a]).then(function(l){const h=l[0],d=l[1],f=l[2];f!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(f,Xe)});for(let p=0,g=d.length;p<g;p++)h.add(d[p]);return h})}_loadNodeShallow(t){const e=this.json,r=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const i=e.nodes[t],s=i.name?n.createUniqueName(i.name):"",o=[],a=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(t)});return a&&o.push(a),i.camera!==void 0&&o.push(n.getDependency("camera",i.camera).then(function(l){return n._getNodeRef(n.cameraCache,i.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(t)}).forEach(function(l){o.push(l)}),this.nodeCache[t]=Promise.all(o).then(function(l){let h;if(i.isBone===!0?h=new u.Bone:l.length>1?h=new u.Group:l.length===1?h=l[0]:h=new u.Object3D,h!==l[0])for(let d=0,f=l.length;d<f;d++)h.add(l[d]);if(i.name&&(h.userData.name=i.name,h.name=s),M(h,i),i.extensions&&I(r,h,i),i.matrix!==void 0){const d=new u.Matrix4;d.fromArray(i.matrix),h.applyMatrix4(d)}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=t,h}),this.nodeCache[t]}loadScene(t){const e=this.extensions,r=this.json.scenes[t],n=this,i=new u.Group;r.name&&(i.name=n.createUniqueName(r.name)),M(i,r),r.extensions&&I(e,i,r);const s=r.nodes||[],o=[];for(let a=0,l=s.length;a<l;a++)o.push(n.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let h=0,d=a.length;h<d;h++)i.add(a[h]);const l=h=>{const d=new Map;for(const[f,p]of n.associations)(f instanceof u.Material||f instanceof u.Texture)&&d.set(f,p);return h.traverse(f=>{const p=n.associations.get(f);p!=null&&d.set(f,p)}),d};return n.associations=l(i),i})}_createAnimationTracks(t,e,r,n,i){const s=[],o=t.name?t.name:t.uuid,a=[];O[i.path]===O.weights?t.traverse(function(f){f.morphTargetInfluences&&a.push(f.name?f.name:f.uuid)}):a.push(o);let l;switch(O[i.path]){case O.weights:l=u.NumberKeyframeTrack;break;case O.rotation:l=u.QuaternionKeyframeTrack;break;case O.position:case O.scale:l=u.VectorKeyframeTrack;break;default:switch(r.itemSize){case 1:l=u.NumberKeyframeTrack;break;case 2:case 3:default:l=u.VectorKeyframeTrack;break}break}const h=n.interpolation!==void 0?Ge[n.interpolation]:u.InterpolateLinear,d=this._getArrayFromAccessor(r);for(let f=0,p=a.length;f<p;f++){const g=new l(a[f]+"."+O[i.path],e.array,d,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),s.push(g)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const r=Y(e.constructor),n=new Float32Array(e.length);for(let i=0,s=e.length;i<s;i++)n[i]=e[i]*r;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(r){const n=this instanceof u.QuaternionKeyframeTrack?He:se;return new n(this.times,this.values,this.getValueSize()/3,r)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function $e(c,t,e){const r=t.attributes,n=new u.Box3;if(r.POSITION!==void 0){const o=e.json.accessors[r.POSITION],a=o.min,l=o.max;if(a!==void 0&&l!==void 0){if(n.set(new u.Vector3(a[0],a[1],a[2]),new u.Vector3(l[0],l[1],l[2])),o.normalized){const h=Y(P[o.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=t.targets;if(i!==void 0){const o=new u.Vector3,a=new u.Vector3;for(let l=0,h=i.length;l<h;l++){const d=i[l];if(d.POSITION!==void 0){const f=e.json.accessors[d.POSITION],p=f.min,g=f.max;if(p!==void 0&&g!==void 0){if(a.setX(Math.max(Math.abs(p[0]),Math.abs(g[0]))),a.setY(Math.max(Math.abs(p[1]),Math.abs(g[1]))),a.setZ(Math.max(Math.abs(p[2]),Math.abs(g[2]))),f.normalized){const _=Y(P[f.componentType]);a.multiplyScalar(_)}o.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(o)}c.boundingBox=n;const s=new u.Sphere;n.getCenter(s.center),s.radius=n.min.distanceTo(n.max)/2,c.boundingSphere=s}function te(c,t,e){const r=t.attributes,n=[];function i(s,o){return e.getDependency("accessor",s).then(function(a){c.setAttribute(o,a)})}for(const s in r){const o=q[s]||s.toLowerCase();o in c.attributes||n.push(i(r[s],o))}if(t.indices!==void 0&&!c.index){const s=e.getDependency("accessor",t.indices).then(function(o){c.setIndex(o)});n.push(s)}return u.ColorManagement.workingColorSpace!==u.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${u.ColorManagement.workingColorSpace}" not supported.`),M(c,t),$e(c,t,e),Promise.all(n).then(function(){return t.targets!==void 0?je(c,t.targets,e):c})}const X=new WeakMap;class qe extends u.Loader{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,r,n){const i=new u.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(t,s=>{this.parse(s,e,n)},r,n)}parse(t,e,r=()=>{}){this.decodeDracoFile(t,e,null,null,u.SRGBColorSpace,r).catch(r)}decodeDracoFile(t,e,r,n,i=u.LinearSRGBColorSpace,s=()=>{}){const o={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:i};return this.decodeGeometry(t,o).then(e).catch(s)}decodeGeometry(t,e){const r=JSON.stringify(e);if(X.has(t)){const a=X.get(t);if(a.key===r)return a.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const i=this.workerNextTaskID++,s=t.byteLength,o=this._getWorker(i,s).then(a=>(n=a,new Promise((l,h)=>{n._callbacks[i]={resolve:l,reject:h},n.postMessage({type:"decode",id:i,taskConfig:e,buffer:t},[t])}))).then(a=>this._createGeometry(a.geometry));return o.catch(()=>!0).then(()=>{n&&i&&this._releaseTask(n,i)}),X.set(t,{key:r,promise:o}),o}_createGeometry(t){const e=new u.BufferGeometry;t.index&&e.setIndex(new u.BufferAttribute(t.index.array,1));for(let r=0;r<t.attributes.length;r++){const n=t.attributes[r],i=n.name,s=n.array,o=n.itemSize,a=new u.BufferAttribute(s,o);i==="color"&&(this._assignVertexColorSpace(a,n.vertexColorSpace),a.normalized=!(s instanceof Float32Array)),e.setAttribute(i,a)}return e}_assignVertexColorSpace(t,e){if(e!==u.SRGBColorSpace)return;const r=new u.Color;for(let n=0,i=t.count;n<i;n++)r.fromBufferAttribute(t,n),u.ColorManagement.toWorkingColorSpace(r,u.SRGBColorSpace),t.setXYZ(n,r.r,r.g,r.b)}_loadLibrary(t,e){const r=new u.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(e),r.setWithCredentials(this.withCredentials),new Promise((n,i)=>{r.load(t,n,void 0,i)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(r=>{const n=r[0];t||(this.decoderConfig.wasmBinary=r[1]);const i=Ye.toString(),s=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
|
|
2
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(i){const s=i.data;switch(s.type){case"decode":n._callbacks[s.id].resolve(s);break;case"error":n._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,i){return n._taskLoad>i._taskLoad?-1:1});const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[t]=e,r._taskLoad+=e,r})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Ye(){let c,t;onmessage=function(s){const o=s.data;switch(o.type){case"init":c=o.decoderConfig,t=new Promise(function(h){c.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(c)});break;case"decode":const a=o.buffer,l=o.taskConfig;t.then(h=>{const d=h.draco,f=new d.Decoder;try{const p=e(d,f,new Int8Array(a),l),g=p.attributes.map(_=>_.array.buffer);p.index&&g.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},g)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{d.destroy(f)}});break}};function e(s,o,a,l){const h=l.attributeIDs,d=l.attributeTypes;let f,p;const g=o.GetEncodedGeometryType(a);if(g===s.TRIANGULAR_MESH)f=new s.Mesh,p=o.DecodeArrayToMesh(a,a.byteLength,f);else if(g===s.POINT_CLOUD)f=new s.PointCloud,p=o.DecodeArrayToPointCloud(a,a.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const _={index:null,attributes:[]};for(const A in h){const T=self[d[A]];let E,w;if(l.useUniqueIDs)w=h[A],E=o.GetAttributeByUniqueId(f,w);else{if(w=o.GetAttributeId(f,s[h[A]]),w===-1)continue;E=o.GetAttribute(f,w)}const L=n(s,o,f,A,T,E);A==="color"&&(L.vertexColorSpace=l.vertexColorSpace),_.attributes.push(L)}return g===s.TRIANGULAR_MESH&&(_.index=r(s,o,f)),s.destroy(f),_}function r(s,o,a){const h=a.num_faces()*3,d=h*4,f=s._malloc(d);o.GetTrianglesUInt32Array(a,d,f);const p=new Uint32Array(s.HEAPF32.buffer,f,h).slice();return s._free(f),{array:p,itemSize:1}}function n(s,o,a,l,h,d){const f=d.num_components(),g=a.num_points()*f,_=g*h.BYTES_PER_ELEMENT,A=i(s,h),T=s._malloc(_);o.GetAttributeDataArrayForAllPoints(a,d,A,_,T);const E=new h(s.HEAPF32.buffer,T,g).slice();return s._free(T),{name:l,array:E,itemSize:f}}function i(s,o){switch(o){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}var Qe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Ze=(c,t,e,r)=>{for(var n=r>1?void 0:r?Je(t,e):t,i=c.length-1,s;i>=0;i--)(s=c[i])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&Qe(t,e,n),n};let B=class{constructor(){y(this,"loadingManager",new u.LoadingManager);y(this,"loaders",{});y(this,"sources",[]);y(this,"loadedResources",{});y(this,"toLoadCount",0);y(this,"loadedCount",0)}get videoLoader(){return{load:(c,t)=>{const e=document.createElement("video");e.muted=!0,e.loop=!0,e.controls=!1,e.playsInline=!0,e.src=c,e.autoplay=!0;const r=()=>{if(!e)return;e.play();const n=new u.VideoTexture(e),i=n.dispose.bind(n);n.dispose=()=>{var s;(s=n.image)==null||s.remove(),i()},t(n),e.removeEventListener("canplaythrough",r)};e.addEventListener("canplaythrough",r)}}}_initLoaders(){this.loaders.gltfLoader=new pe(this.loadingManager),this.loaders.textureLoader=new u.ImageBitmapLoader(this.loadingManager),this.loaders.cubeTextureLoader=new u.CubeTextureLoader(this.loadingManager),this.loaders.audioLoader=new u.AudioLoader(this.loadingManager),this.loaders.dracoLoader=new qe(this.loadingManager),this.loaders.videoLoader=this.videoLoader}_initSources(c){this.sources=c,this.toLoadCount=this.sources.length,this.loadedCount=0}init(c=[]){this._initLoaders(),this._initSources(c)}setDracoDecoder(c){var t;this.loaders.dracoLoader&&(this.loaders.dracoLoader.setDecoderPath(c??"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),(t=this.loaders.gltfLoader)==null||t.setDRACOLoader(this.loaders.dracoLoader))}handleLoad({source:c,resource:t,toLoadCount:e,loadedCount:r}){t&&(this.loadedResources[c.name]=t,this.loadedCount=r,this.toLoadCount=e)}};B=Ze([m.singleton()],B);var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(c,t,e,r)=>{for(var n=r>1?void 0:r?tt(t,e):t,i=c.length-1,s;i>=0;i--)(s=c[i])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&et(t,e,n),n},st=(c,t)=>(e,r)=>t(e,r,c);let H=class{constructor(c){y(this,"load$$",new m.Subject);y(this,"load$",this.load$$.pipe(m.map(c=>({...c,loadedCount:c.resource?this._service.loadedCount+1:this._service.loadedCount,toLoadCount:this._service.toLoadCount})),m.share()));y(this,"serializedLoad$",this.load$.pipe(m.map(c=>{var e;let t=c.resource;if((e=c==null?void 0:c.resource)!=null&&e.parser){const r=c.resource;t={animations:(c==null?void 0:c.resource).animations.map(n=>n.toJSON()),cameras:r.cameras.map(n=>m.W(n)),parser:{json:r.parser.json},scene:m.W(r.scene),scenes:r.scenes.map(n=>m.W(n)),userData:r.userData}}return(c==null?void 0:c.resource)instanceof u.VideoTexture&&(t=c.resource.toJSON()),{...c,resource:t}})));y(this,"loadCompleted$",this.load$.pipe(m.filter(c=>c.toLoadCount===c.loadedCount)));this._service=c}};H=nt([m.singleton(),st(0,m.inject(B))],H);var rt=Object.defineProperty,it=Object.getOwnPropertyDescriptor,ot=(c,t,e,r)=>{for(var n=r>1?void 0:r?it(t,e):t,i=c.length-1,s;i>=0;i--)(s=c[i])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&rt(t,e,n),n},W=(c,t)=>(e,r)=>t(e,r,c);let G=class{constructor(c,t,e){y(this,"_subscriptions",[]);this._controller=c,this._service=t,this._props=e,this._subscriptions.push(this._controller.load$.subscribe(this._service.handleLoad.bind(this._service)))}_performLoad(c,t){this._controller.load$$.next({source:c,resource:t})}init(c=[]){this._service.init(c),this._service.setDracoDecoder(),[void 0,!0].includes(this._props.loadResourcesOnInit)&&this.load()}load(){var t,e,r,n,i;const c=this._service.sources[0];if(c){this._performLoad(c);for(const s of this._service.sources){if(this._service.loadedResources[s.name])return;s.type==="gltfModel"&&typeof s.path=="string"&&((t=this._service.loaders.gltfLoader)==null||t.load(s.path,o=>this._performLoad(s,o))),s.type==="texture"&&typeof s.path=="string"&&((e=this._service.loaders.textureLoader)==null||e.load(s.path,o=>{this._performLoad(s,new u.CanvasTexture(o))})),s.type==="cubeTexture"&&typeof s.path=="object"&&((r=this._service.loaders.cubeTextureLoader)==null||r.load(s.path,o=>this._performLoad(s,o))),s.type==="video"&&typeof s.path=="string"&&((n=this._service.loaders.videoLoader)==null||n.load(s.path,o=>this._performLoad(s,o))),s.type==="audio"&&typeof s.path=="string"&&((i=this._service.loaders.audioLoader)==null||i.load(s.path,o=>{this._performLoad(s,o)}))}}}getLoadedResources(){return this._service.loadedResources}getLoaders(){return this._service.loaders}getSources(){return this._service.sources}getLoadedCount(){return this._service.loadedCount}getToLoadCount(){return this._service.toLoadCount}getLoad$(){return this._controller.load$}getLoadCompleted$(){return this._controller.loadCompleted$}setDracoDecoder(c){this._service.setDracoDecoder(c)}dispose(){this._controller.load$$.complete()}};G=ot([m.singleton(),W(0,m.inject(H)),W(1,m.inject(B)),W(2,m.inject(U))],G);m.instance.resolve(G);var at=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,lt=(c,t,e,r)=>{for(var n=r>1?void 0:r?ct(t,e):t,i=c.length-1,s;i>=0;i--)(s=c[i])&&(n=(r?s(t,e,n):s(n))||n);return r&&n&&at(t,e,n),n},N=(c,t)=>(e,r)=>t(e,r,c);exports.RegisterModule=class extends m.RegisterProxyEventHandlersBlueprint{constructor(e,r,n,i,s,o){super();y(this,"initialized",!1);this._service=e,this._controller=r,this._loaderController=n,this.props=i,this.loader=s,this.container=o,this.props.initOnConstruct&&this.init()}async _initCanvas(){try{if(this.props.canvas instanceof HTMLCanvasElement&&(this._service.canvas=this.props.canvas),typeof this.props.canvas=="string"){const e=document.querySelector(this.props.canvas);e instanceof HTMLCanvasElement&&(this._service.canvas=e)}this._service.canvas||(this._service.canvas=document.createElement("canvas"),this._service.canvas.dataset.reactive="true",document.body.appendChild(this._service.canvas))}catch(e){console.error(`🛑 Unable to initialize the canvas:
|
|
3
3
|
${e instanceof Error?e.message:"Something went wrong"}`)}}async _initService(){this._service.init({worker:this._service.worker,thread:this._service.thread})}async _initController(){var e,r;if(!this._service.canvas)throw new Error("Canvas element is not initialized.");this._controller.init(this._service.canvas),!(!this._service.thread||!this._service.worker)&&((r=(e=this._service.thread)==null?void 0:e.resize)==null||r.call(e,{...this._controller.uiEventHandler({type:"resize"})}))}async _initWorkerThread(){if(!this._service.canvas)throw new Error("Canvas element is not initialized.");const e=this._service.canvas.transferControlToOffscreen();e.width=this._service.canvas.clientWidth,e.height=this._service.canvas.clientHeight;const[r,n]=await this._service.workerPool.run({payload:{path:this.props.location,subject:{...m.U(this.props,["canvas","location","onReady","loaderDataSources"]),canvas:e},transferSubject:[e]}});if(!r||n)throw new Error("Unable to retrieve the worker-thread info.");this._service.worker=r.worker,this._service.thread=r.thread}async _initObservableProxyEvents(){m.PROXY_EVENT_LISTENERS.forEach(e=>this[`${e}$`]=()=>{var r;return(r=this._controller)==null?void 0:r[`${e}$`]})}async _initLoader(){this.loader.init(this.props.loaderDataSources),this._loaderController.serializedLoad$.subscribe(e=>{var r;return(r=this._service.worker)==null?void 0:r.postMessage({token:m.LOADER_SERIALIZED_LOAD_TOKEN,payload:e})})}isInitialized(){return this.initialized}async init(){var e,r;this.initialized||(await this._initCanvas(),await this._initWorkerThread(),await this._initService(),await this._initController(),await this._initObservableProxyEvents(),await this._initLoader(),(r=(e=this.props).onReady)==null||r.call(e,{module:this,container:this.container}))}canvas(){return this._service.canvas}thread(){return this._service.thread}worker(){return this._service.worker}workerPool(){return this._service.workerPool}async dispose(){var e;await this._service.workerPool.terminateAll(),((e=this._service.canvas)==null?void 0:e.dataset.reactive)==="true"&&(this._service.canvas.remove(),this._service.canvas=void 0),this.initialized=!1}};exports.RegisterModule=lt([m.scoped(m.Lifecycle.ContainerScoped),N(0,m.inject(F)),N(1,m.inject($)),N(2,m.inject(H)),N(3,m.inject(U)),N(4,m.inject(G)),N(5,m.inject(m.CONTAINER_TOKEN))],exports.RegisterModule);const ut=c=>{if(typeof(c==null?void 0:c.location)!="string"&&!((c==null?void 0:c.location)instanceof URL))throw new Error("Invalid register props detected. location path is required");const t=m.instance.createChildContainer();c.initOnConstruct=m.A(c.initOnConstruct)||!m.D(c.initOnConstruct)?!0:c.initOnConstruct,c.defaultCamera=c!=null&&c.defaultCamera&&c.defaultCamera in m.DefaultCameraType?c.defaultCamera:m.DefaultCameraType.PERSPECTIVE,c.withMiniCamera=m.A(c.withMiniCamera)||!m.D(c.withMiniCamera)?!1:c.withMiniCamera,c.startTimer=m.A(c.startTimer)||!m.D(c.startTimer)?!0:c.startTimer,c.fullScreen=m.A(c.fullScreen)||!m.D(c.fullScreen)?!0:c.fullScreen,c.onReady=m.Q(c.onReady)?c.onReady:void 0,t.register(m.CONTAINER_TOKEN,{useValue:t}),t.register(U,{useValue:c});const e=t.resolve(exports.RegisterModule);return e.initialized=!0,{container:t,module:e}};Object.defineProperty(exports,"AppModule",{enumerable:!0,get:()=>m.AppModule});exports.AppProxyEventHandlersBlueprint=m.AppProxyEventHandlersBlueprint;exports.CONTAINER_TOKEN=m.CONTAINER_TOKEN;exports.DefaultCameraType=m.DefaultCameraType;exports.KEYBOARD_EVENT_CODES=m.KEYBOARD_EVENT_CODES;exports.LOADER_SERIALIZED_LOAD_TOKEN=m.LOADER_SERIALIZED_LOAD_TOKEN;exports.PROXY_EVENT_LISTENERS=m.PROXY_EVENT_LISTENERS;exports.ProxyEventHandlersBlueprint=m.ProxyEventHandlersBlueprint;exports.ProxyEventObservablesBlueprint=m.ProxyEventObservablesBlueprint;exports.ProxyEventSubjectsBlueprint=m.ProxyEventSubjectsBlueprint;exports.RegisterProxyEventHandlersBlueprint=m.RegisterProxyEventHandlersBlueprint;exports.LaunchAppProps=oe;exports.RegisterPropsBlueprint=U;exports.register=ut;
|