@jdultra/threedtiles 9.0.10 → 9.0.12
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/threedtiles.min.js +1 -1
- package/package.json +3 -2
package/dist/threedtiles.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see threedtiles.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("three")):"function"==typeof define&&define.amd?define(["three"],t):"object"==typeof exports?exports.threedtiles=t(require("three")):e.threedtiles=t(e.THREE)}(this,(e=>(()=>{var t={852:(e,t,s)=>{const r=s(959),n=s(84),i=s(932);e.exports={Heap:r,Queue:n,LinkedHashMap:i}},959:e=>{e.exports=class{constructor(e,t){if(this._data=[],this._comparator=function(e,t){return e>=t},null!=e){if(!Array.isArray(e))throw Error("Constructor expects data to be an array");this._data=e}if(null!=t){if("function"!=typeof t)throw Error("Constructor expects comparator to be a function");this._comparator=t}}peek(){return this.size()<1?null:this._data[0]}pop(){if(this.size()<1)return null;const e=this._data[0];return this.swap(this.size()-1,0),this._data.pop(),this.heapifyDown(0),e}replaceTop(e){if(this.size()<1)return null;const t=this._data[0];return this._data[0]=e,this.heapifyDown(0),t}push(e){this._data.push(e),this.heapifyUp(this._data.length-1)}size(){return this._data.length}swap(e,t){const s=this._data[e];this._data[e]=this._data[t],this._data[t]=s}heapifyUp(e){if(0===e)return;const t=Math.floor((e-1)/2);this._comparator(this._data[e],this._data[t])||(this.swap(e,t),this.heapifyUp(t))}heapifyDown(e){const t=2*e+1,s=2*e+2;if(t>=this._data.length)return;const r=s<this._data.length&&!this._comparator(this._data[s],this._data[t])?s:t;this._comparator(this._data[e],this._data[r])&&(this.swap(e,r),this.heapifyDown(r))}}},932:e=>{e.exports=class{constructor(){this._data=new Map,this._link=new Map,this._head=void 0,this._tail=void 0}put(e,t,s=!1){this.has(e)?this._data.set(e,t):(this._data.set(e,t),this._link.set(e,{previous:void 0,next:void 0}),null==this._head?(this._head=e,this._tail=e):s?(this._link.get(this._head).previous=e,this._link.get(e).next=this._head,this._head=e):(this._link.get(this._tail).next=e,this._link.get(e).previous=this._tail,this._tail=e))}head(){return{key:this._head,value:this.get(this._head),next:()=>this.next(this._head),previous:()=>null}}tail(){return{key:this._tail,value:this.get(this._tail),next:()=>null,previous:()=>this.previous(this._tail)}}get(e){return this._data.get(e)}previousKey(e){const t=this._link.get(e);return null!=t?t.previous:void 0}previousValue(e){return this.get(this.previousKey(e))}previous(e){const t=this.previousKey(e);return{key:t,value:this.get(t),next:()=>this.next(t),previous:()=>this.previous(t)}}nextKey(e){const t=this._link.get(e);return null!=t?t.next:void 0}nextValue(e){return this.get(this.nextKey(e))}next(e){const t=this.nextKey(e);return{key:t,value:this.get(t),next:()=>this.next(t),previous:()=>this.previous(t)}}remove(e){const t=this._data.get(e);if(null!=t)if(1===this.size())this.reset();else{if(e===this._head){const e=this._link.get(this._head);this._link.get(e.next).previous=null,this._head=e.next}else if(e===this._tail){const e=this._link.get(this._tail);this._link.get(e.previous).next=null,this._tail=e.previous}else{const t=this._link.get(e),s=this._link.get(t.previous),r=this._link.get(t.next);s.next=t.next,r.previous=t.previous}this._link.delete(e),this._data.delete(e)}return t}has(e){return this._data.has(e)}size(){return this._data.size}reset(){this._data.clear(),this._link.clear(),this._head=void 0,this._tail=void 0}keys(){return this._data.keys()}values(){return this._data.values()}entries(){return this._data.entries()}toArray(e="orderByInsert"){if("orderByInsert"!==e){const e=[];let t=this._head;for(;null!=t;)e.push({key:t,value:this.get(t)}),t=this.nextKey(t);return e}return Array.from(this.keys()).map((e=>({key:e,value:this.get(e)})))}}},84:e=>{e.exports=class{constructor(e,t){if(this._data=[],this._head=0,this._cap=null,null!=e){if(!Array.isArray(e))throw Error("Constructor expects data to be an array");this._data=e}if(null!=t){if("number"!=typeof t)throw Error("Constructor expects capacity to be a number");this._cap=t}}enqueue(e){return!(null!=this._cap&&this.size()>=this._cap)&&(this._data.push(e),!0)}dequeue(){if(0===this.size())return null;const e=this._data[this._head];return this._head+=1,2*this._head>=this._data.length&&(this._data=this._data.slice(this._head),this._head=0),e}peek(e=!1){return this.size()>0?e?this._data[this._data.length-1]:this._data[this._head]:null}size(){return this._data.length-this._head}updateCapacity(e){this._cap=e}reset(){this._data=[],this._head=0}forEach(e){for(let t=this._head;t<this._data.length;t+=1)e(this._data[t],t-this._head)}toArray(){return this._data.slice(this._head)}}},470:e=>{"use strict";function t(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function s(e,t){for(var s,r="",n=0,i=-1,o=0,a=0;a<=e.length;++a){if(a<e.length)s=e.charCodeAt(a);else{if(47===s)break;s=47}if(47===s){if(i===a-1||1===o);else if(i!==a-1&&2===o){if(r.length<2||2!==n||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var l=r.lastIndexOf("/");if(l!==r.length-1){-1===l?(r="",n=0):n=(r=r.slice(0,l)).length-1-r.lastIndexOf("/"),i=a,o=0;continue}}else if(2===r.length||1===r.length){r="",n=0,i=a,o=0;continue}t&&(r.length>0?r+="/..":r="..",n=2)}else r.length>0?r+="/"+e.slice(i+1,a):r=e.slice(i+1,a),n=a-i-1;i=a,o=0}else 46===s&&-1!==o?++o:o=-1}return r}var r={resolve:function(){for(var e,r="",n=!1,i=arguments.length-1;i>=-1&&!n;i--){var o;i>=0?o=arguments[i]:(void 0===e&&(e=process.cwd()),o=e),t(o),0!==o.length&&(r=o+"/"+r,n=47===o.charCodeAt(0))}return r=s(r,!n),n?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(t(e),0===e.length)return".";var r=47===e.charCodeAt(0),n=47===e.charCodeAt(e.length-1);return 0!==(e=s(e,!r)).length||r||(e="."),e.length>0&&n&&(e+="/"),r?"/"+e:e},isAbsolute:function(e){return t(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,s=0;s<arguments.length;++s){var n=arguments[s];t(n),n.length>0&&(void 0===e?e=n:e+="/"+n)}return void 0===e?".":r.normalize(e)},relative:function(e,s){if(t(e),t(s),e===s)return"";if((e=r.resolve(e))===(s=r.resolve(s)))return"";for(var n=1;n<e.length&&47===e.charCodeAt(n);++n);for(var i=e.length,o=i-n,a=1;a<s.length&&47===s.charCodeAt(a);++a);for(var l=s.length-a,c=o<l?o:l,h=-1,d=0;d<=c;++d){if(d===c){if(l>c){if(47===s.charCodeAt(a+d))return s.slice(a+d+1);if(0===d)return s.slice(a+d)}else o>c&&(47===e.charCodeAt(n+d)?h=d:0===d&&(h=0));break}var u=e.charCodeAt(n+d);if(u!==s.charCodeAt(a+d))break;47===u&&(h=d)}var p="";for(d=n+h+1;d<=i;++d)d!==i&&47!==e.charCodeAt(d)||(0===p.length?p+="..":p+="/..");return p.length>0?p+s.slice(a+h):(a+=h,47===s.charCodeAt(a)&&++a,s.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var s=e.charCodeAt(0),r=47===s,n=-1,i=!0,o=e.length-1;o>=1;--o)if(47===(s=e.charCodeAt(o))){if(!i){n=o;break}}else i=!1;return-1===n?r?"/":".":r&&1===n?"//":e.slice(0,n)},basename:function(e,s){if(void 0!==s&&"string"!=typeof s)throw new TypeError('"ext" argument must be a string');t(e);var r,n=0,i=-1,o=!0;if(void 0!==s&&s.length>0&&s.length<=e.length){if(s.length===e.length&&s===e)return"";var a=s.length-1,l=-1;for(r=e.length-1;r>=0;--r){var c=e.charCodeAt(r);if(47===c){if(!o){n=r+1;break}}else-1===l&&(o=!1,l=r+1),a>=0&&(c===s.charCodeAt(a)?-1==--a&&(i=r):(a=-1,i=l))}return n===i?i=l:-1===i&&(i=e.length),e.slice(n,i)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!o){n=r+1;break}}else-1===i&&(o=!1,i=r+1);return-1===i?"":e.slice(n,i)},extname:function(e){t(e);for(var s=-1,r=0,n=-1,i=!0,o=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===n&&(i=!1,n=a+1),46===l?-1===s?s=a:1!==o&&(o=1):-1!==s&&(o=-1);else if(!i){r=a+1;break}}return-1===s||-1===n||0===o||1===o&&s===n-1&&s===r+1?"":e.slice(s,n)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var s=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return s?s===t.root?s+r:s+e+r:r}("/",e)},parse:function(e){t(e);var s={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return s;var r,n=e.charCodeAt(0),i=47===n;i?(s.root="/",r=1):r=0;for(var o=-1,a=0,l=-1,c=!0,h=e.length-1,d=0;h>=r;--h)if(47!==(n=e.charCodeAt(h)))-1===l&&(c=!1,l=h+1),46===n?-1===o?o=h:1!==d&&(d=1):-1!==o&&(d=-1);else if(!c){a=h+1;break}return-1===o||-1===l||0===d||1===d&&o===l-1&&o===a+1?-1!==l&&(s.base=s.name=0===a&&i?e.slice(1,l):e.slice(a,l)):(0===a&&i?(s.name=e.slice(1,o),s.base=e.slice(1,l)):(s.name=e.slice(a,o),s.base=e.slice(a,l)),s.ext=e.slice(o,l)),a>0?s.dir=e.slice(0,a-1):i&&(s.dir="/"),s},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,e.exports=r},381:t=>{"use strict";t.exports=e}},s={};function r(e){var n=s[e];if(void 0!==n)return n.exports;var i=s[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{InstancedOGC3DTile:()=>Ye,InstancedTileLoader:()=>st,OGC3DTile:()=>Ne,OcclusionCullingService:()=>i,TileLoader:()=>_e});var e=r(381);const t=[];for(let e=0;e<256;e++)t[e]=(e<16?"0":"")+e.toString(16);Math.PI,Math.PI;function s(e,t,s){return Math.max(t,Math.min(s,e))}class i{constructor(){this.cullMap=[],this.cullMaterial=new e.MeshBasicMaterial({vertexColors:!0}),this.cullMaterial.side=e.FrontSide,this.cullTarget=this.createCullTarget(),this.cullPixels=new Uint8Array(4*this.cullTarget.width*this.cullTarget.height)}setSide(e){this.cullMaterial.side=e}createCullTarget(){const t=new e.WebGLRenderTarget(Math.floor(.05*window.innerWidth),Math.floor(.05*window.innerHeight));return t.texture.format=e.RGBAFormat,t.texture.encoding=e.LinearEncoding,t.texture.minFilter=e.NearestFilter,t.texture.magFilter=e.NearestFilter,t.texture.generateMipmaps=!1,t.stencilBuffer=!1,t.depthBuffer=!0,t.depthTexture=new e.DepthTexture,t.depthTexture.format=e.DepthFormat,t.depthTexture.type=e.UnsignedShortType,t}update(e,t,r){let n=t.getRenderTarget(),i=e.overrideMaterial;e.overrideMaterial=this.cullMaterial,t.setRenderTarget(this.cullTarget),t.render(e,r),e.overrideMaterial=i,t.setRenderTarget(n),t.readRenderTargetPixels(this.cullTarget,0,0,this.cullTarget.width,this.cullTarget.height,this.cullPixels),this.cullMap=[];for(let e=0;e<this.cullPixels.length;e+=4){const t=s(this.cullPixels[e],0,255)<<16^s(this.cullPixels[e+1],0,255)<<8^s(this.cullPixels[e+2],0,255)<<0;this.cullMap[t]=!0}}hasID(e){return this.cullMap[e]}}class o{constructor(t){this.center=new e.Vector3(t[0],t[1],t[2]);var s=new e.Vector3(t[3],t[4],t[4]),r=new e.Vector3(t[6],t[7],t[8]),n=new e.Vector3(t[9],t[10],t[11]);this.halfWidth=s.length(),this.halfHeight=r.length(),this.halfDepth=n.length(),s.normalize(),r.normalize(),n.normalize(),this.sphere=new e.Sphere(this.center,Math.sqrt(this.halfWidth*this.halfWidth+this.halfHeight*this.halfHeight+this.halfDepth*this.halfDepth)),this.matrixToOBBCoordinateSystem=new e.Matrix3,this.matrixToOBBCoordinateSystem.set(s.x,s.y,s.z,r.x,r.y,r.z,n.x,n.y,n.z)}inFrustum(e){return e.intersectsSphere(this.sphere)}distanceToPoint(e){let t=e.clone();t.sub(this.center),t.applyMatrix3(this.matrixToOBBCoordinateSystem);let s=Math.max(0,Math.max(-this.halfWidth-t.x,t.x-this.halfWidth)),r=Math.max(0,Math.max(-this.halfHeight-t.y,t.y-this.halfHeight)),n=Math.max(0,Math.max(-this.halfDepth-t.z,t.z-this.halfDepth));return Math.sqrt(s*s+r*r+n*n)}}var a=r(852);class l extends e.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new m(e)})),this.register((function(e){return new w(e)})),this.register((function(e){return new b(e)})),this.register((function(e){return new f(e)})),this.register((function(e){return new g(e)})),this.register((function(e){return new T(e)})),this.register((function(e){return new y(e)})),this.register((function(e){return new p(e)})),this.register((function(e){return new x(e)})),this.register((function(e){return new d(e)})),this.register((function(e){return new _(e)}))}load(t,s,r,n){const i=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:e.LoaderUtils.extractUrlBase(t),this.manager.itemStart(t);const a=function(e){n?n(e):console.error(e),i.manager.itemError(t),i.manager.itemEnd(t)},l=new e.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(t,(function(e){try{i.parse(e,o,(function(e){s(e),i.manager.itemEnd(t)}),a)}catch(e){a(e)}}),r,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(t,s,r,n){let i;const o={},a={};if("string"==typeof t)i=t;else{if(e.LoaderUtils.decodeText(new Uint8Array(t,0,4))===M){try{o[h.KHR_BINARY_GLTF]=new E(t)}catch(e){return void(n&&n(e))}i=o[h.KHR_BINARY_GLTF].content}else i=e.LoaderUtils.decodeText(new Uint8Array(t))}const l=JSON.parse(i);if(void 0===l.asset||l.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=new ne(l,{path:s||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](c);a[t.name]=t,o[t.name]=!0}if(l.extensionsUsed)for(let e=0;e<l.extensionsUsed.length;++e){const t=l.extensionsUsed[e],s=l.extensionsRequired||[];switch(t){case h.KHR_MATERIALS_UNLIT:o[t]=new u;break;case h.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[t]=new L;break;case h.KHR_DRACO_MESH_COMPRESSION:o[t]=new R(l,this.dracoLoader);break;case h.KHR_TEXTURE_TRANSFORM:o[t]=new A;break;case h.KHR_MESH_QUANTIZATION:o[t]=new k;break;default:s.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(r,n)}parseAsync(e,t){const s=this;return new Promise((function(r,n){s.parse(e,t,r,n)}))}}function c(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const h={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class d{constructor(e){this.parser=e,this.name=h.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,r=t.length;s<r;s++){const r=t[s];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const s=this.parser,r="light:"+t;let n=s.cache.get(r);if(n)return n;const i=s.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let a;const l=new e.Color(16777215);void 0!==o.color&&l.fromArray(o.color);const c=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new e.DirectionalLight(l),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new e.PointLight(l),a.distance=c;break;case"spot":a=new e.SpotLight(l),a.distance=c,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,void 0!==o.intensity&&(a.intensity=o.intensity),a.name=s.createUniqueName(o.name||"light_"+t),n=Promise.resolve(a),s.cache.add(r,n),n}createNodeAttachment(e){const t=this,s=this.parser,r=s.json.nodes[e],n=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===n?null:this._loadLight(n).then((function(e){return s._getNodeRef(t.cache,n,e)}))}}class u{constructor(){this.name=h.KHR_MATERIALS_UNLIT}getMaterialType(){return e.MeshBasicMaterial}extendParams(t,s,r){const n=[];t.color=new e.Color(1,1,1),t.opacity=1;const i=s.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;t.color.fromArray(e),t.opacity=e[3]}void 0!==i.baseColorTexture&&n.push(r.assignTexture(t,"map",i.baseColorTexture,e.sRGBEncoding))}return Promise.all(n)}}class p{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class m{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];if(void 0!==o.clearcoatFactor&&(s.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&i.push(r.assignTexture(s,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(s.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&i.push(r.assignTexture(s,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(i.push(r.assignTexture(s,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const t=o.clearcoatNormalTexture.scale;s.clearcoatNormalScale=new e.Vector2(t,t)}return Promise.all(i)}}class f{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_SHEEN}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];s.sheenColor=new e.Color(0,0,0),s.sheenRoughness=0,s.sheen=1;const o=n.extensions[this.name];return void 0!==o.sheenColorFactor&&s.sheenColor.fromArray(o.sheenColorFactor),void 0!==o.sheenRoughnessFactor&&(s.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&i.push(r.assignTexture(s,"sheenColorMap",o.sheenColorTexture,e.sRGBEncoding)),void 0!==o.sheenRoughnessTexture&&i.push(r.assignTexture(s,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class g{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],i=r.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&n.push(s.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(n)}}class T{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_VOLUME}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];s.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&i.push(r.assignTexture(s,"thicknessMap",o.thicknessTexture)),s.attenuationDistance=o.attenuationDistance||0;const a=o.attenuationColor||[1,1,1];return s.attenuationColor=new e.Color(a[0],a[1],a[2]),Promise.all(i)}}class y{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_IOR}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class x{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_SPECULAR}getMaterialType(t){const s=this.parser.json.materials[t];return s.extensions&&s.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,s){const r=this.parser,n=r.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];s.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&i.push(r.assignTexture(s,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return s.specularColor=new e.Color(a[0],a[1],a[2]),void 0!==o.specularColorTexture&&i.push(r.assignTexture(s,"specularColorMap",o.specularColorTexture,e.sRGBEncoding)),Promise.all(i)}}class w{constructor(e){this.parser=e,this.name=h.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,r=s.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const n=r.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,i)}}class b{constructor(e){this.parser=e,this.name=h.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,r=s.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const i=n.extensions[t],o=r.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,i.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class _{constructor(e){this.name=h.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,n.ready]).then((function(t){const s=e.byteOffset||0,r=e.byteLength||0,i=e.count,o=e.byteStride,a=new ArrayBuffer(i*o),l=new Uint8Array(t[0],s,r);return n.decodeGltfBuffer(new Uint8Array(a),i,o,l,e.mode,e.filter),a}))}return null}}const M="glTF",C=1313821514,v=5130562;class E{constructor(t){this.name=h.KHR_BINARY_GLTF,this.content=null,this.body=null;const s=new DataView(t,0,12);if(this.header={magic:e.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:s.getUint32(4,!0),length:s.getUint32(8,!0)},this.header.magic!==M)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,n=new DataView(t,12);let i=0;for(;i<r;){const s=n.getUint32(i,!0);i+=4;const r=n.getUint32(i,!0);if(i+=4,r===C){const r=new Uint8Array(t,12+i,s);this.content=e.LoaderUtils.decodeText(r)}else if(r===v){const e=12+i;this.body=t.slice(e,e+s)}i+=s}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class R{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=h.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,r=this.dracoLoader,n=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,o={},a={},l={};for(const e in i){const t=z[e]||e.toLowerCase();o[t]=i[e]}for(const t in e.attributes){const r=z[t]||t.toLowerCase();if(void 0!==i[t]){const n=s.accessors[e.attributes[t]],i=G[n.componentType];l[r]=i,a[r]=!0===n.normalized}}return t.getDependency("bufferView",n).then((function(e){return new Promise((function(t){r.decodeDracoFile(e,(function(e){for(const t in e.attributes){const s=e.attributes[t],r=a[t];void 0!==r&&(s.normalized=r)}t(e)}),o,l)}))}))}}class A{constructor(){this.name=h.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class S extends e.MeshStandardMaterial{constructor(t){super(),this.isGLTFSpecularGlossinessMaterial=!0;const s=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),r=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),n=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),i=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),o=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new e.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(e){for(const t in a)e.uniforms[t]=a[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",s).replace("#include <metalnessmap_pars_fragment>",r).replace("#include <roughnessmap_fragment>",n).replace("#include <metalnessmap_fragment>",i).replace("#include <lights_physical_fragment>",o)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(t)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=h.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return S}extendParams(t,s,r){const n=s.extensions[this.name];t.color=new e.Color(1,1,1),t.opacity=1;const i=[];if(Array.isArray(n.diffuseFactor)){const e=n.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==n.diffuseTexture&&i.push(r.assignTexture(t,"map",n.diffuseTexture,e.sRGBEncoding)),t.emissive=new e.Color(0,0,0),t.glossiness=void 0!==n.glossinessFactor?n.glossinessFactor:1,t.specular=new e.Color(1,1,1),Array.isArray(n.specularFactor)&&t.specular.fromArray(n.specularFactor),void 0!==n.specularGlossinessTexture){const s=n.specularGlossinessTexture;i.push(r.assignTexture(t,"glossinessMap",s)),i.push(r.assignTexture(t,"specularMap",s,e.sRGBEncoding))}return Promise.all(i)}createMaterial(t){const s=new S(t);return s.fog=!0,s.color=t.color,s.map=void 0===t.map?null:t.map,s.lightMap=null,s.lightMapIntensity=1,s.aoMap=void 0===t.aoMap?null:t.aoMap,s.aoMapIntensity=1,s.emissive=t.emissive,s.emissiveIntensity=void 0===t.emissiveIntensity?1:t.emissiveIntensity,s.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,s.bumpMap=void 0===t.bumpMap?null:t.bumpMap,s.bumpScale=1,s.normalMap=void 0===t.normalMap?null:t.normalMap,s.normalMapType=e.TangentSpaceNormalMap,t.normalScale&&(s.normalScale=t.normalScale),s.displacementMap=null,s.displacementScale=1,s.displacementBias=0,s.specularMap=void 0===t.specularMap?null:t.specularMap,s.specular=t.specular,s.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,s.glossiness=t.glossiness,s.alphaMap=null,s.envMap=void 0===t.envMap?null:t.envMap,s.envMapIntensity=1,s}}class k{constructor(){this.name=h.KHR_MESH_QUANTIZATION}}class P extends e.Interpolant{constructor(e,t,s,r){super(e,t,s,r)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,r=this.valueSize,n=e*r*3+r;for(let e=0;e!==r;e++)t[e]=s[n+e];return t}}P.prototype.beforeStart_=P.prototype.copySampleValue_,P.prototype.afterEnd_=P.prototype.copySampleValue_,P.prototype.interpolate_=function(e,t,s,r){const n=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,c=r-t,h=(s-t)/c,d=h*h,u=d*h,p=e*l,m=p-l,f=-2*u+3*d,g=u-d,T=1-f,y=g-d+h;for(let e=0;e!==o;e++){const t=i[m+e+o],s=i[m+e+a]*c,r=i[p+e+o],l=i[p+e]*c;n[e]=T*t+y*s+f*r+g*l}return n};const j=new e.Quaternion;class F extends P{interpolate_(e,t,s,r){const n=super.interpolate_(e,t,s,r);return j.fromArray(n).normalize().toArray(n),n}}const I=0,D=1,O=2,U=3,V=4,B=5,N=6,G={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},H={9728:e.NearestFilter,9729:e.LinearFilter,9984:e.NearestMipmapNearestFilter,9985:e.LinearMipmapNearestFilter,9986:e.NearestMipmapLinearFilter,9987:e.LinearMipmapLinearFilter},K={33071:e.ClampToEdgeWrapping,33648:e.MirroredRepeatWrapping,10497:e.RepeatWrapping},W={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},z={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},X={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},q={CUBICSPLINE:void 0,LINEAR:e.InterpolateLinear,STEP:e.InterpolateDiscrete},J="OPAQUE",Y="MASK",Q="BLEND";function Z(e,t,s){for(const r in s.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=s.extensions[r])}function $(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ee(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,r=t.weights.length;s<r;s++)e.morphTargetInfluences[s]=t.weights[s];if(t.extras&&Array.isArray(t.extras.targetNames)){const s=t.extras.targetNames;if(e.morphTargetInfluences.length===s.length){e.morphTargetDictionary={};for(let t=0,r=s.length;t<r;t++)e.morphTargetDictionary[s[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function te(e){const t=e.extensions&&e.extensions[h.KHR_DRACO_MESH_COMPRESSION];let s;return s=t?"draco:"+t.bufferView+":"+t.indices+":"+se(t.attributes):e.indices+":"+se(e.attributes)+":"+e.mode,s}function se(e){let t="";const s=Object.keys(e).sort();for(let r=0,n=s.length;r<n;r++)t+=s[r]+":"+e[s[r]]+";";return t}function re(e){switch(e){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.")}}class ne{constructor(t={},s={}){this.json=t,this.extensions={},this.plugins={},this.options=s,this.cache=new c,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};const r=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),n=navigator.userAgent.indexOf("Firefox")>-1,i=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1;"undefined"==typeof createImageBitmap||r||n&&i<98?this.textureLoader=new e.TextureLoader(this.options.manager):this.textureLoader=new e.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new e.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,r=this.json,n=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])})).then((function(t){const i={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:s,userData:{}};Z(n,i,r),$(i,r),Promise.all(s._invokeAll((function(e){return e.afterRoot&&e.afterRoot(i)}))).then((function(){e(i)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){const r=t[s].joints;for(let t=0,s=r.length;t<s;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(s[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const r=s.clone(),n=(e,t)=>{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,r]of e.children.entries())n(r,t.children[s])};return n(s,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const r=e(t[s]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let r=0;r<t.length;r++){const n=e(t[r]);n&&s.push(n)}return s}getDependency(e,t){const s=e+":"+t;let r=this.cache.get(s);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this.loadNode(t);break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":r=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(s,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return s.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(t){const s=this.json.buffers[t],r=this.fileLoader;if(s.type&&"arraybuffer"!==s.type)throw new Error("THREE.GLTFLoader: "+s.type+" buffer type is not supported.");if(void 0===s.uri&&0===t)return Promise.resolve(this.extensions[h.KHR_BINARY_GLTF].body);const n=this.options;return new Promise((function(t,i){r.load(e.LoaderUtils.resolveURL(s.uri,n.path),t,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+s.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const s=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+s)}))}loadAccessor(t){const s=this,r=this.json,n=this.json.accessors[t];if(void 0===n.bufferView&&void 0===n.sparse)return Promise.resolve(null);const i=[];return void 0!==n.bufferView?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),void 0!==n.sparse&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then((function(t){const i=t[0],o=W[n.type],a=G[n.componentType],l=a.BYTES_PER_ELEMENT,c=l*o,h=n.byteOffset||0,d=void 0!==n.bufferView?r.bufferViews[n.bufferView].byteStride:void 0,u=!0===n.normalized;let p,m;if(d&&d!==c){const t=Math.floor(h/d),r="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+t+":"+n.count;let c=s.cache.get(r);c||(p=new a(i,t*d,n.count*d/l),c=new e.InterleavedBuffer(p,d/l),s.cache.add(r,c)),m=new e.InterleavedBufferAttribute(c,o,h%d/l,u)}else p=null===i?new a(n.count*o):new a(i,h,n.count*o),m=new e.BufferAttribute(p,o,u);if(void 0!==n.sparse){const s=W.SCALAR,r=G[n.sparse.indices.componentType],l=n.sparse.indices.byteOffset||0,c=n.sparse.values.byteOffset||0,h=new r(t[1],l,n.sparse.count*s),d=new a(t[2],c,n.sparse.count*o);null!==i&&(m=new e.BufferAttribute(m.array.slice(),m.itemSize,m.normalized));for(let e=0,t=h.length;e<t;e++){const t=h[e];if(m.setX(t,d[e*o]),o>=2&&m.setY(t,d[e*o+1]),o>=3&&m.setZ(t,d[e*o+2]),o>=4&&m.setW(t,d[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,r=t.textures[e].source,n=t.images[r];let i=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(i=e)}return this.loadTextureImage(e,r,i)}loadTextureImage(t,s,r){const n=this,i=this.json,o=i.textures[t],a=i.images[s],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(s,r).then((function(s){s.flipY=!1,o.name&&(s.name=o.name);const r=(i.samplers||{})[o.sampler]||{};return s.magFilter=H[r.magFilter]||e.LinearFilter,s.minFilter=H[r.minFilter]||e.LinearMipmapLinearFilter,s.wrapS=K[r.wrapS]||e.RepeatWrapping,s.wrapT=K[r.wrapT]||e.RepeatWrapping,n.associations.set(s,{textures:t}),s})).catch((function(){return null}));return this.textureCache[l]=c,c}loadImageSource(t,s){const r=this,n=this.json,i=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((e=>e.clone()));const o=n.images[t],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(void 0!==o.bufferView)l=r.getDependency("bufferView",o.bufferView).then((function(e){c=!0;const t=new Blob([e],{type:o.mimeType});return l=a.createObjectURL(t),l}));else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(l).then((function(t){return new Promise((function(r,n){let o=r;!0===s.isImageBitmapLoader&&(o=function(t){const s=new e.Texture(t);s.needsUpdate=!0,r(s)}),s.load(e.LoaderUtils.resolveURL(t,i.path),o,void 0,n)}))})).then((function(e){var t;return!0===c&&a.revokeObjectURL(l),e.userData.mimeType=o.mimeType||((t=o.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),e}));return this.sourceCache[t]=h,h}assignTexture(e,t,s,r){const n=this;return this.getDependency("texture",s.index).then((function(i){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[h.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[h.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(i);i=n.extensions[h.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),n.associations.set(i,t)}}return void 0!==r&&(i.encoding=r),e[t]=i,i}))}assignFinalMaterial(t){const s=t.geometry;let r=t.material;const n=void 0===s.attributes.tangent,i=void 0!==s.attributes.color,o=void 0===s.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+r.uuid;let s=this.cache.get(t);s||(s=new e.PointsMaterial,e.Material.prototype.copy.call(s,r),s.color.copy(r.color),s.map=r.map,s.sizeAttenuation=!1,this.cache.add(t,s)),r=s}else if(t.isLine){const t="LineBasicMaterial:"+r.uuid;let s=this.cache.get(t);s||(s=new e.LineBasicMaterial,e.Material.prototype.copy.call(s,r),s.color.copy(r.color),this.cache.add(t,s)),r=s}if(n||i||o){let e="ClonedMaterial:"+r.uuid+":";r.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),n&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),n&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}r.aoMap&&void 0===s.attributes.uv2&&void 0!==s.attributes.uv&&s.setAttribute("uv2",s.attributes.uv),t.material=r}getMaterialType(){return e.MeshStandardMaterial}loadMaterial(t){const s=this,r=this.json,n=this.extensions,i=r.materials[t];let o;const a={},l=i.extensions||{},c=[];if(l[h.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=n[h.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];o=e.getMaterialType(),c.push(e.extendParams(a,i,s))}else if(l[h.KHR_MATERIALS_UNLIT]){const e=n[h.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),c.push(e.extendParams(a,i,s))}else{const r=i.pbrMetallicRoughness||{};if(a.color=new e.Color(1,1,1),a.opacity=1,Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==r.baseColorTexture&&c.push(s.assignTexture(a,"map",r.baseColorTexture,e.sRGBEncoding)),a.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,a.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(c.push(s.assignTexture(a,"metalnessMap",r.metallicRoughnessTexture)),c.push(s.assignTexture(a,"roughnessMap",r.metallicRoughnessTexture))),o=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),c.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===i.doubleSided&&(a.side=e.DoubleSide);const d=i.alphaMode||J;if(d===Q?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===Y&&(a.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&o!==e.MeshBasicMaterial&&(c.push(s.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new e.Vector2(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==i.occlusionTexture&&o!==e.MeshBasicMaterial&&(c.push(s.assignTexture(a,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(a.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&o!==e.MeshBasicMaterial&&(a.emissive=(new e.Color).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&o!==e.MeshBasicMaterial&&c.push(s.assignTexture(a,"emissiveMap",i.emissiveTexture,e.sRGBEncoding)),Promise.all(c).then((function(){let e;return e=o===S?n[h.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new o(a),i.name&&(e.name=i.name),$(e,i),s.associations.set(e,{materials:t}),i.extensions&&Z(n,e,i),e}))}createUniqueName(t){const s=e.PropertyBinding.sanitizeNodeName(t||"");let r=s;for(let e=1;this.nodeNamesUsed[r];++e)r=s+"_"+e;return this.nodeNamesUsed[r]=!0,r}loadGeometries(t){const s=this,r=this.extensions,n=this.primitiveCache;function i(e){return r[h.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,s).then((function(t){return oe(t,e,s)}))}const o=[];for(let r=0,a=t.length;r<a;r++){const a=t[r],l=te(a),c=n[l];if(c)o.push(c.promise);else{let t;t=a.extensions&&a.extensions[h.KHR_DRACO_MESH_COMPRESSION]?i(a):oe(new e.BufferGeometry,a,s),n[l]={primitive:a,promise:t},o.push(t)}}return Promise.all(o)}loadMesh(t){const s=this,r=this.json,n=this.extensions,i=r.meshes[t],o=i.primitives,a=[];for(let t=0,s=o.length;t<s;t++){const s=void 0===o[t].material?(void 0===(l=this.cache).DefaultMaterial&&(l.DefaultMaterial=new e.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:e.FrontSide})),l.DefaultMaterial):this.getDependency("material",o[t].material);a.push(s)}var l;return a.push(s.loadGeometries(o)),Promise.all(a).then((function(r){const a=r.slice(0,r.length-1),l=r[r.length-1],c=[];for(let r=0,h=l.length;r<h;r++){const h=l[r],d=o[r];let u;const p=a[r];if(d.mode===V||d.mode===B||d.mode===N||void 0===d.mode)u=!0===i.isSkinnedMesh?new e.SkinnedMesh(h,p):new e.Mesh(h,p),!0!==u.isSkinnedMesh||u.geometry.attributes.skinWeight.normalized||u.normalizeSkinWeights(),d.mode===B?u.geometry=ae(u.geometry,e.TriangleStripDrawMode):d.mode===N&&(u.geometry=ae(u.geometry,e.TriangleFanDrawMode));else if(d.mode===D)u=new e.LineSegments(h,p);else if(d.mode===U)u=new e.Line(h,p);else if(d.mode===O)u=new e.LineLoop(h,p);else{if(d.mode!==I)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);u=new e.Points(h,p)}Object.keys(u.geometry.morphAttributes).length>0&&ee(u,i),u.name=s.createUniqueName(i.name||"mesh_"+t),$(u,i),d.extensions&&Z(n,u,d),s.assignFinalMaterial(u),c.push(u)}for(let e=0,r=c.length;e<r;e++)s.associations.set(c[e],{meshes:t,primitives:e});if(1===c.length)return c[0];const h=new e.Group;s.associations.set(h,{meshes:t});for(let e=0,t=c.length;e<t;e++)h.add(c[e]);return h}))}loadCamera(t){let s;const r=this.json.cameras[t],n=r[r.type];if(n)return"perspective"===r.type?s=new e.PerspectiveCamera(e.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===r.type&&(s=new e.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(s.name=this.createUniqueName(r.name)),$(s,r),Promise.resolve(s);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],s={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(s):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return s.inverseBindMatrices=e,s}))}loadAnimation(t){const s=this.json.animations[t],r=[],n=[],i=[],o=[],a=[];for(let e=0,t=s.channels.length;e<t;e++){const t=s.channels[e],l=s.samplers[t.sampler],c=t.target,h=void 0!==c.node?c.node:c.id,d=void 0!==s.parameters?s.parameters[l.input]:l.input,u=void 0!==s.parameters?s.parameters[l.output]:l.output;r.push(this.getDependency("node",h)),n.push(this.getDependency("accessor",d)),i.push(this.getDependency("accessor",u)),o.push(l),a.push(c)}return Promise.all([Promise.all(r),Promise.all(n),Promise.all(i),Promise.all(o),Promise.all(a)]).then((function(r){const n=r[0],i=r[1],o=r[2],a=r[3],l=r[4],c=[];for(let t=0,s=n.length;t<s;t++){const s=n[t],r=i[t],h=o[t],d=a[t],u=l[t];if(void 0===s)continue;let p;switch(s.updateMatrix(),s.matrixAutoUpdate=!0,X[u.path]){case X.weights:p=e.NumberKeyframeTrack;break;case X.rotation:p=e.QuaternionKeyframeTrack;break;default:p=e.VectorKeyframeTrack}const m=s.name?s.name:s.uuid,f=void 0!==d.interpolation?q[d.interpolation]:e.InterpolateLinear,g=[];X[u.path]===X.weights?s.traverse((function(e){e.morphTargetInfluences&&g.push(e.name?e.name:e.uuid)})):g.push(m);let T=h.array;if(h.normalized){const e=re(T.constructor),t=new Float32Array(T.length);for(let s=0,r=T.length;s<r;s++)t[s]=T[s]*e;T=t}for(let t=0,s=g.length;t<s;t++){const s=new p(g[t]+"."+X[u.path],r.array,T,f);"CUBICSPLINE"===d.interpolation&&(s.createInterpolant=function(t){return new(this instanceof e.QuaternionKeyframeTrack?F:P)(this.times,this.values,this.getValueSize()/3,t)},s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),c.push(s)}}const h=s.name?s.name:"animation_"+t;return new e.AnimationClip(h,void 0,c)}))}createNodeMesh(e){const t=this.json,s=this,r=t.nodes[e];return void 0===r.mesh?null:s.getDependency("mesh",r.mesh).then((function(e){const t=s._getNodeRef(s.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,s=r.weights.length;t<s;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(t){const s=this.json,r=this.extensions,n=this,i=s.nodes[t],o=i.name?n.createUniqueName(i.name):"";return function(){const e=[],s=n._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return s&&e.push(s),void 0!==i.camera&&e.push(n.getDependency("camera",i.camera).then((function(e){return n._getNodeRef(n.cameraCache,i.camera,e)}))),n._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){e.push(t)})),Promise.all(e)}().then((function(s){let a;if(a=!0===i.isBone?new e.Bone:s.length>1?new e.Group:1===s.length?s[0]:new e.Object3D,a!==s[0])for(let e=0,t=s.length;e<t;e++)a.add(s[e]);if(i.name&&(a.userData.name=i.name,a.name=o),$(a,i),i.extensions&&Z(r,a,i),void 0!==i.matrix){const t=new e.Matrix4;t.fromArray(i.matrix),a.applyMatrix4(t)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return n.associations.has(a)||n.associations.set(a,{}),n.associations.get(a).nodes=t,a}))}loadScene(t){const s=this.json,r=this.extensions,n=this.json.scenes[t],i=this,o=new e.Group;n.name&&(o.name=i.createUniqueName(n.name)),$(o,n),n.extensions&&Z(r,o,n);const a=n.nodes||[],l=[];for(let e=0,t=a.length;e<t;e++)l.push(ie(a[e],o,s,i));return Promise.all(l).then((function(){return i.associations=(t=>{const s=new Map;for(const[t,r]of i.associations)(t instanceof e.Material||t instanceof e.Texture)&&s.set(t,r);return t.traverse((e=>{const t=i.associations.get(e);null!=t&&s.set(e,t)})),s})(o),o}))}}function ie(t,s,r,n){const i=r.nodes[t];return n.getDependency("node",t).then((function(t){if(void 0===i.skin)return t;let s;return n.getDependency("skin",i.skin).then((function(e){s=e;const t=[];for(let e=0,r=s.joints.length;e<r;e++)t.push(n.getDependency("node",s.joints[e]));return Promise.all(t)})).then((function(r){return t.traverse((function(t){if(!t.isMesh)return;const n=[],i=[];for(let t=0,o=r.length;t<o;t++){const o=r[t];if(o){n.push(o);const r=new e.Matrix4;void 0!==s.inverseBindMatrices&&r.fromArray(s.inverseBindMatrices.array,16*t),i.push(r)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',s.joints[t])}t.bind(new e.Skeleton(n,i),t.matrixWorld)})),t}))})).then((function(e){s.add(e);const t=[];if(i.children){const s=i.children;for(let i=0,o=s.length;i<o;i++){const o=s[i];t.push(ie(o,e,r,n))}}return Promise.all(t)}))}function oe(t,s,r){const n=s.attributes,i=[];function o(e,s){return r.getDependency("accessor",e).then((function(e){t.setAttribute(s,e)}))}for(const e in n){const s=z[e]||e.toLowerCase();s in t.attributes||i.push(o(n[e],s))}if(void 0!==s.indices&&!t.index){const e=r.getDependency("accessor",s.indices).then((function(e){t.setIndex(e)}));i.push(e)}return $(t,s),function(t,s,r){const n=s.attributes,i=new e.Box3;if(void 0===n.POSITION)return;{const t=r.json.accessors[n.POSITION],s=t.min,o=t.max;if(void 0===s||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new e.Vector3(s[0],s[1],s[2]),new e.Vector3(o[0],o[1],o[2])),t.normalized){const e=re(G[t.componentType]);i.min.multiplyScalar(e),i.max.multiplyScalar(e)}}const o=s.targets;if(void 0!==o){const t=new e.Vector3,s=new e.Vector3;for(let e=0,n=o.length;e<n;e++){const n=o[e];if(void 0!==n.POSITION){const e=r.json.accessors[n.POSITION],i=e.min,o=e.max;if(void 0!==i&&void 0!==o){if(s.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),s.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),s.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),e.normalized){const t=re(G[e.componentType]);s.multiplyScalar(t)}t.max(s)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(t)}t.boundingBox=i;const a=new e.Sphere;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,t.boundingSphere=a}(t,s,r),Promise.all(i).then((function(){return void 0!==s.targets?function(e,t,s){let r=!1,n=!1,i=!1;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(void 0!==s.POSITION&&(r=!0),void 0!==s.NORMAL&&(n=!0),void 0!==s.COLOR_0&&(i=!0),r&&n&&i)break}if(!r&&!n&&!i)return Promise.resolve(e);const o=[],a=[],l=[];for(let c=0,h=t.length;c<h;c++){const h=t[c];if(r){const t=void 0!==h.POSITION?s.getDependency("accessor",h.POSITION):e.attributes.position;o.push(t)}if(n){const t=void 0!==h.NORMAL?s.getDependency("accessor",h.NORMAL):e.attributes.normal;a.push(t)}if(i){const t=void 0!==h.COLOR_0?s.getDependency("accessor",h.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then((function(t){const s=t[0],o=t[1],a=t[2];return r&&(e.morphAttributes.position=s),n&&(e.morphAttributes.normal=o),i&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(t,s.targets,r):t}))}function ae(t,s){let r=t.getIndex();if(null===r){const e=[],s=t.getAttribute("position");if(void 0===s)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<s.count;t++)e.push(t);t.setIndex(e),r=t.getIndex()}const n=r.count-2,i=[];if(s===e.TriangleFanDrawMode)for(let e=1;e<=n;e++)i.push(r.getX(0)),i.push(r.getX(e)),i.push(r.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(i.push(r.getX(e)),i.push(r.getX(e+1)),i.push(r.getX(e+2))):(i.push(r.getX(e+2)),i.push(r.getX(e+1)),i.push(r.getX(e)));i.length/3!==n&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=t.clone();return o.setIndex(i),o}const le=new WeakMap;class ce extends e.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(t,s,r,n){const i=new e.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(t,(e=>{const t={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,t).then(s).catch(n)}),r,n)}decodeDracoFile(e,t,s,r){const n={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!s};this.decodeGeometry(e,n).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){const s=t.attributeTypes[e];void 0!==s.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=s.name)}const s=JSON.stringify(t);if(le.has(e)){const t=le.get(e);if(t.key===s)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const n=this.workerNextTaskID++,i=e.byteLength,o=this._getWorker(n,i).then((s=>(r=s,new Promise(((s,i)=>{r._callbacks[n]={resolve:s,reject:i},r.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{r&&n&&this._releaseTask(r,n)})),le.set(e,{key:s,promise:o}),o}_createGeometry(t){const s=new e.BufferGeometry;t.index&&s.setIndex(new e.BufferAttribute(t.index.array,1));for(let r=0;r<t.attributes.length;r++){const n=t.attributes[r],i=n.name,o=n.array,a=n.itemSize;s.setAttribute(i,new e.BufferAttribute(o,a))}return s}_loadLibrary(t,s){const r=new e.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(s),r.setWithCredentials(this.withCredentials),new Promise(((e,s)=>{r.load(t,e,void 0,s)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const s=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=he.toString(),n=["/* draco decoder */",s,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const s=t.data;switch(s.type){case"decode":e._callbacks[s.id].resolve(s);break;case"error":e._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=t,s._taskLoad+=t,s}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function he(){let e,t;function s(e,t,s,r,n,i){const o=i.num_components(),a=s.num_points()*o,l=a*n.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,n),h=e._malloc(l);t.GetAttributeDataArrayForAllPoints(s,i,c,l,h);const d=new n(e.HEAPF32.buffer,h,a).slice();return e._free(h),{name:r,array:d,itemSize:o}}onmessage=function(r){const n=r.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=n.buffer,i=n.taskConfig;t.then((e=>{const t=e.draco,o=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(r),r.byteLength);try{const e=function(e,t,r,n){const i=n.attributeIDs,o=n.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(r);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeBufferToMesh(r,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeBufferToPointCloud(r,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const r in i){const l=self[o[r]];let c,d;if(n.useUniqueIDs)d=i[r],c=t.GetAttributeByUniqueId(a,d);else{if(d=t.GetAttributeId(a,e[i[r]]),-1===d)continue;c=t.GetAttribute(a,d)}h.attributes.push(s(e,t,a,r,l,c))}c===e.TRIANGULAR_MESH&&(h.index=function(e,t,s){const r=s.num_faces(),n=3*r,i=4*n,o=e._malloc(i);t.GetTrianglesUInt32Array(s,i,o);const a=new Uint32Array(e.HEAPF32.buffer,o,n).slice();return e._free(o),{array:a,itemSize:1}}(e,t,a));return e.destroy(a),h}(t,o,a,i),r=e.attributes.map((e=>e.array.buffer));e.index&&r.push(e.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:e},r)}catch(e){console.error(e),self.postMessage({type:"error",id:n.id,error:e.message})}finally{t.destroy(a),t.destroy(o)}}))}}}class de{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const s=this.workersResolve[e];if(s&&s(t),this.queue.length){const{resolve:t,msg:s,transfer:r}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(s,r)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((s=>{const r=this._getIdleWorker();-1!==r?(this._initWorker(r),this.workerStatus|=1<<r,this.workersResolve[r]=s,this.workers[r].postMessage(e,t)):this.queue.push({resolve:s,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const ue=new WeakMap;let pe=0;class me extends e.Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new de,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1),this}init(){if(!this.transcoderPending){const t=new e.FileLoader(this.manager);t.setPath(this.transcoderPath),t.setWithCredentials(this.withCredentials);const s=t.loadAsync("basis_transcoder.js"),r=new e.FileLoader(this.manager);r.setPath(this.transcoderPath),r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials);const n=r.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([s,n]).then((([e,t])=>{const s=me.BasisWorker.toString(),r=["/* constants */","let _EngineFormat = "+JSON.stringify(me.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(me.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(me.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r])),this.transcoderBinary=t,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e}))})),pe>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),pe++}return this.transcoderPending}load(t,s,r,n){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const i=new e.FileLoader(this.manager);i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials);const o=new e.CompressedTexture;return i.load(t,(e=>{if(ue.has(e)){return ue.get(e).promise.then(s).catch(n)}this._createTexture([e]).then((function(e){o.copy(e),o.needsUpdate=!0,s&&s(o)})).catch(n)}),r,n),o}_createTextureFrom(t){const{mipmaps:s,width:r,height:n,format:i,type:o,error:a,dfdTransferFn:l,dfdFlags:c}=t;if("error"===o)return Promise.reject(a);const h=new e.CompressedTexture(s,r,n,i,e.UnsignedByteType);return h.minFilter=1===s.length?e.LinearFilter:e.LinearMipmapLinearFilter,h.magFilter=e.LinearFilter,h.generateMipmaps=!1,h.needsUpdate=!0,h.encoding=2===l?e.sRGBEncoding:e.LinearEncoding,h.premultiplyAlpha=!!(1&c),h}_createTexture(e,t={}){const s=t,r=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffers:e,taskConfig:s},e))).then((e=>this._createTextureFrom(e.data)));return ue.set(e[0],{promise:r}),r}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),pe--,this}}me.BasisFormat={ETC1S:0,UASTC_4x4:1},me.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},me.EngineFormat={RGBAFormat:e.RGBAFormat,RGBA_ASTC_4x4_Format:e.RGBA_ASTC_4x4_Format,RGBA_BPTC_Format:e.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:e.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:e.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:e.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:e.RGB_ETC1_Format,RGB_ETC2_Format:e.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:e.RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:e.RGB_S3TC_DXT1_Format},me.BasisWorker=function(){let e,t,s;const r=_EngineFormat,n=_TranscoderFormat,i=_BasisFormat;self.addEventListener("message",(function(o){const h=o.data;switch(h.type){case"init":e=h.config,d=h.transcoderBinary,t=new Promise((e=>{s={wasmBinary:d,onRuntimeInitialized:e},BASIS(s)})).then((()=>{s.initializeBasis(),void 0===s.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":t.then((()=>{try{const{width:t,height:o,hasAlpha:d,mipmaps:u,format:p,dfdTransferFn:m,dfdFlags:f}=function(t){const o=new s.KTX2File(new Uint8Array(t));function h(){o.close(),o.delete()}if(!o.isValid())throw h(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const d=o.isUASTC()?i.UASTC_4x4:i.ETC1S,u=o.getWidth(),p=o.getHeight(),m=o.getLevels(),f=o.getHasAlpha(),g=o.getDFDTransferFunc(),T=o.getDFDFlags(),{transcoderFormat:y,engineFormat:x}=function(t,s,o,h){let d,u;const p=t===i.ETC1S?a:l;for(let r=0;r<p.length;r++){const n=p[r];if(e[n.if]&&(n.basisFormat.includes(t)&&!(h&&n.transcoderFormat.length<2)&&(!n.needsPowerOfTwo||c(s)&&c(o))))return d=n.transcoderFormat[h?1:0],u=n.engineFormat[h?1:0],{transcoderFormat:d,engineFormat:u}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),d=n.RGBA32,u=r.RGBAFormat,{transcoderFormat:d,engineFormat:u}}(d,u,p,f);if(!u||!p||!m)throw h(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!o.startTranscoding())throw h(),new Error("THREE.KTX2Loader: .startTranscoding failed");const w=[];for(let e=0;e<m;e++){const t=o.getImageLevelInfo(e,0,0),s=t.origWidth,r=t.origHeight,n=new Uint8Array(o.getImageTranscodedSizeInBytes(e,0,0,y));if(!o.transcodeImage(n,e,0,0,y,0,-1,-1))throw h(),new Error("THREE.KTX2Loader: .transcodeImage failed.");w.push({data:n,width:s,height:r})}return h(),{width:u,height:p,hasAlpha:f,mipmaps:w,format:x,dfdTransferFn:g,dfdFlags:T}}(h.buffers[0]),g=[];for(let e=0;e<u.length;++e)g.push(u[e].data.buffer);self.postMessage({type:"transcode",id:h.id,width:t,height:o,hasAlpha:d,mipmaps:u,format:p,dfdTransferFn:m,dfdFlags:f},g)}catch(e){console.error(e),self.postMessage({type:"error",id:h.id,error:e.message})}}))}var d}));const o=[{if:"astcSupported",basisFormat:[i.UASTC_4x4],transcoderFormat:[n.ASTC_4x4,n.ASTC_4x4],engineFormat:[r.RGBA_ASTC_4x4_Format,r.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[i.ETC1S,i.UASTC_4x4],transcoderFormat:[n.BC7_M5,n.BC7_M5],engineFormat:[r.RGBA_BPTC_Format,r.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[i.ETC1S,i.UASTC_4x4],transcoderFormat:[n.BC1,n.BC3],engineFormat:[r.RGB_S3TC_DXT1_Format,r.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[i.ETC1S,i.UASTC_4x4],transcoderFormat:[n.ETC1,n.ETC2],engineFormat:[r.RGB_ETC2_Format,r.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[i.ETC1S,i.UASTC_4x4],transcoderFormat:[n.ETC1],engineFormat:[r.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[i.ETC1S,i.UASTC_4x4],transcoderFormat:[n.PVRTC1_4_RGB,n.PVRTC1_4_RGBA],engineFormat:[r.RGB_PVRTC_4BPPV1_Format,r.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],a=o.sort((function(e,t){return e.priorityETC1S-t.priorityETC1S})),l=o.sort((function(e,t){return e.priorityUASTC-t.priorityUASTC}));function c(e){return e<=2||0==(e&e-1)&&0!==e}};const fe=new TextDecoder;class ge{constructor(e,t,s,r){this.buffer=e,this.binOffset=t+s,this.binLength=r;let n=null;if(0!==s)try{const r=new Uint8Array(e,t,s);n=JSON.parse(fe.decode(r))}catch(e){n={}}else n={};this.header=n}getKeys(){return Object.keys(this.header)}getData(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const n=this.header;if(!(e in n))return null;const i=n[e];if(i instanceof Object){if(Array.isArray(i))return i;{const{buffer:n,binOffset:o,binLength:a}=this,l=i.byteOffset||0,c=i.type||r,h=i.componentType||s;if("type"in i&&r&&i.type!==r)throw new Error("FeatureTable: Specified type does not match expected type.");let d,u;switch(c){case"SCALAR":d=1;break;case"VEC2":d=2;break;case"VEC3":d=3;break;case"VEC4":d=4;break;default:throw new Error('FeatureTable : Feature type not provided for "'.concat(e,'".'))}const p=o+l,m=t*d;switch(h){case"BYTE":u=new Int8Array(n,p,m);break;case"UNSIGNED_BYTE":u=new Uint8Array(n,p,m);break;case"SHORT":u=new Int16Array(n,p,m);break;case"UNSIGNED_SHORT":u=new Uint16Array(n,p,m);break;case"INT":u=new Int32Array(n,p,m);break;case"UNSIGNED_INT":u=new Uint32Array(n,p,m);break;case"FLOAT":u=new Float32Array(n,p,m);break;case"DOUBLE":u=new Float64Array(n,p,m);break;default:throw new Error('FeatureTable : Feature component type not provided for "'.concat(e,'".'))}if(p+m*u.BYTES_PER_ELEMENT>o+a)throw new Error("FeatureTable: Feature data read outside binary body length.");return u}}return i}}class Te extends ge{constructor(e,t,s,r,n){super(e,s,r,n),this.batchSize=t}getData(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return super.getData(e,this.batchSize,t,s)}}const ye=new e.Matrix4;ye.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);class xe{constructor(t){this.gltfLoader=new l;const s=new ce;if(s.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),this.gltfLoader.setDRACOLoader(s),t){const e=new me;e.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(t),this.gltfLoader.setKTX2Loader(e)}this.tempMatrix=new e.Matrix4}parseB3DM(e,t,s,r){const n=new DataView(e),i=String.fromCharCode(n.getUint8(0))+String.fromCharCode(n.getUint8(1))+String.fromCharCode(n.getUint8(2))+String.fromCharCode(n.getUint8(3));console.assert("b3dm"===i);const o=n.getUint32(8,!0);console.assert(o===e.byteLength);const a=n.getUint32(12,!0),l=n.getUint32(16,!0),c=n.getUint32(20,!0),h=n.getUint32(24,!0),d=new ge(e,28,a,l),u=28+a+l,p=(new Te(e,d.getData("BATCH_LENGTH"),u,c,h),u+c+h),m=new Uint8Array(e,p,o-p).slice().buffer;return new Promise(((e,n)=>{this.gltfLoader.parse(m,null,(n=>{const i=d.getData("RTC_CENTER");i?(this.tempMatrix.makeTranslation(i[0],i[1],i[2]),n.scene.applyMatrix4(this.tempMatrix)):n.userData.gltfExtensions&&n.userData.gltfExtensions.CESIUM_RTC&&(this.tempMatrix.makeTranslation(n.userData.gltfExtensions.CESIUM_RTC.center[0],n.userData.gltfExtensions.CESIUM_RTC.center[1],n.userData.gltfExtensions.CESIUM_RTC.center[2]),n.scene.applyMatrix4(this.tempMatrix)),r||n.scene.applyMatrix4(ye),n.scene.traverse((e=>{e.isMesh&&(e.geometricError=s,r&&e.applyMatrix4(ye),t&&t(e))})),e(n.scene)}),(e=>{console.error(e)}))}))}parseB3DMInstanced(t,s,r,n){return this.parseB3DM(t,s,n).then((t=>{let s;return t.updateWorldMatrix(!1,!0),t.traverse((t=>{t.isMesh&&(s=new e.InstancedMesh(t.geometry,t.material,r),s.baseMatrix=t.matrixWorld)})),s}))}}let we=0;const be=new e.Matrix4;be.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);class _e{constructor(e){this.maxCachedItems=100,this.proxy=e.proxy,e&&(this.meshCallback=e.meshCallback,this.pointsCallback=e.pointsCallback,e.maxCachedItems&&(this.maxCachedItems=e.maxCachedItems)),this.gltfLoader=new l;const t=new ce;if(t.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),this.gltfLoader.setDRACOLoader(t),e&&e.renderer){const t=new me;t.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(e.renderer),this.gltfLoader.setKTX2Loader(t),this.b3dmDecoder=new xe(e.renderer)}else this.b3dmDecoder=new xe(null);this.cache=new a.LinkedHashMap,this.register={},this.ready=[],this.downloads=[],this.nextReady=[],this.nextDownloads=[],this.init()}init(){const e=this;Me((()=>{e.download()}),10),Me((()=>{const t=Date.now();let s=0;do{s=e.loadBatch()}while(s>0&&Date.now()-t<=0)}),10)}scheduleDownload(e){this.downloads.unshift(e)}download(){if(0!=this.nextDownloads.length||(this.getNextDownloads(),0!=this.nextDownloads.length))for(;this.nextDownloads.length>0&&we<500;){const e=this.nextDownloads.shift();e&&e.shouldDoDownload()&&e.doDownload()}}meshReceived(e,t,s,r,n,i,o){this.ready.unshift([e,t,s,r,n,i,o])}loadBatch(){if(0==this.nextReady.length&&(this.getNextReady(),0==this.nextReady.length))return 0;const e=this.nextReady.shift();if(!e)return 0;const t=e[0],s=e[1],r=e[2],n=t.get(r);return n&&s[r]&&Object.keys(s[r]).forEach((e=>{const t=s[r][e];t&&(t(n),s[r][e]=null)})),1}getNextDownloads(){let e=Number.MAX_VALUE,t=-1;for(let e=this.downloads.length-1;e>=0;e--)this.downloads[e].shouldDoDownload()?this.downloads[e].distanceFunction||this.nextDownloads.push(this.downloads.splice(e,1)[0]):this.downloads.splice(e,1);if(!(this.nextDownloads.length>0)){for(let s=this.downloads.length-1;s>=0;s--){const r=this.downloads[s].distanceFunction()*this.downloads[s].level;r<e&&(e=r,t=s)}if(t>=0){const e=this.downloads.splice(t,1).pop();this.nextDownloads.push(e);const s=e.getSiblings();for(let e=this.downloads.length-1;e>=0;e--)s.includes(this.downloads[e].uuid)&&this.nextDownloads.push(this.downloads.splice(e,1).pop())}}}getNextReady(){let e=Number.MAX_VALUE,t=-1;for(let e=this.ready.length-1;e>=0;e--)this.ready[e][3]||this.nextReady.push(this.ready.splice(e,1)[0]);if(!(this.nextReady.length>0)){for(let s=this.ready.length-1;s>=0;s--){const r=this.ready[s][3]()*this.ready[s][5];r<e&&(e=r,t=s)}if(t>=0){const e=this.ready.splice(t,1).pop();this.nextReady.push(e);const s=e[4]();for(let e=this.ready.length-1;e>=0;e--)s.includes(this.ready[e][6])&&this.nextready.push(this.ready.splice(e,1).pop())}}}get(e,t,s,r,n,i,o,a,l){const c=this,h=Ce(s),d=new AbortController;if(e.signal.addEventListener("abort",(()=>{c.register[h]&&0!=Object.keys(c.register[h]).length||d.abort()})),!(s.includes(".b3dm")||s.includes(".json")||s.includes(".gltf")||s.includes(".glb")))return void console.error("the 3DTiles cache can only be used to load B3DM, gltf and json data");c.register[h]||(c.register[h]={}),c.register[h][t]&&console.error(" a tile should only be loaded once"),c.register[h][t]=r;if(c.cache.get(h))this.meshReceived(c.cache,c.register,h,n,i,o,t);else if(1==Object.keys(c.register[h]).length){let r;s.includes(".b3dm")?r=()=>{we++,(c.proxy?()=>fetch(c.proxy,{method:"POST",body:s,signal:d.signal}):()=>fetch(s,{signal:d.signal}))().then((e=>{if(we--,!e.ok)throw console.error("could not load tile with path : "+s),new Error("couldn't load \"".concat(s,'". Request failed with status ').concat(e.status," : ").concat(e.statusText));return e.arrayBuffer()})).then((e=>this.b3dmDecoder.parseB3DM(e,c.meshCallback,l,a))).then((e=>{c.cache.put(h,e),c.checkSize(),this.meshReceived(c.cache,c.register,h,n,i,o,t)})).catch((e=>console.error(e)))}:s.includes(".glb")||s.includes(".gltf")?r=()=>{we++,this.gltfLoader.load(s,(e=>{e.scene.traverse((e=>{e.geometricError=l,e.isMesh&&(a&&e.applyMatrix4(be),c.meshCallback&&c.meshCallback(e)),e.isPoints&&(a&&e.applyMatrix4(be),c.pointsCallback&&c.pointsCallback(e))})),c.cache.put(h,e.scene),c.checkSize(),c.meshReceived(c.cache,c.register,h,n,i,o,t)}))}:s.includes(".json")&&(r=()=>{we++,(c.proxy?()=>fetch(c.proxy,{method:"POST",body:s,signal:d.signal}):()=>fetch(s,{signal:d.signal}))().then((e=>{if(we--,!e.ok)throw console.error("could not load tile with path : "+s),new Error("couldn't load \"".concat(s,'". Request failed with status ').concat(e.status," : ").concat(e.statusText));return e.json()})).then((e=>{c.cache.put(h,e),c.checkSize(),c.meshReceived(c.cache,c.register,h)})).catch((e=>console.error("tile download aborted")))}),this.scheduleDownload({shouldDoDownload:()=>!e.signal.aborted&&!!c.register[h]&&Object.keys(c.register[h]).length>0,doDownload:r,distanceFunction:n,getSiblings:i,level:o,uuid:t})}}invalidate(e,t){const s=Ce(e);this.register[s]&&delete this.register[s][t]}checkSize(){const e=this;let t=0;for(;e.cache.size()>e.maxCachedItems&&t<e.cache.size();){t++;const s=e.cache.head(),r=e.register[s.key];r&&(Object.keys(r).length>0?(e.cache.remove(s.key),e.cache.put(s.key,s.value)):(e.cache.remove(s.key),delete e.register[s.key],s.value.traverse((e=>{if(e.material)if(e.material.length)for(let t=0;t<e.material.length;++t)e.material[t].dispose();else e.material.dispose();e.geometry&&e.geometry.dispose()}))))}}}function Me(e,t){let s;const r=async()=>{const n=Date.now();try{await e()}catch(e){console.error(e)}finally{const e=Date.now()-n;s=setTimeout(r,e>=t?0:t-e)}};return s=setTimeout(r,t),{clearInterval:()=>clearTimeout(s)}}function Ce(e){for(var t=e.split("/"),s=[],r=0,n=0;n<t.length;n++){var i=t[n];"."!==i&&""!==i&&".."!==i?s[r++]=i:".."===i&&r>0&&r--}if(0===r)return"/";var o="";for(n=0;n<r;n++)o+="/"+s[n];return o}var ve,Ee=new Uint8Array(16);function Re(){if(!ve&&!(ve="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ve(Ee)}const Ae=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const Se=function(e){return"string"==typeof e&&Ae.test(e)};for(var Le=[],ke=0;ke<256;++ke)Le.push((ke+256).toString(16).substr(1));const Pe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=(Le[e[t+0]]+Le[e[t+1]]+Le[e[t+2]]+Le[e[t+3]]+"-"+Le[e[t+4]]+Le[e[t+5]]+"-"+Le[e[t+6]]+Le[e[t+7]]+"-"+Le[e[t+8]]+Le[e[t+9]]+"-"+Le[e[t+10]]+Le[e[t+11]]+Le[e[t+12]]+Le[e[t+13]]+Le[e[t+14]]+Le[e[t+15]]).toLowerCase();if(!Se(s))throw TypeError("Stringified UUID is invalid");return s};const je=function(e,t,s){var r=(e=e||{}).random||(e.rng||Re)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){s=s||0;for(var n=0;n<16;++n)t[s+n]=r[n];return t}return Pe(r)};var Fe=r(470);const Ie=new e.Sphere(new e.Vector3(0,0,0),1),De=new e.Vector3(0,0,0),Oe=new e.Vector3(0,0,0),Ue=new e.Vector3(0,1,0),Ve=new e.Vector2(1e3,1e3),Be=new e.Quaternion;class Ne extends e.Object3D{constructor(t){super();const r=this;if(this.proxy=t.proxy,this.uuid=je(),t.tileLoader)this.tileLoader=t.tileLoader;else{const s={};s.meshCallback=t.meshCallback?t.meshCallback:t=>{t.material.wireframe=!1,t.material.side=e.DoubleSide},s.pointsCallback=t.pointsCallback?t.pointsCallback:e=>{e.material.size=.1,e.material.sizeAttenuation=!0},s.proxy=this.proxy,this.tileLoader=new _e(s)}if(this.geometricErrorMultiplier=t.geometricErrorMultiplier?t.geometricErrorMultiplier:1,this.renderer=t.renderer,this.meshCallback=t.meshCallback,this.loadOutsideView=t.loadOutsideView,this.cameraOnLoad=t.cameraOnLoad,this.parentTile=t.parentTile,this.occlusionCullingService=t.occlusionCullingService,this.static=t.static,this.occlusionCullingService&&(this.color=new e.Color,this.color.setHex(16777215*Math.random()),this.colorID=s(255*r.color.r,0,255)<<16^s(255*r.color.g,0,255)<<8^s(255*r.color.b,0,255)<<0),this.static&&(this.matrixAutoUpdate=!1),this.childrenTiles=[],this.meshContent,this.tileContent,this.refinement,this.rootPath,this.geometricError,this.boundingVolume,this.json,this.materialVisibility=!1,this.inFrustum=!0,this.level=t.level?t.level:0,this.hasMeshContent=!1,this.hasUnloadedJSONContent=!1,this.centerModel=t.centerModel,this.abortController=new AbortController,this.layers.disable(0),t.json)r.setup(t),t.onLoadCallback&&t.onLoadCallback(r);else if(t.url){(r.proxy?()=>fetch(r.proxy,{method:"POST",body:t.url,signal:r.abortController.signal}):()=>fetch(t.url,{signal:r.abortController.signal}))().then((s=>{if(!s.ok)throw new Error("couldn't load \"".concat(t.url,'". Request failed with status ').concat(s.status," : ").concat(s.statusText));s.json().then((s=>{if(r.setup({rootPath:Fe.dirname(t.url),json:s}),t.onLoadCallback&&t.onLoadCallback(r),r.centerModel){const t=new e.Sphere;r.boundingVolume instanceof o?t.copy(r.boundingVolume.sphere):r.boundingVolume instanceof e.Sphere&&t.copy(r.boundingVolume),this.json.boundingVolume.region&&(this.transformWGS84ToCartesian(.5*(this.json.boundingVolume.region[0]+this.json.boundingVolume.region[2]),.5*(this.json.boundingVolume.region[1]+this.json.boundingVolume.region[3]),.5*(this.json.boundingVolume.region[4]+this.json.boundingVolume.region[5]),De),Be.setFromUnitVectors(De.normalize(),Ue.normalize()),r.applyQuaternion(Be)),r.translateX(-t.center.x*r.scale.x),r.translateY(-t.center.y*r.scale.y),r.translateZ(-t.center.z*r.scale.z)}}))})).catch((e=>console.error(e)))}}setup(t){if(t.json.root?(this.json=t.json.root,this.json.refinement||(this.json.refinement=t.json.refinement),this.json.geometricError||(this.json.geometricError=t.json.geometricError),this.json.transform||(this.json.transform=t.json.transform),this.json.boundingVolume||(this.json.boundingVolume=t.json.boundingVolume)):this.json=t.json,this.rootPath=t.json.rootPath?t.json.rootPath:t.rootPath,this.json.refinement?this.refinement=this.json.refinement:this.refinement=t.parentRefinement,this.json.geometricError?this.geometricError=this.json.geometricError:this.geometricError=t.parentGeometricError,this.json.transform&&!this.centerModel){let t=new e.Matrix4;t.elements=this.json.transform,this.applyMatrix4(t)}if(this.json.boundingVolume)if(this.json.boundingVolume.box)this.boundingVolume=new o(this.json.boundingVolume.box);else if(this.json.boundingVolume.region){const t=this.json.boundingVolume.region;this.transformWGS84ToCartesian(t[0],t[1],t[4],De),this.transformWGS84ToCartesian(t[2],t[3],t[5],Oe),De.lerp(Oe,.5),this.boundingVolume=new e.Sphere(new e.Vector3(De.x,De.y,De.z),De.distanceTo(Oe))}else if(this.json.boundingVolume.sphere){const t=this.json.boundingVolume.sphere;this.boundingVolume=new e.Sphere(new e.Vector3(t[0],t[1],t[2]),t[3])}else this.boundingVolume=t.parentBoundingVolume;else this.boundingVolume=t.parentBoundingVolume;this.json.content&&(this.json.content.uri&&this.json.content.uri.includes("json")||this.json.content.url&&this.json.content.url.includes("json")?this.hasUnloadedJSONContent=!0:this.hasMeshContent=!0,this.load())}isAbsolutePathOrURL(e){const t=/^(?:http|https|ftp|tcp|udp):\/\/\S+/.test(e),s=e.startsWith("/")&&!e.startsWith("//");return t||s}load(){var t=this;if(!t.deleted&&t.json.content){let s;t.json.content.uri?s=Fe.isAbsolute(t.json.content.uri)||t.isAbsolutePathOrURL(t.json.content.uri)?t.json.content.uri:t.rootPath+Fe.sep+t.json.content.uri:t.json.content.url&&(s=Fe.isAbsolute(t.json.content.url)||t.isAbsolutePathOrURL(t.json.content.url)?t.json.content.url:t.rootPath+Fe.sep+t.json.content.url),s&&(s.includes(".b3dm")||s.includes(".glb")||s.includes(".gltf")?(t.contentURL=s,t.tileLoader.get(t.abortController,this.uuid,s,(s=>{t.deleted||(s.traverse((s=>{if(s.isMesh){if(s.layers.disable(0),t.occlusionCullingService){const r=s.geometry.attributes.position,n=[];for(let e=0;e<r.count;e++)n.push(t.color.r,t.color.g,t.color.b);s.geometry.setAttribute("color",new e.Float32BufferAttribute(n,3))}t.static&&(s.matrixAutoUpdate=!1)}})),t.add(s),t.updateWorldMatrix(!1,!0),t.meshContent=s)}),t.cameraOnLoad?()=>t.calculateDistanceToCamera(t.cameraOnLoad):()=>0,(()=>t.getSiblings()),t.level,!!t.json.boundingVolume.region,t.geometricError)):s.includes(".json")&&t.tileLoader.get(t.abortController,this.uuid,s,(e=>{t.deleted||(t.json.children||(t.json.children=[]),e.rootPath=Fe.dirname(s),t.json.children.push(e),delete t.json.content,t.hasUnloadedJSONContent=!1)})))}}dispose(){const e=this;e.childrenTiles.forEach((e=>e.dispose())),e.deleted=!0,this.traverse((function(t){t.contentURL&&e.tileLoader.invalidate(t.contentURL,t.uuid),t.abortController&&t.abortController.abort()})),this.parent=null,this.parentTile=null,this.dispatchEvent({type:"removed"})}disposeChildren(){var e=this;e.childrenTiles.forEach((e=>e.dispose())),e.childrenTiles=[],e.children=[],e.meshContent&&e.children.push(e.meshContent)}update(t){const s=new e.Frustum;s.setFromProjectionMatrix((new e.Matrix4).multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),this._update(t,s)}_update(e,t){const s=this,r=s.materialVisibility;function n(e){if(s.hasMeshContent&&s.meshContent){if(e<0)return s.inFrustum=!1,void s.changeContentVisibility(!!s.loadOutsideView);if(s.inFrustum=!0,0!=s.childrenTiles.length){if(e>=s.geometricErrorMultiplier*s.geometricError)s.changeContentVisibility(!0);else if(e<s.geometricErrorMultiplier*s.geometricError){let e=!0;s.childrenTiles.every((t=>!!t.isReady()||(e=!1,!1))),e&&s.changeContentVisibility(!1)}}else s.changeContentVisibility(!0)}}s.boundingVolume&&s.geometricError&&(s.metric=s.calculateUpdateMetric(e,t)),s.childrenTiles.forEach((s=>s._update(e,t))),n(s.metric),function(t){if(t<0&&s.hasMeshContent)return;if(s.occlusionCullingService&&s.hasMeshContent&&!s.occlusionCullingService.hasID(s.colorID))return;if((!s.hasMeshContent||t<s.geometricErrorMultiplier*s.geometricError&&s.meshContent)&&s.json&&s.json.children&&s.childrenTiles.length!=s.json.children.length)s.json.children.forEach((t=>{let r=new Ne({parentTile:s,parentGeometricError:s.geometricError,parentBoundingVolume:s.boundingVolume,parentRefinement:s.refinement,json:t,rootPath:s.rootPath,geometricErrorMultiplier:s.geometricErrorMultiplier,loadOutsideView:s.loadOutsideView,level:s.level+1,tileLoader:s.tileLoader,cameraOnLoad:e,occlusionCullingService:s.occlusionCullingService,renderer:s.renderer,static:s.static,centerModel:!1});s.childrenTiles.push(r),s.add(r)}))}(s.metric),function(e,t){if(!s.hasMeshContent)return;if(!s.inFrustum)return s.disposeChildren(),void n(e);if(s.occlusionCullingService&&!t&&s.hasMeshContent&&s.meshContent&&s.meshDisplayed&&s.areAllChildrenLoadedAndHidden())return s.disposeChildren(),void n(e);if(e>=s.geometricErrorMultiplier*s.geometricError)s.disposeChildren(),n()}(s.metric,r)}areAllChildrenLoadedAndHidden(){let e=!0;const t=this;return this.childrenTiles.every((s=>{if(s.hasMeshContent){if(s.childrenTiles.length>0)return e=!1,!1;if(!s.inFrustum)return!0;if(!s.materialVisibility||s.meshDisplayed)return e=!1,!1;if(t.occlusionCullingService.hasID(s.colorID))return e=!1,!1}else if(!s.areAllChildrenLoadedAndHidden())return e=!1,!1;return!0})),e}isReady(){if(!this.inFrustum)return!0;if(this.hasUnloadedJSONContent)return!1;if((!this.hasMeshContent||!this.meshContent||!this.materialVisibility)&&this.childrenTiles.length>0){var e=!0;return this.childrenTiles.every((t=>!!t.isReady()||(e=!1,!1))),e}return!this.hasMeshContent||!!this.meshContent&&(!!this.materialVisibility&&!!this.meshDisplayed)}changeContentVisibility(e){const t=this;function s(e,s){e.material.visible=s,s&&(e.onAfterRender=()=>{delete e.onAfterRender,t.meshDisplayed=!0})}t.hasMeshContent&&t.meshContent&&(e?t.meshContent.traverse((e=>{e.isMesh&&e.layers.enable(0)})):t.meshContent.traverse((e=>{e.isMesh&&e.layers.disable(0)}))),t.materialVisibility!=e&&(t.materialVisibility=e,t.meshDisplayed=!0,t.meshContent.traverse?t.meshContent.traverse((function(t){t.material&&s(t,e)})):t.meshContent.scenes&&t.meshContent.scenes.forEach((t=>t.traverse((function(t){t.material&&s(t,e)})))))}calculateUpdateMetric(t,s){if(this.boundingVolume instanceof o){if(Ie.copy(this.boundingVolume.sphere),Ie.applyMatrix4(this.matrixWorld),!s.intersectsSphere(Ie))return-1}else{if(!(this.boundingVolume instanceof e.Sphere))return console.error("unsupported shape"),-1;if(Ie.copy(this.boundingVolume),Ie.applyMatrix4(this.matrixWorld),!s.intersectsSphere(Ie))return-1}const r=Math.max(0,t.position.distanceTo(Ie.center)-Ie.radius);if(0==r)return 0;const n=this.matrixWorld.getMaxScaleOnAxis();this.renderer&&this.renderer.getDrawingBufferSize(Ve);let i=Ve.y,a=t.fov;t.aspect<1&&(a*=t.aspect,i=Ve.x);let l=2*Math.tan(.5*a*.017453292519943295)*r;return 16*window.devicePixelRatio*l/(i*n)}getSiblings(){const e=this,t=[];if(!e.parentTile)return t;let s=e.parentTile;for(;!s.hasMeshContent&&s.parentTile;)s=s.parentTile;return s.childrenTiles.forEach((s=>{if(s&&s!=e){for(;!s.hasMeshContent&&s.childrenTiles[0];)s=s.childrenTiles[0];t.push(s)}})),t}calculateDistanceToCamera(t){return this.boundingVolume instanceof o?(Ie.copy(this.boundingVolume.sphere),Ie.applyMatrix4(this.matrixWorld)):this.boundingVolume instanceof e.Sphere?(Ie.copy(this.boundingVolume),Ie.applyMatrix4(this.matrixWorld)):console.error("unsupported shape"),Math.max(0,t.position.distanceTo(Ie.center)-Ie.radius)}setGeometricErrorMultiplier(e){this.geometricErrorMultiplier=e,this.childrenTiles.forEach((t=>t.setGeometricErrorMultiplier(e)))}transformWGS84ToCartesian(e,t,s,r){const n=6378137/Math.sqrt(1-.006694384442042*Math.pow(Math.sin(t),2)),i=Math.cos(t),o=Math.cos(e),a=Math.sin(t),l=n+s,c=l*i*o,h=l*i*Math.sin(e),d=(.993305615557957*n+s)*a;r.set(c,h,d)}}const Ge=new e.Sphere(new e.Vector3(0,0,0),1),He=new e.Vector3(0,0,0),Ke=new e.Vector3(0,0,0),We=new e.Vector3(0,1,0),ze=new e.Vector2,Xe=new e.Quaternion,qe=new e.Matrix4;class Je extends e.Object3D{constructor(t){super();const s=this;this.uuid=je(),t.tileLoader?this.tileLoader=t.tileLoader:console.error("an instanced tileset must be provided an InstancedTilesetLoader"),this.master=t.master,this.meshCallback=t.meshCallback,this.loadOutsideView=t.loadOutsideView,this.cameraOnLoad=t.cameraOnLoad,this.parentTile=t.parentTile,this.childrenTiles=[],this.jsonChildren=[],this.meshContent,this.tileContent,this.refinement,this.rootPath,this.geometricError,this.boundingVolume,this.json,this.materialVisibility=!1,this.inFrustum=!0,this.level=t.level?t.level:0,this.hasMeshContent=!1,this.hasUnloadedJSONContent=!1,this.centerModel=t.centerModel,this.deleted=!1,this.abortController=new AbortController,t.json?(this.rootPath=t.json.rootPath?t.json.rootPath:t.rootPath,t.json.children&&(this.jsonChildren=t.json.children),s.setup(t),t.onLoadCallback&&t.onLoadCallback(s)):t.url&&(this.loadJson=(r,n)=>{const i=Fe.dirname(n);if(s.setup({rootPath:i,json:r}),s.centerModel){const t=new e.Sphere;s.boundingVolume instanceof o?t.copy(s.boundingVolume.sphere):s.boundingVolume instanceof e.Sphere&&t.copy(s.boundingVolume),this.json.boundingVolume.region&&(s.transformWGS84ToCartesian(.5*(s.json.boundingVolume.region[0]+s.json.boundingVolume.region[2]),.5*(s.json.boundingVolume.region[1]+s.json.boundingVolume.region[3]),.5*(s.json.boundingVolume.region[4]+s.json.boundingVolume.region[5]),He),Xe.setFromUnitVectors(He.normalize(),We.normalize()),s.master.applyQuaternion(Xe),s.master.updateWorldMatrix(!1,!1)),qe.makeTranslation(-t.center.x*s.scale.x,-t.center.y*s.scale.y,-t.center.z*s.scale.z),s.master.matrix.multiply(qe),s.master.matrix.decompose(s.master.position,s.master.quaternion,s.master.scale)}t.onLoadCallback&&t.onLoadCallback(s)},s.tileLoader.get(s.abortController,t.url,s.uuid,s))}setup(t){if(this.isSetup=!0,t.json.root?(this.json=t.json.root,this.jsonChildren=this.json.children,this.json.refinement||(this.json.refinement=t.json.refinement),this.json.geometricError||(this.json.geometricError=t.json.geometricError),this.json.transform||(this.json.transform=t.json.transform),this.json.boundingVolume||(this.json.boundingVolume=t.json.boundingVolume)):this.json=t.json,this.rootPath=t.json.rootPath?t.json.rootPath:t.rootPath,this.json.refinement?this.refinement=this.json.refinement:this.refinement=t.parentRefinement,this.json.geometricError?this.geometricError=this.json.geometricError:this.geometricError=t.parentGeometricError,this.json.transform&&!this.centerModel){let t=new e.Matrix4;t.elements=this.json.transform,this.master.applyMatrix4(t)}if(this.json.boundingVolume)if(this.json.boundingVolume.box)this.boundingVolume=new o(this.json.boundingVolume.box);else if(this.json.boundingVolume.region){const t=this.json.boundingVolume.region;this.transformWGS84ToCartesian(t[0],t[1],t[4],He),this.transformWGS84ToCartesian(t[2],t[3],t[5],Ke),He.lerp(Ke,.5),this.boundingVolume=new e.Sphere(new e.Vector3(He.x,He.y,He.z),He.distanceTo(Ke))}else if(this.json.boundingVolume.sphere){const t=this.json.boundingVolume.sphere;this.boundingVolume=new e.Sphere(new e.Vector3(t[0],t[2],-t[1]),t[3])}else this.boundingVolume=t.parentBoundingVolume;else this.boundingVolume=t.parentBoundingVolume;this.json.content&&(this.json.content.uri&&this.json.content.uri.includes("json")||this.json.content.url&&this.json.content.url.includes("json")?this.hasUnloadedJSONContent=!0:this.hasMeshContent=!0,this.load())}isAbsolutePathOrURL(e){const t=/^(?:http|https|ftp|tcp|udp):\/\/\S+/.test(e),s=e.startsWith("/")&&!e.startsWith("//");return t||s}load(){var e=this;if(!e.deleted){if(e.json.content){let t;e.json.content.uri?t=Fe.isAbsolute(e.json.content.uri)||e.isAbsolutePathOrURL(e.json.content.uri)?e.json.content.uri:e.rootPath+Fe.sep+e.json.content.uri:e.json.content.url&&(t=Fe.isAbsolute(e.json.content.url)||e.isAbsolutePathOrURL(e.json.content.url)?e.json.content.url:e.rootPath+Fe.sep+e.json.content.url),t&&(t.includes(".b3dm")||t.includes(".glb")||t.includes(".gltf")?(e.contentURL=t,e.tileLoader.get(e.abortController,t,e.uuid,e,e.cameraOnLoad?()=>e.calculateDistanceToCamera(e.cameraOnLoad):()=>0,(()=>e.getSiblings()),e.level,!!e.json.boundingVolume.region,e.geometricError)):t.includes(".json")&&e.tileLoader.get(e.abortController,t,e.uuid,e))}e.matrixWorldNeedsUpdate=!0,e.updateWorldMatrix(!0,!0)}}loadMesh(e){this.deleted||(this.meshContent=e)}loadJson(e,t){this.deleted||(this.json.children&&(this.jsonChildren=this.json.children),e.rootPath=Fe.dirname(t),this.jsonChildren.push(e),this.hasUnloadedJSONContent=!1)}dispose(){const e=this;e.childrenTiles.forEach((e=>e.dispose())),e.deleted=!0,e.abortController&&e.abortController.abort(),this.parent=null,this.parentTile=null,this.dispatchEvent({type:"removed"})}disposeChildren(){this.childrenTiles.forEach((e=>e.dispose())),this.childrenTiles=[]}_update(e,t){const s=this;s.materialVisibility;function r(e){if(s.hasMeshContent&&s.meshContent){if(e<0)return s.inFrustum=!1,void s.changeContentVisibility(!!s.loadOutsideView);if(s.inFrustum=!0,0!=s.childrenTiles.length){if(e>=s.master.geometricErrorMultiplier*s.geometricError)s.changeContentVisibility(!0);else if(e<s.master.geometricErrorMultiplier*s.geometricError){let e=!0;s.childrenTiles.every((t=>!!t.isReady()||(e=!1,!1))),e&&s.changeContentVisibility(!1)}}else s.changeContentVisibility(!0)}}s.boundingVolume&&s.geometricError&&(s.metric=s.calculateUpdateMetric(e,t)),s.childrenTiles.forEach((s=>s._update(e,t))),r(s.metric),function(t){if(t<0&&s.hasMeshContent)return;if((!s.hasMeshContent&&s.rootPath||t<s.master.geometricErrorMultiplier*s.geometricError&&s.meshContent)&&s.json&&s.jsonChildren&&s.childrenTiles.length!=s.jsonChildren.length)s.jsonChildren.forEach((t=>{let r=new Je({parentTile:s,parentGeometricError:s.geometricError,parentBoundingVolume:s.boundingVolume,parentRefinement:s.refinement,json:t,rootPath:s.rootPath,loadOutsideView:s.loadOutsideView,level:s.level+1,tileLoader:s.tileLoader,cameraOnLoad:e,master:s.master,centerModel:!1});s.childrenTiles.push(r)}))}(s.metric),function(e,t){if(!s.hasMeshContent)return;if(!s.inFrustum)return s.disposeChildren(),void r(e);if(e>=s.master.geometricErrorMultiplier*s.geometricError)s.disposeChildren(),r(e)}(s.metric)}areAllChildrenLoadedAndHidden(){let e=!0;return this.childrenTiles.every((t=>{if(t.hasMeshContent){if(t.childrenTiles.length>0)return e=!1,!1;if(!t.inFrustum)return!0;if(!t.materialVisibility||t.meshesToDisplay!=t.meshesDisplayed)return e=!1,!1}else if(!t.areAllChildrenLoadedAndHidden())return e=!1,!1;return!0})),e}isReady(){if(!this.inFrustum)return!0;if(this.hasUnloadedJSONContent)return!1;if((!this.hasMeshContent||!this.meshContent||!this.materialVisibility)&&this.childrenTiles.length>0){var e=!0;return this.childrenTiles.every((t=>!!t.isReady()||(e=!1,!1))),e}return!this.hasMeshContent||!!this.meshContent&&(!!this.materialVisibility&&!!this.meshContent.displayedOnce)}changeContentVisibility(e){this.materialVisibility=e}calculateUpdateMetric(t,s){if(this.boundingVolume instanceof o){if(Ge.copy(this.boundingVolume.sphere),Ge.applyMatrix4(this.master.matrixWorld),!s.intersectsSphere(Ge))return-1}else{if(!(this.boundingVolume instanceof e.Sphere))return console.error("unsupported shape"),-1;if(Ge.copy(this.boundingVolume),Ge.applyMatrix4(this.master.matrixWorld),!s.intersectsSphere(Ge))return-1}if(this.boundingVolume instanceof o||this.boundingVolume instanceof e.Sphere){const e=Math.max(0,t.position.distanceTo(Ge.center)-Ge.radius);if(0==e)return 0;const s=this.master.matrixWorld.getMaxScaleOnAxis();this.master.renderer.getDrawingBufferSize(ze);let r=ze.y,n=t.fov;t.aspect<1&&(n*=t.aspect,r=ze.x);let i=2*Math.tan(.5*n*.017453292519943295)*e;return 16*window.devicePixelRatio*i/(r*s)}if(this.boundingVolume instanceof e.Box3)return-1}getSiblings(){const e=this,t=[];if(!e.parentTile)return t;let s=e.parentTile;for(;!s.hasMeshContent&&s.parentTile;)s=s.parentTile;return s.childrenTiles.forEach((s=>{if(s&&s!=e){for(;!s.hasMeshContent&&s.childrenTiles[0];)s=s.childrenTiles[0];t.push(s)}})),t}calculateDistanceToCamera(t){return this.boundingVolume instanceof o?(Ge.copy(this.boundingVolume.sphere),Ge.applyMatrix4(this.master.matrixWorld)):this.boundingVolume instanceof e.Sphere?(Ge.copy(this.boundingVolume),Ge.applyMatrix4(this.master.matrixWorld)):console.error("unsupported shape"),Math.max(0,t.position.distanceTo(Ge.center)-Ge.radius)}getWorldMatrix(){return this.master.matrixWorld}transformWGS84ToCartesian(e,t,s,r){const n=6378137/Math.sqrt(1-.006694384442042*Math.pow(Math.sin(t),2)),i=Math.cos(t),o=Math.cos(e),a=Math.sin(t),l=n+s,c=l*i*o,h=l*i*Math.sin(e),d=(.993305615557957*n+s)*a;r.set(c,h,d)}}class Ye extends e.Object3D{constructor(e){super(),e.master=this,this.renderer=e.renderer,this.geometricErrorMultiplier=e.geometricErrorMultiplier?e.geometricErrorMultiplier:1,this.tileset=new Je(e),e.static&&(this.matrixAutoUpdate=!1)}update(t,s){if(s)this.tileset._update(t,s);else{const s=new e.Frustum;s.setFromProjectionMatrix((new e.Matrix4).multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),this.tileset._update(t,s)}}updateWithFrustum(e,t){this.tileset._update(e,t)}setGeometricErrorMultiplier(e){this.geometricErrorMultiplier=e||1}}const Qe=new e.Matrix4;class Ze{constructor(t){const s=this;s.scene=t,s.instancedTiles=[],s.instancedMesh,s.reuseableMatrix=new e.Matrix4}addInstance(e){const t=this;e.added=!0,e.listOMesh=t.instancedTiles,t.instancedTiles.push(e),t.instancedMesh&&e.loadMesh(t.instancedMesh)}addToScene(){const t=this;t.instancedMesh.setMatrixAt(0,new e.Matrix4),t.instancedMesh.instanceMatrix.needsUpdate=!0,t.instancedMesh.count=1,t.scene.add(t.instancedMesh),t.instancedMesh.onAfterRender=()=>{delete t.instancedMesh.onAfterRender,t.instancedMesh.displayedOnce=!0}}setObject(e){const t=this;t.instancedMesh=e;for(let e=0;e<t.instancedTiles.length;e++)t.instancedTiles[e].loadMesh(t.instancedMesh)}update(){const e=this;for(let t=e.instancedTiles.length-1;t>=0;t--)e.instancedTiles[t].deleted&&e.instancedTiles.splice(t,1);if(e.instancedMesh){e.instancedMesh.count=0;for(let t=0;t<e.instancedTiles.length;t++)e.instancedTiles[t].meshContent=e.instancedMesh,e.instancedTiles[t].materialVisibility&&e.instancedTiles[t].meshContent&&(e.instancedMesh.count++,e.reuseableMatrix.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),e.reuseableMatrix.multiply(e.instancedTiles[t].master.matrixWorld),e.reuseableMatrix.multiply(e.instancedMesh.baseMatrix),e.instancedMesh.setMatrixAt(e.instancedMesh.count-1,e.reuseableMatrix),e.instancedMesh.getMatrixAt(0,Qe),console.log());e.instancedMesh.instanceMatrix.needsUpdate=!0}}getCount(){return this.instancedTiles.length}}class $e{constructor(){const e=this;e.count=0,e.json,e.instancedTiles=[]}addInstance(e){this.instancedTiles.push(e),this.json&&e.loadJson(this.json,this.url)}setObject(e,t){const s=this;s.json=e,s.url=t;for(let e=0;e<s.instancedTiles.length;e++)s.instancedTiles[e].loadJson(s.json,s.url)}getCount(){return this.instancedTiles.length}update(){const e=this;for(let t=e.instancedTiles.length-1;t>=0;t--)e.instancedTiles[t].deleted&&e.instancedTiles.splice(t,1)}}let et=0;const tt=new e.Matrix4;tt.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);class st{constructor(e,t){this.maxCachedItems=100,this.maxInstances=1,t&&(this.meshCallback=t.meshCallback,this.pointsCallback=t.pointsCallback,t.maxCachedItems&&(this.maxCachedItems=t.maxCachedItems),t.maxInstances&&(this.maxInstances=t.maxInstances)),this.gltfLoader=new l;const s=new ce;if(s.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),this.gltfLoader.setDRACOLoader(s),t&&t.renderer){const e=new me;e.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(t.renderer),this.gltfLoader.setKTX2Loader(e),this.b3dmDecoder=new xe(t.renderer)}else this.b3dmDecoder=new xe(null);this.cache=new a.LinkedHashMap,this.scene=e,this.ready=[],this.downloads=[],this.nextReady=[],this.nextDownloads=[],this.init()}update(){this.cache._data.forEach((e=>{e.update()}))}init(){const e=this;rt((()=>{e.download()}),10),rt((()=>{const t=Date.now();let s=0;do{s=e.loadBatch()}while(s>0&&Date.now()-t<=0)}),10)}download(){const t=this;if(0!=t.nextDownloads.length||(t.getNextDownloads(),0!=t.nextDownloads.length))for(;t.nextDownloads.length>0&&et<500;){const s=t.nextDownloads.shift();s&&s.shouldDoDownload()&&(et++,s.path.includes(".b3dm")&&fetch(s.path,{signal:s.abortController.signal}).then((e=>{if(et--,!e.ok)throw console.error("could not load tile with path : "+path),new Error("couldn't load \"".concat(path,'". Request failed with status ').concat(e.status," : ").concat(e.statusText));return e.arrayBuffer()})).then((e=>this.b3dmDecoder.parseB3DMInstanced(e,t.meshCallback,t.maxInstances,s.zUpToYUp))).then((e=>{s.tile.setObject(e),t.ready.unshift(s)})).catch((e=>console.error(e))),s.path.includes(".glb")||s.path.includes(".gltf")?this.gltfLoader.load(s.path,(r=>{let n;r.scene.traverse((e=>{e.geometricError=s.geometricError,e.isMesh&&(s.zUpToYUp&&e.applyMatrix4(tt),t.meshCallback&&t.meshCallback(e)),e.isPoints&&console.error("instanced point cloud is not supported")})),r.scene.updateWorldMatrix(!1,!0),r.scene.traverse((s=>{s.isMesh&&(n=new e.InstancedMesh(s.geometry,s.material,t.maxInstances),n.baseMatrix=s.matrixWorld)})),t.ready.unshift(s),n?s.tile.setObject(n):r.scene.traverse((e=>{e.dispose&&e.dispose(),e.material&&e.material.dispose()}))})):s.path.includes(".json")&&(et++,fetch(s.path,{signal:s.abortController.signal}).then((e=>{if(et--,!e.ok)throw console.error("could not load tile with path : "+path),new Error("couldn't load \"".concat(path,'". Request failed with status ').concat(e.status," : ").concat(e.statusText));return e.json()})).then((e=>{s.tile.setObject(e,s.path),t.ready.unshift(s)})).catch((e=>console.error(e)))))}}loadBatch(){if(0==this.nextReady.length&&(this.getNextReady(),0==this.nextReady.length))return 0;const e=this.nextReady.shift();return e?(e.tile.addToScene&&e.tile.addToScene(),1):0}getNextReady(){let e=Number.MAX_VALUE,t=-1;for(let e=this.ready.length-1;e>=0;e--)this.ready[e].distanceFunction||this.nextReady.push(this.ready.splice(e,1)[0]);if(!(this.nextReady.length>0)){for(let s=this.ready.length-1;s>=0;s--){const r=this.ready[s].distanceFunction()*this.ready[s].level;r<e&&(e=r,t=s)}if(t>=0){const e=this.ready.splice(t,1).pop();this.nextReady.push(e);const s=e.getSiblings();for(let e=this.ready.length-1;e>=0;e--)s.includes(this.ready[e].uuid)&&this.nextready.push(this.ready.splice(e,1).pop())}}}get(e,t,s,r,n,i,o,a,l){const c=this,h=function(e){for(var t=e.split("/"),s=[],r=0,n=0;n<t.length;n++){var i=t[n];"."!==i&&""!==i&&".."!==i?s[r++]=i:".."===i&&r>0&&r--}if(0===r)return"/";var o="";for(n=0;n<r;n++)o+="/"+s[n];return o}(t);if(!(t.includes(".b3dm")||t.includes(".json")||t.includes(".glb")||t.includes(".gltf")))return void console.error("the 3DTiles cache can only be used to load B3DM, gltf and json data");const d=c.cache.get(h);if(d)d.addInstance(r);else if(t.includes(".b3dm")||t.includes(".glb")||t.includes(".gltf")){const d=new Ze(c.scene);d.addInstance(r),c.cache.put(h,d);const u=new AbortController;e.signal.addEventListener("abort",(()=>{0==d.getCount()&&u.abort()})),this.downloads.push({abortController:u,tile:d,key:h,path:t,distanceFunction:n,getSiblings:i,level:o,uuid:s,zUpToYUp:a,geometricError:l,shouldDoDownload:()=>!0})}else if(t.includes(".json")){const s=new $e;s.addInstance(r),c.cache.put(h,s);const a=new AbortController;e.signal.addEventListener("abort",(()=>{0==s.getCount()&&a.abort()})),this.downloads.push({abortController:a,tile:s,key:h,path:t,distanceFunction:n,getSiblings:i,level:o,shouldDoDownload:()=>!0})}}getNextDownloads(){let e=Number.MAX_VALUE,t=-1;for(let e=this.downloads.length-1;e>=0;e--){const t=this.downloads[e];t.shouldDoDownload()?t.distanceFunction||this.nextDownloads.push(this.downloads.splice(e,1)[0]):this.downloads.splice(e,1)}if(!(this.nextDownloads.length>0)){for(let s=this.downloads.length-1;s>=0;s--){const r=this.downloads[s],n=r.distanceFunction()*r.level;n<e&&(e=n,t=s)}if(t>=0){const e=this.downloads.splice(t,1).pop();this.nextDownloads.push(e);const s=e.getSiblings();for(let e=this.downloads.length-1;e>=0;e--)s.includes(this.downloads[e].uuid)&&this.nextDownloads.push(this.downloads.splice(e,1).pop())}}}checkSize(){const e=this;let t=0;for(;e.cache.size()>e.maxCachedItems&&t<e.cache.size();){t++;const s=e.cache.head();s.value.getCount()>0?(e.cache.remove(s.key),e.cache.put(s.key,s.value)):(e.cache.remove(s.key),s.value.instancedMesh&&s.value.instancedMesh.traverse((e=>{if(e.material)if(e.material.length)for(let t=0;t<e.material.length;++t)e.material[t].dispose();else e.material.dispose();e.geometry&&e.geometry.dispose()})))}}}function rt(e,t){let s;const r=async()=>{const n=Date.now();try{await e()}catch(e){console.error(e)}finally{const e=Date.now()-n;s=setTimeout(r,e>=t?0:t-e)}};return s=setTimeout(r,t),{clearInterval:()=>clearTimeout(s)}}})(),n})()));
|
|
2
|
+
!function(A,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("three")):"function"==typeof define&&define.amd?define(["three"],e):"object"==typeof exports?exports.threedtiles=e(require("three")):A.threedtiles=e(A.THREE)}(this,(A=>(()=>{var e={852:(A,e,t)=>{const s=t(959),i=t(84),o=t(932);A.exports={Heap:s,Queue:i,LinkedHashMap:o}},959:A=>{A.exports=class{constructor(A,e){if(this._data=[],this._comparator=function(A,e){return A>=e},null!=A){if(!Array.isArray(A))throw Error("Constructor expects data to be an array");this._data=A}if(null!=e){if("function"!=typeof e)throw Error("Constructor expects comparator to be a function");this._comparator=e}}peek(){return this.size()<1?null:this._data[0]}pop(){if(this.size()<1)return null;const A=this._data[0];return this.swap(this.size()-1,0),this._data.pop(),this.heapifyDown(0),A}replaceTop(A){if(this.size()<1)return null;const e=this._data[0];return this._data[0]=A,this.heapifyDown(0),e}push(A){this._data.push(A),this.heapifyUp(this._data.length-1)}size(){return this._data.length}swap(A,e){const t=this._data[A];this._data[A]=this._data[e],this._data[e]=t}heapifyUp(A){if(0===A)return;const e=Math.floor((A-1)/2);this._comparator(this._data[A],this._data[e])||(this.swap(A,e),this.heapifyUp(e))}heapifyDown(A){const e=2*A+1,t=2*A+2;if(e>=this._data.length)return;const s=t<this._data.length&&!this._comparator(this._data[t],this._data[e])?t:e;this._comparator(this._data[A],this._data[s])&&(this.swap(A,s),this.heapifyDown(s))}}},932:A=>{A.exports=class{constructor(){this._data=new Map,this._link=new Map,this._head=void 0,this._tail=void 0}put(A,e,t=!1){this.has(A)?this._data.set(A,e):(this._data.set(A,e),this._link.set(A,{previous:void 0,next:void 0}),null==this._head?(this._head=A,this._tail=A):t?(this._link.get(this._head).previous=A,this._link.get(A).next=this._head,this._head=A):(this._link.get(this._tail).next=A,this._link.get(A).previous=this._tail,this._tail=A))}head(){return{key:this._head,value:this.get(this._head),next:()=>this.next(this._head),previous:()=>null}}tail(){return{key:this._tail,value:this.get(this._tail),next:()=>null,previous:()=>this.previous(this._tail)}}get(A){return this._data.get(A)}previousKey(A){const e=this._link.get(A);return null!=e?e.previous:void 0}previousValue(A){return this.get(this.previousKey(A))}previous(A){const e=this.previousKey(A);return{key:e,value:this.get(e),next:()=>this.next(e),previous:()=>this.previous(e)}}nextKey(A){const e=this._link.get(A);return null!=e?e.next:void 0}nextValue(A){return this.get(this.nextKey(A))}next(A){const e=this.nextKey(A);return{key:e,value:this.get(e),next:()=>this.next(e),previous:()=>this.previous(e)}}remove(A){const e=this._data.get(A);if(null!=e)if(1===this.size())this.reset();else{if(A===this._head){const A=this._link.get(this._head);this._link.get(A.next).previous=null,this._head=A.next}else if(A===this._tail){const A=this._link.get(this._tail);this._link.get(A.previous).next=null,this._tail=A.previous}else{const e=this._link.get(A),t=this._link.get(e.previous),s=this._link.get(e.next);t.next=e.next,s.previous=e.previous}this._link.delete(A),this._data.delete(A)}return e}has(A){return this._data.has(A)}size(){return this._data.size}reset(){this._data.clear(),this._link.clear(),this._head=void 0,this._tail=void 0}keys(){return this._data.keys()}values(){return this._data.values()}entries(){return this._data.entries()}toArray(A="orderByInsert"){if("orderByInsert"!==A){const A=[];let e=this._head;for(;null!=e;)A.push({key:e,value:this.get(e)}),e=this.nextKey(e);return A}return Array.from(this.keys()).map((A=>({key:A,value:this.get(A)})))}}},84:A=>{A.exports=class{constructor(A,e){if(this._data=[],this._head=0,this._cap=null,null!=A){if(!Array.isArray(A))throw Error("Constructor expects data to be an array");this._data=A}if(null!=e){if("number"!=typeof e)throw Error("Constructor expects capacity to be a number");this._cap=e}}enqueue(A){return!(null!=this._cap&&this.size()>=this._cap)&&(this._data.push(A),!0)}dequeue(){if(0===this.size())return null;const A=this._data[this._head];return this._head+=1,2*this._head>=this._data.length&&(this._data=this._data.slice(this._head),this._head=0),A}peek(A=!1){return this.size()>0?A?this._data[this._data.length-1]:this._data[this._head]:null}size(){return this._data.length-this._head}updateCapacity(A){this._cap=A}reset(){this._data=[],this._head=0}forEach(A){for(let e=this._head;e<this._data.length;e+=1)A(this._data[e],e-this._head)}toArray(){return this._data.slice(this._head)}}},470:A=>{"use strict";function e(A){if("string"!=typeof A)throw new TypeError("Path must be a string. Received "+JSON.stringify(A))}function t(A,e){for(var t,s="",i=0,o=-1,r=0,n=0;n<=A.length;++n){if(n<A.length)t=A.charCodeAt(n);else{if(47===t)break;t=47}if(47===t){if(o===n-1||1===r);else if(o!==n-1&&2===r){if(s.length<2||2!==i||46!==s.charCodeAt(s.length-1)||46!==s.charCodeAt(s.length-2))if(s.length>2){var a=s.lastIndexOf("/");if(a!==s.length-1){-1===a?(s="",i=0):i=(s=s.slice(0,a)).length-1-s.lastIndexOf("/"),o=n,r=0;continue}}else if(2===s.length||1===s.length){s="",i=0,o=n,r=0;continue}e&&(s.length>0?s+="/..":s="..",i=2)}else s.length>0?s+="/"+A.slice(o+1,n):s=A.slice(o+1,n),i=n-o-1;o=n,r=0}else 46===t&&-1!==r?++r:r=-1}return s}var s={resolve:function(){for(var A,s="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var r;o>=0?r=arguments[o]:(void 0===A&&(A=process.cwd()),r=A),e(r),0!==r.length&&(s=r+"/"+s,i=47===r.charCodeAt(0))}return s=t(s,!i),i?s.length>0?"/"+s:"/":s.length>0?s:"."},normalize:function(A){if(e(A),0===A.length)return".";var s=47===A.charCodeAt(0),i=47===A.charCodeAt(A.length-1);return 0!==(A=t(A,!s)).length||s||(A="."),A.length>0&&i&&(A+="/"),s?"/"+A:A},isAbsolute:function(A){return e(A),A.length>0&&47===A.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var A,t=0;t<arguments.length;++t){var i=arguments[t];e(i),i.length>0&&(void 0===A?A=i:A+="/"+i)}return void 0===A?".":s.normalize(A)},relative:function(A,t){if(e(A),e(t),A===t)return"";if((A=s.resolve(A))===(t=s.resolve(t)))return"";for(var i=1;i<A.length&&47===A.charCodeAt(i);++i);for(var o=A.length,r=o-i,n=1;n<t.length&&47===t.charCodeAt(n);++n);for(var a=t.length-n,g=r<a?r:a,h=-1,I=0;I<=g;++I){if(I===g){if(a>g){if(47===t.charCodeAt(n+I))return t.slice(n+I+1);if(0===I)return t.slice(n+I)}else r>g&&(47===A.charCodeAt(i+I)?h=I:0===I&&(h=0));break}var l=A.charCodeAt(i+I);if(l!==t.charCodeAt(n+I))break;47===l&&(h=I)}var c="";for(I=i+h+1;I<=o;++I)I!==o&&47!==A.charCodeAt(I)||(0===c.length?c+="..":c+="/..");return c.length>0?c+t.slice(n+h):(n+=h,47===t.charCodeAt(n)&&++n,t.slice(n))},_makeLong:function(A){return A},dirname:function(A){if(e(A),0===A.length)return".";for(var t=A.charCodeAt(0),s=47===t,i=-1,o=!0,r=A.length-1;r>=1;--r)if(47===(t=A.charCodeAt(r))){if(!o){i=r;break}}else o=!1;return-1===i?s?"/":".":s&&1===i?"//":A.slice(0,i)},basename:function(A,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');e(A);var s,i=0,o=-1,r=!0;if(void 0!==t&&t.length>0&&t.length<=A.length){if(t.length===A.length&&t===A)return"";var n=t.length-1,a=-1;for(s=A.length-1;s>=0;--s){var g=A.charCodeAt(s);if(47===g){if(!r){i=s+1;break}}else-1===a&&(r=!1,a=s+1),n>=0&&(g===t.charCodeAt(n)?-1==--n&&(o=s):(n=-1,o=a))}return i===o?o=a:-1===o&&(o=A.length),A.slice(i,o)}for(s=A.length-1;s>=0;--s)if(47===A.charCodeAt(s)){if(!r){i=s+1;break}}else-1===o&&(r=!1,o=s+1);return-1===o?"":A.slice(i,o)},extname:function(A){e(A);for(var t=-1,s=0,i=-1,o=!0,r=0,n=A.length-1;n>=0;--n){var a=A.charCodeAt(n);if(47!==a)-1===i&&(o=!1,i=n+1),46===a?-1===t?t=n:1!==r&&(r=1):-1!==t&&(r=-1);else if(!o){s=n+1;break}}return-1===t||-1===i||0===r||1===r&&t===i-1&&t===s+1?"":A.slice(t,i)},format:function(A){if(null===A||"object"!=typeof A)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof A);return function(A,e){var t=e.dir||e.root,s=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+s:t+A+s:s}("/",A)},parse:function(A){e(A);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===A.length)return t;var s,i=A.charCodeAt(0),o=47===i;o?(t.root="/",s=1):s=0;for(var r=-1,n=0,a=-1,g=!0,h=A.length-1,I=0;h>=s;--h)if(47!==(i=A.charCodeAt(h)))-1===a&&(g=!1,a=h+1),46===i?-1===r?r=h:1!==I&&(I=1):-1!==r&&(I=-1);else if(!g){n=h+1;break}return-1===r||-1===a||0===I||1===I&&r===a-1&&r===n+1?-1!==a&&(t.base=t.name=0===n&&o?A.slice(1,a):A.slice(n,a)):(0===n&&o?(t.name=A.slice(1,r),t.base=A.slice(1,a)):(t.name=A.slice(n,r),t.base=A.slice(n,a)),t.ext=A.slice(r,a)),n>0?t.dir=A.slice(0,n-1):o&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};s.posix=s,A.exports=s},381:e=>{"use strict";e.exports=A}},t={};function s(A){var i=t[A];if(void 0!==i)return i.exports;var o=t[A]={exports:{}};return e[A](o,o.exports,s),o.exports}s.d=(A,e)=>{for(var t in e)s.o(e,t)&&!s.o(A,t)&&Object.defineProperty(A,t,{enumerable:!0,get:e[t]})},s.o=(A,e)=>Object.prototype.hasOwnProperty.call(A,e),s.r=A=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(A,"__esModule",{value:!0})};var i={};return(()=>{"use strict";s.r(i),s.d(i,{InstancedOGC3DTile:()=>ie,InstancedTileLoader:()=>he,OGC3DTile:()=>WA,OcclusionCullingService:()=>t,TileLoader:()=>TA});var A=s(381);Math.PI,Math.PI;function e(A,e,t){return Math.max(e,Math.min(t,A))}class t{constructor(){this.cullMap=[],this.cullMaterial=new A.MeshBasicMaterial({vertexColors:!0}),this.cullMaterial.side=A.FrontSide,this.cullTarget=this.createCullTarget(),this.cullPixels=new Uint8Array(4*this.cullTarget.width*this.cullTarget.height)}setSide(A){this.cullMaterial.side=A}createCullTarget(){const e=new A.WebGLRenderTarget(Math.floor(.05*window.innerWidth),Math.floor(.05*window.innerHeight));return e.texture.format=A.RGBAFormat,e.texture.encoding=A.LinearEncoding,e.texture.minFilter=A.NearestFilter,e.texture.magFilter=A.NearestFilter,e.texture.generateMipmaps=!1,e.stencilBuffer=!1,e.depthBuffer=!0,e.depthTexture=new A.DepthTexture,e.depthTexture.format=A.DepthFormat,e.depthTexture.type=A.UnsignedShortType,e}update(A,t,s){let i=t.getRenderTarget(),o=A.overrideMaterial;A.overrideMaterial=this.cullMaterial,t.setRenderTarget(this.cullTarget),t.render(A,s),A.overrideMaterial=o,t.setRenderTarget(i),t.readRenderTargetPixels(this.cullTarget,0,0,this.cullTarget.width,this.cullTarget.height,this.cullPixels),this.cullMap=[];for(let A=0;A<this.cullPixels.length;A+=4){const t=e(this.cullPixels[A],0,255)<<16^e(this.cullPixels[A+1],0,255)<<8^e(this.cullPixels[A+2],0,255)<<0;this.cullMap[t]=!0}}hasID(A){return this.cullMap[A]}}class o{constructor(e){this.center=new A.Vector3(e[0],e[1],e[2]);var t=new A.Vector3(e[3],e[4],e[4]),s=new A.Vector3(e[6],e[7],e[8]),i=new A.Vector3(e[9],e[10],e[11]);this.halfWidth=t.length(),this.halfHeight=s.length(),this.halfDepth=i.length(),t.normalize(),s.normalize(),i.normalize(),this.sphere=new A.Sphere(this.center,Math.sqrt(this.halfWidth*this.halfWidth+this.halfHeight*this.halfHeight+this.halfDepth*this.halfDepth)),this.matrixToOBBCoordinateSystem=new A.Matrix3,this.matrixToOBBCoordinateSystem.set(t.x,t.y,t.z,s.x,s.y,s.z,i.x,i.y,i.z)}inFrustum(A){return A.intersectsSphere(this.sphere)}distanceToPoint(A){let e=A.clone();e.sub(this.center),e.applyMatrix3(this.matrixToOBBCoordinateSystem);let t=Math.max(0,Math.max(-this.halfWidth-e.x,e.x-this.halfWidth)),s=Math.max(0,Math.max(-this.halfHeight-e.y,e.y-this.halfHeight)),i=Math.max(0,Math.max(-this.halfDepth-e.z,e.z-this.halfDepth));return Math.sqrt(t*t+s*s+i*i)}}var r=s(852);function n(e,t){if(t===A.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===A.TriangleFanDrawMode||t===A.TriangleStripDrawMode){let s=e.getIndex();if(null===s){const A=[],t=e.getAttribute("position");if(void 0===t)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<t.count;e++)A.push(e);e.setIndex(A),s=e.getIndex()}const i=s.count-2,o=[];if(t===A.TriangleFanDrawMode)for(let A=1;A<=i;A++)o.push(s.getX(0)),o.push(s.getX(A)),o.push(s.getX(A+1));else for(let A=0;A<i;A++)A%2==0?(o.push(s.getX(A)),o.push(s.getX(A+1)),o.push(s.getX(A+2))):(o.push(s.getX(A+2)),o.push(s.getX(A+1)),o.push(s.getX(A)));o.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=e.clone();return r.setIndex(o),r.clearGroups(),r}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}class a extends A.Loader{constructor(A){super(A),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(A){return new C(A)})),this.register((function(A){return new f(A)})),this.register((function(A){return new m(A)})),this.register((function(A){return new w(A)})),this.register((function(A){return new E(A)})),this.register((function(A){return new d(A)})),this.register((function(A){return new Q(A)})),this.register((function(A){return new u(A)})),this.register((function(A){return new c(A)})),this.register((function(A){return new p(A)})),this.register((function(A){return new B(A)})),this.register((function(A){return new I(A)})),this.register((function(A){return new y(A)})),this.register((function(A){return new D(A)}))}load(e,t,s,i){const o=this;let r;r=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:A.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const n=function(A){i?i(A):console.error(A),o.manager.itemError(e),o.manager.itemEnd(e)},a=new A.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(A){try{o.parse(A,r,(function(A){t(A),o.manager.itemEnd(e)}),n)}catch(A){n(A)}}),s,n)}setDRACOLoader(A){return this.dracoLoader=A,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(A){return this.ktx2Loader=A,this}setMeshoptDecoder(A){return this.meshoptDecoder=A,this}register(A){return-1===this.pluginCallbacks.indexOf(A)&&this.pluginCallbacks.push(A),this}unregister(A){return-1!==this.pluginCallbacks.indexOf(A)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(A),1),this}parse(A,e,t,s){let i;const o={},r={},n=new TextDecoder;if("string"==typeof A)i=JSON.parse(A);else if(A instanceof ArrayBuffer){if(n.decode(new Uint8Array(A,0,4))===R){try{o[h.KHR_BINARY_GLTF]=new M(A)}catch(A){return void(s&&s(A))}i=JSON.parse(o[h.KHR_BINARY_GLTF].content)}else i=JSON.parse(n.decode(A))}else i=A;if(void 0===i.asset||i.asset.version[0]<2)return void(s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const a=new AA(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let A=0;A<this.pluginCallbacks.length;A++){const e=this.pluginCallbacks[A](a);r[e.name]=e,o[e.name]=!0}if(i.extensionsUsed)for(let A=0;A<i.extensionsUsed.length;++A){const e=i.extensionsUsed[A],t=i.extensionsRequired||[];switch(e){case h.KHR_MATERIALS_UNLIT:o[e]=new l;break;case h.KHR_DRACO_MESH_COMPRESSION:o[e]=new T(i,this.dracoLoader);break;case h.KHR_TEXTURE_TRANSFORM:o[e]=new F;break;case h.KHR_MESH_QUANTIZATION:o[e]=new L;break;default:t.indexOf(e)>=0&&void 0===r[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}a.setExtensions(o),a.setPlugins(r),a.parse(t,s)}parseAsync(A,e){const t=this;return new Promise((function(s,i){t.parse(A,e,s,i)}))}}function g(){let A={};return{get:function(e){return A[e]},add:function(e,t){A[e]=t},remove:function(e){delete A[e]},removeAll:function(){A={}}}}const h={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class I{constructor(A){this.parser=A,this.name=h.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const A=this.parser,e=this.parser.json.nodes||[];for(let t=0,s=e.length;t<s;t++){const s=e[t];s.extensions&&s.extensions[this.name]&&void 0!==s.extensions[this.name].light&&A._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let i=t.cache.get(s);if(i)return i;const o=t.json,r=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let n;const a=new A.Color(16777215);void 0!==r.color&&a.fromArray(r.color);const g=void 0!==r.range?r.range:0;switch(r.type){case"directional":n=new A.DirectionalLight(a),n.target.position.set(0,0,-1),n.add(n.target);break;case"point":n=new A.PointLight(a),n.distance=g;break;case"spot":n=new A.SpotLight(a),n.distance=g,r.spot=r.spot||{},r.spot.innerConeAngle=void 0!==r.spot.innerConeAngle?r.spot.innerConeAngle:0,r.spot.outerConeAngle=void 0!==r.spot.outerConeAngle?r.spot.outerConeAngle:Math.PI/4,n.angle=r.spot.outerConeAngle,n.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,n.target.position.set(0,0,-1),n.add(n.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+r.type)}return n.position.set(0,0,0),n.decay=2,Y(n,r),void 0!==r.intensity&&(n.intensity=r.intensity),n.name=t.createUniqueName(r.name||"light_"+e),i=Promise.resolve(n),t.cache.add(s,i),i}getDependency(A,e){if("light"===A)return this._loadLight(e)}createNodeAttachment(A){const e=this,t=this.parser,s=t.json.nodes[A],i=(s.extensions&&s.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(A){return t._getNodeRef(e.cache,i,A)}))}}class l{constructor(){this.name=h.KHR_MATERIALS_UNLIT}getMaterialType(){return A.MeshBasicMaterial}extendParams(e,t,s){const i=[];e.color=new A.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const A=o.baseColorFactor;e.color.fromArray(A),e.opacity=A[3]}void 0!==o.baseColorTexture&&i.push(s.assignTexture(e,"map",o.baseColorTexture,A.SRGBColorSpace))}return Promise.all(i)}}class c{constructor(A){this.parser=A,this.name=h.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(A,e){const t=this.parser.json.materials[A];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const s=t.extensions[this.name].emissiveStrength;return void 0!==s&&(e.emissiveIntensity=s),Promise.resolve()}}class C{constructor(A){this.parser=A,this.name=h.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];if(void 0!==r.clearcoatFactor&&(t.clearcoat=r.clearcoatFactor),void 0!==r.clearcoatTexture&&o.push(s.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),void 0!==r.clearcoatRoughnessFactor&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),void 0!==r.clearcoatRoughnessTexture&&o.push(s.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),void 0!==r.clearcoatNormalTexture&&(o.push(s.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),void 0!==r.clearcoatNormalTexture.scale)){const e=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new A.Vector2(e,e)}return Promise.all(o)}}class B{constructor(A){this.parser=A,this.name=h.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A.MeshPhysicalMaterial:null}extendMaterialParams(A,e){const t=this.parser,s=t.json.materials[A];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return void 0!==o.iridescenceFactor&&(e.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&i.push(t.assignTexture(e,"iridescenceMap",o.iridescenceTexture)),void 0!==o.iridescenceIor&&(e.iridescenceIOR=o.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==o.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),void 0!==o.iridescenceThicknessTexture&&i.push(t.assignTexture(e,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class E{constructor(A){this.parser=A,this.name=h.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new A.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];return void 0!==r.sheenColorFactor&&t.sheenColor.fromArray(r.sheenColorFactor),void 0!==r.sheenRoughnessFactor&&(t.sheenRoughness=r.sheenRoughnessFactor),void 0!==r.sheenColorTexture&&o.push(s.assignTexture(t,"sheenColorMap",r.sheenColorTexture,A.SRGBColorSpace)),void 0!==r.sheenRoughnessTexture&&o.push(s.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(o)}}class d{constructor(A){this.parser=A,this.name=h.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A.MeshPhysicalMaterial:null}extendMaterialParams(A,e){const t=this.parser,s=t.json.materials[A];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return void 0!==o.transmissionFactor&&(e.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&i.push(t.assignTexture(e,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class Q{constructor(A){this.parser=A,this.name=h.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];t.thickness=void 0!==r.thicknessFactor?r.thicknessFactor:0,void 0!==r.thicknessTexture&&o.push(s.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const n=r.attenuationColor||[1,1,1];return t.attenuationColor=new A.Color(n[0],n[1],n[2]),Promise.all(o)}}class u{constructor(A){this.parser=A,this.name=h.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A.MeshPhysicalMaterial:null}extendMaterialParams(A,e){const t=this.parser.json.materials[A];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const s=t.extensions[this.name];return e.ior=void 0!==s.ior?s.ior:1.5,Promise.resolve()}}class p{constructor(A){this.parser=A,this.name=h.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,i=s.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];t.specularIntensity=void 0!==r.specularFactor?r.specularFactor:1,void 0!==r.specularTexture&&o.push(s.assignTexture(t,"specularIntensityMap",r.specularTexture));const n=r.specularColorFactor||[1,1,1];return t.specularColor=new A.Color(n[0],n[1],n[2]),void 0!==r.specularColorTexture&&o.push(s.assignTexture(t,"specularColorMap",r.specularColorTexture,A.SRGBColorSpace)),Promise.all(o)}}class f{constructor(A){this.parser=A,this.name=h.KHR_TEXTURE_BASISU}loadTexture(A){const e=this.parser,t=e.json,s=t.textures[A];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],o=e.options.ktx2Loader;if(!o){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(A,i.source,o)}}class m{constructor(A){this.parser=A,this.name=h.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(A){const e=this.name,t=this.parser,s=t.json,i=s.textures[A];if(!i.extensions||!i.extensions[e])return null;const o=i.extensions[e],r=s.images[o.source];let n=t.textureLoader;if(r.uri){const A=t.options.manager.getHandler(r.uri);null!==A&&(n=A)}return this.detectSupport().then((function(i){if(i)return t.loadTextureImage(A,o.source,n);if(s.extensionsRequired&&s.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return t.loadTexture(A)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(A){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){A(1===e.height)}}))),this.isSupported}}class w{constructor(A){this.parser=A,this.name=h.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(A){const e=this.name,t=this.parser,s=t.json,i=s.textures[A];if(!i.extensions||!i.extensions[e])return null;const o=i.extensions[e],r=s.images[o.source];let n=t.textureLoader;if(r.uri){const A=t.options.manager.getHandler(r.uri);null!==A&&(n=A)}return this.detectSupport().then((function(i){if(i)return t.loadTextureImage(A,o.source,n);if(s.extensionsRequired&&s.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return t.loadTexture(A)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(A){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){A(1===e.height)}}))),this.isSupported}}class y{constructor(A){this.name=h.EXT_MESHOPT_COMPRESSION,this.parser=A}loadBufferView(A){const e=this.parser.json,t=e.bufferViews[A];if(t.extensions&&t.extensions[this.name]){const A=t.extensions[this.name],s=this.parser.getDependency("buffer",A.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.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 s.then((function(e){const t=A.byteOffset||0,s=A.byteLength||0,o=A.count,r=A.byteStride,n=new Uint8Array(e,t,s);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,r,n,A.mode,A.filter).then((function(A){return A.buffer})):i.ready.then((function(){const e=new ArrayBuffer(o*r);return i.decodeGltfBuffer(new Uint8Array(e),o,r,n,A.mode,A.filter),e}))}))}return null}}class D{constructor(A){this.name=h.EXT_MESH_GPU_INSTANCING,this.parser=A}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||void 0===s.mesh)return null;const i=t.meshes[s.mesh];for(const A of i.primitives)if(A.mode!==b.TRIANGLES&&A.mode!==b.TRIANGLE_STRIP&&A.mode!==b.TRIANGLE_FAN&&void 0!==A.mode)return null;const o=s.extensions[this.name].attributes,r=[],n={};for(const A in o)r.push(this.parser.getDependency("accessor",o[A]).then((e=>(n[A]=e,n[A]))));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then((e=>{const t=e.pop(),s=t.isGroup?t.children:[t],i=e[0].count,o=[];for(const e of s){const t=new A.Matrix4,s=new A.Vector3,r=new A.Quaternion,a=new A.Vector3(1,1,1),g=new A.InstancedMesh(e.geometry,e.material,i);for(let A=0;A<i;A++)n.TRANSLATION&&s.fromBufferAttribute(n.TRANSLATION,A),n.ROTATION&&r.fromBufferAttribute(n.ROTATION,A),n.SCALE&&a.fromBufferAttribute(n.SCALE,A),g.setMatrixAt(A,t.compose(s,r,a));for(const A in n)"TRANSLATION"!==A&&"ROTATION"!==A&&"SCALE"!==A&&e.geometry.setAttribute(A,n[A]);A.Object3D.prototype.copy.call(g,e),this.parser.assignFinalMaterial(g),o.push(g)}return t.isGroup?(t.clear(),t.add(...o),t):o[0]})))}}const R="glTF",S=1313821514,x=5130562;class M{constructor(A){this.name=h.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(A,0,12),t=new TextDecoder;if(this.header={magic:t.decode(new Uint8Array(A.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==R)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(A,12);let o=0;for(;o<s;){const e=i.getUint32(o,!0);o+=4;const s=i.getUint32(o,!0);if(o+=4,s===S){const s=new Uint8Array(A,12+o,e);this.content=t.decode(s)}else if(s===x){const t=12+o;this.body=A.slice(t,t+e)}o+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class T{constructor(A,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=h.KHR_DRACO_MESH_COMPRESSION,this.json=A,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(A,e){const t=this.json,s=this.dracoLoader,i=A.extensions[this.name].bufferView,o=A.extensions[this.name].attributes,r={},n={},a={};for(const A in o){const e=q[A]||A.toLowerCase();r[e]=o[A]}for(const e in A.attributes){const s=q[e]||e.toLowerCase();if(void 0!==o[e]){const i=t.accessors[A.attributes[e]],o=_[i.componentType];a[s]=o.name,n[s]=!0===i.normalized}}return e.getDependency("bufferView",i).then((function(A){return new Promise((function(e){s.decodeDracoFile(A,(function(A){for(const e in A.attributes){const t=A.attributes[e],s=n[e];void 0!==s&&(t.normalized=s)}e(A)}),r,a)}))}))}}class F{constructor(){this.name=h.KHR_TEXTURE_TRANSFORM}extendTexture(A,e){return void 0!==e.texCoord&&e.texCoord!==A.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(A=A.clone(),void 0!==e.texCoord&&(A.channel=e.texCoord),void 0!==e.offset&&A.offset.fromArray(e.offset),void 0!==e.rotation&&(A.rotation=e.rotation),void 0!==e.scale&&A.repeat.fromArray(e.scale),A.needsUpdate=!0,A):A}}class L{constructor(){this.name=h.KHR_MESH_QUANTIZATION}}class G extends A.Interpolant{constructor(A,e,t,s){super(A,e,t,s)}copySampleValue_(A){const e=this.resultBuffer,t=this.sampleValues,s=this.valueSize,i=A*s*3+s;for(let A=0;A!==s;A++)e[A]=t[i+A];return e}interpolate_(A,e,t,s){const i=this.resultBuffer,o=this.sampleValues,r=this.valueSize,n=2*r,a=3*r,g=s-e,h=(t-e)/g,I=h*h,l=I*h,c=A*a,C=c-a,B=-2*l+3*I,E=l-I,d=1-B,Q=E-I+h;for(let A=0;A!==r;A++){const e=o[C+A+r],t=o[C+A+n]*g,s=o[c+A+r],a=o[c+A]*g;i[A]=d*e+Q*t+B*s+E*a}return i}}const k=new A.Quaternion;class U extends G{interpolate_(A,e,t,s){const i=super.interpolate_(A,e,t,s);return k.fromArray(i).normalize().toArray(i),i}}const b={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},_={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},N={9728:A.NearestFilter,9729:A.LinearFilter,9984:A.NearestMipmapNearestFilter,9985:A.LinearMipmapNearestFilter,9986:A.NearestMipmapLinearFilter,9987:A.LinearMipmapLinearFilter},v={33071:A.ClampToEdgeWrapping,33648:A.MirroredRepeatWrapping,10497:A.RepeatWrapping},H={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"},J={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},O={CUBICSPLINE:void 0,LINEAR:A.InterpolateLinear,STEP:A.InterpolateDiscrete},P="OPAQUE",V="MASK",K="BLEND";function j(A,e,t){for(const s in t.extensions)void 0===A[s]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function Y(A,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(A.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function W(A,e){if(A.updateMorphTargets(),void 0!==e.weights)for(let t=0,s=e.weights.length;t<s;t++)A.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(A.morphTargetInfluences.length===t.length){A.morphTargetDictionary={};for(let e=0,s=t.length;e<s;e++)A.morphTargetDictionary[t[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function X(A){const e=A.extensions&&A.extensions[h.KHR_DRACO_MESH_COMPRESSION];let t;return t=e?"draco:"+e.bufferView+":"+e.indices+":"+z(e.attributes):A.indices+":"+z(A.attributes)+":"+A.mode,t}function z(A){let e="";const t=Object.keys(A).sort();for(let s=0,i=t.length;s<i;s++)e+=t[s]+":"+A[t[s]]+";";return e}function Z(A){switch(A){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const $=new A.Matrix4;class AA{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new g,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,i=!1,o=-1;"undefined"!=typeof navigator&&(s=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,o=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||s||i&&o<98?this.textureLoader=new A.TextureLoader(this.options.manager):this.textureLoader=new A.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new A.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(A){this.extensions=A}setPlugins(A){this.plugins=A}parse(A,e){const t=this,s=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(A){return A._markDefs&&A._markDefs()})),Promise.all(this._invokeAll((function(A){return A.beforeRoot&&A.beforeRoot()}))).then((function(){return Promise.all([t.getDependencies("scene"),t.getDependencies("animation"),t.getDependencies("camera")])})).then((function(e){const o={scene:e[0][s.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:s.asset,parser:t,userData:{}};j(i,o,s),Y(o,s),Promise.all(t._invokeAll((function(A){return A.afterRoot&&A.afterRoot(o)}))).then((function(){A(o)}))})).catch(e)}_markDefs(){const A=this.json.nodes||[],e=this.json.skins||[],t=this.json.meshes||[];for(let t=0,s=e.length;t<s;t++){const s=e[t].joints;for(let e=0,t=s.length;e<t;e++)A[s[e]].isBone=!0}for(let e=0,s=A.length;e<s;e++){const s=A[e];void 0!==s.mesh&&(this._addNodeRef(this.meshCache,s.mesh),void 0!==s.skin&&(t[s.mesh].isSkinnedMesh=!0)),void 0!==s.camera&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(A,e){void 0!==e&&(void 0===A.refs[e]&&(A.refs[e]=A.uses[e]=0),A.refs[e]++)}_getNodeRef(A,e,t){if(A.refs[e]<=1)return t;const s=t.clone(),i=(A,e)=>{const t=this.associations.get(A);null!=t&&this.associations.set(e,t);for(const[t,s]of A.children.entries())i(s,e.children[t])};return i(t,s),s.name+="_instance_"+A.uses[e]++,s}_invokeOne(A){const e=Object.values(this.plugins);e.push(this);for(let t=0;t<e.length;t++){const s=A(e[t]);if(s)return s}return null}_invokeAll(A){const e=Object.values(this.plugins);e.unshift(this);const t=[];for(let s=0;s<e.length;s++){const i=A(e[s]);i&&t.push(i)}return t}getDependency(A,e){const t=A+":"+e;let s=this.cache.get(t);if(!s){switch(A){case"scene":s=this.loadScene(e);break;case"node":s=this._invokeOne((function(A){return A.loadNode&&A.loadNode(e)}));break;case"mesh":s=this._invokeOne((function(A){return A.loadMesh&&A.loadMesh(e)}));break;case"accessor":s=this.loadAccessor(e);break;case"bufferView":s=this._invokeOne((function(A){return A.loadBufferView&&A.loadBufferView(e)}));break;case"buffer":s=this.loadBuffer(e);break;case"material":s=this._invokeOne((function(A){return A.loadMaterial&&A.loadMaterial(e)}));break;case"texture":s=this._invokeOne((function(A){return A.loadTexture&&A.loadTexture(e)}));break;case"skin":s=this.loadSkin(e);break;case"animation":s=this._invokeOne((function(A){return A.loadAnimation&&A.loadAnimation(e)}));break;case"camera":s=this.loadCamera(e);break;default:if(s=this._invokeOne((function(t){return t!=this&&t.getDependency&&t.getDependency(A,e)})),!s)throw new Error("Unknown type: "+A)}this.cache.add(t,s)}return s}getDependencies(A){let e=this.cache.get(A);if(!e){const t=this,s=this.json[A+("mesh"===A?"es":"s")]||[];e=Promise.all(s.map((function(e,s){return t.getDependency(A,s)}))),this.cache.add(A,e)}return e}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[h.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,o){s.load(A.LoaderUtils.resolveURL(t.uri,i.path),e,void 0,(function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(A){const e=this.json.bufferViews[A];return this.getDependency("buffer",e.buffer).then((function(A){const t=e.byteLength||0,s=e.byteOffset||0;return A.slice(s,s+t)}))}loadAccessor(e){const t=this,s=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse){const e=H[i.type],t=_[i.componentType],s=!0===i.normalized,o=new t(i.count*e);return Promise.resolve(new A.BufferAttribute(o,e,s))}const o=[];return void 0!==i.bufferView?o.push(this.getDependency("bufferView",i.bufferView)):o.push(null),void 0!==i.sparse&&(o.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(o).then((function(e){const o=e[0],r=H[i.type],n=_[i.componentType],a=n.BYTES_PER_ELEMENT,g=a*r,h=i.byteOffset||0,I=void 0!==i.bufferView?s.bufferViews[i.bufferView].byteStride:void 0,l=!0===i.normalized;let c,C;if(I&&I!==g){const e=Math.floor(h/I),s="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let g=t.cache.get(s);g||(c=new n(o,e*I,i.count*I/a),g=new A.InterleavedBuffer(c,I/a),t.cache.add(s,g)),C=new A.InterleavedBufferAttribute(g,r,h%I/a,l)}else c=null===o?new n(i.count*r):new n(o,h,i.count*r),C=new A.BufferAttribute(c,r,l);if(void 0!==i.sparse){const t=H.SCALAR,s=_[i.sparse.indices.componentType],a=i.sparse.indices.byteOffset||0,g=i.sparse.values.byteOffset||0,h=new s(e[1],a,i.sparse.count*t),I=new n(e[2],g,i.sparse.count*r);null!==o&&(C=new A.BufferAttribute(C.array.slice(),C.itemSize,C.normalized));for(let A=0,e=h.length;A<e;A++){const e=h[A];if(C.setX(e,I[A*r]),r>=2&&C.setY(e,I[A*r+1]),r>=3&&C.setZ(e,I[A*r+2]),r>=4&&C.setW(e,I[A*r+3]),r>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return C}))}loadTexture(A){const e=this.json,t=this.options,s=e.textures[A].source,i=e.images[s];let o=this.textureLoader;if(i.uri){const A=t.manager.getHandler(i.uri);null!==A&&(o=A)}return this.loadTextureImage(A,s,o)}loadTextureImage(e,t,s){const i=this,o=this.json,r=o.textures[e],n=o.images[t],a=(n.uri||n.bufferView)+":"+r.sampler;if(this.textureCache[a])return this.textureCache[a];const g=this.loadImageSource(t,s).then((function(t){t.flipY=!1,t.name=r.name||n.name||"",""===t.name&&"string"==typeof n.uri&&!1===n.uri.startsWith("data:image/")&&(t.name=n.uri);const s=(o.samplers||{})[r.sampler]||{};return t.magFilter=N[s.magFilter]||A.LinearFilter,t.minFilter=N[s.minFilter]||A.LinearMipmapLinearFilter,t.wrapS=v[s.wrapS]||A.RepeatWrapping,t.wrapT=v[s.wrapT]||A.RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=g,g}loadImageSource(e,t){const s=this,i=this.json,o=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((A=>A.clone()));const r=i.images[e],n=self.URL||self.webkitURL;let a=r.uri||"",g=!1;if(void 0!==r.bufferView)a=s.getDependency("bufferView",r.bufferView).then((function(A){g=!0;const e=new Blob([A],{type:r.mimeType});return a=n.createObjectURL(e),a}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(a).then((function(e){return new Promise((function(s,i){let r=s;!0===t.isImageBitmapLoader&&(r=function(e){const t=new A.Texture(e);t.needsUpdate=!0,s(t)}),t.load(A.LoaderUtils.resolveURL(e,o.path),r,void 0,i)}))})).then((function(A){var e;return!0===g&&n.revokeObjectURL(a),A.userData.mimeType=r.mimeType||((e=r.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"),A})).catch((function(A){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),A}));return this.sourceCache[e]=h,h}assignTexture(A,e,t,s){const i=this;return this.getDependency("texture",t.index).then((function(o){if(!o)return null;if(void 0!==t.texCoord&&t.texCoord>0&&((o=o.clone()).channel=t.texCoord),i.extensions[h.KHR_TEXTURE_TRANSFORM]){const A=void 0!==t.extensions?t.extensions[h.KHR_TEXTURE_TRANSFORM]:void 0;if(A){const e=i.associations.get(o);o=i.extensions[h.KHR_TEXTURE_TRANSFORM].extendTexture(o,A),i.associations.set(o,e)}}return void 0!==s&&(o.colorSpace=s),A[e]=o,o}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,o=void 0!==t.attributes.color,r=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new A.PointsMaterial,A.Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new A.LineBasicMaterial,A.Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,this.cache.add(e,t)),s=t}if(i||o||r){let A="ClonedMaterial:"+s.uuid+":";i&&(A+="derivative-tangents:"),o&&(A+="vertex-colors:"),r&&(A+="flat-shading:");let e=this.cache.get(A);e||(e=s.clone(),o&&(e.vertexColors=!0),r&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(A,e),this.associations.set(e,this.associations.get(s))),s=e}e.material=s}getMaterialType(){return A.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,o=s.materials[e];let r;const n={},a=[];if((o.extensions||{})[h.KHR_MATERIALS_UNLIT]){const A=i[h.KHR_MATERIALS_UNLIT];r=A.getMaterialType(),a.push(A.extendParams(n,o,t))}else{const s=o.pbrMetallicRoughness||{};if(n.color=new A.Color(1,1,1),n.opacity=1,Array.isArray(s.baseColorFactor)){const A=s.baseColorFactor;n.color.fromArray(A),n.opacity=A[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(n,"map",s.baseColorTexture,A.SRGBColorSpace)),n.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,n.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(n,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(n,"roughnessMap",s.metallicRoughnessTexture))),r=this._invokeOne((function(A){return A.getMaterialType&&A.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(A){return A.extendMaterialParams&&A.extendMaterialParams(e,n)}))))}!0===o.doubleSided&&(n.side=A.DoubleSide);const g=o.alphaMode||P;if(g===K?(n.transparent=!0,n.depthWrite=!1):(n.transparent=!1,g===V&&(n.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&r!==A.MeshBasicMaterial&&(a.push(t.assignTexture(n,"normalMap",o.normalTexture)),n.normalScale=new A.Vector2(1,1),void 0!==o.normalTexture.scale)){const A=o.normalTexture.scale;n.normalScale.set(A,A)}return void 0!==o.occlusionTexture&&r!==A.MeshBasicMaterial&&(a.push(t.assignTexture(n,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(n.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&r!==A.MeshBasicMaterial&&(n.emissive=(new A.Color).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&r!==A.MeshBasicMaterial&&a.push(t.assignTexture(n,"emissiveMap",o.emissiveTexture,A.SRGBColorSpace)),Promise.all(a).then((function(){const A=new r(n);return o.name&&(A.name=o.name),Y(A,o),t.associations.set(A,{materials:e}),o.extensions&&j(i,A,o),A}))}createUniqueName(e){const t=A.PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let A=1;this.nodeNamesUsed[s];++A)s=t+"_"+A;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function o(A){return s[h.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(A,t).then((function(e){return eA(e,A,t)}))}const r=[];for(let s=0,n=e.length;s<n;s++){const n=e[s],a=X(n),g=i[a];if(g)r.push(g.promise);else{let e;e=n.extensions&&n.extensions[h.KHR_DRACO_MESH_COMPRESSION]?o(n):eA(new A.BufferGeometry,n,t),i[a]={primitive:n,promise:e},r.push(e)}}return Promise.all(r)}loadMesh(e){const t=this,s=this.json,i=this.extensions,o=s.meshes[e],r=o.primitives,a=[];for(let e=0,t=r.length;e<t;e++){const t=void 0===r[e].material?(void 0===(g=this.cache).DefaultMaterial&&(g.DefaultMaterial=new A.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:A.FrontSide})),g.DefaultMaterial):this.getDependency("material",r[e].material);a.push(t)}var g;return a.push(t.loadGeometries(r)),Promise.all(a).then((function(s){const a=s.slice(0,s.length-1),g=s[s.length-1],h=[];for(let s=0,I=g.length;s<I;s++){const I=g[s],l=r[s];let c;const C=a[s];if(l.mode===b.TRIANGLES||l.mode===b.TRIANGLE_STRIP||l.mode===b.TRIANGLE_FAN||void 0===l.mode)c=!0===o.isSkinnedMesh?new A.SkinnedMesh(I,C):new A.Mesh(I,C),!0===c.isSkinnedMesh&&c.normalizeSkinWeights(),l.mode===b.TRIANGLE_STRIP?c.geometry=n(c.geometry,A.TriangleStripDrawMode):l.mode===b.TRIANGLE_FAN&&(c.geometry=n(c.geometry,A.TriangleFanDrawMode));else if(l.mode===b.LINES)c=new A.LineSegments(I,C);else if(l.mode===b.LINE_STRIP)c=new A.Line(I,C);else if(l.mode===b.LINE_LOOP)c=new A.LineLoop(I,C);else{if(l.mode!==b.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+l.mode);c=new A.Points(I,C)}Object.keys(c.geometry.morphAttributes).length>0&&W(c,o),c.name=t.createUniqueName(o.name||"mesh_"+e),Y(c,o),l.extensions&&j(i,c,l),t.assignFinalMaterial(c),h.push(c)}for(let A=0,s=h.length;A<s;A++)t.associations.set(h[A],{meshes:e,primitives:A});if(1===h.length)return h[0];const I=new A.Group;t.associations.set(I,{meshes:e});for(let A=0,e=h.length;A<e;A++)I.add(h[A]);return I}))}loadCamera(e){let t;const s=this.json.cameras[e],i=s[s.type];if(i)return"perspective"===s.type?t=new A.PerspectiveCamera(A.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===s.type&&(t=new A.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),Y(t,s),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],s=[];for(let A=0,e=t.joints.length;A<e;A++)s.push(this._loadNodeShallow(t.joints[A]));return void 0!==t.inverseBindMatrices?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then((function(e){const s=e.pop(),i=e,o=[],r=[];for(let e=0,n=i.length;e<n;e++){const n=i[e];if(n){o.push(n);const t=new A.Matrix4;null!==s&&t.fromArray(s.array,16*e),r.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new A.Skeleton(o,r)}))}loadAnimation(e){const t=this.json.animations[e],s=t.name?t.name:"animation_"+e,i=[],o=[],r=[],n=[],a=[];for(let A=0,e=t.channels.length;A<e;A++){const e=t.channels[A],s=t.samplers[e.sampler],g=e.target,h=g.node,I=void 0!==t.parameters?t.parameters[s.input]:s.input,l=void 0!==t.parameters?t.parameters[s.output]:s.output;void 0!==g.node&&(i.push(this.getDependency("node",h)),o.push(this.getDependency("accessor",I)),r.push(this.getDependency("accessor",l)),n.push(s),a.push(g))}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(r),Promise.all(n),Promise.all(a)]).then((function(e){const t=e[0],i=e[1],o=e[2],r=e[3],n=e[4],a=[];for(let e=0,s=t.length;e<s;e++){const s=t[e],g=i[e],h=o[e],I=r[e],l=n[e];if(void 0===s)continue;let c;switch(s.updateMatrix(),J[l.path]){case J.weights:c=A.NumberKeyframeTrack;break;case J.rotation:c=A.QuaternionKeyframeTrack;break;default:c=A.VectorKeyframeTrack}const C=s.name?s.name:s.uuid,B=void 0!==I.interpolation?O[I.interpolation]:A.InterpolateLinear,E=[];J[l.path]===J.weights?s.traverse((function(A){A.morphTargetInfluences&&E.push(A.name?A.name:A.uuid)})):E.push(C);let d=h.array;if(h.normalized){const A=Z(d.constructor),e=new Float32Array(d.length);for(let t=0,s=d.length;t<s;t++)e[t]=d[t]*A;d=e}for(let e=0,t=E.length;e<t;e++){const t=new c(E[e]+"."+J[l.path],g.array,d,B);"CUBICSPLINE"===I.interpolation&&(t.createInterpolant=function(e){return new(this instanceof A.QuaternionKeyframeTrack?U:G)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),a.push(t)}}return new A.AnimationClip(s,void 0,a)}))}createNodeMesh(A){const e=this.json,t=this,s=e.nodes[A];return void 0===s.mesh?null:t.getDependency("mesh",s.mesh).then((function(A){const e=t._getNodeRef(t.meshCache,s.mesh,A);return void 0!==s.weights&&e.traverse((function(A){if(A.isMesh)for(let e=0,t=s.weights.length;e<t;e++)A.morphTargetInfluences[e]=s.weights[e]})),e}))}loadNode(A){const e=this,t=this.json.nodes[A],s=e._loadNodeShallow(A),i=[],o=t.children||[];for(let A=0,t=o.length;A<t;A++)i.push(e.getDependency("node",o[A]));const r=void 0===t.skin?Promise.resolve(null):e.getDependency("skin",t.skin);return Promise.all([s,Promise.all(i),r]).then((function(A){const e=A[0],t=A[1],s=A[2];null!==s&&e.traverse((function(A){A.isSkinnedMesh&&A.bind(s,$)}));for(let A=0,s=t.length;A<s;A++)e.add(t[A]);return e}))}_loadNodeShallow(e){const t=this.json,s=this.extensions,i=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const o=t.nodes[e],r=o.name?i.createUniqueName(o.name):"",n=[],a=i._invokeOne((function(A){return A.createNodeMesh&&A.createNodeMesh(e)}));return a&&n.push(a),void 0!==o.camera&&n.push(i.getDependency("camera",o.camera).then((function(A){return i._getNodeRef(i.cameraCache,o.camera,A)}))),i._invokeAll((function(A){return A.createNodeAttachment&&A.createNodeAttachment(e)})).forEach((function(A){n.push(A)})),this.nodeCache[e]=Promise.all(n).then((function(t){let n;if(n=!0===o.isBone?new A.Bone:t.length>1?new A.Group:1===t.length?t[0]:new A.Object3D,n!==t[0])for(let A=0,e=t.length;A<e;A++)n.add(t[A]);if(o.name&&(n.userData.name=o.name,n.name=r),Y(n,o),o.extensions&&j(s,n,o),void 0!==o.matrix){const e=new A.Matrix4;e.fromArray(o.matrix),n.applyMatrix4(e)}else void 0!==o.translation&&n.position.fromArray(o.translation),void 0!==o.rotation&&n.quaternion.fromArray(o.rotation),void 0!==o.scale&&n.scale.fromArray(o.scale);return i.associations.has(n)||i.associations.set(n,{}),i.associations.get(n).nodes=e,n})),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],i=this,o=new A.Group;s.name&&(o.name=i.createUniqueName(s.name)),Y(o,s),s.extensions&&j(t,o,s);const r=s.nodes||[],n=[];for(let A=0,e=r.length;A<e;A++)n.push(i.getDependency("node",r[A]));return Promise.all(n).then((function(e){for(let A=0,t=e.length;A<t;A++)o.add(e[A]);return i.associations=(e=>{const t=new Map;for(const[e,s]of i.associations)(e instanceof A.Material||e instanceof A.Texture)&&t.set(e,s);return e.traverse((A=>{const e=i.associations.get(A);null!=e&&t.set(A,e)})),t})(o),o}))}}function eA(e,t,s){const i=t.attributes,o=[];function r(A,t){return s.getDependency("accessor",A).then((function(A){e.setAttribute(t,A)}))}for(const A in i){const t=q[A]||A.toLowerCase();t in e.attributes||o.push(r(i[A],t))}if(void 0!==t.indices&&!e.index){const A=s.getDependency("accessor",t.indices).then((function(A){e.setIndex(A)}));o.push(A)}return Y(e,t),function(e,t,s){const i=t.attributes,o=new A.Box3;if(void 0===i.POSITION)return;{const e=s.json.accessors[i.POSITION],t=e.min,r=e.max;if(void 0===t||void 0===r)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(o.set(new A.Vector3(t[0],t[1],t[2]),new A.Vector3(r[0],r[1],r[2])),e.normalized){const A=Z(_[e.componentType]);o.min.multiplyScalar(A),o.max.multiplyScalar(A)}}const r=t.targets;if(void 0!==r){const e=new A.Vector3,t=new A.Vector3;for(let A=0,i=r.length;A<i;A++){const i=r[A];if(void 0!==i.POSITION){const A=s.json.accessors[i.POSITION],o=A.min,r=A.max;if(void 0!==o&&void 0!==r){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(r[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(r[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(r[2]))),A.normalized){const e=Z(_[A.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(e)}e.boundingBox=o;const n=new A.Sphere;o.getCenter(n.center),n.radius=o.min.distanceTo(o.max)/2,e.boundingSphere=n}(e,t,s),Promise.all(o).then((function(){return void 0!==t.targets?function(A,e,t){let s=!1,i=!1,o=!1;for(let A=0,t=e.length;A<t;A++){const t=e[A];if(void 0!==t.POSITION&&(s=!0),void 0!==t.NORMAL&&(i=!0),void 0!==t.COLOR_0&&(o=!0),s&&i&&o)break}if(!s&&!i&&!o)return Promise.resolve(A);const r=[],n=[],a=[];for(let g=0,h=e.length;g<h;g++){const h=e[g];if(s){const e=void 0!==h.POSITION?t.getDependency("accessor",h.POSITION):A.attributes.position;r.push(e)}if(i){const e=void 0!==h.NORMAL?t.getDependency("accessor",h.NORMAL):A.attributes.normal;n.push(e)}if(o){const e=void 0!==h.COLOR_0?t.getDependency("accessor",h.COLOR_0):A.attributes.color;a.push(e)}}return Promise.all([Promise.all(r),Promise.all(n),Promise.all(a)]).then((function(e){const t=e[0],r=e[1],n=e[2];return s&&(A.morphAttributes.position=t),i&&(A.morphAttributes.normal=r),o&&(A.morphAttributes.color=n),A.morphTargetsRelative=!0,A}))}(e,t.targets,s):e}))}const tA=new WeakMap;class sA extends A.Loader{constructor(A){super(A),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(A){return this.decoderPath=A,this}setDecoderConfig(A){return this.decoderConfig=A,this}setWorkerLimit(A){return this.workerLimit=A,this}load(e,t,s,i){const o=new A.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(A=>{this.parse(A,t,i)}),s,i)}parse(e,t,s){this.decodeDracoFile(e,t,null,null,A.SRGBColorSpace).catch(s)}decodeDracoFile(e,t,s,i,o=A.LinearSRGBColorSpace){const r={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:o};return this.decodeGeometry(e,r).then(t)}decodeGeometry(A,e){const t=JSON.stringify(e);if(tA.has(A)){const e=tA.get(A);if(e.key===t)return e.promise;if(0===A.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const i=this.workerNextTaskID++,o=A.byteLength,r=this._getWorker(i,o).then((t=>(s=t,new Promise(((t,o)=>{s._callbacks[i]={resolve:t,reject:o},s.postMessage({type:"decode",id:i,taskConfig:e,buffer:A},[A])}))))).then((A=>this._createGeometry(A.geometry)));return r.catch((()=>!0)).then((()=>{s&&i&&this._releaseTask(s,i)})),tA.set(A,{key:t,promise:r}),r}_createGeometry(e){const t=new A.BufferGeometry;e.index&&t.setIndex(new A.BufferAttribute(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const i=e.attributes[s],o=i.name,r=i.array,n=i.itemSize,a=new A.BufferAttribute(r,n);"color"===o&&this._assignVertexColorSpace(a,i.vertexColorSpace),t.setAttribute(o,a)}return t}_assignVertexColorSpace(e,t){if(t!==A.SRGBColorSpace)return;const s=new A.Color;for(let A=0,t=e.count;A<t;A++)s.fromBufferAttribute(e,A).convertSRGBToLinear(),e.setXYZ(A,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new A.FileLoader(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise(((A,t)=>{s.load(e,A,void 0,t)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const A="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return A?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((e=>{const t=e[0];A||(this.decoderConfig.wasmBinary=e[1]);const s=iA.toString(),i=["/* draco decoder */",t,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))})),this.decoderPending}_getWorker(A,e){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const A=new Worker(this.workerSourceURL);A._callbacks={},A._taskCosts={},A._taskLoad=0,A.postMessage({type:"init",decoderConfig:this.decoderConfig}),A.onmessage=function(e){const t=e.data;switch(t.type){case"decode":A._callbacks[t.id].resolve(t);break;case"error":A._callbacks[t.id].reject(t);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+t.type+'"')}},this.workerPool.push(A)}else this.workerPool.sort((function(A,e){return A._taskLoad>e._taskLoad?-1:1}));const t=this.workerPool[this.workerPool.length-1];return t._taskCosts[A]=e,t._taskLoad+=e,t}))}_releaseTask(A,e){A._taskLoad-=A._taskCosts[e],delete A._callbacks[e],delete A._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map((A=>A._taskLoad)))}dispose(){for(let A=0;A<this.workerPool.length;++A)this.workerPool[A].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function iA(){let A,e;function t(A,e,t,s,i,o){const r=o.num_components(),n=t.num_points()*r,a=n*i.BYTES_PER_ELEMENT,g=function(A,e){switch(e){case Float32Array:return A.DT_FLOAT32;case Int8Array:return A.DT_INT8;case Int16Array:return A.DT_INT16;case Int32Array:return A.DT_INT32;case Uint8Array:return A.DT_UINT8;case Uint16Array:return A.DT_UINT16;case Uint32Array:return A.DT_UINT32}}(A,i),h=A._malloc(a);e.GetAttributeDataArrayForAllPoints(t,o,g,a,h);const I=new i(A.HEAPF32.buffer,h,n).slice();return A._free(h),{name:s,array:I,itemSize:r}}onmessage=function(s){const i=s.data;switch(i.type){case"init":A=i.decoderConfig,e=new Promise((function(e){A.onModuleLoaded=function(A){e({draco:A})},DracoDecoderModule(A)}));break;case"decode":const s=i.buffer,o=i.taskConfig;e.then((A=>{const e=A.draco,r=new e.Decoder;try{const A=function(A,e,s,i){const o=i.attributeIDs,r=i.attributeTypes;let n,a;const g=e.GetEncodedGeometryType(s);if(g===A.TRIANGULAR_MESH)n=new A.Mesh,a=e.DecodeArrayToMesh(s,s.byteLength,n);else{if(g!==A.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");n=new A.PointCloud,a=e.DecodeArrayToPointCloud(s,s.byteLength,n)}if(!a.ok()||0===n.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+a.error_msg());const h={index:null,attributes:[]};for(const s in o){const a=self[r[s]];let g,I;if(i.useUniqueIDs)I=o[s],g=e.GetAttributeByUniqueId(n,I);else{if(I=e.GetAttributeId(n,A[o[s]]),-1===I)continue;g=e.GetAttribute(n,I)}const l=t(A,e,n,s,a,g);"color"===s&&(l.vertexColorSpace=i.vertexColorSpace),h.attributes.push(l)}g===A.TRIANGULAR_MESH&&(h.index=function(A,e,t){const s=t.num_faces(),i=3*s,o=4*i,r=A._malloc(o);e.GetTrianglesUInt32Array(t,o,r);const n=new Uint32Array(A.HEAPF32.buffer,r,i).slice();return A._free(r),{array:n,itemSize:1}}(A,e,n));return A.destroy(n),h}(e,r,new Int8Array(s),o),n=A.attributes.map((A=>A.array.buffer));A.index&&n.push(A.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:A},n)}catch(A){console.error(A),self.postMessage({type:"error",id:i.id,error:A.message})}finally{e.destroy(r)}}))}}}class oA{constructor(A=4){this.pool=A,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(A){if(!this.workers[A]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,A)),this.workers[A]=e}}_getIdleWorker(){for(let A=0;A<this.pool;A++)if(!(this.workerStatus&1<<A))return A;return-1}_onMessage(A,e){const t=this.workersResolve[A];if(t&&t(e),this.queue.length){const{resolve:e,msg:t,transfer:s}=this.queue.shift();this.workersResolve[A]=e,this.workers[A].postMessage(t,s)}else this.workerStatus^=1<<A}setWorkerCreator(A){this.workerCreator=A}setWorkerLimit(A){this.pool=A}postMessage(A,e){return new Promise((t=>{const s=this._getIdleWorker();-1!==s?(this._initWorker(s),this.workerStatus|=1<<s,this.workersResolve[s]=t,this.workers[s].postMessage(A,e)):this.queue.push({resolve:t,msg:A,transfer:e})}))}dispose(){this.workers.forEach((A=>A.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}class rA{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class nA{constructor(A,e,t,s){this._dataView=new DataView(A.buffer,A.byteOffset+e,t),this._littleEndian=s,this._offset=0}_nextUint8(){const A=this._dataView.getUint8(this._offset);return this._offset+=1,A}_nextUint16(){const A=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,A}_nextUint32(){const A=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,A}_nextUint64(){const A=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,A}_nextInt32(){const A=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,A}_skip(A){return this._offset+=A,this}_scan(A,e=0){const t=this._offset;let s=0;for(;this._dataView.getUint8(this._offset)!==e&&s<A;)s++,this._offset++;return s<A&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+t,s)}}new Uint8Array([0]);const aA=[171,75,84,88,32,50,48,187,13,10,26,10];function gA(A){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(A):Buffer.from(A).toString("utf8")}let hA,IA,lA;const cA={env:{emscripten_notify_memory_growth:function(A){lA=new Uint8Array(IA.exports.memory.buffer)}}};class CA{init(){return hA||(hA="undefined"!=typeof fetch?fetch("data:application/wasm;base64,"+BA).then((A=>A.arrayBuffer())).then((A=>WebAssembly.instantiate(A,cA))).then(this._init):WebAssembly.instantiate(Buffer.from(BA,"base64"),cA).then(this._init),hA)}_init(A){IA=A.instance,cA.env.emscripten_notify_memory_growth(0)}decode(A,e=0){if(!IA)throw new Error("ZSTDDecoder: Await .init() before decoding.");const t=A.byteLength,s=IA.exports.malloc(t);lA.set(A,s),e=e||Number(IA.exports.ZSTD_findDecompressedSize(s,t));const i=IA.exports.malloc(e),o=IA.exports.ZSTD_decompress(i,e,s,t),r=lA.slice(i,i+o);return IA.exports.free(s),IA.exports.free(i),r}}const BA="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEh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AsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQ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ABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0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BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8L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gAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",EA=new WeakMap;let dA,QA=0;class uA extends A.Loader{constructor(A){super(A),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new oA,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(A){return this.transcoderPath=A,this}setWorkerLimit(A){return this.workerPool.setWorkerLimit(A),this}detectSupport(A){return!0===A.isWebGPURenderer?this.workerConfig={astcSupported:A.hasFeature("texture-compression-astc"),etc1Supported:!1,etc2Supported:A.hasFeature("texture-compression-etc2"),dxtSupported:A.hasFeature("texture-compression-bc"),bptcSupported:!1,pvrtcSupported:!1}:(this.workerConfig={astcSupported:A.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:A.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:A.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:A.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:A.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:A.extensions.has("WEBGL_compressed_texture_pvrtc")||A.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},A.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1)),this}init(){if(!this.transcoderPending){const e=new A.FileLoader(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),s=new A.FileLoader(this.manager);s.setPath(this.transcoderPath),s.setResponseType("arraybuffer"),s.setWithCredentials(this.withCredentials);const i=s.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,i]).then((([A,e])=>{const t=uA.BasisWorker.toString(),s=["/* constants */","let _EngineFormat = "+JSON.stringify(uA.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(uA.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(uA.BasisFormat),"/* basis_transcoder.js */",A,"/* worker */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([s])),this.transcoderBinary=e,this.workerPool.setWorkerCreator((()=>{const A=new Worker(this.workerSourceURL),e=this.transcoderBinary.slice(0);return A.postMessage({type:"init",config:this.workerConfig,transcoderBinary:e},[e]),A}))})),QA>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),QA++}return this.transcoderPending}load(e,t,s,i){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const o=new A.FileLoader(this.manager);o.setResponseType("arraybuffer"),o.setWithCredentials(this.withCredentials),o.load(e,(A=>{if(EA.has(A)){return EA.get(A).promise.then(t).catch(i)}this._createTexture(A).then((A=>t?t(A):null)).catch(i)}),s,i)}_createTextureFrom(e,t){const{mipmaps:s,width:i,height:o,format:r,type:n,error:a,dfdTransferFn:g,dfdFlags:h}=e;if("error"===n)return Promise.reject(a);const I=t.layerCount>1?new A.CompressedArrayTexture(s,i,o,t.layerCount,r,A.UnsignedByteType):new A.CompressedTexture(s,i,o,r,A.UnsignedByteType);return I.minFilter=1===s.length?A.LinearFilter:A.LinearMipmapLinearFilter,I.magFilter=A.LinearFilter,I.generateMipmaps=!1,I.needsUpdate=!0,I.colorSpace=2===g?A.SRGBColorSpace:A.NoColorSpace,I.premultiplyAlpha=!!(1&h),I}async _createTexture(e,t={}){const s=function(A){const e=new Uint8Array(A.buffer,A.byteOffset,aA.length);if(e[0]!==aA[0]||e[1]!==aA[1]||e[2]!==aA[2]||e[3]!==aA[3]||e[4]!==aA[4]||e[5]!==aA[5]||e[6]!==aA[6]||e[7]!==aA[7]||e[8]!==aA[8]||e[9]!==aA[9]||e[10]!==aA[10]||e[11]!==aA[11])throw new Error("Missing KTX 2.0 identifier.");const t=new rA,s=17*Uint32Array.BYTES_PER_ELEMENT,i=new nA(A,aA.length,s,!0);t.vkFormat=i._nextUint32(),t.typeSize=i._nextUint32(),t.pixelWidth=i._nextUint32(),t.pixelHeight=i._nextUint32(),t.pixelDepth=i._nextUint32(),t.layerCount=i._nextUint32(),t.faceCount=i._nextUint32();const o=i._nextUint32();t.supercompressionScheme=i._nextUint32();const r=i._nextUint32(),n=i._nextUint32(),a=i._nextUint32(),g=i._nextUint32(),h=i._nextUint64(),I=i._nextUint64(),l=new nA(A,aA.length+s,3*o*8,!0);for(let e=0;e<o;e++)t.levels.push({levelData:new Uint8Array(A.buffer,A.byteOffset+l._nextUint64(),l._nextUint64()),uncompressedByteLength:l._nextUint64()});const c=new nA(A,r,n,!0),C={vendorId:c._skip(4)._nextUint16(),descriptorType:c._nextUint16(),versionNumber:c._nextUint16(),descriptorBlockSize:c._nextUint16(),colorModel:c._nextUint8(),colorPrimaries:c._nextUint8(),transferFunction:c._nextUint8(),flags:c._nextUint8(),texelBlockDimension:[c._nextUint8(),c._nextUint8(),c._nextUint8(),c._nextUint8()],bytesPlane:[c._nextUint8(),c._nextUint8(),c._nextUint8(),c._nextUint8(),c._nextUint8(),c._nextUint8(),c._nextUint8(),c._nextUint8()],samples:[]},B=(C.descriptorBlockSize/4-6)/4;for(let A=0;A<B;A++){const e={bitOffset:c._nextUint16(),bitLength:c._nextUint8(),channelType:c._nextUint8(),samplePosition:[c._nextUint8(),c._nextUint8(),c._nextUint8(),c._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&e.channelType?(e.sampleLower=c._nextInt32(),e.sampleUpper=c._nextInt32()):(e.sampleLower=c._nextUint32(),e.sampleUpper=c._nextUint32()),C.samples[A]=e}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(C);const E=new nA(A,a,g,!0);for(;E._offset<g;){const A=E._nextUint32(),e=E._scan(A),s=gA(e),i=E._scan(A-e.byteLength);t.keyValue[s]=s.match(/^ktx/i)?gA(i):i,E._offset%4&&E._skip(4-E._offset%4)}if(I<=0)return t;const d=new nA(A,h,I,!0),Q=d._nextUint16(),u=d._nextUint16(),p=d._nextUint32(),f=d._nextUint32(),m=d._nextUint32(),w=d._nextUint32(),y=[];for(let A=0;A<o;A++)y.push({imageFlags:d._nextUint32(),rgbSliceByteOffset:d._nextUint32(),rgbSliceByteLength:d._nextUint32(),alphaSliceByteOffset:d._nextUint32(),alphaSliceByteLength:d._nextUint32()});const D=h+d._offset,R=D+p,S=R+f,x=S+m,M=new Uint8Array(A.buffer,A.byteOffset+D,p),T=new Uint8Array(A.buffer,A.byteOffset+R,f),F=new Uint8Array(A.buffer,A.byteOffset+S,m),L=new Uint8Array(A.buffer,A.byteOffset+x,w);return t.globalData={endpointCount:Q,selectorCount:u,imageDescs:y,endpointsData:M,selectorsData:T,tablesData:F,extendedData:L},t}(new Uint8Array(e));if(0!==s.vkFormat)return async function(e){const{vkFormat:t,pixelWidth:s,pixelHeight:i,pixelDepth:o}=e;if(void 0===pA[t])throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");const r=e.levels[0];let n,a;if(0===e.supercompressionScheme)n=r.levelData;else{if(2!==e.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");dA||(dA=new Promise((async A=>{const e=new CA;await e.init(),A(e)}))),n=(await dA).decode(r.levelData,r.uncompressedByteLength)}a=fA[t]===A.FloatType?new Float32Array(n.buffer,n.byteOffset,n.byteLength/Float32Array.BYTES_PER_ELEMENT):fA[t]===A.HalfFloatType?new Uint16Array(n.buffer,n.byteOffset,n.byteLength/Uint16Array.BYTES_PER_ELEMENT):n;const g=0===o?new A.DataTexture(a,s,i):new A.Data3DTexture(a,s,i,o);return g.type=fA[t],g.format=pA[t],g.colorSpace=mA[t]||A.NoColorSpace,g.needsUpdate=!0,Promise.resolve(g)}(s);const i=t,o=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:i},[e]))).then((A=>this._createTextureFrom(A.data,s)));return EA.set(e,{promise:o}),o}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),QA--,this}}uA.BasisFormat={ETC1S:0,UASTC_4x4:1},uA.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},uA.EngineFormat={RGBAFormat:A.RGBAFormat,RGBA_ASTC_4x4_Format:A.RGBA_ASTC_4x4_Format,RGBA_BPTC_Format:A.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:A.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:A.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:A.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:A.RGB_ETC1_Format,RGB_ETC2_Format:A.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:A.RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:A.RGB_S3TC_DXT1_Format},uA.BasisWorker=function(){let A,e,t;const s=_EngineFormat,i=_TranscoderFormat,o=_BasisFormat;self.addEventListener("message",(function(r){const I=r.data;switch(I.type){case"init":A=I.config,l=I.transcoderBinary,e=new Promise((A=>{t={wasmBinary:l,onRuntimeInitialized:A},BASIS(t)})).then((()=>{t.initializeBasis(),void 0===t.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":e.then((()=>{try{const{width:e,height:r,hasAlpha:l,mipmaps:c,format:C,dfdTransferFn:B,dfdFlags:E}=function(e){const r=new t.KTX2File(new Uint8Array(e));function I(){r.close(),r.delete()}if(!r.isValid())throw I(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const l=r.isUASTC()?o.UASTC_4x4:o.ETC1S,c=r.getWidth(),C=r.getHeight(),B=r.getLayers()||1,E=r.getLevels(),d=r.getHasAlpha(),Q=r.getDFDTransferFunc(),u=r.getDFDFlags(),{transcoderFormat:p,engineFormat:f}=function(e,t,r,h){let I,l;const c=e===o.ETC1S?n:a;for(let s=0;s<c.length;s++){const i=c[s];if(A[i.if]&&(i.basisFormat.includes(e)&&!(h&&i.transcoderFormat.length<2)&&(!i.needsPowerOfTwo||g(t)&&g(r))))return I=i.transcoderFormat[h?1:0],l=i.engineFormat[h?1:0],{transcoderFormat:I,engineFormat:l}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),I=i.RGBA32,l=s.RGBAFormat,{transcoderFormat:I,engineFormat:l}}(l,c,C,d);if(!c||!C||!E)throw I(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!r.startTranscoding())throw I(),new Error("THREE.KTX2Loader: .startTranscoding failed");const m=[];for(let A=0;A<E;A++){const e=[];let t,s;for(let i=0;i<B;i++){const o=r.getImageLevelInfo(A,i,0);t=o.origWidth<4?o.origWidth:o.width,s=o.origHeight<4?o.origHeight:o.height;const n=new Uint8Array(r.getImageTranscodedSizeInBytes(A,i,0,p));if(!r.transcodeImage(n,A,i,0,p,0,-1,-1))throw I(),new Error("THREE.KTX2Loader: .transcodeImage failed.");e.push(n)}m.push({data:h(e),width:t,height:s})}return I(),{width:c,height:C,hasAlpha:d,mipmaps:m,format:f,dfdTransferFn:Q,dfdFlags:u}}(I.buffer),d=[];for(let A=0;A<c.length;++A)d.push(c[A].data.buffer);self.postMessage({type:"transcode",id:I.id,width:e,height:r,hasAlpha:l,mipmaps:c,format:C,dfdTransferFn:B,dfdFlags:E},d)}catch(A){console.error(A),self.postMessage({type:"error",id:I.id,error:A.message})}}))}var l}));const r=[{if:"astcSupported",basisFormat:[o.UASTC_4x4],transcoderFormat:[i.ASTC_4x4,i.ASTC_4x4],engineFormat:[s.RGBA_ASTC_4x4_Format,s.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[o.ETC1S,o.UASTC_4x4],transcoderFormat:[i.BC7_M5,i.BC7_M5],engineFormat:[s.RGBA_BPTC_Format,s.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[o.ETC1S,o.UASTC_4x4],transcoderFormat:[i.BC1,i.BC3],engineFormat:[s.RGB_S3TC_DXT1_Format,s.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[o.ETC1S,o.UASTC_4x4],transcoderFormat:[i.ETC1,i.ETC2],engineFormat:[s.RGB_ETC2_Format,s.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[o.ETC1S,o.UASTC_4x4],transcoderFormat:[i.ETC1],engineFormat:[s.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[o.ETC1S,o.UASTC_4x4],transcoderFormat:[i.PVRTC1_4_RGB,i.PVRTC1_4_RGBA],engineFormat:[s.RGB_PVRTC_4BPPV1_Format,s.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],n=r.sort((function(A,e){return A.priorityETC1S-e.priorityETC1S})),a=r.sort((function(A,e){return A.priorityUASTC-e.priorityUASTC}));function g(A){return A<=2||0==(A&A-1)&&0!==A}function h(A){let e=0;for(let t=0;t<A.length;t++){e+=A[t].byteLength}const t=new Uint8Array(e);let s=0;for(let e=0;e<A.length;e++){const i=A[e];t.set(i,s),s+=i.byteLength}return t}};const pA={109:A.RGBAFormat,97:A.RGBAFormat,37:A.RGBAFormat,43:A.RGBAFormat,103:A.RGFormat,83:A.RGFormat,16:A.RGFormat,22:A.RGFormat,100:A.RedFormat,76:A.RedFormat,15:A.RedFormat,9:A.RedFormat},fA={109:A.FloatType,97:A.HalfFloatType,37:A.UnsignedByteType,43:A.UnsignedByteType,103:A.FloatType,83:A.HalfFloatType,16:A.UnsignedByteType,22:A.UnsignedByteType,100:A.FloatType,76:A.HalfFloatType,15:A.UnsignedByteType,9:A.UnsignedByteType},mA={43:A.SRGBColorSpace,22:A.SRGBColorSpace,15:A.SRGBColorSpace};const wA=new TextDecoder;class yA{constructor(A,e,t,s){this.buffer=A,this.binOffset=e+t,this.binLength=s;let i=null;if(0!==t)try{const s=new Uint8Array(A,e,t);i=JSON.parse(wA.decode(s))}catch(A){i={}}else i={};this.header=i}getKeys(){return Object.keys(this.header)}getData(A,e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const i=this.header;if(!(A in i))return null;const o=i[A];if(o instanceof Object){if(Array.isArray(o))return o;{const{buffer:i,binOffset:r,binLength:n}=this,a=o.byteOffset||0,g=o.type||s,h=o.componentType||t;if("type"in o&&s&&o.type!==s)throw new Error("FeatureTable: Specified type does not match expected type.");let I,l;switch(g){case"SCALAR":I=1;break;case"VEC2":I=2;break;case"VEC3":I=3;break;case"VEC4":I=4;break;default:throw new Error('FeatureTable : Feature type not provided for "'.concat(A,'".'))}const c=r+a,C=e*I;switch(h){case"BYTE":l=new Int8Array(i,c,C);break;case"UNSIGNED_BYTE":l=new Uint8Array(i,c,C);break;case"SHORT":l=new Int16Array(i,c,C);break;case"UNSIGNED_SHORT":l=new Uint16Array(i,c,C);break;case"INT":l=new Int32Array(i,c,C);break;case"UNSIGNED_INT":l=new Uint32Array(i,c,C);break;case"FLOAT":l=new Float32Array(i,c,C);break;case"DOUBLE":l=new Float64Array(i,c,C);break;default:throw new Error('FeatureTable : Feature component type not provided for "'.concat(A,'".'))}if(c+C*l.BYTES_PER_ELEMENT>r+n)throw new Error("FeatureTable: Feature data read outside binary body length.");return l}}return o}}class DA extends yA{constructor(A,e,t,s,i){super(A,t,s,i),this.batchSize=e}getData(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return super.getData(A,this.batchSize,e,t)}}const RA=new A.Matrix4;RA.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);class SA{constructor(e){this.gltfLoader=new a;const t=new sA;if(t.setDecoderPath("draco-decoders/"),this.gltfLoader.setDRACOLoader(t),e){const A=new uA;A.setTranscoderPath("ktx2-decoders/").detectSupport(e),this.gltfLoader.setKTX2Loader(A)}this.tempMatrix=new A.Matrix4}parseB3DM(A,e,t,s){const i=new DataView(A),o=String.fromCharCode(i.getUint8(0))+String.fromCharCode(i.getUint8(1))+String.fromCharCode(i.getUint8(2))+String.fromCharCode(i.getUint8(3));console.assert("b3dm"===o);const r=i.getUint32(8,!0);console.assert(r===A.byteLength);const n=i.getUint32(12,!0),a=i.getUint32(16,!0),g=i.getUint32(20,!0),h=i.getUint32(24,!0),I=new yA(A,28,n,a),l=28+n+a,c=(new DA(A,I.getData("BATCH_LENGTH"),l,g,h),l+g+h),C=new Uint8Array(A,c,r-c).slice().buffer;return new Promise(((A,i)=>{this.gltfLoader.parse(C,null,(i=>{const o=I.getData("RTC_CENTER");o?(this.tempMatrix.makeTranslation(o[0],o[1],o[2]),i.scene.applyMatrix4(this.tempMatrix)):i.userData.gltfExtensions&&i.userData.gltfExtensions.CESIUM_RTC&&(this.tempMatrix.makeTranslation(i.userData.gltfExtensions.CESIUM_RTC.center[0],i.userData.gltfExtensions.CESIUM_RTC.center[1],i.userData.gltfExtensions.CESIUM_RTC.center[2]),i.scene.applyMatrix4(this.tempMatrix)),s||i.scene.applyMatrix4(RA),i.scene.traverse((A=>{A.isMesh&&(A.geometricError=t,s&&A.applyMatrix4(RA),e&&e(A))})),A(i.scene)}),(A=>{console.error(A)}))}))}parseB3DMInstanced(e,t,s,i){return this.parseB3DM(e,t,i).then((e=>{let t;return e.updateWorldMatrix(!1,!0),e.traverse((e=>{e.isMesh&&(t=new A.InstancedMesh(e.geometry,e.material,s),t.baseMatrix=e.matrixWorld)})),t}))}}let xA=0;const MA=new A.Matrix4;MA.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);class TA{constructor(A){this.maxCachedItems=100,this.proxy=A.proxy,A&&(this.meshCallback=A.meshCallback,this.pointsCallback=A.pointsCallback,A.maxCachedItems&&(this.maxCachedItems=A.maxCachedItems)),this.gltfLoader=new a;const e=new sA;if(e.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),this.gltfLoader.setDRACOLoader(e),A&&A.renderer){const e=new uA;e.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(A.renderer),this.gltfLoader.setKTX2Loader(e),this.b3dmDecoder=new SA(A.renderer)}else this.b3dmDecoder=new SA(null);this.cache=new r.LinkedHashMap,this.register={},this.ready=[],this.downloads=[],this.nextReady=[],this.nextDownloads=[],this.init()}init(){const A=this;FA((()=>{A.download()}),10),FA((()=>{const e=Date.now();let t=0;do{t=A.loadBatch()}while(t>0&&Date.now()-e<=0)}),10)}scheduleDownload(A){this.downloads.unshift(A)}download(){if(0!=this.nextDownloads.length||(this.getNextDownloads(),0!=this.nextDownloads.length))for(;this.nextDownloads.length>0&&xA<500;){const A=this.nextDownloads.shift();A&&A.shouldDoDownload()&&A.doDownload()}}meshReceived(A,e,t,s,i,o,r){this.ready.unshift([A,e,t,s,i,o,r])}loadBatch(){if(0==this.nextReady.length&&(this.getNextReady(),0==this.nextReady.length))return 0;const A=this.nextReady.shift();if(!A)return 0;const e=A[0],t=A[1],s=A[2],i=e.get(s);return i&&t[s]&&Object.keys(t[s]).forEach((A=>{const e=t[s][A];e&&(e(i),t[s][A]=null)})),1}getNextDownloads(){let A=Number.MAX_VALUE,e=-1;for(let A=this.downloads.length-1;A>=0;A--)this.downloads[A].shouldDoDownload()?this.downloads[A].distanceFunction||this.nextDownloads.push(this.downloads.splice(A,1)[0]):this.downloads.splice(A,1);if(!(this.nextDownloads.length>0)){for(let t=this.downloads.length-1;t>=0;t--){const s=this.downloads[t].distanceFunction()*this.downloads[t].level;s<A&&(A=s,e=t)}if(e>=0){const A=this.downloads.splice(e,1).pop();this.nextDownloads.push(A);const t=A.getSiblings();for(let A=this.downloads.length-1;A>=0;A--)t.includes(this.downloads[A].uuid)&&this.nextDownloads.push(this.downloads.splice(A,1).pop())}}}getNextReady(){let A=Number.MAX_VALUE,e=-1;for(let A=this.ready.length-1;A>=0;A--)this.ready[A][3]||this.nextReady.push(this.ready.splice(A,1)[0]);if(!(this.nextReady.length>0)){for(let t=this.ready.length-1;t>=0;t--){const s=this.ready[t][3]()*this.ready[t][5];s<A&&(A=s,e=t)}if(e>=0){const A=this.ready.splice(e,1).pop();this.nextReady.push(A);const t=A[4]();for(let A=this.ready.length-1;A>=0;A--)t.includes(this.ready[A][6])&&this.nextready.push(this.ready.splice(A,1).pop())}}}get(A,e,t,s,i,o,r,n,a){const g=this,h=LA(t),I=new AbortController;if(A.signal.addEventListener("abort",(()=>{g.register[h]&&0!=Object.keys(g.register[h]).length||I.abort()})),!(t.includes(".b3dm")||t.includes(".json")||t.includes(".gltf")||t.includes(".glb")))return void console.error("the 3DTiles cache can only be used to load B3DM, gltf and json data");g.register[h]||(g.register[h]={}),g.register[h][e]&&console.error(" a tile should only be loaded once"),g.register[h][e]=s;if(g.cache.get(h))this.meshReceived(g.cache,g.register,h,i,o,r,e);else if(1==Object.keys(g.register[h]).length){let s;t.includes(".b3dm")?s=()=>{xA++,(g.proxy?()=>fetch(g.proxy,{method:"POST",body:t,signal:I.signal}):()=>fetch(t,{signal:I.signal}))().then((A=>{if(xA--,!A.ok)throw console.error("could not load tile with path : "+t),new Error("couldn't load \"".concat(t,'". Request failed with status ').concat(A.status," : ").concat(A.statusText));return A.arrayBuffer()})).then((A=>this.b3dmDecoder.parseB3DM(A,g.meshCallback,a,n))).then((A=>{g.cache.put(h,A),g.checkSize(),this.meshReceived(g.cache,g.register,h,i,o,r,e)})).catch((A=>console.error(A)))}:t.includes(".glb")||t.includes(".gltf")?s=()=>{xA++,this.gltfLoader.load(t,(A=>{A.scene.traverse((A=>{A.geometricError=a,A.isMesh&&(n&&A.applyMatrix4(MA),g.meshCallback&&g.meshCallback(A)),A.isPoints&&(n&&A.applyMatrix4(MA),g.pointsCallback&&g.pointsCallback(A))})),g.cache.put(h,A.scene),g.checkSize(),g.meshReceived(g.cache,g.register,h,i,o,r,e)}))}:t.includes(".json")&&(s=()=>{xA++,(g.proxy?()=>fetch(g.proxy,{method:"POST",body:t,signal:I.signal}):()=>fetch(t,{signal:I.signal}))().then((A=>{if(xA--,!A.ok)throw console.error("could not load tile with path : "+t),new Error("couldn't load \"".concat(t,'". Request failed with status ').concat(A.status," : ").concat(A.statusText));return A.json()})).then((A=>{g.cache.put(h,A),g.checkSize(),g.meshReceived(g.cache,g.register,h)})).catch((A=>console.error("tile download aborted")))}),this.scheduleDownload({shouldDoDownload:()=>!A.signal.aborted&&!!g.register[h]&&Object.keys(g.register[h]).length>0,doDownload:s,distanceFunction:i,getSiblings:o,level:r,uuid:e})}}invalidate(A,e){const t=LA(A);this.register[t]&&delete this.register[t][e]}checkSize(){const A=this;let e=0;for(;A.cache.size()>A.maxCachedItems&&e<A.cache.size();){e++;const t=A.cache.head(),s=A.register[t.key];s&&(Object.keys(s).length>0?(A.cache.remove(t.key),A.cache.put(t.key,t.value)):(A.cache.remove(t.key),delete A.register[t.key],t.value.traverse((A=>{if(A.material)if(A.material.length)for(let e=0;e<A.material.length;++e)A.material[e].dispose();else A.material.dispose();A.geometry&&A.geometry.dispose()}))))}}}function FA(A,e){let t;const s=async()=>{const i=Date.now();try{await A()}catch(A){console.error(A)}finally{const A=Date.now()-i;t=setTimeout(s,A>=e?0:e-A)}};return t=setTimeout(s,e),{clearInterval:()=>clearTimeout(t)}}function LA(A){for(var e=A.split("/"),t=[],s=0,i=0;i<e.length;i++){var o=e[i];"."!==o&&""!==o&&".."!==o?t[s++]=o:".."===o&&s>0&&s--}if(0===s)return"/";var r="";for(i=0;i<s;i++)r+="/"+t[i];return r}var GA,kA=new Uint8Array(16);function UA(){if(!GA&&!(GA="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return GA(kA)}const bA=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const _A=function(A){return"string"==typeof A&&bA.test(A)};for(var NA=[],vA=0;vA<256;++vA)NA.push((vA+256).toString(16).substr(1));const HA=function(A){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=(NA[A[e+0]]+NA[A[e+1]]+NA[A[e+2]]+NA[A[e+3]]+"-"+NA[A[e+4]]+NA[A[e+5]]+"-"+NA[A[e+6]]+NA[A[e+7]]+"-"+NA[A[e+8]]+NA[A[e+9]]+"-"+NA[A[e+10]]+NA[A[e+11]]+NA[A[e+12]]+NA[A[e+13]]+NA[A[e+14]]+NA[A[e+15]]).toLowerCase();if(!_A(t))throw TypeError("Stringified UUID is invalid");return t};const qA=function(A,e,t){var s=(A=A||{}).random||(A.rng||UA)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e){t=t||0;for(var i=0;i<16;++i)e[t+i]=s[i];return e}return HA(s)};var JA=s(470);const OA=new A.Sphere(new A.Vector3(0,0,0),1),PA=new A.Vector3(0,0,0),VA=new A.Vector3(0,0,0),KA=new A.Vector3(0,1,0),jA=new A.Vector2(1e3,1e3),YA=new A.Quaternion;class WA extends A.Object3D{constructor(t){super();const s=this;if(this.proxy=t.proxy,this.uuid=qA(),t.tileLoader)this.tileLoader=t.tileLoader;else{const e={};e.meshCallback=t.meshCallback?t.meshCallback:e=>{e.material.wireframe=!1,e.material.side=A.DoubleSide},e.pointsCallback=t.pointsCallback?t.pointsCallback:A=>{A.material.size=.1,A.material.sizeAttenuation=!0},e.proxy=this.proxy,this.tileLoader=new TA(e)}if(this.geometricErrorMultiplier=t.geometricErrorMultiplier?t.geometricErrorMultiplier:1,this.renderer=t.renderer,this.meshCallback=t.meshCallback,this.loadOutsideView=t.loadOutsideView,this.cameraOnLoad=t.cameraOnLoad,this.parentTile=t.parentTile,this.occlusionCullingService=t.occlusionCullingService,this.static=t.static,this.occlusionCullingService&&(this.color=new A.Color,this.color.setHex(16777215*Math.random()),this.colorID=e(255*s.color.r,0,255)<<16^e(255*s.color.g,0,255)<<8^e(255*s.color.b,0,255)<<0),this.static&&(this.matrixAutoUpdate=!1),this.childrenTiles=[],this.meshContent,this.tileContent,this.refinement,this.rootPath,this.geometricError,this.boundingVolume,this.json,this.materialVisibility=!1,this.inFrustum=!0,this.level=t.level?t.level:0,this.hasMeshContent=!1,this.hasUnloadedJSONContent=!1,this.centerModel=t.centerModel,this.abortController=new AbortController,this.layers.disable(0),t.json)s.setup(t),t.onLoadCallback&&t.onLoadCallback(s);else if(t.url){(s.proxy?()=>fetch(s.proxy,{method:"POST",body:t.url,signal:s.abortController.signal}):()=>fetch(t.url,{signal:s.abortController.signal}))().then((e=>{if(!e.ok)throw new Error("couldn't load \"".concat(t.url,'". Request failed with status ').concat(e.status," : ").concat(e.statusText));e.json().then((e=>{if(s.setup({rootPath:JA.dirname(t.url),json:e}),t.onLoadCallback&&t.onLoadCallback(s),s.centerModel){const e=new A.Sphere;s.boundingVolume instanceof o?e.copy(s.boundingVolume.sphere):s.boundingVolume instanceof A.Sphere&&e.copy(s.boundingVolume),this.json.boundingVolume.region&&(this.transformWGS84ToCartesian(.5*(this.json.boundingVolume.region[0]+this.json.boundingVolume.region[2]),.5*(this.json.boundingVolume.region[1]+this.json.boundingVolume.region[3]),.5*(this.json.boundingVolume.region[4]+this.json.boundingVolume.region[5]),PA),YA.setFromUnitVectors(PA.normalize(),KA.normalize()),s.applyQuaternion(YA)),s.translateX(-e.center.x*s.scale.x),s.translateY(-e.center.y*s.scale.y),s.translateZ(-e.center.z*s.scale.z)}}))})).catch((A=>console.error(A)))}}setup(e){if(e.json.root?(this.json=e.json.root,this.json.refinement||(this.json.refinement=e.json.refinement),this.json.geometricError||(this.json.geometricError=e.json.geometricError),this.json.transform||(this.json.transform=e.json.transform),this.json.boundingVolume||(this.json.boundingVolume=e.json.boundingVolume)):this.json=e.json,this.rootPath=e.json.rootPath?e.json.rootPath:e.rootPath,this.json.refinement?this.refinement=this.json.refinement:this.refinement=e.parentRefinement,this.json.geometricError?this.geometricError=this.json.geometricError:this.geometricError=e.parentGeometricError,this.json.transform&&!this.centerModel){let e=new A.Matrix4;e.elements=this.json.transform,this.applyMatrix4(e)}if(this.json.boundingVolume)if(this.json.boundingVolume.box)this.boundingVolume=new o(this.json.boundingVolume.box);else if(this.json.boundingVolume.region){const e=this.json.boundingVolume.region;this.transformWGS84ToCartesian(e[0],e[1],e[4],PA),this.transformWGS84ToCartesian(e[2],e[3],e[5],VA),PA.lerp(VA,.5),this.boundingVolume=new A.Sphere(new A.Vector3(PA.x,PA.y,PA.z),PA.distanceTo(VA))}else if(this.json.boundingVolume.sphere){const e=this.json.boundingVolume.sphere;this.boundingVolume=new A.Sphere(new A.Vector3(e[0],e[1],e[2]),e[3])}else this.boundingVolume=e.parentBoundingVolume;else this.boundingVolume=e.parentBoundingVolume;this.json.content&&(this.json.content.uri&&this.json.content.uri.includes("json")||this.json.content.url&&this.json.content.url.includes("json")?this.hasUnloadedJSONContent=!0:this.hasMeshContent=!0,this.load())}isAbsolutePathOrURL(A){const e=/^(?:http|https|ftp|tcp|udp):\/\/\S+/.test(A),t=A.startsWith("/")&&!A.startsWith("//");return e||t}load(){var e=this;if(!e.deleted&&e.json.content){let t;e.json.content.uri?t=JA.isAbsolute(e.json.content.uri)||e.isAbsolutePathOrURL(e.json.content.uri)?e.json.content.uri:e.rootPath+JA.sep+e.json.content.uri:e.json.content.url&&(t=JA.isAbsolute(e.json.content.url)||e.isAbsolutePathOrURL(e.json.content.url)?e.json.content.url:e.rootPath+JA.sep+e.json.content.url),t&&(t.includes(".b3dm")||t.includes(".glb")||t.includes(".gltf")?(e.contentURL=t,e.tileLoader.get(e.abortController,this.uuid,t,(t=>{e.deleted||(t.traverse((t=>{if(t.isMesh){if(t.layers.disable(0),e.occlusionCullingService){const s=t.geometry.attributes.position,i=[];for(let A=0;A<s.count;A++)i.push(e.color.r,e.color.g,e.color.b);t.geometry.setAttribute("color",new A.Float32BufferAttribute(i,3))}e.static&&(t.matrixAutoUpdate=!1)}})),e.add(t),e.updateWorldMatrix(!1,!0),e.meshContent=t)}),e.cameraOnLoad?()=>e.calculateDistanceToCamera(e.cameraOnLoad):()=>0,(()=>e.getSiblings()),e.level,!!e.json.boundingVolume.region,e.geometricError)):t.includes(".json")&&e.tileLoader.get(e.abortController,this.uuid,t,(A=>{e.deleted||(e.json.children||(e.json.children=[]),A.rootPath=JA.dirname(t),e.json.children.push(A),delete e.json.content,e.hasUnloadedJSONContent=!1)})))}}dispose(){const A=this;A.childrenTiles.forEach((A=>A.dispose())),A.deleted=!0,this.traverse((function(e){e.contentURL&&A.tileLoader.invalidate(e.contentURL,e.uuid),e.abortController&&e.abortController.abort()})),this.parent=null,this.parentTile=null,this.dispatchEvent({type:"removed"})}disposeChildren(){var A=this;A.childrenTiles.forEach((A=>A.dispose())),A.childrenTiles=[],A.children=[],A.meshContent&&A.children.push(A.meshContent)}update(e){const t=new A.Frustum;t.setFromProjectionMatrix((new A.Matrix4).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse)),this._update(e,t)}_update(A,e){const t=this,s=t.materialVisibility;function i(A){if(t.hasMeshContent&&t.meshContent){if(A<0)return t.inFrustum=!1,void t.changeContentVisibility(!!t.loadOutsideView);if(t.inFrustum=!0,0!=t.childrenTiles.length){if(A>=t.geometricErrorMultiplier*t.geometricError)t.changeContentVisibility(!0);else if(A<t.geometricErrorMultiplier*t.geometricError){let A=!0;t.childrenTiles.every((e=>!!e.isReady()||(A=!1,!1))),A&&t.changeContentVisibility(!1)}}else t.changeContentVisibility(!0)}}t.boundingVolume&&t.geometricError&&(t.metric=t.calculateUpdateMetric(A,e)),t.childrenTiles.forEach((t=>t._update(A,e))),i(t.metric),function(e){if(e<0&&t.hasMeshContent)return;if(t.occlusionCullingService&&t.hasMeshContent&&!t.occlusionCullingService.hasID(t.colorID))return;if((!t.hasMeshContent||e<t.geometricErrorMultiplier*t.geometricError&&t.meshContent)&&t.json&&t.json.children&&t.childrenTiles.length!=t.json.children.length)t.json.children.forEach((e=>{let s=new WA({parentTile:t,parentGeometricError:t.geometricError,parentBoundingVolume:t.boundingVolume,parentRefinement:t.refinement,json:e,rootPath:t.rootPath,geometricErrorMultiplier:t.geometricErrorMultiplier,loadOutsideView:t.loadOutsideView,level:t.level+1,tileLoader:t.tileLoader,cameraOnLoad:A,occlusionCullingService:t.occlusionCullingService,renderer:t.renderer,static:t.static,centerModel:!1});t.childrenTiles.push(s),t.add(s)}))}(t.metric),function(A,e){if(!t.hasMeshContent)return;if(!t.inFrustum)return t.disposeChildren(),void i(A);if(t.occlusionCullingService&&!e&&t.hasMeshContent&&t.meshContent&&t.meshDisplayed&&t.areAllChildrenLoadedAndHidden())return t.disposeChildren(),void i(A);if(A>=t.geometricErrorMultiplier*t.geometricError)t.disposeChildren(),i()}(t.metric,s)}areAllChildrenLoadedAndHidden(){let A=!0;const e=this;return this.childrenTiles.every((t=>{if(t.hasMeshContent){if(t.childrenTiles.length>0)return A=!1,!1;if(!t.inFrustum)return!0;if(!t.materialVisibility||t.meshDisplayed)return A=!1,!1;if(e.occlusionCullingService.hasID(t.colorID))return A=!1,!1}else if(!t.areAllChildrenLoadedAndHidden())return A=!1,!1;return!0})),A}isReady(){if(!this.inFrustum)return!0;if(this.hasUnloadedJSONContent)return!1;if((!this.hasMeshContent||!this.meshContent||!this.materialVisibility)&&this.childrenTiles.length>0){var A=!0;return this.childrenTiles.every((e=>!!e.isReady()||(A=!1,!1))),A}return!this.hasMeshContent||!!this.meshContent&&(!!this.materialVisibility&&!!this.meshDisplayed)}changeContentVisibility(A){const e=this;function t(A,t){A.material.visible=t,t&&(A.onAfterRender=()=>{delete A.onAfterRender,e.meshDisplayed=!0})}e.hasMeshContent&&e.meshContent&&(A?e.meshContent.traverse((A=>{A.isMesh&&A.layers.enable(0)})):e.meshContent.traverse((A=>{A.isMesh&&A.layers.disable(0)}))),e.materialVisibility!=A&&(e.materialVisibility=A,e.meshDisplayed=!0,e.meshContent.traverse?e.meshContent.traverse((function(e){e.material&&t(e,A)})):e.meshContent.scenes&&e.meshContent.scenes.forEach((e=>e.traverse((function(e){e.material&&t(e,A)})))))}calculateUpdateMetric(e,t){if(this.boundingVolume instanceof o){if(OA.copy(this.boundingVolume.sphere),OA.applyMatrix4(this.matrixWorld),!t.intersectsSphere(OA))return-1}else{if(!(this.boundingVolume instanceof A.Sphere))return console.error("unsupported shape"),-1;if(OA.copy(this.boundingVolume),OA.applyMatrix4(this.matrixWorld),!t.intersectsSphere(OA))return-1}const s=Math.max(0,e.position.distanceTo(OA.center)-OA.radius);if(0==s)return 0;const i=this.matrixWorld.getMaxScaleOnAxis();this.renderer&&this.renderer.getDrawingBufferSize(jA);let r=jA.y,n=e.fov;e.aspect<1&&(n*=e.aspect,r=jA.x);let a=2*Math.tan(.5*n*.017453292519943295)*s;return 16*window.devicePixelRatio*a/(r*i)}getSiblings(){const A=this,e=[];if(!A.parentTile)return e;let t=A.parentTile;for(;!t.hasMeshContent&&t.parentTile;)t=t.parentTile;return t.childrenTiles.forEach((t=>{if(t&&t!=A){for(;!t.hasMeshContent&&t.childrenTiles[0];)t=t.childrenTiles[0];e.push(t)}})),e}calculateDistanceToCamera(e){return this.boundingVolume instanceof o?(OA.copy(this.boundingVolume.sphere),OA.applyMatrix4(this.matrixWorld)):this.boundingVolume instanceof A.Sphere?(OA.copy(this.boundingVolume),OA.applyMatrix4(this.matrixWorld)):console.error("unsupported shape"),Math.max(0,e.position.distanceTo(OA.center)-OA.radius)}setGeometricErrorMultiplier(A){this.geometricErrorMultiplier=A,this.childrenTiles.forEach((e=>e.setGeometricErrorMultiplier(A)))}transformWGS84ToCartesian(A,e,t,s){const i=6378137/Math.sqrt(1-.006694384442042*Math.pow(Math.sin(e),2)),o=Math.cos(e),r=Math.cos(A),n=Math.sin(e),a=i+t,g=a*o*r,h=a*o*Math.sin(A),I=(.993305615557957*i+t)*n;s.set(g,h,I)}}const XA=new A.Sphere(new A.Vector3(0,0,0),1),zA=new A.Vector3(0,0,0),ZA=new A.Vector3(0,0,0),$A=new A.Vector3(0,1,0),Ae=new A.Vector2,ee=new A.Quaternion,te=new A.Matrix4;class se extends A.Object3D{constructor(e){super();const t=this;this.uuid=qA(),e.tileLoader?this.tileLoader=e.tileLoader:console.error("an instanced tileset must be provided an InstancedTilesetLoader"),this.master=e.master,this.meshCallback=e.meshCallback,this.loadOutsideView=e.loadOutsideView,this.cameraOnLoad=e.cameraOnLoad,this.parentTile=e.parentTile,this.childrenTiles=[],this.jsonChildren=[],this.meshContent,this.tileContent,this.refinement,this.rootPath,this.geometricError,this.boundingVolume,this.json,this.materialVisibility=!1,this.inFrustum=!0,this.level=e.level?e.level:0,this.hasMeshContent=!1,this.hasUnloadedJSONContent=!1,this.centerModel=e.centerModel,this.deleted=!1,this.abortController=new AbortController,e.json?(this.rootPath=e.json.rootPath?e.json.rootPath:e.rootPath,e.json.children&&(this.jsonChildren=e.json.children),t.setup(e),e.onLoadCallback&&e.onLoadCallback(t)):e.url&&(this.loadJson=(s,i)=>{const r=JA.dirname(i);if(t.setup({rootPath:r,json:s}),t.centerModel){const e=new A.Sphere;t.boundingVolume instanceof o?e.copy(t.boundingVolume.sphere):t.boundingVolume instanceof A.Sphere&&e.copy(t.boundingVolume),this.json.boundingVolume.region&&(t.transformWGS84ToCartesian(.5*(t.json.boundingVolume.region[0]+t.json.boundingVolume.region[2]),.5*(t.json.boundingVolume.region[1]+t.json.boundingVolume.region[3]),.5*(t.json.boundingVolume.region[4]+t.json.boundingVolume.region[5]),zA),ee.setFromUnitVectors(zA.normalize(),$A.normalize()),t.master.applyQuaternion(ee),t.master.updateWorldMatrix(!1,!1)),te.makeTranslation(-e.center.x*t.scale.x,-e.center.y*t.scale.y,-e.center.z*t.scale.z),t.master.matrix.multiply(te),t.master.matrix.decompose(t.master.position,t.master.quaternion,t.master.scale)}e.onLoadCallback&&e.onLoadCallback(t)},t.tileLoader.get(t.abortController,e.url,t.uuid,t))}setup(e){if(this.isSetup=!0,e.json.root?(this.json=e.json.root,this.jsonChildren=this.json.children,this.json.refinement||(this.json.refinement=e.json.refinement),this.json.geometricError||(this.json.geometricError=e.json.geometricError),this.json.transform||(this.json.transform=e.json.transform),this.json.boundingVolume||(this.json.boundingVolume=e.json.boundingVolume)):this.json=e.json,this.rootPath=e.json.rootPath?e.json.rootPath:e.rootPath,this.json.refinement?this.refinement=this.json.refinement:this.refinement=e.parentRefinement,this.json.geometricError?this.geometricError=this.json.geometricError:this.geometricError=e.parentGeometricError,this.json.transform&&!this.centerModel){let e=new A.Matrix4;e.elements=this.json.transform,this.master.applyMatrix4(e)}if(this.json.boundingVolume)if(this.json.boundingVolume.box)this.boundingVolume=new o(this.json.boundingVolume.box);else if(this.json.boundingVolume.region){const e=this.json.boundingVolume.region;this.transformWGS84ToCartesian(e[0],e[1],e[4],zA),this.transformWGS84ToCartesian(e[2],e[3],e[5],ZA),zA.lerp(ZA,.5),this.boundingVolume=new A.Sphere(new A.Vector3(zA.x,zA.y,zA.z),zA.distanceTo(ZA))}else if(this.json.boundingVolume.sphere){const e=this.json.boundingVolume.sphere;this.boundingVolume=new A.Sphere(new A.Vector3(e[0],e[2],-e[1]),e[3])}else this.boundingVolume=e.parentBoundingVolume;else this.boundingVolume=e.parentBoundingVolume;this.json.content&&(this.json.content.uri&&this.json.content.uri.includes("json")||this.json.content.url&&this.json.content.url.includes("json")?this.hasUnloadedJSONContent=!0:this.hasMeshContent=!0,this.load())}isAbsolutePathOrURL(A){const e=/^(?:http|https|ftp|tcp|udp):\/\/\S+/.test(A),t=A.startsWith("/")&&!A.startsWith("//");return e||t}load(){var A=this;if(!A.deleted){if(A.json.content){let e;A.json.content.uri?e=JA.isAbsolute(A.json.content.uri)||A.isAbsolutePathOrURL(A.json.content.uri)?A.json.content.uri:A.rootPath+JA.sep+A.json.content.uri:A.json.content.url&&(e=JA.isAbsolute(A.json.content.url)||A.isAbsolutePathOrURL(A.json.content.url)?A.json.content.url:A.rootPath+JA.sep+A.json.content.url),e&&(e.includes(".b3dm")||e.includes(".glb")||e.includes(".gltf")?(A.contentURL=e,A.tileLoader.get(A.abortController,e,A.uuid,A,A.cameraOnLoad?()=>A.calculateDistanceToCamera(A.cameraOnLoad):()=>0,(()=>A.getSiblings()),A.level,!!A.json.boundingVolume.region,A.geometricError)):e.includes(".json")&&A.tileLoader.get(A.abortController,e,A.uuid,A))}A.matrixWorldNeedsUpdate=!0,A.updateWorldMatrix(!0,!0)}}loadMesh(A){this.deleted||(this.meshContent=A)}loadJson(A,e){this.deleted||(this.json.children&&(this.jsonChildren=this.json.children),A.rootPath=JA.dirname(e),this.jsonChildren.push(A),this.hasUnloadedJSONContent=!1)}dispose(){const A=this;A.childrenTiles.forEach((A=>A.dispose())),A.deleted=!0,A.abortController&&A.abortController.abort(),this.parent=null,this.parentTile=null,this.dispatchEvent({type:"removed"})}disposeChildren(){this.childrenTiles.forEach((A=>A.dispose())),this.childrenTiles=[]}_update(A,e){const t=this;t.materialVisibility;function s(A){if(t.hasMeshContent&&t.meshContent){if(A<0)return t.inFrustum=!1,void t.changeContentVisibility(!!t.loadOutsideView);if(t.inFrustum=!0,0!=t.childrenTiles.length){if(A>=t.master.geometricErrorMultiplier*t.geometricError)t.changeContentVisibility(!0);else if(A<t.master.geometricErrorMultiplier*t.geometricError){let A=!0;t.childrenTiles.every((e=>!!e.isReady()||(A=!1,!1))),A&&t.changeContentVisibility(!1)}}else t.changeContentVisibility(!0)}}t.boundingVolume&&t.geometricError&&(t.metric=t.calculateUpdateMetric(A,e)),t.childrenTiles.forEach((t=>t._update(A,e))),s(t.metric),function(e){if(e<0&&t.hasMeshContent)return;if((!t.hasMeshContent&&t.rootPath||e<t.master.geometricErrorMultiplier*t.geometricError&&t.meshContent)&&t.json&&t.jsonChildren&&t.childrenTiles.length!=t.jsonChildren.length)t.jsonChildren.forEach((e=>{let s=new se({parentTile:t,parentGeometricError:t.geometricError,parentBoundingVolume:t.boundingVolume,parentRefinement:t.refinement,json:e,rootPath:t.rootPath,loadOutsideView:t.loadOutsideView,level:t.level+1,tileLoader:t.tileLoader,cameraOnLoad:A,master:t.master,centerModel:!1});t.childrenTiles.push(s)}))}(t.metric),function(A,e){if(!t.hasMeshContent)return;if(!t.inFrustum)return t.disposeChildren(),void s(A);if(A>=t.master.geometricErrorMultiplier*t.geometricError)t.disposeChildren(),s(A)}(t.metric)}areAllChildrenLoadedAndHidden(){let A=!0;return this.childrenTiles.every((e=>{if(e.hasMeshContent){if(e.childrenTiles.length>0)return A=!1,!1;if(!e.inFrustum)return!0;if(!e.materialVisibility||e.meshesToDisplay!=e.meshesDisplayed)return A=!1,!1}else if(!e.areAllChildrenLoadedAndHidden())return A=!1,!1;return!0})),A}isReady(){if(!this.inFrustum)return!0;if(this.hasUnloadedJSONContent)return!1;if((!this.hasMeshContent||!this.meshContent||!this.materialVisibility)&&this.childrenTiles.length>0){var A=!0;return this.childrenTiles.every((e=>!!e.isReady()||(A=!1,!1))),A}return!this.hasMeshContent||!!this.meshContent&&(!!this.materialVisibility&&!!this.meshContent.displayedOnce)}changeContentVisibility(A){this.materialVisibility=A}calculateUpdateMetric(e,t){if(this.boundingVolume instanceof o){if(XA.copy(this.boundingVolume.sphere),XA.applyMatrix4(this.master.matrixWorld),!t.intersectsSphere(XA))return-1}else{if(!(this.boundingVolume instanceof A.Sphere))return console.error("unsupported shape"),-1;if(XA.copy(this.boundingVolume),XA.applyMatrix4(this.master.matrixWorld),!t.intersectsSphere(XA))return-1}if(this.boundingVolume instanceof o||this.boundingVolume instanceof A.Sphere){const A=Math.max(0,e.position.distanceTo(XA.center)-XA.radius);if(0==A)return 0;const t=this.master.matrixWorld.getMaxScaleOnAxis();this.master.renderer.getDrawingBufferSize(Ae);let s=Ae.y,i=e.fov;e.aspect<1&&(i*=e.aspect,s=Ae.x);let o=2*Math.tan(.5*i*.017453292519943295)*A;return 16*window.devicePixelRatio*o/(s*t)}if(this.boundingVolume instanceof A.Box3)return-1}getSiblings(){const A=this,e=[];if(!A.parentTile)return e;let t=A.parentTile;for(;!t.hasMeshContent&&t.parentTile;)t=t.parentTile;return t.childrenTiles.forEach((t=>{if(t&&t!=A){for(;!t.hasMeshContent&&t.childrenTiles[0];)t=t.childrenTiles[0];e.push(t)}})),e}calculateDistanceToCamera(e){return this.boundingVolume instanceof o?(XA.copy(this.boundingVolume.sphere),XA.applyMatrix4(this.master.matrixWorld)):this.boundingVolume instanceof A.Sphere?(XA.copy(this.boundingVolume),XA.applyMatrix4(this.master.matrixWorld)):console.error("unsupported shape"),Math.max(0,e.position.distanceTo(XA.center)-XA.radius)}getWorldMatrix(){return this.master.matrixWorld}transformWGS84ToCartesian(A,e,t,s){const i=6378137/Math.sqrt(1-.006694384442042*Math.pow(Math.sin(e),2)),o=Math.cos(e),r=Math.cos(A),n=Math.sin(e),a=i+t,g=a*o*r,h=a*o*Math.sin(A),I=(.993305615557957*i+t)*n;s.set(g,h,I)}}class ie extends A.Object3D{constructor(A){super(),A.master=this,this.renderer=A.renderer,this.geometricErrorMultiplier=A.geometricErrorMultiplier?A.geometricErrorMultiplier:1,this.tileset=new se(A),A.static&&(this.matrixAutoUpdate=!1)}update(e,t){if(t)this.tileset._update(e,t);else{const t=new A.Frustum;t.setFromProjectionMatrix((new A.Matrix4).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse)),this.tileset._update(e,t)}}updateWithFrustum(A,e){this.tileset._update(A,e)}setGeometricErrorMultiplier(A){this.geometricErrorMultiplier=A||1}}const oe=new A.Matrix4;class re{constructor(e){const t=this;t.scene=e,t.instancedTiles=[],t.instancedMesh,t.reuseableMatrix=new A.Matrix4}addInstance(A){const e=this;A.added=!0,A.listOMesh=e.instancedTiles,e.instancedTiles.push(A),e.instancedMesh&&A.loadMesh(e.instancedMesh)}addToScene(){const e=this;e.instancedMesh.setMatrixAt(0,new A.Matrix4),e.instancedMesh.instanceMatrix.needsUpdate=!0,e.instancedMesh.count=1,e.scene.add(e.instancedMesh),e.instancedMesh.onAfterRender=()=>{delete e.instancedMesh.onAfterRender,e.instancedMesh.displayedOnce=!0}}setObject(A){const e=this;e.instancedMesh=A;for(let A=0;A<e.instancedTiles.length;A++)e.instancedTiles[A].loadMesh(e.instancedMesh)}update(){const A=this;for(let e=A.instancedTiles.length-1;e>=0;e--)A.instancedTiles[e].deleted&&A.instancedTiles.splice(e,1);if(A.instancedMesh){A.instancedMesh.count=0;for(let e=0;e<A.instancedTiles.length;e++)A.instancedTiles[e].meshContent=A.instancedMesh,A.instancedTiles[e].materialVisibility&&A.instancedTiles[e].meshContent&&(A.instancedMesh.count++,A.reuseableMatrix.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),A.reuseableMatrix.multiply(A.instancedTiles[e].master.matrixWorld),A.reuseableMatrix.multiply(A.instancedMesh.baseMatrix),A.instancedMesh.setMatrixAt(A.instancedMesh.count-1,A.reuseableMatrix),A.instancedMesh.getMatrixAt(0,oe),console.log());A.instancedMesh.instanceMatrix.needsUpdate=!0}}getCount(){return this.instancedTiles.length}}class ne{constructor(){const A=this;A.count=0,A.json,A.instancedTiles=[]}addInstance(A){this.instancedTiles.push(A),this.json&&A.loadJson(this.json,this.url)}setObject(A,e){const t=this;t.json=A,t.url=e;for(let A=0;A<t.instancedTiles.length;A++)t.instancedTiles[A].loadJson(t.json,t.url)}getCount(){return this.instancedTiles.length}update(){const A=this;for(let e=A.instancedTiles.length-1;e>=0;e--)A.instancedTiles[e].deleted&&A.instancedTiles.splice(e,1)}}let ae=0;const ge=new A.Matrix4;ge.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);class he{constructor(A,e){this.maxCachedItems=100,this.maxInstances=1,e&&(this.meshCallback=e.meshCallback,this.pointsCallback=e.pointsCallback,e.maxCachedItems&&(this.maxCachedItems=e.maxCachedItems),e.maxInstances&&(this.maxInstances=e.maxInstances)),this.gltfLoader=new a;const t=new sA;if(t.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),this.gltfLoader.setDRACOLoader(t),e&&e.renderer){const A=new uA;A.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(e.renderer),this.gltfLoader.setKTX2Loader(A),this.b3dmDecoder=new SA(e.renderer)}else this.b3dmDecoder=new SA(null);this.cache=new r.LinkedHashMap,this.scene=A,this.ready=[],this.downloads=[],this.nextReady=[],this.nextDownloads=[],this.init()}update(){this.cache._data.forEach((A=>{A.update()}))}init(){const A=this;Ie((()=>{A.download()}),10),Ie((()=>{const e=Date.now();let t=0;do{t=A.loadBatch()}while(t>0&&Date.now()-e<=0)}),10)}download(){const e=this;if(0!=e.nextDownloads.length||(e.getNextDownloads(),0!=e.nextDownloads.length))for(;e.nextDownloads.length>0&&ae<500;){const t=e.nextDownloads.shift();t&&t.shouldDoDownload()&&(ae++,t.path.includes(".b3dm")&&fetch(t.path,{signal:t.abortController.signal}).then((A=>{if(ae--,!A.ok)throw console.error("could not load tile with path : "+path),new Error("couldn't load \"".concat(path,'". Request failed with status ').concat(A.status," : ").concat(A.statusText));return A.arrayBuffer()})).then((A=>this.b3dmDecoder.parseB3DMInstanced(A,e.meshCallback,e.maxInstances,t.zUpToYUp))).then((A=>{t.tile.setObject(A),e.ready.unshift(t)})).catch((A=>console.error(A))),t.path.includes(".glb")||t.path.includes(".gltf")?this.gltfLoader.load(t.path,(s=>{let i;s.scene.traverse((A=>{A.geometricError=t.geometricError,A.isMesh&&(t.zUpToYUp&&A.applyMatrix4(ge),e.meshCallback&&e.meshCallback(A)),A.isPoints&&console.error("instanced point cloud is not supported")})),s.scene.updateWorldMatrix(!1,!0),s.scene.traverse((t=>{t.isMesh&&(i=new A.InstancedMesh(t.geometry,t.material,e.maxInstances),i.baseMatrix=t.matrixWorld)})),e.ready.unshift(t),i?t.tile.setObject(i):s.scene.traverse((A=>{A.dispose&&A.dispose(),A.material&&A.material.dispose()}))})):t.path.includes(".json")&&(ae++,fetch(t.path,{signal:t.abortController.signal}).then((A=>{if(ae--,!A.ok)throw console.error("could not load tile with path : "+path),new Error("couldn't load \"".concat(path,'". Request failed with status ').concat(A.status," : ").concat(A.statusText));return A.json()})).then((A=>{t.tile.setObject(A,t.path),e.ready.unshift(t)})).catch((A=>console.error(A)))))}}loadBatch(){if(0==this.nextReady.length&&(this.getNextReady(),0==this.nextReady.length))return 0;const A=this.nextReady.shift();return A?(A.tile.addToScene&&A.tile.addToScene(),1):0}getNextReady(){let A=Number.MAX_VALUE,e=-1;for(let A=this.ready.length-1;A>=0;A--)this.ready[A].distanceFunction||this.nextReady.push(this.ready.splice(A,1)[0]);if(!(this.nextReady.length>0)){for(let t=this.ready.length-1;t>=0;t--){const s=this.ready[t].distanceFunction()*this.ready[t].level;s<A&&(A=s,e=t)}if(e>=0){const A=this.ready.splice(e,1).pop();this.nextReady.push(A);const t=A.getSiblings();for(let A=this.ready.length-1;A>=0;A--)t.includes(this.ready[A].uuid)&&this.nextready.push(this.ready.splice(A,1).pop())}}}get(A,e,t,s,i,o,r,n,a){const g=this,h=function(A){for(var e=A.split("/"),t=[],s=0,i=0;i<e.length;i++){var o=e[i];"."!==o&&""!==o&&".."!==o?t[s++]=o:".."===o&&s>0&&s--}if(0===s)return"/";var r="";for(i=0;i<s;i++)r+="/"+t[i];return r}(e);if(!(e.includes(".b3dm")||e.includes(".json")||e.includes(".glb")||e.includes(".gltf")))return void console.error("the 3DTiles cache can only be used to load B3DM, gltf and json data");const I=g.cache.get(h);if(I)I.addInstance(s);else if(e.includes(".b3dm")||e.includes(".glb")||e.includes(".gltf")){const I=new re(g.scene);I.addInstance(s),g.cache.put(h,I);const l=new AbortController;A.signal.addEventListener("abort",(()=>{0==I.getCount()&&l.abort()})),this.downloads.push({abortController:l,tile:I,key:h,path:e,distanceFunction:i,getSiblings:o,level:r,uuid:t,zUpToYUp:n,geometricError:a,shouldDoDownload:()=>!0})}else if(e.includes(".json")){const t=new ne;t.addInstance(s),g.cache.put(h,t);const n=new AbortController;A.signal.addEventListener("abort",(()=>{0==t.getCount()&&n.abort()})),this.downloads.push({abortController:n,tile:t,key:h,path:e,distanceFunction:i,getSiblings:o,level:r,shouldDoDownload:()=>!0})}}getNextDownloads(){let A=Number.MAX_VALUE,e=-1;for(let A=this.downloads.length-1;A>=0;A--){const e=this.downloads[A];e.shouldDoDownload()?e.distanceFunction||this.nextDownloads.push(this.downloads.splice(A,1)[0]):this.downloads.splice(A,1)}if(!(this.nextDownloads.length>0)){for(let t=this.downloads.length-1;t>=0;t--){const s=this.downloads[t],i=s.distanceFunction()*s.level;i<A&&(A=i,e=t)}if(e>=0){const A=this.downloads.splice(e,1).pop();this.nextDownloads.push(A);const t=A.getSiblings();for(let A=this.downloads.length-1;A>=0;A--)t.includes(this.downloads[A].uuid)&&this.nextDownloads.push(this.downloads.splice(A,1).pop())}}}checkSize(){const A=this;let e=0;for(;A.cache.size()>A.maxCachedItems&&e<A.cache.size();){e++;const t=A.cache.head();t.value.getCount()>0?(A.cache.remove(t.key),A.cache.put(t.key,t.value)):(A.cache.remove(t.key),t.value.instancedMesh&&t.value.instancedMesh.traverse((A=>{if(A.material)if(A.material.length)for(let e=0;e<A.material.length;++e)A.material[e].dispose();else A.material.dispose();A.geometry&&A.geometry.dispose()})))}}}function Ie(A,e){let t;const s=async()=>{const i=Date.now();try{await A()}catch(A){console.error(A)}finally{const A=Date.now()-i;t=setTimeout(s,A>=e?0:e-A)}};return t=setTimeout(s,e),{clearInterval:()=>clearTimeout(t)}}})(),i})()));
|
|
3
3
|
//# sourceMappingURL=threedtiles.min.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jdultra/threedtiles",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.12",
|
|
4
4
|
"description": "An OGC 3DTiles viewer for Three.js",
|
|
5
5
|
"main": "dist/threedtiles.min.js",
|
|
6
6
|
"files": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"author": "Emeric Beaufays",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"three": "^0.
|
|
31
|
+
"three": "^0.152.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"js-utils-z": "^1.2.1",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@babel/core": "^7.21.4",
|
|
41
41
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
42
|
+
"@babel/plugin-syntax-import-meta": "^7.10.4",
|
|
42
43
|
"@babel/preset-env": "^7.21.4",
|
|
43
44
|
"babel-loader": "^9.1.2",
|
|
44
45
|
"copy-webpack-plugin": "^6.3.2",
|