@maptalks/3dtiles 0.15.3 → 0.16.0
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/maptalks.3dtiles.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/3dtiles v0.
|
|
2
|
+
* @maptalks/3dtiles v0.16.0
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
4
|
* (c) 2016-2022 maptalks.org
|
|
5
5
|
*/
|
|
6
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks"),require("@maptalks/gl")):"function"==typeof define&&define.amd?define(["exports","maptalks","@maptalks/gl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).maptalks=t.maptalks||{},t.maptalks,t.maptalksgl)}(this,(function(t,e,r){"use strict";function n(t){if(t&&t.t)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var i=n(e),s=n(r);const o='function(t){var e=1e-6,r="undefined"!=typeof Float32Array?Float32Array:Array;function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],f=e[6],u=e[7],l=e[8],E=e[9],_=e[10],A=e[11],h=e[12],T=e[13],R=e[14],y=e[15],I=r[0],N=r[1],U=r[2],S=r[3];return t[0]=I*n+N*a+U*l+S*h,t[1]=I*i+N*c+U*E+S*T,t[2]=I*s+N*f+U*_+S*R,t[3]=I*o+N*u+U*A+S*y,I=r[4],N=r[5],U=r[6],S=r[7],t[4]=I*n+N*a+U*l+S*h,t[5]=I*i+N*c+U*E+S*T,t[6]=I*s+N*f+U*_+S*R,t[7]=I*o+N*u+U*A+S*y,I=r[8],N=r[9],U=r[10],S=r[11],t[8]=I*n+N*a+U*l+S*h,t[9]=I*i+N*c+U*E+S*T,t[10]=I*s+N*f+U*_+S*R,t[11]=I*o+N*u+U*A+S*y,I=r[12],N=r[13],U=r[14],S=r[15],t[12]=I*n+N*a+U*l+S*h,t[13]=I*i+N*c+U*E+S*T,t[14]=I*s+N*f+U*_+S*R,t[15]=I*o+N*u+U*A+S*y,t}function s(){var t=new r(3);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function o(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function a(t,e,n){var i=new r(3);return i[0]=t,i[1]=e,i[2]=n,i}function c(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function f(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function u(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function l(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function E(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function _(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function A(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}function h(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s),t}function T(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function R(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[0],a=r[1],c=r[2];return t[0]=i*c-s*a,t[1]=s*o-n*c,t[2]=n*a-i*o,t}function y(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,t}var I=l,N=E,U=o;function S(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function d(){var t=new r(4);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function m(t,r,n,i){var s=r[0],o=r[1],a=r[2],c=r[3],f=n[0],u=n[1],l=n[2],E=n[3],_=void 0,A=void 0,h=void 0,T=void 0,R=void 0;return(A=s*f+o*u+a*l+c*E)<0&&(A=-A,f=-f,u=-u,l=-l,E=-E),1-A>e?(_=Math.acos(A),h=Math.sin(_),T=Math.sin((1-i)*_)/h,R=Math.sin(i*_)/h):(T=1-i,R=i),t[0]=T*s+R*f,t[1]=T*o+R*u,t[2]=T*a+R*l,t[3]=T*c+R*E,t}s(),function(){var t,e=(t=new r(4),r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var M,O=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};s(),a(1,0,0),a(0,1,0),d(),d(),M=new r(9),r!=Float32Array&&(M[1]=0,M[2]=0,M[3]=0,M[5]=0,M[6]=0,M[7]=0),M[0]=1,M[4]=1,M[8]=1;\n/*!\n * @maptalks/gltf-loader v0.27.1\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.org\n */\nlet F=0;function b(t){return null==t}function C(t){return!b(t)}function p(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}function w(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView\'s component type: "+t)}function D(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function B(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),r=e.length,n=new Uint8Array(r);for(let t=0;t<r;t++)n[t]=e.charCodeAt(t);return n.buffer}const L=[],P=[],g=[],G=[0,0,0],v=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),X=[1,1,1];function H(t,e,r,n,i,s,o){const a=w(o);if((0===i||i===n*a.BYTES_PER_ELEMENT)&&s%a.BYTES_PER_ELEMENT==0){const i=new a(e,s,r*n);return t.set(i),t}0===i&&(i=n*a.BYTES_PER_ELEMENT);const c=new Uint8Array(n*a.BYTES_PER_ELEMENT);for(let o=0;o<r;o++){let r=null;const f=new Uint8Array(e,i*o+s,n*a.BYTES_PER_ELEMENT);c.set(f),r=new a(c.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const x="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function V(t,e,r){const n=new Uint8Array(t,e,r);return x.decode(n)}const k={get:function(t,e={}){e||(e={});const r=new AbortController,n=r.signal,i=p({},e);i.signal=n,i.method||(i.method="GET");const s=fetch(t,i).then((t=>{const r=this.t(t,e.responseType);return r.message?r:r.then((r=>"arraybuffer"===e.responseType?{data:r,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:r)).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}))})).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}));return s.xhr=r,s},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",k.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?k.jsonp(t):((e=e||{}).responseType="json",k.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+F++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,new Promise((t=>{window[e]=function(n){document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e],t(n)},document.getElementsByTagName("head")[0].appendChild(r)}))}};class Z{constructor(t,e,r){this.i=t,this.decoders=e,this.o=r,this.images={},this.u={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],i=this.l(e,n);return this.getImageByBuffer(i,r)}if(this.u[t.id])return this.u[t.id].then((()=>{const n=this.buffers[t.id],i=this.l(e,n);return this.getImageByBuffer(i,r)}));if(D(t.uri)){const n=this.buffers[t.id]=B(t.uri),i=this.l(e,n);return this.getImageByBuffer(i,r)}return this.u[t.id]=k.getArrayBuffer(t.uri,null).then((n=>{const i=this.buffers[t.id]=n.data,s=this.l(e,i);return this.getImageByBuffer(s,r)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const r=this.decoders;if(r[e.mimeType])return r[e.mimeType](t,{supportedFormats:this.o});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const r=new Blob([t],{type:e.mimeType}),n=URL.createObjectURL(r);return this._(e.id,n)}}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.u[t.id]?this.u[t.id].then((()=>this.images[t.id])):this.u[t.id]=this._(t.id,e)}_(t,e){return new Promise(((r,n)=>{this.i(e,((i,s)=>{i?n(i):(URL.revokeObjectURL(e),this.images[t]=s,r(this.images[t]))}))}))}}const Y=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class K{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.A=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.h()}T(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this.I(t,e,null,0),Promise.resolve(this.accessors[n.id]);if(n&&this.accessors[n.id])return Promise.resolve(this.accessors[n.id]);const i=r.bufferViews[n.bufferView];return this.N(i).then((r=>{const{buffer:i,byteOffset:s}=r;return this.accessors[n.id]=this.I(t,e,i,s)}))}N(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then((()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}));if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(D(e.uri)){const t=this.buffers[e.id]=B(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=k.getArrayBuffer(t,null).then((n=>(r&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=n.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}I(t,e,r,n=0){const i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+n,c=this.U(s.type),f=w(s.componentType),u=o.byteStride||0,l={array:void 0,name:t,accessorName:e,byteLength:s.count*c*f.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c};if(s.min&&(l.min=s.min),s.max&&(l.max=s.max),r)if(this.A)l.byteStride=u,l.byteOffset=a+(s.byteOffset||0),!u||u===c*f.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(l.array=this.S(r,s.count,c,a+(s.byteOffset||0),f),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(r,a,o.byteLength);else if(s.interleaved){l.byteStride=0,l.byteOffset=0;const t=new f(s.count*c);l.array=H(t,r,s.count,c,u,a+(s.byteOffset||0),s.componentType)}else l.byteStride=0,l.array=this.S(r,s.count,c,a+(s.byteOffset||0),f),l.byteOffset=l.array.byteOffset;else{l.array=new f(s.count);const t=l.min||l.max;t&&(l.array[0]=t[0],l.array[1]=t[1],l.array[2]=t[2])}return l}h(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let r=0;r<t.length;r++)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0);else for(const e in t)for(const r in t)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0)}S(t,e,r,n,i){return n%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(n,n+e*r*i.BYTES_PER_ELEMENT),n=0),new i(t,n,r*e)}U(t){const e=Y.indexOf(t);return Y[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,r=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:r}=e;return this.N(e).then((n=>{const{buffer:i,byteOffset:s}=n,o=V(i,s+(e.byteOffset||0),r);return t.content=o,t}))}if(t.uri){if(D(t.uri)){const e=B(t.uri),r=V(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return k.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class z extends Z{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=r,this.accessor=new K(t,e,r)}iterate(t,e){const r=this.gltf[e];if(!r)return;let n=0;for(const e in r)t(e,r[e],n++)}createNode(t){const e={};if(C(t.name)&&(e.name=t.name),C(t.children)&&(e.children=t.children),C(t.jointName)&&(e.jointName=t.jointName),C(t.matrix)&&(e.matrix=t.matrix),C(t.rotation)&&(e.rotation=t.rotation),C(t.scale)&&(e.scale=t.scale),C(t.translation)&&(e.translation=t.translation),C(t.extras)&&(e.extras=t.extras),C(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const r=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(L,e.translation||G),n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,c=i+i,f=r*o,u=n*o,l=n*a,E=i*o,_=i*a,A=i*c,h=s*o,T=s*a,R=s*c;return t[0]=1-l-A,t[1]=u+R,t[2]=E-T,t[3]=0,t[4]=u-R,t[5]=1-f-A,t[6]=_+h,t[7]=0,t[8]=E+T,t[9]=_-h,t[10]=1-f-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(P,e.rotation||v),s=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(g,e.scale||X);return i(s,n,s),i(t,r,s)}return n(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}m(t){const e={};for(const r in t){const n=t[r];let i,s;n.instanceTechnique&&n.instanceTechnique.values?(i=n.instanceTechnique,s=i.values.diffuse):(i=n,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={baseColorTexture:{index:s}};n.name&&(o.name=n.name),n.extensions&&(o.extensions=n.extensions),n.extras&&(o.extras=n.extras),e[r]=o}return e}M(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const r=this.gltf.bufferViews[e.bufferView],n=(r.byteOffset||0)+this.glbBuffer.byteOffset,i=r.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,n,i);return this.getImageByBuffer(s,t)}return this.requestExternalImage(t)}O(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.M(r).then((t=>{const n=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extras:r.extras},sampler:n}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let r,n;if(e.instanceTechnique&&e.instanceTechnique.values?(r=e.instanceTechnique,n=r.values.diffuse):(r=e,n=r.values.tex||r.values.diffuseTex||r.values.diffuse),void 0===n||void 0===this.gltf.textures)return null;const i=this.gltf.textures[n];if(!i)return null;const s=this.gltf.samplers[i.sampler];return{format:i.format||6408,internalFormat:i.internalFormat||6408,type:i.type||5121,sampler:s,source:this.gltf.images[i.source]}}getMaterial(){return null}getAnimations(){return null}}class W extends Z{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.glbBuffer=r,this.buffers={},this.requests={},this.accessor=new K(t,e,r)}iterate(t,e){const r=this.gltf[e];if(r)for(let e=0;e<r.length;e++)t(e,r[e],e)}createNode(t){const e={};return p(e,t),!C(t.weights)&&this.gltf.meshes&&C(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}O(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.M(r).then((t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};p(n,e);const i=C(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),t.format&&(n.format=t.format),n}))}M(t){if(!C(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],r=this.gltf.buffers[e.buffer];if(r.uri)return this.requestImageFromBufferURI(r,e,t);if(this.glbBuffer)return this.F(e,t)}return null}F(t,e){const r=this.l(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}l(t,e,r){r=r||0;const n=t.byteOffset+r,i=t.byteLength;return new Uint8Array(e,n,i)}C(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);return r.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)))}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let r=0;r<e.length;r++)t[r].samplers=e[r];return t}))}getSamplers(t){const e=[];for(let r=0;r<t.length;r++)(C(t[r].input)||C(t[r].output))&&(e.push(this.accessor.T("input",t[r].input)),e.push(this.accessor.T("output",t[r].output)));return Promise.all(e).then((e=>{for(let r=0;r<e.length/2;r++)t[r].input=e[2*r],t[r].output=e[2*r+1],t[r].interpolation||(t[r].interpolation="LINEAR");return t}))}}const j="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class q{static read(t,e=0,r=0){r||(r=t.byteLength);const n=new DataView(t,e,r),i=n.getUint32(4,!0);if(1===i)return q.readV1(n,e);if(2===i)return q.readV2(t,e);throw new Error("Unsupported glb version : "+i)}static readV1(t,e){const r=t.getUint32(8,!0),n=t.getUint32(12,!0);if(r!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb\'s byte length.");const i=$(t.buffer,20+e,n);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+n,buffer:t.buffer,byteLength:r}}}static readV2(t,e){let r,n,i;const s=new DataView(t,e+12);let o=0;for(;o<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,1313821514===c)r=$(t,e+12+o,a);else if(5130562===c){i=e+12+o,n=a;break}o+=a}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function $(t,e,r){if(j){const n=new Uint8Array(t,e,r);return j.decode(n)}return function(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=J[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}(new Uint8Array(t,e,r))}const J=[1,1,1,1,2,2,3,0],Q=[0,0,0],tt=[0,0,0,1],et=[1,1,1],rt={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},nt={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},it={p(t,e,r,n,i,s,o,a){const f=C(t)?e.animations:[e.animations[0]],u={};for(let e=0;e<f.length;e++){const l=f[e],E=l.name||e;if(C(t)&&E!==t)continue;const _=l.channelsMap[r];if(_)for(let t=0;t<_.length;t++){const e=_[t];"translation"===e.target.path?(this.D(i,l.samplers[e.sampler],n,1),u.translation=c(Q,i)):"rotation"===e.target.path?(this.B(s,l.samplers[e.sampler],n,1),u.rotation=O(tt,s)):"scale"===e.target.path?(this.D(o,l.samplers[e.sampler],n,1),u.scale=c(et,o)):"weights"===e.target.path&&a&&(this.D(a,l.samplers[e.sampler],n,a.length),u.weights=a)}}return u},D(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.L(nt,e,r,1*n);i&&(t=function(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e[i]+n*(r[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.L(nt,e,r,1*n);i&&(t=function(t,e){for(let r=0;r<t.length;r++)t[r]=e[r];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.L(nt,e,r,3*n);i&&(t=this.P(t,i,e.input.array,3*n));break}}return t},B(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.L(nt,e,r,1);n&&m(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.L(nt,e,r,1);n&&(t=S(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.L(nt,e,r,3);if(n){for(let t=0;t<n.PREVIOUS.length;t++)n.PREVIOUS[t]=Math.acos(n.PREVIOUS[t]),n.NEXT[t]=Math.acos(n.NEXT[t]);t=this.P(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},G(t,e){const r=t.length;let n,i,s,o=0,a=r-1,c=Math.floor((o+a)/2);for(;o<=r-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const r=t[c];return n=c,i=c+1,s=(e-r)/(t[c+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},L(t,e,r,n){const i=e.input.array,s=e.output.array,o=e.output.itemSize;(r<i[0]||r>i[i.length-1])&&(r=Math.max(i[0],Math.min(i[i.length-1],r))),r===i[i.length-1]&&(r=i[0]);const a=this.G(i,r);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:f,interpolation:u}=a;t.PREINDEX=c,t.NEXTINDEX=f,t.INTERPOLATION=u;const l=o*n;return t.PREVIOUS=s.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=s.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},P(t,e,r,n){const i=e.INTERPOLATION,s=r[e.PREINDEX],o=r[e.NEXTINDEX];for(let r=0;r<3;r++){const a=e.PREVIOUS[n+r],c=(o-s)*e.PREVIOUS[2*n+r],f=e.NEXT[3+r],u=(o-s)*e.NEXT[r],l=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(2*-Math.pow(i,3)+3*Math.pow(i,2))*f+(Math.pow(i,3)-Math.pow(i,2))*u;t[r]=l}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;return f(Q,...rt.TRANSLATION),S(tt,...rt.ROTATION),f(et,...rt.SCALE),this.p(n,t,e,r,Q,tt,et,i)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,r)=>{let n=-1/0,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const r=s[t],o=e.samplers[r.sampler].input.array;o[o.length-1]>n&&(n=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||r;t.timeSpan[o]={max:n,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const r=this.getTimeSpan(t);return r?C(e)?r[e]:r[Object.keys(r)[0]]:null}};let st=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(ue){}t&&"undefined"!=typeof createImageBitmap&&(st=!0)}const ot="undefined"==typeof document?null:document.createElement("canvas");class at{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=q.read(e.buffer,e.byteOffset,e.byteLength);this.v(t,r,n)}else this.v(t,e);this.X=new K(this.rootPath,this.gltf,this.glbBuffer),this.H()}H(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}V(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.X.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.k(t),r=this.Z(),n=this.Y(),i=this.V();return Promise.all([e,r,n,i]).then((t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0])))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const r=e[t];r.channelsMap={};for(let t=0;t<r.channels.length;t++){const e=r.channels[t];r.channelsMap[e.target.node]||(r.channelsMap[e.target.node]=[]),r.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:r}=this.gltf;for(let r=0;r<e.length;r++)e[r].uri&&e[r].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[r].uri});for(let e=0;e<r.length;e++)r[e].uri&&r[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:r[e].uri})}return t}static getAnimationClip(t,e,r,n){return it.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return it.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return w(t)}static readInterleavedArray(t,e,r,n,i,s,o){return H(t,e,r,n,i,s,o)}v(t,e,r){this.gltf=e,this.glbBuffer=r,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=st?lt.bind(this):this.options.requestImage||ct,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new W(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="buffer_"+r}),"buffers"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors")):(this.adapter=new z(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"))}K(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(r=t.children[0])&&isFinite(r)||function(t){return!b(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const n=t.children.map((t=>{const r=e[t];return r.nodeIndex=t,this.K(r,e)}));t.children=n}var r;return t}k(t){return this.W(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.K(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((n,i,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===n&&(r=s),e.push(o)}),"scenes");const n={asset:this.gltf.asset,scene:r,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(n.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.m(this.gltf.materials);n.materials=t}return n}))}W(t){return this.j(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,r)=>{const n=this.adapter.createNode(r,this.meshes,this.skins);t[e]=n}),"nodes"),t}))}q(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.$(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}$(t){const e=t.inverseBindMatrices;return this.adapter.accessor.T("inverseBindMatrices",e).then((e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t)))}Z(){const t=this.gltf.animations;return C(t)?this.adapter.getAnimations(t):null}j(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,i)=>{e.push(this.J(n,t).then((t=>{t.index=i,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.q()),Promise.all(e)}J(t,e){const r=t.primitives.map((t=>this.tt(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return p(r,t),r.primitives=e,r}))}Y(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.O(r));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const r=e[t].image.array;if(e[t]&&r){let t;t=r instanceof ImageBitmap?r:r.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const r={},n=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(r[n[t]]=e[t]);return r}return e}))}tt(t,e){let r;const n=[],i=t.extensions;if(C(t.targets))for(let e=0;e<t.targets.length;e++){const r=t.targets[e];for(const t in r){const i=this.adapter.accessor.T(`morphTargets_${t}_${e}`,r[t]);i&&n.push(i)}}if(i&&i.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:s,attributes:o}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[s],c=this.X.N(a).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:c}=a;s||(s=0);const f=new DataView(n,i+s,c),u={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(f,u).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(c),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor.T(t,e[t]);r&&n.push(r)}if(C(t.indices)){const e=this.adapter.accessor.T("indices",t.indices);e&&n.push(e)}r=Promise.all(n)}return r.then((e=>{if(i&&i.KHR_draco_mesh_compression){const r=t.targets?t.targets.length:0;e[r]=e[r].concat(e.slice(0,r)),e=e[r]}let r,n;const s={attributes:e.reduce(((t,e)=>{if("indices"===e.name)r=e;else if(e.name.indexOf("morphTargets_")>-1)n=n||{},n[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0],{itemSize:n,array:i}=e,s=i.length/n;for(let e=0;e<s;e++)for(let s=0;s<n;s++){const o=e*n+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>r[s]&&(r[s]=i[o])}if(e.quantization){const n=e.quantization,i=n.range/(1<<n.quantizationBits),s=n.minValues;_(t,t,i),u(t,t,s),_(r,r,i),u(r,r,s)}e.min=t,e.max=r}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t}),{}),material:t.material};return r&&(s.indices=r),n&&(s.morphTargets=n),s.mode=C(t.mode)?t.mode:4,C(t.extras)&&(s.extras=t.extras),s}))}}function ct(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!ot)return void e(new Error("There is no canvas to draw image!"));ot.width=r.width,ot.height=r.height;const t=ot.getContext("2d");t.drawImage(r,0,0,r.width,r.height);const n=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(n.data)};e(null,i)},r.onerror=function(t){e(t)},r.src=t}let ft,ut;function lt(t,e){ft||(ft=new OffscreenCanvas(2,2),ut=ft.getContext("2d")),fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{let{width:r,height:n}=t;Et(r)||(r=_t(r)),Et(n)||(n=_t(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r),n=Math.min(i,n)),ft.width=r,ft.height=n,ut.drawImage(t,0,0,r,n),t.close();const s=ut.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function Et(t){return 0==(t&t-1)&&0!==t}function _t(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function At(t){return"object"==typeof t&&!!t}function ht(t){return t*Math.PI/180}function Tt(t){return t/Math.PI*180}function Rt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const yt=[1,1,1,1,2,2,3,0];function It(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=yt[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}const Nt=new Array(3),Ut=new Array(3),St=[40680631590769,40680631590769,40408299984661.445];const dt=[1/6378137,1/6378137,1/6356752.314245179],mt=[1/40680631590769,1/40680631590769,1/40408299984661.445],Mt=new Array(3),Ot=new Array(3),Ft=new Array(3);function bt(t,e){const r=mt,n=function(t,e,r,n,i){const s=e[0],o=e[1],a=e[2],c=r[0],f=r[1],u=r[2],l=s*s*c*c,E=o*o*f*f,A=a*a*u*u,h=l+E+A,T=Math.sqrt(1/h),R=_(Ct,e,T);if(h<i)return isFinite(T)?R:void 0;const y=n[0],I=n[1],N=n[2],U=pt;U[0]=R[0]*y*2,U[1]=R[1]*I*2,U[2]=R[2]*N*2;let S,d,m,M,O,F,b,C,p,w,D,B=(1-T)*wt(e)/(.5*wt(U)),L=0;do{B-=L,m=1/(1+B*y),M=1/(1+B*I),O=1/(1+B*N),F=m*m,b=M*M,C=O*O,p=F*m,w=b*M,D=C*O,S=l*F+E*b+A*C-1,d=l*p*y+E*w*I+A*D*N;L=S/(-2*d)}while(Math.abs(S)>1e-12);return t[0]=s*m,t[1]=o*M,t[2]=a*O,t}(Mt,e,dt,r,.1);let i=N(Ot,n,r);i=Dt(i,i);const s=I(Ft,e,n),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=Rt(T(s,e))*wt(s);return t[0]=Tt(o),t[1]=Tt(a),t[2]=c,t}const Ct=new Array(3),pt=new Array(3);function wt(t){return o(t)}function Dt(t,e){const r=e[0],n=e[1],i=e[2];let s=r*r+n*n+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function Bt(t,e,r,n){r=r||0,n=n||r;var i=Math.abs(t-e);return i<=n||i<=r*Math.max(Math.abs(t),Math.abs(e))}function Lt(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const Pt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function gt(t,e,r){const n=new Uint8Array(t,e,r);return Pt?JSON.parse(Pt.decode(n)):JSON.parse(It(n))}function Gt(t,e,r){const n=new Uint8Array(t,e,r);return Pt?JSON.parse(Pt.decode(n)):JSON.parse(It(n))}function vt(t,e,r){return{offset:e,byteLength:r}}function Xt(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=function(t){return Vt[t]}(s),f=function(t){if(!t)return 1;return xt[t]}(o);return{byteStride:0,byteOffset:i+r,itemSize:f,count:n*f,componentType:c,array:new a(e,r+i,n*f)}}function Ht(t,e,r,n){t.componentType||(t.componentType="UNSIGNED_SHORT");const i=Xt(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const xt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Vt={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function kt(t){for(let e in Vt)if(t===Vt[e].ctor)return Vt[e].type;throw new Error("unrecognized ctor:"+t)}function Zt(t,e,r,n){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*n[0]+r[0],i[3*t+1]=e[3*t+1]/65535*n[1]+r[1],i[3*t+2]=e[3*t+2]/65535*n[2]+r[2];return i}function Yt(t,e,r){let n=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0);const a=t.buffer;let c,f,u={},l={};n>0&&(u=gt(a,e,n),e+=n),i>0&&(c=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(l=Gt(a,e,s),e+=s);const E=vt(0,e,o);return f=a.slice(E.offset,E.offset+E.byteLength),r.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}var Kt={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},zt={},Wt={east:[],north:[],up:[],west:[],south:[],down:[]},jt=[],qt=[],$t=[];const Jt=[0,0,0];const Qt=(ne={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}}[te="east"][ee="north"],zt[ie=te+ee]?re=zt[ie]:(re=function(t,r,n){if(function(t,r){var n=t[0],i=t[1],s=t[2],o=r[0],a=r[1],c=r[2];return Math.abs(n-o)<=e*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=e*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=e*Math.max(1,Math.abs(s),Math.abs(c))}(t,Jt))c(jt,Kt[te]),c(qt,Kt[ee]),c($t,Kt[ne]);else if(Bt(t[0],0,1e-14)&&Bt(t[1],0,1e-14)){var i=Rt(t[2]);c(jt,Kt[te]),"east"!==te&&"west"!==te&&_(jt,jt,i),c(qt,Kt[ee]),"east"!==ee&&"west"!==ee&&_(qt,qt,i),c($t,Kt[ne]),"east"!==ne&&"west"!==ne&&_($t,$t,i)}else{!function(t,e){E(e,t,mt),h(e,e)}(t,Wt.up);var s=Wt.up,o=Wt.east;o[0]=-t[1],o[1]=t[0],o[2]=0,h(Wt.east,o),R(Wt.north,s,o),_(Wt.down,Wt.up,-1),_(Wt.west,Wt.east,-1),_(Wt.south,Wt.north,-1),jt=Wt[te],qt=Wt[ee],$t=Wt[ne]}return n[0]=jt[0],n[1]=jt[1],n[2]=jt[2],n[3]=0,n[4]=qt[0],n[5]=qt[1],n[6]=qt[2],n[7]=0,n[8]=$t[0],n[9]=$t[1],n[10]=$t[2],n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n},zt[ie]=re),re);var te,ee,re,ne,ie;const se={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function oe(t){for(let e in se)if(t===se[e])return+e;throw new Error("unrecognized ctor:"+t)}function ae(t){return 1===t?"FLOAT":"VEC"+t}\n/*!\n * @maptalks/gl v0.68.1\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.com\n */const ce=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")},fe=ce(),ue=fe.gl_trans__coders=fe.gl_trans__coders||{};ue.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=fe.gl_trans__coders=fe.gl_trans__coders||{};let s=`${n}\\n const _____getGlobal = ${ce.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals[\'gl_trans__coders\'] = g___lobals[\'gl_trans__coders\'] || {};`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+=\'tran_____scoders["\'+t+\'"] =\'+i[t].toString()+"\\n;");return s+="\\n"+e.substring(n.length),s},ue.registerTranscoder=function(t,e){ue[t]=e},ue.getTranscoder=function(t){return ue[t]};class le{constructor(t,e,r){this.i=t,this.et=e||at,this.o=r,this.rt={"image/crn":ue.crn&&ue.crn(),"image/ktx2":ue.ktx2&&ue.ktx2(),"image/cttf":ue.ktx2&&ue.ktx2(),"draco":ue.draco&&ue.draco()}}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.nt(t,e,r,n,i)):k.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.nt(t,i,r,n)}))}nt(t,e,r,n,i){const s=i&&i.maxTextureSize,o=this.it(e,r,n,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.et(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.rt,supportedFormats:this.o,maxTextureSize:s});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${r}-${n}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}it(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in b3dm header is inconsistent with b3dm\'s byte length, url: "+n;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),f=i.getUint32(20,!0),u=i.getUint32(24,!0),l=28+e;f>=570425344?(l-=8,o=a,f=c,u=0,a=0,c=0):u>=570425344&&(l-=4,o=f,f=a,u=c,a=0,c=0);const E=[t];let _,A,h;if(a>0?(_=gt(t,l,a),l+=a,o=_.BATCH_LENGTH):_={"BATCH_LENGTH":o},c>0&&(l+=c),f>0&&(A=Gt(t,l,f),l+=f,u>0)){const e=vt(0,l,u);h=t.slice(e.offset,e.offset+e.byteLength),l+=u,E.push(h)}const T=_.BATCH_LENGTH,R={};if(_&&_.BATCH_ID){R.BATCH_ID=Ht(_.BATCH_ID,t,undefined.offset,T);const e=R.BATCH_ID.array&&R.BATCH_ID.array.buffer;e&&E.indexOf(e)<0&&E.push(e)}return{count:o,transferables:E,featureTable:_,batchTable:A,batchTableBin:h,b3dm:R,glb:{buffer:t,byteOffset:l,byteLength:i.byteLength+i.byteOffset-l}}}st(){return null}}class Ee{constructor(t,e,r,n){this.i=t,this.et=e||at,this.o=r,this.rt={"image/crn":ue.crn&&ue.crn(),"image/ktx2":ue.ktx2&&ue.ktx2(),"image/cttf":ue.ktx2&&ue.ktx2(),"draco":ue.draco&&ue.draco()},this.ot=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.nt(t,e,r,n,i)):k.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.nt(t,i,r,n)}))}nt(t,e,r,n,i){return this.at(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const o=this.ct(e,r,n,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}at(t,e,r,n,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.rt,supportedFormats:this.o,maxTextureSize:s},a=new DataView(e,r,n),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let n=It(new Uint8Array(e,c+r,a.byteLength-c));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?k.getArrayBuffer(n,{}).then((t=>this.ft(n,{buffer:t.data,byteOffset:0},o))):k.getJSON(n,{}).then((t=>this.ft(n,t,o)))}{const n={buffer:e,byteOffset:c+r,byteLength:a.byteLength-c};return this.ft(t,n,o)}}ft(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.et(n,e,r);return i.load({skipAttributeTransform:!0}).then((r=>{let n=0,s=0;return e.buffer&&(n=e.byteOffset||0,s=e.byteLength||0),r.url=`${t}-${n}-${s}`,{transferables:i.transferables,gltf:r}}))}ct(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:f,batchTableBin:u}=Yt(i,32+e,o),l={},E=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,r=a.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=a.POSITION_QUANTIZED;l.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:E,componentType:5126,array:this.ut(new Uint16Array(t,n+c.offset,3*E),e,r)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Ht(a.BATCH_ID,t,c.offset,E);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:this.lt(new Uint16Array(t,e+c.offset,2*E))},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:this.lt(new Uint16Array(t,e+c.offset,2*E))},o.push(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,E).slice()},o.push(l.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;l.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:E,batchTable:f,batchTableBin:u,featureTable:a,i3dm:l,transferables:o}}lt(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)_e(n,t[2*i],t[2*i+1],65535),r[3*i]=n[0],r[3*i+1]=n[1],r[3*i+2]=n[2];return r}ut(t,e,r){return Zt(new Float32Array(t.length),t,e,r)}st(){return null}}function _e(t,e,r,n){if(t[0]=Ae(e,n),t[1]=Ae(r,n),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*he(e),t[1]=(1-Math.abs(e))*he(t[1])}return h(t,t)}function Ae(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,r){return t<e?e:t>r?r:t}(t,0,e)/e*2-1}function he(t){return t<0?-1:1}class Te{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.nt(t,e,r,n)):k.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.nt(t,i,r,n)}))}nt(t,e,r,n){return this.Et(e,r,n,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}Et(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:f,batchTableBin:u}=Yt(i,e+28,o),l=a.QUANTIZED_VOLUME_OFFSET,E=a.QUANTIZED_VOLUME_SCALE,_=a.POINTS_LENGTH;let A,h={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){h=a.extensions["3DTILES_draco_point_compression"],A=new DataView(t,h.byteOffset+c.offset,h.byteLength);const e={attributes:h.properties,useUniqueIDs:!1};return this._t||(this._t=ue.draco()),this._t(A,e).then((e=>{const r=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=a.POSITION,r.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=a.RGB,r.RGBA=a.RGBA,r.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=a.NORMAL,r.NORMAL_OCT16P=a.NORMAL_OCT16P);const n=this.At(t,e.attributes,c.offset,_,o,l,E);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:kt(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(f).length){a.BATCH_ID?n.BATCH_ID=Ht(a.BATCH_ID,t,c.offset,_):n.BATCH_ID=Re(_);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:_,batchTable:f,batchTableBin:u,featureTable:a,pnts:n,transferables:o}}))}const T=this.At(t,a,c.offset,_,o,l,E);if(a.BATCH_ID||Object.keys(f).length){a.BATCH_ID?T.BATCH_ID=Ht(a.BATCH_ID,t,c.offset,_):T.BATCH_ID=Re(_);const e=T.BATCH_ID.array&&T.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:_,batchTable:f,batchTableBin:u,featureTable:a,pnts:T,transferables:o})}At(t,e,r,n,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c,array:f}=e.POSITION_QUANTIZED;c=c||0;const u=f?0:r;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.ut(f||new Uint16Array(t,c+u,3*n),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+4*n);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+2*n);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+2*n);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:o},i.push(o.buffer)}return a}ut(t,e,r){return Zt(new Float32Array(t.length),t,e,r)}st(){return null}}function Re(t){const e=(r=t)<256?Uint8Array:r<65536?Uint16Array:Uint32Array;var r;const n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:kt(e),array:n}}class ye{constructor(t,e){this.i=t,this.et=e||at}load(t,e,r=0,n=0,i){return e?this.nt(t,e,r,n,i):k.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.nt(t,i,r,n)}))}nt(t,e,r,n,i){n||(n=e.byteLength);const s=this.ht(e,t,r,n),o=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new le(this.i,this.et);else if("i3dm"===s[r].magic)n=new Ee(this.i,this.et);else if("pnts"===s[r].magic)n=new Te;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new ye(this.i,this.et)}o.push(n.load(t,e,s[r].offset,s[r].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}ht(t,e,r,n){const i=new DataView(t,r,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Lt(i,c),n=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+r,byteLength:n}),c+=n}return o}}function Ie(t,e){if(t.scenes&&t.scenes.length)for(let r=0,n=t.scenes.length;r<n;r++){const n=t.scenes[r].nodes;for(let r=0,i=n.length;r<i;r++){const i=[];Ne(n[r],i,t,e)}}}function Ne(t,e,r,n){if(t.matrix&&e.push(t.matrix),t.children&&t.children.length)for(let i=0,s=t.children.length;i<s;i++)Ne(t.children[i],e,r,n);if(void 0!==t.mesh){const i=t.mesh,s=r.meshes[i];if(s){const t=e.slice(0),o=s.primitives;for(let e=0,s=o.length;e<s;e++){const s=o[e];s&&(s.matrices=t,n(s,i,e,r))}}}}function Ue(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:o}=t;const a=t.array.buffer,c=r?at.getTypedArrayCtor(r):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,i=i||0,s=s||t.array.length/o,(!i||i===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o)}return}const f=new Uint8Array(o*c.BYTES_PER_ELEMENT);i||(i=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(a,i*t+n,o*c.BYTES_PER_ELEMENT);f.set(r);e(new c(f.buffer),t),r.set(f)}}const Se=[],de=[];function me(t){const e={asset:{version:"1.0",gltfUpAxis:"Z",s3mType:t.dataType},geometricError:0,root:{boundingVolume:{},content:{uri:""},transform:[],geometricError:0,refine:"REPLACE",children:[]}},r=t.position.x,n=t.position.y,i=t.position.z,s=function(t,e,r,n){const i=St,s=Math.cos(r);Nt[0]=s*Math.cos(e),Nt[1]=s*Math.sin(e),Nt[2]=Math.sin(r),Dt(Nt,Nt),E(Ut,i,Nt);const o=Math.sqrt(T(Nt,Ut));var a,c,f;return c=Ut,f=o,(a=Ut)[0]=c[0]/f,a[1]=c[1]/f,a[2]=c[2]/f,_(Nt,Nt,n),u(t,Ut,Nt)}([],ht(r),ht(n),i),o=Qt(s,null,[]);e.root.transform=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],o);const a=[];for(let r=0,n=t.tiles.length;r<n;r++)if(t.tiles[r].boundingbox){const n=t.tiles[r].boundingbox;f(Se,n.min.x,n.min.y,n.min.z),f(de,n.max.x,n.max.y,n.max.z);const i={center:[0,0,0],radius:0};Me(Se,de,i),e.root.children.push({boundingVolume:{sphere:[...i.center,i.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(i)}else if(t.tiles[r].boundingsphere){const{boundingsphere:n}=t.tiles[r],i={center:[n.center.x,n.center.y,n.center.z],radius:n.radius};e.root.children.push({boundingVolume:{sphere:[...i.center,i.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(i)}const h=function(t,e){if(0===t.length)return e;const r=t.length;if(1===r)return function(t,e){return c(e.center,t.center),e.radius=t.radius,e}(t[0],e);if(2===r)return function(t,e,r){const n=t.center,i=t.radius,s=e.center,o=e.radius,a=l(Fe,s,n),f=Ve(a);if(i>=f+o)return t.clone(r),r;if(o>=f+i)return e.clone(r),r;const E=.5*(i+f+o),A=_(be,a,(-i+E)/f);return u(A,A,n),c(r.center,A),r.radius=E,r}(t[0],t[1],e);const n=[];for(let e=0;e<r;e++)n.push(t[e].center);const i=(e=function(t,e){if(0===t.length)return e.center=f(e.center,0,0,0),e.radius=0,e;const r=c(Pe,t[0]),n=c(Ce,r),i=c(pe,r),s=c(we,r),o=c(De,r),a=c(Be,r),u=c(Le,r),E=t.length;for(let e=1;e<E;e++){c(r,t[e]);const f=r[0],l=r[1],E=r[2];f<n[0]&&c(n,r),f>o[0]&&c(o,r),l<i[1]&&c(i,r),l>a[1]&&c(a,r),E<s[2]&&c(s,r),E>u[2]&&c(u,r)}const _=xe(l(ge,o,n)),A=xe(l(ge,a,i)),h=xe(l(ge,u,s));let T=n,R=o,y=_;A>y&&(y=A,T=i,R=a);h>y&&(y=h,T=s,R=u);const I=Ge;I[0]=.5*(T[0]+R[0]),I[1]=.5*(T[1]+R[1]),I[2]=.5*(T[2]+R[2]);let N=xe(l(ge,R,I)),U=Math.sqrt(N);const S=ve;S[0]=n[0],S[1]=i[1],S[2]=s[2];const d=Xe;d[0]=o[0],d[1]=a[1],d[2]=u[2];const m=Oe(S,d,He);let M=0;for(let e=0;e<E;e++){c(r,t[e]);const n=Ve(l(ge,r,m));n>M&&(M=n);const i=xe(l(ge,r,I));if(i>N){const t=Math.sqrt(i);U=.5*(U+t),N=U*U;const e=t-U;I[0]=(U*I[0]+e*r[0])/t,I[1]=(U*I[1]+e*r[1])/t,I[2]=(U*I[2]+e*r[2])/t}}U<M?(c(e.center,I),e.radius=U):(c(e.center,m),e.radius=M);return e}(n,e)).center;let s=e.radius;for(let e=0;e<r;e++){const r=t[e];s=Math.max(s,A(i,r.center)+r.radius)}return e.radius=s,e}(a,{center:[0,0,0],radius:0});return e.root.boundingVolume.sphere=[...h.center,h.radius],e}function Me(t,e,r){var n=Oe(t,e,r.center);return r.radius=A(n,e),r}function Oe(t,e,r){return r[0]=.5*(t[0]+e[0]),r[1]=.5*(t[1]+e[1]),r[2]=.5*(t[2]+e[2]),r}const Fe=[],be=[];const Ce=[],pe=[],we=[],De=[],Be=[],Le=[],Pe=[],ge=[],Ge=[],ve=[],Xe=[],He=[];function xe(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function Ve(t){return Math.hypot(t[0],t[1],t[2])}\n/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ke(t){let e=t.length;for(;--e>=0;)t[e]=0}const Ze=256,Ye=286,Ke=30,ze=15,We=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),je=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),qe=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),$e=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Je=new Array(576);ke(Je);const Qe=new Array(60);ke(Qe);const tr=new Array(512);ke(tr);const er=new Array(256);ke(er);const rr=new Array(29);ke(rr);const nr=new Array(Ke);function ir(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let sr,or,ar;function cr(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}ke(nr);const fr=t=>t<256?tr[t]:tr[256+(t>>>7)],ur=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},lr=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,ur(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},Er=(t,e,r)=>{lr(t,r[2*e],r[2*e+1])},_r=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},Ar=(t,e,r)=>{const n=new Array(16);let i,s,o=0;for(i=1;i<=ze;i++)n[i]=o=o+r[i-1]<<1;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=_r(n[e]++,e))}},hr=t=>{let e;for(e=0;e<Ye;e++)t.dyn_ltree[2*e]=0;for(e=0;e<Ke;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},Tr=t=>{t.bi_valid>8?ur(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},Rr=(t,e,r,n)=>{const i=2*e,s=2*r;return t[i]<t[s]||t[i]===t[s]&&n[e]<=n[r]},yr=(t,e,r)=>{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i<t.heap_len&&Rr(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!Rr(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n},Ir=(t,e,r)=>{let n,i,s,o,a=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*a]<<8|t.pending_buf[t.d_buf+2*a+1],i=t.pending_buf[t.l_buf+a],a++,0===n?Er(t,i,e):(s=er[i],Er(t,s+Ze+1,e),o=We[s],0!==o&&(i-=rr[s],lr(t,i,o)),n--,s=fr(n),Er(t,s,r),o=je[s],0!==o&&(n-=nr[s],lr(t,n,o)))}while(a<t.last_lit);Er(t,256,e)},Nr=(t,e)=>{const r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,c,f=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==r[2*o]?(t.heap[++t.heap_len]=f=o,t.depth[o]=0):r[2*o+1]=0;for(;t.heap_len<2;)c=t.heap[++t.heap_len]=f<2?++f:0,r[2*c]=1,t.depth[c]=0,t.opt_len--,i&&(t.static_len-=n[2*c+1]);for(e.max_code=f,o=t.heap_len>>1;o>=1;o--)yr(t,r,o);c=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],yr(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,r[2*c]=r[2*o]+r[2*a],t.depth[c]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,r[2*o+1]=r[2*a+1]=c,t.heap[1]=c++,yr(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,c=e.stat_desc.max_length;let f,u,l,E,_,A,h=0;for(E=0;E<=ze;E++)t.bl_count[E]=0;for(r[2*t.heap[t.heap_max]+1]=0,f=t.heap_max+1;f<573;f++)u=t.heap[f],E=r[2*r[2*u+1]+1]+1,E>c&&(E=c,h++),r[2*u+1]=E,u>n||(t.bl_count[E]++,_=0,u>=a&&(_=o[u-a]),A=r[2*u],t.opt_len+=A*(E+_),s&&(t.static_len+=A*(i[2*u+1]+_)));if(0!==h){do{for(E=c-1;0===t.bl_count[E];)E--;t.bl_count[E]--,t.bl_count[E+1]+=2,t.bl_count[c]--,h-=2}while(h>0);for(E=c;0!==E;E--)for(u=t.bl_count[E];0!==u;)l=t.heap[--f],l>n||(r[2*l+1]!==E&&(t.opt_len+=(E-r[2*l+1])*r[2*l],r[2*l+1]=E),u--)}})(t,e),Ar(r,f,t.bl_count)},Ur=(t,e,r)=>{let n,i,s=-1,o=e[1],a=0,c=7,f=4;for(0===o&&(c=138,f=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++a<c&&i===o||(a<f?t.bl_tree[2*i]+=a:0!==i?(i!==s&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,s=i,0===o?(c=138,f=3):i===o?(c=6,f=3):(c=7,f=4))},Sr=(t,e,r)=>{let n,i,s=-1,o=e[1],a=0,c=7,f=4;for(0===o&&(c=138,f=3),n=0;n<=r;n++)if(i=o,o=e[2*(n+1)+1],!(++a<c&&i===o)){if(a<f)do{Er(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==s&&(Er(t,i,t.bl_tree),a--),Er(t,16,t.bl_tree),lr(t,a-3,2)):a<=10?(Er(t,17,t.bl_tree),lr(t,a-3,3)):(Er(t,18,t.bl_tree),lr(t,a-11,7));a=0,s=i,0===o?(c=138,f=3):i===o?(c=6,f=3):(c=7,f=4)}};let dr=!1;const mr=(t,e,r,n)=>{lr(t,0+(n?1:0),3),((t,e,r,n)=>{Tr(t),n&&(ur(t,r),ur(t,~r)),t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r})(t,e,r,!0)};var Mr=t=>{dr||((()=>{let t,e,r,n,i;const s=new Array(16);for(r=0,n=0;n<28;n++)for(rr[n]=r,t=0;t<1<<We[n];t++)er[r++]=n;for(er[r-1]=n,i=0,n=0;n<16;n++)for(nr[n]=i,t=0;t<1<<je[n];t++)tr[i++]=n;for(i>>=7;n<Ke;n++)for(nr[n]=i<<7,t=0;t<1<<je[n]-7;t++)tr[256+i++]=n;for(e=0;e<=ze;e++)s[e]=0;for(t=0;t<=143;)Je[2*t+1]=8,t++,s[8]++;for(;t<=255;)Je[2*t+1]=9,t++,s[9]++;for(;t<=279;)Je[2*t+1]=7,t++,s[7]++;for(;t<=287;)Je[2*t+1]=8,t++,s[8]++;for(Ar(Je,287,s),t=0;t<Ke;t++)Qe[2*t+1]=5,Qe[2*t]=_r(t,5);sr=new ir(Je,We,257,Ye,ze),or=new ir(Qe,je,0,Ke,ze),ar=new ir(new Array(0),qe,0,19,7)})(),dr=!0),t.l_desc=new cr(t.dyn_ltree,sr),t.d_desc=new cr(t.dyn_dtree,or),t.bl_desc=new cr(t.bl_tree,ar),t.bi_buf=0,t.bi_valid=0,hr(t)},Or=(t,e,r,n)=>{let i,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<Ze;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Nr(t,t.l_desc),Nr(t,t.d_desc),o=(t=>{let e;for(Ur(t,t.dyn_ltree,t.l_desc.max_code),Ur(t,t.dyn_dtree,t.d_desc.max_code),Nr(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*$e[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==e?mr(t,e,r,n):4===t.strategy||s===i?(lr(t,2+(n?1:0),3),Ir(t,Je,Qe)):(lr(t,4+(n?1:0),3),((t,e,r,n)=>{let i;for(lr(t,e-257,5),lr(t,r-1,5),lr(t,n-4,4),i=0;i<n;i++)lr(t,t.bl_tree[2*$e[i]+1],3);Sr(t,t.dyn_ltree,e-1),Sr(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Ir(t,t.dyn_ltree,t.dyn_dtree)),hr(t),n&&Tr(t)},Fr={Tt:Mr,Rt:mr,yt:Or,It:(t,e,r)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(er[r]+Ze+1)]++,t.dyn_dtree[2*fr(e)]++),t.last_lit===t.lit_bufsize-1),Nt:t=>{lr(t,2,3),Er(t,256,Je),(t=>{16===t.bi_valid?(ur(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var br=(t,e,r,n)=>{let i=65535&t|0,s=t>>>16&65535|0,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{i=i+e[n++]|0,s=s+i|0}while(--o);i%=65521,s%=65521}return i|s<<16|0};const Cr=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var pr=(t,e,r,n)=>{const i=Cr,s=n+r;t^=-1;for(let r=n;r<s;r++)t=t>>>8^i[255&(t^e[r])];return-1^t},wr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Dr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{Tt:Br,Rt:Lr,yt:Pr,It:gr,Nt:Gr}=Fr,{Z_NO_FLUSH:vr,Z_PARTIAL_FLUSH:Xr,Z_FULL_FLUSH:Hr,Z_FINISH:xr,Z_BLOCK:Vr,Z_OK:kr,Z_STREAM_END:Zr,Z_STREAM_ERROR:Yr,Z_DATA_ERROR:Kr,Z_BUF_ERROR:zr,Z_DEFAULT_COMPRESSION:Wr,Z_FILTERED:jr,Z_HUFFMAN_ONLY:qr,Z_RLE:$r,Z_FIXED:Jr,Z_DEFAULT_STRATEGY:Qr,Z_UNKNOWN:tn,Z_DEFLATED:en}=Dr,rn=258,nn=262,sn=103,on=113,an=666,cn=(t,e)=>(t.msg=wr[e],e),fn=t=>(t<<1)-(t>4?9:0),un=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let ln=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const En=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},_n=(t,e)=>{Pr(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,En(t.strm)},An=(t,e)=>{t.pending_buf[t.pending++]=e},hn=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Tn=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=br(t.adler,e,i,r):2===t.state.wrap&&(t.adler=pr(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},Rn=(t,e)=>{let r,n,i=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const c=t.strstart>t.w_size-nn?t.strstart-(t.w_size-nn):0,f=t.window,u=t.w_mask,l=t.prev,E=t.strstart+rn;let _=f[s+o-1],A=f[s+o];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(r=e,f[r+o]===A&&f[r+o-1]===_&&f[r]===f[s]&&f[++r]===f[s+1]){s+=2,r++;do{}while(f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&s<E);if(n=rn-(E-s),s=E-rn,n>o){if(t.match_start=e,o=n,n>=a)break;_=f[s+o-1],A=f[s+o]}}}while((e=l[e&u])>c&&0!=--i);return o<=t.lookahead?o:t.lookahead},yn=t=>{const e=t.w_size;let r,n,i,s,o;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-nn)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do{i=t.head[--r],t.head[r]=i>=e?i-e:0}while(--n);n=e,r=n;do{i=t.prev[--r],t.prev[r]=i>=e?i-e:0}while(--n);s+=e}if(0===t.strm.avail_in)break;if(n=Tn(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=n,t.lookahead+t.insert>=3)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=ln(t,t.ins_h,t.window[o+1]);t.insert&&(t.ins_h=ln(t,t.ins_h,t.window[o+3-1]),t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<nn&&0!==t.strm.avail_in)},In=(t,e)=>{let r,n;for(;;){if(t.lookahead<nn){if(yn(t),t.lookahead<nn&&e===vr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-nn&&(t.match_length=Rn(t,r)),t.match_length>=3)if(n=gr(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=ln(t,t.ins_h,t.window[t.strstart+1]);else n=gr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===xr?(_n(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(_n(t,!1),0===t.strm.avail_out)?1:2},Nn=(t,e)=>{let r,n,i;for(;;){if(t.lookahead<nn){if(yn(t),t.lookahead<nn&&e===vr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-nn&&(t.match_length=Rn(t,r),t.match_length<=5&&(t.strategy===jr||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=gr(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(_n(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=gr(t,0,t.window[t.strstart-1]),n&&_n(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=gr(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===xr?(_n(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(_n(t,!1),0===t.strm.avail_out)?1:2};function Un(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}const Sn=[new Un(0,0,0,0,((t,e)=>{let r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(yn(t),0===t.lookahead&&e===vr)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,_n(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-nn&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===xr?(_n(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(_n(t,!1),t.strm.avail_out),1)})),new Un(4,4,8,4,In),new Un(4,5,16,8,In),new Un(4,6,32,32,In),new Un(4,4,16,16,Nn),new Un(8,16,32,32,Nn),new Un(8,16,128,128,Nn),new Un(8,32,128,256,Nn),new Un(32,128,258,1024,Nn),new Un(32,258,258,4096,Nn)];function dn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=en,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),un(this.dyn_ltree),un(this.dyn_dtree),un(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),un(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),un(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const mn=t=>{if(!t||!t.state)return cn(t,Yr);t.total_in=t.total_out=0,t.data_type=tn;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:on,t.adler=2===e.wrap?0:1,e.last_flush=vr,Br(e),kr},Mn=t=>{const e=mn(t);var r;return e===kr&&((r=t.state).window_size=2*r.w_size,un(r.head),r.max_lazy_match=Sn[r.level].max_lazy,r.good_match=Sn[r.level].good_length,r.nice_match=Sn[r.level].nice_length,r.max_chain_length=Sn[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),e},On=(t,e,r,n,i,s)=>{if(!t)return Yr;let o=1;if(e===Wr&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==en||n<8||n>15||e<0||e>9||s<0||s>Jr)return cn(t,Yr);8===n&&(n=9);const a=new dn;return t.state=a,a.strm=t,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=e,a.strategy=s,a.method=r,Mn(t)};var Fn=(t,e)=>{let r=e.length;if(!t||!t.state)return Yr;const n=t.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return Yr;if(1===i&&(t.adler=br(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(un(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,yn(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=ln(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,yn(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,n.wrap=i,kr},bn={deflateInit:(t,e)=>On(t,e,en,15,8,Qr),deflateInit2:On,deflateReset:Mn,deflateResetKeep:mn,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?Yr:(t.state.gzhead=e,kr):Yr,deflate:(t,e)=>{let r,n;if(!t||!t.state||e>Vr||e<0)return t?cn(t,Yr):Yr;const i=t.state;if(!t.output||!t.input&&0!==t.avail_in||i.status===an&&e!==xr)return cn(t,0===t.avail_out?zr:Yr);i.strm=t;const s=i.last_flush;if(i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,An(i,31),An(i,139),An(i,8),i.gzhead?(An(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),An(i,255&i.gzhead.time),An(i,i.gzhead.time>>8&255),An(i,i.gzhead.time>>16&255),An(i,i.gzhead.time>>24&255),An(i,9===i.level?2:i.strategy>=qr||i.level<2?4:0),An(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(An(i,255&i.gzhead.extra.length),An(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=pr(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(An(i,0),An(i,0),An(i,0),An(i,0),An(i,0),An(i,9===i.level?2:i.strategy>=qr||i.level<2?4:0),An(i,3),i.status=on);else{let e=en+(i.w_bits-8<<4)<<8,r=-1;r=i.strategy>=qr||i.level<2?0:i.level<6?1:6===i.level?2:3,e|=r<<6,0!==i.strstart&&(e|=32),e+=31-e%31,i.status=on,hn(i,e),0!==i.strstart&&(hn(i,t.adler>>>16),hn(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),En(t),r=i.pending,i.pending!==i.pending_buf_size));)An(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),En(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,An(i,n)}while(0!==n);i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),En(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,An(i,n)}while(0!==n);i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=sn)}else i.status=sn;if(i.status===sn&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&En(t),i.pending+2<=i.pending_buf_size&&(An(i,255&t.adler),An(i,t.adler>>8&255),t.adler=0,i.status=on)):i.status=on),0!==i.pending){if(En(t),0===t.avail_out)return i.last_flush=-1,kr}else if(0===t.avail_in&&fn(e)<=fn(s)&&e!==xr)return cn(t,zr);if(i.status===an&&0!==t.avail_in)return cn(t,zr);if(0!==t.avail_in||0!==i.lookahead||e!==vr&&i.status!==an){let r=i.strategy===qr?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(yn(t),0===t.lookahead)){if(e===vr)return 1;break}if(t.match_length=0,r=gr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===xr?(_n(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(_n(t,!1),0===t.strm.avail_out)?1:2})(i,e):i.strategy===$r?((t,e)=>{let r,n,i,s;const o=t.window;for(;;){if(t.lookahead<=rn){if(yn(t),t.lookahead<=rn&&e===vr)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){s=t.strstart+rn;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<s);t.match_length=rn-(s-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=gr(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=gr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===xr?(_n(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(_n(t,!1),0===t.strm.avail_out)?1:2})(i,e):Sn[i.level].func(i,e);if(3!==r&&4!==r||(i.status=an),1===r||3===r)return 0===t.avail_out&&(i.last_flush=-1),kr;if(2===r&&(e===Xr?Gr(i):e!==Vr&&(Lr(i,0,0,!1),e===Hr&&(un(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),En(t),0===t.avail_out))return i.last_flush=-1,kr}return e!==xr?kr:i.wrap<=0?Zr:(2===i.wrap?(An(i,255&t.adler),An(i,t.adler>>8&255),An(i,t.adler>>16&255),An(i,t.adler>>24&255),An(i,255&t.total_in),An(i,t.total_in>>8&255),An(i,t.total_in>>16&255),An(i,t.total_in>>24&255)):(hn(i,t.adler>>>16),hn(i,65535&t.adler)),En(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?kr:Zr)},deflateEnd:t=>{if(!t||!t.state)return Yr;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==sn&&e!==on&&e!==an?cn(t,Yr):(t.state=null,e===on?cn(t,Kr):kr)},deflateSetDictionary:Fn,deflateInfo:"pako deflate (from Nodeca project)"};const Cn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var pn=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)Cn(r,e)&&(t[e]=r[e])}}return t},wn=t=>{let e=0;for(let r=0,n=t.length;r<n;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,n=0,i=t.length;e<i;e++){let i=t[e];r.set(i,n),n+=i.length}return r};let Dn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Dn=!1}const Bn=new Uint8Array(256);for(let t=0;t<256;t++)Bn[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Bn[254]=Bn[254]=1;var Ln=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,i,s,o=t.length,a=0;for(i=0;i<o;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<o&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),s=0,i=0;s<a;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<o&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[s++]=r:r<2048?(e[s++]=192|r>>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},Pn=(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,i;const s=new Array(2*r);for(i=0,n=0;n<r;){let e=t[n++];if(e<128){s[i++]=e;continue}let o=Bn[e];if(o>4)s[i++]=65533,n+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&n<r;)e=e<<6|63&t[n++],o--;o>1?s[i++]=65533:e<65536?s[i++]=e:(e-=65536,s[i++]=55296|e>>10&1023,s[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Dn)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r})(s,i)},gn=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+Bn[t[r]]>e?r:e};var Gn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const vn=Object.prototype.toString,{Z_NO_FLUSH:Xn,Z_SYNC_FLUSH:Hn,Z_FULL_FLUSH:xn,Z_FINISH:Vn,Z_OK:kn,Z_STREAM_END:Zn,Z_DEFAULT_COMPRESSION:Yn,Z_DEFAULT_STRATEGY:Kn,Z_DEFLATED:zn}=Dr;function Wn(t){this.options=pn({level:Yn,method:zn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Kn},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gn,this.strm.avail_out=0;let r=bn.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==kn)throw new Error(wr[r]);if(e.header&&bn.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Ln(e.dictionary):"[object ArrayBuffer]"===vn.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=bn.deflateSetDictionary(this.strm,t),r!==kn)throw new Error(wr[r]);this.Ut=!0}}function jn(t,e){const r=new Wn(e);if(r.push(t,!0),r.err)throw r.msg||wr[r.err];return r.result}Wn.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize;let i,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Vn:Xn,"string"==typeof t?r.input=Ln(t):"[object ArrayBuffer]"===vn.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(s===Hn||s===xn)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(i=bn.deflate(r,s),i===Zn)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=bn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===kn;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Wn.prototype.onData=function(t){this.chunks.push(t)},Wn.prototype.onEnd=function(t){t===kn&&(this.result=wn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var qn={Deflate:Wn,deflate:jn,deflateRaw:function(t,e){return(e=e||{}).raw=!0,jn(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,jn(t,e)},constants:Dr};var $n=function(t,e){let r,n,i,s,o,a,c,f,u,l,E,_,A,h,T,R,y,I,N,U,S,d,m,M;const O=t.state;r=t.next_in,m=t.input,n=r+(t.avail_in-5),i=t.next_out,M=t.output,s=i-(e-t.avail_out),o=i+(t.avail_out-257),a=O.dmax,c=O.wsize,f=O.whave,u=O.wnext,l=O.window,E=O.hold,_=O.bits,A=O.lencode,h=O.distcode,T=(1<<O.lenbits)-1,R=(1<<O.distbits)-1;t:do{_<15&&(E+=m[r++]<<_,_+=8,E+=m[r++]<<_,_+=8),y=A[E&T];e:for(;;){if(I=y>>>24,E>>>=I,_-=I,I=y>>>16&255,0===I)M[i++]=65535&y;else{if(!(16&I)){if(0==(64&I)){y=A[(65535&y)+(E&(1<<I)-1)];continue e}if(32&I){O.mode=12;break t}t.msg="invalid literal/length code",O.mode=30;break t}N=65535&y,I&=15,I&&(_<I&&(E+=m[r++]<<_,_+=8),N+=E&(1<<I)-1,E>>>=I,_-=I),_<15&&(E+=m[r++]<<_,_+=8,E+=m[r++]<<_,_+=8),y=h[E&R];r:for(;;){if(I=y>>>24,E>>>=I,_-=I,I=y>>>16&255,!(16&I)){if(0==(64&I)){y=h[(65535&y)+(E&(1<<I)-1)];continue r}t.msg="invalid distance code",O.mode=30;break t}if(U=65535&y,I&=15,_<I&&(E+=m[r++]<<_,_+=8,_<I&&(E+=m[r++]<<_,_+=8)),U+=E&(1<<I)-1,U>a){t.msg="invalid distance too far back",O.mode=30;break t}if(E>>>=I,_-=I,I=i-s,U>I){if(I=U-I,I>f&&O.sane){t.msg="invalid distance too far back",O.mode=30;break t}if(S=0,d=l,0===u){if(S+=c-I,I<N){N-=I;do{M[i++]=l[S++]}while(--I);S=i-U,d=M}}else if(u<I){if(S+=c+u-I,I-=u,I<N){N-=I;do{M[i++]=l[S++]}while(--I);if(S=0,u<N){I=u,N-=I;do{M[i++]=l[S++]}while(--I);S=i-U,d=M}}}else if(S+=u-I,I<N){N-=I;do{M[i++]=l[S++]}while(--I);S=i-U,d=M}for(;N>2;)M[i++]=d[S++],M[i++]=d[S++],M[i++]=d[S++],N-=3;N&&(M[i++]=d[S++],N>1&&(M[i++]=d[S++]))}else{S=i-U;do{M[i++]=M[S++],M[i++]=M[S++],M[i++]=M[S++],N-=3}while(N>2);N&&(M[i++]=M[S++],N>1&&(M[i++]=M[S++]))}break}}break}}while(r<n&&i<o);N=_>>3,r-=N,_-=N<<3,E&=(1<<_)-1,t.next_in=r,t.next_out=i,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=i<o?o-i+257:257-(i-o),O.hold=E,O.bits=_};const Jn=15,Qn=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),ti=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),ei=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ri=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ni=(t,e,r,n,i,s,o,a)=>{const c=a.bits;let f,u,l,E,_,A,h=0,T=0,R=0,y=0,I=0,N=0,U=0,S=0,d=0,m=0,M=null,O=0;const F=new Uint16Array(16),b=new Uint16Array(16);let C,p,w,D=null,B=0;for(h=0;h<=Jn;h++)F[h]=0;for(T=0;T<n;T++)F[e[r+T]]++;for(I=c,y=Jn;y>=1&&0===F[y];y--);if(I>y&&(I=y),0===y)return i[s++]=20971520,i[s++]=20971520,a.bits=1,0;for(R=1;R<y&&0===F[R];R++);for(I<R&&(I=R),S=1,h=1;h<=Jn;h++)if(S<<=1,S-=F[h],S<0)return-1;if(S>0&&(0===t||1!==y))return-1;for(b[1]=0,h=1;h<Jn;h++)b[h+1]=b[h]+F[h];for(T=0;T<n;T++)0!==e[r+T]&&(o[b[e[r+T]]++]=T);if(0===t?(M=D=o,A=19):1===t?(M=Qn,O-=257,D=ti,B-=257,A=256):(M=ei,D=ri,A=-1),m=0,T=0,h=R,_=s,N=I,U=0,l=-1,d=1<<I,E=d-1,1===t&&d>852||2===t&&d>592)return 1;for(;;){C=h-U,o[T]<A?(p=0,w=o[T]):o[T]>A?(p=D[B+o[T]],w=M[O+o[T]]):(p=96,w=0),f=1<<h-U,u=1<<N,R=u;do{u-=f,i[_+(m>>U)+u]=C<<24|p<<16|w|0}while(0!==u);for(f=1<<h-1;m&f;)f>>=1;if(0!==f?(m&=f-1,m+=f):m=0,T++,0==--F[h]){if(h===y)break;h=e[r+o[T]]}if(h>I&&(m&E)!==l){for(0===U&&(U=I),_+=R,N=h-U,S=1<<N;N+U<y&&(S-=F[N+U],!(S<=0));)N++,S<<=1;if(d+=1<<N,1===t&&d>852||2===t&&d>592)return 1;l=m&E,i[l]=I<<24|N<<16|_-s|0}}return 0!==m&&(i[_+m]=h-U<<24|64<<16|0),a.bits=I,0};const{Z_FINISH:ii,Z_BLOCK:si,Z_TREES:oi,Z_OK:ai,Z_STREAM_END:ci,Z_NEED_DICT:fi,Z_STREAM_ERROR:ui,Z_DATA_ERROR:li,Z_MEM_ERROR:Ei,Z_BUF_ERROR:_i,Z_DEFLATED:Ai}=Dr,hi=12,Ti=30,Ri=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function yi(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ii=t=>{if(!t||!t.state)return ui;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,ai},Ni=t=>{if(!t||!t.state)return ui;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Ii(t)},Ui=(t,e)=>{let r;if(!t||!t.state)return ui;const n=t.state;return e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?ui:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,Ni(t))},Si=(t,e)=>{if(!t)return ui;const r=new yi;t.state=r,r.window=null;const n=Ui(t,e);return n!==ai&&(t.state=null),n};let di,mi,Mi=!0;const Oi=t=>{if(Mi){di=new Int32Array(512),mi=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ni(1,t.lens,0,288,di,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ni(2,t.lens,0,32,mi,0,t.work,{bits:5}),Mi=!1}t.lencode=di,t.lenbits=9,t.distcode=mi,t.distbits=5},Fi=(t,e,r,n)=>{let i;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>n&&(i=n),s.window.set(e.subarray(r-n,r-n+i),s.wnext),(n-=i)?(s.window.set(e.subarray(r-n,r),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0};var bi=(t,e)=>{let r,n,i,s,o,a,c,f,u,l,E,_,A,h,T,R,y,I,N,U,S,d,m=0;const M=new Uint8Array(4);let O,F;const b=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return ui;r=t.state,r.mode===hi&&(r.mode=13),o=t.next_out,i=t.output,c=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,f=r.hold,u=r.bits,l=a,E=c,d=ai;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(2&r.wrap&&35615===f){r.check=0,M[0]=255&f,M[1]=f>>>8&255,r.check=pr(r.check,M,2,0),f=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&f)<<8)+(f>>8))%31){t.msg="incorrect header check",r.mode=Ti;break}if((15&f)!==Ai){t.msg="unknown compression method",r.mode=Ti;break}if(f>>>=4,u-=4,S=8+(15&f),0===r.wbits)r.wbits=S;else if(S>r.wbits){t.msg="invalid window size",r.mode=Ti;break}r.dmax=1<<r.wbits,t.adler=r.check=1,r.mode=512&f?10:hi,f=0,u=0;break;case 2:for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(r.flags=f,(255&r.flags)!==Ai){t.msg="unknown compression method",r.mode=Ti;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=Ti;break}r.head&&(r.head.text=f>>8&1),512&r.flags&&(M[0]=255&f,M[1]=f>>>8&255,r.check=pr(r.check,M,2,0)),f=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.head&&(r.head.time=f),512&r.flags&&(M[0]=255&f,M[1]=f>>>8&255,M[2]=f>>>16&255,M[3]=f>>>24&255,r.check=pr(r.check,M,4,0)),f=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.head&&(r.head.xflags=255&f,r.head.os=f>>8),512&r.flags&&(M[0]=255&f,M[1]=f>>>8&255,r.check=pr(r.check,M,2,0)),f=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.length=f,r.head&&(r.head.extra_len=f),512&r.flags&&(M[0]=255&f,M[1]=f>>>8&255,r.check=pr(r.check,M,2,0)),f=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(_=r.length,_>a&&(_=a),_&&(r.head&&(S=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(s,s+_),S)),512&r.flags&&(r.check=pr(r.check,n,_,s)),a-=_,s+=_,r.length-=_),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===a)break t;_=0;do{S=n[s+_++],r.head&&S&&r.length<65536&&(r.head.name+=String.fromCharCode(S))}while(S&&_<a);if(512&r.flags&&(r.check=pr(r.check,n,_,s)),a-=_,s+=_,S)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===a)break t;_=0;do{S=n[s+_++],r.head&&S&&r.length<65536&&(r.head.comment+=String.fromCharCode(S))}while(S&&_<a);if(512&r.flags&&(r.check=pr(r.check,n,_,s)),a-=_,s+=_,S)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(f!==(65535&r.check)){t.msg="header crc mismatch",r.mode=Ti;break}f=0,u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=hi;break;case 10:for(;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}t.adler=r.check=Ri(f),f=0,u=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,r.hold=f,r.bits=u,fi;t.adler=r.check=1,r.mode=hi;case hi:if(e===si||e===oi)break t;case 13:if(r.last){f>>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}switch(r.last=1&f,f>>>=1,u-=1,3&f){case 0:r.mode=14;break;case 1:if(Oi(r),r.mode=20,e===oi){f>>>=2,u-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=Ti}f>>>=2,u-=2;break;case 14:for(f>>>=7&u,u-=7&u;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if((65535&f)!=(f>>>16^65535)){t.msg="invalid stored block lengths",r.mode=Ti;break}if(r.length=65535&f,f=0,u=0,r.mode=15,e===oi)break t;case 15:r.mode=16;case 16:if(_=r.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break t;i.set(n.subarray(s,s+_),o),a-=_,s+=_,c-=_,o+=_,r.length-=_;break}r.mode=hi;break;case 17:for(;u<14;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(r.nlen=257+(31&f),f>>>=5,u-=5,r.ndist=1+(31&f),f>>>=5,u-=5,r.ncode=4+(15&f),f>>>=4,u-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=Ti;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;u<3;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.lens[b[r.have++]]=7&f,f>>>=3,u-=3}for(;r.have<19;)r.lens[b[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,O={bits:r.lenbits},d=ni(0,r.lens,0,19,r.lencode,0,r.work,O),r.lenbits=O.bits,d){t.msg="invalid code lengths set",r.mode=Ti;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=r.lencode[f&(1<<r.lenbits)-1],T=m>>>24,R=m>>>16&255,y=65535&m,!(T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(y<16)f>>>=T,u-=T,r.lens[r.have++]=y;else{if(16===y){for(F=T+2;u<F;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(f>>>=T,u-=T,0===r.have){t.msg="invalid bit length repeat",r.mode=Ti;break}S=r.lens[r.have-1],_=3+(3&f),f>>>=2,u-=2}else if(17===y){for(F=T+3;u<F;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=T,u-=T,S=0,_=3+(7&f),f>>>=3,u-=3}else{for(F=T+7;u<F;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=T,u-=T,S=0,_=11+(127&f),f>>>=7,u-=7}if(r.have+_>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=Ti;break}for(;_--;)r.lens[r.have++]=S}}if(r.mode===Ti)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=Ti;break}if(r.lenbits=9,O={bits:r.lenbits},d=ni(1,r.lens,0,r.nlen,r.lencode,0,r.work,O),r.lenbits=O.bits,d){t.msg="invalid literal/lengths set",r.mode=Ti;break}if(r.distbits=6,r.distcode=r.distdyn,O={bits:r.distbits},d=ni(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,O),r.distbits=O.bits,d){t.msg="invalid distances set",r.mode=Ti;break}if(r.mode=20,e===oi)break t;case 20:r.mode=21;case 21:if(a>=6&&c>=258){t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,r.hold=f,r.bits=u,$n(t,E),o=t.next_out,i=t.output,c=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,f=r.hold,u=r.bits,r.mode===hi&&(r.back=-1);break}for(r.back=0;m=r.lencode[f&(1<<r.lenbits)-1],T=m>>>24,R=m>>>16&255,y=65535&m,!(T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(R&&0==(240&R)){for(I=T,N=R,U=y;m=r.lencode[U+((f&(1<<I+N)-1)>>I)],T=m>>>24,R=m>>>16&255,y=65535&m,!(I+T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=I,u-=I,r.back+=I}if(f>>>=T,u-=T,r.back+=T,r.length=y,0===R){r.mode=26;break}if(32&R){r.back=-1,r.mode=hi;break}if(64&R){t.msg="invalid literal/length code",r.mode=Ti;break}r.extra=15&R,r.mode=22;case 22:if(r.extra){for(F=r.extra;u<F;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.length+=f&(1<<r.extra)-1,f>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=r.distcode[f&(1<<r.distbits)-1],T=m>>>24,R=m>>>16&255,y=65535&m,!(T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(0==(240&R)){for(I=T,N=R,U=y;m=r.distcode[U+((f&(1<<I+N)-1)>>I)],T=m>>>24,R=m>>>16&255,y=65535&m,!(I+T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=I,u-=I,r.back+=I}if(f>>>=T,u-=T,r.back+=T,64&R){t.msg="invalid distance code",r.mode=Ti;break}r.offset=y,r.extra=15&R,r.mode=24;case 24:if(r.extra){for(F=r.extra;u<F;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.offset+=f&(1<<r.extra)-1,f>>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=Ti;break}r.mode=25;case 25:if(0===c)break t;if(_=E-c,r.offset>_){if(_=r.offset-_,_>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=Ti;break}_>r.wnext?(_-=r.wnext,A=r.wsize-_):A=r.wnext-_,_>r.length&&(_=r.length),h=r.window}else h=i,A=o-r.offset,_=r.length;_>c&&(_=c),c-=_,r.length-=_;do{i[o++]=h[A++]}while(--_);0===r.length&&(r.mode=21);break;case 26:if(0===c)break t;i[o++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===a)break t;a--,f|=n[s++]<<u,u+=8}if(E-=c,t.total_out+=E,r.total+=E,E&&(t.adler=r.check=r.flags?pr(r.check,i,E,o-E):br(r.check,i,E,o-E)),E=c,(r.flags?f:Ri(f))!==r.check){t.msg="incorrect data check",r.mode=Ti;break}f=0,u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(f!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=Ti;break}f=0,u=0}r.mode=29;case 29:d=ci;break t;case Ti:d=li;break t;case 31:return Ei;default:return ui}return t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,r.hold=f,r.bits=u,(r.wsize||E!==t.avail_out&&r.mode<Ti&&(r.mode<27||e!==ii))&&Fi(t,t.output,t.next_out,E-t.avail_out),l-=t.avail_in,E-=t.avail_out,t.total_in+=l,t.total_out+=E,r.total+=E,r.wrap&&E&&(t.adler=r.check=r.flags?pr(r.check,i,E,t.next_out-E):br(r.check,i,E,t.next_out-E)),t.data_type=r.bits+(r.last?64:0)+(r.mode===hi?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===E||e===ii)&&d===ai&&(d=_i),d},Ci={inflateReset:Ni,inflateReset2:Ui,inflateResetKeep:Ii,inflateInit:t=>Si(t,15),inflateInit2:Si,inflate:bi,inflateEnd:t=>{if(!t||!t.state)return ui;let e=t.state;return e.window&&(e.window=null),t.state=null,ai},inflateGetHeader:(t,e)=>{if(!t||!t.state)return ui;const r=t.state;return 0==(2&r.wrap)?ui:(r.head=e,e.done=!1,ai)},inflateSetDictionary:(t,e)=>{const r=e.length;let n,i,s;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?ui:11===n.mode&&(i=1,i=br(i,e,r,0),i!==n.check)?li:(s=Fi(t,e,r,r),s?(n.mode=31,Ei):(n.havedict=1,ai))):ui},inflateInfo:"pako inflate (from Nodeca project)"};var pi=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const wi=Object.prototype.toString,{Z_NO_FLUSH:Di,Z_FINISH:Bi,Z_OK:Li,Z_STREAM_END:Pi,Z_NEED_DICT:gi,Z_STREAM_ERROR:Gi,Z_DATA_ERROR:vi,Z_MEM_ERROR:Xi}=Dr;function Hi(t){this.options=pn({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gn,this.strm.avail_out=0;let r=Ci.inflateInit2(this.strm,e.windowBits);if(r!==Li)throw new Error(wr[r]);if(this.header=new pi,Ci.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Ln(e.dictionary):"[object ArrayBuffer]"===wi.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Ci.inflateSetDictionary(this.strm,e.dictionary),r!==Li)))throw new Error(wr[r])}function xi(t,e){const r=new Hi(e);if(r.push(t),r.err)throw r.msg||wr[r.err];return r.result}Hi.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Bi:Di,"[object ArrayBuffer]"===wi.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),s=Ci.inflate(r,o),s===gi&&i&&(s=Ci.inflateSetDictionary(r,i),s===Li?s=Ci.inflate(r,o):s===vi&&(s=gi));r.avail_in>0&&s===Pi&&r.state.wrap>0&&0!==t[r.next_in];)Ci.inflateReset(r),s=Ci.inflate(r,o);switch(s){case Gi:case vi:case gi:case Xi:return this.onEnd(s),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||s===Pi))if("string"===this.options.to){let t=gn(r.output,r.next_out),e=r.next_out-t,i=Pn(r.output,t);r.next_out=e,r.avail_out=n-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(s!==Li||0!==a){if(s===Pi)return s=Ci.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},Hi.prototype.onData=function(t){this.chunks.push(t)},Hi.prototype.onEnd=function(t){t===Li&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=wn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Vi={Inflate:Hi,inflate:xi,inflateRaw:function(t,e){return(e=e||{}).raw=!0,xi(t,e)},ungzip:xi,constants:Dr};const{Deflate:ki,deflate:Zi,deflateRaw:Yi,gzip:Ki}=qn,{Inflate:zi,inflate:Wi,inflateRaw:ji,ungzip:qi}=Vi;var $i={Deflate:ki,deflate:Zi,deflateRaw:Yi,gzip:Ki,Inflate:zi,inflate:Wi,inflateRaw:ji,ungzip:qi,constants:Dr},Ji=5,Qi=11,ts=13,es=14;function rs(t,e,r,n){var i=t|e<<8,s=i>>11&31,o=i>>5&63,a=31&i;return r[n+0]=s<<3|s>>2,r[n+1]=o<<2|o>>4,r[n+2]=a<<3|a>>2,r[n+3]=255,i}var ns=new Uint8Array(16),is=new Uint8Array(16);function ss(t,e,r,n){var i=0;0!=(6&n)&&(i=8),function(t,e,r,n){for(var i=rs(e[r+0],e[r+1],ns,0),s=rs(e[r+2],e[r+3],ns,4),o=0;o<3;o++){var a=ns[o],c=ns[4+o];n&&i<=s?(ns[8+o]=(a+c)/2,ns[12+o]=0):(ns[8+o]=(2*a+c)/3,ns[12+o]=(a+2*c)/3)}for(ns[11]=255,ns[15]=n&&i<=s?0:255,o=0;o<4;++o){var f=e[r+4+o];is[4*o+0]=3&f,is[4*o+1]=f>>2&3,is[4*o+2]=f>>4&3,is[4*o+3]=f>>6&3}for(o=0;o<16;++o)for(var u=4*is[o],l=0;l<4;++l)t[4*o+l]=ns[u+l]}(t,e,r+i,0!=(1&n)),0!=(2&n)?function(t,e,r){for(var n=0;n<8;++n){var i=bytes[r+n],s=15&i,o=240&i;t[8*n+3]=s|s<<4,t[8*n+7]=o|o>>4}}(t,0,r):0!=(4&n)&&function(t,e,r){var n=e[r+0],i=e[r+1];if(ns[0]=n,ns[1]=i,n<=i){for(var s=1;s<5;++s)ns[1+s]=((5-s)*n+s*i)/5;ns[6]=0,ns[7]=255}else for(s=1;s<7;++s)ns[1+s]=((7-s)*n+s*i)/7;r+=2;var o=0;for(s=0;s<2;++s){for(var a=0,c=0;c<3;++c)a|=e[r++]<<8*c;for(c=0;c<8;++c){var f=a>>3*c&7;is[o++]=f}}for(s=0;s<16;++s)t[4*s+3]=ns[is[s]]}(t,e,r)}var os=new Uint16Array(4);\n/*! @brief Decompresses an image in memory.\n\n @param rgba\t\tStorage for the decompressed pixels.\n @param width\tThe width of the source image.\n @param height\tThe height of the source image.\n @param blocks\tThe compressed DXT blocks.\n @param flags\tCompression flags.\n\n The decompressed pixels will be written as a contiguous array of width*height\n 16 rgba values, with each component as 1 byte each. In memory this is:\n\n { r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height\n\n The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression,\n however, DXT1 will be used by default if none is specified. All other flags\n are ignored.\n\n Internally this function calls squish::Decompress for each block.\n */\nvar as=new Uint8Array(64);function cs(t){}function fs(){}cs.decode=function(t,e,r,n,i){if(null!=t&&null!=n&&0!=r&&0!=e){var s=0;1&(s=i>11||5===i?4:33)&&32&s?function(t,e,r,n){for(var i=t,s=0,o=0,a=0,c=0,f=0,u=0,l=0,E=0,_=0,A=e/4,h=r/4,T=0;T<h;T++)for(var R=0;R<A;R++)a=4*((h-T)*A+R),os[0]=n[a],os[1]=n[a+1],c=31&os[0],f=2016&os[0],u=63488&os[0],l=31&os[1],E=2016&os[1],_=63488&os[1],os[2]=5*c+3*l>>3|5*f+3*E>>3&2016|5*u+3*_>>3&63488,os[3]=5*l+3*c>>3|5*E+3*f>>3&2016|5*_+3*u>>3&63488,s=n[a+2],i[o=4*T*e+4*R]=os[3&s],i[o+1]=os[s>>2&3],i[o+2]=os[s>>4&3],i[o+3]=os[s>>6&3],i[o+=e]=os[s>>8&3],i[o+1]=os[s>>10&3],i[o+2]=os[s>>12&3],i[o+3]=os[s>>14],s=n[a+3],i[o+=e]=os[3&s],i[o+1]=os[s>>2&3],i[o+2]=os[s>>4&3],i[o+3]=os[s>>6&3],i[o+=e]=os[s>>8&3],i[o+1]=os[s>>10&3],i[o+2]=os[s>>12&3],i[o+3]=os[s>>14]}(t,e,r,n):function(t,e,r,n,i,s){for(var o=0!=(1&i)?8:16,a=0,c=0;c<r;c+=4)for(var f=0;f<e;f+=4){ss(as,n,a,i);for(var u=0,l=0;l<4;++l)for(var E=0;E<4;++E){var _=f+E,A=c+l;if(_<e&&A<r){var h=4*(e*(r-A)+_);if(s===ts||s===es)t[h+2]=as[u++],t[h+1]=as[u++],t[h+0]=as[u++],t[h+3]=as[u++];else for(var T=0;T<4;++T)t[h++]=as[u++]}else u+=4}a+=o}}(t,e,r,n,s,i)}},fs.s3tc=!0,fs.pvrtc=!1,fs.etc1=!1;let us=1,ls=2;const Es=10,_s=11,As=1,hs=2,Ts=16,Rs=32;function ys(t,e,r){r=t.byteLength;return t=t.subarray(0,0+r),new TextDecoder("utf-8").decode(t)}function Is(t,e,r){let n=e.getUint32(r,!0);return r+=Uint32Array.BYTES_PER_ELEMENT,{string:ys(new Uint8Array(t,r,n)),bytesOffset:r+=n}}function Ns(t,e,r,n){let i={},s=[],o=new Array(16);for(let t=0;t<16;t++)o[t]=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;i.matrix=o,i.skeletonNames=s;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<a;n++){let n=Is(t,e,r);s.push(n.string),r=n.bytesOffset}return n.push(i),r}function Us(t,e,r,n){let i={};i.rangeList=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,i.rangeMode=e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let s={};s.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,s.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,s.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;let o=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT,i.boundingSphere={center:s,radius:o};let a=Is(t,e,r),c=a.string;r=a.bytesOffset;let f=c.indexOf("Geometry");if(-1!==f){let t=c.substring(f);c=c.replace(t,"")}i.childTile=c,i.geodes=[];let u=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<u;n++)r=Ns(t,e,r,i.geodes);return n.push(i),r}function Ss(t,e,r,n){let i=e.getUint32(r,!0);if(n.verticesCount=i,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=s*Float32Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*s*Float32Array.BYTES_PER_ELEMENT,c=new Uint8Array(t,r,a);r+=a;let f=n.vertexAttributes,u=n.attrLocation;return u.aPosition=f.length,f.push({index:u.aPosition,typedArray:c,componentsPerAttribute:s,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function ds(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*s*Float32Array.BYTES_PER_ELEMENT,c=new Uint8Array(t,r,a);r+=a;let f=n.vertexAttributes,u=n.attrLocation;return u.aNormal=f.length,f.push({index:u.aNormal,typedArray:c,componentsPerAttribute:s,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function ms(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s,o=n.verticesCount;if(i>0){e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let n=i*Uint8Array.BYTES_PER_ELEMENT*4;s=new Uint8Array(t,r,n).slice(0,n),r+=n}else{s=new Uint8Array(4*o);for(let t=0;t<o;t++)s[4*t]=255,s[4*t+1]=255,s[4*t+2]=255,s[4*t+3]=255}let a=n.vertexAttributes,c=n.attrLocation;return c.aColor=a.length,a.push({index:c.aColor,typedArray:s,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),n.vertexColor=s,r}function Ms(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let s=i*Uint8Array.BYTES_PER_ELEMENT*4,o=new Uint8Array(t,r,s);r+=s;let a=n.vertexAttributes,c=n.attrLocation;return c.aSecondColor=a.length,a.push({index:c.aSecondColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),r}function Os(t,e,r,n){let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*o*Float32Array.BYTES_PER_ELEMENT,c=new Uint8Array(t,r,a);r+=a;let f="aTexCoord"+s,u=n.vertexAttributes,l=n.attrLocation;l[f]=u.length,u.push({index:l[f],typedArray:c,componentsPerAttribute:o,componentDatatype:5126,offsetInBytes:0,strideInBytes:o*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}return r}function Fs(t,e,r,n){let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let s=n.vertexAttributes,o=n.attrLocation;for(let a=0;a<i;a++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let c=i*a*Float32Array.BYTES_PER_ELEMENT;if(17===a){let e=new Uint8Array(t,r,c);n.instanceCount=i,n.instanceMode=a,n.instanceBuffer=e,n.instanceIndex=1;let f,u=a*i*4,l=e.slice(0,u);n.vertexColorInstance=l,17===a?(f=17*Float32Array.BYTES_PER_ELEMENT,o.uv2=s.length,s.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:f,instanceDivisor:1}),o.uv3=s.length,s.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv4=s.length,s.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.secondary_colour=s.length,s.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv6=s.length,s.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1})):29===a&&(f=29*Float32Array.BYTES_PER_ELEMENT,o.uv1=s.length,s.push({index:o.uv1,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:f,instanceDivisor:1,byteLength:c}),o.uv2=s.length,s.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv3=s.length,s.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv4=s.length,s.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv5=s.length,s.push({index:o.uv5,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv6=s.length,s.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:20*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv7=s.length,s.push({index:o.uv7,componentsPerAttribute:3,componentDatatype:5126,normalize:!1,offsetInBytes:24*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.secondary_colour=s.length,s.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:27*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv9=s.length,s.push({index:o.uv9,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:28*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}))}else{let t=i*a;n.instanceBounds=new Float32Array(t);for(let i=0;i<t;i++)n.instanceBounds[i]=e.getFloat32(r+i*Float32Array.BYTES_PER_ELEMENT,!0)}r+=c}return r}function bs(t,e,r,n){return r=Fs(t,e,r=Os(t,e,r=Ms(t,e,r=ms(t,e,r=ds(t,e,r=Ss(t,e,r,n),n),n),n),n),n)}function Cs(t,e,r,n){let i=e.getUint32(r,!0);return n.compressOptions=i,r+=Uint32Array.BYTES_PER_ELEMENT,r=(i&As)===As?function(t,e,r,n){let i=e.getUint32(r,!0);if(n.verticesCount=i,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=s*Int16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let a=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT;let c={};c.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.vertCompressConstant=a,n.minVerticesValue=c;let f=i*s*Int16Array.BYTES_PER_ELEMENT,u=new Uint8Array(t,r,f);r+=f;let l=n.vertexAttributes,E=n.attrLocation;return E.aPosition=l.length,l.push({index:E.aPosition,typedArray:u,componentsPerAttribute:s,componentDatatype:5122,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}(t,e,r,n):Ss(t,e,r,n),r=(i&hs)===hs?function(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=2*i*Int16Array.BYTES_PER_ELEMENT,a=new Uint8Array(t,r,o);r+=o;let c=n.vertexAttributes,f=n.attrLocation;return f.aNormal=c.length,c.push({index:f.aNormal,typedArray:a,componentsPerAttribute:2,componentDatatype:5122,offsetInBytes:0,strideInBytes:s,normalize:!1}),r}(t,e,r,n):ds(t,e,r,n),r=Ms(t,e,r=ms(t,e,r,n),n),r=(i&Ts)===Ts?function(t,e,r,n){n.texCoordCompressConstant=[],n.minTexCoordValue=[];let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT,r+=3*Uint8Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let c=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT,n.texCoordCompressConstant.push(c);let f={};f.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.minTexCoordValue.push(f);let u=o*a*Int16Array.BYTES_PER_ELEMENT,l=new Uint8Array(t,r,u),E=(r+=u)%4;0!==E&&(r+=4-E);let _="aTexCoord"+s,A=n.vertexAttributes,h=n.attrLocation;if(h[_]=A.length,A.push({index:h[_],typedArray:l,componentsPerAttribute:a,componentDatatype:5122,offsetInBytes:0,strideInBytes:a*Int16Array.BYTES_PER_ELEMENT,normalize:!1}),i){u=o*Float32Array.BYTES_PER_ELEMENT;let e=new Uint8Array(t,r,u);r+=u,n.texCoordZMatrix=!0,_="aTexCoordZ"+s,h[_]=A.length,A.push({index:h[_],typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:Float32Array.BYTES_PER_ELEMENT,normalize:!1})}}return r}(t,e,r,n):Os(t,e,r,n),(i&Rs)===Rs&&(n.textureCoordIsW=!0),r=Fs(t,e,r,n)}function ps(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i={},s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT,e.getUint8(r,!0),r+=Uint8Array.BYTES_PER_ELEMENT;let a=e.getUint8(r,!0);if(r+=Uint8Array.BYTES_PER_ELEMENT,r+=Uint8Array.BYTES_PER_ELEMENT,s>0){let e,n=null;1===o||3===o?(e=s*Uint32Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e)):(e=s*Uint16Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e),s%2!=0&&(e+=2)),i.indicesTypedArray=n,r+=e}i.indicesCount=s,i.indexType=o,i.primitiveType=a;let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<c;n++){let n=Is(t,e,r),s=n.string;r=n.bytesOffset,i.materialCode=s}if(0!==r%4){r+=4-r%4}n.push(i)}return r}let ws={red:0,green:0,blue:0,alpha:0};function Ds(t,e,r){let n=t.vertexAttributes,i=t.attrLocation,s=n.length;i[1===r?"instanceId":"batchId"]=s,n.push({index:s,typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,instanceDivisor:r})}fs.parseBuffer=function(t){let e=0,r={version:void 0,groupNode:void 0,geoPackage:{},matrials:void 0,texturePackage:{}},n=new DataView(t);r.version=n.getFloat32(e,!0),e+=Float32Array.BYTES_PER_ELEMENT,r.version>=2&&(n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT),n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT;let i=function(t,e){let r=new Uint8Array(t,e);return $i.inflate(r).buffer}(t,e);n=new DataView(i),e=0;let s=n.getUint32(e,!0);return e+=Uint32Array.BYTES_PER_ELEMENT,e=function(t,e,r,n){let i={},s=[];e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<o;n++)r=Us(t,e,r,s);i.pageLods=s;let a=r%4;return 0!==a&&(r+=4-a),n.groupNode=i,r}(i,n,e,r),e=function(t,e,r,n){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=Is(t,e,r),s=i.string,o=(r=i.bytesOffset)%4;0!==o&&(r+=4-o);let a=e.getUint32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;let c={vertexAttributes:[],attrLocation:{},instanceCount:0,instanceMode:0,instanceIndex:-1};a===us?r=bs(t,e,r,c):a===ls&&(r=Cs(t,e,r,c));let f,u=[];r=ps(t,e,r,u),2===u.length&&13===u[1].primitiveType&&u[1].indicesCount>=3&&(f=S3MEdgeProcessor.createEdgeDataByIndices(c,u[1])),n[s]={vertexPackage:c,arrIndexPackage:u,edgeGeometry:f}}return r+=e.getUint32(r,!0),r+Uint32Array.BYTES_PER_ELEMENT}(i,n,e,r.geoPackage),e=function(t,e,r,n){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=Is(t,e,r),s=i.string,o=(r=i.bytesOffset)%4;0!==o&&(r+=4-o),e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let f=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let u=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let l=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let E=new Uint8Array(t,r,u);r+=u;let _=l===Es||l===_s?33776:33779;if(22===f&&(_=36196),!fs.s3tc&&(33776===_||33779===_)){let t=new Uint8Array(a*c*4);cs.decode(t,a,c,E,l),E=t,f=0,_=l===Es||l===Es?273:4369}n[s]={id:s,width:a,height:c,compressType:f,nFormat:l,internalFormat:_,arrayBufferView:E}}return r}(i,n,e,r.texturePackage),e=function(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=ys(new Uint8Array(t,r,i));return r+=i,n.materials=JSON.parse(s),r}(i,n,e,r),function(t,e,r,n,i,s){if(1==(1&n)){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let n=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let o=0;o<n;o++){let n=Is(t,e,r),o=n.string;r=n.bytesOffset;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let c={};if(i[o].pickInfo=c,-1==i[o].vertexPackage.instanceIndex){let t=new Float32Array(i[o].vertexPackage.verticesCount);for(let n=0;n<a;n++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=[];for(let i=0;i<s;i++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,t.fill(n,i,i+s),o.push({vertexColorOffset:i,vertexColorCount:s,batchId:n})}c[i]=o}Ds(i[o].vertexPackage,t,void 0)}else{let t=i[o].vertexPackage.instanceCount,n=i[o].vertexPackage.instanceBuffer,f=i[o].vertexPackage.instanceMode,u=new Float32Array(t),l=[];for(let t=0;t<a;t++){let t=e.getUint32(r,!0);l.push(t),r+=Uint32Array.BYTES_PER_ELEMENT;let n=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let t=0;t<n;t++)e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT,3===s&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT)}let E=17===f?16:28;E*=Float32Array.BYTES_PER_ELEMENT;for(let e=0;e<t;e++){u[e]=e;let t=e*f*Float32Array.BYTES_PER_ELEMENT+E;Cesium.Color.unpack(n,t,ws);let r=2===s?l[e]:ws.red+256*ws.green+65536*ws.blue;void 0===c[r]&&(c[r]={vertexColorCount:1,instanceIds:[],vertexColorOffset:e}),c[r].instanceIds.push(e)}Ds(i[o].vertexPackage,u,1)}}}}(i,n,e,s,r.geoPackage,r.version),r};class Bs{constructor(t,e,{width:r,height:n,colorDepth:i,format:s}){if(this.format=s,this.offset=e,this.depth=i,this.stride=\n/*!\n * decode-bmp\n * https://github.com/LinusU/decode-bmp\n * MIT License\n */\nfunction(t){const e=t%4;return e?t+4-e:t}(r*this.depth/8),this.size=this.stride*n,this.data=t.subarray(this.offset,this.offset+this.size),this.size!==this.data.byteLength)throw new Error("Truncated bitmap data")}get(t,e,r){const n=this.format.indexOf(r);if(1===this.depth){return(this.data[e*this.stride+(t/8|0)]&1<<7-t%8*1)>>7-t%8*1}if(2===this.depth){return(this.data[e*this.stride+(t/4|0)]&3<<6-t%4*2)>>>6-t%4*2}if(4===this.depth){return(this.data[e*this.stride+(t/2|0)]&15<<4-t%2*4)>>>4-t%2*4}return this.data[e*this.stride+t*(this.depth/8)+n]}}function Ls(t,e,r,n,{width:i=0,height:s=0,icon:o=!1}={}){const a=new DataView(e,r,n);let c,f,u,l,E;o?(c=a.getUint32(0,!0),f=a.getUint32(4,!0)/1|0,u=a.getUint32(8,!0)/2|0,l=a.getUint16(14,!0),E=a.getUint32(32,!0)):(!function(t){if(19778!==t)throw new Error(`Invalid magic byte 0x${t.toString(16)}`)}(a.getUint16(0,!0)),c=14+a.getUint32(14,!0),f=a.getUint32(18,!0),u=a.getUint32(22,!0),l=a.getUint16(28,!0),E=a.getUint32(46,!0)),0===E&&l<=8&&(E=1<<l);const _=0===f?i:f,A=0===u?s:u,h=new Uint8Array(a.buffer,a.byteOffset+c,a.byteLength-c),T=t.byteLength===_*A*4,R=E?function(t,e,r,{width:n,height:i,colorDepth:s,colorCount:o,icon:a}){if(8!==s&&4!==s&&2!==s&&1!==s)throw new Error(`A color depth of ${s} is not supported`);const c=new Bs(r,0,{width:o,height:1,colorDepth:32,format:"BGRA"}),f=new Bs(r,c.offset+c.size,{width:n,height:i,colorDepth:s,format:"C"}),u=a?new Bs(r,f.offset+f.size,{width:n,height:i,colorDepth:1,format:"A"}):null,l=t;let E=0;for(let t=0;t<i;t++)for(let r=0;r<n;r++){const n=f.get(r,i-t-1,"C");l[E++]=c.get(n,0,"R"),l[E++]=c.get(n,0,"G"),l[E++]=c.get(n,0,"B"),e&&(l[E++]=u&&u.get(r,i-t-1,"A")?0:255)}return l}(t,T,h,{width:_,height:A,colorDepth:l,colorCount:E,icon:o}):function(t,e,r,{width:n,height:i,colorDepth:s,icon:o}){if(32!==s&&24!==s)throw new Error(`A color depth of ${s} is not supported`);const a=new Bs(r,0,{width:n,height:i,colorDepth:s,format:"BGRA"}),c=24===s&&o?new Bs(r,a.offset+a.size,{width:n,height:i,colorDepth:1,format:"A"}):null,f=t;let u=0;for(let t=0;t<i;t++)for(let r=0;r<n;r++)f[u++]=a.get(r,i-t-1,"R"),f[u++]=a.get(r,i-t-1,"G"),f[u++]=a.get(r,i-t-1,"B"),e&&(f[u++]=32===s?a.get(r,i-t-1,"A"):c&&c.get(r,i-t-1,"A")?0:255);return f}(t,T,h,{width:_,height:A,colorDepth:l,icon:o});return R}var Ps=Object.freeze({DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,VERTEX_ATTRIB_ARRAY_ENABLED:34338,VERTEX_ATTRIB_ARRAY_SIZE:34339,VERTEX_ATTRIB_ARRAY_STRIDE:34340,VERTEX_ATTRIB_ARRAY_TYPE:34341,VERTEX_ATTRIB_ARRAY_NORMALIZED:34922,VERTEX_ATTRIB_ARRAY_POINTER:34373,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:34975,IMPLEMENTATION_COLOR_READ_TYPE:35738,IMPLEMENTATION_COLOR_READ_FORMAT:35739,COMPILE_STATUS:35713,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX:6401,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444,COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGBA_ASTC_4x4_WEBGL:37808,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGBA_BPTC_UNORM:36492,HALF_FLOAT_OES:36193,DOUBLE:5130,READ_BUFFER:3074,UNPACK_ROW_LENGTH:3314,UNPACK_SKIP_ROWS:3315,UNPACK_SKIP_PIXELS:3316,PACK_ROW_LENGTH:3330,PACK_SKIP_ROWS:3331,PACK_SKIP_PIXELS:3332,COLOR:6144,DEPTH:6145,STENCIL:6146,RED:6403,RGB8:32849,RGBA8:32856,RGB10_A2:32857,TEXTURE_BINDING_3D:32874,UNPACK_SKIP_IMAGES:32877,UNPACK_IMAGE_HEIGHT:32878,TEXTURE_3D:32879,TEXTURE_WRAP_R:32882,MAX_3D_TEXTURE_SIZE:32883,UNSIGNED_INT_2_10_10_10_REV:33640,MAX_ELEMENTS_VERTICES:33e3,MAX_ELEMENTS_INDICES:33001,TEXTURE_MIN_LOD:33082,TEXTURE_MAX_LOD:33083,TEXTURE_BASE_LEVEL:33084,TEXTURE_MAX_LEVEL:33085,MIN:32775,MAX:32776,DEPTH_COMPONENT24:33190,MAX_TEXTURE_LOD_BIAS:34045,TEXTURE_COMPARE_MODE:34892,TEXTURE_COMPARE_FUNC:34893,CURRENT_QUERY:34917,QUERY_RESULT:34918,QUERY_RESULT_AVAILABLE:34919,STREAM_READ:35041,STREAM_COPY:35042,STATIC_READ:35045,STATIC_COPY:35046,DYNAMIC_READ:35049,DYNAMIC_COPY:35050,MAX_DRAW_BUFFERS:34852,DRAW_BUFFER0:34853,DRAW_BUFFER1:34854,DRAW_BUFFER2:34855,DRAW_BUFFER3:34856,DRAW_BUFFER4:34857,DRAW_BUFFER5:34858,DRAW_BUFFER6:34859,DRAW_BUFFER7:34860,DRAW_BUFFER8:34861,DRAW_BUFFER9:34862,DRAW_BUFFER10:34863,DRAW_BUFFER11:34864,DRAW_BUFFER12:34865,DRAW_BUFFER13:34866,DRAW_BUFFER14:34867,DRAW_BUFFER15:34868,MAX_FRAGMENT_UNIFORM_COMPONENTS:35657,MAX_VERTEX_UNIFORM_COMPONENTS:35658,SAMPLER_3D:35679,SAMPLER_2D_SHADOW:35682,FRAGMENT_SHADER_DERIVATIVE_HINT:35723,PIXEL_PACK_BUFFER:35051,PIXEL_UNPACK_BUFFER:35052,PIXEL_PACK_BUFFER_BINDING:35053,PIXEL_UNPACK_BUFFER_BINDING:35055,FLOAT_MAT2x3:35685,FLOAT_MAT2x4:35686,FLOAT_MAT3x2:35687,FLOAT_MAT3x4:35688,FLOAT_MAT4x2:35689,FLOAT_MAT4x3:35690,SRGB:35904,SRGB8:35905,SRGB8_ALPHA8:35907,COMPARE_REF_TO_TEXTURE:34894,RGBA32F:34836,RGB32F:34837,RGBA16F:34842,RGB16F:34843,VERTEX_ATTRIB_ARRAY_INTEGER:35069,MAX_ARRAY_TEXTURE_LAYERS:35071,MIN_PROGRAM_TEXEL_OFFSET:35076,MAX_PROGRAM_TEXEL_OFFSET:35077,MAX_VARYING_COMPONENTS:35659,TEXTURE_2D_ARRAY:35866,TEXTURE_BINDING_2D_ARRAY:35869,R11F_G11F_B10F:35898,UNSIGNED_INT_10F_11F_11F_REV:35899,RGB9_E5:35901,UNSIGNED_INT_5_9_9_9_REV:35902,TRANSFORM_FEEDBACK_BUFFER_MODE:35967,MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:35968,TRANSFORM_FEEDBACK_VARYINGS:35971,TRANSFORM_FEEDBACK_BUFFER_START:35972,TRANSFORM_FEEDBACK_BUFFER_SIZE:35973,TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:35976,RASTERIZER_DISCARD:35977,MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:35978,MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:35979,INTERLEAVED_ATTRIBS:35980,SEPARATE_ATTRIBS:35981,TRANSFORM_FEEDBACK_BUFFER:35982,TRANSFORM_FEEDBACK_BUFFER_BINDING:35983,RGBA32UI:36208,RGB32UI:36209,RGBA16UI:36214,RGB16UI:36215,RGBA8UI:36220,RGB8UI:36221,RGBA32I:36226,RGB32I:36227,RGBA16I:36232,RGB16I:36233,RGBA8I:36238,RGB8I:36239,RED_INTEGER:36244,RGB_INTEGER:36248,RGBA_INTEGER:36249,SAMPLER_2D_ARRAY:36289,SAMPLER_2D_ARRAY_SHADOW:36292,SAMPLER_CUBE_SHADOW:36293,UNSIGNED_INT_VEC2:36294,UNSIGNED_INT_VEC3:36295,UNSIGNED_INT_VEC4:36296,INT_SAMPLER_2D:36298,INT_SAMPLER_3D:36299,INT_SAMPLER_CUBE:36300,INT_SAMPLER_2D_ARRAY:36303,UNSIGNED_INT_SAMPLER_2D:36306,UNSIGNED_INT_SAMPLER_3D:36307,UNSIGNED_INT_SAMPLER_CUBE:36308,UNSIGNED_INT_SAMPLER_2D_ARRAY:36311,DEPTH_COMPONENT32F:36012,DEPTH32F_STENCIL8:36013,FLOAT_32_UNSIGNED_INT_24_8_REV:36269,FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:33296,FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:33297,FRAMEBUFFER_ATTACHMENT_RED_SIZE:33298,FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:33299,FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:33300,FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:33301,FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:33302,FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:33303,FRAMEBUFFER_DEFAULT:33304,UNSIGNED_INT_24_8:34042,DEPTH24_STENCIL8:35056,UNSIGNED_NORMALIZED:35863,DRAW_FRAMEBUFFER_BINDING:36006,READ_FRAMEBUFFER:36008,DRAW_FRAMEBUFFER:36009,READ_FRAMEBUFFER_BINDING:36010,RENDERBUFFER_SAMPLES:36011,FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:36052,MAX_COLOR_ATTACHMENTS:36063,COLOR_ATTACHMENT1:36065,COLOR_ATTACHMENT2:36066,COLOR_ATTACHMENT3:36067,COLOR_ATTACHMENT4:36068,COLOR_ATTACHMENT5:36069,COLOR_ATTACHMENT6:36070,COLOR_ATTACHMENT7:36071,COLOR_ATTACHMENT8:36072,COLOR_ATTACHMENT9:36073,COLOR_ATTACHMENT10:36074,COLOR_ATTACHMENT11:36075,COLOR_ATTACHMENT12:36076,COLOR_ATTACHMENT13:36077,COLOR_ATTACHMENT14:36078,COLOR_ATTACHMENT15:36079,FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:36182,MAX_SAMPLES:36183,HALF_FLOAT:5131,RG:33319,RG_INTEGER:33320,R8:33321,RG8:33323,R16F:33325,R32F:33326,RG16F:33327,RG32F:33328,R8I:33329,R8UI:33330,R16I:33331,R16UI:33332,R32I:33333,R32UI:33334,RG8I:33335,RG8UI:33336,RG16I:33337,RG16UI:33338,RG32I:33339,RG32UI:33340,VERTEX_ARRAY_BINDING:34229,R8_SNORM:36756,RG8_SNORM:36757,RGB8_SNORM:36758,RGBA8_SNORM:36759,SIGNED_NORMALIZED:36764,COPY_READ_BUFFER:36662,COPY_WRITE_BUFFER:36663,COPY_READ_BUFFER_BINDING:36662,COPY_WRITE_BUFFER_BINDING:36663,UNIFORM_BUFFER:35345,UNIFORM_BUFFER_BINDING:35368,UNIFORM_BUFFER_START:35369,UNIFORM_BUFFER_SIZE:35370,MAX_VERTEX_UNIFORM_BLOCKS:35371,MAX_FRAGMENT_UNIFORM_BLOCKS:35373,MAX_COMBINED_UNIFORM_BLOCKS:35374,MAX_UNIFORM_BUFFER_BINDINGS:35375,MAX_UNIFORM_BLOCK_SIZE:35376,MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:35377,MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:35379,UNIFORM_BUFFER_OFFSET_ALIGNMENT:35380,ACTIVE_UNIFORM_BLOCKS:35382,UNIFORM_TYPE:35383,UNIFORM_SIZE:35384,UNIFORM_BLOCK_INDEX:35386,UNIFORM_OFFSET:35387,UNIFORM_ARRAY_STRIDE:35388,UNIFORM_MATRIX_STRIDE:35389,UNIFORM_IS_ROW_MAJOR:35390,UNIFORM_BLOCK_BINDING:35391,UNIFORM_BLOCK_DATA_SIZE:35392,UNIFORM_BLOCK_ACTIVE_UNIFORMS:35394,UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:35395,UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:35396,UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:35398,INVALID_INDEX:4294967295,MAX_VERTEX_OUTPUT_COMPONENTS:37154,MAX_FRAGMENT_INPUT_COMPONENTS:37157,MAX_SERVER_WAIT_TIMEOUT:37137,OBJECT_TYPE:37138,SYNC_CONDITION:37139,SYNC_STATUS:37140,SYNC_FLAGS:37141,SYNC_FENCE:37142,SYNC_GPU_COMMANDS_COMPLETE:37143,UNSIGNALED:37144,SIGNALED:37145,ALREADY_SIGNALED:37146,TIMEOUT_EXPIRED:37147,CONDITION_SATISFIED:37148,WAIT_FAILED:37149,SYNC_FLUSH_COMMANDS_BIT:1,VERTEX_ATTRIB_ARRAY_DIVISOR:35070,ANY_SAMPLES_PASSED:35887,ANY_SAMPLES_PASSED_CONSERVATIVE:36202,SAMPLER_BINDING:35097,RGB10_A2UI:36975,INT_2_10_10_10_REV:36255,TRANSFORM_FEEDBACK:36386,TRANSFORM_FEEDBACK_PAUSED:36387,TRANSFORM_FEEDBACK_ACTIVE:36388,TRANSFORM_FEEDBACK_BINDING:36389,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_SRGB8_ETC2:37493,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37494,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37495,COMPRESSED_RGBA8_ETC2_EAC:37496,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37497,TEXTURE_IMMUTABLE_FORMAT:37167,MAX_ELEMENT_INDEX:36203,TEXTURE_IMMUTABLE_LEVELS:33503,MAX_TEXTURE_MAX_ANISOTROPY_EXT:34047}),gs={UNSIGNED_BYTE:Ps.UNSIGNED_BYTE,UNSIGNED_SHORT:Ps.UNSIGNED_SHORT,UNSIGNED_INT:Ps.UNSIGNED_INT,FLOAT:Ps.FLOAT,HALF_FLOAT:Ps.HALF_FLOAT_OES,UNSIGNED_INT_24_8:Ps.UNSIGNED_INT_24_8,UNSIGNED_SHORT_4_4_4_4:Ps.UNSIGNED_SHORT_4_4_4_4,UNSIGNED_SHORT_5_5_5_1:Ps.UNSIGNED_SHORT_5_5_5_1,UNSIGNED_SHORT_5_6_5:Ps.UNSIGNED_SHORT_5_6_5,toWebGLConstant:function(t,e){switch(t){case gs.UNSIGNED_BYTE:return Ps.UNSIGNED_BYTE;case gs.UNSIGNED_SHORT:return Ps.UNSIGNED_SHORT;case gs.UNSIGNED_INT:return Ps.UNSIGNED_INT;case gs.FLOAT:return Ps.FLOAT;case gs.HALF_FLOAT:return e.webgl2?Ps.HALF_FLOAT:Ps.HALF_FLOAT_OES;case gs.UNSIGNED_INT_24_8:return Ps.UNSIGNED_INT_24_8;case gs.UNSIGNED_SHORT_4_4_4_4:return Ps.UNSIGNED_SHORT_4_4_4_4;case gs.UNSIGNED_SHORT_5_5_5_1:return Ps.UNSIGNED_SHORT_5_5_5_1;case gs.UNSIGNED_SHORT_5_6_5:return gs.UNSIGNED_SHORT_5_6_5}},isPacked:function(t){return t===gs.UNSIGNED_INT_24_8||t===gs.UNSIGNED_SHORT_4_4_4_4||t===gs.UNSIGNED_SHORT_5_5_5_1||t===gs.UNSIGNED_SHORT_5_6_5},sizeInBytes:function(t){switch(t){case gs.UNSIGNED_BYTE:return 1;case gs.UNSIGNED_SHORT:case gs.UNSIGNED_SHORT_4_4_4_4:case gs.UNSIGNED_SHORT_5_5_5_1:case gs.UNSIGNED_SHORT_5_6_5:case gs.HALF_FLOAT:return 2;case gs.UNSIGNED_INT:case gs.FLOAT:case gs.UNSIGNED_INT_24_8:return 4}},validate:function(t){return t===gs.UNSIGNED_BYTE||t===gs.UNSIGNED_SHORT||t===gs.UNSIGNED_INT||t===gs.FLOAT||t===gs.HALF_FLOAT||t===gs.UNSIGNED_INT_24_8||t===gs.UNSIGNED_SHORT_4_4_4_4||t===gs.UNSIGNED_SHORT_5_5_5_1||t===gs.UNSIGNED_SHORT_5_6_5}},Gs=Object.freeze(gs),vs={DEPTH_COMPONENT:Ps.DEPTH_COMPONENT,DEPTH_STENCIL:Ps.DEPTH_STENCIL,ALPHA:Ps.ALPHA,RGB:Ps.RGB,RGBA:Ps.RGBA,LUMINANCE:Ps.LUMINANCE,LUMINANCE_ALPHA:Ps.LUMINANCE_ALPHA,RGB_DXT1:Ps.COMPRESSED_RGB_S3TC_DXT1_EXT,RGBA_DXT1:Ps.COMPRESSED_RGBA_S3TC_DXT1_EXT,RGBA_DXT3:Ps.COMPRESSED_RGBA_S3TC_DXT3_EXT,RGBA_DXT5:Ps.COMPRESSED_RGBA_S3TC_DXT5_EXT,RGB_PVRTC_4BPPV1:Ps.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,RGB_PVRTC_2BPPV1:Ps.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,RGBA_PVRTC_4BPPV1:Ps.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,RGBA_PVRTC_2BPPV1:Ps.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,RGBA_ASTC:Ps.COMPRESSED_RGBA_ASTC_4x4_WEBGL,RGB_ETC1:Ps.COMPRESSED_RGB_ETC1_WEBGL,RGB8_ETC2:Ps.COMPRESSED_RGB8_ETC2,RGBA8_ETC2_EAC:Ps.COMPRESSED_RGBA8_ETC2_EAC,RGBA_BC7:Ps.COMPRESSED_RGBA_BPTC_UNORM,componentsLength:function(t){switch(t){case vs.RGB:return 3;case vs.RGBA:return 4;case vs.LUMINANCE_ALPHA:return 2;case vs.ALPHA:case vs.LUMINANCE:default:return 1}},validate:function(t){return t===vs.DEPTH_COMPONENT||t===vs.DEPTH_STENCIL||t===vs.ALPHA||t===vs.RGB||t===vs.RGBA||t===vs.LUMINANCE||t===vs.LUMINANCE_ALPHA||t===vs.RGB_DXT1||t===vs.RGBA_DXT1||t===vs.RGBA_DXT3||t===vs.RGBA_DXT5||t===vs.RGB_PVRTC_4BPPV1||t===vs.RGB_PVRTC_2BPPV1||t===vs.RGBA_PVRTC_4BPPV1||t===vs.RGBA_PVRTC_2BPPV1||t===vs.RGBA_ASTC||t===vs.RGB_ETC1||t===vs.RGB8_ETC2||t===vs.RGBA8_ETC2_EAC||t===vs.RGBA_BC7},isColorFormat:function(t){return t===vs.ALPHA||t===vs.RGB||t===vs.RGBA||t===vs.LUMINANCE||t===vs.LUMINANCE_ALPHA},isDepthFormat:function(t){return t===vs.DEPTH_COMPONENT||t===vs.DEPTH_STENCIL},isCompressedFormat:function(t){return t===vs.RGB_DXT1||t===vs.RGBA_DXT1||t===vs.RGBA_DXT3||t===vs.RGBA_DXT5||t===vs.RGB_PVRTC_4BPPV1||t===vs.RGB_PVRTC_2BPPV1||t===vs.RGBA_PVRTC_4BPPV1||t===vs.RGBA_PVRTC_2BPPV1||t===vs.RGBA_ASTC||t===vs.RGB_ETC1||t===vs.RGB8_ETC2||t===vs.RGBA8_ETC2_EAC||t===vs.RGBA_BC7},isDXTFormat:function(t){return t===vs.RGB_DXT1||t===vs.RGBA_DXT1||t===vs.RGBA_DXT3||t===vs.RGBA_DXT5},isPVRTCFormat:function(t){return t===vs.RGB_PVRTC_4BPPV1||t===vs.RGB_PVRTC_2BPPV1||t===vs.RGBA_PVRTC_4BPPV1||t===vs.RGBA_PVRTC_2BPPV1},isASTCFormat:function(t){return t===vs.RGBA_ASTC},isETC1Format:function(t){return t===vs.RGB_ETC1},isETC2Format:function(t){return t===vs.RGB8_ETC2||t===vs.RGBA8_ETC2_EAC},isBC7Format:function(t){return t===vs.RGBA_BC7},compressedTextureSizeInBytes:function(t,e,r){switch(t){case vs.RGB_DXT1:case vs.RGBA_DXT1:case vs.RGB_ETC1:case vs.RGB8_ETC2:return Math.floor((e+3)/4)*Math.floor((r+3)/4)*8;case vs.RGBA_DXT3:case vs.RGBA_DXT5:case vs.RGBA_ASTC:case vs.RGBA8_ETC2_EAC:return Math.floor((e+3)/4)*Math.floor((r+3)/4)*16;case vs.RGB_PVRTC_4BPPV1:case vs.RGBA_PVRTC_4BPPV1:return Math.floor((Math.max(e,8)*Math.max(r,8)*4+7)/8);case vs.RGB_PVRTC_2BPPV1:case vs.RGBA_PVRTC_2BPPV1:return Math.floor((Math.max(e,16)*Math.max(r,8)*2+7)/8);case vs.RGBA_BC7:return Math.ceil(e/4)*Math.ceil(r/4)*16;default:return 0}},textureSizeInBytes:function(t,e,r,n){var i=vs.componentsLength(t);return Gs.isPacked(e)&&(i=1),i*Gs.sizeInBytes(e)*r*n},alignmentInBytes:function(t,e,r){var n=vs.textureSizeInBytes(t,e,r,1)%4;return 0===n?4:2===n?2:1},createTypedArray:function(t,e,r,n){var i=Gs.sizeInBytes(e);return new(i===Uint8Array.BYTES_PER_ELEMENT?Uint8Array:i===Uint16Array.BYTES_PER_ELEMENT?Uint16Array:i===Float32Array.BYTES_PER_ELEMENT&&e===Gs.FLOAT?Float32Array:Uint32Array)(vs.componentsLength(t)*r*n)},flipY:function(t,e,r,n,i){if(1===i)return t;for(var s=vs.createTypedArray(e,r,n,i),o=vs.componentsLength(e),a=n*o,c=0;c<i;++c)for(var f=c*n*o,u=(i-c-1)*n*o,l=0;l<a;++l)s[u+l]=t[f+l];return s},toInternalFormat:function(t,e,r){if(!r.webgl2)return t;if(t===vs.DEPTH_STENCIL)return Ps.DEPTH24_STENCIL8;if(t===vs.DEPTH_COMPONENT){if(e===Gs.UNSIGNED_SHORT)return Ps.DEPTH_COMPONENT16;if(e===Gs.UNSIGNED_INT)return Ps.DEPTH_COMPONENT24}if(e===Gs.FLOAT)switch(t){case vs.RGBA:return Ps.RGBA32F;case vs.RGB:return Ps.RGB32F;case vs.RG:return Ps.RG32F;case vs.R:return Ps.R32F}if(e===Gs.HALF_FLOAT)switch(t){case vs.RGBA:return Ps.RGBA16F;case vs.RGB:return Ps.RGB16F;case vs.RG:return Ps.RG16F;case vs.R:return Ps.R16F}return t}},Xs=Object.freeze(vs);function Hs(t,e,r,n,i,s){const o=function(t,e,r,n){let i=t.length,s=r,o=n,a=0;for(;s>0&&o>0;){if(a+=Xs.compressedTextureSizeInBytes(e,s,o),s>>=1,o>>=1,0===s&&0===o)break;s=Math.max(s,1),o=Math.max(o,1)}return a===i}(t,r,i,s);if(!o)return null;const a=6410===r||4369===r;let c=0,f=i,u=s;const l=[];do{let n=Xs.compressedTextureSizeInBytes(r,f,u),i=new Uint8Array(t.buffer,e+c,n);l.push(i),f=Math.max(f>>1,1),u=Math.max(u>>1,1),c+=n}while(c<t.byteLength&&o);return{flipY:a,mipmap:l}}function xs(t,e){for(var r,n,i,s=t.bytesOffset,o=fs.parseBuffer(t.buffer,s),a=o.geoPackage,c=o.groupNode.pageLods,f=[],u=[],l=[],E=[],_=[],A=[],h=[],T=c[0].geodes[0].matrix,R={},y=0;y<o.materials.material.length;y++)R[o.materials.material[y].material.id]=o.materials.material[y].material;var I=Number.MAX_VALUE,N=Number.MAX_VALUE,U=Number.MAX_VALUE,S=Number.MIN_VALUE,d=Number.MIN_VALUE,m=Number.MIN_VALUE;for(var M in a){var O=a[M].vertexPackage;r=O.verticesCount;var F=O.vertexAttributes[0].typedArray.buffer,b=O.vertexAttributes[0].typedArray.byteOffset,C=O.vertexAttributes[0].componentsPerAttribute;i=new Float32Array(F,O.vertexAttributes[0].offsetInBytes+b,r*C);for(let t=0;t<r;t++){var p=i[t*C],w=i[t*C+1],D=i[t*C+2];I=Math.min(I,p),N=Math.min(N,w),U=Math.min(U,D),S=Math.max(S,p),d=Math.max(d,w),m=Math.max(m,D)}f.push(i),Eo("aTexCoord0",O,F,r,l),Eo("batchId",O,F,r,_),O.vertexColor?E.push(O.vertexColor):E.push(void 0);var B=a[M].arrIndexPackage[0].indicesTypedArray,L=B.byteLength/a[M].arrIndexPackage[0].indicesCount;n=new(4===L?Uint32Array:2===L?Uint16Array:Uint8Array)(B.buffer,(a[M].arrIndexPackage[0].bytesOffset||0)+B.byteOffset,a[M].arrIndexPackage[0].indicesCount),u.push(n),n.length,h.push(r);var P=a[M].arrIndexPackage[0].materialCode;A.push(R[P])}var g=[I,N,U],G=[S,d,m];const v=function(t,e,r,n,i,s,o,a,c,f,u,l,E,_,A){let h=0;for(const t in a)a[t].width*a[t].height*4>h&&(h=a[t].width*a[t].height*4);(!ks||h>ks)&&(Vs=new Uint8ClampedArray(h+122),ks=h);const T=[],R={magFilter:9729,minFilter:9729,wrapS:10497,wrapT:10497},y={},I={},N=[],U=[],S=[];for(let c=0;c<r.length;c++){const h=e[c],d=t[c],m=r[c],M=i&&i[c]&&i[c],O=n&&n[c]&&n[c],F=s&&s[c]&&s[c],b=o&&o[c]&&o[c],C={POSITION:{array:m,componentType:5126,count:d,byteOffset:m.byteOffset,byteStride:0,byteLength:m.byteLength,type:ae(m.length/d),itemSize:m.length/d,name:"POSITION",min:f,max:u}};N.indexOf(m.buffer)<0&&N.push(m.buffer),M&&_o(C,"TEXCOORD_0",M,d,N),O&&_o(C,"NORMAL",O,d,N),F&&_o(C,"COLOR_0",F,d,N),b&&_o(C,"_BATCHID",b,d,N);const p={attributes:C,material:c,indices:{array:h.slice(),itemSize:1,byteLength:h.byteLength,byteOffset:0,byteStride:0,name:h,count:h.length,componentType:5123},mode:4};N.push(p.indices.array.buffer);const w={primitives:[p],index:c};I[c]=w;const D={mesh:c,nodeIndex:c,matrix:A};y[c]=D,U.push({nodes:[D]});const B=E[c],L={uFillForeColor:[1,1,1,1]};let P=B.ambient;L.ambientColor=[P.r,P.g,P.b,P.a];let g=B.diffuse;L.uDiffuseColor=[g.r,g.g,g.b,g.a];let G=B.specular;L.specularColor=[G.r,G.g,G.b,G.a],L.shininess=B.shininess,L.bTransparentSorting=B.transparentsorting;let v=B.textureunitstates;if(v.length){L.uTexMatrix=v[0].textureunitstate.texmodmatrix;const t=a[v[0].textureunitstate.id];if(L.uTexture0Width=t.width,v[1]){const t=a[v[1].textureunitstate.id];L.uTexture1Width=t.width}}S.push({pbrMetallicRoughness:{baseColorFactor:[.8,.8,.8,1],metallicFactor:0,roughnessFactor:.5},extensions:{KHR_techniques_webgl:{technique:0,values:L}}}),T.push(Ks(c,E,l,a,_).then((t=>{if(!t)return null;const{array:e,mipmap:r,width:n,height:i,format:s,flipY:o}=t;if(e&&N.indexOf(e.buffer)<0&&N.push(e.buffer),r)for(let t=0;t<r.length;t++)e&&N.indexOf(r[t].buffer)<0&&N.push(r[t].buffer);let a=R;return r&&(a={magFilter:R.magFilter,minFilter:9987,wrapS:R.wrapS,wrapT:R.wrapT}),{materialIndex:c,image:{mipmap:r,array:e,flipY:!!o,width:n,height:i,mimeType:"image/bmp"},sampler:a,format:s,source:c}})))}return Promise.all(T).then((t=>{t=t.filter((t=>!!t));for(let e=0;e<t.length;e++){const{materialIndex:r}=t[e];let n="uTexture";S[r].extensions.KHR_techniques_webgl.values.uTexture&&(n="uTexture2"),S[r].extensions.KHR_techniques_webgl.values[n]={"index":e,"texCoord":r},delete t[e].materialIndex}return{transferables:N,gltf:{"asset":{"generator":"S3M","version":"2.0"},"scene":0,"scenes":U,"nodes":y,"meshes":I,"materials":S,"skins":[],"animations":null,"textures":t,"transferables":[{},{},{},{},{}]}}}))}(h,u,f,null,l,E,_,o.texturePackage,0,g,G,[],A,e,T);return v.then((({gltf:t,transferables:e})=>({gltf:t,featureTable:{"BATCH_LENGTH":0},transferables:e,pageLods:c})))}fs.multiplyByPoint=function(t,e,r){var n=e.x,i=e.y,s=e.z,o=t[0]*n+t[4]*i+t[8]*s+t[12],a=t[1]*n+t[5]*i+t[9]*s+t[13],c=t[2]*n+t[6]*i+t[10]*s+t[14];return r.x=o,r.y=a,r.z=c,r};let Vs,ks=0;let Zs=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(cn){}t&&"undefined"!=typeof createImageBitmap&&(Zs=!0)}const Ys={};function Ks(t,e,r,n,i){const s=Vs;return new Promise((function(r){!function(t){if(e[t].textureunitstates[0]){var o=e[t].textureunitstates[0].textureunitstate.id,a=n[o],c=a.arrayBufferView,f=a.nFormat,u=a.internalFormat;if(function(t){return t===Qs||t===to||t===eo||t===ro||t===no||t===io||t===so||t===oo||t===ao||t===co||t===fo||t===uo||t===lo}(u)&&a.width===a.height){const t=Hs(c,c.byteOffset,u,0,a.width,a.height);if(t){const{mipmap:e,flipY:n}=t;return void r({format:u,mipmap:e,flipY:n,width:a.width,height:a.height})}}let l;l=f>Qi||f===Ji?122+a.width*a.height*4:61+a.width*a.height,cs.decode(s.subarray(122),a.width,a.height,c,f),function(t,e,r){var n=r*(4*e+e%4),i=n+o,s=new DataView(t),o=0;s.setUint16(o,19778,!0),o+=2,s.setUint32(o,i,!0),o+=4,s.setUint32(o,0,!0),o+=4,s.setUint32(o,122,!0),o+=4,s.setUint32(o,108,!0),o+=4,s.setUint32(o,e,!0),o+=4,s.setUint32(o,r,!0),o+=4,s.setUint16(o,1,!0),o+=2,s.setUint16(o,32,!0),o+=2,s.setUint32(o,this.compress,!0),o+=4,s.setUint32(o,n,!0),o+=4,s.setUint32(o,2835,!0),o+=4,s.setUint32(o,2835,!0),o+=4,s.setUint8(o,0,!0),o+=4,s.setUint32(o,0,!0),o+=4,s.setUint32(o,16711680,!0),o+=4,s.setUint32(o,65280,!0),o+=4,s.setUint32(o,255,!0),o+=4,s.setUint32(o,4278190080,!0),o+=4,s.setUint32(o,1466527264,!0),o+=4}(s.buffer,a.width,a.height);let{width:E,height:_}=a;zs(E)||(E=Ws(E)),zs(_)||(_=Ws(_));const A=i;let h;A&&(E=Math.min(A,E),_=Math.min(A,_));let T=6408;const R=a.width*a.height*4;!Zs||E===a.width&&_===a.height?(h=new Uint8Array(3*R/4),T=6407):(Ys[R]||(Ys[R]=new Uint8Array(R)),h=Ys[R]),h=Ls(h,s.buffer,0,l),!Zs||E===a.width&&_===a.height||(h=function(t,e,r,n,i){js||(js=new OffscreenCanvas(2,2),qs=js.getContext("2d"),$s=new OffscreenCanvas(2,2),Js=$s.getContext("2d"));const s=new ImageData(new Uint8ClampedArray(t.buffer),e,r);return js.width=e,js.height=r,qs.putImageData(s,0,0),$s.width=n,$s.height=i,Js.drawImage(js,0,0,n,i),Js.getImageData(0,0,n,i).data}(h,a.width,a.height,E,_)),h.buffer===(Ys[R]&&Ys[R].buffer)&&(h=new Uint8Array(h)),r({array:h,width:E,height:_,format:T})}else r(null)}(t)}))}function zs(t){return 0==(t&t-1)&&0!==t}function Ws(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}let js,qs,$s,Js;const Qs=33776,to=33777,eo=33778,ro=33779,no=35840,io=35841,so=35842,oo=35843,ao=37808,co=36196,fo=37492,uo=37496,lo=36492;function Eo(t,e,r,n,i){var s,o=e.attrLocation[t];if(o){const t=e.vertexAttributes[o];if(t.typedArray.buffer!==r)i.push(t.typedArray);else{var a=t.componentsPerAttribute;var c=new(s=t.componentDatatype,se[s])(r,t.offsetInBytes+t.typedArray.byteOffset,n*a);i.push(c)}}else i.push(void 0)}function _o(t,e,r,n,i){t[e]={array:r,componentType:oe(r.constructor),count:n,byteOffset:r.byteOffset,byteStride:0,byteLength:r.byteLength,type:ae(r.length/n),itemSize:r.length/n,name:e},i.indexOf(r.buffer)<0&&i.push(r.buffer)}var Ao=Io("DXT1"),ho=Io("DXT3"),To=Io("DXT5"),Ro=Io("DX10"),yo=function(t){var e,r,n=new Int32Array(t,0,31);if(542327876!==n[0])throw new Error("Invalid magic number in DDS header");if(4&!n[20])throw new Error("Unsupported format, must contain a FourCC code");var i=n[21];switch(i){case Ao:e=8,r="dxt1";break;case ho:e=16,r="dxt3";break;case To:e=16,r="dxt5";break;case 116:r="rgba32f";break;case Ro:var s=new Uint32Array(t.slice(128,148));r=s[0];var o=s[1];if(s[2],s[3],s[4],3!==o||2!==r)throw new Error("Unsupported DX10 texture format "+r);r="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=i,String.fromCharCode(255&a,a>>8&255,a>>16&255,a>>24&255)))}var a;var c=n[2],f=1;131072&c&&(f=Math.max(1,n[7]));var u=!1;512&n[28]&&(u=!0);var l,E=n[4],_=n[3],A=n[1]+4,h=E,T=_,R=[];i===Ro&&(A+=20);if(u)for(var y=0;y<6;y++){if("rgba32f"!==r)throw new Error("Only RGBA32f cubemaps are supported");E=h,_=T;for(var I=Math.log(E)/Math.log(2)+1,N=0;N<I;N++)l=E*_*16,R.push({offset:A,length:l,shape:[E,_]}),N<f&&(A+=l),E=Math.floor(E/2),_=Math.floor(_/2)}else for(N=0;N<f;N++)l=Math.max(4,E)/4*Math.max(4,_)/4*e,R.push({offset:A,length:l,shape:[E,_]}),A+=l,E=Math.floor(E/2),_=Math.floor(_/2);return{shape:[h,T],images:R,format:r,flags:c,cubemap:u}};function Io(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}const No=Math.PI/180,Uo=6378137*Math.PI/180,So=85.0511287798;function mo(t,e,r){if("EPSG:3857"===r)return function(t,e){const r=So,n=e[0],i=Math.max(Math.min(r,e[1]),-r);let s;s=0===i?0:Math.log(Math.tan((90+i)*No/2))/No;return t[0]=n*Uo,t[1]=s*Uo,t}(t,e);if("EPSG:4326"===r||"EPSG:4490"===r||"identity"===r)return Mo(t,e);if("baidu"===r)return Mo(t,e);throw new Error("unsupported projection:"+r)}function Mo(t,e){return t[0]=e[0],t[1]=e[1],t}function Oo(t,e,r,n){if("EPSG:3857"===n)return function(t,e,r,n){return Co(Fo,t,r,0),mo(Fo,Fo,n),Fo[0]-e[0]}(t,e,r,n);if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return bo(t,e,r);if("baidu"===n)return bo(t,e,r);throw new Error("unsupported projection:"+n)}const Fo=[0,0];function bo(t,e,r){return Co(Fo,t,r,0),Fo[0]-t[0]}function Co(t,e,r,n){if(!e)return null;if(r||(r=0),n||(n=0),!r&&!n)return t[0]=e[0],t[1]=e[1],t;let i,s,o=po(e[1]);if(0!==n){const t=Math.abs(n);o+=2*Math.sin(t/12756274)*(n>0?1:-1),s=wo(180*o/Math.PI,-90,90)}else s=e[1];if(0!==r){const t=Math.abs(r);let n=po(e[0]);n+=2*Math.sqrt(Math.pow(Math.sin(t/12756274),2)/Math.pow(Math.cos(o),2))*(r>0?1:-1),i=wo(180*n/Math.PI,-180,180)}else i=e[0];return t[0]=i,t[1]=s,t}function po(t){return t*Math.PI/180}function wo(t,e,r){if(t===r||t===e)return t;const n=r-e;return((t-e)%n+n)%n+e}const Do=n([]),Bo=ue.draco&&ue.draco(),Lo=ue.ktx2&&ue.ktx2(),Po={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{"componentType":5125,"type":"VEC2"}};function go(t,e,r,i){const s=[],o=[],a=[];for(let e=0;e<t.meshes.length;e++){const{geometry:r,material:n}=t.meshes[e];let i=k.getArrayBuffer(r.url);i.xhr.url=r.url,a.push(i.xhr);const c=i.then((t=>({buffer:t})));s.push(c);const f=[];if(Zo(n,f),f.length){const t=f.map((t=>{const e=k.getArrayBuffer(t.url);return e.xhr.url=t.url,a.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));s.push(...t)}o[e]=f.length}const c=Promise.all(s).then((s=>{for(let t=0;t<s.length;t++)if(!s[t]||!s[t].buffer)return Promise.resolve(null);const a=[];let c=0;for(let t=0;t<o.length;t++){const e=o[t];a.push({geoBuffer:{data:s[c].buffer.data},textureBuffers:s.slice(c+1,e+c+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),c+=1+e}const f=function(t,e,r,i,s){const o={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},a=[];for(let c=0;c<t.meshes.length;c++){const{geometry:f,material:u}=t.meshes[c];let l;l=qo(e[c].geoBuffer.data)?vo(o,c,f,e[c].geoBuffer.data,t.transform,t.center,s):Ho(o,c,f,e[c].geoBuffer.data,t.transform,t.center,s),a.push(l),o.nodes[c]={mesh:c,nodeIndex:c,matrix:n([])},o.scenes[0].nodes[c]=o.nodes[c];const E=Vo(c,o,u,e[c].textureBuffers,r,i);a.push(E)}return Promise.all(a).then((()=>({gltf:o,featureTable:{BATCH_LENGTH:0},transferables:o.transferables})))}(t,a,e,i,r);return f}));return c.xhr=a,c}const Go={"magFilter":9729,"minFilter":9729,"wrapR":10497,"wrapS":10497,"wrapT":10497};function vo(t,e,r,n,i,s,o){const a=r.info.compressedAttributes.attributes.reduce(((t,e,r)=>{const n=Po[e];if(!n)return t;return t[n.name||e]=r,t}),{});return Bo(n,{attributes:a,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((r=>xo(r,t,e,i,s,o)))}var Xo={position:function(t,e,r){const n=3*t.vertexCount,i=new Float32Array(e,r,n);return t.position={array:i,componentType:5126,itemSize:3,count:n/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},r+=4*n},normal:function(t,e,r){var n=3*t.vertexCount;const i=new Float32Array(e,r,n);return t.normal={array:i,componentType:5126,itemSize:3,count:n/3,type:"VEC3"},r+=4*n},uv0:function(t,e,r){var n=2*t.vertexCount;const i=new Float32Array(e,r,n);return t.uv0={array:i,componentType:5126,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},color:function(t,e,r){var n=4*t.vertexCount;const i=new Uint8Array(e,r,n);return t.color={array:i,componentType:5121,itemSize:4,count:n/4,type:"VEC4"},r+=n},featureId:function(t,e,r){return r+=8*t.featureCount},id:function(t,e,r){return r+=8*t.featureCount},faceRange:function(t,e,r){var n=2*t.featureCount;const i=new Uint32Array(e,r,n);return t.faceRange={array:i,componentType:5125,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},uvRegion:function(t,e,r){var n=4*t.vertexCount;const i=new Uint16Array(e,r,n);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n},region:function(t,e,r){var n=4*t.vertexCount;const i=new Uint16Array(e,r,n);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n}};function Ho(t,e,r,n,i,s,o){const a={vertexCount:0},c=new DataView(n);try{var f=0;a.vertexCount=c.getUint32(f,1),f+=4,a.featureCount=c.getUint32(f,1),f+=4;const t=r.info.ordering?null:r.info;if(t){const e=[];for(const r in t)"offset"!==r&&""!==r&&e.push(r);for(var u=0;u<e.length;u++)Xo[e[u]]?f=Xo[e[u]](a,n,f):console.error("Unknown decoder for",e[u])}else{const t=r.info;let e=t.ordering,i=t.featureAttributeOrder;const s=null;s&&s.geometryData&&s.geometryData[0]&&s.geometryData[0].params;for(var l=0;l<e.length;l++){var E=Xo[e[l]];E||console.log(e[l]),f=E(a,n,f)}for(var _=0;_<i.length;_++){var A=Xo[i[_]];A||console.log(i[_]),f=A(a,n,f)}}}catch(t){console.error(t)}a.scale_x=1,a.scale_y=1;const h={};for(const t in a){const e=Po[t]&&Po[t].name;e&&(h[e]=a[t])}if(a.faceRange){const t=a.faceRange.array,e=t.length/2,r=(T=e)<=255?Uint8Array:T<=65535?Uint16Array:Uint32Array,n=new r(h.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const r=e/2,i=t[e],s=t[e+1];for(let t=i;t<=s;t++)n[3*t]=r,n[3*t+1]=r,n[3*t+2]=r}h._BATCHID={componentType:oe(r),array:n,itemSize:1,count:n.length,type:"SCALAR"}}var T;return xo({attributes:h},t,e,i,s,o)}function xo(t,e,r,n,i,s){const o={attributes:t.attributes,material:r,indices:t.indices,mode:4},a=t.attributes.POSITION.array.length/3;!function(t){const e=t.array,r=t.meta&&t.meta["i3s-scale_x"],n=t.meta&&t.meta["i3s-scale_y"];if(r&&n&&(1!==r||1!==n))for(let t=0;t<e.length;t+=3)e[t]*=r.value,e[t+1]*=n.value}(t.attributes.POSITION);const c=function(t,e,r,n){const i=r;let s,o=[0,0,0,1],a=[0,0];const c=mo([],r,n);c[2]=r[2];const f=e&&function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}(Do,e);return Ue(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],f||(o=y(o,o,e)),i&&u(o,o,i),mo(a,o,n),s=o[2]?Oo(o,a,o[2],n):0,t[0]=a[0]-c[0],t[1]=a[1]-c[1],t[2]=s-c[2],t))),c}(t.attributes.POSITION,n,i,s);t.attributes.TEXCOORD_0&&t.attributes.uvRegion&&(!function(t,e,r){for(var n=0;n<t;++n){var i=r[4*n]/65535,s=r[4*n+1]/65535,o=(r[4*n+2]-r[4*n])/65535,a=(r[4*n+3]-r[4*n+1])/65535;e[2*n]*=o,e[2*n]+=i,e[2*n+1]*=a,e[2*n+1]+=s}}(a,t.attributes.TEXCOORD_0.array,t.attributes.uvRegion.array),delete t.attributes.uvRegion),e.meshes[r]={primitives:[o],index:r},e.extensions.CESIUM_RTC={i3sProjCenter:c};for(const r in t.attributes)jo(e.transferables,t.attributes[r].array.buffer);return t.indices&&jo(e.transferables,t.indices.array.buffer),o}function Vo(t,e,r,n,i,s){const o=n.map((t=>function(t,e,r,n,i){if("dds"===e){const e=yo(t),n=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),i="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:n,width:e.shape[0],height:e.shape[1],mimeType:r},sampler:Go,format:i})}if("png"===e||"jpg"===e)return function(t,e){Yo||(Yo=new OffscreenCanvas(2,2),Ko=Yo.getContext("2d"));const r=new Blob([new Uint8Array(t)]);return createImageBitmap(r).then((t=>{let{width:r,height:n}=t;zo(r)||(r=Wo(r)),zo(n)||(n=Wo(n));const i=e;i&&(r=Math.min(i,r),n=Math.min(i,n)),Yo.width=r,Yo.height=n,Ko.drawImage(t,0,0,r,n),t.close();const s=Ko.getImageData(0,0,r,n);return{width:r,height:n,array:new Uint8Array(s.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,i).then((t=>{t.mimeType=r;return{image:t,sampler:Go,format:6408}}));if("ktx2"===e)return Lo(t,n).then((t=>(t.mimeType=r,{image:t,sampler:Go,format:t.format})))}(t.data,t.format,t.mimeType,i,s).then((t=>{if(t.image)if(t.image.array)jo(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let r=0;r<t.image.mipmap.length;r++)jo(e.transferables,t.image.mipmap[r].buffer);return t}))));return Promise.all(o).then((n=>{ko(t,e,r,n)}))}function ko(t,e,r,n){const i=JSON.parse(JSON.stringify(r)),s=e.textures;n.ptr||(n.ptr=0);for(const t in r)r[t]&&r[t].url?(s.push(n[n.ptr++]),i[t]={index:s.length-1},void 0!==r[t].factor&&(i[t].scale=r[t].factor)):At(r[t])&&(i[t]=ko(-1,e,r[t],n));return t>=0&&(e.materials[t]=i),i}function Zo(t,e){for(const r in t)t[r]&&t[r].url?e.push({url:t[r].url,mimeType:t[r].mimeType,format:t[r].format}):At(t[r])&&Zo(t[r],e)}let Yo,Ko;function zo(t){return 0==(t&t-1)&&0!==t}function Wo(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function jo(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function qo(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}const $o=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Jo=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],Qo="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let ta,ea,ra=!1;if("undefined"!=typeof OffscreenCanvas){try{ea=new OffscreenCanvas(2,2).getContext("2d")}catch(cn){}ea&&"undefined"!=typeof createImageBitmap&&(ra=!0)}const na=n([]),ia=[0,0,0],sa=[],oa=[];class aa{constructor(t,e,r,n){this.id=t,this.options=e,this.St=this.requestImage.bind(this),this.dt=r,this.Mt={},n(null,{},[])}Ot(t){this.Ft||(this.bt=new Te,this.Ft=new le(this.St,at,t),this.Ct=new Ee(this.St,at,t))}requestImage(t,e){ra?fetch(t).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{ta.width=t.width,ta.height=t.height,ea.drawImage(t,0,0);const r=ea.getImageData(0,0,ta.width,ta.height);e(null,{width:t.width,height:t.height,data:new Uint8Array(r.data)})})):this.dt("requestImage",{url:t},null,e)}loadTile(t,e){this.Ot(t.supportedFormats);const r=t.url,n=t.arraybuffer;if(function(t){return t.indexOf("i3s:")>=0}(r)){const n=t.i3sInfo,i=this.options.services[t.rootIdx].maxTextureSize||1024,s=go(n,t.supportedFormats,this.options.projection,i);return s.then((t=>{if(delete this.Mt[r],!t)return void e({status:404,url:r,i3sInfo:n});t.gltf.url=r;const{transferables:i}=t;t.magic="b3dm",e(null,t,i)})),void(this.Mt[r]=s.xhr)}if(n){delete this.Mt[r];const i=new DataView(n),s=Lt(i,0);if("{"===s[0]||" "===s[0]||"<"===s[0]){const i=function(t,e,r){if(Qo){const n=new Uint8Array(t,e,r);return Qo.decode(n)}return It(new Uint8Array(t,e,r))}(n,0,n.byteLength),s=JSON.parse(i);this.wt(t.rootIdx,s,n,r,e)}else{const o=i.getFloat32(0,!0);1===o||2===o?this.Dt(n,r,t,e):this.Bt(n,r,t,s,e)}}else{const n=this.options.services[t.rootIdx];let i=n.urlParams;i&&(i=(r.indexOf("?")>0?"&":"?")+i);let s=k.getArrayBuffer(r+(i||""),n.fetchOptions);const o=s.xhr;s=s.then((n=>{delete this.Mt[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.Mt[r],e(t)})),this.Mt[r]=o}}Bt(t,e,r,n,i){const s=this.options.services[r.rootIdx];if("b3dm"===n){this.Ft.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:n}=this.Lt(t,r);i(null,e,n)})).catch((t=>{i(t)}))}else if("pnts"===n){const n=r.transform;this.bt.load(e,t).then((t=>{const{content:e,transferables:s}=this.Pt(t,n,r.rootIdx);i(null,e,s)}))}else if("i3dm"===n){const n=r.transform;this.Ct.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{const{content:e,transferables:s}=this.Pt(t,n,r.rootIdx);i(null,e,s)}))}else if("cmpt"===n){new ye(this.St,at).load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{const{content:e,transferables:n}=this.gt(t,r);i(null,e,n)})).catch((t=>{i(t)}))}}Dt(t,e,r,n){xs({buffer:t,bytesOffset:0},this.options.services[r.rootIdx].maxTextureSize||1024).then((t=>{t.gltf.url=e;const{content:i,transferables:s}=this.Lt(t,r);if(i.magic="b3dm",t.pageLods){const e=this.Gt(t.pageLods);e.length&&(i.children=e)}n(null,i,s)}))}Gt(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(!n.childTile)continue;const i={boundingVolume:{sphere:[n.boundingSphere.center.x,n.boundingSphere.center.y,n.boundingSphere.center.z,n.boundingSphere.radius]},content:{uri:n.childTile},geometricError:n.boundingSphere.radius/n.rangeList*16,refine:"REPLACE"};e.push(i)}return e}wt(t,e,r,n,i){return e.dataType&&e.position?void i(null,me(e)):(e.capabilities,void i(null,e))}gt(t,e){const{tiles:r}=t,n={magic:"cmpt",content:[]},i=[];for(let t=0;t<r.length;t++){const{magic:s}=r[t];if("b3dm"===s){const{content:s,transferables:o}=this.Lt(r[t],e);ua(i,o),n.content.push(s)}else if("i3dm"===s||"pnts"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Pt(r[t],s,o);ua(i,c),n.content.push(a)}else if("cmpt"===s){const{content:s,transferables:o}=this.gt(r[t],e);ua(i,o),n.content.push(s)}}return{content:n,transferables:i}}Lt(t,e){const{gltf:r,transferables:n,featureTable:i}=t;return this.vt(t.gltf),this.convertCoordinates(r,i,e.upAxis,e.transform),delete t.transferables,{content:t,transferables:n}}Pt(t,e,r){const{featureTable:n}=t,i=t.pnts||t.i3dm;let s=n&&n.RTC_CENTER||[0,0,0];if(n.EAST_NORTH_UP&&!i.NORMAL_UP&&!i.NORMAL_UP_OCT32P){const e=new Float32Array(3*i.POSITION.array.length),r=[],n=[],o=[];Ue(i.POSITION,((t,i)=>{u(o,t,s),Qt(o,null,r),function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10]}(n,r);!function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8]}(e.subarray(9*i,9*(i+1)),n)})),i.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const o={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};ca(i.POSITION.array,3,s,na,o);const a=fa(o),f=c([],a),l=[1/0,1/0,1/0],E=[-1/0,-1/0,-1/0];Ue(i.POSITION,(t=>{t[0]=t[0]+s[0]-f[0],t[1]=t[1]+s[1]-f[1],t[2]=t[2]+s[2]-f[2],t[0]<l[0]&&(l[0]=t[0]),t[1]<l[1]&&(l[1]=t[1]),t[2]<l[2]&&(l[2]=t[2]),t[0]>E[0]&&(E[0]=t[0]),t[1]>E[1]&&(E[1]=t[1]),t[2]>E[2]&&(E[2]=t[2])})),i.POSITION.min=l,i.POSITION.max=E,e&&y(a,a,e);const _=this.Xt(a);t.rtcCenter=f,t.rtcCoord=_,t.rootIdx=r;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}vt(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const r=e[t].image&&e[t].image.array;if(r&&r.length){const n=r[0],i=r[1],s=r[2],o=r[3];let a=!0;for(let t=4;t<r.length;t+=4)if(r[t]!==n||r[t+1]!==i||r[t+2]!==s||r[t+3]!==o){a=!1;break}a&&(e[t].image.color=[n/255,i/255,s/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const r=this.Mt[t.url];if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t].abort();else r&&r.abort&&r.abort();delete this.Mt[t.url],e(null)}convertCoordinates(t,e,r,s){let o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center,a=$o;"X"===(r=r&&r.toUpperCase())?a=Jo:"Z"===r&&(a=na),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o);const f={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Ie(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=n(sa);if(t.matrices)for(let r=t.matrices.length-1;r>=0;r--)i(e,e,t.matrices[r]);const r=t.attributes.POSITION.array,s=t.attributes.POSITION.itemSize;i(e,a,e),ca(r,s,o||ia,e,f)}));const u=fa(f),l=c([],u);s&&y(u,u,s),t.extensions.CESIUM_RTC.coord=this.Xt(u),o||(Ie(t,(t=>{if(t.attributes&&t.attributes.POSITION){const e=t.attributes.POSITION;if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return;const r=n(sa);if(t.matrices)for(let e=t.matrices.length-1;e>=0;e--)i(r,r,t.matrices[e]);i(r,a,r);const s=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],f=e[7],u=e[8],l=e[9],E=e[10],_=e[11],A=e[12],h=e[13],T=e[14],R=e[15],y=r*a-n*o,I=r*c-i*o,N=r*f-s*o,U=n*c-i*a,S=n*f-s*a,d=i*f-s*c,m=u*h-l*A,M=u*T-E*A,O=u*R-_*A,F=l*T-E*h,b=l*R-_*h,C=E*R-_*T,p=y*C-I*b+N*F+U*O-S*M+d*m;return p?(p=1/p,t[0]=(a*C-c*b+f*F)*p,t[1]=(i*b-n*C-s*F)*p,t[2]=(h*d-T*S+R*U)*p,t[3]=(E*S-l*d-_*U)*p,t[4]=(c*O-o*C-f*M)*p,t[5]=(r*C-i*O+s*M)*p,t[6]=(T*N-A*d-R*I)*p,t[7]=(u*d-E*N+_*I)*p,t[8]=(o*b-a*O+f*m)*p,t[9]=(n*O-r*b-s*m)*p,t[10]=(A*S-h*N+R*y)*p,t[11]=(l*N-u*S-_*y)*p,t[12]=(a*M-o*F-c*m)*p,t[13]=(r*F-n*M+i*m)*p,t[14]=(h*I-A*U-T*y)*p,t[15]=(u*U-l*I+E*y)*p,t):null}(oa,r),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];Ue(e,(t=>{y(t,t,r),t[0]=t[0]-l[0],t[1]=t[1]-l[1],t[2]=t[2]-l[2],y(t,t,s),t[0]<o[0]&&(o[0]=t[0]),t[1]<o[1]&&(o[1]=t[1]),t[2]<o[2]&&(o[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),e.min=o,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=l)}Xt(t){return 0===U(t)?f([],0,0,-6378137):bt([],t)}onRemove(){}}function ca(t,e,r,n,i){const s=[];for(let o=0,a=t.length;o<a;o+=e){const{xmin:a,ymin:c,xmax:l,ymax:E,hmin:_,hmax:A}=i;f(s,t[o],t[o+1],t[o+2]),y(s,s,n);const h=u(s,r,s);h[0]<a&&(i.xmin=h[0]),h[0]>l&&(i.xmax=h[0]),h[1]<c&&(i.ymin=h[1]),h[1]>E&&(i.ymax=h[1]),e>2&&(h[2]<_&&(i.hmin=h[2]),h[2]>A&&(i.hmax=h[2]))}}function fa(t){const{xmax:e,ymax:r,xmin:n,ymin:i,hmin:s,hmax:o}=t,a=[(n+e)/2,(i+r)/2,(s+o)/2];return e===-1/0&&(a[0]=0),r===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function ua(t,e){for(let r=0;r<e.length;r++)t.indexOf(e[r])<0&&t.push(e[r])}let la=0;class Ea{constructor(t){this.workerId=t,this.workers={},this.Ht={}}addLayer({actorId:t,mapId:e,layerId:r,params:n},i){if(this.xt(e,r))return;const s=this.Vt(e,r),o=n.options,a=this.send.bind(this,t);this.workers[s]=new aa(r,o,a,i)}removeLayer({mapId:t,layerId:e},r){const n=this.xt(t,e),i=this.Vt(t,e);delete this.workers[i],n&&n.onRemove(r)}loadTile({mapId:t,layerId:e,params:r},n){const i=this.xt(t,e);i&&i.loadTile(r,n)}abortTileLoading({mapId:t,layerId:e,params:r},n){const i=this.xt(t,e);i&&i.abortTileLoading(r,n)}receive(t){const e=t.callback,r=this.Ht[e];delete this.Ht[e],r&&t.error?r(new Error(t.error)):r&&r(null,t.data)}send(t,e,r,n,i){const s=i?`${t}-${la++}`:null;i&&(this.Ht[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:r,callback:String(s)},n||[])}Vt(t,e){return`${t}-${e}`}xt(t,e){const r=this.Vt(t,e);return this.workers[r]}}t.initialize=function(){},t.onmessage=function(t,e){const r=t.data;this.dispatcher||(this.dispatcher=new Ea(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[r.command]({actorId:r.actorId,mapId:r.mapId,layerId:r.layerId,params:r.params},((t,r,n)=>{t instanceof Error&&(t={message:t.message}),e(t,r,n)}))},Object.defineProperty(t,"kt",{value:!0})}';for(
|
|
6
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks"),require("@maptalks/gl")):"function"==typeof define&&define.amd?define(["exports","maptalks","@maptalks/gl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).maptalks=t.maptalks||{},t.maptalks,t.maptalksgl)}(this,(function(t,e,r){"use strict";function n(t){if(t&&t.t)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var i=n(e),s=n(r);const o='function(t){var e=1e-6,r="undefined"!=typeof Float32Array?Float32Array:Array;function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],f=e[6],u=e[7],l=e[8],E=e[9],_=e[10],A=e[11],h=e[12],T=e[13],R=e[14],y=e[15],I=r[0],N=r[1],U=r[2],S=r[3];return t[0]=I*n+N*a+U*l+S*h,t[1]=I*i+N*c+U*E+S*T,t[2]=I*s+N*f+U*_+S*R,t[3]=I*o+N*u+U*A+S*y,I=r[4],N=r[5],U=r[6],S=r[7],t[4]=I*n+N*a+U*l+S*h,t[5]=I*i+N*c+U*E+S*T,t[6]=I*s+N*f+U*_+S*R,t[7]=I*o+N*u+U*A+S*y,I=r[8],N=r[9],U=r[10],S=r[11],t[8]=I*n+N*a+U*l+S*h,t[9]=I*i+N*c+U*E+S*T,t[10]=I*s+N*f+U*_+S*R,t[11]=I*o+N*u+U*A+S*y,I=r[12],N=r[13],U=r[14],S=r[15],t[12]=I*n+N*a+U*l+S*h,t[13]=I*i+N*c+U*E+S*T,t[14]=I*s+N*f+U*_+S*R,t[15]=I*o+N*u+U*A+S*y,t}function s(){var t=new r(3);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function o(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function a(t,e,n){var i=new r(3);return i[0]=t,i[1]=e,i[2]=n,i}function c(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function f(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function u(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function l(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function E(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function _(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function A(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}function h(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s),t}function T(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function R(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[0],a=r[1],c=r[2];return t[0]=i*c-s*a,t[1]=s*o-n*c,t[2]=n*a-i*o,t}function y(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,t}var I=l,N=E,U=o;function S(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function d(){var t=new r(4);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function m(t,r,n,i){var s=r[0],o=r[1],a=r[2],c=r[3],f=n[0],u=n[1],l=n[2],E=n[3],_=void 0,A=void 0,h=void 0,T=void 0,R=void 0;return(A=s*f+o*u+a*l+c*E)<0&&(A=-A,f=-f,u=-u,l=-l,E=-E),1-A>e?(_=Math.acos(A),h=Math.sin(_),T=Math.sin((1-i)*_)/h,R=Math.sin(i*_)/h):(T=1-i,R=i),t[0]=T*s+R*f,t[1]=T*o+R*u,t[2]=T*a+R*l,t[3]=T*c+R*E,t}s(),function(){var t,e=(t=new r(4),r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var M,O=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};s(),a(1,0,0),a(0,1,0),d(),d(),M=new r(9),r!=Float32Array&&(M[1]=0,M[2]=0,M[3]=0,M[5]=0,M[6]=0,M[7]=0),M[0]=1,M[4]=1,M[8]=1;\n/*!\n * @maptalks/gltf-loader v0.27.1\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.org\n */\nlet F=0;function b(t){return null==t}function C(t){return!b(t)}function p(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}function w(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView\'s component type: "+t)}function D(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function B(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),r=e.length,n=new Uint8Array(r);for(let t=0;t<r;t++)n[t]=e.charCodeAt(t);return n.buffer}const L=[],P=[],g=[],G=[0,0,0],v=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),X=[1,1,1];function H(t,e,r,n,i,s,o){const a=w(o);if((0===i||i===n*a.BYTES_PER_ELEMENT)&&s%a.BYTES_PER_ELEMENT==0){const i=new a(e,s,r*n);return t.set(i),t}0===i&&(i=n*a.BYTES_PER_ELEMENT);const c=new Uint8Array(n*a.BYTES_PER_ELEMENT);for(let o=0;o<r;o++){let r=null;const f=new Uint8Array(e,i*o+s,n*a.BYTES_PER_ELEMENT);c.set(f),r=new a(c.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const x="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function V(t,e,r){const n=new Uint8Array(t,e,r);return x.decode(n)}const k={get:function(t,e={}){e||(e={});const r=new AbortController,n=r.signal,i=p({},e);i.signal=n,i.method||(i.method="GET");const s=fetch(t,i).then((t=>{const r=this.t(t,e.responseType);return r.message?r:r.then((r=>"arraybuffer"===e.responseType?{data:r,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:r)).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}))})).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}));return s.xhr=r,s},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",k.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?k.jsonp(t):((e=e||{}).responseType="json",k.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+F++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,new Promise((t=>{window[e]=function(n){document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e],t(n)},document.getElementsByTagName("head")[0].appendChild(r)}))}};class Z{constructor(t,e,r){this.i=t,this.decoders=e,this.o=r,this.images={},this.u={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],i=this.l(e,n);return this.getImageByBuffer(i,r)}if(this.u[t.id])return this.u[t.id].then((()=>{const n=this.buffers[t.id],i=this.l(e,n);return this.getImageByBuffer(i,r)}));if(D(t.uri)){const n=this.buffers[t.id]=B(t.uri),i=this.l(e,n);return this.getImageByBuffer(i,r)}return this.u[t.id]=k.getArrayBuffer(t.uri,null).then((n=>{const i=this.buffers[t.id]=n.data,s=this.l(e,i);return this.getImageByBuffer(s,r)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const r=this.decoders;if(r[e.mimeType])return r[e.mimeType](t,{supportedFormats:this.o});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const r=new Blob([t],{type:e.mimeType}),n=URL.createObjectURL(r);return this._(e.id,n)}}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.u[t.id]?this.u[t.id].then((()=>this.images[t.id])):this.u[t.id]=this._(t.id,e)}_(t,e){return new Promise(((r,n)=>{this.i(e,((i,s)=>{i?n(i):(URL.revokeObjectURL(e),this.images[t]=s,r(this.images[t]))}))}))}}const Y=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class K{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.A=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.h()}T(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this.I(t,e,null,0),Promise.resolve(this.accessors[n.id]);if(n&&this.accessors[n.id])return Promise.resolve(this.accessors[n.id]);const i=r.bufferViews[n.bufferView];return this.N(i).then((r=>{const{buffer:i,byteOffset:s}=r;return this.accessors[n.id]=this.I(t,e,i,s)}))}N(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then((()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}));if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(D(e.uri)){const t=this.buffers[e.id]=B(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=k.getArrayBuffer(t,null).then((n=>(r&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=n.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}I(t,e,r,n=0){const i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+n,c=this.U(s.type),f=w(s.componentType),u=o.byteStride||0,l={array:void 0,name:t,accessorName:e,byteLength:s.count*c*f.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c};if(s.min&&(l.min=s.min),s.max&&(l.max=s.max),r)if(this.A)l.byteStride=u,l.byteOffset=a+(s.byteOffset||0),!u||u===c*f.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(l.array=this.S(r,s.count,c,a+(s.byteOffset||0),f),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(r,a,o.byteLength);else if(s.interleaved){l.byteStride=0,l.byteOffset=0;const t=new f(s.count*c);l.array=H(t,r,s.count,c,u,a+(s.byteOffset||0),s.componentType)}else l.byteStride=0,l.array=this.S(r,s.count,c,a+(s.byteOffset||0),f),l.byteOffset=l.array.byteOffset;else{l.array=new f(s.count);const t=l.min||l.max;t&&(l.array[0]=t[0],l.array[1]=t[1],l.array[2]=t[2])}return l}h(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let r=0;r<t.length;r++)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0);else for(const e in t)for(const r in t)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0)}S(t,e,r,n,i){return n%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(n,n+e*r*i.BYTES_PER_ELEMENT),n=0),new i(t,n,r*e)}U(t){const e=Y.indexOf(t);return Y[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,r=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:r}=e;return this.N(e).then((n=>{const{buffer:i,byteOffset:s}=n,o=V(i,s+(e.byteOffset||0),r);return t.content=o,t}))}if(t.uri){if(D(t.uri)){const e=B(t.uri),r=V(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return k.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class z extends Z{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=r,this.accessor=new K(t,e,r)}iterate(t,e){const r=this.gltf[e];if(!r)return;let n=0;for(const e in r)t(e,r[e],n++)}createNode(t){const e={};if(C(t.name)&&(e.name=t.name),C(t.children)&&(e.children=t.children),C(t.jointName)&&(e.jointName=t.jointName),C(t.matrix)&&(e.matrix=t.matrix),C(t.rotation)&&(e.rotation=t.rotation),C(t.scale)&&(e.scale=t.scale),C(t.translation)&&(e.translation=t.translation),C(t.extras)&&(e.extras=t.extras),C(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const r=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(L,e.translation||G),n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,c=i+i,f=r*o,u=n*o,l=n*a,E=i*o,_=i*a,A=i*c,h=s*o,T=s*a,R=s*c;return t[0]=1-l-A,t[1]=u+R,t[2]=E-T,t[3]=0,t[4]=u-R,t[5]=1-f-A,t[6]=_+h,t[7]=0,t[8]=E+T,t[9]=_-h,t[10]=1-f-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(P,e.rotation||v),s=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(g,e.scale||X);return i(s,n,s),i(t,r,s)}return n(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}m(t){const e={};for(const r in t){const n=t[r];let i,s;n.instanceTechnique&&n.instanceTechnique.values?(i=n.instanceTechnique,s=i.values.diffuse):(i=n,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={baseColorTexture:{index:s}};n.name&&(o.name=n.name),n.extensions&&(o.extensions=n.extensions),n.extras&&(o.extras=n.extras),e[r]=o}return e}M(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const r=this.gltf.bufferViews[e.bufferView],n=(r.byteOffset||0)+this.glbBuffer.byteOffset,i=r.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,n,i);return this.getImageByBuffer(s,t)}return this.requestExternalImage(t)}O(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.M(r).then((t=>{const n=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extras:r.extras},sampler:n}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let r,n;if(e.instanceTechnique&&e.instanceTechnique.values?(r=e.instanceTechnique,n=r.values.diffuse):(r=e,n=r.values.tex||r.values.diffuseTex||r.values.diffuse),void 0===n||void 0===this.gltf.textures)return null;const i=this.gltf.textures[n];if(!i)return null;const s=this.gltf.samplers[i.sampler];return{format:i.format||6408,internalFormat:i.internalFormat||6408,type:i.type||5121,sampler:s,source:this.gltf.images[i.source]}}getMaterial(){return null}getAnimations(){return null}}class W extends Z{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.glbBuffer=r,this.buffers={},this.requests={},this.accessor=new K(t,e,r)}iterate(t,e){const r=this.gltf[e];if(r)for(let e=0;e<r.length;e++)t(e,r[e],e)}createNode(t){const e={};return p(e,t),!C(t.weights)&&this.gltf.meshes&&C(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}O(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.M(r).then((t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};p(n,e);const i=C(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),t.format&&(n.format=t.format),n}))}M(t){if(!C(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],r=this.gltf.buffers[e.buffer];if(r.uri)return this.requestImageFromBufferURI(r,e,t);if(this.glbBuffer)return this.F(e,t)}return null}F(t,e){const r=this.l(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}l(t,e,r){r=r||0;const n=t.byteOffset+r,i=t.byteLength;return new Uint8Array(e,n,i)}C(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);return r.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)))}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let r=0;r<e.length;r++)t[r].samplers=e[r];return t}))}getSamplers(t){const e=[];for(let r=0;r<t.length;r++)(C(t[r].input)||C(t[r].output))&&(e.push(this.accessor.T("input",t[r].input)),e.push(this.accessor.T("output",t[r].output)));return Promise.all(e).then((e=>{for(let r=0;r<e.length/2;r++)t[r].input=e[2*r],t[r].output=e[2*r+1],t[r].interpolation||(t[r].interpolation="LINEAR");return t}))}}const j="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class q{static read(t,e=0,r=0){r||(r=t.byteLength);const n=new DataView(t,e,r),i=n.getUint32(4,!0);if(1===i)return q.readV1(n,e);if(2===i)return q.readV2(t,e);throw new Error("Unsupported glb version : "+i)}static readV1(t,e){const r=t.getUint32(8,!0),n=t.getUint32(12,!0);if(r!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb\'s byte length.");const i=$(t.buffer,20+e,n);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+n,buffer:t.buffer,byteLength:r}}}static readV2(t,e){let r,n,i;const s=new DataView(t,e+12);let o=0;for(;o<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,1313821514===c)r=$(t,e+12+o,a);else if(5130562===c){i=e+12+o,n=a;break}o+=a}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function $(t,e,r){if(j){const n=new Uint8Array(t,e,r);return j.decode(n)}return function(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=J[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}(new Uint8Array(t,e,r))}const J=[1,1,1,1,2,2,3,0],Q=[0,0,0],tt=[0,0,0,1],et=[1,1,1],rt={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},nt={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},it={p(t,e,r,n,i,s,o,a){const f=C(t)?e.animations:[e.animations[0]],u={};for(let e=0;e<f.length;e++){const l=f[e],E=l.name||e;if(C(t)&&E!==t)continue;const _=l.channelsMap[r];if(_)for(let t=0;t<_.length;t++){const e=_[t];"translation"===e.target.path?(this.D(i,l.samplers[e.sampler],n,1),u.translation=c(Q,i)):"rotation"===e.target.path?(this.B(s,l.samplers[e.sampler],n,1),u.rotation=O(tt,s)):"scale"===e.target.path?(this.D(o,l.samplers[e.sampler],n,1),u.scale=c(et,o)):"weights"===e.target.path&&a&&(this.D(a,l.samplers[e.sampler],n,a.length),u.weights=a)}}return u},D(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.L(nt,e,r,1*n);i&&(t=function(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e[i]+n*(r[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.L(nt,e,r,1*n);i&&(t=function(t,e){for(let r=0;r<t.length;r++)t[r]=e[r];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.L(nt,e,r,3*n);i&&(t=this.P(t,i,e.input.array,3*n));break}}return t},B(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.L(nt,e,r,1);n&&m(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.L(nt,e,r,1);n&&(t=S(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.L(nt,e,r,3);if(n){for(let t=0;t<n.PREVIOUS.length;t++)n.PREVIOUS[t]=Math.acos(n.PREVIOUS[t]),n.NEXT[t]=Math.acos(n.NEXT[t]);t=this.P(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},G(t,e){const r=t.length;let n,i,s,o=0,a=r-1,c=Math.floor((o+a)/2);for(;o<=r-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const r=t[c];return n=c,i=c+1,s=(e-r)/(t[c+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},L(t,e,r,n){const i=e.input.array,s=e.output.array,o=e.output.itemSize;(r<i[0]||r>i[i.length-1])&&(r=Math.max(i[0],Math.min(i[i.length-1],r))),r===i[i.length-1]&&(r=i[0]);const a=this.G(i,r);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:f,interpolation:u}=a;t.PREINDEX=c,t.NEXTINDEX=f,t.INTERPOLATION=u;const l=o*n;return t.PREVIOUS=s.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=s.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},P(t,e,r,n){const i=e.INTERPOLATION,s=r[e.PREINDEX],o=r[e.NEXTINDEX];for(let r=0;r<3;r++){const a=e.PREVIOUS[n+r],c=(o-s)*e.PREVIOUS[2*n+r],f=e.NEXT[3+r],u=(o-s)*e.NEXT[r],l=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(2*-Math.pow(i,3)+3*Math.pow(i,2))*f+(Math.pow(i,3)-Math.pow(i,2))*u;t[r]=l}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;return f(Q,...rt.TRANSLATION),S(tt,...rt.ROTATION),f(et,...rt.SCALE),this.p(n,t,e,r,Q,tt,et,i)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,r)=>{let n=-1/0,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const r=s[t],o=e.samplers[r.sampler].input.array;o[o.length-1]>n&&(n=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||r;t.timeSpan[o]={max:n,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const r=this.getTimeSpan(t);return r?C(e)?r[e]:r[Object.keys(r)[0]]:null}};let st=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(ue){}t&&"undefined"!=typeof createImageBitmap&&(st=!0)}const ot="undefined"==typeof document?null:document.createElement("canvas");class at{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=q.read(e.buffer,e.byteOffset,e.byteLength);this.v(t,r,n)}else this.v(t,e);this.X=new K(this.rootPath,this.gltf,this.glbBuffer),this.H()}H(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}V(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.X.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.k(t),r=this.Z(),n=this.Y(),i=this.V();return Promise.all([e,r,n,i]).then((t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0])))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const r=e[t];r.channelsMap={};for(let t=0;t<r.channels.length;t++){const e=r.channels[t];r.channelsMap[e.target.node]||(r.channelsMap[e.target.node]=[]),r.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:r}=this.gltf;for(let r=0;r<e.length;r++)e[r].uri&&e[r].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[r].uri});for(let e=0;e<r.length;e++)r[e].uri&&r[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:r[e].uri})}return t}static getAnimationClip(t,e,r,n){return it.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return it.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return w(t)}static readInterleavedArray(t,e,r,n,i,s,o){return H(t,e,r,n,i,s,o)}v(t,e,r){this.gltf=e,this.glbBuffer=r,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=st?lt.bind(this):this.options.requestImage||ct,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new W(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="buffer_"+r}),"buffers"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors")):(this.adapter=new z(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"))}K(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(r=t.children[0])&&isFinite(r)||function(t){return!b(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const n=t.children.map((t=>{const r=e[t];return r.nodeIndex=t,this.K(r,e)}));t.children=n}var r;return t}k(t){return this.W(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.K(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((n,i,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===n&&(r=s),e.push(o)}),"scenes");const n={asset:this.gltf.asset,scene:r,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(n.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.m(this.gltf.materials);n.materials=t}return n}))}W(t){return this.j(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,r)=>{const n=this.adapter.createNode(r,this.meshes,this.skins);t[e]=n}),"nodes"),t}))}q(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.$(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}$(t){const e=t.inverseBindMatrices;return this.adapter.accessor.T("inverseBindMatrices",e).then((e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t)))}Z(){const t=this.gltf.animations;return C(t)?this.adapter.getAnimations(t):null}j(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,i)=>{e.push(this.J(n,t).then((t=>{t.index=i,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.q()),Promise.all(e)}J(t,e){const r=t.primitives.map((t=>this.tt(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return p(r,t),r.primitives=e,r}))}Y(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.O(r));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const r=e[t].image.array;if(e[t]&&r){let t;t=r instanceof ImageBitmap?r:r.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const r={},n=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(r[n[t]]=e[t]);return r}return e}))}tt(t,e){let r;const n=[],i=t.extensions;if(C(t.targets))for(let e=0;e<t.targets.length;e++){const r=t.targets[e];for(const t in r){const i=this.adapter.accessor.T(`morphTargets_${t}_${e}`,r[t]);i&&n.push(i)}}if(i&&i.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:s,attributes:o}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[s],c=this.X.N(a).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:c}=a;s||(s=0);const f=new DataView(n,i+s,c),u={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(f,u).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(c),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor.T(t,e[t]);r&&n.push(r)}if(C(t.indices)){const e=this.adapter.accessor.T("indices",t.indices);e&&n.push(e)}r=Promise.all(n)}return r.then((e=>{if(i&&i.KHR_draco_mesh_compression){const r=t.targets?t.targets.length:0;e[r]=e[r].concat(e.slice(0,r)),e=e[r]}let r,n;const s={attributes:e.reduce(((t,e)=>{if("indices"===e.name)r=e;else if(e.name.indexOf("morphTargets_")>-1)n=n||{},n[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0],{itemSize:n,array:i}=e,s=i.length/n;for(let e=0;e<s;e++)for(let s=0;s<n;s++){const o=e*n+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>r[s]&&(r[s]=i[o])}if(e.quantization){const n=e.quantization,i=n.range/(1<<n.quantizationBits),s=n.minValues;_(t,t,i),u(t,t,s),_(r,r,i),u(r,r,s)}e.min=t,e.max=r}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t}),{}),material:t.material};return r&&(s.indices=r),n&&(s.morphTargets=n),s.mode=C(t.mode)?t.mode:4,C(t.extras)&&(s.extras=t.extras),s}))}}function ct(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!ot)return void e(new Error("There is no canvas to draw image!"));ot.width=r.width,ot.height=r.height;const t=ot.getContext("2d");t.drawImage(r,0,0,r.width,r.height);const n=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(n.data)};e(null,i)},r.onerror=function(t){e(t)},r.src=t}let ft,ut;function lt(t,e){ft||(ft=new OffscreenCanvas(2,2),ut=ft.getContext("2d")),fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{let{width:r,height:n}=t;Et(r)||(r=_t(r)),Et(n)||(n=_t(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r),n=Math.min(i,n)),ft.width=r,ft.height=n,ut.drawImage(t,0,0,r,n),t.close();const s=ut.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function Et(t){return 0==(t&t-1)&&0!==t}function _t(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function At(t){return"object"==typeof t&&!!t}function ht(t){return t*Math.PI/180}function Tt(t){return t/Math.PI*180}function Rt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const yt=[1,1,1,1,2,2,3,0];function It(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=yt[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}const Nt=new Array(3),Ut=new Array(3),St=[40680631590769,40680631590769,40408299984661.445];const dt=[1/6378137,1/6378137,1/6356752.314245179],mt=[1/40680631590769,1/40680631590769,1/40408299984661.445],Mt=new Array(3),Ot=new Array(3),Ft=new Array(3);function bt(t,e){const r=mt,n=function(t,e,r,n,i){const s=e[0],o=e[1],a=e[2],c=r[0],f=r[1],u=r[2],l=s*s*c*c,E=o*o*f*f,A=a*a*u*u,h=l+E+A,T=Math.sqrt(1/h),R=_(Ct,e,T);if(h<i)return isFinite(T)?R:void 0;const y=n[0],I=n[1],N=n[2],U=pt;U[0]=R[0]*y*2,U[1]=R[1]*I*2,U[2]=R[2]*N*2;let S,d,m,M,O,F,b,C,p,w,D,B=(1-T)*wt(e)/(.5*wt(U)),L=0;do{B-=L,m=1/(1+B*y),M=1/(1+B*I),O=1/(1+B*N),F=m*m,b=M*M,C=O*O,p=F*m,w=b*M,D=C*O,S=l*F+E*b+A*C-1,d=l*p*y+E*w*I+A*D*N;L=S/(-2*d)}while(Math.abs(S)>1e-12);return t[0]=s*m,t[1]=o*M,t[2]=a*O,t}(Mt,e,dt,r,.1);let i=N(Ot,n,r);i=Dt(i,i);const s=I(Ft,e,n),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=Rt(T(s,e))*wt(s);return t[0]=Tt(o),t[1]=Tt(a),t[2]=c,t}const Ct=new Array(3),pt=new Array(3);function wt(t){return o(t)}function Dt(t,e){const r=e[0],n=e[1],i=e[2];let s=r*r+n*n+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function Bt(t,e,r,n){r=r||0,n=n||r;var i=Math.abs(t-e);return i<=n||i<=r*Math.max(Math.abs(t),Math.abs(e))}function Lt(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const Pt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function gt(t,e,r){const n=new Uint8Array(t,e,r);return Pt?JSON.parse(Pt.decode(n)):JSON.parse(It(n))}function Gt(t,e,r){const n=new Uint8Array(t,e,r);return Pt?JSON.parse(Pt.decode(n)):JSON.parse(It(n))}function vt(t,e,r){return{offset:e,byteLength:r}}function Xt(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=function(t){return Vt[t]}(s||"UNSIGNED_SHORT"),f=function(t){if(!t)return 1;return xt[t]}(o);return{byteStride:0,byteOffset:i+r,itemSize:f,count:n*f,componentType:c,array:new a(e,r+i,n*f)}}function Ht(t,e,r,n){const i=Xt(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const xt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Vt={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function kt(t){for(let e in Vt)if(t===Vt[e].ctor)return Vt[e].type;throw new Error("unrecognized ctor:"+t)}function Zt(t,e,r,n){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*n[0]+r[0],i[3*t+1]=e[3*t+1]/65535*n[1]+r[1],i[3*t+2]=e[3*t+2]/65535*n[2]+r[2];return i}function Yt(t,e,r){let n=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0);const a=t.buffer;let c,f,u={},l={};n>0&&(u=gt(a,e,n),e+=n),i>0&&(c=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(l=Gt(a,e,s),e+=s);const E=vt(0,e,o);return f=a.slice(E.offset,E.offset+E.byteLength),r.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}var Kt={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},zt={},Wt={east:[],north:[],up:[],west:[],south:[],down:[]},jt=[],qt=[],$t=[];const Jt=[0,0,0];const Qt=(ne={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}}[te="east"][ee="north"],zt[ie=te+ee]?re=zt[ie]:(re=function(t,r,n){if(function(t,r){var n=t[0],i=t[1],s=t[2],o=r[0],a=r[1],c=r[2];return Math.abs(n-o)<=e*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=e*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=e*Math.max(1,Math.abs(s),Math.abs(c))}(t,Jt))c(jt,Kt[te]),c(qt,Kt[ee]),c($t,Kt[ne]);else if(Bt(t[0],0,1e-14)&&Bt(t[1],0,1e-14)){var i=Rt(t[2]);c(jt,Kt[te]),"east"!==te&&"west"!==te&&_(jt,jt,i),c(qt,Kt[ee]),"east"!==ee&&"west"!==ee&&_(qt,qt,i),c($t,Kt[ne]),"east"!==ne&&"west"!==ne&&_($t,$t,i)}else{!function(t,e){E(e,t,mt),h(e,e)}(t,Wt.up);var s=Wt.up,o=Wt.east;o[0]=-t[1],o[1]=t[0],o[2]=0,h(Wt.east,o),R(Wt.north,s,o),_(Wt.down,Wt.up,-1),_(Wt.west,Wt.east,-1),_(Wt.south,Wt.north,-1),jt=Wt[te],qt=Wt[ee],$t=Wt[ne]}return n[0]=jt[0],n[1]=jt[1],n[2]=jt[2],n[3]=0,n[4]=qt[0],n[5]=qt[1],n[6]=qt[2],n[7]=0,n[8]=$t[0],n[9]=$t[1],n[10]=$t[2],n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n},zt[ie]=re),re);var te,ee,re,ne,ie;const se={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function oe(t){for(let e in se)if(t===se[e])return+e;throw new Error("unrecognized ctor:"+t)}function ae(t){return 1===t?"FLOAT":"VEC"+t}\n/*!\n * @maptalks/gl v0.68.1\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.com\n */const ce=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")},fe=ce(),ue=fe.gl_trans__coders=fe.gl_trans__coders||{};ue.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=fe.gl_trans__coders=fe.gl_trans__coders||{};let s=`${n}\\n const _____getGlobal = ${ce.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals[\'gl_trans__coders\'] = g___lobals[\'gl_trans__coders\'] || {};`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+=\'tran_____scoders["\'+t+\'"] =\'+i[t].toString()+"\\n;");return s+="\\n"+e.substring(n.length),s},ue.registerTranscoder=function(t,e){ue[t]=e},ue.getTranscoder=function(t){return ue[t]};class le{constructor(t,e,r){this.i=t,this.et=e||at,this.o=r,this.rt={"image/crn":ue.crn&&ue.crn(),"image/ktx2":ue.ktx2&&ue.ktx2(),"image/cttf":ue.ktx2&&ue.ktx2(),"draco":ue.draco&&ue.draco()}}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.nt(t,e,r,n,i)):k.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.nt(t,i,r,n)}))}nt(t,e,r,n,i){const s=i&&i.maxTextureSize,o=this.it(e,r,n,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.et(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.rt,supportedFormats:this.o,maxTextureSize:s});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${r}-${n}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}it(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in b3dm header is inconsistent with b3dm\'s byte length, url: "+n;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),f=i.getUint32(20,!0),u=i.getUint32(24,!0),l=28+e;f>=570425344?(l-=8,o=a,f=c,u=0,a=0,c=0):u>=570425344&&(l-=4,o=f,f=a,u=c,a=0,c=0);const E=[t];let _,A,h;if(a>0?(_=gt(t,l,a),l+=a,o=_.BATCH_LENGTH):_={"BATCH_LENGTH":o},c>0&&(l+=c),f>0&&(A=Gt(t,l,f),l+=f,u>0)){const e=vt(0,l,u);h=t.slice(e.offset,e.offset+e.byteLength),l+=u,E.push(h)}const T=_.BATCH_LENGTH,R={};if(_&&_.BATCH_ID){R.BATCH_ID=Ht(_.BATCH_ID,t,undefined.offset,T);const e=R.BATCH_ID.array&&R.BATCH_ID.array.buffer;e&&E.indexOf(e)<0&&E.push(e)}return{count:o,transferables:E,featureTable:_,batchTable:A,batchTableBin:h,b3dm:R,glb:{buffer:t,byteOffset:l,byteLength:i.byteLength+i.byteOffset-l}}}st(){return null}}class Ee{constructor(t,e,r,n){this.i=t,this.et=e||at,this.o=r,this.rt={"image/crn":ue.crn&&ue.crn(),"image/ktx2":ue.ktx2&&ue.ktx2(),"image/cttf":ue.ktx2&&ue.ktx2(),"draco":ue.draco&&ue.draco()},this.ot=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.nt(t,e,r,n,i)):k.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.nt(t,i,r,n)}))}nt(t,e,r,n,i){return this.ct(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const o=this.ft(e,r,n,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}ct(t,e,r,n,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.rt,supportedFormats:this.o,maxTextureSize:s},a=new DataView(e,r,n),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let n=It(new Uint8Array(e,c+r,a.byteLength-c));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?k.getArrayBuffer(n,{}).then((t=>this.ut(n,{buffer:t.data,byteOffset:0},o))):k.getJSON(n,{}).then((t=>this.ut(n,t,o)))}{const n={buffer:e,byteOffset:c+r,byteLength:a.byteLength-c};return this.ut(t,n,o)}}ut(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.et(n,e,r);return i.load({skipAttributeTransform:!0}).then((r=>{let n=0,s=0;return e.buffer&&(n=e.byteOffset||0,s=e.byteLength||0),r.url=`${t}-${n}-${s}`,{transferables:i.transferables,gltf:r}}))}ft(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:f,batchTableBin:u}=Yt(i,32+e,o),l={},E=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,r=a.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=a.POSITION_QUANTIZED;l.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:E,componentType:5126,array:this.lt(new Uint16Array(t,n+c.offset,3*E),e,r)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Ht(a.BATCH_ID,t,c.offset,E);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:this.Et(new Uint16Array(t,e+c.offset,2*E))},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:this.Et(new Uint16Array(t,e+c.offset,2*E))},o.push(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,E).slice()},o.push(l.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;l.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:E,batchTable:f,batchTableBin:u,featureTable:a,i3dm:l,transferables:o}}Et(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)_e(n,t[2*i],t[2*i+1],65535),r[3*i]=n[0],r[3*i+1]=n[1],r[3*i+2]=n[2];return r}lt(t,e,r){return Zt(new Float32Array(t.length),t,e,r)}st(){return null}}function _e(t,e,r,n){if(t[0]=Ae(e,n),t[1]=Ae(r,n),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*he(e),t[1]=(1-Math.abs(e))*he(t[1])}return h(t,t)}function Ae(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,r){return t<e?e:t>r?r:t}(t,0,e)/e*2-1}function he(t){return t<0?-1:1}class Te{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.nt(t,e,r,n)):k.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.nt(t,i,r,n)}))}nt(t,e,r,n){return this._t(e,r,n,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}_t(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:f,batchTableBin:u}=Yt(i,e+28,o),l=a.QUANTIZED_VOLUME_OFFSET,E=a.QUANTIZED_VOLUME_SCALE,_=a.POINTS_LENGTH;let A,h={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){h=a.extensions["3DTILES_draco_point_compression"],A=new DataView(t,h.byteOffset+c.offset,h.byteLength);const e={attributes:h.properties,useUniqueIDs:!1};return this.At||(this.At=ue.draco()),this.At(A,e).then((e=>{const r=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=a.POSITION,r.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=a.RGB,r.RGBA=a.RGBA,r.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=a.NORMAL,r.NORMAL_OCT16P=a.NORMAL_OCT16P);const n=this.ht(t,e.attributes,c.offset,_,o,l,E);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:kt(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(f).length){a.BATCH_ID?n.BATCH_ID=Ht(a.BATCH_ID,t,c.offset,_):n.BATCH_ID=Re(_);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:_,batchTable:f,batchTableBin:u,featureTable:a,pnts:n,transferables:o}}))}const T=this.ht(t,a,c.offset,_,o,l,E);if(a.BATCH_ID||Object.keys(f).length){a.BATCH_ID?T.BATCH_ID=Ht(a.BATCH_ID,t,c.offset,_):T.BATCH_ID=Re(_);const e=T.BATCH_ID.array&&T.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:_,batchTable:f,batchTableBin:u,featureTable:a,pnts:T,transferables:o})}ht(t,e,r,n,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c,array:f}=e.POSITION_QUANTIZED;c=c||0;const u=f?0:r;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.lt(f||new Uint16Array(t,c+u,3*n),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+4*n);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+2*n);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+2*n);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:o},i.push(o.buffer)}return a}lt(t,e,r){return Zt(new Float32Array(t.length),t,e,r)}st(){return null}}function Re(t){const e=(r=t)<256?Uint8Array:r<65536?Uint16Array:Uint32Array;var r;const n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:kt(e),array:n}}class ye{constructor(t,e){this.i=t,this.et=e||at}load(t,e,r=0,n=0,i){return e?this.nt(t,e,r,n,i):k.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.nt(t,i,r,n)}))}nt(t,e,r,n,i){n||(n=e.byteLength);const s=this.Tt(e,t,r,n),o=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new le(this.i,this.et);else if("i3dm"===s[r].magic)n=new Ee(this.i,this.et);else if("pnts"===s[r].magic)n=new Te;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new ye(this.i,this.et)}o.push(n.load(t,e,s[r].offset,s[r].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Tt(t,e,r,n){const i=new DataView(t,r,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Lt(i,c),n=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+r,byteLength:n}),c+=n}return o}}function Ie(t,e){if(t.scenes&&t.scenes.length)for(let r=0,n=t.scenes.length;r<n;r++){const n=t.scenes[r].nodes;for(let r=0,i=n.length;r<i;r++){const i=[];Ne(n[r],i,t,e)}}}function Ne(t,e,r,n){if(t.matrix&&e.push(t.matrix),t.children&&t.children.length)for(let i=0,s=t.children.length;i<s;i++)Ne(t.children[i],e,r,n);if(void 0!==t.mesh){const i=t.mesh,s=r.meshes[i];if(s){const t=e.slice(0),o=s.primitives;for(let e=0,s=o.length;e<s;e++){const s=o[e];s&&(s.matrices=t,n(s,i,e,r))}}}}function Ue(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:o}=t;const a=t.array.buffer,c=r?at.getTypedArrayCtor(r):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,i=i||0,s=s||t.array.length/o,(!i||i===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o)}return}const f=new Uint8Array(o*c.BYTES_PER_ELEMENT);i||(i=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(a,i*t+n,o*c.BYTES_PER_ELEMENT);f.set(r);e(new c(f.buffer),t),r.set(f)}}const Se=[],de=[];function me(t){const e={asset:{version:"1.0",gltfUpAxis:"Z",s3mType:t.dataType},geometricError:0,root:{boundingVolume:{},content:{uri:""},transform:[],geometricError:0,refine:"REPLACE",children:[]}},r=t.position.x,n=t.position.y,i=t.position.z,s=function(t,e,r,n){const i=St,s=Math.cos(r);Nt[0]=s*Math.cos(e),Nt[1]=s*Math.sin(e),Nt[2]=Math.sin(r),Dt(Nt,Nt),E(Ut,i,Nt);const o=Math.sqrt(T(Nt,Ut));var a,c,f;return c=Ut,f=o,(a=Ut)[0]=c[0]/f,a[1]=c[1]/f,a[2]=c[2]/f,_(Nt,Nt,n),u(t,Ut,Nt)}([],ht(r),ht(n),i),o=Qt(s,null,[]);e.root.transform=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],o);const a=[];for(let r=0,n=t.tiles.length;r<n;r++)if(t.tiles[r].boundingbox){const n=t.tiles[r].boundingbox;f(Se,n.min.x,n.min.y,n.min.z),f(de,n.max.x,n.max.y,n.max.z);const i={center:[0,0,0],radius:0};Me(Se,de,i),e.root.children.push({boundingVolume:{sphere:[...i.center,i.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(i)}else if(t.tiles[r].boundingsphere){const{boundingsphere:n}=t.tiles[r],i={center:[n.center.x,n.center.y,n.center.z],radius:n.radius};e.root.children.push({boundingVolume:{sphere:[...i.center,i.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(i)}const h=function(t,e){if(0===t.length)return e;const r=t.length;if(1===r)return function(t,e){return c(e.center,t.center),e.radius=t.radius,e}(t[0],e);if(2===r)return function(t,e,r){const n=t.center,i=t.radius,s=e.center,o=e.radius,a=l(Fe,s,n),f=Ve(a);if(i>=f+o)return t.clone(r),r;if(o>=f+i)return e.clone(r),r;const E=.5*(i+f+o),A=_(be,a,(-i+E)/f);return u(A,A,n),c(r.center,A),r.radius=E,r}(t[0],t[1],e);const n=[];for(let e=0;e<r;e++)n.push(t[e].center);const i=(e=function(t,e){if(0===t.length)return e.center=f(e.center,0,0,0),e.radius=0,e;const r=c(Pe,t[0]),n=c(Ce,r),i=c(pe,r),s=c(we,r),o=c(De,r),a=c(Be,r),u=c(Le,r),E=t.length;for(let e=1;e<E;e++){c(r,t[e]);const f=r[0],l=r[1],E=r[2];f<n[0]&&c(n,r),f>o[0]&&c(o,r),l<i[1]&&c(i,r),l>a[1]&&c(a,r),E<s[2]&&c(s,r),E>u[2]&&c(u,r)}const _=xe(l(ge,o,n)),A=xe(l(ge,a,i)),h=xe(l(ge,u,s));let T=n,R=o,y=_;A>y&&(y=A,T=i,R=a);h>y&&(y=h,T=s,R=u);const I=Ge;I[0]=.5*(T[0]+R[0]),I[1]=.5*(T[1]+R[1]),I[2]=.5*(T[2]+R[2]);let N=xe(l(ge,R,I)),U=Math.sqrt(N);const S=ve;S[0]=n[0],S[1]=i[1],S[2]=s[2];const d=Xe;d[0]=o[0],d[1]=a[1],d[2]=u[2];const m=Oe(S,d,He);let M=0;for(let e=0;e<E;e++){c(r,t[e]);const n=Ve(l(ge,r,m));n>M&&(M=n);const i=xe(l(ge,r,I));if(i>N){const t=Math.sqrt(i);U=.5*(U+t),N=U*U;const e=t-U;I[0]=(U*I[0]+e*r[0])/t,I[1]=(U*I[1]+e*r[1])/t,I[2]=(U*I[2]+e*r[2])/t}}U<M?(c(e.center,I),e.radius=U):(c(e.center,m),e.radius=M);return e}(n,e)).center;let s=e.radius;for(let e=0;e<r;e++){const r=t[e];s=Math.max(s,A(i,r.center)+r.radius)}return e.radius=s,e}(a,{center:[0,0,0],radius:0});return e.root.boundingVolume.sphere=[...h.center,h.radius],e}function Me(t,e,r){var n=Oe(t,e,r.center);return r.radius=A(n,e),r}function Oe(t,e,r){return r[0]=.5*(t[0]+e[0]),r[1]=.5*(t[1]+e[1]),r[2]=.5*(t[2]+e[2]),r}const Fe=[],be=[];const Ce=[],pe=[],we=[],De=[],Be=[],Le=[],Pe=[],ge=[],Ge=[],ve=[],Xe=[],He=[];function xe(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function Ve(t){return Math.hypot(t[0],t[1],t[2])}\n/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ke(t){let e=t.length;for(;--e>=0;)t[e]=0}const Ze=256,Ye=286,Ke=30,ze=15,We=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),je=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),qe=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),$e=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Je=new Array(576);ke(Je);const Qe=new Array(60);ke(Qe);const tr=new Array(512);ke(tr);const er=new Array(256);ke(er);const rr=new Array(29);ke(rr);const nr=new Array(Ke);function ir(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let sr,or,ar;function cr(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}ke(nr);const fr=t=>t<256?tr[t]:tr[256+(t>>>7)],ur=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},lr=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,ur(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},Er=(t,e,r)=>{lr(t,r[2*e],r[2*e+1])},_r=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},Ar=(t,e,r)=>{const n=new Array(16);let i,s,o=0;for(i=1;i<=ze;i++)n[i]=o=o+r[i-1]<<1;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=_r(n[e]++,e))}},hr=t=>{let e;for(e=0;e<Ye;e++)t.dyn_ltree[2*e]=0;for(e=0;e<Ke;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},Tr=t=>{t.bi_valid>8?ur(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},Rr=(t,e,r,n)=>{const i=2*e,s=2*r;return t[i]<t[s]||t[i]===t[s]&&n[e]<=n[r]},yr=(t,e,r)=>{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i<t.heap_len&&Rr(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!Rr(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n},Ir=(t,e,r)=>{let n,i,s,o,a=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*a]<<8|t.pending_buf[t.d_buf+2*a+1],i=t.pending_buf[t.l_buf+a],a++,0===n?Er(t,i,e):(s=er[i],Er(t,s+Ze+1,e),o=We[s],0!==o&&(i-=rr[s],lr(t,i,o)),n--,s=fr(n),Er(t,s,r),o=je[s],0!==o&&(n-=nr[s],lr(t,n,o)))}while(a<t.last_lit);Er(t,256,e)},Nr=(t,e)=>{const r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,c,f=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==r[2*o]?(t.heap[++t.heap_len]=f=o,t.depth[o]=0):r[2*o+1]=0;for(;t.heap_len<2;)c=t.heap[++t.heap_len]=f<2?++f:0,r[2*c]=1,t.depth[c]=0,t.opt_len--,i&&(t.static_len-=n[2*c+1]);for(e.max_code=f,o=t.heap_len>>1;o>=1;o--)yr(t,r,o);c=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],yr(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,r[2*c]=r[2*o]+r[2*a],t.depth[c]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,r[2*o+1]=r[2*a+1]=c,t.heap[1]=c++,yr(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,c=e.stat_desc.max_length;let f,u,l,E,_,A,h=0;for(E=0;E<=ze;E++)t.bl_count[E]=0;for(r[2*t.heap[t.heap_max]+1]=0,f=t.heap_max+1;f<573;f++)u=t.heap[f],E=r[2*r[2*u+1]+1]+1,E>c&&(E=c,h++),r[2*u+1]=E,u>n||(t.bl_count[E]++,_=0,u>=a&&(_=o[u-a]),A=r[2*u],t.opt_len+=A*(E+_),s&&(t.static_len+=A*(i[2*u+1]+_)));if(0!==h){do{for(E=c-1;0===t.bl_count[E];)E--;t.bl_count[E]--,t.bl_count[E+1]+=2,t.bl_count[c]--,h-=2}while(h>0);for(E=c;0!==E;E--)for(u=t.bl_count[E];0!==u;)l=t.heap[--f],l>n||(r[2*l+1]!==E&&(t.opt_len+=(E-r[2*l+1])*r[2*l],r[2*l+1]=E),u--)}})(t,e),Ar(r,f,t.bl_count)},Ur=(t,e,r)=>{let n,i,s=-1,o=e[1],a=0,c=7,f=4;for(0===o&&(c=138,f=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++a<c&&i===o||(a<f?t.bl_tree[2*i]+=a:0!==i?(i!==s&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,s=i,0===o?(c=138,f=3):i===o?(c=6,f=3):(c=7,f=4))},Sr=(t,e,r)=>{let n,i,s=-1,o=e[1],a=0,c=7,f=4;for(0===o&&(c=138,f=3),n=0;n<=r;n++)if(i=o,o=e[2*(n+1)+1],!(++a<c&&i===o)){if(a<f)do{Er(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==s&&(Er(t,i,t.bl_tree),a--),Er(t,16,t.bl_tree),lr(t,a-3,2)):a<=10?(Er(t,17,t.bl_tree),lr(t,a-3,3)):(Er(t,18,t.bl_tree),lr(t,a-11,7));a=0,s=i,0===o?(c=138,f=3):i===o?(c=6,f=3):(c=7,f=4)}};let dr=!1;const mr=(t,e,r,n)=>{lr(t,0+(n?1:0),3),((t,e,r,n)=>{Tr(t),n&&(ur(t,r),ur(t,~r)),t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r})(t,e,r,!0)};var Mr=t=>{dr||((()=>{let t,e,r,n,i;const s=new Array(16);for(r=0,n=0;n<28;n++)for(rr[n]=r,t=0;t<1<<We[n];t++)er[r++]=n;for(er[r-1]=n,i=0,n=0;n<16;n++)for(nr[n]=i,t=0;t<1<<je[n];t++)tr[i++]=n;for(i>>=7;n<Ke;n++)for(nr[n]=i<<7,t=0;t<1<<je[n]-7;t++)tr[256+i++]=n;for(e=0;e<=ze;e++)s[e]=0;for(t=0;t<=143;)Je[2*t+1]=8,t++,s[8]++;for(;t<=255;)Je[2*t+1]=9,t++,s[9]++;for(;t<=279;)Je[2*t+1]=7,t++,s[7]++;for(;t<=287;)Je[2*t+1]=8,t++,s[8]++;for(Ar(Je,287,s),t=0;t<Ke;t++)Qe[2*t+1]=5,Qe[2*t]=_r(t,5);sr=new ir(Je,We,257,Ye,ze),or=new ir(Qe,je,0,Ke,ze),ar=new ir(new Array(0),qe,0,19,7)})(),dr=!0),t.l_desc=new cr(t.dyn_ltree,sr),t.d_desc=new cr(t.dyn_dtree,or),t.bl_desc=new cr(t.bl_tree,ar),t.bi_buf=0,t.bi_valid=0,hr(t)},Or=(t,e,r,n)=>{let i,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<Ze;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Nr(t,t.l_desc),Nr(t,t.d_desc),o=(t=>{let e;for(Ur(t,t.dyn_ltree,t.l_desc.max_code),Ur(t,t.dyn_dtree,t.d_desc.max_code),Nr(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*$e[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==e?mr(t,e,r,n):4===t.strategy||s===i?(lr(t,2+(n?1:0),3),Ir(t,Je,Qe)):(lr(t,4+(n?1:0),3),((t,e,r,n)=>{let i;for(lr(t,e-257,5),lr(t,r-1,5),lr(t,n-4,4),i=0;i<n;i++)lr(t,t.bl_tree[2*$e[i]+1],3);Sr(t,t.dyn_ltree,e-1),Sr(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Ir(t,t.dyn_ltree,t.dyn_dtree)),hr(t),n&&Tr(t)},Fr={Rt:Mr,yt:mr,It:Or,Nt:(t,e,r)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(er[r]+Ze+1)]++,t.dyn_dtree[2*fr(e)]++),t.last_lit===t.lit_bufsize-1),Ut:t=>{lr(t,2,3),Er(t,256,Je),(t=>{16===t.bi_valid?(ur(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var br=(t,e,r,n)=>{let i=65535&t|0,s=t>>>16&65535|0,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{i=i+e[n++]|0,s=s+i|0}while(--o);i%=65521,s%=65521}return i|s<<16|0};const Cr=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var pr=(t,e,r,n)=>{const i=Cr,s=n+r;t^=-1;for(let r=n;r<s;r++)t=t>>>8^i[255&(t^e[r])];return-1^t},wr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Dr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{Rt:Br,yt:Lr,It:Pr,Nt:gr,Ut:Gr}=Fr,{Z_NO_FLUSH:vr,Z_PARTIAL_FLUSH:Xr,Z_FULL_FLUSH:Hr,Z_FINISH:xr,Z_BLOCK:Vr,Z_OK:kr,Z_STREAM_END:Zr,Z_STREAM_ERROR:Yr,Z_DATA_ERROR:Kr,Z_BUF_ERROR:zr,Z_DEFAULT_COMPRESSION:Wr,Z_FILTERED:jr,Z_HUFFMAN_ONLY:qr,Z_RLE:$r,Z_FIXED:Jr,Z_DEFAULT_STRATEGY:Qr,Z_UNKNOWN:tn,Z_DEFLATED:en}=Dr,rn=258,nn=262,sn=103,on=113,an=666,cn=(t,e)=>(t.msg=wr[e],e),fn=t=>(t<<1)-(t>4?9:0),un=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let ln=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const En=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},_n=(t,e)=>{Pr(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,En(t.strm)},An=(t,e)=>{t.pending_buf[t.pending++]=e},hn=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Tn=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=br(t.adler,e,i,r):2===t.state.wrap&&(t.adler=pr(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},Rn=(t,e)=>{let r,n,i=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const c=t.strstart>t.w_size-nn?t.strstart-(t.w_size-nn):0,f=t.window,u=t.w_mask,l=t.prev,E=t.strstart+rn;let _=f[s+o-1],A=f[s+o];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(r=e,f[r+o]===A&&f[r+o-1]===_&&f[r]===f[s]&&f[++r]===f[s+1]){s+=2,r++;do{}while(f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&s<E);if(n=rn-(E-s),s=E-rn,n>o){if(t.match_start=e,o=n,n>=a)break;_=f[s+o-1],A=f[s+o]}}}while((e=l[e&u])>c&&0!=--i);return o<=t.lookahead?o:t.lookahead},yn=t=>{const e=t.w_size;let r,n,i,s,o;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-nn)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do{i=t.head[--r],t.head[r]=i>=e?i-e:0}while(--n);n=e,r=n;do{i=t.prev[--r],t.prev[r]=i>=e?i-e:0}while(--n);s+=e}if(0===t.strm.avail_in)break;if(n=Tn(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=n,t.lookahead+t.insert>=3)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=ln(t,t.ins_h,t.window[o+1]);t.insert&&(t.ins_h=ln(t,t.ins_h,t.window[o+3-1]),t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<nn&&0!==t.strm.avail_in)},In=(t,e)=>{let r,n;for(;;){if(t.lookahead<nn){if(yn(t),t.lookahead<nn&&e===vr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-nn&&(t.match_length=Rn(t,r)),t.match_length>=3)if(n=gr(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=ln(t,t.ins_h,t.window[t.strstart+1]);else n=gr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===xr?(_n(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(_n(t,!1),0===t.strm.avail_out)?1:2},Nn=(t,e)=>{let r,n,i;for(;;){if(t.lookahead<nn){if(yn(t),t.lookahead<nn&&e===vr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-nn&&(t.match_length=Rn(t,r),t.match_length<=5&&(t.strategy===jr||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=gr(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(_n(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=gr(t,0,t.window[t.strstart-1]),n&&_n(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=gr(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===xr?(_n(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(_n(t,!1),0===t.strm.avail_out)?1:2};function Un(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}const Sn=[new Un(0,0,0,0,((t,e)=>{let r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(yn(t),0===t.lookahead&&e===vr)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,_n(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-nn&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===xr?(_n(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(_n(t,!1),t.strm.avail_out),1)})),new Un(4,4,8,4,In),new Un(4,5,16,8,In),new Un(4,6,32,32,In),new Un(4,4,16,16,Nn),new Un(8,16,32,32,Nn),new Un(8,16,128,128,Nn),new Un(8,32,128,256,Nn),new Un(32,128,258,1024,Nn),new Un(32,258,258,4096,Nn)];function dn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=en,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),un(this.dyn_ltree),un(this.dyn_dtree),un(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),un(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),un(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const mn=t=>{if(!t||!t.state)return cn(t,Yr);t.total_in=t.total_out=0,t.data_type=tn;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:on,t.adler=2===e.wrap?0:1,e.last_flush=vr,Br(e),kr},Mn=t=>{const e=mn(t);var r;return e===kr&&((r=t.state).window_size=2*r.w_size,un(r.head),r.max_lazy_match=Sn[r.level].max_lazy,r.good_match=Sn[r.level].good_length,r.nice_match=Sn[r.level].nice_length,r.max_chain_length=Sn[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),e},On=(t,e,r,n,i,s)=>{if(!t)return Yr;let o=1;if(e===Wr&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==en||n<8||n>15||e<0||e>9||s<0||s>Jr)return cn(t,Yr);8===n&&(n=9);const a=new dn;return t.state=a,a.strm=t,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=e,a.strategy=s,a.method=r,Mn(t)};var Fn=(t,e)=>{let r=e.length;if(!t||!t.state)return Yr;const n=t.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return Yr;if(1===i&&(t.adler=br(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(un(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,yn(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=ln(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,yn(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,n.wrap=i,kr},bn={deflateInit:(t,e)=>On(t,e,en,15,8,Qr),deflateInit2:On,deflateReset:Mn,deflateResetKeep:mn,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?Yr:(t.state.gzhead=e,kr):Yr,deflate:(t,e)=>{let r,n;if(!t||!t.state||e>Vr||e<0)return t?cn(t,Yr):Yr;const i=t.state;if(!t.output||!t.input&&0!==t.avail_in||i.status===an&&e!==xr)return cn(t,0===t.avail_out?zr:Yr);i.strm=t;const s=i.last_flush;if(i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,An(i,31),An(i,139),An(i,8),i.gzhead?(An(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),An(i,255&i.gzhead.time),An(i,i.gzhead.time>>8&255),An(i,i.gzhead.time>>16&255),An(i,i.gzhead.time>>24&255),An(i,9===i.level?2:i.strategy>=qr||i.level<2?4:0),An(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(An(i,255&i.gzhead.extra.length),An(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=pr(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(An(i,0),An(i,0),An(i,0),An(i,0),An(i,0),An(i,9===i.level?2:i.strategy>=qr||i.level<2?4:0),An(i,3),i.status=on);else{let e=en+(i.w_bits-8<<4)<<8,r=-1;r=i.strategy>=qr||i.level<2?0:i.level<6?1:6===i.level?2:3,e|=r<<6,0!==i.strstart&&(e|=32),e+=31-e%31,i.status=on,hn(i,e),0!==i.strstart&&(hn(i,t.adler>>>16),hn(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),En(t),r=i.pending,i.pending!==i.pending_buf_size));)An(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),En(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,An(i,n)}while(0!==n);i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),En(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,An(i,n)}while(0!==n);i.gzhead.hcrc&&i.pending>r&&(t.adler=pr(t.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=sn)}else i.status=sn;if(i.status===sn&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&En(t),i.pending+2<=i.pending_buf_size&&(An(i,255&t.adler),An(i,t.adler>>8&255),t.adler=0,i.status=on)):i.status=on),0!==i.pending){if(En(t),0===t.avail_out)return i.last_flush=-1,kr}else if(0===t.avail_in&&fn(e)<=fn(s)&&e!==xr)return cn(t,zr);if(i.status===an&&0!==t.avail_in)return cn(t,zr);if(0!==t.avail_in||0!==i.lookahead||e!==vr&&i.status!==an){let r=i.strategy===qr?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(yn(t),0===t.lookahead)){if(e===vr)return 1;break}if(t.match_length=0,r=gr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===xr?(_n(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(_n(t,!1),0===t.strm.avail_out)?1:2})(i,e):i.strategy===$r?((t,e)=>{let r,n,i,s;const o=t.window;for(;;){if(t.lookahead<=rn){if(yn(t),t.lookahead<=rn&&e===vr)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){s=t.strstart+rn;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<s);t.match_length=rn-(s-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=gr(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=gr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===xr?(_n(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(_n(t,!1),0===t.strm.avail_out)?1:2})(i,e):Sn[i.level].func(i,e);if(3!==r&&4!==r||(i.status=an),1===r||3===r)return 0===t.avail_out&&(i.last_flush=-1),kr;if(2===r&&(e===Xr?Gr(i):e!==Vr&&(Lr(i,0,0,!1),e===Hr&&(un(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),En(t),0===t.avail_out))return i.last_flush=-1,kr}return e!==xr?kr:i.wrap<=0?Zr:(2===i.wrap?(An(i,255&t.adler),An(i,t.adler>>8&255),An(i,t.adler>>16&255),An(i,t.adler>>24&255),An(i,255&t.total_in),An(i,t.total_in>>8&255),An(i,t.total_in>>16&255),An(i,t.total_in>>24&255)):(hn(i,t.adler>>>16),hn(i,65535&t.adler)),En(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?kr:Zr)},deflateEnd:t=>{if(!t||!t.state)return Yr;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==sn&&e!==on&&e!==an?cn(t,Yr):(t.state=null,e===on?cn(t,Kr):kr)},deflateSetDictionary:Fn,deflateInfo:"pako deflate (from Nodeca project)"};const Cn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var pn=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)Cn(r,e)&&(t[e]=r[e])}}return t},wn=t=>{let e=0;for(let r=0,n=t.length;r<n;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,n=0,i=t.length;e<i;e++){let i=t[e];r.set(i,n),n+=i.length}return r};let Dn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Dn=!1}const Bn=new Uint8Array(256);for(let t=0;t<256;t++)Bn[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Bn[254]=Bn[254]=1;var Ln=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,i,s,o=t.length,a=0;for(i=0;i<o;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<o&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),s=0,i=0;s<a;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<o&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[s++]=r:r<2048?(e[s++]=192|r>>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},Pn=(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,i;const s=new Array(2*r);for(i=0,n=0;n<r;){let e=t[n++];if(e<128){s[i++]=e;continue}let o=Bn[e];if(o>4)s[i++]=65533,n+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&n<r;)e=e<<6|63&t[n++],o--;o>1?s[i++]=65533:e<65536?s[i++]=e:(e-=65536,s[i++]=55296|e>>10&1023,s[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Dn)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r})(s,i)},gn=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+Bn[t[r]]>e?r:e};var Gn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const vn=Object.prototype.toString,{Z_NO_FLUSH:Xn,Z_SYNC_FLUSH:Hn,Z_FULL_FLUSH:xn,Z_FINISH:Vn,Z_OK:kn,Z_STREAM_END:Zn,Z_DEFAULT_COMPRESSION:Yn,Z_DEFAULT_STRATEGY:Kn,Z_DEFLATED:zn}=Dr;function Wn(t){this.options=pn({level:Yn,method:zn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Kn},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gn,this.strm.avail_out=0;let r=bn.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==kn)throw new Error(wr[r]);if(e.header&&bn.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Ln(e.dictionary):"[object ArrayBuffer]"===vn.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=bn.deflateSetDictionary(this.strm,t),r!==kn)throw new Error(wr[r]);this.St=!0}}function jn(t,e){const r=new Wn(e);if(r.push(t,!0),r.err)throw r.msg||wr[r.err];return r.result}Wn.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize;let i,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Vn:Xn,"string"==typeof t?r.input=Ln(t):"[object ArrayBuffer]"===vn.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(s===Hn||s===xn)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(i=bn.deflate(r,s),i===Zn)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=bn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===kn;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Wn.prototype.onData=function(t){this.chunks.push(t)},Wn.prototype.onEnd=function(t){t===kn&&(this.result=wn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var qn={Deflate:Wn,deflate:jn,deflateRaw:function(t,e){return(e=e||{}).raw=!0,jn(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,jn(t,e)},constants:Dr};var $n=function(t,e){let r,n,i,s,o,a,c,f,u,l,E,_,A,h,T,R,y,I,N,U,S,d,m,M;const O=t.state;r=t.next_in,m=t.input,n=r+(t.avail_in-5),i=t.next_out,M=t.output,s=i-(e-t.avail_out),o=i+(t.avail_out-257),a=O.dmax,c=O.wsize,f=O.whave,u=O.wnext,l=O.window,E=O.hold,_=O.bits,A=O.lencode,h=O.distcode,T=(1<<O.lenbits)-1,R=(1<<O.distbits)-1;t:do{_<15&&(E+=m[r++]<<_,_+=8,E+=m[r++]<<_,_+=8),y=A[E&T];e:for(;;){if(I=y>>>24,E>>>=I,_-=I,I=y>>>16&255,0===I)M[i++]=65535&y;else{if(!(16&I)){if(0==(64&I)){y=A[(65535&y)+(E&(1<<I)-1)];continue e}if(32&I){O.mode=12;break t}t.msg="invalid literal/length code",O.mode=30;break t}N=65535&y,I&=15,I&&(_<I&&(E+=m[r++]<<_,_+=8),N+=E&(1<<I)-1,E>>>=I,_-=I),_<15&&(E+=m[r++]<<_,_+=8,E+=m[r++]<<_,_+=8),y=h[E&R];r:for(;;){if(I=y>>>24,E>>>=I,_-=I,I=y>>>16&255,!(16&I)){if(0==(64&I)){y=h[(65535&y)+(E&(1<<I)-1)];continue r}t.msg="invalid distance code",O.mode=30;break t}if(U=65535&y,I&=15,_<I&&(E+=m[r++]<<_,_+=8,_<I&&(E+=m[r++]<<_,_+=8)),U+=E&(1<<I)-1,U>a){t.msg="invalid distance too far back",O.mode=30;break t}if(E>>>=I,_-=I,I=i-s,U>I){if(I=U-I,I>f&&O.sane){t.msg="invalid distance too far back",O.mode=30;break t}if(S=0,d=l,0===u){if(S+=c-I,I<N){N-=I;do{M[i++]=l[S++]}while(--I);S=i-U,d=M}}else if(u<I){if(S+=c+u-I,I-=u,I<N){N-=I;do{M[i++]=l[S++]}while(--I);if(S=0,u<N){I=u,N-=I;do{M[i++]=l[S++]}while(--I);S=i-U,d=M}}}else if(S+=u-I,I<N){N-=I;do{M[i++]=l[S++]}while(--I);S=i-U,d=M}for(;N>2;)M[i++]=d[S++],M[i++]=d[S++],M[i++]=d[S++],N-=3;N&&(M[i++]=d[S++],N>1&&(M[i++]=d[S++]))}else{S=i-U;do{M[i++]=M[S++],M[i++]=M[S++],M[i++]=M[S++],N-=3}while(N>2);N&&(M[i++]=M[S++],N>1&&(M[i++]=M[S++]))}break}}break}}while(r<n&&i<o);N=_>>3,r-=N,_-=N<<3,E&=(1<<_)-1,t.next_in=r,t.next_out=i,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=i<o?o-i+257:257-(i-o),O.hold=E,O.bits=_};const Jn=15,Qn=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),ti=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),ei=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ri=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ni=(t,e,r,n,i,s,o,a)=>{const c=a.bits;let f,u,l,E,_,A,h=0,T=0,R=0,y=0,I=0,N=0,U=0,S=0,d=0,m=0,M=null,O=0;const F=new Uint16Array(16),b=new Uint16Array(16);let C,p,w,D=null,B=0;for(h=0;h<=Jn;h++)F[h]=0;for(T=0;T<n;T++)F[e[r+T]]++;for(I=c,y=Jn;y>=1&&0===F[y];y--);if(I>y&&(I=y),0===y)return i[s++]=20971520,i[s++]=20971520,a.bits=1,0;for(R=1;R<y&&0===F[R];R++);for(I<R&&(I=R),S=1,h=1;h<=Jn;h++)if(S<<=1,S-=F[h],S<0)return-1;if(S>0&&(0===t||1!==y))return-1;for(b[1]=0,h=1;h<Jn;h++)b[h+1]=b[h]+F[h];for(T=0;T<n;T++)0!==e[r+T]&&(o[b[e[r+T]]++]=T);if(0===t?(M=D=o,A=19):1===t?(M=Qn,O-=257,D=ti,B-=257,A=256):(M=ei,D=ri,A=-1),m=0,T=0,h=R,_=s,N=I,U=0,l=-1,d=1<<I,E=d-1,1===t&&d>852||2===t&&d>592)return 1;for(;;){C=h-U,o[T]<A?(p=0,w=o[T]):o[T]>A?(p=D[B+o[T]],w=M[O+o[T]]):(p=96,w=0),f=1<<h-U,u=1<<N,R=u;do{u-=f,i[_+(m>>U)+u]=C<<24|p<<16|w|0}while(0!==u);for(f=1<<h-1;m&f;)f>>=1;if(0!==f?(m&=f-1,m+=f):m=0,T++,0==--F[h]){if(h===y)break;h=e[r+o[T]]}if(h>I&&(m&E)!==l){for(0===U&&(U=I),_+=R,N=h-U,S=1<<N;N+U<y&&(S-=F[N+U],!(S<=0));)N++,S<<=1;if(d+=1<<N,1===t&&d>852||2===t&&d>592)return 1;l=m&E,i[l]=I<<24|N<<16|_-s|0}}return 0!==m&&(i[_+m]=h-U<<24|64<<16|0),a.bits=I,0};const{Z_FINISH:ii,Z_BLOCK:si,Z_TREES:oi,Z_OK:ai,Z_STREAM_END:ci,Z_NEED_DICT:fi,Z_STREAM_ERROR:ui,Z_DATA_ERROR:li,Z_MEM_ERROR:Ei,Z_BUF_ERROR:_i,Z_DEFLATED:Ai}=Dr,hi=12,Ti=30,Ri=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function yi(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ii=t=>{if(!t||!t.state)return ui;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,ai},Ni=t=>{if(!t||!t.state)return ui;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Ii(t)},Ui=(t,e)=>{let r;if(!t||!t.state)return ui;const n=t.state;return e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?ui:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,Ni(t))},Si=(t,e)=>{if(!t)return ui;const r=new yi;t.state=r,r.window=null;const n=Ui(t,e);return n!==ai&&(t.state=null),n};let di,mi,Mi=!0;const Oi=t=>{if(Mi){di=new Int32Array(512),mi=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ni(1,t.lens,0,288,di,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ni(2,t.lens,0,32,mi,0,t.work,{bits:5}),Mi=!1}t.lencode=di,t.lenbits=9,t.distcode=mi,t.distbits=5},Fi=(t,e,r,n)=>{let i;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>n&&(i=n),s.window.set(e.subarray(r-n,r-n+i),s.wnext),(n-=i)?(s.window.set(e.subarray(r-n,r),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0};var bi=(t,e)=>{let r,n,i,s,o,a,c,f,u,l,E,_,A,h,T,R,y,I,N,U,S,d,m=0;const M=new Uint8Array(4);let O,F;const b=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return ui;r=t.state,r.mode===hi&&(r.mode=13),o=t.next_out,i=t.output,c=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,f=r.hold,u=r.bits,l=a,E=c,d=ai;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(2&r.wrap&&35615===f){r.check=0,M[0]=255&f,M[1]=f>>>8&255,r.check=pr(r.check,M,2,0),f=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&f)<<8)+(f>>8))%31){t.msg="incorrect header check",r.mode=Ti;break}if((15&f)!==Ai){t.msg="unknown compression method",r.mode=Ti;break}if(f>>>=4,u-=4,S=8+(15&f),0===r.wbits)r.wbits=S;else if(S>r.wbits){t.msg="invalid window size",r.mode=Ti;break}r.dmax=1<<r.wbits,t.adler=r.check=1,r.mode=512&f?10:hi,f=0,u=0;break;case 2:for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(r.flags=f,(255&r.flags)!==Ai){t.msg="unknown compression method",r.mode=Ti;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=Ti;break}r.head&&(r.head.text=f>>8&1),512&r.flags&&(M[0]=255&f,M[1]=f>>>8&255,r.check=pr(r.check,M,2,0)),f=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.head&&(r.head.time=f),512&r.flags&&(M[0]=255&f,M[1]=f>>>8&255,M[2]=f>>>16&255,M[3]=f>>>24&255,r.check=pr(r.check,M,4,0)),f=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.head&&(r.head.xflags=255&f,r.head.os=f>>8),512&r.flags&&(M[0]=255&f,M[1]=f>>>8&255,r.check=pr(r.check,M,2,0)),f=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.length=f,r.head&&(r.head.extra_len=f),512&r.flags&&(M[0]=255&f,M[1]=f>>>8&255,r.check=pr(r.check,M,2,0)),f=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(_=r.length,_>a&&(_=a),_&&(r.head&&(S=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(s,s+_),S)),512&r.flags&&(r.check=pr(r.check,n,_,s)),a-=_,s+=_,r.length-=_),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===a)break t;_=0;do{S=n[s+_++],r.head&&S&&r.length<65536&&(r.head.name+=String.fromCharCode(S))}while(S&&_<a);if(512&r.flags&&(r.check=pr(r.check,n,_,s)),a-=_,s+=_,S)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===a)break t;_=0;do{S=n[s+_++],r.head&&S&&r.length<65536&&(r.head.comment+=String.fromCharCode(S))}while(S&&_<a);if(512&r.flags&&(r.check=pr(r.check,n,_,s)),a-=_,s+=_,S)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(f!==(65535&r.check)){t.msg="header crc mismatch",r.mode=Ti;break}f=0,u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=hi;break;case 10:for(;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}t.adler=r.check=Ri(f),f=0,u=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,r.hold=f,r.bits=u,fi;t.adler=r.check=1,r.mode=hi;case hi:if(e===si||e===oi)break t;case 13:if(r.last){f>>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}switch(r.last=1&f,f>>>=1,u-=1,3&f){case 0:r.mode=14;break;case 1:if(Oi(r),r.mode=20,e===oi){f>>>=2,u-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=Ti}f>>>=2,u-=2;break;case 14:for(f>>>=7&u,u-=7&u;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if((65535&f)!=(f>>>16^65535)){t.msg="invalid stored block lengths",r.mode=Ti;break}if(r.length=65535&f,f=0,u=0,r.mode=15,e===oi)break t;case 15:r.mode=16;case 16:if(_=r.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break t;i.set(n.subarray(s,s+_),o),a-=_,s+=_,c-=_,o+=_,r.length-=_;break}r.mode=hi;break;case 17:for(;u<14;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(r.nlen=257+(31&f),f>>>=5,u-=5,r.ndist=1+(31&f),f>>>=5,u-=5,r.ncode=4+(15&f),f>>>=4,u-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=Ti;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;u<3;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.lens[b[r.have++]]=7&f,f>>>=3,u-=3}for(;r.have<19;)r.lens[b[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,O={bits:r.lenbits},d=ni(0,r.lens,0,19,r.lencode,0,r.work,O),r.lenbits=O.bits,d){t.msg="invalid code lengths set",r.mode=Ti;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=r.lencode[f&(1<<r.lenbits)-1],T=m>>>24,R=m>>>16&255,y=65535&m,!(T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(y<16)f>>>=T,u-=T,r.lens[r.have++]=y;else{if(16===y){for(F=T+2;u<F;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(f>>>=T,u-=T,0===r.have){t.msg="invalid bit length repeat",r.mode=Ti;break}S=r.lens[r.have-1],_=3+(3&f),f>>>=2,u-=2}else if(17===y){for(F=T+3;u<F;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=T,u-=T,S=0,_=3+(7&f),f>>>=3,u-=3}else{for(F=T+7;u<F;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=T,u-=T,S=0,_=11+(127&f),f>>>=7,u-=7}if(r.have+_>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=Ti;break}for(;_--;)r.lens[r.have++]=S}}if(r.mode===Ti)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=Ti;break}if(r.lenbits=9,O={bits:r.lenbits},d=ni(1,r.lens,0,r.nlen,r.lencode,0,r.work,O),r.lenbits=O.bits,d){t.msg="invalid literal/lengths set",r.mode=Ti;break}if(r.distbits=6,r.distcode=r.distdyn,O={bits:r.distbits},d=ni(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,O),r.distbits=O.bits,d){t.msg="invalid distances set",r.mode=Ti;break}if(r.mode=20,e===oi)break t;case 20:r.mode=21;case 21:if(a>=6&&c>=258){t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,r.hold=f,r.bits=u,$n(t,E),o=t.next_out,i=t.output,c=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,f=r.hold,u=r.bits,r.mode===hi&&(r.back=-1);break}for(r.back=0;m=r.lencode[f&(1<<r.lenbits)-1],T=m>>>24,R=m>>>16&255,y=65535&m,!(T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(R&&0==(240&R)){for(I=T,N=R,U=y;m=r.lencode[U+((f&(1<<I+N)-1)>>I)],T=m>>>24,R=m>>>16&255,y=65535&m,!(I+T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=I,u-=I,r.back+=I}if(f>>>=T,u-=T,r.back+=T,r.length=y,0===R){r.mode=26;break}if(32&R){r.back=-1,r.mode=hi;break}if(64&R){t.msg="invalid literal/length code",r.mode=Ti;break}r.extra=15&R,r.mode=22;case 22:if(r.extra){for(F=r.extra;u<F;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.length+=f&(1<<r.extra)-1,f>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=r.distcode[f&(1<<r.distbits)-1],T=m>>>24,R=m>>>16&255,y=65535&m,!(T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(0==(240&R)){for(I=T,N=R,U=y;m=r.distcode[U+((f&(1<<I+N)-1)>>I)],T=m>>>24,R=m>>>16&255,y=65535&m,!(I+T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=I,u-=I,r.back+=I}if(f>>>=T,u-=T,r.back+=T,64&R){t.msg="invalid distance code",r.mode=Ti;break}r.offset=y,r.extra=15&R,r.mode=24;case 24:if(r.extra){for(F=r.extra;u<F;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.offset+=f&(1<<r.extra)-1,f>>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=Ti;break}r.mode=25;case 25:if(0===c)break t;if(_=E-c,r.offset>_){if(_=r.offset-_,_>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=Ti;break}_>r.wnext?(_-=r.wnext,A=r.wsize-_):A=r.wnext-_,_>r.length&&(_=r.length),h=r.window}else h=i,A=o-r.offset,_=r.length;_>c&&(_=c),c-=_,r.length-=_;do{i[o++]=h[A++]}while(--_);0===r.length&&(r.mode=21);break;case 26:if(0===c)break t;i[o++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===a)break t;a--,f|=n[s++]<<u,u+=8}if(E-=c,t.total_out+=E,r.total+=E,E&&(t.adler=r.check=r.flags?pr(r.check,i,E,o-E):br(r.check,i,E,o-E)),E=c,(r.flags?f:Ri(f))!==r.check){t.msg="incorrect data check",r.mode=Ti;break}f=0,u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(f!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=Ti;break}f=0,u=0}r.mode=29;case 29:d=ci;break t;case Ti:d=li;break t;case 31:return Ei;default:return ui}return t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,r.hold=f,r.bits=u,(r.wsize||E!==t.avail_out&&r.mode<Ti&&(r.mode<27||e!==ii))&&Fi(t,t.output,t.next_out,E-t.avail_out),l-=t.avail_in,E-=t.avail_out,t.total_in+=l,t.total_out+=E,r.total+=E,r.wrap&&E&&(t.adler=r.check=r.flags?pr(r.check,i,E,t.next_out-E):br(r.check,i,E,t.next_out-E)),t.data_type=r.bits+(r.last?64:0)+(r.mode===hi?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===E||e===ii)&&d===ai&&(d=_i),d},Ci={inflateReset:Ni,inflateReset2:Ui,inflateResetKeep:Ii,inflateInit:t=>Si(t,15),inflateInit2:Si,inflate:bi,inflateEnd:t=>{if(!t||!t.state)return ui;let e=t.state;return e.window&&(e.window=null),t.state=null,ai},inflateGetHeader:(t,e)=>{if(!t||!t.state)return ui;const r=t.state;return 0==(2&r.wrap)?ui:(r.head=e,e.done=!1,ai)},inflateSetDictionary:(t,e)=>{const r=e.length;let n,i,s;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?ui:11===n.mode&&(i=1,i=br(i,e,r,0),i!==n.check)?li:(s=Fi(t,e,r,r),s?(n.mode=31,Ei):(n.havedict=1,ai))):ui},inflateInfo:"pako inflate (from Nodeca project)"};var pi=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const wi=Object.prototype.toString,{Z_NO_FLUSH:Di,Z_FINISH:Bi,Z_OK:Li,Z_STREAM_END:Pi,Z_NEED_DICT:gi,Z_STREAM_ERROR:Gi,Z_DATA_ERROR:vi,Z_MEM_ERROR:Xi}=Dr;function Hi(t){this.options=pn({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gn,this.strm.avail_out=0;let r=Ci.inflateInit2(this.strm,e.windowBits);if(r!==Li)throw new Error(wr[r]);if(this.header=new pi,Ci.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Ln(e.dictionary):"[object ArrayBuffer]"===wi.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Ci.inflateSetDictionary(this.strm,e.dictionary),r!==Li)))throw new Error(wr[r])}function xi(t,e){const r=new Hi(e);if(r.push(t),r.err)throw r.msg||wr[r.err];return r.result}Hi.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Bi:Di,"[object ArrayBuffer]"===wi.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),s=Ci.inflate(r,o),s===gi&&i&&(s=Ci.inflateSetDictionary(r,i),s===Li?s=Ci.inflate(r,o):s===vi&&(s=gi));r.avail_in>0&&s===Pi&&r.state.wrap>0&&0!==t[r.next_in];)Ci.inflateReset(r),s=Ci.inflate(r,o);switch(s){case Gi:case vi:case gi:case Xi:return this.onEnd(s),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||s===Pi))if("string"===this.options.to){let t=gn(r.output,r.next_out),e=r.next_out-t,i=Pn(r.output,t);r.next_out=e,r.avail_out=n-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(s!==Li||0!==a){if(s===Pi)return s=Ci.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},Hi.prototype.onData=function(t){this.chunks.push(t)},Hi.prototype.onEnd=function(t){t===Li&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=wn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Vi={Inflate:Hi,inflate:xi,inflateRaw:function(t,e){return(e=e||{}).raw=!0,xi(t,e)},ungzip:xi,constants:Dr};const{Deflate:ki,deflate:Zi,deflateRaw:Yi,gzip:Ki}=qn,{Inflate:zi,inflate:Wi,inflateRaw:ji,ungzip:qi}=Vi;var $i={Deflate:ki,deflate:Zi,deflateRaw:Yi,gzip:Ki,Inflate:zi,inflate:Wi,inflateRaw:ji,ungzip:qi,constants:Dr},Ji=5,Qi=11,ts=13,es=14;function rs(t,e,r,n){var i=t|e<<8,s=i>>11&31,o=i>>5&63,a=31&i;return r[n+0]=s<<3|s>>2,r[n+1]=o<<2|o>>4,r[n+2]=a<<3|a>>2,r[n+3]=255,i}var ns=new Uint8Array(16),is=new Uint8Array(16);function ss(t,e,r,n){var i=0;0!=(6&n)&&(i=8),function(t,e,r,n){for(var i=rs(e[r+0],e[r+1],ns,0),s=rs(e[r+2],e[r+3],ns,4),o=0;o<3;o++){var a=ns[o],c=ns[4+o];n&&i<=s?(ns[8+o]=(a+c)/2,ns[12+o]=0):(ns[8+o]=(2*a+c)/3,ns[12+o]=(a+2*c)/3)}for(ns[11]=255,ns[15]=n&&i<=s?0:255,o=0;o<4;++o){var f=e[r+4+o];is[4*o+0]=3&f,is[4*o+1]=f>>2&3,is[4*o+2]=f>>4&3,is[4*o+3]=f>>6&3}for(o=0;o<16;++o)for(var u=4*is[o],l=0;l<4;++l)t[4*o+l]=ns[u+l]}(t,e,r+i,0!=(1&n)),0!=(2&n)?function(t,e,r){for(var n=0;n<8;++n){var i=bytes[r+n],s=15&i,o=240&i;t[8*n+3]=s|s<<4,t[8*n+7]=o|o>>4}}(t,0,r):0!=(4&n)&&function(t,e,r){var n=e[r+0],i=e[r+1];if(ns[0]=n,ns[1]=i,n<=i){for(var s=1;s<5;++s)ns[1+s]=((5-s)*n+s*i)/5;ns[6]=0,ns[7]=255}else for(s=1;s<7;++s)ns[1+s]=((7-s)*n+s*i)/7;r+=2;var o=0;for(s=0;s<2;++s){for(var a=0,c=0;c<3;++c)a|=e[r++]<<8*c;for(c=0;c<8;++c){var f=a>>3*c&7;is[o++]=f}}for(s=0;s<16;++s)t[4*s+3]=ns[is[s]]}(t,e,r)}var os=new Uint16Array(4);\n/*! @brief Decompresses an image in memory.\n\n @param rgba\t\tStorage for the decompressed pixels.\n @param width\tThe width of the source image.\n @param height\tThe height of the source image.\n @param blocks\tThe compressed DXT blocks.\n @param flags\tCompression flags.\n\n The decompressed pixels will be written as a contiguous array of width*height\n 16 rgba values, with each component as 1 byte each. In memory this is:\n\n { r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height\n\n The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression,\n however, DXT1 will be used by default if none is specified. All other flags\n are ignored.\n\n Internally this function calls squish::Decompress for each block.\n */\nvar as=new Uint8Array(64);function cs(t){}function fs(){}cs.decode=function(t,e,r,n,i){if(null!=t&&null!=n&&0!=r&&0!=e){var s=0;1&(s=i>11||5===i?4:33)&&32&s?function(t,e,r,n){for(var i=t,s=0,o=0,a=0,c=0,f=0,u=0,l=0,E=0,_=0,A=e/4,h=r/4,T=0;T<h;T++)for(var R=0;R<A;R++)a=4*((h-T)*A+R),os[0]=n[a],os[1]=n[a+1],c=31&os[0],f=2016&os[0],u=63488&os[0],l=31&os[1],E=2016&os[1],_=63488&os[1],os[2]=5*c+3*l>>3|5*f+3*E>>3&2016|5*u+3*_>>3&63488,os[3]=5*l+3*c>>3|5*E+3*f>>3&2016|5*_+3*u>>3&63488,s=n[a+2],i[o=4*T*e+4*R]=os[3&s],i[o+1]=os[s>>2&3],i[o+2]=os[s>>4&3],i[o+3]=os[s>>6&3],i[o+=e]=os[s>>8&3],i[o+1]=os[s>>10&3],i[o+2]=os[s>>12&3],i[o+3]=os[s>>14],s=n[a+3],i[o+=e]=os[3&s],i[o+1]=os[s>>2&3],i[o+2]=os[s>>4&3],i[o+3]=os[s>>6&3],i[o+=e]=os[s>>8&3],i[o+1]=os[s>>10&3],i[o+2]=os[s>>12&3],i[o+3]=os[s>>14]}(t,e,r,n):function(t,e,r,n,i,s){for(var o=0!=(1&i)?8:16,a=0,c=0;c<r;c+=4)for(var f=0;f<e;f+=4){ss(as,n,a,i);for(var u=0,l=0;l<4;++l)for(var E=0;E<4;++E){var _=f+E,A=c+l;if(_<e&&A<r){var h=4*(e*(r-A)+_);if(s===ts||s===es)t[h+2]=as[u++],t[h+1]=as[u++],t[h+0]=as[u++],t[h+3]=as[u++];else for(var T=0;T<4;++T)t[h++]=as[u++]}else u+=4}a+=o}}(t,e,r,n,s,i)}},fs.s3tc=!0,fs.pvrtc=!1,fs.etc1=!1;let us=1,ls=2;const Es=10,_s=11,As=1,hs=2,Ts=16,Rs=32;function ys(t,e,r){r=t.byteLength;return t=t.subarray(0,0+r),new TextDecoder("utf-8").decode(t)}function Is(t,e,r){let n=e.getUint32(r,!0);return r+=Uint32Array.BYTES_PER_ELEMENT,{string:ys(new Uint8Array(t,r,n)),bytesOffset:r+=n}}function Ns(t,e,r,n){let i={},s=[],o=new Array(16);for(let t=0;t<16;t++)o[t]=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;i.matrix=o,i.skeletonNames=s;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<a;n++){let n=Is(t,e,r);s.push(n.string),r=n.bytesOffset}return n.push(i),r}function Us(t,e,r,n){let i={};i.rangeList=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,i.rangeMode=e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let s={};s.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,s.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,s.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;let o=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT,i.boundingSphere={center:s,radius:o};let a=Is(t,e,r),c=a.string;r=a.bytesOffset;let f=c.indexOf("Geometry");if(-1!==f){let t=c.substring(f);c=c.replace(t,"")}i.childTile=c,i.geodes=[];let u=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<u;n++)r=Ns(t,e,r,i.geodes);return n.push(i),r}function Ss(t,e,r,n){let i=e.getUint32(r,!0);if(n.verticesCount=i,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=s*Float32Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*s*Float32Array.BYTES_PER_ELEMENT,c=new Uint8Array(t,r,a);r+=a;let f=n.vertexAttributes,u=n.attrLocation;return u.aPosition=f.length,f.push({index:u.aPosition,typedArray:c,componentsPerAttribute:s,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function ds(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*s*Float32Array.BYTES_PER_ELEMENT,c=new Uint8Array(t,r,a);r+=a;let f=n.vertexAttributes,u=n.attrLocation;return u.aNormal=f.length,f.push({index:u.aNormal,typedArray:c,componentsPerAttribute:s,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function ms(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s,o=n.verticesCount;if(i>0){e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let n=i*Uint8Array.BYTES_PER_ELEMENT*4;s=new Uint8Array(t,r,n).slice(0,n),r+=n}else{s=new Uint8Array(4*o);for(let t=0;t<o;t++)s[4*t]=255,s[4*t+1]=255,s[4*t+2]=255,s[4*t+3]=255}let a=n.vertexAttributes,c=n.attrLocation;return c.aColor=a.length,a.push({index:c.aColor,typedArray:s,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),n.vertexColor=s,r}function Ms(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let s=i*Uint8Array.BYTES_PER_ELEMENT*4,o=new Uint8Array(t,r,s);r+=s;let a=n.vertexAttributes,c=n.attrLocation;return c.aSecondColor=a.length,a.push({index:c.aSecondColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),r}function Os(t,e,r,n){let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*o*Float32Array.BYTES_PER_ELEMENT,c=new Uint8Array(t,r,a);r+=a;let f="aTexCoord"+s,u=n.vertexAttributes,l=n.attrLocation;l[f]=u.length,u.push({index:l[f],typedArray:c,componentsPerAttribute:o,componentDatatype:5126,offsetInBytes:0,strideInBytes:o*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}return r}function Fs(t,e,r,n){let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let s=n.vertexAttributes,o=n.attrLocation;for(let a=0;a<i;a++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let c=i*a*Float32Array.BYTES_PER_ELEMENT;if(17===a){let e=new Uint8Array(t,r,c);n.instanceCount=i,n.instanceMode=a,n.instanceBuffer=e,n.instanceIndex=1;let f,u=a*i*4,l=e.slice(0,u);n.vertexColorInstance=l,17===a?(f=17*Float32Array.BYTES_PER_ELEMENT,o.uv2=s.length,s.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:f,instanceDivisor:1}),o.uv3=s.length,s.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv4=s.length,s.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.secondary_colour=s.length,s.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv6=s.length,s.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1})):29===a&&(f=29*Float32Array.BYTES_PER_ELEMENT,o.uv1=s.length,s.push({index:o.uv1,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:f,instanceDivisor:1,byteLength:c}),o.uv2=s.length,s.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv3=s.length,s.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv4=s.length,s.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv5=s.length,s.push({index:o.uv5,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv6=s.length,s.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:20*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv7=s.length,s.push({index:o.uv7,componentsPerAttribute:3,componentDatatype:5126,normalize:!1,offsetInBytes:24*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.secondary_colour=s.length,s.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:27*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv9=s.length,s.push({index:o.uv9,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:28*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}))}else{let t=i*a;n.instanceBounds=new Float32Array(t);for(let i=0;i<t;i++)n.instanceBounds[i]=e.getFloat32(r+i*Float32Array.BYTES_PER_ELEMENT,!0)}r+=c}return r}function bs(t,e,r,n){return r=Fs(t,e,r=Os(t,e,r=Ms(t,e,r=ms(t,e,r=ds(t,e,r=Ss(t,e,r,n),n),n),n),n),n)}function Cs(t,e,r,n){let i=e.getUint32(r,!0);return n.compressOptions=i,r+=Uint32Array.BYTES_PER_ELEMENT,r=(i&As)===As?function(t,e,r,n){let i=e.getUint32(r,!0);if(n.verticesCount=i,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=s*Int16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let a=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT;let c={};c.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.vertCompressConstant=a,n.minVerticesValue=c;let f=i*s*Int16Array.BYTES_PER_ELEMENT,u=new Uint8Array(t,r,f);r+=f;let l=n.vertexAttributes,E=n.attrLocation;return E.aPosition=l.length,l.push({index:E.aPosition,typedArray:u,componentsPerAttribute:s,componentDatatype:5122,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}(t,e,r,n):Ss(t,e,r,n),r=(i&hs)===hs?function(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=2*i*Int16Array.BYTES_PER_ELEMENT,a=new Uint8Array(t,r,o);r+=o;let c=n.vertexAttributes,f=n.attrLocation;return f.aNormal=c.length,c.push({index:f.aNormal,typedArray:a,componentsPerAttribute:2,componentDatatype:5122,offsetInBytes:0,strideInBytes:s,normalize:!1}),r}(t,e,r,n):ds(t,e,r,n),r=Ms(t,e,r=ms(t,e,r,n),n),r=(i&Ts)===Ts?function(t,e,r,n){n.texCoordCompressConstant=[],n.minTexCoordValue=[];let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT,r+=3*Uint8Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let c=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT,n.texCoordCompressConstant.push(c);let f={};f.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.minTexCoordValue.push(f);let u=o*a*Int16Array.BYTES_PER_ELEMENT,l=new Uint8Array(t,r,u),E=(r+=u)%4;0!==E&&(r+=4-E);let _="aTexCoord"+s,A=n.vertexAttributes,h=n.attrLocation;if(h[_]=A.length,A.push({index:h[_],typedArray:l,componentsPerAttribute:a,componentDatatype:5122,offsetInBytes:0,strideInBytes:a*Int16Array.BYTES_PER_ELEMENT,normalize:!1}),i){u=o*Float32Array.BYTES_PER_ELEMENT;let e=new Uint8Array(t,r,u);r+=u,n.texCoordZMatrix=!0,_="aTexCoordZ"+s,h[_]=A.length,A.push({index:h[_],typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:Float32Array.BYTES_PER_ELEMENT,normalize:!1})}}return r}(t,e,r,n):Os(t,e,r,n),(i&Rs)===Rs&&(n.textureCoordIsW=!0),r=Fs(t,e,r,n)}function ps(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i={},s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT,e.getUint8(r,!0),r+=Uint8Array.BYTES_PER_ELEMENT;let a=e.getUint8(r,!0);if(r+=Uint8Array.BYTES_PER_ELEMENT,r+=Uint8Array.BYTES_PER_ELEMENT,s>0){let e,n=null;1===o||3===o?(e=s*Uint32Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e)):(e=s*Uint16Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e),s%2!=0&&(e+=2)),i.indicesTypedArray=n,r+=e}i.indicesCount=s,i.indexType=o,i.primitiveType=a;let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<c;n++){let n=Is(t,e,r),s=n.string;r=n.bytesOffset,i.materialCode=s}if(0!==r%4){r+=4-r%4}n.push(i)}return r}let ws={red:0,green:0,blue:0,alpha:0};function Ds(t,e,r){let n=t.vertexAttributes,i=t.attrLocation,s=n.length;i[1===r?"instanceId":"batchId"]=s,n.push({index:s,typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,instanceDivisor:r})}fs.parseBuffer=function(t){let e=0,r={version:void 0,groupNode:void 0,geoPackage:{},matrials:void 0,texturePackage:{}},n=new DataView(t);r.version=n.getFloat32(e,!0),e+=Float32Array.BYTES_PER_ELEMENT,r.version>=2&&(n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT),n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT;let i=function(t,e){let r=new Uint8Array(t,e);return $i.inflate(r).buffer}(t,e);n=new DataView(i),e=0;let s=n.getUint32(e,!0);return e+=Uint32Array.BYTES_PER_ELEMENT,e=function(t,e,r,n){let i={},s=[];e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<o;n++)r=Us(t,e,r,s);i.pageLods=s;let a=r%4;return 0!==a&&(r+=4-a),n.groupNode=i,r}(i,n,e,r),e=function(t,e,r,n){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=Is(t,e,r),s=i.string,o=(r=i.bytesOffset)%4;0!==o&&(r+=4-o);let a=e.getUint32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;let c={vertexAttributes:[],attrLocation:{},instanceCount:0,instanceMode:0,instanceIndex:-1};a===us?r=bs(t,e,r,c):a===ls&&(r=Cs(t,e,r,c));let f,u=[];r=ps(t,e,r,u),2===u.length&&13===u[1].primitiveType&&u[1].indicesCount>=3&&(f=S3MEdgeProcessor.createEdgeDataByIndices(c,u[1])),n[s]={vertexPackage:c,arrIndexPackage:u,edgeGeometry:f}}return r+=e.getUint32(r,!0),r+Uint32Array.BYTES_PER_ELEMENT}(i,n,e,r.geoPackage),e=function(t,e,r,n){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=Is(t,e,r),s=i.string,o=(r=i.bytesOffset)%4;0!==o&&(r+=4-o),e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let f=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let u=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let l=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let E=new Uint8Array(t,r,u);r+=u;let _=l===Es||l===_s?33776:33779;if(22===f&&(_=36196),!fs.s3tc&&(33776===_||33779===_)){let t=new Uint8Array(a*c*4);cs.decode(t,a,c,E,l),E=t,f=0,_=l===Es||l===Es?273:4369}n[s]={id:s,width:a,height:c,compressType:f,nFormat:l,internalFormat:_,arrayBufferView:E}}return r}(i,n,e,r.texturePackage),e=function(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=ys(new Uint8Array(t,r,i));return r+=i,n.materials=JSON.parse(s),r}(i,n,e,r),function(t,e,r,n,i,s){if(1==(1&n)){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let n=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let o=0;o<n;o++){let n=Is(t,e,r),o=n.string;r=n.bytesOffset;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let c={};if(i[o].pickInfo=c,-1==i[o].vertexPackage.instanceIndex){let t=new Float32Array(i[o].vertexPackage.verticesCount);for(let n=0;n<a;n++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=[];for(let i=0;i<s;i++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,t.fill(n,i,i+s),o.push({vertexColorOffset:i,vertexColorCount:s,batchId:n})}c[i]=o}Ds(i[o].vertexPackage,t,void 0)}else{let t=i[o].vertexPackage.instanceCount,n=i[o].vertexPackage.instanceBuffer,f=i[o].vertexPackage.instanceMode,u=new Float32Array(t),l=[];for(let t=0;t<a;t++){let t=e.getUint32(r,!0);l.push(t),r+=Uint32Array.BYTES_PER_ELEMENT;let n=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let t=0;t<n;t++)e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT,3===s&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT)}let E=17===f?16:28;E*=Float32Array.BYTES_PER_ELEMENT;for(let e=0;e<t;e++){u[e]=e;let t=e*f*Float32Array.BYTES_PER_ELEMENT+E;Cesium.Color.unpack(n,t,ws);let r=2===s?l[e]:ws.red+256*ws.green+65536*ws.blue;void 0===c[r]&&(c[r]={vertexColorCount:1,instanceIds:[],vertexColorOffset:e}),c[r].instanceIds.push(e)}Ds(i[o].vertexPackage,u,1)}}}}(i,n,e,s,r.geoPackage,r.version),r};class Bs{constructor(t,e,{width:r,height:n,colorDepth:i,format:s}){if(this.format=s,this.offset=e,this.depth=i,this.stride=\n/*!\n * decode-bmp\n * https://github.com/LinusU/decode-bmp\n * MIT License\n */\nfunction(t){const e=t%4;return e?t+4-e:t}(r*this.depth/8),this.size=this.stride*n,this.data=t.subarray(this.offset,this.offset+this.size),this.size!==this.data.byteLength)throw new Error("Truncated bitmap data")}get(t,e,r){const n=this.format.indexOf(r);if(1===this.depth){return(this.data[e*this.stride+(t/8|0)]&1<<7-t%8*1)>>7-t%8*1}if(2===this.depth){return(this.data[e*this.stride+(t/4|0)]&3<<6-t%4*2)>>>6-t%4*2}if(4===this.depth){return(this.data[e*this.stride+(t/2|0)]&15<<4-t%2*4)>>>4-t%2*4}return this.data[e*this.stride+t*(this.depth/8)+n]}}function Ls(t,e,r,n,{width:i=0,height:s=0,icon:o=!1}={}){const a=new DataView(e,r,n);let c,f,u,l,E;o?(c=a.getUint32(0,!0),f=a.getUint32(4,!0)/1|0,u=a.getUint32(8,!0)/2|0,l=a.getUint16(14,!0),E=a.getUint32(32,!0)):(!function(t){if(19778!==t)throw new Error(`Invalid magic byte 0x${t.toString(16)}`)}(a.getUint16(0,!0)),c=14+a.getUint32(14,!0),f=a.getUint32(18,!0),u=a.getUint32(22,!0),l=a.getUint16(28,!0),E=a.getUint32(46,!0)),0===E&&l<=8&&(E=1<<l);const _=0===f?i:f,A=0===u?s:u,h=new Uint8Array(a.buffer,a.byteOffset+c,a.byteLength-c),T=t.byteLength===_*A*4,R=E?function(t,e,r,{width:n,height:i,colorDepth:s,colorCount:o,icon:a}){if(8!==s&&4!==s&&2!==s&&1!==s)throw new Error(`A color depth of ${s} is not supported`);const c=new Bs(r,0,{width:o,height:1,colorDepth:32,format:"BGRA"}),f=new Bs(r,c.offset+c.size,{width:n,height:i,colorDepth:s,format:"C"}),u=a?new Bs(r,f.offset+f.size,{width:n,height:i,colorDepth:1,format:"A"}):null,l=t;let E=0;for(let t=0;t<i;t++)for(let r=0;r<n;r++){const n=f.get(r,i-t-1,"C");l[E++]=c.get(n,0,"R"),l[E++]=c.get(n,0,"G"),l[E++]=c.get(n,0,"B"),e&&(l[E++]=u&&u.get(r,i-t-1,"A")?0:255)}return l}(t,T,h,{width:_,height:A,colorDepth:l,colorCount:E,icon:o}):function(t,e,r,{width:n,height:i,colorDepth:s,icon:o}){if(32!==s&&24!==s)throw new Error(`A color depth of ${s} is not supported`);const a=new Bs(r,0,{width:n,height:i,colorDepth:s,format:"BGRA"}),c=24===s&&o?new Bs(r,a.offset+a.size,{width:n,height:i,colorDepth:1,format:"A"}):null,f=t;let u=0;for(let t=0;t<i;t++)for(let r=0;r<n;r++)f[u++]=a.get(r,i-t-1,"R"),f[u++]=a.get(r,i-t-1,"G"),f[u++]=a.get(r,i-t-1,"B"),e&&(f[u++]=32===s?a.get(r,i-t-1,"A"):c&&c.get(r,i-t-1,"A")?0:255);return f}(t,T,h,{width:_,height:A,colorDepth:l,icon:o});return R}var Ps=Object.freeze({DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,VERTEX_ATTRIB_ARRAY_ENABLED:34338,VERTEX_ATTRIB_ARRAY_SIZE:34339,VERTEX_ATTRIB_ARRAY_STRIDE:34340,VERTEX_ATTRIB_ARRAY_TYPE:34341,VERTEX_ATTRIB_ARRAY_NORMALIZED:34922,VERTEX_ATTRIB_ARRAY_POINTER:34373,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:34975,IMPLEMENTATION_COLOR_READ_TYPE:35738,IMPLEMENTATION_COLOR_READ_FORMAT:35739,COMPILE_STATUS:35713,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX:6401,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444,COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGBA_ASTC_4x4_WEBGL:37808,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGBA_BPTC_UNORM:36492,HALF_FLOAT_OES:36193,DOUBLE:5130,READ_BUFFER:3074,UNPACK_ROW_LENGTH:3314,UNPACK_SKIP_ROWS:3315,UNPACK_SKIP_PIXELS:3316,PACK_ROW_LENGTH:3330,PACK_SKIP_ROWS:3331,PACK_SKIP_PIXELS:3332,COLOR:6144,DEPTH:6145,STENCIL:6146,RED:6403,RGB8:32849,RGBA8:32856,RGB10_A2:32857,TEXTURE_BINDING_3D:32874,UNPACK_SKIP_IMAGES:32877,UNPACK_IMAGE_HEIGHT:32878,TEXTURE_3D:32879,TEXTURE_WRAP_R:32882,MAX_3D_TEXTURE_SIZE:32883,UNSIGNED_INT_2_10_10_10_REV:33640,MAX_ELEMENTS_VERTICES:33e3,MAX_ELEMENTS_INDICES:33001,TEXTURE_MIN_LOD:33082,TEXTURE_MAX_LOD:33083,TEXTURE_BASE_LEVEL:33084,TEXTURE_MAX_LEVEL:33085,MIN:32775,MAX:32776,DEPTH_COMPONENT24:33190,MAX_TEXTURE_LOD_BIAS:34045,TEXTURE_COMPARE_MODE:34892,TEXTURE_COMPARE_FUNC:34893,CURRENT_QUERY:34917,QUERY_RESULT:34918,QUERY_RESULT_AVAILABLE:34919,STREAM_READ:35041,STREAM_COPY:35042,STATIC_READ:35045,STATIC_COPY:35046,DYNAMIC_READ:35049,DYNAMIC_COPY:35050,MAX_DRAW_BUFFERS:34852,DRAW_BUFFER0:34853,DRAW_BUFFER1:34854,DRAW_BUFFER2:34855,DRAW_BUFFER3:34856,DRAW_BUFFER4:34857,DRAW_BUFFER5:34858,DRAW_BUFFER6:34859,DRAW_BUFFER7:34860,DRAW_BUFFER8:34861,DRAW_BUFFER9:34862,DRAW_BUFFER10:34863,DRAW_BUFFER11:34864,DRAW_BUFFER12:34865,DRAW_BUFFER13:34866,DRAW_BUFFER14:34867,DRAW_BUFFER15:34868,MAX_FRAGMENT_UNIFORM_COMPONENTS:35657,MAX_VERTEX_UNIFORM_COMPONENTS:35658,SAMPLER_3D:35679,SAMPLER_2D_SHADOW:35682,FRAGMENT_SHADER_DERIVATIVE_HINT:35723,PIXEL_PACK_BUFFER:35051,PIXEL_UNPACK_BUFFER:35052,PIXEL_PACK_BUFFER_BINDING:35053,PIXEL_UNPACK_BUFFER_BINDING:35055,FLOAT_MAT2x3:35685,FLOAT_MAT2x4:35686,FLOAT_MAT3x2:35687,FLOAT_MAT3x4:35688,FLOAT_MAT4x2:35689,FLOAT_MAT4x3:35690,SRGB:35904,SRGB8:35905,SRGB8_ALPHA8:35907,COMPARE_REF_TO_TEXTURE:34894,RGBA32F:34836,RGB32F:34837,RGBA16F:34842,RGB16F:34843,VERTEX_ATTRIB_ARRAY_INTEGER:35069,MAX_ARRAY_TEXTURE_LAYERS:35071,MIN_PROGRAM_TEXEL_OFFSET:35076,MAX_PROGRAM_TEXEL_OFFSET:35077,MAX_VARYING_COMPONENTS:35659,TEXTURE_2D_ARRAY:35866,TEXTURE_BINDING_2D_ARRAY:35869,R11F_G11F_B10F:35898,UNSIGNED_INT_10F_11F_11F_REV:35899,RGB9_E5:35901,UNSIGNED_INT_5_9_9_9_REV:35902,TRANSFORM_FEEDBACK_BUFFER_MODE:35967,MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:35968,TRANSFORM_FEEDBACK_VARYINGS:35971,TRANSFORM_FEEDBACK_BUFFER_START:35972,TRANSFORM_FEEDBACK_BUFFER_SIZE:35973,TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:35976,RASTERIZER_DISCARD:35977,MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:35978,MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:35979,INTERLEAVED_ATTRIBS:35980,SEPARATE_ATTRIBS:35981,TRANSFORM_FEEDBACK_BUFFER:35982,TRANSFORM_FEEDBACK_BUFFER_BINDING:35983,RGBA32UI:36208,RGB32UI:36209,RGBA16UI:36214,RGB16UI:36215,RGBA8UI:36220,RGB8UI:36221,RGBA32I:36226,RGB32I:36227,RGBA16I:36232,RGB16I:36233,RGBA8I:36238,RGB8I:36239,RED_INTEGER:36244,RGB_INTEGER:36248,RGBA_INTEGER:36249,SAMPLER_2D_ARRAY:36289,SAMPLER_2D_ARRAY_SHADOW:36292,SAMPLER_CUBE_SHADOW:36293,UNSIGNED_INT_VEC2:36294,UNSIGNED_INT_VEC3:36295,UNSIGNED_INT_VEC4:36296,INT_SAMPLER_2D:36298,INT_SAMPLER_3D:36299,INT_SAMPLER_CUBE:36300,INT_SAMPLER_2D_ARRAY:36303,UNSIGNED_INT_SAMPLER_2D:36306,UNSIGNED_INT_SAMPLER_3D:36307,UNSIGNED_INT_SAMPLER_CUBE:36308,UNSIGNED_INT_SAMPLER_2D_ARRAY:36311,DEPTH_COMPONENT32F:36012,DEPTH32F_STENCIL8:36013,FLOAT_32_UNSIGNED_INT_24_8_REV:36269,FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:33296,FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:33297,FRAMEBUFFER_ATTACHMENT_RED_SIZE:33298,FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:33299,FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:33300,FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:33301,FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:33302,FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:33303,FRAMEBUFFER_DEFAULT:33304,UNSIGNED_INT_24_8:34042,DEPTH24_STENCIL8:35056,UNSIGNED_NORMALIZED:35863,DRAW_FRAMEBUFFER_BINDING:36006,READ_FRAMEBUFFER:36008,DRAW_FRAMEBUFFER:36009,READ_FRAMEBUFFER_BINDING:36010,RENDERBUFFER_SAMPLES:36011,FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:36052,MAX_COLOR_ATTACHMENTS:36063,COLOR_ATTACHMENT1:36065,COLOR_ATTACHMENT2:36066,COLOR_ATTACHMENT3:36067,COLOR_ATTACHMENT4:36068,COLOR_ATTACHMENT5:36069,COLOR_ATTACHMENT6:36070,COLOR_ATTACHMENT7:36071,COLOR_ATTACHMENT8:36072,COLOR_ATTACHMENT9:36073,COLOR_ATTACHMENT10:36074,COLOR_ATTACHMENT11:36075,COLOR_ATTACHMENT12:36076,COLOR_ATTACHMENT13:36077,COLOR_ATTACHMENT14:36078,COLOR_ATTACHMENT15:36079,FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:36182,MAX_SAMPLES:36183,HALF_FLOAT:5131,RG:33319,RG_INTEGER:33320,R8:33321,RG8:33323,R16F:33325,R32F:33326,RG16F:33327,RG32F:33328,R8I:33329,R8UI:33330,R16I:33331,R16UI:33332,R32I:33333,R32UI:33334,RG8I:33335,RG8UI:33336,RG16I:33337,RG16UI:33338,RG32I:33339,RG32UI:33340,VERTEX_ARRAY_BINDING:34229,R8_SNORM:36756,RG8_SNORM:36757,RGB8_SNORM:36758,RGBA8_SNORM:36759,SIGNED_NORMALIZED:36764,COPY_READ_BUFFER:36662,COPY_WRITE_BUFFER:36663,COPY_READ_BUFFER_BINDING:36662,COPY_WRITE_BUFFER_BINDING:36663,UNIFORM_BUFFER:35345,UNIFORM_BUFFER_BINDING:35368,UNIFORM_BUFFER_START:35369,UNIFORM_BUFFER_SIZE:35370,MAX_VERTEX_UNIFORM_BLOCKS:35371,MAX_FRAGMENT_UNIFORM_BLOCKS:35373,MAX_COMBINED_UNIFORM_BLOCKS:35374,MAX_UNIFORM_BUFFER_BINDINGS:35375,MAX_UNIFORM_BLOCK_SIZE:35376,MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:35377,MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:35379,UNIFORM_BUFFER_OFFSET_ALIGNMENT:35380,ACTIVE_UNIFORM_BLOCKS:35382,UNIFORM_TYPE:35383,UNIFORM_SIZE:35384,UNIFORM_BLOCK_INDEX:35386,UNIFORM_OFFSET:35387,UNIFORM_ARRAY_STRIDE:35388,UNIFORM_MATRIX_STRIDE:35389,UNIFORM_IS_ROW_MAJOR:35390,UNIFORM_BLOCK_BINDING:35391,UNIFORM_BLOCK_DATA_SIZE:35392,UNIFORM_BLOCK_ACTIVE_UNIFORMS:35394,UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:35395,UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:35396,UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:35398,INVALID_INDEX:4294967295,MAX_VERTEX_OUTPUT_COMPONENTS:37154,MAX_FRAGMENT_INPUT_COMPONENTS:37157,MAX_SERVER_WAIT_TIMEOUT:37137,OBJECT_TYPE:37138,SYNC_CONDITION:37139,SYNC_STATUS:37140,SYNC_FLAGS:37141,SYNC_FENCE:37142,SYNC_GPU_COMMANDS_COMPLETE:37143,UNSIGNALED:37144,SIGNALED:37145,ALREADY_SIGNALED:37146,TIMEOUT_EXPIRED:37147,CONDITION_SATISFIED:37148,WAIT_FAILED:37149,SYNC_FLUSH_COMMANDS_BIT:1,VERTEX_ATTRIB_ARRAY_DIVISOR:35070,ANY_SAMPLES_PASSED:35887,ANY_SAMPLES_PASSED_CONSERVATIVE:36202,SAMPLER_BINDING:35097,RGB10_A2UI:36975,INT_2_10_10_10_REV:36255,TRANSFORM_FEEDBACK:36386,TRANSFORM_FEEDBACK_PAUSED:36387,TRANSFORM_FEEDBACK_ACTIVE:36388,TRANSFORM_FEEDBACK_BINDING:36389,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_SRGB8_ETC2:37493,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37494,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37495,COMPRESSED_RGBA8_ETC2_EAC:37496,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37497,TEXTURE_IMMUTABLE_FORMAT:37167,MAX_ELEMENT_INDEX:36203,TEXTURE_IMMUTABLE_LEVELS:33503,MAX_TEXTURE_MAX_ANISOTROPY_EXT:34047}),gs={UNSIGNED_BYTE:Ps.UNSIGNED_BYTE,UNSIGNED_SHORT:Ps.UNSIGNED_SHORT,UNSIGNED_INT:Ps.UNSIGNED_INT,FLOAT:Ps.FLOAT,HALF_FLOAT:Ps.HALF_FLOAT_OES,UNSIGNED_INT_24_8:Ps.UNSIGNED_INT_24_8,UNSIGNED_SHORT_4_4_4_4:Ps.UNSIGNED_SHORT_4_4_4_4,UNSIGNED_SHORT_5_5_5_1:Ps.UNSIGNED_SHORT_5_5_5_1,UNSIGNED_SHORT_5_6_5:Ps.UNSIGNED_SHORT_5_6_5,toWebGLConstant:function(t,e){switch(t){case gs.UNSIGNED_BYTE:return Ps.UNSIGNED_BYTE;case gs.UNSIGNED_SHORT:return Ps.UNSIGNED_SHORT;case gs.UNSIGNED_INT:return Ps.UNSIGNED_INT;case gs.FLOAT:return Ps.FLOAT;case gs.HALF_FLOAT:return e.webgl2?Ps.HALF_FLOAT:Ps.HALF_FLOAT_OES;case gs.UNSIGNED_INT_24_8:return Ps.UNSIGNED_INT_24_8;case gs.UNSIGNED_SHORT_4_4_4_4:return Ps.UNSIGNED_SHORT_4_4_4_4;case gs.UNSIGNED_SHORT_5_5_5_1:return Ps.UNSIGNED_SHORT_5_5_5_1;case gs.UNSIGNED_SHORT_5_6_5:return gs.UNSIGNED_SHORT_5_6_5}},isPacked:function(t){return t===gs.UNSIGNED_INT_24_8||t===gs.UNSIGNED_SHORT_4_4_4_4||t===gs.UNSIGNED_SHORT_5_5_5_1||t===gs.UNSIGNED_SHORT_5_6_5},sizeInBytes:function(t){switch(t){case gs.UNSIGNED_BYTE:return 1;case gs.UNSIGNED_SHORT:case gs.UNSIGNED_SHORT_4_4_4_4:case gs.UNSIGNED_SHORT_5_5_5_1:case gs.UNSIGNED_SHORT_5_6_5:case gs.HALF_FLOAT:return 2;case gs.UNSIGNED_INT:case gs.FLOAT:case gs.UNSIGNED_INT_24_8:return 4}},validate:function(t){return t===gs.UNSIGNED_BYTE||t===gs.UNSIGNED_SHORT||t===gs.UNSIGNED_INT||t===gs.FLOAT||t===gs.HALF_FLOAT||t===gs.UNSIGNED_INT_24_8||t===gs.UNSIGNED_SHORT_4_4_4_4||t===gs.UNSIGNED_SHORT_5_5_5_1||t===gs.UNSIGNED_SHORT_5_6_5}},Gs=Object.freeze(gs),vs={DEPTH_COMPONENT:Ps.DEPTH_COMPONENT,DEPTH_STENCIL:Ps.DEPTH_STENCIL,ALPHA:Ps.ALPHA,RGB:Ps.RGB,RGBA:Ps.RGBA,LUMINANCE:Ps.LUMINANCE,LUMINANCE_ALPHA:Ps.LUMINANCE_ALPHA,RGB_DXT1:Ps.COMPRESSED_RGB_S3TC_DXT1_EXT,RGBA_DXT1:Ps.COMPRESSED_RGBA_S3TC_DXT1_EXT,RGBA_DXT3:Ps.COMPRESSED_RGBA_S3TC_DXT3_EXT,RGBA_DXT5:Ps.COMPRESSED_RGBA_S3TC_DXT5_EXT,RGB_PVRTC_4BPPV1:Ps.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,RGB_PVRTC_2BPPV1:Ps.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,RGBA_PVRTC_4BPPV1:Ps.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,RGBA_PVRTC_2BPPV1:Ps.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,RGBA_ASTC:Ps.COMPRESSED_RGBA_ASTC_4x4_WEBGL,RGB_ETC1:Ps.COMPRESSED_RGB_ETC1_WEBGL,RGB8_ETC2:Ps.COMPRESSED_RGB8_ETC2,RGBA8_ETC2_EAC:Ps.COMPRESSED_RGBA8_ETC2_EAC,RGBA_BC7:Ps.COMPRESSED_RGBA_BPTC_UNORM,componentsLength:function(t){switch(t){case vs.RGB:return 3;case vs.RGBA:return 4;case vs.LUMINANCE_ALPHA:return 2;case vs.ALPHA:case vs.LUMINANCE:default:return 1}},validate:function(t){return t===vs.DEPTH_COMPONENT||t===vs.DEPTH_STENCIL||t===vs.ALPHA||t===vs.RGB||t===vs.RGBA||t===vs.LUMINANCE||t===vs.LUMINANCE_ALPHA||t===vs.RGB_DXT1||t===vs.RGBA_DXT1||t===vs.RGBA_DXT3||t===vs.RGBA_DXT5||t===vs.RGB_PVRTC_4BPPV1||t===vs.RGB_PVRTC_2BPPV1||t===vs.RGBA_PVRTC_4BPPV1||t===vs.RGBA_PVRTC_2BPPV1||t===vs.RGBA_ASTC||t===vs.RGB_ETC1||t===vs.RGB8_ETC2||t===vs.RGBA8_ETC2_EAC||t===vs.RGBA_BC7},isColorFormat:function(t){return t===vs.ALPHA||t===vs.RGB||t===vs.RGBA||t===vs.LUMINANCE||t===vs.LUMINANCE_ALPHA},isDepthFormat:function(t){return t===vs.DEPTH_COMPONENT||t===vs.DEPTH_STENCIL},isCompressedFormat:function(t){return t===vs.RGB_DXT1||t===vs.RGBA_DXT1||t===vs.RGBA_DXT3||t===vs.RGBA_DXT5||t===vs.RGB_PVRTC_4BPPV1||t===vs.RGB_PVRTC_2BPPV1||t===vs.RGBA_PVRTC_4BPPV1||t===vs.RGBA_PVRTC_2BPPV1||t===vs.RGBA_ASTC||t===vs.RGB_ETC1||t===vs.RGB8_ETC2||t===vs.RGBA8_ETC2_EAC||t===vs.RGBA_BC7},isDXTFormat:function(t){return t===vs.RGB_DXT1||t===vs.RGBA_DXT1||t===vs.RGBA_DXT3||t===vs.RGBA_DXT5},isPVRTCFormat:function(t){return t===vs.RGB_PVRTC_4BPPV1||t===vs.RGB_PVRTC_2BPPV1||t===vs.RGBA_PVRTC_4BPPV1||t===vs.RGBA_PVRTC_2BPPV1},isASTCFormat:function(t){return t===vs.RGBA_ASTC},isETC1Format:function(t){return t===vs.RGB_ETC1},isETC2Format:function(t){return t===vs.RGB8_ETC2||t===vs.RGBA8_ETC2_EAC},isBC7Format:function(t){return t===vs.RGBA_BC7},compressedTextureSizeInBytes:function(t,e,r){switch(t){case vs.RGB_DXT1:case vs.RGBA_DXT1:case vs.RGB_ETC1:case vs.RGB8_ETC2:return Math.floor((e+3)/4)*Math.floor((r+3)/4)*8;case vs.RGBA_DXT3:case vs.RGBA_DXT5:case vs.RGBA_ASTC:case vs.RGBA8_ETC2_EAC:return Math.floor((e+3)/4)*Math.floor((r+3)/4)*16;case vs.RGB_PVRTC_4BPPV1:case vs.RGBA_PVRTC_4BPPV1:return Math.floor((Math.max(e,8)*Math.max(r,8)*4+7)/8);case vs.RGB_PVRTC_2BPPV1:case vs.RGBA_PVRTC_2BPPV1:return Math.floor((Math.max(e,16)*Math.max(r,8)*2+7)/8);case vs.RGBA_BC7:return Math.ceil(e/4)*Math.ceil(r/4)*16;default:return 0}},textureSizeInBytes:function(t,e,r,n){var i=vs.componentsLength(t);return Gs.isPacked(e)&&(i=1),i*Gs.sizeInBytes(e)*r*n},alignmentInBytes:function(t,e,r){var n=vs.textureSizeInBytes(t,e,r,1)%4;return 0===n?4:2===n?2:1},createTypedArray:function(t,e,r,n){var i=Gs.sizeInBytes(e);return new(i===Uint8Array.BYTES_PER_ELEMENT?Uint8Array:i===Uint16Array.BYTES_PER_ELEMENT?Uint16Array:i===Float32Array.BYTES_PER_ELEMENT&&e===Gs.FLOAT?Float32Array:Uint32Array)(vs.componentsLength(t)*r*n)},flipY:function(t,e,r,n,i){if(1===i)return t;for(var s=vs.createTypedArray(e,r,n,i),o=vs.componentsLength(e),a=n*o,c=0;c<i;++c)for(var f=c*n*o,u=(i-c-1)*n*o,l=0;l<a;++l)s[u+l]=t[f+l];return s},toInternalFormat:function(t,e,r){if(!r.webgl2)return t;if(t===vs.DEPTH_STENCIL)return Ps.DEPTH24_STENCIL8;if(t===vs.DEPTH_COMPONENT){if(e===Gs.UNSIGNED_SHORT)return Ps.DEPTH_COMPONENT16;if(e===Gs.UNSIGNED_INT)return Ps.DEPTH_COMPONENT24}if(e===Gs.FLOAT)switch(t){case vs.RGBA:return Ps.RGBA32F;case vs.RGB:return Ps.RGB32F;case vs.RG:return Ps.RG32F;case vs.R:return Ps.R32F}if(e===Gs.HALF_FLOAT)switch(t){case vs.RGBA:return Ps.RGBA16F;case vs.RGB:return Ps.RGB16F;case vs.RG:return Ps.RG16F;case vs.R:return Ps.R16F}return t}},Xs=Object.freeze(vs);function Hs(t,e,r,n,i,s){const o=function(t,e,r,n){let i=t.length,s=r,o=n,a=0;for(;s>0&&o>0;){if(a+=Xs.compressedTextureSizeInBytes(e,s,o),s>>=1,o>>=1,0===s&&0===o)break;s=Math.max(s,1),o=Math.max(o,1)}return a===i}(t,r,i,s);if(!o)return null;const a=6410===r||4369===r;let c=0,f=i,u=s;const l=[];do{let n=Xs.compressedTextureSizeInBytes(r,f,u),i=new Uint8Array(t.buffer,e+c,n);l.push(i),f=Math.max(f>>1,1),u=Math.max(u>>1,1),c+=n}while(c<t.byteLength&&o);return{flipY:a,mipmap:l}}function xs(t,e){for(var r,n,i,s=t.bytesOffset,o=fs.parseBuffer(t.buffer,s),a=o.geoPackage,c=o.groupNode.pageLods,f=[],u=[],l=[],E=[],_=[],A=[],h=[],T=c[0].geodes[0].matrix,R={},y=0;y<o.materials.material.length;y++)R[o.materials.material[y].material.id]=o.materials.material[y].material;var I=Number.MAX_VALUE,N=Number.MAX_VALUE,U=Number.MAX_VALUE,S=Number.MIN_VALUE,d=Number.MIN_VALUE,m=Number.MIN_VALUE;for(var M in a){var O=a[M].vertexPackage;r=O.verticesCount;var F=O.vertexAttributes[0].typedArray.buffer,b=O.vertexAttributes[0].typedArray.byteOffset,C=O.vertexAttributes[0].componentsPerAttribute;i=new Float32Array(F,O.vertexAttributes[0].offsetInBytes+b,r*C);for(let t=0;t<r;t++){var p=i[t*C],w=i[t*C+1],D=i[t*C+2];I=Math.min(I,p),N=Math.min(N,w),U=Math.min(U,D),S=Math.max(S,p),d=Math.max(d,w),m=Math.max(m,D)}f.push(i),Eo("aTexCoord0",O,F,r,l),Eo("batchId",O,F,r,_),O.vertexColor?E.push(O.vertexColor):E.push(void 0);var B=a[M].arrIndexPackage[0].indicesTypedArray,L=B.byteLength/a[M].arrIndexPackage[0].indicesCount;n=new(4===L?Uint32Array:2===L?Uint16Array:Uint8Array)(B.buffer,(a[M].arrIndexPackage[0].bytesOffset||0)+B.byteOffset,a[M].arrIndexPackage[0].indicesCount),u.push(n),n.length,h.push(r);var P=a[M].arrIndexPackage[0].materialCode;A.push(R[P])}var g=[I,N,U],G=[S,d,m];const v=function(t,e,r,n,i,s,o,a,c,f,u,l,E,_,A){let h=0;for(const t in a)a[t].width*a[t].height*4>h&&(h=a[t].width*a[t].height*4);(!ks||h>ks)&&(Vs=new Uint8ClampedArray(h+122),ks=h);const T=[],R={magFilter:9729,minFilter:9729,wrapS:10497,wrapT:10497},y={},I={},N=[],U=[],S=[];for(let c=0;c<r.length;c++){const h=e[c],d=t[c],m=r[c],M=i&&i[c]&&i[c],O=n&&n[c]&&n[c],F=s&&s[c]&&s[c],b=o&&o[c]&&o[c],C={POSITION:{array:m,componentType:5126,count:d,byteOffset:m.byteOffset,byteStride:0,byteLength:m.byteLength,type:ae(m.length/d),itemSize:m.length/d,name:"POSITION",min:f,max:u}};N.indexOf(m.buffer)<0&&N.push(m.buffer),M&&_o(C,"TEXCOORD_0",M,d,N),O&&_o(C,"NORMAL",O,d,N),F&&_o(C,"COLOR_0",F,d,N),b&&_o(C,"_BATCHID",b,d,N);const p={attributes:C,material:c,indices:{array:h.slice(),itemSize:1,byteLength:h.byteLength,byteOffset:0,byteStride:0,name:h,count:h.length,componentType:5123},mode:4};N.push(p.indices.array.buffer);const w={primitives:[p],index:c};I[c]=w;const D={mesh:c,nodeIndex:c,matrix:A};y[c]=D,U.push({nodes:[D]});const B=E[c],L={uFillForeColor:[1,1,1,1]};let P=B.ambient;L.ambientColor=[P.r,P.g,P.b,P.a];let g=B.diffuse;L.uDiffuseColor=[g.r,g.g,g.b,g.a];let G=B.specular;L.specularColor=[G.r,G.g,G.b,G.a],L.shininess=B.shininess,L.bTransparentSorting=B.transparentsorting;let v=B.textureunitstates;if(v.length){L.uTexMatrix=v[0].textureunitstate.texmodmatrix;const t=a[v[0].textureunitstate.id];if(L.uTexture0Width=t.width,v[1]){const t=a[v[1].textureunitstate.id];L.uTexture1Width=t.width}}S.push({pbrMetallicRoughness:{baseColorFactor:[.8,.8,.8,1],metallicFactor:0,roughnessFactor:.5},extensions:{KHR_techniques_webgl:{technique:0,values:L}}}),T.push(Ks(c,E,l,a,_).then((t=>{if(!t)return null;const{array:e,mipmap:r,width:n,height:i,format:s,flipY:o}=t;if(e&&N.indexOf(e.buffer)<0&&N.push(e.buffer),r)for(let t=0;t<r.length;t++)e&&N.indexOf(r[t].buffer)<0&&N.push(r[t].buffer);let a=R;return r&&(a={magFilter:R.magFilter,minFilter:9987,wrapS:R.wrapS,wrapT:R.wrapT}),{materialIndex:c,image:{mipmap:r,array:e,flipY:!!o,width:n,height:i,mimeType:"image/bmp"},sampler:a,format:s,source:c}})))}return Promise.all(T).then((t=>{t=t.filter((t=>!!t));for(let e=0;e<t.length;e++){const{materialIndex:r}=t[e];let n="uTexture";S[r].extensions.KHR_techniques_webgl.values.uTexture&&(n="uTexture2"),S[r].extensions.KHR_techniques_webgl.values[n]={"index":e,"texCoord":r},delete t[e].materialIndex}return{transferables:N,gltf:{"asset":{"generator":"S3M","version":"2.0"},"scene":0,"scenes":U,"nodes":y,"meshes":I,"materials":S,"skins":[],"animations":null,"textures":t,"transferables":[{},{},{},{},{}]}}}))}(h,u,f,null,l,E,_,o.texturePackage,0,g,G,[],A,e,T);return v.then((({gltf:t,transferables:e})=>({gltf:t,featureTable:{"BATCH_LENGTH":0},transferables:e,pageLods:c})))}fs.multiplyByPoint=function(t,e,r){var n=e.x,i=e.y,s=e.z,o=t[0]*n+t[4]*i+t[8]*s+t[12],a=t[1]*n+t[5]*i+t[9]*s+t[13],c=t[2]*n+t[6]*i+t[10]*s+t[14];return r.x=o,r.y=a,r.z=c,r};let Vs,ks=0;let Zs=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(cn){}t&&"undefined"!=typeof createImageBitmap&&(Zs=!0)}const Ys={};function Ks(t,e,r,n,i){const s=Vs;return new Promise((function(r){!function(t){if(e[t].textureunitstates[0]){var o=e[t].textureunitstates[0].textureunitstate.id,a=n[o],c=a.arrayBufferView,f=a.nFormat,u=a.internalFormat;if(function(t){return t===Qs||t===to||t===eo||t===ro||t===no||t===io||t===so||t===oo||t===ao||t===co||t===fo||t===uo||t===lo}(u)&&a.width===a.height){const t=Hs(c,c.byteOffset,u,0,a.width,a.height);if(t){const{mipmap:e,flipY:n}=t;return void r({format:u,mipmap:e,flipY:n,width:a.width,height:a.height})}}let l;l=f>Qi||f===Ji?122+a.width*a.height*4:61+a.width*a.height,cs.decode(s.subarray(122),a.width,a.height,c,f),function(t,e,r){var n=r*(4*e+e%4),i=n+o,s=new DataView(t),o=0;s.setUint16(o,19778,!0),o+=2,s.setUint32(o,i,!0),o+=4,s.setUint32(o,0,!0),o+=4,s.setUint32(o,122,!0),o+=4,s.setUint32(o,108,!0),o+=4,s.setUint32(o,e,!0),o+=4,s.setUint32(o,r,!0),o+=4,s.setUint16(o,1,!0),o+=2,s.setUint16(o,32,!0),o+=2,s.setUint32(o,this.compress,!0),o+=4,s.setUint32(o,n,!0),o+=4,s.setUint32(o,2835,!0),o+=4,s.setUint32(o,2835,!0),o+=4,s.setUint8(o,0,!0),o+=4,s.setUint32(o,0,!0),o+=4,s.setUint32(o,16711680,!0),o+=4,s.setUint32(o,65280,!0),o+=4,s.setUint32(o,255,!0),o+=4,s.setUint32(o,4278190080,!0),o+=4,s.setUint32(o,1466527264,!0),o+=4}(s.buffer,a.width,a.height);let{width:E,height:_}=a;zs(E)||(E=Ws(E)),zs(_)||(_=Ws(_));const A=i;let h;A&&(E=Math.min(A,E),_=Math.min(A,_));let T=6408;const R=a.width*a.height*4;!Zs||E===a.width&&_===a.height?(h=new Uint8Array(3*R/4),T=6407):(Ys[R]||(Ys[R]=new Uint8Array(R)),h=Ys[R]),h=Ls(h,s.buffer,0,l),!Zs||E===a.width&&_===a.height||(h=function(t,e,r,n,i){js||(js=new OffscreenCanvas(2,2),qs=js.getContext("2d"),$s=new OffscreenCanvas(2,2),Js=$s.getContext("2d"));const s=new ImageData(new Uint8ClampedArray(t.buffer),e,r);return js.width=e,js.height=r,qs.putImageData(s,0,0),$s.width=n,$s.height=i,Js.drawImage(js,0,0,n,i),Js.getImageData(0,0,n,i).data}(h,a.width,a.height,E,_)),h.buffer===(Ys[R]&&Ys[R].buffer)&&(h=new Uint8Array(h)),r({array:h,width:E,height:_,format:T})}else r(null)}(t)}))}function zs(t){return 0==(t&t-1)&&0!==t}function Ws(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}let js,qs,$s,Js;const Qs=33776,to=33777,eo=33778,ro=33779,no=35840,io=35841,so=35842,oo=35843,ao=37808,co=36196,fo=37492,uo=37496,lo=36492;function Eo(t,e,r,n,i){var s,o=e.attrLocation[t];if(o){const t=e.vertexAttributes[o];if(t.typedArray.buffer!==r)i.push(t.typedArray);else{var a=t.componentsPerAttribute;var c=new(s=t.componentDatatype,se[s])(r,t.offsetInBytes+t.typedArray.byteOffset,n*a);i.push(c)}}else i.push(void 0)}function _o(t,e,r,n,i){t[e]={array:r,componentType:oe(r.constructor),count:n,byteOffset:r.byteOffset,byteStride:0,byteLength:r.byteLength,type:ae(r.length/n),itemSize:r.length/n,name:e},i.indexOf(r.buffer)<0&&i.push(r.buffer)}var Ao=Io("DXT1"),ho=Io("DXT3"),To=Io("DXT5"),Ro=Io("DX10"),yo=function(t){var e,r,n=new Int32Array(t,0,31);if(542327876!==n[0])throw new Error("Invalid magic number in DDS header");if(4&!n[20])throw new Error("Unsupported format, must contain a FourCC code");var i=n[21];switch(i){case Ao:e=8,r="dxt1";break;case ho:e=16,r="dxt3";break;case To:e=16,r="dxt5";break;case 116:r="rgba32f";break;case Ro:var s=new Uint32Array(t.slice(128,148));r=s[0];var o=s[1];if(s[2],s[3],s[4],3!==o||2!==r)throw new Error("Unsupported DX10 texture format "+r);r="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=i,String.fromCharCode(255&a,a>>8&255,a>>16&255,a>>24&255)))}var a;var c=n[2],f=1;131072&c&&(f=Math.max(1,n[7]));var u=!1;512&n[28]&&(u=!0);var l,E=n[4],_=n[3],A=n[1]+4,h=E,T=_,R=[];i===Ro&&(A+=20);if(u)for(var y=0;y<6;y++){if("rgba32f"!==r)throw new Error("Only RGBA32f cubemaps are supported");E=h,_=T;for(var I=Math.log(E)/Math.log(2)+1,N=0;N<I;N++)l=E*_*16,R.push({offset:A,length:l,shape:[E,_]}),N<f&&(A+=l),E=Math.floor(E/2),_=Math.floor(_/2)}else for(N=0;N<f;N++)l=Math.max(4,E)/4*Math.max(4,_)/4*e,R.push({offset:A,length:l,shape:[E,_]}),A+=l,E=Math.floor(E/2),_=Math.floor(_/2);return{shape:[h,T],images:R,format:r,flags:c,cubemap:u}};function Io(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}const No=Math.PI/180,Uo=6378137*Math.PI/180,So=85.0511287798;function mo(t,e,r){if("EPSG:3857"===r)return function(t,e){const r=So,n=e[0],i=Math.max(Math.min(r,e[1]),-r);let s;s=0===i?0:Math.log(Math.tan((90+i)*No/2))/No;return t[0]=n*Uo,t[1]=s*Uo,t}(t,e);if("EPSG:4326"===r||"EPSG:4490"===r||"identity"===r)return Mo(t,e);if("baidu"===r)return Mo(t,e);throw new Error("unsupported projection:"+r)}function Mo(t,e){return t[0]=e[0],t[1]=e[1],t}function Oo(t,e,r,n){if("EPSG:3857"===n)return function(t,e,r,n){return Co(Fo,t,r,0),mo(Fo,Fo,n),Fo[0]-e[0]}(t,e,r,n);if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return bo(t,e,r);if("baidu"===n)return bo(t,e,r);throw new Error("unsupported projection:"+n)}const Fo=[0,0];function bo(t,e,r){return Co(Fo,t,r,0),Fo[0]-t[0]}function Co(t,e,r,n){if(!e)return null;if(r||(r=0),n||(n=0),!r&&!n)return t[0]=e[0],t[1]=e[1],t;let i,s,o=po(e[1]);if(0!==n){const t=Math.abs(n);o+=2*Math.sin(t/12756274)*(n>0?1:-1),s=wo(180*o/Math.PI,-90,90)}else s=e[1];if(0!==r){const t=Math.abs(r);let n=po(e[0]);n+=2*Math.sqrt(Math.pow(Math.sin(t/12756274),2)/Math.pow(Math.cos(o),2))*(r>0?1:-1),i=wo(180*n/Math.PI,-180,180)}else i=e[0];return t[0]=i,t[1]=s,t}function po(t){return t*Math.PI/180}function wo(t,e,r){if(t===r||t===e)return t;const n=r-e;return((t-e)%n+n)%n+e}const Do=n([]),Bo=ue.draco&&ue.draco(),Lo=ue.ktx2&&ue.ktx2(),Po={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},go={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{"componentType":5125,"type":"VEC2"}};function Go(t,e,r,i){const s=[],o=[],a=[];for(let e=0;e<t.meshes.length;e++){const{geometry:r,material:n}=t.meshes[e];let i=k.getArrayBuffer(r.url);i.xhr.url=r.url,a.push(i.xhr);const c=i.then((t=>({buffer:t})));s.push(c);const f=[];if(Yo(n,f),f.length){const t=f.map((t=>{const e=k.getArrayBuffer(t.url);return e.xhr.url=t.url,a.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));s.push(...t)}o[e]=f.length}const c=Promise.all(s).then((s=>{for(let t=0;t<s.length;t++)if(!s[t]||!s[t].buffer)return Promise.resolve(null);const a=[];let c=0;for(let t=0;t<o.length;t++){const e=o[t];a.push({geoBuffer:{data:s[c].buffer.data},textureBuffers:s.slice(c+1,e+c+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),c+=1+e}const f=function(t,e,r,i,s){const o={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},a=[];for(let c=0;c<t.meshes.length;c++){let f,{geometry:u,material:l}=t.meshes[c];f=$o(e[c].geoBuffer.data)?Xo(o,c,u,e[c].geoBuffer.data,t.transform,t.center,s):xo(o,c,u,e[c].geoBuffer.data,t.transform,t.center,s),a.push(f),o.nodes[c]={mesh:c,nodeIndex:c,matrix:n([])},o.scenes[0].nodes[c]=o.nodes[c],l||(l=Po);const E=ko(c,o,l,e[c].textureBuffers,r,i);a.push(E)}return Promise.all(a).then((()=>({gltf:o,featureTable:{BATCH_LENGTH:0},transferables:o.transferables})))}(t,a,e,i,r);return f}));return c.xhr=a,c}const vo={"magFilter":9729,"minFilter":9729,"wrapR":10497,"wrapS":10497,"wrapT":10497};function Xo(t,e,r,n,i,s,o){const a=r.info.compressedAttributes.attributes.reduce(((t,e,r)=>{const n=go[e];if(!n)return t;return t[n.name||e]=r,t}),{});return Bo(n,{attributes:a,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((r=>Vo(r,t,e,i,s,o)))}var Ho={position:function(t,e,r){const n=3*t.vertexCount,i=new Float32Array(e,r,n);return t.position={array:i,componentType:5126,itemSize:3,count:n/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},r+=4*n},normal:function(t,e,r){var n=3*t.vertexCount;const i=new Float32Array(e,r,n);return t.normal={array:i,componentType:5126,itemSize:3,count:n/3,type:"VEC3"},r+=4*n},uv0:function(t,e,r){var n=2*t.vertexCount;const i=new Float32Array(e,r,n);return t.uv0={array:i,componentType:5126,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},color:function(t,e,r){var n=4*t.vertexCount;const i=new Uint8Array(e,r,n);return t.color={array:i,componentType:5121,itemSize:4,count:n/4,type:"VEC4"},r+=n},featureId:function(t,e,r){return r+=8*t.featureCount},id:function(t,e,r){return r+=8*t.featureCount},faceRange:function(t,e,r){var n=2*t.featureCount;const i=new Uint32Array(e,r,n);return t.faceRange={array:i,componentType:5125,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},uvRegion:function(t,e,r){var n=4*t.vertexCount;const i=new Uint16Array(e,r,n);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n},region:function(t,e,r){var n=4*t.vertexCount;const i=new Uint16Array(e,r,n);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n}};function xo(t,e,r,n,i,s,o){const a={vertexCount:0},c=new DataView(n);try{var f=0;a.vertexCount=c.getUint32(f,1),f+=4,a.featureCount=c.getUint32(f,1),f+=4;const t=r.info.ordering?null:r.info;if(t){const e=[];for(const r in t)"offset"!==r&&""!==r&&e.push(r);for(var u=0;u<e.length;u++)Ho[e[u]]?f=Ho[e[u]](a,n,f):console.error("Unknown decoder for",e[u])}else{const t=r.info;let e=t.ordering,i=t.featureAttributeOrder;const s=null;s&&s.geometryData&&s.geometryData[0]&&s.geometryData[0].params;for(var l=0;l<e.length;l++){var E=Ho[e[l]];E||console.log(e[l]),f=E(a,n,f)}for(var _=0;_<i.length;_++){var A=Ho[i[_]];A||console.log(i[_]),f=A(a,n,f)}}}catch(t){console.warn(t)}a.scale_x=1,a.scale_y=1;const h={};for(const t in a){const e=go[t]&&go[t].name;e&&(h[e]=a[t])}if(a.faceRange){const t=a.faceRange.array,e=t.length/2,r=(T=e)<=255?Uint8Array:T<=65535?Uint16Array:Uint32Array,n=new r(h.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const r=e/2,i=t[e],s=t[e+1];for(let t=i;t<=s;t++)n[3*t]=r,n[3*t+1]=r,n[3*t+2]=r}h._BATCHID={componentType:oe(r),array:n,itemSize:1,count:n.length,type:"SCALAR"}}var T;return Vo({attributes:h},t,e,i,s,o)}function Vo(t,e,r,n,i,s){const o={attributes:t.attributes,material:r,indices:t.indices,mode:4},a=t.attributes.POSITION.array.length/3;!function(t){const e=t.array,r=t.meta&&t.meta["i3s-scale_x"],n=t.meta&&t.meta["i3s-scale_y"];if(r&&n&&(1!==r||1!==n))for(let t=0;t<e.length;t+=3)e[t]*=r.value,e[t+1]*=n.value}(t.attributes.POSITION);const c=function(t,e,r,n){const i=r;let s,o=[0,0,0,1],a=[0,0];const c=mo([],r,n);c[2]=r[2];const f=e&&function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}(Do,e);return Ue(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],f||(o=y(o,o,e)),i&&u(o,o,i),mo(a,o,n),s=o[2]?Oo(o,a,o[2],n):0,t[0]=a[0]-c[0],t[1]=a[1]-c[1],t[2]=s-c[2],t))),c}(t.attributes.POSITION,n,i,s);t.attributes.TEXCOORD_0&&t.attributes.uvRegion&&(!function(t,e,r){for(var n=0;n<t;++n){var i=r[4*n]/65535,s=r[4*n+1]/65535,o=(r[4*n+2]-r[4*n])/65535,a=(r[4*n+3]-r[4*n+1])/65535;e[2*n]*=o,e[2*n]+=i,e[2*n+1]*=a,e[2*n+1]+=s}}(a,t.attributes.TEXCOORD_0.array,t.attributes.uvRegion.array),delete t.attributes.uvRegion),e.meshes[r]={primitives:[o],index:r},e.extensions.CESIUM_RTC={i3sProjCenter:c};for(const r in t.attributes)qo(e.transferables,t.attributes[r].array.buffer);return t.indices&&qo(e.transferables,t.indices.array.buffer),o}function ko(t,e,r,n,i,s){const o=n.map((t=>function(t,e,r,n,i){if("dds"===e){const e=yo(t),n=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),i="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:n,width:e.shape[0],height:e.shape[1],mimeType:r},sampler:vo,format:i})}if("png"===e||"jpg"===e)return function(t,e){Ko||(Ko=new OffscreenCanvas(2,2),zo=Ko.getContext("2d"));const r=new Blob([new Uint8Array(t)]);return createImageBitmap(r).then((t=>{let{width:r,height:n}=t;Wo(r)||(r=jo(r)),Wo(n)||(n=jo(n));const i=e;i&&(r=Math.min(i,r),n=Math.min(i,n)),Ko.width=r,Ko.height=n,zo.drawImage(t,0,0,r,n),t.close();const s=zo.getImageData(0,0,r,n);return{width:r,height:n,array:new Uint8Array(s.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,i).then((t=>{t.mimeType=r;return{image:t,sampler:vo,format:6408}}));if("ktx2"===e)return Lo(t,n).then((t=>(t.mimeType=r,{image:t,sampler:vo,format:t.format})))}(t.data,t.format,t.mimeType,i,s).then((t=>{if(t.image)if(t.image.array)qo(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let r=0;r<t.image.mipmap.length;r++)qo(e.transferables,t.image.mipmap[r].buffer);return t}))));return Promise.all(o).then((n=>{Zo(t,e,r,n)}))}function Zo(t,e,r,n){const i=JSON.parse(JSON.stringify(r)),s=e.textures;n.ptr||(n.ptr=0);for(const t in r)r[t]&&r[t].url?(s.push(n[n.ptr++]),i[t]={index:s.length-1},void 0!==r[t].factor&&(i[t].scale=r[t].factor)):At(r[t])&&(i[t]=Zo(-1,e,r[t],n));return t>=0&&(e.materials[t]=i),i}function Yo(t,e){for(const r in t)t[r]&&t[r].url?e.push({url:t[r].url,mimeType:t[r].mimeType,format:t[r].format}):At(t[r])&&Yo(t[r],e)}let Ko,zo;function Wo(t){return 0==(t&t-1)&&0!==t}function jo(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function qo(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function $o(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}const Jo=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Qo=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],ta="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let ea,ra,na=!1;if("undefined"!=typeof OffscreenCanvas){try{ra=new OffscreenCanvas(2,2).getContext("2d")}catch(cn){}ra&&"undefined"!=typeof createImageBitmap&&(na=!0)}const ia=n([]),sa=[0,0,0],oa=[],aa=[];class ca{constructor(t,e,r,n){this.id=t,this.options=e,this.dt=this.requestImage.bind(this),this.Mt=r,this.Ot={},n(null,{},[])}Ft(t){this.bt||(this.Ct=new Te,this.bt=new le(this.dt,at,t),this.wt=new Ee(this.dt,at,t))}requestImage(t,e){na?fetch(t).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{ea.width=t.width,ea.height=t.height,ra.drawImage(t,0,0);const r=ra.getImageData(0,0,ea.width,ea.height);e(null,{width:t.width,height:t.height,data:new Uint8Array(r.data)})})):this.Mt("requestImage",{url:t},null,e)}loadTile(t,e){this.Ft(t.supportedFormats);const r=t.url,n=t.arraybuffer;if(function(t){return t.indexOf("i3s:")>=0}(r)){const n=t.i3sInfo,i=this.options.services[t.rootIdx].maxTextureSize||1024,s=Go(n,t.supportedFormats,this.options.projection,i);return s.then((t=>{if(delete this.Ot[r],!t)return void e({status:404,url:r,i3sInfo:n});t.gltf.url=r;const{transferables:i}=t;t.magic="b3dm",e(null,t,i)})),void(this.Ot[r]=s.xhr)}if(n){delete this.Ot[r];const i=new DataView(n),s=Lt(i,0);if("{"===s[0]||" "===s[0]||"<"===s[0]){const i=function(t,e,r){if(ta){const n=new Uint8Array(t,e,r);return ta.decode(n)}return It(new Uint8Array(t,e,r))}(n,0,n.byteLength),s=JSON.parse(i);this.Dt(t.rootIdx,s,n,r,e)}else{const o=i.getFloat32(0,!0);1===o||2===o?this.Bt(n,r,t,e):this.Lt(n,r,t,s,e)}}else{const n=this.options.services[t.rootIdx];let i=n.urlParams;i&&(i=(r.indexOf("?")>0?"&":"?")+i);let s=k.getArrayBuffer(r+(i||""),n.fetchOptions);const o=s.xhr;s=s.then((n=>{delete this.Ot[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.Ot[r],e(t)})),this.Ot[r]=o}}Lt(t,e,r,n,i){const s=this.options.services[r.rootIdx];if("b3dm"===n){this.bt.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:n}=this.Pt(t,r);i(null,e,n)})).catch((t=>{i(t)}))}else if("pnts"===n){const n=r.transform;this.Ct.load(e,t).then((t=>{const{content:e,transferables:s}=this.gt(t,n,r.rootIdx);i(null,e,s)}))}else if("i3dm"===n){const n=r.transform;this.wt.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{const{content:e,transferables:s}=this.gt(t,n,r.rootIdx);i(null,e,s)}))}else if("cmpt"===n){new ye(this.dt,at).load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{const{content:e,transferables:n}=this.Gt(t,r);i(null,e,n)})).catch((t=>{i(t)}))}}Bt(t,e,r,n){xs({buffer:t,bytesOffset:0},this.options.services[r.rootIdx].maxTextureSize||1024).then((t=>{t.gltf.url=e;const{content:i,transferables:s}=this.Pt(t,r);if(i.magic="b3dm",t.pageLods){const e=this.vt(t.pageLods);e.length&&(i.children=e)}n(null,i,s)}))}vt(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(!n.childTile)continue;const i={boundingVolume:{sphere:[n.boundingSphere.center.x,n.boundingSphere.center.y,n.boundingSphere.center.z,n.boundingSphere.radius]},content:{uri:n.childTile},geometricError:n.boundingSphere.radius/n.rangeList*16,refine:"REPLACE"};e.push(i)}return e}Dt(t,e,r,n,i){return e.dataType&&e.position?void i(null,me(e)):(e.capabilities,void i(null,e))}Gt(t,e){const{tiles:r}=t,n={magic:"cmpt",content:[]},i=[];for(let t=0;t<r.length;t++){const{magic:s}=r[t];if("b3dm"===s){const{content:s,transferables:o}=this.Pt(r[t],e);la(i,o),n.content.push(s)}else if("i3dm"===s||"pnts"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.gt(r[t],s,o);la(i,c),n.content.push(a)}else if("cmpt"===s){const{content:s,transferables:o}=this.Gt(r[t],e);la(i,o),n.content.push(s)}}return{content:n,transferables:i}}Pt(t,e){const{gltf:r,transferables:n,featureTable:i}=t;return this.Xt(t.gltf),this.convertCoordinates(r,i,e.upAxis,e.transform),delete t.transferables,{content:t,transferables:n}}gt(t,e,r){const{featureTable:n}=t,i=t.pnts||t.i3dm;let s=n&&n.RTC_CENTER||[0,0,0];if(n.EAST_NORTH_UP&&!i.NORMAL_UP&&!i.NORMAL_UP_OCT32P){const e=new Float32Array(3*i.POSITION.array.length),r=[],n=[],o=[];Ue(i.POSITION,((t,i)=>{u(o,t,s),Qt(o,null,r),function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10]}(n,r);!function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8]}(e.subarray(9*i,9*(i+1)),n)})),i.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const o={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};fa(i.POSITION.array,3,s,ia,o);const a=ua(o),f=c([],a),l=[1/0,1/0,1/0],E=[-1/0,-1/0,-1/0];Ue(i.POSITION,(t=>{t[0]=t[0]+s[0]-f[0],t[1]=t[1]+s[1]-f[1],t[2]=t[2]+s[2]-f[2],t[0]<l[0]&&(l[0]=t[0]),t[1]<l[1]&&(l[1]=t[1]),t[2]<l[2]&&(l[2]=t[2]),t[0]>E[0]&&(E[0]=t[0]),t[1]>E[1]&&(E[1]=t[1]),t[2]>E[2]&&(E[2]=t[2])})),i.POSITION.min=l,i.POSITION.max=E,e&&y(a,a,e);const _=this.Ht(a);t.rtcCenter=f,t.rtcCoord=_,t.rootIdx=r;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}Xt(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const r=e[t].image&&e[t].image.array;if(r&&r.length){const n=r[0],i=r[1],s=r[2],o=r[3];let a=!0;for(let t=4;t<r.length;t+=4)if(r[t]!==n||r[t+1]!==i||r[t+2]!==s||r[t+3]!==o){a=!1;break}a&&(e[t].image.color=[n/255,i/255,s/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const r=this.Ot[t.url];if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t].abort();else r&&r.abort&&r.abort();delete this.Ot[t.url],e(null)}convertCoordinates(t,e,r,s){let o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center,a=Jo;"X"===(r=r&&r.toUpperCase())?a=Qo:"Z"===r&&(a=ia),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o);const f={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Ie(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=n(oa);if(t.matrices)for(let r=t.matrices.length-1;r>=0;r--)i(e,e,t.matrices[r]);const r=t.attributes.POSITION.array,s=t.attributes.POSITION.itemSize;i(e,a,e),fa(r,s,o||sa,e,f)}));const u=ua(f),l=c([],u);s&&y(u,u,s),t.extensions.CESIUM_RTC.coord=this.Ht(u),o||(Ie(t,(t=>{if(t.attributes&&t.attributes.POSITION){const e=t.attributes.POSITION;if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return;const r=n(oa);if(t.matrices)for(let e=t.matrices.length-1;e>=0;e--)i(r,r,t.matrices[e]);i(r,a,r);const s=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],f=e[7],u=e[8],l=e[9],E=e[10],_=e[11],A=e[12],h=e[13],T=e[14],R=e[15],y=r*a-n*o,I=r*c-i*o,N=r*f-s*o,U=n*c-i*a,S=n*f-s*a,d=i*f-s*c,m=u*h-l*A,M=u*T-E*A,O=u*R-_*A,F=l*T-E*h,b=l*R-_*h,C=E*R-_*T,p=y*C-I*b+N*F+U*O-S*M+d*m;return p?(p=1/p,t[0]=(a*C-c*b+f*F)*p,t[1]=(i*b-n*C-s*F)*p,t[2]=(h*d-T*S+R*U)*p,t[3]=(E*S-l*d-_*U)*p,t[4]=(c*O-o*C-f*M)*p,t[5]=(r*C-i*O+s*M)*p,t[6]=(T*N-A*d-R*I)*p,t[7]=(u*d-E*N+_*I)*p,t[8]=(o*b-a*O+f*m)*p,t[9]=(n*O-r*b-s*m)*p,t[10]=(A*S-h*N+R*y)*p,t[11]=(l*N-u*S-_*y)*p,t[12]=(a*M-o*F-c*m)*p,t[13]=(r*F-n*M+i*m)*p,t[14]=(h*I-A*U-T*y)*p,t[15]=(u*U-l*I+E*y)*p,t):null}(aa,r),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];Ue(e,(t=>{y(t,t,r),t[0]=t[0]-l[0],t[1]=t[1]-l[1],t[2]=t[2]-l[2],y(t,t,s),t[0]<o[0]&&(o[0]=t[0]),t[1]<o[1]&&(o[1]=t[1]),t[2]<o[2]&&(o[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),e.min=o,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=l)}Ht(t){return 0===U(t)?f([],0,0,-6378137):bt([],t)}onRemove(){}}function fa(t,e,r,n,i){const s=[];for(let o=0,a=t.length;o<a;o+=e){const{xmin:a,ymin:c,xmax:l,ymax:E,hmin:_,hmax:A}=i;f(s,t[o],t[o+1],t[o+2]),y(s,s,n);const h=u(s,r,s);h[0]<a&&(i.xmin=h[0]),h[0]>l&&(i.xmax=h[0]),h[1]<c&&(i.ymin=h[1]),h[1]>E&&(i.ymax=h[1]),e>2&&(h[2]<_&&(i.hmin=h[2]),h[2]>A&&(i.hmax=h[2]))}}function ua(t){const{xmax:e,ymax:r,xmin:n,ymin:i,hmin:s,hmax:o}=t,a=[(n+e)/2,(i+r)/2,(s+o)/2];return e===-1/0&&(a[0]=0),r===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function la(t,e){for(let r=0;r<e.length;r++)t.indexOf(e[r])<0&&t.push(e[r])}let Ea=0;class _a{constructor(t){this.workerId=t,this.workers={},this.xt={}}addLayer({actorId:t,mapId:e,layerId:r,params:n},i){if(this.Vt(e,r))return;const s=this.kt(e,r),o=n.options,a=this.send.bind(this,t);this.workers[s]=new ca(r,o,a,i)}removeLayer({mapId:t,layerId:e},r){const n=this.Vt(t,e),i=this.kt(t,e);delete this.workers[i],n&&n.onRemove(r)}loadTile({mapId:t,layerId:e,params:r},n){const i=this.Vt(t,e);i&&i.loadTile(r,n)}abortTileLoading({mapId:t,layerId:e,params:r},n){const i=this.Vt(t,e);i&&i.abortTileLoading(r,n)}receive(t){const e=t.callback,r=this.xt[e];delete this.xt[e],r&&t.error?r(new Error(t.error)):r&&r(null,t.data)}send(t,e,r,n,i){const s=i?`${t}-${Ea++}`:null;i&&(this.xt[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:r,callback:String(s)},n||[])}kt(t,e){return`${t}-${e}`}Vt(t,e){const r=this.kt(t,e);return this.workers[r]}}t.initialize=function(){},t.onmessage=function(t,e){const r=t.data;this.dispatcher||(this.dispatcher=new _a(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[r.command]({actorId:r.actorId,mapId:r.mapId,layerId:r.layerId,params:r.params},((t,r,n)=>{t instanceof Error&&(t={message:t.message}),e(t,r,n)}))},Object.defineProperty(t,"Zt",{value:!0})}';for(
|
|
7
7
|
/*!
|
|
8
8
|
* Contains code from THREE.js
|
|
9
9
|
* MIT License
|
|
@@ -15,9 +15,9 @@ var a=[],c=0;c<6;c++)a[c]=[];var l=[];function f(t,e,r){h(t);for(var n=0;n<6;n++
|
|
|
15
15
|
* LICENSE : UNLICENSED
|
|
16
16
|
* (c) 2016-2022 maptalks.org
|
|
17
17
|
*/
|
|
18
|
-
let rt=0;function nt(t){return null==t}function it(t){return!nt(t)}function st(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}function ot(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+t)}function at(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function ct(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),r=e.length,n=new Uint8Array(r);for(let t=0;t<r;t++)n[t]=e.charCodeAt(t);return n.buffer}const lt=[],ft=[],ut=[],ht=[0,0,0],_t=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),dt=[1,1,1];function Et(t,e,r,n,i,s,o){const a=ot(o);if((0===i||i===n*a.BYTES_PER_ELEMENT)&&s%a.BYTES_PER_ELEMENT==0){const i=new a(e,s,r*n);return t.set(i),t}0===i&&(i=n*a.BYTES_PER_ELEMENT);const c=new Uint8Array(n*a.BYTES_PER_ELEMENT);for(let o=0;o<r;o++){let r=null;const l=new Uint8Array(e,i*o+s,n*a.BYTES_PER_ELEMENT);c.set(l),r=new a(c.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const Tt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function mt(t,e,r){const n=new Uint8Array(t,e,r);return Tt.decode(n)}const At={get:function(t,e={}){e||(e={});const r=new AbortController,n=r.signal,i=st({},e);i.signal=n,i.method||(i.method="GET");const s=fetch(t,i).then((t=>{const r=this.i(t,e.responseType);return r.message?r:r.then((r=>"arraybuffer"===e.responseType?{data:r,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:r)).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}))})).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}));return s.xhr=r,s},i:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",At.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?At.jsonp(t):((e=e||{}).responseType="json",At.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+rt++;t.match(/\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,new Promise((t=>{window[e]=function(n){document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e],t(n)},document.getElementsByTagName("head")[0].appendChild(r)}))}};class pt{constructor(t,e,r){this.o=t,this.decoders=e,this.l=r,this.images={},this.u={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],i=this.h(e,n);return this.getImageByBuffer(i,r)}if(this.u[t.id])return this.u[t.id].then((()=>{const n=this.buffers[t.id],i=this.h(e,n);return this.getImageByBuffer(i,r)}));if(at(t.uri)){const n=this.buffers[t.id]=ct(t.uri),i=this.h(e,n);return this.getImageByBuffer(i,r)}return this.u[t.id]=At.getArrayBuffer(t.uri,null).then((n=>{const i=this.buffers[t.id]=n.data,s=this.h(e,i);return this.getImageByBuffer(s,r)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const r=this.decoders;if(r[e.mimeType])return r[e.mimeType](t,{supportedFormats:this.l});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const r=new Blob([t],{type:e.mimeType}),n=URL.createObjectURL(r);return this._(e.id,n)}}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.u[t.id]?this.u[t.id].then((()=>this.images[t.id])):this.u[t.id]=this._(t.id,e)}_(t,e){return new Promise(((r,n)=>{this.o(e,((i,s)=>{i?n(i):(URL.revokeObjectURL(e),this.images[t]=s,r(this.images[t]))}))}))}}const yt=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class gt{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.T=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.m()}A(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this.p(t,e,null,0),Promise.resolve(this.accessors[n.id]);if(n&&this.accessors[n.id])return Promise.resolve(this.accessors[n.id]);const i=r.bufferViews[n.bufferView];return this.g(i).then((r=>{const{buffer:i,byteOffset:s}=r;return this.accessors[n.id]=this.p(t,e,i,s)}))}g(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then((()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}));if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(at(e.uri)){const t=this.buffers[e.id]=ct(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=At.getArrayBuffer(t,null).then((n=>(r&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=n.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}p(t,e,r,n=0){const i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+n,c=this.R(s.type),l=ot(s.componentType),f=o.byteStride||0,u={array:void 0,name:t,accessorName:e,byteLength:s.count*c*l.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c};if(s.min&&(u.min=s.min),s.max&&(u.max=s.max),r)if(this.T)u.byteStride=f,u.byteOffset=a+(s.byteOffset||0),!f||f===c*l.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(u.array=this.I(r,s.count,c,a+(s.byteOffset||0),l),u.array.buffer.byteLength===u.byteLength&&(u.byteOffset=0)):u.array=new Uint8Array(r,a,o.byteLength);else if(s.interleaved){u.byteStride=0,u.byteOffset=0;const t=new l(s.count*c);u.array=Et(t,r,s.count,c,f,a+(s.byteOffset||0),s.componentType)}else u.byteStride=0,u.array=this.I(r,s.count,c,a+(s.byteOffset||0),l),u.byteOffset=u.array.byteOffset;else{u.array=new l(s.count);const t=u.min||u.max;t&&(u.array[0]=t[0],u.array[1]=t[1],u.array[2]=t[2])}return u}m(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let r=0;r<t.length;r++)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0);else for(const e in t)for(const r in t)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0)}I(t,e,r,n,i){return n%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(n,n+e*r*i.BYTES_PER_ELEMENT),n=0),new i(t,n,r*e)}R(t){const e=yt.indexOf(t);return yt[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,r=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:r}=e;return this.g(e).then((n=>{const{buffer:i,byteOffset:s}=n,o=mt(i,s+(e.byteOffset||0),r);return t.content=o,t}))}if(t.uri){if(at(t.uri)){const e=ct(t.uri),r=mt(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return At.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class Rt extends pt{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=r,this.accessor=new gt(t,e,r)}iterate(t,e){const r=this.gltf[e];if(!r)return;let n=0;for(const e in r)t(e,r[e],n++)}createNode(t){const e={};if(it(t.name)&&(e.name=t.name),it(t.children)&&(e.children=t.children),it(t.jointName)&&(e.jointName=t.jointName),it(t.matrix)&&(e.matrix=t.matrix),it(t.rotation)&&(e.rotation=t.rotation),it(t.scale)&&(e.scale=t.scale),it(t.translation)&&(e.translation=t.translation),it(t.extras)&&(e.extras=t.extras),it(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const r=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(lt,e.translation||ht),n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,c=i+i,l=r*o,f=n*o,u=n*a,h=i*o,_=i*a,d=i*c,E=s*o,T=s*a,m=s*c;return t[0]=1-u-d,t[1]=f+m,t[2]=h-T,t[3]=0,t[4]=f-m,t[5]=1-l-d,t[6]=_+E,t[7]=0,t[8]=h+T,t[9]=_-E,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ft,e.rotation||_t),i=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ut,e.scale||dt);return P(i,n,i),P(t,r,i)}return B(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}N(t){const e={};for(const r in t){const n=t[r];let i,s;n.instanceTechnique&&n.instanceTechnique.values?(i=n.instanceTechnique,s=i.values.diffuse):(i=n,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={baseColorTexture:{index:s}};n.name&&(o.name=n.name),n.extensions&&(o.extensions=n.extensions),n.extras&&(o.extras=n.extras),e[r]=o}return e}S(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const r=this.gltf.bufferViews[e.bufferView],n=(r.byteOffset||0)+this.glbBuffer.byteOffset,i=r.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,n,i);return this.getImageByBuffer(s,t)}return this.requestExternalImage(t)}M(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.S(r).then((t=>{const n=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extras:r.extras},sampler:n}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let r,n;if(e.instanceTechnique&&e.instanceTechnique.values?(r=e.instanceTechnique,n=r.values.diffuse):(r=e,n=r.values.tex||r.values.diffuseTex||r.values.diffuse),void 0===n||void 0===this.gltf.textures)return null;const i=this.gltf.textures[n];if(!i)return null;const s=this.gltf.samplers[i.sampler];return{format:i.format||6408,internalFormat:i.internalFormat||6408,type:i.type||5121,sampler:s,source:this.gltf.images[i.source]}}getMaterial(){return null}getAnimations(){return null}}class bt extends pt{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.glbBuffer=r,this.buffers={},this.requests={},this.accessor=new gt(t,e,r)}iterate(t,e){const r=this.gltf[e];if(r)for(let e=0;e<r.length;e++)t(e,r[e],e)}createNode(t){const e={};return st(e,t),!it(t.weights)&&this.gltf.meshes&&it(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}M(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.S(r).then((t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};st(n,e);const i=it(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),t.format&&(n.format=t.format),n}))}S(t){if(!it(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],r=this.gltf.buffers[e.buffer];if(r.uri)return this.requestImageFromBufferURI(r,e,t);if(this.glbBuffer)return this.O(e,t)}return null}O(t,e){const r=this.h(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}h(t,e,r){r=r||0;const n=t.byteOffset+r,i=t.byteLength;return new Uint8Array(e,n,i)}v(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);return r.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)))}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let r=0;r<e.length;r++)t[r].samplers=e[r];return t}))}getSamplers(t){const e=[];for(let r=0;r<t.length;r++)(it(t[r].input)||it(t[r].output))&&(e.push(this.accessor.A("input",t[r].input)),e.push(this.accessor.A("output",t[r].output)));return Promise.all(e).then((e=>{for(let r=0;r<e.length/2;r++)t[r].input=e[2*r],t[r].output=e[2*r+1],t[r].interpolation||(t[r].interpolation="LINEAR");return t}))}}const It="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class Nt{static read(t,e=0,r=0){r||(r=t.byteLength);const n=new DataView(t,e,r),i=n.getUint32(4,!0);if(1===i)return Nt.readV1(n,e);if(2===i)return Nt.readV2(t,e);throw new Error("Unsupported glb version : "+i)}static readV1(t,e){const r=t.getUint32(8,!0),n=t.getUint32(12,!0);if(r!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const i=St(t.buffer,20+e,n);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+n,buffer:t.buffer,byteLength:r}}}static readV2(t,e){let r,n,i;const s=new DataView(t,e+12);let o=0;for(;o<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,1313821514===c)r=St(t,e+12+o,a);else if(5130562===c){i=e+12+o,n=a;break}o+=a}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function St(t,e,r){if(It){const n=new Uint8Array(t,e,r);return It.decode(n)}return function(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=wt[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}(new Uint8Array(t,e,r))}const wt=[1,1,1,1,2,2,3,0],Mt=[0,0,0],Ot=[0,0,0,1],vt=[1,1,1],Ct={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},xt={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Ut={C(t,e,r,n,i,s,o,a){const c=it(t)?e.animations:[e.animations[0]],l={};for(let e=0;e<c.length;e++){const f=c[e],u=f.name||e;if(it(t)&&u!==t)continue;const h=f.channelsMap[r];if(h)for(let t=0;t<h.length;t++){const e=h[t];"translation"===e.target.path?(this.U(i,f.samplers[e.sampler],n,1),l.translation=G(Mt,i)):"rotation"===e.target.path?(this.B(s,f.samplers[e.sampler],n,1),l.rotation=et(Ot,s)):"scale"===e.target.path?(this.U(o,f.samplers[e.sampler],n,1),l.scale=G(vt,o)):"weights"===e.target.path&&a&&(this.U(a,f.samplers[e.sampler],n,a.length),l.weights=a)}}return l},U(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.P(xt,e,r,1*n);i&&(t=function(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e[i]+n*(r[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.P(xt,e,r,1*n);i&&(t=function(t,e){for(let r=0;r<t.length;r++)t[r]=e[r];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.P(xt,e,r,3*n);i&&(t=this.L(t,i,e.input.array,3*n));break}}return t},B(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.P(xt,e,r,1);n&&Q(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.P(xt,e,r,1);n&&(t=$(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.P(xt,e,r,3);if(n){for(let t=0;t<n.PREVIOUS.length;t++)n.PREVIOUS[t]=Math.acos(n.PREVIOUS[t]),n.NEXT[t]=Math.acos(n.NEXT[t]);t=this.L(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},D(t,e){const r=t.length;let n,i,s,o=0,a=r-1,c=Math.floor((o+a)/2);for(;o<=r-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const r=t[c];return n=c,i=c+1,s=(e-r)/(t[c+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},P(t,e,r,n){const i=e.input.array,s=e.output.array,o=e.output.itemSize;(r<i[0]||r>i[i.length-1])&&(r=Math.max(i[0],Math.min(i[i.length-1],r))),r===i[i.length-1]&&(r=i[0]);const a=this.D(i,r);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:l,interpolation:f}=a;t.PREINDEX=c,t.NEXTINDEX=l,t.INTERPOLATION=f;const u=o*n;return t.PREVIOUS=s.subarray(t.PREINDEX*u,(t.PREINDEX+1)*u),t.NEXT=s.subarray(t.NEXTINDEX*u,(t.NEXTINDEX+1)*u),t},L(t,e,r,n){const i=e.INTERPOLATION,s=r[e.PREINDEX],o=r[e.NEXTINDEX];for(let r=0;r<3;r++){const a=e.PREVIOUS[n+r],c=(o-s)*e.PREVIOUS[2*n+r],l=e.NEXT[3+r],f=(o-s)*e.NEXT[r],u=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(2*-Math.pow(i,3)+3*Math.pow(i,2))*l+(Math.pow(i,3)-Math.pow(i,2))*f;t[r]=u}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;return k(Mt,...Ct.TRANSLATION),$(Ot,...Ct.ROTATION),k(vt,...Ct.SCALE),this.C(n,t,e,r,Mt,Ot,vt,i)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,r)=>{let n=-1/0,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const r=s[t],o=e.samplers[r.sampler].input.array;o[o.length-1]>n&&(n=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||r;t.timeSpan[o]={max:n,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const r=this.getTimeSpan(t);return r?it(e)?r[e]:r[Object.keys(r)[0]]:null}};let Bt=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(wr){}t&&"undefined"!=typeof createImageBitmap&&(Bt=!0)}const Pt="undefined"==typeof document?null:document.createElement("canvas");class Lt{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=Nt.read(e.buffer,e.byteOffset,e.byteLength);this.F(t,r,n)}else this.F(t,e);this.G=new gt(this.rootPath,this.gltf,this.glbBuffer),this.k()}k(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}H(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.G.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.V(t),r=this.Y(),n=this.X(),i=this.H();return Promise.all([e,r,n,i]).then((t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0])))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const r=e[t];r.channelsMap={};for(let t=0;t<r.channels.length;t++){const e=r.channels[t];r.channelsMap[e.target.node]||(r.channelsMap[e.target.node]=[]),r.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:r}=this.gltf;for(let r=0;r<e.length;r++)e[r].uri&&e[r].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[r].uri});for(let e=0;e<r.length;e++)r[e].uri&&r[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:r[e].uri})}return t}static getAnimationClip(t,e,r,n){return Ut.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return Ut.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return ot(t)}static readInterleavedArray(t,e,r,n,i,s,o){return Et(t,e,r,n,i,s,o)}F(t,e,r){this.gltf=e,this.glbBuffer=r,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=Bt?kt.bind(this):this.options.requestImage||Dt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new bt(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="buffer_"+r}),"buffers"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors")):(this.adapter=new Rt(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"))}Z(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(r=t.children[0])&&isFinite(r)||function(t){return!nt(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const n=t.children.map((t=>{const r=e[t];return r.nodeIndex=t,this.Z(r,e)}));t.children=n}var r;return t}V(t){return this.W(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.Z(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((n,i,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===n&&(r=s),e.push(o)}),"scenes");const n={asset:this.gltf.asset,scene:r,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(n.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.N(this.gltf.materials);n.materials=t}return n}))}W(t){return this.j(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,r)=>{const n=this.adapter.createNode(r,this.meshes,this.skins);t[e]=n}),"nodes"),t}))}K(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.q(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}q(t){const e=t.inverseBindMatrices;return this.adapter.accessor.A("inverseBindMatrices",e).then((e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t)))}Y(){const t=this.gltf.animations;return it(t)?this.adapter.getAnimations(t):null}j(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,i)=>{e.push(this.$(n,t).then((t=>{t.index=i,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.K()),Promise.all(e)}$(t,e){const r=t.primitives.map((t=>this.J(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return st(r,t),r.primitives=e,r}))}X(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.M(r));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const r=e[t].image.array;if(e[t]&&r){let t;t=r instanceof ImageBitmap?r:r.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const r={},n=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(r[n[t]]=e[t]);return r}return e}))}J(t,e){let r;const n=[],i=t.extensions;if(it(t.targets))for(let e=0;e<t.targets.length;e++){const r=t.targets[e];for(const t in r){const i=this.adapter.accessor.A(`morphTargets_${t}_${e}`,r[t]);i&&n.push(i)}}if(i&&i.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:s,attributes:o}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[s],c=this.G.g(a).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:c}=a;s||(s=0);const l=new DataView(n,i+s,c),f={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(l,f).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(c),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor.A(t,e[t]);r&&n.push(r)}if(it(t.indices)){const e=this.adapter.accessor.A("indices",t.indices);e&&n.push(e)}r=Promise.all(n)}return r.then((e=>{if(i&&i.KHR_draco_mesh_compression){const r=t.targets?t.targets.length:0;e[r]=e[r].concat(e.slice(0,r)),e=e[r]}let r,n;const s={attributes:e.reduce(((t,e)=>{if("indices"===e.name)r=e;else if(e.name.indexOf("morphTargets_")>-1)n=n||{},n[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0],{itemSize:n,array:i}=e,s=i.length/n;for(let e=0;e<s;e++)for(let s=0;s<n;s++){const o=e*n+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>r[s]&&(r[s]=i[o])}if(e.quantization){const n=e.quantization,i=n.range/(1<<n.quantizationBits),s=n.minValues;Y(t,t,i),H(t,t,s),Y(r,r,i),H(r,r,s)}e.min=t,e.max=r}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t}),{}),material:t.material};return r&&(s.indices=r),n&&(s.morphTargets=n),s.mode=it(t.mode)?t.mode:4,it(t.extras)&&(s.extras=t.extras),s}))}}function Dt(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Pt)return void e(new Error("There is no canvas to draw image!"));Pt.width=r.width,Pt.height=r.height;const t=Pt.getContext("2d");t.drawImage(r,0,0,r.width,r.height);const n=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(n.data)};e(null,i)},r.onerror=function(t){e(t)},r.src=t}let Ft,Gt;function kt(t,e){Ft||(Ft=new OffscreenCanvas(2,2),Gt=Ft.getContext("2d")),fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{let{width:r,height:n}=t;Ht(r)||(r=Vt(r)),Ht(n)||(n=Vt(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r),n=Math.min(i,n)),Ft.width=r,Ft.height=n,Gt.drawImage(t,0,0,r,n),t.close();const s=Gt.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function Ht(t){return 0==(t&t-1)&&0!==t}function Vt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const zt="undefined"==typeof document?null:document.createElement("canvas");class Yt extends i.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,r){let n=null;e&&e.arraybuffer&&(n=[e.arraybuffer]);const i={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(i,n,r)}abortTileLoading(t,e,r){const n={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(n,null,r)}addLayer(t,e,r){const n={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(n,null,r)}removeLayer(t,e){const r={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(r,null,e)}requestImage({url:t},e){const r=new Image;r.onload=()=>{if(!this.isActive())return;if(!zt)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(Xt(t.width)&&Xt(t.height))return t;let e=t.width,r=t.height;Xt(e)||(e=Zt(e));Xt(r)||(r=Zt(r));const n=document.createElement("canvas");n.width=e,n.height=r,n.getContext("2d").drawImage(t,0,0,e,r);const i=t.src,s=i.lastIndexOf("/")+1,o=i.substring(s);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${r})`),n}(r);zt.width=t.width,zt.height=t.height;const n=zt.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,s,[s.data.buffer])},r.onerror=function(t){e(t)},r.src=t}}function Xt(t){return 0==(t&t-1)&&0!==t}function Zt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}class Wt{constructor(t,e){this.max=t,this.currentSize=0,this.onRemove=e,this.reset()}reset(){if(this.data){const t=this.data.values();for(const e of t)this.onRemove(e)}return this.data=new Map,this.currentSize=0,this}clear(){this.reset(),delete this.onRemove}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const r=this.data.get(t);r&&r.node&&r.node.memorySize&&(this.currentSize-=r.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){const t=this.data.keys();let e=t.next();for(;this.currentSize>this.max&&void 0!==e.value;){if(!this.data.get(e.value).current){const t=this.getAndRemove(e.value);t&&this.onRemove(t)}e=t.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const r=this.data.keys();for(let n of r)t[e++]=n;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e),this}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const r of e){const e=r&&r.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t){const e=this.data.values();for(const r of e)r.current=t}}function jt(t,e){if(t.scenes&&t.scenes.length)for(let r=0,n=t.scenes.length;r<n;r++){const n=t.scenes[r].nodes;for(let r=0,i=n.length;r<i;r++){const i=[];Kt(n[r],i,t,e)}}}function Kt(t,e,r,n){if(t.matrix&&e.push(t.matrix),t.children&&t.children.length)for(let i=0,s=t.children.length;i<s;i++)Kt(t.children[i],e,r,n);if(void 0!==t.mesh){const i=t.mesh,s=r.meshes[i];if(s){const t=e.slice(0),o=s.primitives;for(let e=0,s=o.length;e<s;e++){const s=o[e];s&&(s.matrices=t,n(s,i,e,r))}}}}function qt(t,e,r){let{componentType:n,byteOffset:i,byteStride:s,itemSize:o}=e;const a=e.array.buffer,c=n?Lt.getTypedArrayCtor(n):e.array.constructor;if(i=void 0===i?e.array.byteOffset:i,s=s||0,!s||s===o*c.BYTES_PER_ELEMENT&&i%c.BYTES_PER_ELEMENT==0){const e=new c(a,i+r*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*c.BYTES_PER_ELEMENT);const l=new Uint8Array(a,s*r+i,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(l),t}function $t(t,e,r,n){t[4*e]=r[n],t[4*e+1]=r[n+4],t[4*e+2]=r[n+8],t[4*e+3]=r[n+12]}const Jt=new Array(3),Qt=new Array(3),te=[40680631590769,40680631590769,40408299984661.445];function ee(t,e,r,n){const i=te,s=Math.cos(r);Jt[0]=s*Math.cos(e),Jt[1]=s*Math.sin(e),Jt[2]=Math.sin(r),ue(Jt,Jt),z(Qt,i,Jt);const o=Math.sqrt(Z(Jt,Qt));var a,c,l;return c=Qt,l=o,(a=Qt)[0]=c[0]/l,a[1]=c[1]/l,a[2]=c[2]/l,Y(Jt,Jt,n),H(t,Qt,Jt)}const re=[1/6378137,1/6378137,1/6356752.314245179],ne=[1/40680631590769,1/40680631590769,1/40408299984661.445],ie=new Array(3),se=new Array(3),oe=new Array(3);function ae(t,e){const r=ne,n=function(t,e,r,n,i){const s=e[0],o=e[1],a=e[2],c=r[0],l=r[1],f=r[2],u=s*s*c*c,h=o*o*l*l,_=a*a*f*f,d=u+h+_,E=Math.sqrt(1/d),T=Y(ce,e,E);if(d<i)return isFinite(E)?T:void 0;const m=n[0],A=n[1],p=n[2],y=le;y[0]=T[0]*m*2,y[1]=T[1]*A*2,y[2]=T[2]*p*2;let g,R,b,I,N,S,w,M,O,v,C,x=(1-E)*fe(e)/(.5*fe(y)),U=0;do{x-=U,b=1/(1+x*m),I=1/(1+x*A),N=1/(1+x*p),S=b*b,w=I*I,M=N*N,O=S*b,v=w*I,C=M*N,g=u*S+h*w+_*M-1,R=u*O*m+h*v*A+_*C*p;U=g/(-2*R)}while(Math.abs(g)>1e-12);return t[0]=s*b,t[1]=o*I,t[2]=a*N,t}(ie,e,re,r,.1);let i=K(se,n,r);i=ue(i,i);const s=j(oe,e,n),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=R(Z(s,e))*fe(s);return t[0]=y(o),t[1]=y(a),t[2]=c,t}const ce=new Array(3),le=new Array(3);function fe(t){return D(t)}function ue(t,e){const r=e[0],n=e[1],i=e[2];let s=r*r+n*n+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function he(t,e){return z(e,t,ne),X(e,e)}function _e(t,e){var r=t[0],n=t[1],i=Math.cos(n),s=i*Math.cos(r),o=i*Math.sin(r),a=Math.sin(n);return e.x=s,e.y=o,e.z=a,X(e,e)}var de=Object.freeze({__proto__:null,radianToCartesian3:ee,cartesian3ToDegree:ae,normalizeCartesian:ue,geodeticSurfaceNormal:he,geodeticSurfaceNormalCartographic:_e});function Ee(t,e,r,n){r=r||0,n=n||r;var i=Math.abs(t-e);return i<=n||i<=r*Math.max(Math.abs(t),Math.abs(e))}function Te(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const me="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ae(t,e,r){const n=new Uint8Array(t,e,r);return me?JSON.parse(me.decode(n)):JSON.parse(I(n))}function pe(t,e,r){const n=new Uint8Array(t,e,r);return me?JSON.parse(me.decode(n)):JSON.parse(I(n))}function ye(t,e,r){return{offset:e,byteLength:r}}function ge(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=function(t){return Ie[t]}(s),l=function(t){if(!t)return 1;return be[t]}(o);return{byteStride:0,byteOffset:i+r,itemSize:l,count:n*l,componentType:c,array:new a(e,r+i,n*l)}}function Re(t,e,r,n){t.componentType||(t.componentType="UNSIGNED_SHORT");const i=ge(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const be={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Ie={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function Ne(t){for(let e in Ie)if(t===Ie[e].ctor)return Ie[e].type;throw new Error("unrecognized ctor:"+t)}function Se(t,e,r,n){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*n[0]+r[0],i[3*t+1]=e[3*t+1]/65535*n[1]+r[1],i[3*t+2]=e[3*t+2]/65535*n[2]+r[2];return i}function we(t,e,r){let n=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0);const a=t.buffer;let c,l,f={},u={};n>0&&(f=Ae(a,e,n),e+=n),i>0&&(c=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(u=pe(a,e,s),e+=s);const h=ye(0,e,o);return l=a.slice(h.offset,h.offset+h.byteLength),r.push(l),{featureTable:f,featureTableBin:c,batchTable:u,batchTableBin:l}}var Me={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Oe={},ve={east:[],north:[],up:[],west:[],south:[],down:[]},Ce=[],xe=[],Ue=[];const Be=[0,0,0];function Pe(t,e,r){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=e[0],r[13]=e[1],r[14]=e[2],r[15]=t[15],r}const Le=(ke={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}}[De="east"][Fe="north"],Oe[He=De+Fe]?Ge=Oe[He]:(Ge=function(t,e,r){if(function(t,e){var r=t[0],n=t[1],i=t[2],s=e[0],o=e[1],a=e[2];return Math.abs(r-s)<=x*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-o)<=x*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=x*Math.max(1,Math.abs(i),Math.abs(a))}(t,Be))G(Ce,Me[De]),G(xe,Me[Fe]),G(Ue,Me[ke]);else if(Ee(t[0],0,1e-14)&&Ee(t[1],0,1e-14)){var n=R(t[2]);G(Ce,Me[De]),"east"!==De&&"west"!==De&&Y(Ce,Ce,n),G(xe,Me[Fe]),"east"!==Fe&&"west"!==Fe&&Y(xe,xe,n),G(Ue,Me[ke]),"east"!==ke&&"west"!==ke&&Y(Ue,Ue,n)}else{he(t,ve.up);var i=ve.up,s=ve.east;s[0]=-t[1],s[1]=t[0],s[2]=0,X(ve.east,s),W(ve.north,i,s),Y(ve.down,ve.up,-1),Y(ve.west,ve.east,-1),Y(ve.south,ve.north,-1),Ce=ve[De],xe=ve[Fe],Ue=ve[ke]}return r[0]=Ce[0],r[1]=Ce[1],r[2]=Ce[2],r[3]=0,r[4]=xe[0],r[5]=xe[1],r[6]=xe[2],r[7]=0,r[8]=Ue[0],r[9]=Ue[1],r[10]=Ue[2],r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r},Oe[He]=Ge),Ge);var De,Fe,Ge,ke,He;const Ve=[],ze=[],Ye=[],Xe=[],Ze=[],We=[],je=[],Ke={x:0,y:0},qe={x:0,y:0},$e=Math.PI/180;const Je={"programs":[{"attributes":["aPosition","instanceId","batchId","aTexCoord0","aTexCoord1","aNormal","aColor","uv2","uv3","uv4","secondary_colour","uv6"],"fragmentShader":1,"vertexShader":0}],"shaders":[{"type":35633,"content":"#include <gl2_vert>\n\nuniform mat4 czm_modelViewProjection;\n\nuniform mat4 czm_modelView;\n\nuniform mat3 czm_normal;\n\n\n\nattribute vec4 aPosition;\n\n\n\n#ifdef VertexColor\n\n attribute vec4 aColor;\n\n#endif\n\n#ifdef VertexNormal\n\n attribute vec3 aNormal;\n\n#endif\n\n#ifdef Instance\n\n attribute float instanceId;\n\n#else\n\n attribute float batchId;\n\n#endif\n\n\n\n#ifdef TexCoord\n\n attribute vec4 aTexCoord0;\n\n varying vec4 vTexCoord;\n\n uniform mat4 uTexMatrix;\n\n#ifdef COMPUTE_TEXCOORD\n\n uniform float uTexture0Width;\n\n varying vec4 vTexMatrix;\n\n varying vec4 vTexCoordTransform;\n\n varying vec2 vIsRGBA;\n\n#endif\n\n#endif\n\n\n\n#ifdef TexCoord2\n\n attribute vec4 aTexCoord1;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef InstanceBim\n\n attribute vec4 uv2;\n\n attribute vec4 uv3;\n\n attribute vec4 uv4;\n\n attribute vec4 secondary_colour;\n\n attribute vec4 uv6;\n\n#endif\n\n\n\n uniform vec4 uFillForeColor;\n\n uniform vec4 uSelectedColor;\n\n varying vec4 vSecondColor;\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n varying vec4 vColor;\n\n\n\n const float SHIFT_LEFT8 = 256.0;\n\n const float SHIFT_RIGHT8 = 1.0 / 256.0;\n\n const float SHIFT_RIGHT4 = 1.0 / 16.0;\n\n const float SHIFT_LEFT4 = 16.0;\n\n void getTextureMatrixFromZValue(in float nZ, inout float XTran, inout float YTran, inout float scale, inout float isRGBA)\n\n {\n\n if(nZ <= 0.0)\n\n {\n\n return;\n\n }\n\n float nDel8 = floor(nZ * SHIFT_RIGHT8);\n\n float nDel16 = floor(nDel8 * SHIFT_RIGHT8);\n\n float nDel20 = floor(nDel16 * SHIFT_RIGHT4);\n\n isRGBA = floor(nDel20);\n\n YTran = nZ - nDel8 * SHIFT_LEFT8;\n\n XTran = nDel8 - nDel16 * SHIFT_LEFT8;\n\n float nLevel = nDel16 - nDel20 * SHIFT_LEFT4;\n\n scale = 1.0 / pow(2.0, nLevel);\n\n }\n\n\n\n void operation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor)\n\n {\n\n float right_2 = operationType.x * 0.5;\n\n float right_4 = right_2 * 0.5;\n\n float right_8 = right_4 * 0.5;\n\n float right_16 = right_8 * 0.5;\n\n float isSetColor = fract(right_2);\n\n if(isSetColor > 0.1)\n\n {\n\n vertexColor *= color;\n\n }\n\n float isPicked = fract(floor(right_2)* 0.5);\n\n if(isPicked > 0.1)\n\n {\n\n vertexColor *= selectedColor;\n\n }\n\n float isHide = fract(floor(right_4)* 0.5);\n\n if(isHide > 0.1)\n\n {\n\n vertexColor.a = 0.0;\n\n }\n\n }\n\n\n\n void main()\n\n {\n\n #ifdef TexCoord\n\n vTexCoord.xy = aTexCoord0.xy;\n\n #ifdef COMPUTE_TEXCOORD\n\n vTexMatrix = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.x = 0.0;\n\n vTexCoordTransform.x = aTexCoord0.z;\n\n if(vTexCoordTransform.x < -90000.0)\n\n {\n\n vTexMatrix.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.x), vTexMatrix.x, vTexMatrix.y, vTexMatrix.z, vIsRGBA.x);\n\n vTexMatrix.w = log2(uTexture0Width * vTexMatrix.z);\n\n #endif\n\n #endif\n\n\n\n #ifdef TexCoord2\n\n vTexCoord.zw = aTexCoord1.xy;\n\n vTexMatrix2 = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.y = 0.0;\n\n vTexCoordTransform.y = aTexCoord1.z;\n\n if(vTexCoordTransform.y < -90000.0)\n\n {\n\n vTexMatrix2.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.y), vTexMatrix2.x, vTexMatrix2.y, vTexMatrix2.z, vIsRGBA.y);\n\n vTexMatrix2.w = log2(uTexture1Width * vTexMatrix.z);\n\n #endif\n\n\n\n vec4 vertexPos = aPosition;\n\n vec4 vertexColor = uFillForeColor;\n\n#ifdef VertexColor\n\n vertexColor *= aColor / 255.0;\n\n#endif\n\n#ifdef VertexNormal\n\n vec3 normal = aNormal;\n\n#endif\n\n #ifdef InstanceBim\n\n mat4 worldMatrix;\n\n worldMatrix[0] = uv2;\n\n worldMatrix[1] = uv3;\n\n worldMatrix[2] = uv4;\n\n worldMatrix[3] = vec4(0, 0, 0, 1);\n\n vertexPos = vec4(vertexPos.xyz,1.0) * worldMatrix;\n\n vertexColor *= secondary_colour;\n\n #endif\n\n\n\n\n\n #ifdef Instance\n\n float index = instanceId;\n\n #else\n\n float index = batchId;\n\n #endif\n\n vec4 positionMC = vec4(vertexPos.xyz, 1.0);\n\n vColor = vertexColor;\n\n #ifdef VertexNormal\n\n vNormalEC = czm_normal * normal;\n\n #endif\n\n vPositionMC = positionMC;\n\n vPositionEC = (czm_modelView * positionMC).xyz;\n\n gl_Position = czm_modelViewProjection * vec4(vertexPos.xyz, 1.0);\n\n }\n\n"},{"type":35632,"content":"#ifdef GL_OES_standard_derivatives\n\n #extension GL_OES_standard_derivatives : enable\n\n #define support_standard_derivatives 1\n\n#endif\n\n#ifdef GL_EXT_shader_texture_lod\n\n #extension GL_EXT_shader_texture_lod : enable\n\n #define support_shader_texture_lod 1\n\n#endif\n\n\n\nprecision highp float;\n\n\n\n#include <gl2_frag>\n\n\n\n#if __VERSION__ == 300\n\n #define support_standard_derivatives 1\n\n #define support_shader_texture_lod 1\n\n#endif\n\n\n\n uniform vec3 czm_lightDirectionEC;\n\n uniform vec4 uDiffuseColor;\n\n#ifdef TexCoord\n\n varying vec4 vTexCoord;\n\n#ifdef COMPUTE_TEXCOORD\n\n uniform sampler2D uTexture;\n\n uniform highp float uTexture0Width;\n\n varying vec4 vTexCoordTransform;\n\n varying vec4 vTexMatrix;\n\n varying vec2 vIsRGBA;\n\n#endif\n\n#endif\n\n\n\n varying vec4 vColor;\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n#ifdef TexCoord2\n\n uniform sampler2D uTexture2;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef COMPUTE_TEXCOORD\n\n void calculateMipLevel(in vec2 inTexCoord, in float vecTile, in float fMaxMip, inout float mipLevel)\n\n {\n\n vec2 dx = dFdx(inTexCoord * vecTile);\n\n vec2 dy = dFdy(inTexCoord * vecTile);\n\n float dotX = dot(dx, dx);\n\n float dotY = dot(dy, dy);\n\n float dMax = max(dotX, dotY);\n\n float dMin = min(dotX, dotY);\n\n float offset = (dMax - dMin) / (dMax + dMin);\n\n offset = clamp(offset, 0.0, 1.0);\n\n float d = dMax * (1.0 - offset) + dMin * offset;\n\n mipLevel = 0.5 * log2(d);\n\n mipLevel = clamp(mipLevel, 0.0, fMaxMip - 1.62);\n\n }\n\n\n\n void calculateTexCoord(in vec3 inTexCoord, in float scale, in float XTran, in float YTran, in float fTile, in float mipLevel, inout vec2 outTexCoord)\n\n {\n\n if(inTexCoord.z < -9000.0)\n\n {\n\n outTexCoord = inTexCoord.xy;\n\n }\n\n else\n\n {\n\n vec2 fTexCoord = fract(inTexCoord.xy);\n\n float offset = 1.0 * pow(2.0, mipLevel) / fTile;\n\n fTexCoord = clamp(fTexCoord, offset, 1.0 - offset);\n\n outTexCoord.x = (fTexCoord.x + XTran) * scale;\n\n outTexCoord.y = (fTexCoord.y + YTran) * scale;\n\n }\n\n }\n\n\n\n vec4 getTexColorForS3M(sampler2D curTexture, vec3 oriTexCoord, float texTileWidth, float fMaxMipLev, float fTexCoordScale, vec2 vecTexCoordTranslate, float isRGBA)\n\n {\n\n vec4 color = vec4(1.0);\n\n float mipLevel = 0.0;\n\n #ifdef support_standard_derivatives\n\n calculateMipLevel(oriTexCoord.xy, texTileWidth, fMaxMipLev, mipLevel);\n\n #endif\n\n vec2 realTexCoord;\n\n calculateTexCoord(oriTexCoord, fTexCoordScale, vecTexCoordTranslate.x, vecTexCoordTranslate.y, texTileWidth, mipLevel, realTexCoord);\n\n if(isRGBA > 0.5)\n\n {\n\n vec2 rgbTexCoord;\n\n rgbTexCoord.x = (realTexCoord.x + vecTexCoordTranslate.x * fTexCoordScale) * 0.5;\n\n rgbTexCoord.y = (realTexCoord.y + vecTexCoordTranslate.y * fTexCoordScale) * 0.5;\n\n color = texture2D(curTexture, rgbTexCoord.xy, -10.0);\n\n vec2 vecAlphaTexCoord;\n\n vecAlphaTexCoord.x = rgbTexCoord.x;\n\n vecAlphaTexCoord.y = rgbTexCoord.y + fTexCoordScale * 0.5;\n\n color.a = texture2D(curTexture, vecAlphaTexCoord.xy, -10.0).r;\n\n }\n\n else\n\n {\n\n if(oriTexCoord.z < -9000.0)\n\n {\n\n color = texture2D(curTexture, realTexCoord.xy);\n\n }\n\n else\n\n {\n\n #ifdef support_shader_texture_lod\n\n color = texture2DLodEXT(curTexture, realTexCoord.xy, mipLevel);\n\n #else\n\n color = texture2D(curTexture, realTexCoord.xy, mipLevel);\n\n #endif\n\n }\n\n }\n\n\n\n return color;\n\n }\n\n\n\n vec4 getTextureColor()\n\n {\n\n if(vTexMatrix.z < 0.0)\n\n {\n\n return vec4(1.0);\n\n }\n\n float texTileWidth0 = vTexMatrix.z * uTexture0Width;\n\n vec3 realTexCoord = vec3(vTexCoord.xy, vTexCoordTransform.x);\n\n vec4 FColor = getTexColorForS3M(uTexture, realTexCoord, texTileWidth0, vTexMatrix.w, vTexMatrix.z, vTexMatrix.xy, vIsRGBA.x);\n\n #ifdef TexCoord2\n\n float texTileWidth1 = vTexMatrix2.z * uTexture1Width;\n\n realTexCoord = vec3(vTexCoord.zw, vTexCoordTransform.y);\n\n vec4 SColor = getTexColorForS3M(uTexture2, realTexCoord, texTileWidth1, vTexMatrix2.w, vTexMatrix2.z, vTexMatrix2.xy, vIsRGBA.y);\n\n SColor.r = clamp(SColor.r, 0.0, 1.0);\n\n SColor.g = clamp(SColor.g, 0.0, 1.0);\n\n SColor.b = clamp(SColor.b, 0.0, 1.0);\n\n return FColor * SColor;\n\n #else\n\n return FColor;\n\n #endif\n\n }\n\n#endif\n\n vec4 SRGBtoLINEAR4(vec4 srgbIn)\n\n {\n\n #ifndef HDR\n\n vec3 linearOut = pow(srgbIn.rgb, vec3(2.2));\n\n return vec4(linearOut, srgbIn.a);\n\n #else\n\n return srgbIn;\n\n #endif\n\n }\n\n vec3 LINEARtoSRGB(vec3 linearIn)\n\n {\n\n #ifndef HDR\n\n return pow(linearIn, vec3(1.0/2.2));\n\n #else\n\n return linearIn;\n\n #endif\n\n }\n\n\n\n vec3 computeNormal(in vec3 oriVertex)\n\n {\n\n vec3 normal = cross(vec3(dFdx(oriVertex.x), dFdx(oriVertex.y), dFdx(oriVertex.z)), vec3(dFdy(oriVertex.x), dFdy(oriVertex.y), dFdy(oriVertex.z)));\n\n normal = normalize(normal);\n\n return normal;\n\n }\n\n\n\n void main()\n\n {\n\n if(vColor.a < 0.1)\n\n {\n\n discard;\n\n }\n\n vec4 baseColorWithAlpha = vColor;\n\n #ifdef COMPUTE_TEXCOORD\n\n baseColorWithAlpha *= SRGBtoLINEAR4(getTextureColor());\n\n #endif\n\n\n\n if(baseColorWithAlpha.a < 0.1)\n\n {\n\n discard;\n\n }\n\n vec3 normal = vec3(0.0);\n\n #ifdef VertexNormal\n\n normal = normalize(vNormalEC);\n\n #endif\n\n normal = length(normal) > 0.1 ? normal : computeNormal(vPositionMC.xyz);\n\n vec3 color = baseColorWithAlpha.rgb;\n\n vec3 dirVectorEC = normalize(czm_lightDirectionEC);\n\n float dotProduct = dot( normal, dirVectorEC );\n\n float dirDiffuseWeight = max( dotProduct, 0.0 );\n\n dirDiffuseWeight = dirDiffuseWeight * 0.5 + 0.5;\n\n color += color * uDiffuseColor.rgb * dirDiffuseWeight;\n\n #ifdef TexCoord\n\n color = LINEARtoSRGB(color);\n\n #endif\n\n glFragColor = vec4(color, baseColorWithAlpha.a);\n\n#if __VERSION__ == 100\n\n gl_FragColor = glFragColor;\n\n#endif\n\n }\n\n"}],"techniques":[{"attributes":{"aPosition":{"semantic":"POSITION","type":35666},"instanceId":{"semantic":"instanceId","type":5126},"batchId":{"semantic":"_BATCHID","type":5126},"aTexCoord0":{"semantic":"TEXCOORD_0","type":35664},"aTexCoord1":{"semantic":"aTexCoord1","type":35666},"aNormal":{"semantic":"aNormal","type":35665},"aColor":{"semantic":"COLOR_0","type":35666},"uv2":{"semantic":"uv2","type":35666},"uv3":{"semantic":"uv3","type":35666},"uv4":{"semantic":"uv4","type":35666},"secondary_colour":{"semantic":"secondary_colour","type":35666},"uv6":{"semantic":"uv6","type":35666}},"program":0,"uniforms":{"czm_modelView":{"type":35676,"semantic":"MODELVIEW"},"czm_normal":{"type":35675,"semantic":"MODELINVERSETRANSPOSE"},"czm_modelViewProjection":{"type":35676,"semantic":"MODELVIEWPROJECTION"},"uTexMatrix":{"type":35676},"uTexture0Width":{"type":5126},"uFillForeColor":{"type":35666},"uSelectedColor":{"type":35666},"uDiffuseColor":{"type":35666},"uTexture":{"type":35678},"uTexture2":{"type":35678},"uTexture1Width":{"type":5126}}}]},{getTextureMagFilter:Qe,getTextureMinFilter:tr,getTextureWrap:er,getMaterialType:rr,getMaterialFormat:nr,getPrimitive:ir,getUniqueREGLBuffer:sr}=r.reshader.REGLHelper,or=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],ar=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:cr,logoutIBLResOnCanvas:lr,getIBLResOnCanvas:fr,getPBRUniforms:ur}=r.reshader.pbr.PBRUtils,hr={factor:0,units:0},_r={specularStrength:0,materialShininess:1},dr=[1,1,1],Er=r.mat4.identity([]),Tr=t=>t.material instanceof r.reshader.PhongMaterial,mr=t=>t.material instanceof r.reshader.pbr.StandardMaterial,Ar=[!0,!0,!0,!0],pr=[],yr=new i.Coordinate(0,0),gr=[],Rr=[],br={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"};class Ir{constructor(t,e){this.tt=e,this.et=e.getRenderer().canvas,this.rt=new i.SpatialReference,this.nt=t,this.it=new r.reshader.Renderer(t),this.st={},this.ot={},this.at={},this.ct={},this.lt={},this.ft={},this.ut={},this.ht=new r.reshader.Scene,this._t=new r.reshader.Scene,this.dt=new r.reshader.Scene,this.Et=new r.reshader.Scene,this.Tt=new r.reshader.ResourceLoader(t.texture(2)),this.At=this.yt.bind(this),this.gt=new r.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}),this.Rt(),this.bt=new r.reshader.KHRTechniquesWebglManager(this.nt,this.It(),this.Tt)}getI3DMMeshes(){return this.lt}getPNTSMeshes(){return this.ct}getB3DMMeshes(){return this.at}getPaintedMeshes(){return this.Nt}getMap(){return this.tt.getMap()}paint(t,e,r,n){const i=this.getMap();if(!t.length||!i)return;const s=this.St(),o=i.projViewMatrix,a=this.tt.options.services,c=[],l=[];let u=[];const h=[],_=[];for(let r=0,n=t.length;r<n;r++){const n=t[r].data.node;let i=this.wt(n);if(!i)continue;this.ft[n.id]&&(i=this.ft[n.id],i=S(i));let d=a[n.Mt].polygonOffset||hr;m(d)&&(d=d());const E=a[n.Mt].ambientLight;Array.isArray(i)||(c[0]=i,i=c);for(let a=0,c=i.length;a<c;a++){if(i[a].getBoundingBox&&!f(o,i[a].getBoundingBox()))continue;const c=i[a].properties.magic;"b3dm"===c?u.push(i[a]):"pnts"===c?h.push(i[a]):"i3dm"===c&&_.push(i[a]),i[a].properties.level=t[r].selectionDepth,i[a].properties.polygonOffset=d,Object.prototype.hasOwnProperty.call(i[a].uniforms,"ambientColor")||Object.defineProperty(i[a].uniforms,"ambientColor",{enumerable:!0,get:function(){return E||s.ambientColor}}),i[a].Ot=n,e[n.id]||l.push(i[a])}}let d=0;const E=this.bt.getExcludeFilter();d+=this.vt(this.Ct,s,[r,Tr,E],n,l,u,_),d+=this.vt(this.xt,s,[r,mr,E],n,l,u,_),this.bt.forEachShader(((t,e,i)=>{const s=this.St(i);d+=this.vt(t,s,[r,e],n,l,u,_)})),this._t.setMeshes(h);const T=this.Ut();return d+=this.it.render(this.Bt,T,this._t,n&&n.fbo),this.Nt={pntsMeshes:h,i3dmMeshes:_,b3dmMeshes:u},d}vt(t,e,r,n,i,s,o){t.filter=r.filter((t=>!!t)),e.debug=!1,this.ht.setMeshes(i),e.stencilEnable=!1,e.debug=!1,e.cullFace="back",e.colorMask=Ar;let a=0;return this.ht.setMeshes(s),a+=this.it.render(t,e,this.ht,n&&n.fbo),e.stencilEnable=!1,this.dt.setMeshes(o),a+=this.it.render(t,e,this.dt,n&&n.fbo),a}Pt(t,e){return e.Ot.Lt-t.Ot.Lt}paintRegion(t,e,r,n,i){const s=this.getMap();if(!t.length&&!e.length)return;const o=s.projViewMatrix,a=[];for(let r=0,n=(t=t.concat(e)).length;r<n;r++){const e=t[r].node,n=this.Dt(e);n&&(n.getBoundingBox&&!f(o,n.getBoundingBox())||a.push(n))}this.Ft.filter=n,this.Et.setMeshes(a);const c=this.Gt(r);this.it.render(this.Ft,c,this.Et,i&&i.fbo)}deleteTile(t){const e=t.node.id;this.kt(e)}kt(t){const e=this.ot[t];e&&(e.geometry.dispose(),e.dispose(),delete this.ot[t]);let r=this.at[t]||this.ct[t]||this.lt[t]||this.ft[t]||this.st[t];this.ft[t]?this.Ht(t):r&&(this.Vt(r),delete this.at[t],delete this.ct[t],delete this.lt[t],delete this.st[t])}Ht(t){let e=this.ft[t];e=S(e);for(let t=0;t<e.length;t++){const{id:r}=e[t].properties;this.kt(r)}delete this.ft[t]}Vt(t){if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++)this.Vt(t[e]);else{const e=t.geometry.properties.url;if(e){const t=this.ut[e];t&&(t.refCount--,t.refCount<=0&&(t.geometry.dispose(),t.material.dispose(),delete this.ut[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.tt;lr(t.getRenderer().canvas,t.getMap());for(const t in this.ft)this.Ht(t);this.ft={};for(const t in this.at)this.kt(t);this.at={};for(const t in this.ct)this.kt(t);this.ct={};for(const t in this.lt)this.kt(t);this.lt={};for(const t in this.st)this.kt(t);this.st={};for(const t in this.ot)this.kt(t);this.ot={},this.Ct&&(this.Ct.dispose(),delete this.Ct),this.xt&&(this.xt.dispose(),delete this.xt),this.Bt&&(this.Bt.dispose(),delete this.Bt),this.Ft&&(this.Ft.dispose(),delete this.Ft),this.bt.dispose()}Dt(t){if(!t.boundingVolume||!t.boundingVolume.region)return null;if(this.ot[t.id])return this.ot[t.id];const e=t.boundingVolume.region;let n=new i.Coordinate(y(e[0]),y(e[1])),s=new i.Coordinate(y(e[2]),y(e[3]));n=this.zt(n),s=this.zt(s);const o=n.add(s).Yt(.5);n._sub(o),s._sub(o);const a=this.Xt(e[4],e[5]),c=a.x,l=a.y,f=[n.x,n.y,l,s.x,n.y,l,s.x,s.y,l,n.x,s.y,l,n.x,n.y,c,s.x,n.y,c,s.x,s.y,c,n.x,s.y,c],u=new r.reshader.Geometry({aPosition:f},[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],0,{primitive:"lines"});u.generateBuffers(this.nt);const h=new r.reshader.Mesh(u),_=r.mat4.identity([]);return h.setLocalTransform(r.mat4.translate(_,_,[o.x,o.y,0])),this.ot[t.id]=h,h}wt(t){return this.at[t.id]||this.ct[t.id]||this.lt[t.id]||this.ft[t.id]}has(t){return this.wt(t)||this.st[t.id]}createPntsMesh(t,e,n,i){if(this.ct[e]){const t=this.ct[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:s,featureTable:o,rootIdx:a}=t,c=o.POINTS_LENGTH,l=new r.reshader.Geometry(s,null,c,{primitive:"points",positionAttribute:"POSITION"});l.generateBuffers(this.nt);const f={};s.POSITION?f.HAS_POSITION=1:s.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),s.RGB?f.HAS_RGB=1:s.RGBA?f.HAS_RGBA=1:s.RGB565&&(f.HAS_RGB565=1),(s.NORMAL||s.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,s.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:u,rtcCoord:h}=t,_=this.Zt(h),d=this.Wt(n,u,h);r.mat4.multiply(d,d,_);const E=this.tt.options.services[a],T=new r.reshader.Mesh(l);return T.properties.magic="pnts",T.properties.id=e,T.properties.count=c,T.properties.batchTable=t.batchTable,T.properties.batchTableBin=t.batchTableBin,T.setDefines(f),Object.defineProperty(T.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:E&&E.pointColor||[1,1,1,1]}}),Object.defineProperty(T.uniforms,"pointSize",{enumerable:!0,get:function(){return E&&E.pointSize||2}}),Object.defineProperty(T.uniforms,"pointOpacity",{enumerable:!0,get:function(){return E&&E.pointOpacity||1}}),T.setLocalTransform(d),this.ct[e]=T,i(null,{id:e,mesh:[T]}),[T]}createI3DMMesh(t,e,n,i){if(this.lt[e]){const t=this.lt[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.st[e]||i(null,{id:e,mesh:t}),t}const s=this.jt(n.Kt),{i3dm:o,featureTable:a,gltf:c,batchTable:l,batchTableBin:f,count:u}=t,h=a.INSTANCES_LENGTH,{rtcCenter:_,rtcCoord:d}=t,E=this.Zt(d),T=this.Wt(n,_,d),{POSITION:m,NORMAL_UP:A,NORMAL_RIGHT:p,SCALE:y,SCALE_NON_UNIFORM:g,INSTANCE_ROTATION:R}=o,b={"instance_vectorA":new Float32Array(4*h),"instance_vectorB":new Float32Array(4*h),"instance_vectorC":new Float32Array(4*h)},I=new Float32Array(3),S=new Float32Array(3),w=[],M=new Float32Array(1),O=new Float32Array(3),v=[],C=[],x=[],U=[],B=new Float32Array(9);!function(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:o}=t;const a=t.array.buffer,c=r?Lt.getTypedArrayCtor(r):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,i=i||0,s=s||t.array.length/o,(!i||i===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const l=new Uint8Array(o*c.BYTES_PER_ELEMENT);i||(i=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(a,i*t+n,o*c.BYTES_PER_ELEMENT);l.set(r),e(new c(l.buffer),t),r.set(l)}}(m,((t,e)=>{A?(qt(S,p,e),qt(I,A,e),r.vec3.cross(w,S,I),r.vec3.normalize(w,w),N(v,S,0),N(v,I,1),N(v,w,2),r.quat.fromMat3(C,v)):R?(qt(B,R,e),r.quat.fromMat3(C,B)):r.quat.identity(C),y?(qt(M,y,e),r.vec3.set(x,M[0],M[0],M[0])):g?(qt(O,g,e),r.vec3.set(x,...O)):r.vec3.set(x,1,1,1),r.mat4.fromRotationTranslationScale(U,C,t,x),$t(b.instance_vectorA,e,U,0),$t(b.instance_vectorB,e,U,1),$t(b.instance_vectorC,e,U,2)}));const P={};for(const t in b)P[t]={buffer:this.nt.buffer({dimension:b[t].length/h,data:b[t]}),divisor:1};const L=this.tt.options.services[n.Mt].shader||"phong";let D=0,F=!0;const G=[];return jt(c,((t,i,o,a)=>{let{geometry:c,material:_}=this.qt(t,i,o,a,n,!0,L);_&&!_.isReady()&&(F=!1,D++);const d=new r.reshader.InstancedMesh(P,h,c,_);d.properties.magic="i3dm",d.properties.id=e,d.properties.count=u,d.properties.batchTable=l,d.properties.batchTableBin=f;const m=this.$t(t,c,_,n.Mt,a),A=r.mat4.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.mat4.multiply(A,A,t.matrices[e]);r.mat4.multiply(A,s,A),d.setPositionMatrix(A),r.mat4.multiply(E,T,E),d.setLocalTransform(E),d.setDefines(m),d.properties.polygonOffset={offset:0,factor:0},G.push(d)})),F?(this.lt[e]=G,i(null,{id:e,mesh:G})):(this.st[e]={meshes:G,count:D},G.Jt=i),G}createB3DMMesh(t,e,n,s){if(this.at[e]||this.st[e]){const t=this.at[e];return console.warn(`mesh with id(${e}) was already created.`),this.st[e]||s(null,{id:e,mesh:t}),t}const o=t.gltf.asset&&"i3s"===t.gltf.asset.generator;let a;if(n.maxExtent){const t=new i.Extent(n.maxExtent).convertTo((t=>this._pointToPrj(t)));a=[t.xmin,t.ymin,t.xmax,t.ymax]}const c=this.jt(n.Kt),l=t.gltf,{center:f,coord:u}=l.extensions.CESIUM_RTC,h=this.tt.options.services[n.Mt].heightOffset||0;let _;if(h&&u&&(u[2]+=h),o){const{i3sProjCenter:t}=l.extensions.CESIUM_RTC;_=this.Qt(t,n.Mt)}else _=this.Zt(u,n.Mt);const d=this.tt.options.services[n.Mt].shader||"phong",E=[];let T=0,m=!0;return jt(l,((i,s,l,h)=>{let{geometry:A,material:p}=this.qt(i,s,l,h,n,!1,d);p&&!p.isReady()&&(m=!1,T++);const y=new r.reshader.Mesh(A,p);y.properties.magic="b3dm",y.properties.id=e,y.properties.batchTable=t.batchTable,y.properties.batchTableBin=t.batchTableBin,y.properties.count=t.featureTable.BATCH_LENGTH;const g=this.$t(i,A,p,n.Mt,h);y.setDefines(g),a&&(g.USE_MAX_EXTENT=1,y.setUniform("maxPrjExtent",a));let R=r.mat4.identity([]);if(i.matrices&&i.matrices.length)for(let t=0;t<i.matrices.length;t++)r.mat4.multiply(R,R,i.matrices[t]);const b=o?Er:this.Wt(n,f,u);r.mat4.multiply(R,c,R),r.mat4.multiply(R,_,R),r.mat4.multiply(R,b,R),y.setLocalTransform(R),E.push(y)})),m?(this.at[e]=E,s(null,{id:e,mesh:E})):(this.st[e]={meshes:E,count:T},E.Jt=s),E}Wt(t,e,n){const s=this.getMap(),o=this.tt.options.services[t.Mt].heightOffset||0,a=new i.Coordinate(n),c=s.distanceToPointAtRes(100,0,s.getGLRes(),a).x/100;let l=t.matrix?r.mat4.copy([],t.matrix):r.mat4.identity([]);if(e){Pe(l,r.vec3.transformMat4(pr,e,l),l)}const f=function(t,e,r,n,i,s,o){e=G(Ve,e);const a=ee(Ve,e[0]*$e,e[1]*$e,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(ze,r),l=n.ellipsoid;var f;f=0===q(c)?k(Ye,0,0,-6378137):ae(Ye,c),Ke.x=f[0],Ke.y=f[1];const u=n.project(Ke,qe);Xe[0]=u.x/i,Xe[1]=u.y/i,Xe[2]=(f[2]+o)*s;const h=Le(a,l,Ze),_=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],_=e[11],d=e[12],E=e[13],T=e[14],m=e[15],A=r*a-n*o,p=r*c-i*o,y=r*l-s*o,g=n*c-i*a,R=n*l-s*a,b=i*l-s*c,I=f*E-u*d,N=f*T-h*d,S=f*m-_*d,w=u*T-h*E,M=u*m-_*E,O=h*m-_*T,v=A*O-p*M+y*w+g*S-R*N+b*I;return v?(v=1/v,t[0]=(a*O-c*M+l*w)*v,t[1]=(i*M-n*O-s*w)*v,t[2]=(E*b-T*R+m*g)*v,t[3]=(h*R-u*b-_*g)*v,t[4]=(c*S-o*O-l*N)*v,t[5]=(r*O-i*S+s*N)*v,t[6]=(T*y-d*b-m*p)*v,t[7]=(f*b-h*y+_*p)*v,t[8]=(o*M-a*S+l*I)*v,t[9]=(n*S-r*M-s*I)*v,t[10]=(d*R-E*y+m*A)*v,t[11]=(u*y-f*R-_*A)*v,t[12]=(a*N-o*w-c*I)*v,t[13]=(r*w-n*N+i*I)*v,t[14]=(E*p-d*g-T*A)*v,t[15]=(f*g-u*p+h*A)*v,t):null}(We,h),d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}(je,r),E=function(t,e,r){var n=t[0],i=t[1],s=t[2],o=t[4],a=t[5],c=t[6],l=t[8],f=t[9],u=t[10],h=e[0],_=e[1],d=e[2],E=e[3],T=e[4],m=e[5],A=e[6],p=e[7],y=e[8],g=n*h+o*_+l*d,R=i*h+a*_+f*d,b=s*h+c*_+u*d,I=n*E+o*T+l*m,N=i*E+a*T+f*m,S=s*E+c*T+u*m,w=n*A+o*p+l*y,M=i*A+a*p+f*y,O=s*A+c*p+u*y;return r[0]=g,r[1]=R,r[2]=b,r[3]=0,r[4]=I,r[5]=N,r[6]=S,r[7]=0,r[8]=w,r[9]=M,r[10]=O,r[11]=0,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r}(_,d,t);return Pe(t,Xe,E),t}(l,n,l,s.getProjection(),s.getGLRes(),c,o),u=function(t,e){return k(t,e[12],e[13],e[14]),t}(Rr,f);let h=this.tt.options.offset;if(m(h)){h=h(this.tt.te(t.id).center)}return r.vec3.set(gr,h[0],h[1],0),r.vec3.sub(u,u,gr),Pe(f,u,f),f}createCMPTMesh(t,e,r,n){if(this.ft[e]){const t=this.ft[e];return console.warn(`mesh with id(${e}) was already created.`),n(null,{id:e,mesh:t}),t}const{content:i}=t,s=[];for(let t=0;t<i.length;t++){const{magic:n}=i[t],o=e+"."+t;"b3dm"===n?this.createB3DMMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"i3dm"===n?this.createI3DMMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"pnts"===n?this.createPntsMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"cmpt"===n&&this.createCMPTMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)}))}return this.ft[e]=s,n(null,{id:e,mesh:s}),s}$t(t,e,r,n,i){const s=("phong"===(this.tt.options.services[n].shader||"phong")?this.Ct:this.xt).getGeometryDefines(e);return i.asset&&"S3M"===i.asset.generator&&this.ee(s,e,i),s}ee(t,e,r){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1),e.data.aTexCoord0&&r.textures.length&&(t.COMPUTE_TEXCOORD=1)}qt(t,e,r,n,i,s,o){let a=!1;n.asset&&"S3M"===n.asset.generator&&(a=!0,n.extensions=n.extensions||{},n.extensions.KHR_techniques_webgl=Je);const c=n.url+"-"+e+"-"+r;if(this.ut[c])return this.ut[c].refCount++,this.ut[c];let l,f;const u=n.materials[t.material];if(n.extensions&&n.extensions.KHR_techniques_webgl&&u.extensions&&u.extensions.KHR_techniques_webgl){const e=this.re(t,n,s,a);l=e.material,f=e.geometry;this.tt.options.services[i.Mt].fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.ne(t,s,br);const e=this.tt.options.services[i.Mt].material;l=this.ie(t.material,n,o,e||_r)}l&&!l.isReady()?l.se=i.id:l||(l=this.gt);const h={refCount:1,geometry:f,material:l};return f.properties.url=c,this.ut[c]=h,h}re(t,e,r,n){const{geometry:i,material:s}=this.bt.createMesh(t,e,r,n);return{geometry:i,material:s}}ne(t,e,n){const i=t.attributes;if(i.COLOR_0){const t=i.COLOR_0.array||i.COLOR_0;if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let r=0;r<e.length;r++)e[r]=Math.round(255*t[r]);i.COLOR_0.array?(i.COLOR_0.array=e,i.COLOR_0.componentType=5121):i.COLOR_0=e}}const s={};for(const t in i){const e=sr(this.nt,i[t],{dimension:i[t].itemSize}),r=n[t]||t;s[r]={buffer:e},i[t].quantization&&(s[r].quantization=i[t].quantization),r===n.POSITION&&(s[r].array=i[t].array,s[r].min=i[t].min,s[r].max=i[t].max)}delete t.attributes;const o=new r.reshader.Geometry(s,t.indices?t.indices.array?t.indices.array.slice():t.indices:null,0,{positionAttribute:n.POSITION,normalAttribute:n.NORMAL,uv0Attribute:n.TEXCOORD_0,uv1Attribute:n.TEXCOORD_1,color0Attribute:n.COLOR_0,tangentAttribute:n.TANGENT,batchIdAttribute:n._BATCHID,primitive:void 0===t.mode?"triangles":ir(t.mode)});return o.generateBuffers(this.nt,{excludeElementsInVAO:e}),o}Zt(t){const e=r.mat4.identity([]),n=this.getMap(),i=this.oe();yr.x=t[0],yr.y=t[1];const s=n.distanceToPointAtRes(100,100,n.getGLRes(),yr);return r.vec3.set(i,s.x/100*1.01,s.y/100*1.01,s.y/100),r.mat4.scale(e,e,i),e}Qt(t,e){const n=r.mat4.identity([]),s=this.getMap(),o=this._prjToPoint(new i.Coordinate(t)),a=this.oe(),c=1/(s.getGLZoom?s.getResolution(s.getGLZoom()):s.getGLRes()),l=r.vec3.set(Rr,o.x,o.y,c*t[2]);r.mat4.translate(n,n,l);const f=this.tt.options.services[e].heightOffset;if(f){const e=s.getProjection().unproject(new i.Coordinate(t)),o=s.distanceToPointAtRes(100,100,s.getGLRes(),e).y/100;r.mat4.translate(n,n,[0,0,f*o])}return r.mat4.scale(n,n,r.vec3.scale([],a,c)),n}Rt(){const t={x:0,y:0,width:()=>this.et?this.et.width:1,height:()=>this.et?this.et.height:1};this.Ft=new r.reshader.MeshShader({vert:"attribute vec3 aPosition;\n\n\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main() {\n\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n}\n\n",frag:"precision mediump float;\nuniform vec3 color;\nvoid main() {\n gl_FragColor = vec4(color, 1.0);\n}\n",uniforms:["color",{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.mat4.multiply([],e.projViewMatrix,e.modelMatrix)}],extraCommandProps:{viewport:t}});const e=[],n=[];this.Bt=new r.reshader.MeshShader({vert:"const float SHIFT_RIGHT_11 = 1.0 / 2048.0;\n\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\n\nconst float SHIFT_LEFT_11 = 2048.0;\n\nconst float SHIFT_LEFT_5 = 32.0;\n\nconst float NORMALIZE_6 = 1.0 / 64.0;\n\nconst float NORMALIZE_5 = 1.0 / 32.0;\n\n\n\n#ifdef HAS_POSITION\n\n attribute vec3 POSITION;\n\n#endif\n\n\n\n#if defined(HAS_RGB)\n\n attribute vec3 RGB;\n\n#elif defined(HAS_RGBA)\n\n attribute vec4 RGBA;\n\n#elif defined(HAS_RGB565)\n\n attribute float RGB565;\n\n#endif\n\n\n\nuniform vec4 pointColor;\n\nuniform float pointSize;\n\n\n\nuniform mat4 projViewModelMatrix;\n\nuniform float pointOpacity;\n\n\n\nvarying vec4 vColor;\n\n\n\n#ifdef HAS_NORMAL\n\n #ifdef HAS_NORMAL_OCT16P\n\n attribute vec2 NORMAL_OCT16P;\n\n float signNotZero(float value) {\n\n return value >= 0.0 ? 1.0 : -1.0;\n\n }\n\n vec2 signNotZero(vec2 value) {\n\n return vec2(signNotZero(value.x), signNotZero(value.y));\n\n }\n\n vec3 octDecode(vec2 encoded, float range) {\n\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n\n return vec3(0.0, 0.0, 0.0);\n\n }\n\n encoded = encoded / range * 2.0 - 1.0;\n\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n\n if (v.z < 0.0) {\n\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n\n }\n\n return normalize(v);\n\n }\n\n vec3 octDecode(vec2 encoded) {\n\n return octDecode(encoded, 255.0);\n\n }\n\n #else\n\n attribute vec3 NORMAL;\n\n #endif\n\n uniform vec3 lightDir;\n\n uniform mat3 modelNormalMatrix;\n\n uniform mat4 positionMatrix;\n\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n\n return max(dot(-lightDir, normal), 0.0);\n\n }\n\n#endif\n\n\n\nvoid main() {\n\n #if defined(HAS_RGB)\n\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n\n #elif defined(HAS_RGBA)\n\n vColor = RGBA / 255.0 * pointOpacity;\n\n #elif defined(HAS_RGB565)\n\n float compressed = RGB565;\n\n float r = floor(compressed * SHIFT_RIGHT_11);\n\n compressed -= r * SHIFT_LEFT_11;\n\n float g = floor(compressed * SHIFT_RIGHT_5);\n\n compressed -= g * SHIFT_LEFT_5;\n\n float b = compressed;\n\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n\n vColor = vec4(rgb, 1.0);\n\n #else\n\n vColor = pointColor;\n\n #endif\n\n\n\n #ifdef HAS_POSITION\n\n vec3 localPos = POSITION;\n\n #endif\n\n\n\n #ifdef HAS_NORMAL\n\n mat3 positionNormalMatrix = mat3(positionMatrix);\n\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n\n #ifdef HAS_NORMAL_OCT16P\n\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n\n #else\n\n vec3 localNormal = NORMAL;\n\n #endif\n\n vec3 normal = normalize(normalMatrix * localNormal);\n\n float colorStrength = getLambertDiffuse(lightDir, normal);\n\n colorStrength = max(colorStrength, 0.5);\n\n vColor *= colorStrength;\n\n #endif\n\n\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n}\n\n",frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n gl_FragColor = vColor;\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.mat4.multiply(n,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,n)=>r.mat3.fromMat4(e,n.modelMatrix)}],extraCommandProps:{viewport:t,blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const i=this.It();this.Ct=new r.reshader.PhongShader({extraCommandProps:i}),this.xt=new r.reshader.pbr.StandardShader({extraCommandProps:i});const s=this.tt;cr(s.getRenderer().canvas,this.nt,s.getMap())}It(){return{viewport:{x:0,y:0,width:()=>this.et?this.et.width:1,height:()=>this.et?this.et.height:1},colorMask:(t,e)=>e.colorMask||Ar,cull:{enable:!0,face:(t,e)=>e.cullFace},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}Gt(t){return{projViewMatrix:this.getMap().projViewMatrix,color:t&&t.color||[0,1,0]}}Ut(t){const e=this.getMap(),n=e.getLightManager(),i=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:r.vec3.normalize(i,i)}}St(){const t=this.getMap(),e=this.tt.getRenderer().canvas,{iblTexes:r,dfgLUT:n}=fr(e),i=ur(t,r,n);return T(i,{czm_lightDirectionEC:i.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[e.width,e.height],polygonFill:[1,1,1,1],polygonOpacity:1}),i}ie(t,e,n,i){const s=e.materials[t];if(!s||!s.baseColorTexture&&!s.pbrMetallicRoughness)return null;const o=T({},i);if(s.baseColorTexture){const t=e.textures[s.baseColorTexture.index];let r;t&&!t.image.color&&(r=this.M(t)),o.baseColorFactor=t&&t.image.color||s.baseColorFactor||[1,1,1,1],r&&(o.baseColorTexture=r)}else{if(s.normalTexture){const t=this.M(e.textures[s.normalTexture.index]),r=s.normalTexture.scale||1;o.normalTexture=t,o.normalMapFactor=r}if(s.occlusionTexture){const t=this.M(e.textures[s.occlusionTexture.index]),r=s.occlusionTexture.strength||1;o.occlusionTexture=t,o.occlusionFactor=r}if(s.emissiveTexture){const t=this.M(e.textures[s.emissiveTexture.index]);o.emissiveTexture=t}s.emissiveFactor;const t=s.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(o.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];n.image&&n.image.color?o.baseColorFactor=o.baseColorFactor?r.vec4.multiply(o.baseColorFactor,o.baseColorFactor,n.image.color):n.image.color:(o.baseColorTexture=this.M(n),o.baseColorTexture.getREGLTexture(this.nt))}if(E(t.metallicFactor)||(o.metallicFactor=t.metallicFactor),E(t.roughnessFactor)||(o.roughnessFactor=t.roughnessFactor),s.metallicRoughnessTexture){const t=this.M(e.textures[s.metallicRoughnessTexture.index]);o.metallicRoughnessTexture=t}}}if(s.s3mMaterial)return new r.reshader.Material(o);let a=new r.reshader.pbr.StandardMaterial(o);return"phong"===n&&(a=r.reshader.PhongMaterial.convertFrom(a)),a.once("complete",this.At),a}M(t){const e={type:t.type?rr(t.type):"uint8",format:t.format?nr(t.format):"rgba",flipY:!!t.flipY},n=t.image;n.array?e.data=n.array:n.mipmap&&(e.mipmap=n.mipmap),e.width=n.width,e.height=n.height;const i=t.sampler||t.texture.sampler;return i&&(i.magFilter&&(e.mag=Qe(i.magFilter)),i.minFilter&&(e.min=tr(i.minFilter)),i.wrapS&&(e.wrapS=er(i.wrapS)),i.wrapT&&(e.wrapT=er(i.wrapT))),new r.reshader.Texture2D(e,this.Tt)}ae(t){const e=t.image,r=window.URL||window.webkitURL,n=new Blob([e.array],{type:e.mimeType});return r.createObjectURL(n)}yt({target:t}){const e=t.se,r=this.st[e];if(r.count--,!r.count){const t=r.meshes;this.at[e]=t,delete this.st[e];const n=t.Jt;delete t.Jt,n(null,{mesh:r.meshes,id:e})}}oe(){return dr}zt(t){return this.tt.zt(t)}Xt(t,e){const r=this.getMap();return r.getGLZoom?r.distanceToPoint(t,e,r.getGLZoom()):r.distanceToPointAtRes(t,e,r.getGLRes())}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes())}jt(t){return"Y"===t?or:"X"===t?ar:Er}}
|
|
18
|
+
let rt=0;function nt(t){return null==t}function it(t){return!nt(t)}function st(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}function ot(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+t)}function at(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function ct(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),r=e.length,n=new Uint8Array(r);for(let t=0;t<r;t++)n[t]=e.charCodeAt(t);return n.buffer}const lt=[],ft=[],ut=[],ht=[0,0,0],_t=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),dt=[1,1,1];function Et(t,e,r,n,i,s,o){const a=ot(o);if((0===i||i===n*a.BYTES_PER_ELEMENT)&&s%a.BYTES_PER_ELEMENT==0){const i=new a(e,s,r*n);return t.set(i),t}0===i&&(i=n*a.BYTES_PER_ELEMENT);const c=new Uint8Array(n*a.BYTES_PER_ELEMENT);for(let o=0;o<r;o++){let r=null;const l=new Uint8Array(e,i*o+s,n*a.BYTES_PER_ELEMENT);c.set(l),r=new a(c.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const Tt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function mt(t,e,r){const n=new Uint8Array(t,e,r);return Tt.decode(n)}const At={get:function(t,e={}){e||(e={});const r=new AbortController,n=r.signal,i=st({},e);i.signal=n,i.method||(i.method="GET");const s=fetch(t,i).then((t=>{const r=this.i(t,e.responseType);return r.message?r:r.then((r=>"arraybuffer"===e.responseType?{data:r,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:r)).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}))})).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}));return s.xhr=r,s},i:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",At.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?At.jsonp(t):((e=e||{}).responseType="json",At.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+rt++;t.match(/\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,new Promise((t=>{window[e]=function(n){document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e],t(n)},document.getElementsByTagName("head")[0].appendChild(r)}))}};class pt{constructor(t,e,r){this.o=t,this.decoders=e,this.l=r,this.images={},this.u={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],i=this.h(e,n);return this.getImageByBuffer(i,r)}if(this.u[t.id])return this.u[t.id].then((()=>{const n=this.buffers[t.id],i=this.h(e,n);return this.getImageByBuffer(i,r)}));if(at(t.uri)){const n=this.buffers[t.id]=ct(t.uri),i=this.h(e,n);return this.getImageByBuffer(i,r)}return this.u[t.id]=At.getArrayBuffer(t.uri,null).then((n=>{const i=this.buffers[t.id]=n.data,s=this.h(e,i);return this.getImageByBuffer(s,r)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const r=this.decoders;if(r[e.mimeType])return r[e.mimeType](t,{supportedFormats:this.l});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const r=new Blob([t],{type:e.mimeType}),n=URL.createObjectURL(r);return this._(e.id,n)}}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.u[t.id]?this.u[t.id].then((()=>this.images[t.id])):this.u[t.id]=this._(t.id,e)}_(t,e){return new Promise(((r,n)=>{this.o(e,((i,s)=>{i?n(i):(URL.revokeObjectURL(e),this.images[t]=s,r(this.images[t]))}))}))}}const yt=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class gt{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.T=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.m()}A(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this.p(t,e,null,0),Promise.resolve(this.accessors[n.id]);if(n&&this.accessors[n.id])return Promise.resolve(this.accessors[n.id]);const i=r.bufferViews[n.bufferView];return this.g(i).then((r=>{const{buffer:i,byteOffset:s}=r;return this.accessors[n.id]=this.p(t,e,i,s)}))}g(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then((()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}));if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(at(e.uri)){const t=this.buffers[e.id]=ct(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=At.getArrayBuffer(t,null).then((n=>(r&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=n.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}p(t,e,r,n=0){const i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+n,c=this.R(s.type),l=ot(s.componentType),f=o.byteStride||0,u={array:void 0,name:t,accessorName:e,byteLength:s.count*c*l.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c};if(s.min&&(u.min=s.min),s.max&&(u.max=s.max),r)if(this.T)u.byteStride=f,u.byteOffset=a+(s.byteOffset||0),!f||f===c*l.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(u.array=this.I(r,s.count,c,a+(s.byteOffset||0),l),u.array.buffer.byteLength===u.byteLength&&(u.byteOffset=0)):u.array=new Uint8Array(r,a,o.byteLength);else if(s.interleaved){u.byteStride=0,u.byteOffset=0;const t=new l(s.count*c);u.array=Et(t,r,s.count,c,f,a+(s.byteOffset||0),s.componentType)}else u.byteStride=0,u.array=this.I(r,s.count,c,a+(s.byteOffset||0),l),u.byteOffset=u.array.byteOffset;else{u.array=new l(s.count);const t=u.min||u.max;t&&(u.array[0]=t[0],u.array[1]=t[1],u.array[2]=t[2])}return u}m(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let r=0;r<t.length;r++)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0);else for(const e in t)for(const r in t)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0)}I(t,e,r,n,i){return n%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(n,n+e*r*i.BYTES_PER_ELEMENT),n=0),new i(t,n,r*e)}R(t){const e=yt.indexOf(t);return yt[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,r=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:r}=e;return this.g(e).then((n=>{const{buffer:i,byteOffset:s}=n,o=mt(i,s+(e.byteOffset||0),r);return t.content=o,t}))}if(t.uri){if(at(t.uri)){const e=ct(t.uri),r=mt(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return At.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class Rt extends pt{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=r,this.accessor=new gt(t,e,r)}iterate(t,e){const r=this.gltf[e];if(!r)return;let n=0;for(const e in r)t(e,r[e],n++)}createNode(t){const e={};if(it(t.name)&&(e.name=t.name),it(t.children)&&(e.children=t.children),it(t.jointName)&&(e.jointName=t.jointName),it(t.matrix)&&(e.matrix=t.matrix),it(t.rotation)&&(e.rotation=t.rotation),it(t.scale)&&(e.scale=t.scale),it(t.translation)&&(e.translation=t.translation),it(t.extras)&&(e.extras=t.extras),it(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const r=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(lt,e.translation||ht),n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,c=i+i,l=r*o,f=n*o,u=n*a,h=i*o,_=i*a,d=i*c,E=s*o,T=s*a,m=s*c;return t[0]=1-u-d,t[1]=f+m,t[2]=h-T,t[3]=0,t[4]=f-m,t[5]=1-l-d,t[6]=_+E,t[7]=0,t[8]=h+T,t[9]=_-E,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ft,e.rotation||_t),i=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ut,e.scale||dt);return P(i,n,i),P(t,r,i)}return B(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}N(t){const e={};for(const r in t){const n=t[r];let i,s;n.instanceTechnique&&n.instanceTechnique.values?(i=n.instanceTechnique,s=i.values.diffuse):(i=n,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={baseColorTexture:{index:s}};n.name&&(o.name=n.name),n.extensions&&(o.extensions=n.extensions),n.extras&&(o.extras=n.extras),e[r]=o}return e}S(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const r=this.gltf.bufferViews[e.bufferView],n=(r.byteOffset||0)+this.glbBuffer.byteOffset,i=r.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,n,i);return this.getImageByBuffer(s,t)}return this.requestExternalImage(t)}M(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.S(r).then((t=>{const n=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extras:r.extras},sampler:n}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let r,n;if(e.instanceTechnique&&e.instanceTechnique.values?(r=e.instanceTechnique,n=r.values.diffuse):(r=e,n=r.values.tex||r.values.diffuseTex||r.values.diffuse),void 0===n||void 0===this.gltf.textures)return null;const i=this.gltf.textures[n];if(!i)return null;const s=this.gltf.samplers[i.sampler];return{format:i.format||6408,internalFormat:i.internalFormat||6408,type:i.type||5121,sampler:s,source:this.gltf.images[i.source]}}getMaterial(){return null}getAnimations(){return null}}class bt extends pt{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.glbBuffer=r,this.buffers={},this.requests={},this.accessor=new gt(t,e,r)}iterate(t,e){const r=this.gltf[e];if(r)for(let e=0;e<r.length;e++)t(e,r[e],e)}createNode(t){const e={};return st(e,t),!it(t.weights)&&this.gltf.meshes&&it(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}M(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.S(r).then((t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};st(n,e);const i=it(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),t.format&&(n.format=t.format),n}))}S(t){if(!it(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],r=this.gltf.buffers[e.buffer];if(r.uri)return this.requestImageFromBufferURI(r,e,t);if(this.glbBuffer)return this.O(e,t)}return null}O(t,e){const r=this.h(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}h(t,e,r){r=r||0;const n=t.byteOffset+r,i=t.byteLength;return new Uint8Array(e,n,i)}v(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);return r.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)))}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let r=0;r<e.length;r++)t[r].samplers=e[r];return t}))}getSamplers(t){const e=[];for(let r=0;r<t.length;r++)(it(t[r].input)||it(t[r].output))&&(e.push(this.accessor.A("input",t[r].input)),e.push(this.accessor.A("output",t[r].output)));return Promise.all(e).then((e=>{for(let r=0;r<e.length/2;r++)t[r].input=e[2*r],t[r].output=e[2*r+1],t[r].interpolation||(t[r].interpolation="LINEAR");return t}))}}const It="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class Nt{static read(t,e=0,r=0){r||(r=t.byteLength);const n=new DataView(t,e,r),i=n.getUint32(4,!0);if(1===i)return Nt.readV1(n,e);if(2===i)return Nt.readV2(t,e);throw new Error("Unsupported glb version : "+i)}static readV1(t,e){const r=t.getUint32(8,!0),n=t.getUint32(12,!0);if(r!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const i=St(t.buffer,20+e,n);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+n,buffer:t.buffer,byteLength:r}}}static readV2(t,e){let r,n,i;const s=new DataView(t,e+12);let o=0;for(;o<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,1313821514===c)r=St(t,e+12+o,a);else if(5130562===c){i=e+12+o,n=a;break}o+=a}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function St(t,e,r){if(It){const n=new Uint8Array(t,e,r);return It.decode(n)}return function(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=wt[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}(new Uint8Array(t,e,r))}const wt=[1,1,1,1,2,2,3,0],Mt=[0,0,0],Ot=[0,0,0,1],vt=[1,1,1],Ct={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},xt={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Ut={C(t,e,r,n,i,s,o,a){const c=it(t)?e.animations:[e.animations[0]],l={};for(let e=0;e<c.length;e++){const f=c[e],u=f.name||e;if(it(t)&&u!==t)continue;const h=f.channelsMap[r];if(h)for(let t=0;t<h.length;t++){const e=h[t];"translation"===e.target.path?(this.U(i,f.samplers[e.sampler],n,1),l.translation=G(Mt,i)):"rotation"===e.target.path?(this.B(s,f.samplers[e.sampler],n,1),l.rotation=et(Ot,s)):"scale"===e.target.path?(this.U(o,f.samplers[e.sampler],n,1),l.scale=G(vt,o)):"weights"===e.target.path&&a&&(this.U(a,f.samplers[e.sampler],n,a.length),l.weights=a)}}return l},U(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.P(xt,e,r,1*n);i&&(t=function(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e[i]+n*(r[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.P(xt,e,r,1*n);i&&(t=function(t,e){for(let r=0;r<t.length;r++)t[r]=e[r];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.P(xt,e,r,3*n);i&&(t=this.L(t,i,e.input.array,3*n));break}}return t},B(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.P(xt,e,r,1);n&&Q(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.P(xt,e,r,1);n&&(t=$(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.P(xt,e,r,3);if(n){for(let t=0;t<n.PREVIOUS.length;t++)n.PREVIOUS[t]=Math.acos(n.PREVIOUS[t]),n.NEXT[t]=Math.acos(n.NEXT[t]);t=this.L(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},D(t,e){const r=t.length;let n,i,s,o=0,a=r-1,c=Math.floor((o+a)/2);for(;o<=r-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const r=t[c];return n=c,i=c+1,s=(e-r)/(t[c+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},P(t,e,r,n){const i=e.input.array,s=e.output.array,o=e.output.itemSize;(r<i[0]||r>i[i.length-1])&&(r=Math.max(i[0],Math.min(i[i.length-1],r))),r===i[i.length-1]&&(r=i[0]);const a=this.D(i,r);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:l,interpolation:f}=a;t.PREINDEX=c,t.NEXTINDEX=l,t.INTERPOLATION=f;const u=o*n;return t.PREVIOUS=s.subarray(t.PREINDEX*u,(t.PREINDEX+1)*u),t.NEXT=s.subarray(t.NEXTINDEX*u,(t.NEXTINDEX+1)*u),t},L(t,e,r,n){const i=e.INTERPOLATION,s=r[e.PREINDEX],o=r[e.NEXTINDEX];for(let r=0;r<3;r++){const a=e.PREVIOUS[n+r],c=(o-s)*e.PREVIOUS[2*n+r],l=e.NEXT[3+r],f=(o-s)*e.NEXT[r],u=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(2*-Math.pow(i,3)+3*Math.pow(i,2))*l+(Math.pow(i,3)-Math.pow(i,2))*f;t[r]=u}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;return k(Mt,...Ct.TRANSLATION),$(Ot,...Ct.ROTATION),k(vt,...Ct.SCALE),this.C(n,t,e,r,Mt,Ot,vt,i)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,r)=>{let n=-1/0,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const r=s[t],o=e.samplers[r.sampler].input.array;o[o.length-1]>n&&(n=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||r;t.timeSpan[o]={max:n,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const r=this.getTimeSpan(t);return r?it(e)?r[e]:r[Object.keys(r)[0]]:null}};let Bt=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(vr){}t&&"undefined"!=typeof createImageBitmap&&(Bt=!0)}const Pt="undefined"==typeof document?null:document.createElement("canvas");class Lt{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=Nt.read(e.buffer,e.byteOffset,e.byteLength);this.F(t,r,n)}else this.F(t,e);this.G=new gt(this.rootPath,this.gltf,this.glbBuffer),this.k()}k(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}H(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.G.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.V(t),r=this.Y(),n=this.X(),i=this.H();return Promise.all([e,r,n,i]).then((t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0])))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const r=e[t];r.channelsMap={};for(let t=0;t<r.channels.length;t++){const e=r.channels[t];r.channelsMap[e.target.node]||(r.channelsMap[e.target.node]=[]),r.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:r}=this.gltf;for(let r=0;r<e.length;r++)e[r].uri&&e[r].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[r].uri});for(let e=0;e<r.length;e++)r[e].uri&&r[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:r[e].uri})}return t}static getAnimationClip(t,e,r,n){return Ut.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return Ut.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return ot(t)}static readInterleavedArray(t,e,r,n,i,s,o){return Et(t,e,r,n,i,s,o)}F(t,e,r){this.gltf=e,this.glbBuffer=r,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=Bt?kt.bind(this):this.options.requestImage||Dt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new bt(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="buffer_"+r}),"buffers"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors")):(this.adapter=new Rt(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"))}Z(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(r=t.children[0])&&isFinite(r)||function(t){return!nt(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const n=t.children.map((t=>{const r=e[t];return r.nodeIndex=t,this.Z(r,e)}));t.children=n}var r;return t}V(t){return this.W(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.Z(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((n,i,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===n&&(r=s),e.push(o)}),"scenes");const n={asset:this.gltf.asset,scene:r,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(n.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.N(this.gltf.materials);n.materials=t}return n}))}W(t){return this.j(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,r)=>{const n=this.adapter.createNode(r,this.meshes,this.skins);t[e]=n}),"nodes"),t}))}K(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.q(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}q(t){const e=t.inverseBindMatrices;return this.adapter.accessor.A("inverseBindMatrices",e).then((e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t)))}Y(){const t=this.gltf.animations;return it(t)?this.adapter.getAnimations(t):null}j(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,i)=>{e.push(this.$(n,t).then((t=>{t.index=i,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.K()),Promise.all(e)}$(t,e){const r=t.primitives.map((t=>this.J(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return st(r,t),r.primitives=e,r}))}X(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.M(r));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const r=e[t].image.array;if(e[t]&&r){let t;t=r instanceof ImageBitmap?r:r.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const r={},n=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(r[n[t]]=e[t]);return r}return e}))}J(t,e){let r;const n=[],i=t.extensions;if(it(t.targets))for(let e=0;e<t.targets.length;e++){const r=t.targets[e];for(const t in r){const i=this.adapter.accessor.A(`morphTargets_${t}_${e}`,r[t]);i&&n.push(i)}}if(i&&i.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:s,attributes:o}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[s],c=this.G.g(a).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:c}=a;s||(s=0);const l=new DataView(n,i+s,c),f={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(l,f).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(c),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor.A(t,e[t]);r&&n.push(r)}if(it(t.indices)){const e=this.adapter.accessor.A("indices",t.indices);e&&n.push(e)}r=Promise.all(n)}return r.then((e=>{if(i&&i.KHR_draco_mesh_compression){const r=t.targets?t.targets.length:0;e[r]=e[r].concat(e.slice(0,r)),e=e[r]}let r,n;const s={attributes:e.reduce(((t,e)=>{if("indices"===e.name)r=e;else if(e.name.indexOf("morphTargets_")>-1)n=n||{},n[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0],{itemSize:n,array:i}=e,s=i.length/n;for(let e=0;e<s;e++)for(let s=0;s<n;s++){const o=e*n+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>r[s]&&(r[s]=i[o])}if(e.quantization){const n=e.quantization,i=n.range/(1<<n.quantizationBits),s=n.minValues;Y(t,t,i),H(t,t,s),Y(r,r,i),H(r,r,s)}e.min=t,e.max=r}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t}),{}),material:t.material};return r&&(s.indices=r),n&&(s.morphTargets=n),s.mode=it(t.mode)?t.mode:4,it(t.extras)&&(s.extras=t.extras),s}))}}function Dt(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Pt)return void e(new Error("There is no canvas to draw image!"));Pt.width=r.width,Pt.height=r.height;const t=Pt.getContext("2d");t.drawImage(r,0,0,r.width,r.height);const n=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(n.data)};e(null,i)},r.onerror=function(t){e(t)},r.src=t}let Ft,Gt;function kt(t,e){Ft||(Ft=new OffscreenCanvas(2,2),Gt=Ft.getContext("2d")),fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{let{width:r,height:n}=t;Ht(r)||(r=Vt(r)),Ht(n)||(n=Vt(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r),n=Math.min(i,n)),Ft.width=r,Ft.height=n,Gt.drawImage(t,0,0,r,n),t.close();const s=Gt.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function Ht(t){return 0==(t&t-1)&&0!==t}function Vt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const zt="undefined"==typeof document?null:document.createElement("canvas");class Yt extends i.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,r){let n=null;e&&e.arraybuffer&&(n=[e.arraybuffer]);const i={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(i,n,r)}abortTileLoading(t,e,r){const n={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(n,null,r)}addLayer(t,e,r){const n={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(n,null,r)}removeLayer(t,e){const r={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(r,null,e)}requestImage({url:t},e){const r=new Image;r.onload=()=>{if(!this.isActive())return;if(!zt)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(Xt(t.width)&&Xt(t.height))return t;let e=t.width,r=t.height;Xt(e)||(e=Zt(e));Xt(r)||(r=Zt(r));const n=document.createElement("canvas");n.width=e,n.height=r,n.getContext("2d").drawImage(t,0,0,e,r);const i=t.src,s=i.lastIndexOf("/")+1,o=i.substring(s);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${r})`),n}(r);zt.width=t.width,zt.height=t.height;const n=zt.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,s,[s.data.buffer])},r.onerror=function(t){e(t)},r.src=t}}function Xt(t){return 0==(t&t-1)&&0!==t}function Zt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}class Wt{constructor(t,e){this.max=t,this.currentSize=0,this.onRemove=e,this.reset()}reset(){if(this.data){const t=this.data.values();for(const e of t)this.onRemove(e)}return this.data=new Map,this.currentSize=0,this}clear(){this.reset(),delete this.onRemove}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const r=this.data.get(t);r&&r.node&&r.node.memorySize&&(this.currentSize-=r.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){const t=this.data.keys();let e=t.next();for(;this.currentSize>this.max&&void 0!==e.value;){if(!this.data.get(e.value).current){const t=this.getAndRemove(e.value);t&&this.onRemove(t)}e=t.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const r=this.data.keys();for(let n of r)t[e++]=n;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e),this}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const r of e){const e=r&&r.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t){const e=this.data.values();for(const r of e)r.current=t}}function jt(t,e){if(t.scenes&&t.scenes.length)for(let r=0,n=t.scenes.length;r<n;r++){const n=t.scenes[r].nodes;for(let r=0,i=n.length;r<i;r++){const i=[];Kt(n[r],i,t,e)}}}function Kt(t,e,r,n){if(t.matrix&&e.push(t.matrix),t.children&&t.children.length)for(let i=0,s=t.children.length;i<s;i++)Kt(t.children[i],e,r,n);if(void 0!==t.mesh){const i=t.mesh,s=r.meshes[i];if(s){const t=e.slice(0),o=s.primitives;for(let e=0,s=o.length;e<s;e++){const s=o[e];s&&(s.matrices=t,n(s,i,e,r))}}}}function qt(t,e,r){let{componentType:n,byteOffset:i,byteStride:s,itemSize:o}=e;const a=e.array.buffer,c=n?Lt.getTypedArrayCtor(n):e.array.constructor;if(i=void 0===i?e.array.byteOffset:i,s=s||0,!s||s===o*c.BYTES_PER_ELEMENT&&i%c.BYTES_PER_ELEMENT==0){const e=new c(a,i+r*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*c.BYTES_PER_ELEMENT);const l=new Uint8Array(a,s*r+i,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(l),t}function $t(t,e,r,n){t[4*e]=r[n],t[4*e+1]=r[n+4],t[4*e+2]=r[n+8],t[4*e+3]=r[n+12]}const Jt=new Array(3),Qt=new Array(3),te=[40680631590769,40680631590769,40408299984661.445];function ee(t,e,r,n){const i=te,s=Math.cos(r);Jt[0]=s*Math.cos(e),Jt[1]=s*Math.sin(e),Jt[2]=Math.sin(r),ue(Jt,Jt),z(Qt,i,Jt);const o=Math.sqrt(Z(Jt,Qt));var a,c,l;return c=Qt,l=o,(a=Qt)[0]=c[0]/l,a[1]=c[1]/l,a[2]=c[2]/l,Y(Jt,Jt,n),H(t,Qt,Jt)}const re=[1/6378137,1/6378137,1/6356752.314245179],ne=[1/40680631590769,1/40680631590769,1/40408299984661.445],ie=new Array(3),se=new Array(3),oe=new Array(3);function ae(t,e){const r=ne,n=function(t,e,r,n,i){const s=e[0],o=e[1],a=e[2],c=r[0],l=r[1],f=r[2],u=s*s*c*c,h=o*o*l*l,_=a*a*f*f,d=u+h+_,E=Math.sqrt(1/d),T=Y(ce,e,E);if(d<i)return isFinite(E)?T:void 0;const m=n[0],A=n[1],p=n[2],y=le;y[0]=T[0]*m*2,y[1]=T[1]*A*2,y[2]=T[2]*p*2;let g,R,b,I,N,S,w,M,O,v,C,x=(1-E)*fe(e)/(.5*fe(y)),U=0;do{x-=U,b=1/(1+x*m),I=1/(1+x*A),N=1/(1+x*p),S=b*b,w=I*I,M=N*N,O=S*b,v=w*I,C=M*N,g=u*S+h*w+_*M-1,R=u*O*m+h*v*A+_*C*p;U=g/(-2*R)}while(Math.abs(g)>1e-12);return t[0]=s*b,t[1]=o*I,t[2]=a*N,t}(ie,e,re,r,.1);let i=K(se,n,r);i=ue(i,i);const s=j(oe,e,n),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=R(Z(s,e))*fe(s);return t[0]=y(o),t[1]=y(a),t[2]=c,t}const ce=new Array(3),le=new Array(3);function fe(t){return D(t)}function ue(t,e){const r=e[0],n=e[1],i=e[2];let s=r*r+n*n+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function he(t,e){return z(e,t,ne),X(e,e)}function _e(t,e){var r=t[0],n=t[1],i=Math.cos(n),s=i*Math.cos(r),o=i*Math.sin(r),a=Math.sin(n);return e.x=s,e.y=o,e.z=a,X(e,e)}var de=Object.freeze({__proto__:null,radianToCartesian3:ee,cartesian3ToDegree:ae,normalizeCartesian:ue,geodeticSurfaceNormal:he,geodeticSurfaceNormalCartographic:_e});function Ee(t,e,r,n){r=r||0,n=n||r;var i=Math.abs(t-e);return i<=n||i<=r*Math.max(Math.abs(t),Math.abs(e))}function Te(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const me="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ae(t,e,r){const n=new Uint8Array(t,e,r);return me?JSON.parse(me.decode(n)):JSON.parse(I(n))}function pe(t,e,r){const n=new Uint8Array(t,e,r);return me?JSON.parse(me.decode(n)):JSON.parse(I(n))}function ye(t,e,r){return{offset:e,byteLength:r}}function ge(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=we(s||"UNSIGNED_SHORT"),l=Ne(o);return{byteStride:0,byteOffset:i+r,itemSize:l,count:n*l,componentType:c,array:new a(e,r+i,n*l)}}function Re(t,e,r,n){const i=ge(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}function be(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a}=we(s||"UNSIGNED_SHORT"),c=Ne(o),l=new a(e,i,r*c);return 1===c?l[n]:l.subarray(n*c,n*c+c)}const Ie={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ne(t){return t?Ie[t]:1}const Se={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function we(t){return Se[t]}function Me(t){for(let e in Se)if(t===Se[e].ctor)return Se[e].type;throw new Error("unrecognized ctor:"+t)}function Oe(t,e,r,n){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*n[0]+r[0],i[3*t+1]=e[3*t+1]/65535*n[1]+r[1],i[3*t+2]=e[3*t+2]/65535*n[2]+r[2];return i}function ve(t,e,r){let n=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0);const a=t.buffer;let c,l,f={},u={};n>0&&(f=Ae(a,e,n),e+=n),i>0&&(c=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(u=pe(a,e,s),e+=s);const h=ye(0,e,o);return l=a.slice(h.offset,h.offset+h.byteLength),r.push(l),{featureTable:f,featureTableBin:c,batchTable:u,batchTableBin:l}}var Ce={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},xe={},Ue={east:[],north:[],up:[],west:[],south:[],down:[]},Be=[],Pe=[],Le=[];const De=[0,0,0];function Fe(t,e,r){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=e[0],r[13]=e[1],r[14]=e[2],r[15]=t[15],r}const Ge=(ze={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}}[ke="east"][He="north"],xe[Ye=ke+He]?Ve=xe[Ye]:(Ve=function(t,e,r){if(function(t,e){var r=t[0],n=t[1],i=t[2],s=e[0],o=e[1],a=e[2];return Math.abs(r-s)<=x*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-o)<=x*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=x*Math.max(1,Math.abs(i),Math.abs(a))}(t,De))G(Be,Ce[ke]),G(Pe,Ce[He]),G(Le,Ce[ze]);else if(Ee(t[0],0,1e-14)&&Ee(t[1],0,1e-14)){var n=R(t[2]);G(Be,Ce[ke]),"east"!==ke&&"west"!==ke&&Y(Be,Be,n),G(Pe,Ce[He]),"east"!==He&&"west"!==He&&Y(Pe,Pe,n),G(Le,Ce[ze]),"east"!==ze&&"west"!==ze&&Y(Le,Le,n)}else{he(t,Ue.up);var i=Ue.up,s=Ue.east;s[0]=-t[1],s[1]=t[0],s[2]=0,X(Ue.east,s),W(Ue.north,i,s),Y(Ue.down,Ue.up,-1),Y(Ue.west,Ue.east,-1),Y(Ue.south,Ue.north,-1),Be=Ue[ke],Pe=Ue[He],Le=Ue[ze]}return r[0]=Be[0],r[1]=Be[1],r[2]=Be[2],r[3]=0,r[4]=Pe[0],r[5]=Pe[1],r[6]=Pe[2],r[7]=0,r[8]=Le[0],r[9]=Le[1],r[10]=Le[2],r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r},xe[Ye]=Ve),Ve);var ke,He,Ve,ze,Ye;const Xe=[],Ze=[],We=[],je=[],Ke=[],qe=[],$e=[],Je={x:0,y:0},Qe={x:0,y:0},tr=Math.PI/180;const er={"programs":[{"attributes":["aPosition","instanceId","batchId","aTexCoord0","aTexCoord1","aNormal","aColor","uv2","uv3","uv4","secondary_colour","uv6"],"fragmentShader":1,"vertexShader":0}],"shaders":[{"type":35633,"content":"#include <gl2_vert>\n\nuniform mat4 czm_modelViewProjection;\n\nuniform mat4 czm_modelView;\n\nuniform mat3 czm_normal;\n\n\n\nattribute vec4 aPosition;\n\n\n\n#ifdef VertexColor\n\n attribute vec4 aColor;\n\n#endif\n\n#ifdef VertexNormal\n\n attribute vec3 aNormal;\n\n#endif\n\n#ifdef Instance\n\n attribute float instanceId;\n\n#else\n\n attribute float batchId;\n\n#endif\n\n\n\n#ifdef TexCoord\n\n attribute vec4 aTexCoord0;\n\n varying vec4 vTexCoord;\n\n uniform mat4 uTexMatrix;\n\n#ifdef COMPUTE_TEXCOORD\n\n uniform float uTexture0Width;\n\n varying vec4 vTexMatrix;\n\n varying vec4 vTexCoordTransform;\n\n varying vec2 vIsRGBA;\n\n#endif\n\n#endif\n\n\n\n#ifdef TexCoord2\n\n attribute vec4 aTexCoord1;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef InstanceBim\n\n attribute vec4 uv2;\n\n attribute vec4 uv3;\n\n attribute vec4 uv4;\n\n attribute vec4 secondary_colour;\n\n attribute vec4 uv6;\n\n#endif\n\n\n\n uniform vec4 uFillForeColor;\n\n uniform vec4 uSelectedColor;\n\n varying vec4 vSecondColor;\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n varying vec4 vColor;\n\n\n\n const float SHIFT_LEFT8 = 256.0;\n\n const float SHIFT_RIGHT8 = 1.0 / 256.0;\n\n const float SHIFT_RIGHT4 = 1.0 / 16.0;\n\n const float SHIFT_LEFT4 = 16.0;\n\n void getTextureMatrixFromZValue(in float nZ, inout float XTran, inout float YTran, inout float scale, inout float isRGBA)\n\n {\n\n if(nZ <= 0.0)\n\n {\n\n return;\n\n }\n\n float nDel8 = floor(nZ * SHIFT_RIGHT8);\n\n float nDel16 = floor(nDel8 * SHIFT_RIGHT8);\n\n float nDel20 = floor(nDel16 * SHIFT_RIGHT4);\n\n isRGBA = floor(nDel20);\n\n YTran = nZ - nDel8 * SHIFT_LEFT8;\n\n XTran = nDel8 - nDel16 * SHIFT_LEFT8;\n\n float nLevel = nDel16 - nDel20 * SHIFT_LEFT4;\n\n scale = 1.0 / pow(2.0, nLevel);\n\n }\n\n\n\n void operation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor)\n\n {\n\n float right_2 = operationType.x * 0.5;\n\n float right_4 = right_2 * 0.5;\n\n float right_8 = right_4 * 0.5;\n\n float right_16 = right_8 * 0.5;\n\n float isSetColor = fract(right_2);\n\n if(isSetColor > 0.1)\n\n {\n\n vertexColor *= color;\n\n }\n\n float isPicked = fract(floor(right_2)* 0.5);\n\n if(isPicked > 0.1)\n\n {\n\n vertexColor *= selectedColor;\n\n }\n\n float isHide = fract(floor(right_4)* 0.5);\n\n if(isHide > 0.1)\n\n {\n\n vertexColor.a = 0.0;\n\n }\n\n }\n\n\n\n void main()\n\n {\n\n #ifdef TexCoord\n\n vTexCoord.xy = aTexCoord0.xy;\n\n #ifdef COMPUTE_TEXCOORD\n\n vTexMatrix = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.x = 0.0;\n\n vTexCoordTransform.x = aTexCoord0.z;\n\n if(vTexCoordTransform.x < -90000.0)\n\n {\n\n vTexMatrix.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.x), vTexMatrix.x, vTexMatrix.y, vTexMatrix.z, vIsRGBA.x);\n\n vTexMatrix.w = log2(uTexture0Width * vTexMatrix.z);\n\n #endif\n\n #endif\n\n\n\n #ifdef TexCoord2\n\n vTexCoord.zw = aTexCoord1.xy;\n\n vTexMatrix2 = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.y = 0.0;\n\n vTexCoordTransform.y = aTexCoord1.z;\n\n if(vTexCoordTransform.y < -90000.0)\n\n {\n\n vTexMatrix2.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.y), vTexMatrix2.x, vTexMatrix2.y, vTexMatrix2.z, vIsRGBA.y);\n\n vTexMatrix2.w = log2(uTexture1Width * vTexMatrix.z);\n\n #endif\n\n\n\n vec4 vertexPos = aPosition;\n\n vec4 vertexColor = uFillForeColor;\n\n#ifdef VertexColor\n\n vertexColor *= aColor / 255.0;\n\n#endif\n\n#ifdef VertexNormal\n\n vec3 normal = aNormal;\n\n#endif\n\n #ifdef InstanceBim\n\n mat4 worldMatrix;\n\n worldMatrix[0] = uv2;\n\n worldMatrix[1] = uv3;\n\n worldMatrix[2] = uv4;\n\n worldMatrix[3] = vec4(0, 0, 0, 1);\n\n vertexPos = vec4(vertexPos.xyz,1.0) * worldMatrix;\n\n vertexColor *= secondary_colour;\n\n #endif\n\n\n\n\n\n #ifdef Instance\n\n float index = instanceId;\n\n #else\n\n float index = batchId;\n\n #endif\n\n vec4 positionMC = vec4(vertexPos.xyz, 1.0);\n\n vColor = vertexColor;\n\n #ifdef VertexNormal\n\n vNormalEC = czm_normal * normal;\n\n #endif\n\n vPositionMC = positionMC;\n\n vPositionEC = (czm_modelView * positionMC).xyz;\n\n gl_Position = czm_modelViewProjection * vec4(vertexPos.xyz, 1.0);\n\n }\n\n"},{"type":35632,"content":"#ifdef GL_OES_standard_derivatives\n\n #extension GL_OES_standard_derivatives : enable\n\n #define support_standard_derivatives 1\n\n#endif\n\n#ifdef GL_EXT_shader_texture_lod\n\n #extension GL_EXT_shader_texture_lod : enable\n\n #define support_shader_texture_lod 1\n\n#endif\n\n\n\nprecision highp float;\n\n\n\n#include <gl2_frag>\n\n\n\n#if __VERSION__ == 300\n\n #define support_standard_derivatives 1\n\n #define support_shader_texture_lod 1\n\n#endif\n\n\n\n uniform vec3 czm_lightDirectionEC;\n\n uniform vec4 uDiffuseColor;\n\n#ifdef TexCoord\n\n varying vec4 vTexCoord;\n\n#ifdef COMPUTE_TEXCOORD\n\n uniform sampler2D uTexture;\n\n uniform highp float uTexture0Width;\n\n varying vec4 vTexCoordTransform;\n\n varying vec4 vTexMatrix;\n\n varying vec2 vIsRGBA;\n\n#endif\n\n#endif\n\n\n\n varying vec4 vColor;\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n#ifdef TexCoord2\n\n uniform sampler2D uTexture2;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef COMPUTE_TEXCOORD\n\n void calculateMipLevel(in vec2 inTexCoord, in float vecTile, in float fMaxMip, inout float mipLevel)\n\n {\n\n vec2 dx = dFdx(inTexCoord * vecTile);\n\n vec2 dy = dFdy(inTexCoord * vecTile);\n\n float dotX = dot(dx, dx);\n\n float dotY = dot(dy, dy);\n\n float dMax = max(dotX, dotY);\n\n float dMin = min(dotX, dotY);\n\n float offset = (dMax - dMin) / (dMax + dMin);\n\n offset = clamp(offset, 0.0, 1.0);\n\n float d = dMax * (1.0 - offset) + dMin * offset;\n\n mipLevel = 0.5 * log2(d);\n\n mipLevel = clamp(mipLevel, 0.0, fMaxMip - 1.62);\n\n }\n\n\n\n void calculateTexCoord(in vec3 inTexCoord, in float scale, in float XTran, in float YTran, in float fTile, in float mipLevel, inout vec2 outTexCoord)\n\n {\n\n if(inTexCoord.z < -9000.0)\n\n {\n\n outTexCoord = inTexCoord.xy;\n\n }\n\n else\n\n {\n\n vec2 fTexCoord = fract(inTexCoord.xy);\n\n float offset = 1.0 * pow(2.0, mipLevel) / fTile;\n\n fTexCoord = clamp(fTexCoord, offset, 1.0 - offset);\n\n outTexCoord.x = (fTexCoord.x + XTran) * scale;\n\n outTexCoord.y = (fTexCoord.y + YTran) * scale;\n\n }\n\n }\n\n\n\n vec4 getTexColorForS3M(sampler2D curTexture, vec3 oriTexCoord, float texTileWidth, float fMaxMipLev, float fTexCoordScale, vec2 vecTexCoordTranslate, float isRGBA)\n\n {\n\n vec4 color = vec4(1.0);\n\n float mipLevel = 0.0;\n\n #ifdef support_standard_derivatives\n\n calculateMipLevel(oriTexCoord.xy, texTileWidth, fMaxMipLev, mipLevel);\n\n #endif\n\n vec2 realTexCoord;\n\n calculateTexCoord(oriTexCoord, fTexCoordScale, vecTexCoordTranslate.x, vecTexCoordTranslate.y, texTileWidth, mipLevel, realTexCoord);\n\n if(isRGBA > 0.5)\n\n {\n\n vec2 rgbTexCoord;\n\n rgbTexCoord.x = (realTexCoord.x + vecTexCoordTranslate.x * fTexCoordScale) * 0.5;\n\n rgbTexCoord.y = (realTexCoord.y + vecTexCoordTranslate.y * fTexCoordScale) * 0.5;\n\n color = texture2D(curTexture, rgbTexCoord.xy, -10.0);\n\n vec2 vecAlphaTexCoord;\n\n vecAlphaTexCoord.x = rgbTexCoord.x;\n\n vecAlphaTexCoord.y = rgbTexCoord.y + fTexCoordScale * 0.5;\n\n color.a = texture2D(curTexture, vecAlphaTexCoord.xy, -10.0).r;\n\n }\n\n else\n\n {\n\n if(oriTexCoord.z < -9000.0)\n\n {\n\n color = texture2D(curTexture, realTexCoord.xy);\n\n }\n\n else\n\n {\n\n #ifdef support_shader_texture_lod\n\n color = texture2DLodEXT(curTexture, realTexCoord.xy, mipLevel);\n\n #else\n\n color = texture2D(curTexture, realTexCoord.xy, mipLevel);\n\n #endif\n\n }\n\n }\n\n\n\n return color;\n\n }\n\n\n\n vec4 getTextureColor()\n\n {\n\n if(vTexMatrix.z < 0.0)\n\n {\n\n return vec4(1.0);\n\n }\n\n float texTileWidth0 = vTexMatrix.z * uTexture0Width;\n\n vec3 realTexCoord = vec3(vTexCoord.xy, vTexCoordTransform.x);\n\n vec4 FColor = getTexColorForS3M(uTexture, realTexCoord, texTileWidth0, vTexMatrix.w, vTexMatrix.z, vTexMatrix.xy, vIsRGBA.x);\n\n #ifdef TexCoord2\n\n float texTileWidth1 = vTexMatrix2.z * uTexture1Width;\n\n realTexCoord = vec3(vTexCoord.zw, vTexCoordTransform.y);\n\n vec4 SColor = getTexColorForS3M(uTexture2, realTexCoord, texTileWidth1, vTexMatrix2.w, vTexMatrix2.z, vTexMatrix2.xy, vIsRGBA.y);\n\n SColor.r = clamp(SColor.r, 0.0, 1.0);\n\n SColor.g = clamp(SColor.g, 0.0, 1.0);\n\n SColor.b = clamp(SColor.b, 0.0, 1.0);\n\n return FColor * SColor;\n\n #else\n\n return FColor;\n\n #endif\n\n }\n\n#endif\n\n vec4 SRGBtoLINEAR4(vec4 srgbIn)\n\n {\n\n #ifndef HDR\n\n vec3 linearOut = pow(srgbIn.rgb, vec3(2.2));\n\n return vec4(linearOut, srgbIn.a);\n\n #else\n\n return srgbIn;\n\n #endif\n\n }\n\n vec3 LINEARtoSRGB(vec3 linearIn)\n\n {\n\n #ifndef HDR\n\n return pow(linearIn, vec3(1.0/2.2));\n\n #else\n\n return linearIn;\n\n #endif\n\n }\n\n\n\n vec3 computeNormal(in vec3 oriVertex)\n\n {\n\n vec3 normal = cross(vec3(dFdx(oriVertex.x), dFdx(oriVertex.y), dFdx(oriVertex.z)), vec3(dFdy(oriVertex.x), dFdy(oriVertex.y), dFdy(oriVertex.z)));\n\n normal = normalize(normal);\n\n return normal;\n\n }\n\n\n\n void main()\n\n {\n\n if(vColor.a < 0.1)\n\n {\n\n discard;\n\n }\n\n vec4 baseColorWithAlpha = vColor;\n\n #ifdef COMPUTE_TEXCOORD\n\n baseColorWithAlpha *= SRGBtoLINEAR4(getTextureColor());\n\n #endif\n\n\n\n if(baseColorWithAlpha.a < 0.1)\n\n {\n\n discard;\n\n }\n\n vec3 normal = vec3(0.0);\n\n #ifdef VertexNormal\n\n normal = normalize(vNormalEC);\n\n #endif\n\n normal = length(normal) > 0.1 ? normal : computeNormal(vPositionMC.xyz);\n\n vec3 color = baseColorWithAlpha.rgb;\n\n vec3 dirVectorEC = normalize(czm_lightDirectionEC);\n\n float dotProduct = dot( normal, dirVectorEC );\n\n float dirDiffuseWeight = max( dotProduct, 0.0 );\n\n dirDiffuseWeight = dirDiffuseWeight * 0.5 + 0.5;\n\n color += color * uDiffuseColor.rgb * dirDiffuseWeight;\n\n #ifdef TexCoord\n\n color = LINEARtoSRGB(color);\n\n #endif\n\n glFragColor = vec4(color, baseColorWithAlpha.a);\n\n#if __VERSION__ == 100\n\n gl_FragColor = glFragColor;\n\n#endif\n\n }\n\n"}],"techniques":[{"attributes":{"aPosition":{"semantic":"POSITION","type":35666},"instanceId":{"semantic":"instanceId","type":5126},"batchId":{"semantic":"_BATCHID","type":5126},"aTexCoord0":{"semantic":"TEXCOORD_0","type":35664},"aTexCoord1":{"semantic":"aTexCoord1","type":35666},"aNormal":{"semantic":"aNormal","type":35665},"aColor":{"semantic":"COLOR_0","type":35666},"uv2":{"semantic":"uv2","type":35666},"uv3":{"semantic":"uv3","type":35666},"uv4":{"semantic":"uv4","type":35666},"secondary_colour":{"semantic":"secondary_colour","type":35666},"uv6":{"semantic":"uv6","type":35666}},"program":0,"uniforms":{"czm_modelView":{"type":35676,"semantic":"MODELVIEW"},"czm_normal":{"type":35675,"semantic":"MODELINVERSETRANSPOSE"},"czm_modelViewProjection":{"type":35676,"semantic":"MODELVIEWPROJECTION"},"uTexMatrix":{"type":35676},"uTexture0Width":{"type":5126},"uFillForeColor":{"type":35666},"uSelectedColor":{"type":35666},"uDiffuseColor":{"type":35666},"uTexture":{"type":35678},"uTexture2":{"type":35678},"uTexture1Width":{"type":5126}}}]},{getTextureMagFilter:rr,getTextureMinFilter:nr,getTextureWrap:ir,getMaterialType:sr,getMaterialFormat:or,getPrimitive:ar,getUniqueREGLBuffer:cr}=r.reshader.REGLHelper,lr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],fr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:ur,logoutIBLResOnCanvas:hr,getIBLResOnCanvas:_r,getPBRUniforms:dr}=r.reshader.pbr.PBRUtils,Er={factor:0,units:0},Tr={specularStrength:0,materialShininess:1},mr=[1,1,1],Ar=r.mat4.identity([]),pr=t=>t.material instanceof r.reshader.PhongMaterial,yr=t=>t.material instanceof r.reshader.pbr.StandardMaterial,gr=[!0,!0,!0,!0],Rr=[],br=new i.Coordinate(0,0),Ir=[],Nr=[],Sr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"};class wr{constructor(t,e){this.tt=e,this.et=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.rt=new i.SpatialReference,this.nt=t,this.it=new r.reshader.Renderer(t),this.st={},this.ot={},this.ct={},this.lt={},this.ft={},this.ut={},this.ht={},this._t=new r.reshader.Scene,this.dt=new r.reshader.Scene,this.Et=new r.reshader.Scene,this.Tt=new r.reshader.Scene,this.At=new r.reshader.ResourceLoader(t.texture(2)),this.yt=this.gt.bind(this),this.Rt=new r.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}),this.bt(),this.It=new r.reshader.KHRTechniquesWebglManager(this.nt,this.Nt(),this.At)}getI3DMMeshes(){return this.ft}getPNTSMeshes(){return this.lt}getB3DMMeshes(){return this.ct}getPaintedMeshes(){return this.St}getMap(){return this.tt.getMap()}paint(t,e,r,n){const i=this.getMap();if(!t.length||!i)return;const s=this.wt(),o=i.projViewMatrix,a=this.tt.options.services,c=[],l=[];let u=[];const h=[],_=[];for(let r=0,n=t.length;r<n;r++){const n=t[r].data.node;let i=this.Mt(n);if(!i)continue;this.ut[n.id]&&(i=this.ut[n.id],i=S(i));let d=a[n.Ot].polygonOffset||Er;m(d)&&(d=d());const E=a[n.Ot].ambientLight;Array.isArray(i)||(c[0]=i,i=c);for(let a=0,c=i.length;a<c;a++){if(i[a].getBoundingBox&&!f(o,i[a].getBoundingBox()))continue;const c=i[a].properties.magic;"b3dm"===c?u.push(i[a]):"pnts"===c?h.push(i[a]):"i3dm"===c&&_.push(i[a]),i[a].properties.level=t[r].selectionDepth,i[a].properties.polygonOffset=d,Object.prototype.hasOwnProperty.call(i[a].uniforms,"ambientColor")||Object.defineProperty(i[a].uniforms,"ambientColor",{enumerable:!0,get:function(){return E||s.ambientColor}}),i[a].vt=n,e[n.id]||l.push(i[a])}}let d=0;const E=this.It.getExcludeFilter();d+=this.Ct(this.xt,s,[r,pr,E],n,l,u,_),d+=this.Ct(this.Ut,s,[r,yr,E],n,l,u,_),this.It.forEachShader(((t,e,i)=>{const s=this.wt(i);d+=this.Ct(t,s,[r,e],n,l,u,_)})),this.dt.setMeshes(h);const T=this.Bt();return d+=this.it.render(this.Pt,T,this.dt,n&&n.fbo),this.St={pntsMeshes:h,i3dmMeshes:_,b3dmMeshes:u},d}Ct(t,e,r,n,i,s,o){t.filter=r.filter((t=>!!t)),e.debug=!1,this._t.setMeshes(i),e.stencilEnable=!1,e.debug=!1,e.cullFace="back",e.colorMask=gr;let a=0;return this._t.setMeshes(s),a+=this.it.render(t,e,this._t,n&&n.fbo),e.stencilEnable=!1,this.Et.setMeshes(o),a+=this.it.render(t,e,this.Et,n&&n.fbo),a}Lt(t,e){return e.vt.Dt-t.vt.Dt}paintRegion(t,e,r,n,i){const s=this.getMap();if(!t.length&&!e.length)return;const o=s.projViewMatrix,a=[];for(let r=0,n=(t=t.concat(e)).length;r<n;r++){const e=t[r].node,n=this.Ft(e);n&&(n.getBoundingBox&&!f(o,n.getBoundingBox())||a.push(n))}this.Gt.filter=n,this.Tt.setMeshes(a);const c=this.kt(r);this.it.render(this.Gt,c,this.Tt,i&&i.fbo)}deleteTile(t){const e=t.node.id;this.Ht(e)}Ht(t){const e=this.ot[t];e&&(e.geometry.dispose(),e.dispose(),delete this.ot[t]);let r=this.ct[t]||this.lt[t]||this.ft[t]||this.ut[t]||this.st[t];this.ut[t]?this.Vt(t):r&&(this.zt(r),delete this.ct[t],delete this.lt[t],delete this.ft[t],delete this.st[t])}Vt(t){let e=this.ut[t];e=S(e);for(let t=0;t<e.length;t++){const{id:r}=e[t].properties;this.Ht(r)}delete this.ut[t]}zt(t){if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++)this.zt(t[e]);else{const e=t.geometry.properties.url;if(e){const t=this.ht[e];t&&(t.refCount--,t.refCount<=0&&(t.geometry.dispose(),t.material.dispose(),delete this.ht[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.tt;hr(t.getRenderer().canvas,t.getMap());for(const t in this.ut)this.Vt(t);this.ut={};for(const t in this.ct)this.Ht(t);this.ct={};for(const t in this.lt)this.Ht(t);this.lt={};for(const t in this.ft)this.Ht(t);this.ft={};for(const t in this.st)this.Ht(t);this.st={};for(const t in this.ot)this.Ht(t);this.ot={},this.xt&&(this.xt.dispose(),delete this.xt),this.Ut&&(this.Ut.dispose(),delete this.Ut),this.Pt&&(this.Pt.dispose(),delete this.Pt),this.Gt&&(this.Gt.dispose(),delete this.Gt),this.It.dispose(),this.picking&&this.picking.dispose()}Ft(t){if(!t.boundingVolume||!t.boundingVolume.region)return null;if(this.ot[t.id])return this.ot[t.id];const e=t.boundingVolume.region;let n=new i.Coordinate(y(e[0]),y(e[1])),s=new i.Coordinate(y(e[2]),y(e[3]));n=this.Yt(n),s=this.Yt(s);const o=n.add(s).Xt(.5);n._sub(o),s._sub(o);const a=this.Zt(e[4],e[5]),c=a.x,l=a.y,f=[n.x,n.y,l,s.x,n.y,l,s.x,s.y,l,n.x,s.y,l,n.x,n.y,c,s.x,n.y,c,s.x,s.y,c,n.x,s.y,c],u=new r.reshader.Geometry({aPosition:f},[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],0,{primitive:"lines"});u.generateBuffers(this.nt);const h=new r.reshader.Mesh(u),_=r.mat4.identity([]);return h.setLocalTransform(r.mat4.translate(_,_,[o.x,o.y,0])),this.ot[t.id]=h,h}Mt(t){return this.ct[t.id]||this.lt[t.id]||this.ft[t.id]||this.ut[t.id]}has(t){return this.Mt(t)||this.st[t.id]}createPntsMesh(t,e,n,i){if(this.lt[e]){const t=this.lt[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:s,featureTable:o,rootIdx:a}=t,c=o.POINTS_LENGTH,l=new r.reshader.Geometry(s,null,c,{primitive:"points",positionAttribute:"POSITION"});l.generateBuffers(this.nt);const f={};s.POSITION?f.HAS_POSITION=1:s.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),s.RGB?f.HAS_RGB=1:s.RGBA?f.HAS_RGBA=1:s.RGB565&&(f.HAS_RGB565=1),(s.NORMAL||s.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,s.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:u,rtcCoord:h}=t,_=this.Wt(h),d=this.jt(n,u,h);r.mat4.multiply(d,d,_);const E=this.tt.options.services[a],T=new r.reshader.Mesh(l);return T.properties.magic="pnts",T.properties.id=e,T.properties.count=c,T.properties.batchTable=t.batchTable,T.properties.batchTableBin=t.batchTableBin,T.setDefines(f),Object.defineProperty(T.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:E&&E.pointColor||[1,1,1,1]}}),Object.defineProperty(T.uniforms,"pointSize",{enumerable:!0,get:function(){return E&&E.pointSize||2}}),Object.defineProperty(T.uniforms,"pointOpacity",{enumerable:!0,get:function(){return E&&E.pointOpacity||1}}),T.setLocalTransform(d),this.lt[e]=T,i(null,{id:e,mesh:[T]}),[T]}createI3DMMesh(t,e,n,i){if(this.ft[e]){const t=this.ft[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.st[e]||i(null,{id:e,mesh:t}),t}const s=this.Kt(n.qt),{i3dm:o,featureTable:a,gltf:c,batchTable:l,batchTableBin:f,count:u}=t,h=a.INSTANCES_LENGTH,{rtcCenter:_,rtcCoord:d}=t,E=this.Wt(d),T=this.jt(n,_,d),{POSITION:m,NORMAL_UP:A,NORMAL_RIGHT:p,SCALE:y,SCALE_NON_UNIFORM:g,INSTANCE_ROTATION:R}=o,b={"instance_vectorA":new Float32Array(4*h),"instance_vectorB":new Float32Array(4*h),"instance_vectorC":new Float32Array(4*h)},I=new Float32Array(3),S=new Float32Array(3),w=[],M=new Float32Array(1),O=new Float32Array(3),v=[],C=[],x=[],U=[],B=new Float32Array(9);!function(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:o}=t;const a=t.array.buffer,c=r?Lt.getTypedArrayCtor(r):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,i=i||0,s=s||t.array.length/o,(!i||i===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const l=new Uint8Array(o*c.BYTES_PER_ELEMENT);i||(i=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(a,i*t+n,o*c.BYTES_PER_ELEMENT);l.set(r),e(new c(l.buffer),t),r.set(l)}}(m,((t,e)=>{A?(qt(S,p,e),qt(I,A,e),r.vec3.cross(w,S,I),r.vec3.normalize(w,w),N(v,S,0),N(v,I,1),N(v,w,2),r.quat.fromMat3(C,v)):R?(qt(B,R,e),r.quat.fromMat3(C,B)):r.quat.identity(C),y?(qt(M,y,e),r.vec3.set(x,M[0],M[0],M[0])):g?(qt(O,g,e),r.vec3.set(x,...O)):r.vec3.set(x,1,1,1),r.mat4.fromRotationTranslationScale(U,C,t,x),$t(b.instance_vectorA,e,U,0),$t(b.instance_vectorB,e,U,1),$t(b.instance_vectorC,e,U,2)}));const P={};for(const t in b)P[t]={buffer:this.nt.buffer({dimension:b[t].length/h,data:b[t]}),divisor:1};const L=this.tt.options.services[n.Ot].shader||"phong";let D=0,F=!0;const G=[];return jt(c,((t,i,o,a)=>{let{geometry:c,material:_}=this.$t(t,i,o,a,n,!0,L);_&&!_.isReady()&&(F=!1,D++);const d=new r.reshader.InstancedMesh(P,h,c,_);d.properties.magic="i3dm",d.properties.id=e,d.properties.count=u,d.properties.batchTable=l,d.properties.batchTableBin=f;const m=this.Jt(t,c,_,n.Ot,a),A=r.mat4.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.mat4.multiply(A,A,t.matrices[e]);r.mat4.multiply(A,s,A),d.setPositionMatrix(A),r.mat4.multiply(E,T,E),d.setLocalTransform(E),d.setDefines(m),d.properties.polygonOffset={offset:0,factor:0},G.push(d)})),F?(this.ft[e]=G,i(null,{id:e,mesh:G})):(this.st[e]={meshes:G,count:D},G.Qt=i),G}createB3DMMesh(t,e,n,s){if(this.ct[e]||this.st[e]){const t=this.ct[e];return console.warn(`mesh with id(${e}) was already created.`),this.st[e]||s(null,{id:e,mesh:t}),t}const o=t.gltf.asset&&"i3s"===t.gltf.asset.generator;let a;if(n.maxExtent){const t=new i.Extent(n.maxExtent).convertTo((t=>this._pointToPrj(t)));a=[t.xmin,t.ymin,t.xmax,t.ymax]}const c=this.Kt(n.qt),l=t.gltf,{center:f,coord:u}=l.extensions.CESIUM_RTC,h=this.tt.options.services[n.Ot].heightOffset||0;let _;if(h&&u&&(u[2]+=h),o){const{i3sProjCenter:t}=l.extensions.CESIUM_RTC;_=this.te(t,n.Ot)}else _=this.Wt(u,n.Ot);const d=this.tt.options.services[n.Ot].shader||"phong",E=[];let T=0,m=!0;return jt(l,((i,s,l,h)=>{let{geometry:A,material:p}=this.$t(i,s,l,h,n,!1,d);p&&!p.isReady()&&(m=!1,T++);const y=new r.reshader.Mesh(A,p);y.properties.magic="b3dm",y.properties.id=e,y.properties.batchTable=t.batchTable,y.properties.batchTableBin=t.batchTableBin,y.properties.count=t.featureTable.BATCH_LENGTH;const g=this.Jt(i,A,p,n.Ot,h);y.setDefines(g),a&&(g.USE_MAX_EXTENT=1,y.setUniform("maxPrjExtent",a));let R=r.mat4.identity([]);if(i.matrices&&i.matrices.length)for(let t=0;t<i.matrices.length;t++)r.mat4.multiply(R,R,i.matrices[t]);const b=o?Ar:this.jt(n,f,u);r.mat4.multiply(R,c,R),r.mat4.multiply(R,_,R),r.mat4.multiply(R,b,R),y.setLocalTransform(R),E.push(y)})),m?(this.ct[e]=E,s(null,{id:e,mesh:E})):(this.st[e]={meshes:E,count:T},E.Qt=s),E}jt(t,e,n){const s=this.getMap(),o=this.tt.options.services[t.Ot].heightOffset||0,a=new i.Coordinate(n),c=s.distanceToPointAtRes(100,0,s.getGLRes(),a).x/100;let l=t.matrix?r.mat4.copy([],t.matrix):r.mat4.identity([]);if(e){Fe(l,r.vec3.transformMat4(Rr,e,l),l)}const f=function(t,e,r,n,i,s,o){e=G(Xe,e);const a=ee(Xe,e[0]*tr,e[1]*tr,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(Ze,r),l=n.ellipsoid;var f;f=0===q(c)?k(We,0,0,-6378137):ae(We,c),Je.x=f[0],Je.y=f[1];const u=n.project(Je,Qe);je[0]=u.x/i,je[1]=u.y/i,je[2]=(f[2]+o)*s;const h=Ge(a,l,Ke),_=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],_=e[11],d=e[12],E=e[13],T=e[14],m=e[15],A=r*a-n*o,p=r*c-i*o,y=r*l-s*o,g=n*c-i*a,R=n*l-s*a,b=i*l-s*c,I=f*E-u*d,N=f*T-h*d,S=f*m-_*d,w=u*T-h*E,M=u*m-_*E,O=h*m-_*T,v=A*O-p*M+y*w+g*S-R*N+b*I;return v?(v=1/v,t[0]=(a*O-c*M+l*w)*v,t[1]=(i*M-n*O-s*w)*v,t[2]=(E*b-T*R+m*g)*v,t[3]=(h*R-u*b-_*g)*v,t[4]=(c*S-o*O-l*N)*v,t[5]=(r*O-i*S+s*N)*v,t[6]=(T*y-d*b-m*p)*v,t[7]=(f*b-h*y+_*p)*v,t[8]=(o*M-a*S+l*I)*v,t[9]=(n*S-r*M-s*I)*v,t[10]=(d*R-E*y+m*A)*v,t[11]=(u*y-f*R-_*A)*v,t[12]=(a*N-o*w-c*I)*v,t[13]=(r*w-n*N+i*I)*v,t[14]=(E*p-d*g-T*A)*v,t[15]=(f*g-u*p+h*A)*v,t):null}(qe,h),d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}($e,r),E=function(t,e,r){var n=t[0],i=t[1],s=t[2],o=t[4],a=t[5],c=t[6],l=t[8],f=t[9],u=t[10],h=e[0],_=e[1],d=e[2],E=e[3],T=e[4],m=e[5],A=e[6],p=e[7],y=e[8],g=n*h+o*_+l*d,R=i*h+a*_+f*d,b=s*h+c*_+u*d,I=n*E+o*T+l*m,N=i*E+a*T+f*m,S=s*E+c*T+u*m,w=n*A+o*p+l*y,M=i*A+a*p+f*y,O=s*A+c*p+u*y;return r[0]=g,r[1]=R,r[2]=b,r[3]=0,r[4]=I,r[5]=N,r[6]=S,r[7]=0,r[8]=w,r[9]=M,r[10]=O,r[11]=0,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r}(_,d,t);return Fe(t,je,E),t}(l,n,l,s.getProjection(),s.getGLRes(),c,o),u=function(t,e){return k(t,e[12],e[13],e[14]),t}(Nr,f);let h=this.tt.options.offset;if(m(h)){h=h(this.tt.ee(t.id).center)}return r.vec3.set(Ir,h[0],h[1],0),r.vec3.sub(u,u,Ir),Fe(f,u,f),f}createCMPTMesh(t,e,r,n){if(this.ut[e]){const t=this.ut[e];return console.warn(`mesh with id(${e}) was already created.`),n(null,{id:e,mesh:t}),t}const{content:i}=t,s=[];for(let t=0;t<i.length;t++){const{magic:n}=i[t],o=e+"."+t;"b3dm"===n?this.createB3DMMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"i3dm"===n?this.createI3DMMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"pnts"===n?this.createPntsMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"cmpt"===n&&this.createCMPTMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)}))}return this.ut[e]=s,n(null,{id:e,mesh:s}),s}Jt(t,e,r,n,i){const s=("phong"===(this.tt.options.services[n].shader||"phong")?this.xt:this.Ut).getGeometryDefines(e);return i.asset&&"S3M"===i.asset.generator&&this.re(s,e,i),s}re(t,e,r){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1),e.data.aTexCoord0&&r.textures.length&&(t.COMPUTE_TEXCOORD=1)}$t(t,e,r,n,i,s,o){let a=!1;n.asset&&"S3M"===n.asset.generator&&(a=!0,n.extensions=n.extensions||{},n.extensions.KHR_techniques_webgl=er);const c=n.url+"-"+e+"-"+r;if(this.ht[c])return this.ht[c].refCount++,this.ht[c];let l,f;const u=n.materials[t.material];if(n.extensions&&n.extensions.KHR_techniques_webgl&&u.extensions&&u.extensions.KHR_techniques_webgl){const e=this.ne(t,n,s,a);l=e.material,f=e.geometry;this.tt.options.services[i.Ot].fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.ie(t,s,Sr);const e=this.tt.options.services[i.Ot].material;l=this.se(t.material,n,o,e||Tr)}l&&!l.isReady()?l.oe=i.id:l||(l=this.Rt);const h={refCount:1,geometry:f,material:l};return f.properties.url=c,this.ht[c]=h,h}ne(t,e,r,n){const{geometry:i,material:s}=this.It.createMesh(t,e,r,n);return{geometry:i,material:s}}ie(t,e,n){const i=t.attributes;if(i.COLOR_0){const t=i.COLOR_0.array||i.COLOR_0;if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let r=0;r<e.length;r++)e[r]=Math.round(255*t[r]);i.COLOR_0.array?(i.COLOR_0.array=e,i.COLOR_0.componentType=5121):i.COLOR_0=e}}const s={};for(const t in i){const e=cr(this.nt,i[t],{dimension:i[t].itemSize}),r=n[t]||t;s[r]={buffer:e},i[t].quantization&&(s[r].quantization=i[t].quantization),r===n.POSITION&&(s[r].array=i[t].array,s[r].min=i[t].min,s[r].max=i[t].max)}delete t.attributes;const o=new r.reshader.Geometry(s,t.indices?t.indices.array?t.indices.array.slice():t.indices:null,0,{positionAttribute:n.POSITION,normalAttribute:n.NORMAL,uv0Attribute:n.TEXCOORD_0,uv1Attribute:n.TEXCOORD_1,color0Attribute:n.COLOR_0,tangentAttribute:n.TANGENT,pickingIdAttribute:n._BATCHID,primitive:void 0===t.mode?"triangles":ar(t.mode)});return o.generateBuffers(this.nt,{excludeElementsInVAO:e}),o}Wt(t){const e=r.mat4.identity([]),n=this.getMap(),i=this.ae();br.x=t[0],br.y=t[1];const s=n.distanceToPointAtRes(100,100,n.getGLRes(),br);return r.vec3.set(i,s.x/100*1.01,s.y/100*1.01,s.y/100),r.mat4.scale(e,e,i),e}te(t,e){const n=r.mat4.identity([]),s=this.getMap(),o=this._prjToPoint(new i.Coordinate(t)),a=this.ae(),c=1/(s.getGLZoom?s.getResolution(s.getGLZoom()):s.getGLRes()),l=r.vec3.set(Nr,o.x,o.y,c*t[2]);r.mat4.translate(n,n,l);const f=this.tt.options.services[e].heightOffset;if(f){const e=s.getProjection().unproject(new i.Coordinate(t)),o=s.distanceToPointAtRes(100,100,s.getGLRes(),e).y/100;r.mat4.translate(n,n,[0,0,f*o])}return r.mat4.scale(n,n,r.vec3.scale([],a,c)),n}bt(){const t={x:0,y:0,width:()=>this.et?this.et.width:1,height:()=>this.et?this.et.height:1};this.Gt=new r.reshader.MeshShader({vert:"attribute vec3 aPosition;\n\n\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main() {\n\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n}\n\n",frag:"precision mediump float;\nuniform vec3 color;\nvoid main() {\n gl_FragColor = vec4(color, 1.0);\n}\n",uniforms:["color",{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.mat4.multiply([],e.projViewMatrix,e.modelMatrix)}],extraCommandProps:{viewport:t}});const e=[],n=[];this.Pt=new r.reshader.MeshShader({vert:"const float SHIFT_RIGHT_11 = 1.0 / 2048.0;\n\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\n\nconst float SHIFT_LEFT_11 = 2048.0;\n\nconst float SHIFT_LEFT_5 = 32.0;\n\nconst float NORMALIZE_6 = 1.0 / 64.0;\n\nconst float NORMALIZE_5 = 1.0 / 32.0;\n\n\n\n#ifdef HAS_POSITION\n\n attribute vec3 POSITION;\n\n#endif\n\n\n\n#if defined(HAS_RGB)\n\n attribute vec3 RGB;\n\n#elif defined(HAS_RGBA)\n\n attribute vec4 RGBA;\n\n#elif defined(HAS_RGB565)\n\n attribute float RGB565;\n\n#endif\n\n\n\nuniform vec4 pointColor;\n\nuniform float pointSize;\n\n\n\nuniform mat4 projViewModelMatrix;\n\nuniform float pointOpacity;\n\n\n\nvarying vec4 vColor;\n\n\n\n#ifdef HAS_NORMAL\n\n #ifdef HAS_NORMAL_OCT16P\n\n attribute vec2 NORMAL_OCT16P;\n\n float signNotZero(float value) {\n\n return value >= 0.0 ? 1.0 : -1.0;\n\n }\n\n vec2 signNotZero(vec2 value) {\n\n return vec2(signNotZero(value.x), signNotZero(value.y));\n\n }\n\n vec3 octDecode(vec2 encoded, float range) {\n\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n\n return vec3(0.0, 0.0, 0.0);\n\n }\n\n encoded = encoded / range * 2.0 - 1.0;\n\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n\n if (v.z < 0.0) {\n\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n\n }\n\n return normalize(v);\n\n }\n\n vec3 octDecode(vec2 encoded) {\n\n return octDecode(encoded, 255.0);\n\n }\n\n #else\n\n attribute vec3 NORMAL;\n\n #endif\n\n uniform vec3 lightDir;\n\n uniform mat3 modelNormalMatrix;\n\n uniform mat4 positionMatrix;\n\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n\n return max(dot(-lightDir, normal), 0.0);\n\n }\n\n#endif\n\n\n\nvoid main() {\n\n #if defined(HAS_RGB)\n\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n\n #elif defined(HAS_RGBA)\n\n vColor = RGBA / 255.0 * pointOpacity;\n\n #elif defined(HAS_RGB565)\n\n float compressed = RGB565;\n\n float r = floor(compressed * SHIFT_RIGHT_11);\n\n compressed -= r * SHIFT_LEFT_11;\n\n float g = floor(compressed * SHIFT_RIGHT_5);\n\n compressed -= g * SHIFT_LEFT_5;\n\n float b = compressed;\n\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n\n vColor = vec4(rgb, 1.0);\n\n #else\n\n vColor = pointColor;\n\n #endif\n\n\n\n #ifdef HAS_POSITION\n\n vec3 localPos = POSITION;\n\n #endif\n\n\n\n #ifdef HAS_NORMAL\n\n mat3 positionNormalMatrix = mat3(positionMatrix);\n\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n\n #ifdef HAS_NORMAL_OCT16P\n\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n\n #else\n\n vec3 localNormal = NORMAL;\n\n #endif\n\n vec3 normal = normalize(normalMatrix * localNormal);\n\n float colorStrength = getLambertDiffuse(lightDir, normal);\n\n colorStrength = max(colorStrength, 0.5);\n\n vColor *= colorStrength;\n\n #endif\n\n\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n}\n\n",frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n gl_FragColor = vColor;\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.mat4.multiply(n,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,n)=>r.mat3.fromMat4(e,n.modelMatrix)}],extraCommandProps:{viewport:t,blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const i=this.Nt();this.xt=new r.reshader.PhongShader({extraCommandProps:i}),this.Ut=new r.reshader.pbr.StandardShader({extraCommandProps:i});const s=this.tt;ur(s.getRenderer().canvas,this.nt,s.getMap()),this.picking=new r.reshader.FBORayPicking(this.it,{vert:this.Ut.vert,extraCommandProps:i,uniforms:this.Ut.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO)}Nt(){return{viewport:{x:0,y:0,width:()=>this.et?this.et.width:1,height:()=>this.et?this.et.height:1},colorMask:(t,e)=>e.colorMask||gr,cull:{enable:!0,face:(t,e)=>e.cullFace||"back"},stencil:{enable:(t,e)=>!0===e.stencilEnable,func:{cmp:">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}kt(t){return{projViewMatrix:this.getMap().projViewMatrix,color:t&&t.color||[0,1,0]}}Bt(t){const e=this.getMap(),n=e.getLightManager(),i=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:r.vec3.normalize(i,i)}}wt(){const t=this.getMap(),e=this.tt.getRenderer().canvas,{iblTexes:r,dfgLUT:n}=_r(e),i=dr(t,r,n);return T(i,{czm_lightDirectionEC:i.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[e.width,e.height],polygonFill:[1,1,1,1],polygonOpacity:1}),i}se(t,e,n,i){const s=e.materials[t];if(!s||!s.baseColorTexture&&!s.pbrMetallicRoughness)return null;const o=T({},i);if(s.baseColorTexture){const t=e.textures[s.baseColorTexture.index];let r;t&&!t.image.color&&(r=this.M(t)),o.baseColorFactor=t&&t.image.color||s.baseColorFactor||[1,1,1,1],r&&(o.baseColorTexture=r)}else{if(s.normalTexture){const t=this.M(e.textures[s.normalTexture.index]),r=s.normalTexture.scale||1;o.normalTexture=t,o.normalMapFactor=r}if(s.occlusionTexture){const t=this.M(e.textures[s.occlusionTexture.index]),r=s.occlusionTexture.strength||1;o.occlusionTexture=t,o.occlusionFactor=r}if(s.emissiveTexture){const t=this.M(e.textures[s.emissiveTexture.index]);o.emissiveTexture=t}s.emissiveFactor;const t=s.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(o.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];n.image&&n.image.color?o.baseColorFactor=o.baseColorFactor?r.vec4.multiply(o.baseColorFactor,o.baseColorFactor,n.image.color):n.image.color:(o.baseColorTexture=this.M(n),o.baseColorTexture.getREGLTexture(this.nt))}if(E(t.metallicFactor)||(o.metallicFactor=t.metallicFactor),E(t.roughnessFactor)||(o.roughnessFactor=t.roughnessFactor),s.metallicRoughnessTexture){const t=this.M(e.textures[s.metallicRoughnessTexture.index]);o.metallicRoughnessTexture=t}}}if(s.s3mMaterial)return new r.reshader.Material(o);let a=new r.reshader.pbr.StandardMaterial(o);return"phong"===n&&(a=r.reshader.PhongMaterial.convertFrom(a)),a.once("complete",this.yt),a}M(t){const e={type:t.type?sr(t.type):"uint8",format:t.format?or(t.format):"rgba",flipY:!!t.flipY},n=t.image;n.array?e.data=n.array:n.mipmap&&(e.mipmap=n.mipmap),e.width=n.width,e.height=n.height;const i=t.sampler||t.texture.sampler;return i&&(i.magFilter&&(e.mag=rr(i.magFilter)),i.minFilter&&(e.min=nr(i.minFilter)),i.wrapS&&(e.wrapS=ir(i.wrapS)),i.wrapT&&(e.wrapT=ir(i.wrapT))),new r.reshader.Texture2D(e,this.At)}ce(t){const e=t.image,r=window.URL||window.webkitURL,n=new Blob([e.array],{type:e.mimeType});return r.createObjectURL(n)}gt({target:t}){const e=t.oe,r=this.st[e];if(r.count--,!r.count){const t=r.meshes;this.ct[e]=t,delete this.st[e];const n=t.Qt;delete t.Qt,n(null,{mesh:r.meshes,id:e})}}ae(){return mr}Yt(t){return this.tt.Yt(t)}Zt(t,e){const r=this.getMap();return r.getGLZoom?r.distanceToPoint(t,e,r.getGLZoom()):r.distanceToPointAtRes(t,e,r.getGLRes())}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes())}Kt(t){return"Y"===t?lr:"X"===t?fr:Ar}pick(t,e,r=3){const n=this.tt;if(!n||!n.options.picking)return null;if(!this.pickingFBO||!this.picking)return null;const i=this.getMap(),s=this.wt(),o=this.picking;o.render(this._t.getMeshes(),s,!0);let a={};o.getRenderedMeshes().length&&(a=o.pick(t,e,r,s,{viewMatrix:i.viewMatrix,projMatrix:i.projMatrix,returnPoint:n.options.pickingPoint}));const{meshId:c,pickingId:l,point:f}=a,u=(0===c||c)&&o.getMeshAt(c);if(!u||!u.geometry)return null;const h=u.properties;f&&f.length&&(f[0]=Math.round(1e5*f[0])/1e5,f[1]=Math.round(1e5*f[1])/1e5,f[2]=Math.round(1e5*f[2])/1e5);const _={batchId:l};if(h&&h.batchTable){const{batchTable:t,batchTableBin:e,count:r}=h,n=l;for(const i in t)void 0!==t[i].byteOffset?_[i]=be(t[i],e,r,n):_[i]=t[i][n]}return{data:_,point:f}}}
|
|
19
19
|
/*!
|
|
20
20
|
* @maptalks/gl v0.68.1
|
|
21
21
|
* LICENSE : UNLICENSED
|
|
22
22
|
* (c) 2016-2022 maptalks.com
|
|
23
|
-
*/const Nr=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},Sr=Nr(),wr=Sr.gl_trans__coders=Sr.gl_trans__coders||{};function Mr(t,e){if(e)for(let r=0;r<e.length;r++){t[e[r].id||e[r].index]=e[r]}}wr.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=Sr.gl_trans__coders=Sr.gl_trans__coders||{};let s=`${n}\n const _____getGlobal = ${Nr.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\n;");return s+="\n"+e.substring(n.length),s},wr.registerTranscoder=function(t,e){wr[t]=e},wr.getTranscoder=function(t){return wr[t]};const Or=[];class vr{constructor(t,e,r,n){this.ce=t,this.Mt=e,this.le=n,this.fe=r.version,t.indexOf("i3s:tileset:")<0?(this.fe<=1.6?this.ue="root":this.ue=0,r.version=this.fe):(this.ue=t.substring("i3s:tileset:".length),this.fe>1.6&&(this.ue=parseInt(this.ue))),this.ce=t,this.he=r}load(){const t=this.he,e=t.layerScene.baseUrl;if(this.fe<=1.6)return t[this.ue]&&t[this.ue].lodSelection?(this._e=t[this.ue],this.de()):new Promise((r=>{let n=e+"/nodes/"+this.ue;t.layerScene.eslpk&&(n+="/3dNodeIndexDocument.json"),this.le(this.Mt,n,(()=>{this._e=t[this.ue],r(this.de())}))}));if(this.fe>=1.7){if(t[this.ue])return this._e=t[this.ue],this.de();const r=Math.floor(this.ue/t.nodesPerPage);return new Promise((n=>{let i=e+"/nodepages/"+r;t.layerScene.eslpk&&(i+=".json"),this.le(this.Mt,i,(()=>{this._e=t[this.ue],n(this.de())}))}))}return null}getTileset(){return this.Ee}getChildrenURL(){return this.Te}de(){const t=this.he,e=t.layerScene.baseUrl,r=this._e.children,n=[],i={};if(r)for(let s=0;s<r.length;s++)if(this.fe<=1.6){const o=r[s].id;if(t[o])continue;const a=o;i[a]||(i[a]=new Promise((r=>{let n=e+"/nodes/"+a;t.layerScene.eslpk&&(n+="/3dNodeIndexDocument.json"),this.le(this.Mt,n,(()=>{r()}))})),n.push(i[a]))}else{const o=r[s];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);i[a]||(i[a]=new Promise((r=>{let n=e+"/nodepages/"+a;t.layerScene.eslpk&&(n+=".json"),this.le(this.Mt,n,(()=>{r()}))})),n.push(i[a]))}return n.length?Promise.all(n).then((()=>this.me())):this.me()}me(){return Promise.resolve(this.Ae())}pe(t){Mr(this.he,t)}Ae(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.ye(this._e,!0)}}ye(t){const e=this.fe,r=this.he,n=t;var i,s=n.obb,o=n.mbs,a={};if(o)i=Cr([],o[0],o[1],o[2]),a.sphere=[...i,o[3]];else if(s){const t=function(t,e,r){const n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,c=i+i,l=r*o,f=n*o,u=n*a,h=i*o,_=i*a,d=i*c,E=s*o,T=s*a,m=s*c;return t[0]=1-u-d,t[3]=f-m,t[6]=h+T,t[1]=f+m,t[4]=1-l-d,t[7]=_-E,t[2]=h-T,t[5]=_+E,t[8]=1-l-u,t}([],r);return n[0]=n[0]*e[0],n[1]=n[1]*e[0],n[2]=n[2]*e[0],n[3]=n[3]*e[1],n[4]=n[4]*e[1],n[5]=n[5]*e[1],n[6]=n[6]*e[2],n[7]=n[7]*e[2],n[8]=n[8]*e[2],[...t,...n]}(i=Cr([],s.center[0],s.center[1],s.center[2]),s.halfSize,s.quaternion),e=t[3]+t[6]+t[9],r=t[4]+t[7]+t[10],n=t[5]+t[8]+t[11];k(Or,e,r,n);const o=q(Or);a.sphere=[...i,o]}var c=1/0,l=0;if(n.mbs?l=n.mbs[3]:n.obb&&(l=Math.max(Math.max(n.obb.halfSize[0],n.obb.halfSize[1]),n.obb.halfSize[2])),void 0!==n.lodThreshold)"maxScreenThresholdSQ"===r.lodSelectionMetricType?c=l/(Math.sqrt(n.lodThreshold)/(.25*Math.PI)):console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==n.lodSelection)for(var f=0;f<n.lodSelection.length;f++)"maxScreenThreshold"===n.lodSelection[f].metricType&&(c=l/n.lodSelection[f].maxError);(c===1/0||isNaN(c))&&(c=1e5);var u=16*c;const h=B([]),_=n.children;var d;if(_){d=[];const t=this.he;for(let r=0;r<_.length;r++){const n=e<=1.6?_[r].id:_[r];if(!t[n]){d=null;break}d.push(this.ye(t[n]))}}var E={refine:"REPLACE",boundingVolume:a,transform:h,geometricError:u};return e<=1.6?t.lodSelection?t.geometryData&&(E.content={uri:"i3s:mesh:"+(t.id||t.index)}):E.content={uri:"i3s:tileset:"+(t.id||t.index)}:_&&_.length&&!d?E.content={uri:"i3s:tileset:"+(t.id||t.index)}:n.mesh&&(E.content={uri:"i3s:mesh:"+(t.id||t.index)}),d&&d.length&&(E.children=d),E}getJSON(){return this._e}}function Cr(t,e,r,n){return ee(t,p(e),p(r),n)}const xr=!!wr.ktx2,Ur=r.mat4.identity([]),Br=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function Pr(t){return t.indexOf("i3s:mesh")>=0}const Lr="i3s:mesh:".length;function Dr(t,e,r,n,i){const s=e.layerScene.eslpk,o=function(t,e){const r=e.substring(Lr);return t>=1.7?parseInt(r):r}(e.version,t),a=e[o],c=e.layerScene.baseUrl,l=[];let f=!1;const u=Ur;let h,_;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;let r=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;s&&(r+=".bin");const n={geometry:{url:r,info:e.layerScene.store.defaultGeometrySchema}};let i=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(i){const t=e.layerScene.store.textureEncoding[0];let r;r="image/jpeg"===t?"jpg":"png",s&&(i+="."+r);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+i,factor:1,format:r,mimeType:t},metallicFactor:0}};n.material=o}l.push(n)}else{h=a.mesh.geometry,_=a.mesh.material;const t=e.layerScene.geometryDefinitions[h.definition],{geometryBuffers:o}=t;f=n&&2===o.length;const u=wr.draco&&f?o[1]:o[0],d=wr.draco&&f?1:0;let E=c+`/nodes/${h.resource}/geometries/`+d;s&&(E+=".bin");const T={geometry:{url:E,info:u}};if(i&&Br&&f&&!wr.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const m=e.layerScene.materialDefinitions,A=e.layerScene.textureSetDefinitions;let p,y=0;if(_&&(y=m[_.definition]),m){p=function(t,e,r,n,i,s){const o=JSON.parse(JSON.stringify(t));return Fr(o,e,r,n,i,s),o}(y,A,c,_.resource,r,e.layerScene.eslpk)}else p={pbrMetallicRoughness:{metallicFactor:0}};T.material=p,l.push(T)}return{dracoCompression:f,meshes:l,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:u}}function Fr(t,e,r,n,i,s){for(const o in t)if(t[o]&&t[o].textureSetDefinitionId>=0){const a=e[t[o].textureSetDefinitionId],c="images/"+a.formats[0].format,l=Gr(a.formats,i),f={url:r+`/nodes/${n}/textures/${l.name}`,factor:void 0===t[o].factor?1:t[o].factor,format:l.format,mimeType:c};if(s){let t="";switch(l.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=l.format}f.url+="."+t}t[o]=f}else A(t[o])&&Fr(t[o],e,r,n,i,s)}function Gr(t,e){for(let r=0;r<=t.length;r++){const n=t[r].format;if("dds"===n&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[r];if("jpg"===n||"png"===n)return t[r];if("ktx2"===n&&xr)return t[r]}return null}const kr=[];class Hr extends i.renderer.CanvasRenderer{constructor(t){super(t),this.prepareWorker(),this.tilesLoading={},this.tileCache=new Wt(1024*t.options.maxGPUMemory*1024,this.deleteTile.bind(this)),this.ge={},this.Re=[],this.le=this.be.bind(this)}getAnalysisMeshes(){if(!this.painter)return kr;const t=this.painter.getPaintedMeshes();if(!t)return kr;const e=[],{b3dmMeshes:r,pntsMeshes:n,i3dmMeshes:i}=t;return r.length&&v(e,r),n.length&&v(e,n),i.length&&v(e,i),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.Re.length||super.needToRedraw())}drawOnInteracting(t,e,r){this.draw(e,r)}draw(t,e){const r=this.prepareCanvas();if(r&&!r.intersects(this.canvasExtent2D))return void this.completeRender();const{root:n,tiles:i}=this.layer.getTiles(),s=i.length;if(!i||!s)return void this.completeRender();this.Ie(),this.Ne();const{selectedTiles:o,leaves:a,requests:c}=this.Se(n,i);c.length&&this.loadTiles(c),this.we(o,a,e),this.Me(),c.length||this.completeRender()}Se(t,e){let r=[];this.Oe();let n=0;const i=this.ve(),s={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const i=e[t],c=i.node;if(s[c.id])continue;s[c.id]=1;let l=!1;const f=this.getCachedTile(c.id);if(this.Ce(c.id)?(n++,l=a=!0,this.tilesLoading[c.id].current=!0):f?(this.getTileOpacity(f)<1&&(l=a=!0),o=!0,i.selected=!0,i.data=f):this.painter.has(c)||(l=a=!0,r.push(c)),!l)continue;if(this.xe(i))o=!0;else{this.Ue(i).length&&(o=!0)}}let c=[],l={};if(o&&({selectedTiles:c,leaves:l}=this.Be(t)),r.length>1&&(r.sort(Vr),i)){const t=i-n;r=t>0?r.slice(0,t):[]}return{loading:a,requests:r,selectedTiles:c,leaves:l}}Be(t){const e=[],r={};let n;const i=[t],s=[];for(;i.length>0||s.length>0;){if(s.length>0){const t=s[s.length-1];if(t.Pe===i.length){s.pop(),t===n&&(t.leave=!0,r[t.node.id]=1),e.push(t);continue}}const t=i.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)r[t.node.id]=1,t.selectionDepth=s.length,e.push(t);else{if(t.selectionDepth=s.length,n=t,0===o.length){t.leave=!0,r[t.node.id]=1,e.push(t);continue}s.push(t),t.Pe=i.length}for(let t=0;t<o.length;t++)i.push(o[t])}return{selectedTiles:e,leaves:r}}xe(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}Ue(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const r=t.Le+1,n=[t.node];for(;n.length>0;){const i=n.pop().children;for(let s=0,o=i.length;s<o;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){n.push(i[s]);continue}const o=i[s].id;if(this.tileCache.has(o)){const r=this.layer.De(i[s],t);r.selected=!0,r.data=this.tileCache.get(o),t.children.push(r),e.push(r)}else i[s].Le<=r&&n.push(i[s])}}return e}we(t,e,r){this.tileCache.markAll(!1);for(let e=0,r=t.length;e<r;e++){const r=t[e].data;r.current=!0,this.tileCache.add(t[e].node.id,r)}this.tileCache.shrink();const n={tiles:t,leaves:e};this.onDrawTileStart(n);const i=r&&r.renderTarget,s=r&&r.sceneFilter,o=this.painter.paint(t,e,s,i);this.layer.options.debug&&this.painter.paintRegion(t,{color:this.layer.options.debugOutline},s,i),this.onDrawTileEnd(n),o&&this.layer.fire("canvasisdirty",{renderCount:o})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,r=t.length;e<r;e++){const r=t[e];this.tilesLoading[r.id]={current:!0,node:r},this.loadTile(r)}}loadTile(t){let e=t.content.url;if(M(e)){const r=O(e);return void this.Fe(e,r,t)}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const r=t.Mt,n=this.Ge[r];return new vr(e,r,n,this.le).load().then((r=>{this.onTilesetLoad(r,t,e)}))}t&&-1===e.indexOf("http://")&&-1===e.indexOf("https://")&&!Pr(e)&&(e=t.baseUrl+e);const r=this.layer.options.services[t.Mt];if(r.ajaxInMainThread){let n=r.urlParams;n&&(n=(e.indexOf("?")>0?"&":"?")+n);let i=At.getArrayBuffer(e+(n||""),r.fetchOptions);const s=i.xhr;i=i.then((r=>{delete this.ge[e],r?this.Fe(e,r.data,t):this.onTileError(null,t)})).catch((r=>{delete this.ge[e],this.onTileError(r,t)})),this.ge[e]=s}else this.Fe(e,null,t)}Fe(t,e,n){let i=this.l;i||(i=r.reshader.Util.getSupportedFormats(this.gl.gl||this.gl),this.l=i);const s={url:t,arraybuffer:e,rootIdx:n.Mt,upAxis:n.Kt,transform:n.matrix,supportedFormats:i};if(Pr(t)){const e=this.Ge[n.Mt];if(s.i3sInfo=Dr(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!s.i3sInfo)return void this.onTileError({status:404},n)}this.workerConn.loadTile(this.layer.getId(),s,((e,r)=>{if(e)return void this.onTileError(e,n);const{magic:i}=r;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i?this.Re.push({data:r,tile:n}):this.onTilesetLoad(r,n,t)}))}Ne(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let r=0;for(;this.Re.length&&(r<e||!t.isInteracting());){const{data:t,tile:e}=this.Re.shift(),{magic:n}=t;"b3dm"===n?this.painter.createB3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.ke(t,e,r,n)})):"pnts"===n?this.painter.createPntsMesh(t,e.id,e,((r,{mesh:n})=>{this.ke(t,e,r,n)})):"i3dm"===n?this.painter.createI3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.ke(t,e,r,n)})):"cmpt"===n&&this.painter.createCMPTMesh(t,e.id,e,((r,{mesh:n})=>{this.ke(t,e,r,n)})),r++}}ke(t,e,r,n){if(r)this.onTileError(r,e);else{const r=this.He(n);e.memorySize=r,this.onTileLoad(t,e)}}He(t){let e=0;if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]&&(e+=this.He(t[r]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.Ve(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,r){this.layer&&(t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.ze(t,e,r):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,r)))}onTileError(t,e){if(!this.layer)return;const r=e.content.url;console.warn("failed to load 3d tile: "+r),console.warn(t),delete this.tilesLoading[e.id],this.Ye(e),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}Ye(t){const e={loadTime:i.Util.now(),current:!0,error:!0,node:t};this.tileCache.add(t.id,e)}Ve(t){const e={loadTime:i.Util.now(),current:!0,node:t};this.tileCache.add(t.id,e)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;if(this.layer.options.services[t.node.Mt].ajaxInMainThread){const t=this.ge[e];t&&t.abort()}else this.workerConn.abortTileLoading(this.layer.getId(),e);delete this.ge[e]}Oe(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}createContext(){const t=this.layer,e=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:t.options.antialias};this.canvas.gl&&this.canvas.gl.wrap?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.Xe(this.canvas,e)),this.regl=this.regl||r.createREGL({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),this.painter=new Ir(this.regl,t)}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new Yt("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=T({},r),delete r.offset,r.projection=t.getSpatialReference().getProjection().code;const n=this.layer.getId();e.addLayer(n,r,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.Me(!0),this.tileCache.reset(),this.tilesLoading={},super.clear()}clearCanvas(){this.regl&&this.regl.clear({color:[0,0,0,0],depth:1,stencil:0}),super.clearCanvas()}getTileOpacity(){return 1}getStencilValue(){return 0}Me(t){this.Ze||(this.Ze=Date.now());const e=Date.now();if(t||!(e-this.Ze<this.layer.options.retireInterval)){this.Ze=e;for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||this.abortTileLoading(r)}}}ve(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}Xe(t,e){const r=["webgl","experimental-webgl"];let n=null;for(let i=0;i<r.length;++i){try{n=t.getContext(r[i],e)}catch(t){}if(n)break}return n}Ce(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,r){return ge(t,e,0,r)}Ie(){if(!this.We)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const r=[];for(const n in this.We){const i=this.We[n];if("pending"===i.status)continue;i.status="pending";const s=i.rootIdx;if(r.push(At.getJSON(n).then((t=>{delete this.We[n];const e=this.Ge[s];if(e){t.nodes?Mr(e,t.nodes):(e[t.id]=t,Mr(e,t.children));for(let t=0;t<i.length;t++)i[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}r.length&&Promise.all(r)}be(t,e,r){this.We||(this.We={}),this.We[e]=this.We[e]||[],this.We[e].rootIdx=t,this.We[e].push(r),this.setToRedraw()}ze(t,e,r){this.Ge||(this.Ge=[]);const n=e.Mt;this.Ge[n]||(this.Ge[n]={});const i=this.Ge[n],s=this.layer.options.services[n];t.layers&&(t=t.layers[0],"/"!==r[r.length-1]&&(r+="/"),r+="layers/0"),i.version=+(s.i3sVersion||t.store.version),function(t,e,r,n,i,s){if(!i.layerScene){i.layerScene=t,i.nodesPerPage=t.nodePages&&t.nodePages.nodesPerPage||64,i.lodSelectionMetricType=t.nodePages&&t.nodePages.lodSelectionMetricType;let e=n;if(i.layerScene.eslpk=e.indexOf("3dSceneLayer.json")>=0,i.layerScene.eslpk){const t=n.lastIndexOf("/");e=t<0?"./":n.substring(0,t)}i.layerScene.baseUrl=e}return new vr(n,e,i,s).load()}(t,n,0,r,i,this.le).then((t=>{this.onTilesetLoad(t,e,r)}))}}function Vr(t,e){return t.Lt-e.Lt}function zr(t,e,r){return t[0]=e[r],t[1]=e[r+3],t[2]=e[r+6],t}function Yr(t,e,r){return Math.sqrt(function(t,e,r){var n=V(Xr,r,t),i=zr(Zr,e,0),s=zr(Wr,e,1),o=zr(jr,e,2),a=q(i),c=q(s),l=q(o);X(i,i),X(s,s),X(o,o);var f=Kr;f[0]=Z(n,i),f[1]=Z(n,s),f[2]=Z(n,o);var u,h=0;f[0]<-a?h+=(u=f[0]+a)*u:f[0]>a&&(h+=(u=f[0]-a)*u);f[1]<-c?h+=(u=f[1]+c)*u:f[1]>c&&(h+=(u=f[1]-c)*u);f[2]<-l?h+=(u=f[2]+l)*u:f[2]>l&&(h+=(u=f[2]-l)*u);return h}(t,e,r))}const Xr=[],Zr=[],Wr=[],jr=[],Kr=[];const qr=2*Math.PI;class $r{constructor(t,e,r,n){this.west=t,this.south=e,this.east=r,this.north=n}static contains(t,e){var r=e[0],n=e[1],i=t.west,s=t.east;return s<i&&(s+=qr,r<0&&(r+=qr)),(r>i||Ee(r,i,1e-14))&&(r<s||Ee(r,s,1e-14))&&n>=t.south&&n<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const Jr=[0,0,1];function Qr(t,e){return ee(e,t[0],t[1],t[2])}class tn{constructor(t,e){this.normal=r.vec3.copy([],t),this.distance=e}static fromPointNormal(t,e,n){var i=-r.vec3.dot(e,t);return r.vec3.copy(n.normal,e),n.distance=i,n}}const en=[],rn=[],nn=[],sn=[],on=[],an=[],cn=[],ln=[],fn=[],un=[],hn=new tn([1,0,0],0),_n=[];class dn{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new $r(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){var n,i,s,o=0;if(!$r.contains(this.rectangle,e)){var a=this.southwestCornerCartesian,c=this.northeastCornerCartesian,l=this.westNormal,f=this.southNormal,u=this.eastNormal,h=this.northNormal,_=r.vec3.subtract(_n,t,a),d=r.vec3.dot(_,l),E=r.vec3.dot(_,f),T=r.vec3.subtract(_n,t,c),m=r.vec3.dot(T,u),A=r.vec3.dot(T,h);d>0?o+=d*d:m>0&&(o+=m*m),E>0?o+=E*E:A>0&&(o+=A*A)}if(n=e[2],i=this.minimumHeight,n>(s=this.maximumHeight)){var p=n-s;o+=p*p}else if(n<i){var y=i-n;o+=y*y}return Math.sqrt(o)}computeBox(t){const e=this;Qr($r.southwest(t,rn),e.southwestCornerCartesian),Qr($r.northeast(t,rn),e.northeastCornerCartesian),en[0]=t.west,en[1]=.5*(t.south+t.north),en[2]=0;var n=Qr(en,nn),i=r.vec3.cross(on,n,Jr);r.vec3.normalize(e.westNormal,i),en[0]=t.east;var s=Qr(en,ln),o=r.vec3.cross(on,Jr,s);r.vec3.normalize(e.eastNormal,o);var a,c=r.vec3.subtract(on,n,s),l=r.vec3.normalize(sn,c),f=t.south;if(f>0){en[0]=.5*(t.west+t.east),en[1]=f;var u=Qr(en,fn);r.vec3.copy(un,l);var h=tn.fromPointNormal(e.southwestCornerCartesian,e.westNormal,hn);En(fn,un,h,e.southwestCornerCartesian),a=he(u,an)}else a=_e($r.southeast(t,rn),an);var _=r.vec3.cross(cn,a,c);r.vec3.normalize(e.southNormal,_);var d,E=t.north;if(E<0){en[0]=.5*(t.west+t.east),en[1]=E;var T=Qr(en,fn);r.vec3.scale(un,l,-1);var m=tn.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,hn);En(fn,un,m,e.northeastCornerCartesian),d=he(T,an)}else d=_e($r.northwest(t,rn),an);var A=r.vec3.cross(cn,c,d);r.vec3.normalize(e.northNormal,A)}}function En(t,e,n,i){var s=t,o=e,a=n.normal,c=r.vec3.dot(a,o);if(!(Math.abs(c)<1e-15)){var l=(-n.distance-r.vec3.dot(a,s))/c;if(!(l<0))return i=r.vec3.scale(i,o,l),r.vec3.add(i,s,i)}}const Tn=new i.Extent(0,0,0,0),mn=new i.Extent(0,0,0,0),An=[],pn=[],yn=[],gn=[],Rn=new i.Point(0,0),bn=[],In=new i.Coordinate(0,0),Nn=r.mat4.identity([]);class Sn extends i.Layer{constructor(t,e){super(t,e),this.je(),this.ge={},this.Ke=[]}je(){let t=this.options.services.map((t=>t.url));this.qe=t.map(((t,e)=>function(t,e){t=g(t);return{baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.mat4.identity([]),Mt:e,Le:0}}(t,e))),this.fire("rootready",{roots:this.qe.slice(0)})}getExtent(t){if(!t&&0!==t){const t=new i.Extent;for(let e=0;e<this.qe.length;e++)if(this.qe[e].boundingVolume){const r=this.boundingVolumeToExtent(this.qe[e]);t._combine(r)}return t}return this.qe[t]&&this.qe[t].boundingVolume?this.boundingVolumeToExtent(this.qe[t]):null}boundingVolumeToExtent(t){const e=t.boundingVolume.$e?Nn:t.matrix,n=this.getMap();if(t.boundingVolume.region){const e=t.boundingVolume.region;return new i.Extent(y(e[0]),y(e[1]),y(e[2]),y(e[3]))}if(t.boundingVolume.sphere){const s=t.boundingVolume.sphere,o=ae([],r.vec3.transformMat4([],s,e)),a=s[3],c=n.locate(o,-a,a),l=n.locate(o,a,-a);return new i.Extent(c,l)}if(t.boundingVolume.box){const s=t.boundingVolume.box,o=r.vec3.transformMat4([],s,e),a=new i.Coordinate(ae([],o)),c=s.slice(3);r.mat3.multiply(c,r.mat3.fromMat4([],t.matrix),c);const l=r.vec3.length(c.slice(0,3)),f=r.vec3.length(c.slice(3,6)),u=r.vec3.length(c.slice(6,9)),h=Math.max(l,f,u),_=n.locate(a,-h,h),d=n.locate(a,h,-h);return new i.Extent(_,d)}return null}getRootTiles(){return this.qe}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Je(),{tiles:gn};const e=this.getMap(),n=e.cameraPosition;let i,s;if(e.getGLZoom)s=e.pointToDistance(n[2],0,e.getGLZoom()),In.set(n[0],n[1]),i=e.pointToCoord(In,e.getGLZoom());else{const t=e.getGLRes();s=e.pointAtResToDistance(n[2],0,t),In.set(n[0],n[1]),i=e.pointAtResToCoord(In,t)}this.Qe=this.Qe||[],r.vec3.set(this.Qe,p(i.x),p(i.y),s),this.tr=ee(this.tr||[],this.Qe[0],this.Qe[1],this.Qe[2]),this.er=2*Math.tan(.5*p(e.getFov()));const o=e.projViewMatrix,a={children:[],level:-1};let c=a;const l=[];for(let e=0;e<this.qe.length;e++){let r=1/0;const n=[this.qe[e]],i=this.rr(e);for(;n.length>0;){const e=n.pop();for(e.id||this.nr(e);c.level>=e.Le;)c=c.parent;const s=this.ir(e,i,o);if(s<1){let t=c;for(;t&&!t.content;)t=t.parent;0===s&&t&&t.content&&this.sr(l,t);if(!1===this.options.services[e.Mt].alwaysShow)continue;if(!(0===s&&e.Le<=r))continue;e.content&&(r=e.Le)}e.Lt<1/0&&this.ar(e);const a=this.De(e,c);c.children.push(a);const f=e.children,u=f&&f.length,h=a.content;if(!u&&h&&this.sr(l,a),u){h&&"add"===e.refine&&this.sr(l,a),c=a;const r=f[0].parent;let i=!1;for(let s=0,o=f.length;s<o;s++){if(r){const e=t.getCachedTile(f[s].id);if(e&&e.error)continue;i=!0}else{i=!0,f[s].parent=e,f[s].Kt=e.Kt,f[s].baseUrl=e.baseUrl;const t=f[s].content&&(f[s].content.url||f[s].content.uri);t&&(M(t)||t.indexOf("i3s:")>=0?f[s].baseUrl=e.baseUrl:-1===t.indexOf("http://")&&-1===t.indexOf("https://")?f[s].content.url=e.baseUrl+t:f[s].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}n.push(f[s])}!i&&h&&this.sr(l,a)}}}return{root:a,tiles:l}}sr(t,e){const{viewerRequestVolume:r}=e.node;r&&!function(t,e,r){if(r.region){const e=r.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(r.sphere)return wn(r,e);if(r.box)return 0===Mn(r,e)}return!1}(this.Qe,this.tr,r)||t.push(e)}De(t,e){return{id:t.id,node:t,children:[],level:t.Le,parent:e,content:t.content&&t.content.url}}nr(t){t.id=i.Util.GUID(),t.matrix=t.transform||r.mat4.identity([]),t.cr=this.lr(t),t.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(t)||(t.matrix=r.mat4.multiply(t.matrix,t.parent.matrix,t.matrix)),t.Mt=t.parent.Mt,void 0===t.Le&&(t.Le=t.parent.Le+1),t.maxExtent=t.parent.maxExtent),t.refine=t.refine&&t.refine.toLowerCase()||"replace",t.content&&!t.content.url&&t.content.uri&&(t.content.url=t.content.uri),this.ur(t)}ur(t){const e=t.boundingVolume;if(!e||e.$e)return;const n=this.options.services[t.Mt].heightOffset||0,i=this.options.offset,s=m(i)||i[0]||i[1];if(!t.boundingVolume||!n&&r.mat4.exactEquals(t.matrix,Nn)&&!s)return;const{region:o,box:a,sphere:c}=e;if(o){const t=this.hr([y(o[0]),y(o[1])]);o[0]=p(t.x),o[1]=p(t.y);const e=this.hr([y(o[2]),y(o[3])]);o[2]=p(e.x),o[3]=p(e.y),o[4]+=n,o[5]+=n}else if(a||c){const e=a||c,i=r.vec3.transformMat4(An,e,t.matrix),s=ae(pn,i),o=this.hr([s[0],s[1]]);s[0]=o.x,s[1]=o.y,s[2]+=n,ee(e,p(s[0]),p(s[1]),s[2])}e.$e=!0}lr(t){return void 0===t.geometricError||!t.boundingVolume}ar(t){let e=t.parent;for(;e&&e.cr&&!(e.Lt<=t.Lt);)e.Lt=t.Lt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const r=e.content.url;e.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const n=this.getRenderer();n&&n.setToRedraw()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const i=(t.asset&&t.asset.gltfUpAxis||e&&e.Kt||this.options.services[e.Mt].upAxis||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const s=n.indexOf("realspace/")>-1;t.asset&&t.asset.s3mType&&s&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.Kt=i,e){const n=e.boundingVolume;T(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",n&&(e.boundingVolume=n);const i=t.root.transform;i&&(e.parent?o||(e.matrix=r.mat4.multiply([],e.parent.matrix,i)):e.matrix=i),this.ur(e),e._r=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.cr=this.lr(e);const s=e.content&&(e.content.url||e.content.uri);s&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),o||!s||M(s)||-1!==s.indexOf("http://")||-1!==s.indexOf("https://")||(e.content.url=e.baseUrl+s)}this.Je(),this.fire("loadtileset",{tileset:t,index:e.Mt,url:n})}ir(t,e,r){if(t.Lt=1/0,0===t.Le||t.cr)return 1;if(!this.dr(t,e,r))return-1;if(0===t.geometricError)return 1;let n=this.options.services[t.Mt].maximumScreenSpaceError;null==n&&(n=8);let i=this.Er(t);return 0===i&&t.parent&&(i=.5*(t.parent.Tr||0)),i>=n?1:0}zt(t,e){e||(e=new i.Point(0,0));const r=this.getMap();return r.getGLZoom?r.coordToPoint(t,r.getGLZoom(),e):r.coordToPointAtRes(t,r.getGLRes(),e)}dr(t,e,n){const s=t.id;let o=this.Ke[s];const{boundingVolume:c}=t,l=c.sphere,_=c.region,E=c.box;if(!o){let e,n,a;if(_){e=Tn.set(y(_[0]),y(_[1]),y(_[2]),y(_[3]));const t=e.getCenter(),r=this.mr(t);e=e.convertTo((t=>this.zt(t,Rn)),mn),a=_[4],n=_[5],o=this.Ke[s]=[[e.xmin,e.ymin,a*r[2]],[e.xmax,e.ymax,n*r[2]]],o.center=t}else if(l){const t=ae(An,l),e=new i.Coordinate(t),r=this.zt(e,Rn).toArray(),n=this.mr(e);r.push(t[2]*n[2]),o=this.Ke[s]=[r,l[3]*n[2]],o.center=e}else if(E){const e=ae(An,E),n=new i.Coordinate(e),a=this.zt(n,Rn).toArray(),c=this.mr(n);a.push(e[2]*c[2]);const l=E.slice(3);r.mat4.exactEquals(t.matrix,Nn)||r.mat3.multiply(l,r.mat3.fromMat4(bn,t.matrix),l);for(let t=0;t<l.length;t++)l[t]*=c[t%3],E[3+t]=l[t];o=this.Ke[s]=[...a,...l],o.center=n}}if(e){if(_)Tn.xmin=o[0][0],Tn.ymin=o[0][1],Tn.xmax=o[1][0],Tn.ymax=o[1][1];else if(l){const t=o[2];Tn.xmin=o[0][0]-t,Tn.ymin=o[0][1]-t,Tn.xmax=o[0][0]+t,Tn.ymax=o[0][1]+t}else if(E){const t=o[1],e=o[2];Tn.xmin=o[0][0]-t,Tn.ymin=o[0][1]-e,Tn.xmax=o[0][0]+t,Tn.ymax=o[0][1]+e}if(!e.intersects(Tn))return!1}return _?f(n,o):l?function(t,e,r){h(t);for(var n=e[0],i=-e[1],s=0;s<6;s++)if((!r||"0"!==r.charAt(s))&&d(a[s],n)<i)return!1;return!0}(n,o):!!E&&function(t,e,r){h(t);for(var n=0;n<6;n++)if(!(r&&"0"===r.charAt(n)||u(a[n],e)))return!1;return!0}(n,o)}mr(t){const e=this.getMap(),n=e.distanceToPointAtRes(100,100,e.getGLRes(),t);return r.vec3.set(yn,n.x/100*1.01,n.y/100*1.01,n.y/100),yn}hr(t){Array.isArray(t)&&(t=new i.Coordinate(t));let e=this.options.offset;if(m(e)&&(e=e(Array.isArray(t)?new i.Coordinate(t):t)),e[0]||e[1]){const r=this.getMap(),n=r.getGLRes(),i=r.coordToPointAtRes(t,n);return i._sub(e),r.pointAtResToCoord(i,n)}return t}rr(t){const e=this.options.services[t].maxExtent;if(!e)return null;const r=this.qe[t];return r.maxExtent||(r.maxExtent=new i.Extent(e).convertTo((t=>this.zt(t)))),r.maxExtent}Er(t){const e=this.er,r=t.geometricError;if(0===r)return 0;const n=this.getMap();let i;t.boundingVolume.region?i=function(t,e,r){t.Ar||(t.Ar=new dn(t.boundingVolume.region));return t.Ar.distanceToCamera(e,r)}(t,this.tr,this.Qe):t.boundingVolume.sphere?i=wn(t.boundingVolume,this.tr):t.boundingVolume.box&&(i=Mn(t.boundingVolume,this.tr));const s=Math.max(Math.abs(i),1e-7),o=r*n.height/(s*e);return t.Lt=i,t.Tr=o,o}Je(){const t=this.getRenderer();t&&t.setToRedraw()}te(t){return this.Ke[t]}}function wn(t,e){const n=t.sphere,i=r.vec3.dist(n,e),s=t.sphere[3];return i<s?0:i-s}function Mn(t,e){const n=t.box;return Yr(r.vec3.set(An,n[0],n[1],n[2]),r.mat3.set(bn,n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]),e)}Sn.mergeOptions({"maxGPUMemory":512,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":0,"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"debug":!1,"debugOutline":[0,1,0],"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"antialias":!1,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"],"offset":[0,0]}),Sn.registerRenderer("gl",Hr),Sn.registerJSONType("Geo3DTilesLayer");class On{constructor(t,e,r){this.o=t,this.pr=e||Lt,this.l=r,this.yr={"image/crn":wr.crn&&wr.crn(),"image/ktx2":wr.ktx2&&wr.ktx2(),"image/cttf":wr.ktx2&&wr.ktx2(),"draco":wr.draco&&wr.draco()}}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.gr(t,e,r,n,i)):At.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.gr(t,i,r,n)}))}gr(t,e,r,n,i){const s=i&&i.maxTextureSize,o=this.Rr(e,r,n,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.pr(a,o.glb,{transferable:!0,requestImage:this.o,decoders:this.yr,supportedFormats:this.l,maxTextureSize:s});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${r}-${n}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}Rr(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+n;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),l=i.getUint32(20,!0),f=i.getUint32(24,!0),u=28+e;l>=570425344?(u-=8,o=a,l=c,f=0,a=0,c=0):f>=570425344&&(u-=4,o=l,l=a,f=c,a=0,c=0);const h=[t];let _,d,E;if(a>0?(_=Ae(t,u,a),u+=a,o=_.BATCH_LENGTH):_={"BATCH_LENGTH":o},c>0&&(u+=c),l>0&&(d=pe(t,u,l),u+=l,f>0)){const e=ye(0,u,f);E=t.slice(e.offset,e.offset+e.byteLength),u+=f,h.push(E)}const T=_.BATCH_LENGTH,m={};if(_&&_.BATCH_ID){m.BATCH_ID=Re(_.BATCH_ID,t,undefined.offset,T);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:o,transferables:h,featureTable:_,batchTable:d,batchTableBin:E,b3dm:m,glb:{buffer:t,byteOffset:u,byteLength:i.byteLength+i.byteOffset-u}}}br(){return null}}class vn{constructor(t,e,r,n){this.o=t,this.pr=e||Lt,this.l=r,this.yr={"image/crn":wr.crn&&wr.crn(),"image/ktx2":wr.ktx2&&wr.ktx2(),"image/cttf":wr.ktx2&&wr.ktx2(),"draco":wr.draco&&wr.draco()},this.Ir=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.gr(t,e,r,n,i)):At.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.gr(t,i,r,n)}))}gr(t,e,r,n,i){return this.Nr(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const o=this.Sr(e,r,n,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}Nr(t,e,r,n,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.o,decoders:this.yr,supportedFormats:this.l,maxTextureSize:s},a=new DataView(e,r,n),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let n=I(new Uint8Array(e,c+r,a.byteLength-c));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?At.getArrayBuffer(n,{}).then((t=>this.wr(n,{buffer:t.data,byteOffset:0},o))):At.getJSON(n,{}).then((t=>this.wr(n,t,o)))}{const n={buffer:e,byteOffset:c+r,byteLength:a.byteLength-c};return this.wr(t,n,o)}}wr(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.pr(n,e,r);return i.load({skipAttributeTransform:!0}).then((r=>{let n=0,s=0;return e.buffer&&(n=e.byteOffset||0,s=e.byteLength||0),r.url=`${t}-${n}-${s}`,{transferables:i.transferables,gltf:r}}))}Sr(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:f}=we(i,32+e,o),u={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(u.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,r=a.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=a.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.Mr(new Uint16Array(t,n+c.offset,3*h),e,r)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=Re(a.BATCH_ID,t,c.offset,h);const e=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(u.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.Or(new Uint16Array(t,e+c.offset,2*h))},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.Or(new Uint16Array(t,e+c.offset,2*h))},o.push(u.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},o.push(u.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:l,batchTableBin:f,featureTable:a,i3dm:u,transferables:o}}Or(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)Cn(n,t[2*i],t[2*i+1],65535),r[3*i]=n[0],r[3*i+1]=n[1],r[3*i+2]=n[2];return r}Mr(t,e,r){return Se(new Float32Array(t.length),t,e,r)}br(){return null}}function Cn(t,e,r,n){if(t[0]=xn(e,n),t[1]=xn(r,n),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*Un(e),t[1]=(1-Math.abs(e))*Un(t[1])}return X(t,t)}function xn(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,r){return t<e?e:t>r?r:t}(t,0,e)/e*2-1}function Un(t){return t<0?-1:1}class Bn{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.gr(t,e,r,n)):At.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.gr(t,i,r,n)}))}gr(t,e,r,n){return this.vr(e,r,n,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}vr(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:f}=we(i,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,_=a.POINTS_LENGTH;let d,E={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){E=a.extensions["3DTILES_draco_point_compression"],d=new DataView(t,E.byteOffset+c.offset,E.byteLength);const e={attributes:E.properties,useUniqueIDs:!1};return this.Cr||(this.Cr=wr.draco()),this.Cr(d,e).then((e=>{const r=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=a.POSITION,r.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=a.RGB,r.RGBA=a.RGBA,r.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=a.NORMAL,r.NORMAL_OCT16P=a.NORMAL_OCT16P);const n=this.Ur(t,e.attributes,c.offset,_,o,u,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Ne(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?n.BATCH_ID=Re(a.BATCH_ID,t,c.offset,_):n.BATCH_ID=Pn(_);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:_,batchTable:l,batchTableBin:f,featureTable:a,pnts:n,transferables:o}}))}const T=this.Ur(t,a,c.offset,_,o,u,h);if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?T.BATCH_ID=Re(a.BATCH_ID,t,c.offset,_):T.BATCH_ID=Pn(_);const e=T.BATCH_ID.array&&T.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:_,batchTable:l,batchTableBin:f,featureTable:a,pnts:T,transferables:o})}Ur(t,e,r,n,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c,array:l}=e.POSITION_QUANTIZED;c=c||0;const f=l?0:r;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.Mr(l||new Uint16Array(t,c+f,3*n),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+4*n);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+2*n);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+2*n);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:o},i.push(o.buffer)}return a}Mr(t,e,r){return Se(new Float32Array(t.length),t,e,r)}br(){return null}}function Pn(t){const e=w(t),r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Ne(e),array:r}}class Ln{constructor(t,e){this.o=t,this.pr=e||Lt}load(t,e,r=0,n=0,i){return e?this.gr(t,e,r,n,i):At.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.gr(t,i,r,n)}))}gr(t,e,r,n,i){n||(n=e.byteLength);const s=this.Br(e,t,r,n),o=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new On(this.o,this.pr);else if("i3dm"===s[r].magic)n=new vn(this.o,this.pr);else if("pnts"===s[r].magic)n=new Bn;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new Ln(this.o,this.pr)}o.push(n.load(t,e,s[r].offset,s[r].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Br(t,e,r,n){const i=new DataView(t,r,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Te(i,c),n=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+r,byteLength:n}),c+=n}return o}}if(s.transcoders){const t=i.Map.VERSION;if(t.indexOf("1.0.0-beta")>=0||t.indexOf("1.0.0-alpha")>=0){const t=s.transcoders.inject(o);i.registerWorkerAdapter("@maptalks/3dtiles",t)}else i.registerWorkerAdapter("@maptalks/3dtiles",(function(){return s.transcoders.inject(o)}))}else i.registerWorkerAdapter("@maptalks/3dtiles",o);t.B3DMLoader=On,t.CMPTLoader=Ln,t.Geo3DTilesLayer=Sn,t.Geo3DTilesUtil=C,t.Geo3DTransform=de,Object.defineProperty(t,"t",{value:!0}),"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.15.3")}));
|
|
23
|
+
*/const Mr=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},Or=Mr(),vr=Or.gl_trans__coders=Or.gl_trans__coders||{};function Cr(t,e){if(e)for(let r=0;r<e.length;r++){t[e[r].id||e[r].index]=e[r]}}vr.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=Or.gl_trans__coders=Or.gl_trans__coders||{};let s=`${n}\n const _____getGlobal = ${Mr.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\n;");return s+="\n"+e.substring(n.length),s},vr.registerTranscoder=function(t,e){vr[t]=e},vr.getTranscoder=function(t){return vr[t]};const xr=[];class Ur{constructor(t,e,r,n){this.le=t,this.Ot=e,this.fe=n,this.ue=r.version,t.indexOf("i3s:tileset:")<0?(this.ue<=1.6?this.he="root":this.he=0,r.version=this.ue):(this.he=t.substring("i3s:tileset:".length),this.ue>1.6&&(this.he=parseInt(this.he))),this.le=t,this._e=r}load(){const t=this._e,e=t.layerScene.baseUrl;if(this.ue<=1.6)return t[this.he]&&t[this.he].lodSelection?(this.de=t[this.he],this.Ee()):new Promise((r=>{let n=e+"/nodes/"+this.he;t.layerScene.eslpk&&(n+="/3dNodeIndexDocument.json"),this.fe(this.Ot,n,(()=>{this.de=t[this.he],r(this.Ee())}))}));if(this.ue>=1.7){if(t[this.he])return this.de=t[this.he],this.Ee();const r=Math.floor(this.he/t.nodesPerPage);return new Promise((n=>{let i=e+"/nodepages/"+r;t.layerScene.eslpk&&(i+=".json"),this.fe(this.Ot,i,(()=>{this.de=t[this.he],n(this.Ee())}))}))}return null}getTileset(){return this.Te}getChildrenURL(){return this.me}Ee(){const t=this._e,e=t.layerScene.baseUrl,r=this.de.children,n=[],i={};if(r)for(let s=0;s<r.length;s++)if(this.ue<=1.6){const o=r[s].id;if(t[o])continue;const a=o;i[a]||(i[a]=new Promise((r=>{let n=e+"/nodes/"+a;t.layerScene.eslpk&&(n+="/3dNodeIndexDocument.json"),this.fe(this.Ot,n,(()=>{r()}))})),n.push(i[a]))}else{const o=r[s];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);i[a]||(i[a]=new Promise((r=>{let n=e+"/nodepages/"+a;t.layerScene.eslpk&&(n+=".json"),this.fe(this.Ot,n,(()=>{r()}))})),n.push(i[a]))}return n.length?Promise.all(n).then((()=>this.Ae())):this.Ae()}Ae(){return Promise.resolve(this.pe())}ye(t){Cr(this._e,t)}pe(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.ge(this.de,!0)}}ge(t){const e=this.ue,r=this._e,n=t;var i,s=n.obb,o=n.mbs,a={};if(o)i=Br([],o[0],o[1],o[2]),a.sphere=[...i,o[3]];else if(s){const t=function(t,e,r){const n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,c=i+i,l=r*o,f=n*o,u=n*a,h=i*o,_=i*a,d=i*c,E=s*o,T=s*a,m=s*c;return t[0]=1-u-d,t[3]=f-m,t[6]=h+T,t[1]=f+m,t[4]=1-l-d,t[7]=_-E,t[2]=h-T,t[5]=_+E,t[8]=1-l-u,t}([],r);return n[0]=n[0]*e[0],n[1]=n[1]*e[0],n[2]=n[2]*e[0],n[3]=n[3]*e[1],n[4]=n[4]*e[1],n[5]=n[5]*e[1],n[6]=n[6]*e[2],n[7]=n[7]*e[2],n[8]=n[8]*e[2],[...t,...n]}(i=Br([],s.center[0],s.center[1],s.center[2]),s.halfSize,s.quaternion),e=t[3]+t[6]+t[9],r=t[4]+t[7]+t[10],n=t[5]+t[8]+t[11];k(xr,e,r,n);const o=q(xr);a.sphere=[...i,o]}var c=1/0,l=0;if(n.mbs?l=n.mbs[3]:n.obb&&(l=Math.max(Math.max(n.obb.halfSize[0],n.obb.halfSize[1]),n.obb.halfSize[2])),void 0!==n.lodThreshold)"maxScreenThresholdSQ"===r.lodSelectionMetricType?c=l/(Math.sqrt(n.lodThreshold)/(.25*Math.PI)):console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==n.lodSelection)for(var f=0;f<n.lodSelection.length;f++)"maxScreenThreshold"===n.lodSelection[f].metricType&&(c=l/n.lodSelection[f].maxError);(c===1/0||isNaN(c))&&(c=1e5);var u=16*c;const h=B([]),_=n.children;var d;if(_){d=[];const t=this._e;for(let r=0;r<_.length;r++){const n=e<=1.6?_[r].id:_[r];if(!t[n]){d=null;break}d.push(this.ge(t[n]))}}var E={refine:"REPLACE",boundingVolume:a,transform:h,geometricError:u};return e<=1.6?t.lodSelection?t.geometryData&&(E.content={uri:"i3s:mesh:"+(t.id||t.index)}):E.content={uri:"i3s:tileset:"+(t.id||t.index)}:_&&_.length&&!d?E.content={uri:"i3s:tileset:"+(t.id||t.index)}:n.mesh&&(E.content={uri:"i3s:mesh:"+(t.id||t.index)}),d&&d.length&&(E.children=d),E}getJSON(){return this.de}}function Br(t,e,r,n){return ee(t,p(e),p(r),n)}const Pr=!!vr.ktx2,Lr=r.mat4.identity([]),Dr=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function Fr(t){return t.indexOf("i3s:mesh")>=0}const Gr="i3s:mesh:".length;function kr(t,e,r,n,i){const s=e.layerScene.eslpk,o=function(t,e){const r=e.substring(Gr);return t>=1.7?parseInt(r):r}(e.version,t),a=e[o],c=e.layerScene.baseUrl,l=[];let f=!1;const u=Lr;let h,_;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;let r=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;s&&(r+=".bin");const n={geometry:{url:r,info:e.layerScene.store.defaultGeometrySchema}};let i=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(i){const t=e.layerScene.store.textureEncoding[0];let r;r="image/jpeg"===t?"jpg":"png",s&&(i+="."+r);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+i,factor:1,format:r,mimeType:t},metallicFactor:0}};n.material=o}l.push(n)}else{h=a.mesh.geometry,_=a.mesh.material;const t=e.layerScene.geometryDefinitions[h.definition],{geometryBuffers:o}=t;f=n&&2===o.length;const u=vr.draco&&f?o[1]:o[0],d=vr.draco&&f?1:0;let E=c+`/nodes/${h.resource}/geometries/`+d;s&&(E+=".bin");const T={geometry:{url:E,info:u}};if(i&&Dr&&f&&!vr.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const m=e.layerScene.materialDefinitions,A=e.layerScene.textureSetDefinitions;let p,y=0;if(_&&(y=m[_.definition]),m){p=function(t,e,r,n,i,s){const o=JSON.parse(JSON.stringify(t));return Hr(o,e,r,n,i,s),o}(y,A,c,_.resource,r,e.layerScene.eslpk)}else p={pbrMetallicRoughness:{metallicFactor:0}};T.material=p,l.push(T)}return{dracoCompression:f,meshes:l,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:u}}function Hr(t,e,r,n,i,s){for(const o in t)if(t[o]&&t[o].textureSetDefinitionId>=0){const a=e[t[o].textureSetDefinitionId],c="images/"+a.formats[0].format,l=Vr(a.formats,i),f={url:r+`/nodes/${n}/textures/${l.name}`,factor:void 0===t[o].factor?1:t[o].factor,format:l.format,mimeType:c};if(s){let t="";switch(l.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=l.format}f.url+="."+t}t[o]=f}else A(t[o])&&Hr(t[o],e,r,n,i,s)}function Vr(t,e){for(let r=0;r<=t.length;r++){const n=t[r].format;if("dds"===n&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[r];if("jpg"===n||"png"===n)return t[r];if("ktx2"===n&&Pr)return t[r]}return null}const zr=[];class Yr extends i.renderer.CanvasRenderer{constructor(t){super(t),this.prepareWorker(),this.tilesLoading={},this.tileCache=new Wt(1024*t.options.maxGPUMemory*1024,this.deleteTile.bind(this)),this.Re={},this.be=[],this.fe=this.Ie.bind(this)}getAnalysisMeshes(){if(!this.painter)return zr;const t=this.painter.getPaintedMeshes();if(!t)return zr;const e=[],{b3dmMeshes:r,pntsMeshes:n,i3dmMeshes:i}=t;return r.length&&v(e,r),n.length&&v(e,n),i.length&&v(e,i),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.be.length||super.needToRedraw())}drawOnInteracting(t,e,r){this.draw(e,r)}draw(t,e){const r=this.prepareCanvas();if(r&&!r.intersects(this.canvasExtent2D))return void this.completeRender();const{root:n,tiles:i}=this.layer.getTiles(),s=i.length;if(!i||!s)return void this.completeRender();this.Ne(),this.Se();const{selectedTiles:o,leaves:a,requests:c}=this.we(n,i);c.length&&this.loadTiles(c),this.Me(o,a,e),this.Oe(),c.length||this.completeRender()}we(t,e){let r=[];this.ve();let n=0;const i=this.Ce(),s={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const i=e[t],c=i.node;if(s[c.id])continue;s[c.id]=1;let l=!1;const f=this.getCachedTile(c.id);if(this.xe(c.id)?(n++,l=a=!0,this.tilesLoading[c.id].current=!0):f?(this.getTileOpacity(f)<1&&(l=a=!0),o=!0,i.selected=!0,i.data=f):this.painter.has(c)||(l=a=!0,r.push(c)),!l)continue;if(this.Ue(i))o=!0;else{this.Be(i).length&&(o=!0)}}let c=[],l={};if(o&&({selectedTiles:c,leaves:l}=this.Pe(t)),r.length>1&&(r.sort(Xr),i)){const t=i-n;r=t>0?r.slice(0,t):[]}return{loading:a,requests:r,selectedTiles:c,leaves:l}}Pe(t){const e=[],r={};let n;const i=[t],s=[];for(;i.length>0||s.length>0;){if(s.length>0){const t=s[s.length-1];if(t.Le===i.length){s.pop(),t===n&&(t.leave=!0,r[t.node.id]=1),e.push(t);continue}}const t=i.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)r[t.node.id]=1,t.selectionDepth=s.length,e.push(t);else{if(t.selectionDepth=s.length,n=t,0===o.length){t.leave=!0,r[t.node.id]=1,e.push(t);continue}s.push(t),t.Le=i.length}for(let t=0;t<o.length;t++)i.push(o[t])}return{selectedTiles:e,leaves:r}}Ue(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}Be(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const r=t.De+1,n=[t.node];for(;n.length>0;){const i=n.pop().children;for(let s=0,o=i.length;s<o;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){n.push(i[s]);continue}const o=i[s].id;if(this.tileCache.has(o)){const r=this.layer.Fe(i[s],t);r.selected=!0,r.data=this.tileCache.get(o),t.children.push(r),e.push(r)}else i[s].De<=r&&n.push(i[s])}}return e}Me(t,e,r){this.tileCache.markAll(!1);for(let e=0,r=t.length;e<r;e++){const r=t[e].data;r.current=!0,this.tileCache.add(t[e].node.id,r)}this.tileCache.shrink();const n={tiles:t,leaves:e};this.onDrawTileStart(n);const i=r&&r.renderTarget,s=r&&r.sceneFilter,o=this.painter.paint(t,e,s,i);this.layer.options.debug&&this.painter.paintRegion(t,{color:this.layer.options.debugOutline},s,i),this.onDrawTileEnd(n),o&&this.layer.fire("canvasisdirty",{renderCount:o})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,r=t.length;e<r;e++){const r=t[e];this.tilesLoading[r.id]={current:!0,node:r},this.loadTile(r)}}loadTile(t){let e=t.content.url;if(M(e)){const r=O(e);return void this.Ge(e,r,t)}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const r=t.Ot,n=this.ke[r];return new Ur(e,r,n,this.fe).load().then((r=>{this.onTilesetLoad(r,t,e)}))}t&&-1===e.indexOf("http://")&&-1===e.indexOf("https://")&&!Fr(e)&&(e=t.baseUrl+e);const r=this.layer.options.services[t.Ot];if(r.ajaxInMainThread){let n=r.urlParams;n&&(n=(e.indexOf("?")>0?"&":"?")+n);let i=At.getArrayBuffer(e+(n||""),r.fetchOptions);const s=i.xhr;i=i.then((r=>{delete this.Re[e],r?this.Ge(e,r.data,t):this.onTileError(null,t)})).catch((r=>{delete this.Re[e],this.onTileError(r,t)})),this.Re[e]=s}else this.Ge(e,null,t)}Ge(t,e,n){let i=this.l;i||(i=r.reshader.Util.getSupportedFormats(this.gl.gl||this.gl),this.l=i);const s={url:t,arraybuffer:e,rootIdx:n.Ot,upAxis:n.qt,transform:n.matrix,supportedFormats:i};if(Fr(t)){const e=this.ke[n.Ot];if(s.i3sInfo=kr(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!s.i3sInfo)return void this.onTileError({status:404},n)}this.workerConn.loadTile(this.layer.getId(),s,((e,r)=>{if(e)return void this.onTileError(e,n);const{magic:i}=r;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i?this.be.push({data:r,tile:n}):this.onTilesetLoad(r,n,t)}))}Se(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let r=0;for(;this.be.length&&(r<e||!t.isInteracting());){const{data:t,tile:e}=this.be.shift(),{magic:n}=t;"b3dm"===n?this.painter.createB3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.He(t,e,r,n)})):"pnts"===n?this.painter.createPntsMesh(t,e.id,e,((r,{mesh:n})=>{this.He(t,e,r,n)})):"i3dm"===n?this.painter.createI3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.He(t,e,r,n)})):"cmpt"===n&&this.painter.createCMPTMesh(t,e.id,e,((r,{mesh:n})=>{this.He(t,e,r,n)})),r++}}He(t,e,r,n){if(r)this.onTileError(r,e);else{const r=this.Ve(n);e.memorySize=r,this.onTileLoad(t,e)}}Ve(t){let e=0;if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]&&(e+=this.Ve(t[r]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.ze(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,r){this.layer&&(t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.Ye(t,e,r):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,r)))}onTileError(t,e){if(!this.layer)return;const r=e.content.url;console.warn("failed to load 3d tile: "+r),console.warn(t),delete this.tilesLoading[e.id],this.Xe(e),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}Xe(t){const e={loadTime:i.Util.now(),current:!0,error:!0,node:t};this.tileCache.add(t.id,e)}ze(t){const e={loadTime:i.Util.now(),current:!0,node:t};this.tileCache.add(t.id,e)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;if(this.layer.options.services[t.node.Ot].ajaxInMainThread){const t=this.Re[e];t&&t.abort()}else this.workerConn.abortTileLoading(this.layer.getId(),e);delete this.Re[e]}ve(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}createContext(){const t=this.layer,e=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:t.options.antialias},n=this.canvas.gl&&this.canvas.gl.wrap;n?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.Ze(this.canvas,e)),this.regl=this.regl||r.createREGL({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),n&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.painter=new wr(this.regl,t)}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new Yt("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=T({},r),delete r.offset,r.projection=t.getSpatialReference().getProjection().code;const n=this.layer.getId();e.addLayer(n,r,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.Oe(!0),this.tileCache.reset(),this.tilesLoading={},super.clear()}clearCanvas(){this.regl&&this.regl.clear({color:[0,0,0,0],depth:1,stencil:0}),super.clearCanvas()}getTileOpacity(){return 1}getStencilValue(){return 0}Oe(t){this.We||(this.We=Date.now());const e=Date.now();if(t||!(e-this.We<this.layer.options.retireInterval)){this.We=e;for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||this.abortTileLoading(r)}}}Ce(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}Ze(t,e){const r=["webgl","experimental-webgl"];let n=null;for(let i=0;i<r.length;++i){try{n=t.getContext(r[i],e)}catch(t){}if(n)break}return n}xe(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,r){return ge(t,e,0,r)}Ne(){if(!this.je)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const r=[];for(const n in this.je){const i=this.je[n];if("pending"===i.status)continue;i.status="pending";const s=i.rootIdx;if(r.push(At.getJSON(n).then((t=>{delete this.je[n];const e=this.ke[s];if(e){t.nodes?Cr(e,t.nodes):(e[t.id]=t,Cr(e,t.children));for(let t=0;t<i.length;t++)i[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}r.length&&Promise.all(r)}Ie(t,e,r){this.je||(this.je={}),this.je[e]=this.je[e]||[],this.je[e].rootIdx=t,this.je[e].push(r),this.setToRedraw()}Ye(t,e,r){this.ke||(this.ke=[]);const n=e.Ot;this.ke[n]||(this.ke[n]={});const i=this.ke[n],s=this.layer.options.services[n];t.layers&&(t=t.layers[0],"/"!==r[r.length-1]&&(r+="/"),r+="layers/0"),i.version=+(s.i3sVersion||t.store.version),function(t,e,r,n,i,s){if(!i.layerScene){i.layerScene=t,i.nodesPerPage=t.nodePages&&t.nodePages.nodesPerPage||64,i.lodSelectionMetricType=t.nodePages&&t.nodePages.lodSelectionMetricType;let e=n;if(i.layerScene.eslpk=e.indexOf("3dSceneLayer.json")>=0,i.layerScene.eslpk){const t=n.lastIndexOf("/");e=t<0?"./":n.substring(0,t)}i.layerScene.baseUrl=function(t){return t.split("?")[0]}(e)}return new Ur(n,e,i,s).load()}(t,n,0,r,i,this.fe).then((t=>{this.onTilesetLoad(t,e,r)}))}pick(t,e,r){return this.painter?this.painter.pick(t,e,r&&r.tolerance):[]}}function Xr(t,e){return t.Dt-e.Dt}function Zr(t,e,r){return t[0]=e[r],t[1]=e[r+3],t[2]=e[r+6],t}function Wr(t,e,r){return Math.sqrt(function(t,e,r){var n=V(jr,r,t),i=Zr(Kr,e,0),s=Zr(qr,e,1),o=Zr($r,e,2),a=q(i),c=q(s),l=q(o);X(i,i),X(s,s),X(o,o);var f=Jr;f[0]=Z(n,i),f[1]=Z(n,s),f[2]=Z(n,o);var u,h=0;f[0]<-a?h+=(u=f[0]+a)*u:f[0]>a&&(h+=(u=f[0]-a)*u);f[1]<-c?h+=(u=f[1]+c)*u:f[1]>c&&(h+=(u=f[1]-c)*u);f[2]<-l?h+=(u=f[2]+l)*u:f[2]>l&&(h+=(u=f[2]-l)*u);return h}(t,e,r))}const jr=[],Kr=[],qr=[],$r=[],Jr=[];const Qr=2*Math.PI;class tn{constructor(t,e,r,n){this.west=t,this.south=e,this.east=r,this.north=n}static contains(t,e){var r=e[0],n=e[1],i=t.west,s=t.east;return s<i&&(s+=Qr,r<0&&(r+=Qr)),(r>i||Ee(r,i,1e-14))&&(r<s||Ee(r,s,1e-14))&&n>=t.south&&n<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const en=[0,0,1];function rn(t,e){return ee(e,t[0],t[1],t[2])}class nn{constructor(t,e){this.normal=r.vec3.copy([],t),this.distance=e}static fromPointNormal(t,e,n){var i=-r.vec3.dot(e,t);return r.vec3.copy(n.normal,e),n.distance=i,n}}const sn=[],on=[],an=[],cn=[],ln=[],fn=[],un=[],hn=[],_n=[],dn=[],En=new nn([1,0,0],0),Tn=[];class mn{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new tn(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){var n,i,s,o=0;if(!tn.contains(this.rectangle,e)){var a=this.southwestCornerCartesian,c=this.northeastCornerCartesian,l=this.westNormal,f=this.southNormal,u=this.eastNormal,h=this.northNormal,_=r.vec3.subtract(Tn,t,a),d=r.vec3.dot(_,l),E=r.vec3.dot(_,f),T=r.vec3.subtract(Tn,t,c),m=r.vec3.dot(T,u),A=r.vec3.dot(T,h);d>0?o+=d*d:m>0&&(o+=m*m),E>0?o+=E*E:A>0&&(o+=A*A)}if(n=e[2],i=this.minimumHeight,n>(s=this.maximumHeight)){var p=n-s;o+=p*p}else if(n<i){var y=i-n;o+=y*y}return Math.sqrt(o)}computeBox(t){const e=this;rn(tn.southwest(t,on),e.southwestCornerCartesian),rn(tn.northeast(t,on),e.northeastCornerCartesian),sn[0]=t.west,sn[1]=.5*(t.south+t.north),sn[2]=0;var n=rn(sn,an),i=r.vec3.cross(ln,n,en);r.vec3.normalize(e.westNormal,i),sn[0]=t.east;var s=rn(sn,hn),o=r.vec3.cross(ln,en,s);r.vec3.normalize(e.eastNormal,o);var a,c=r.vec3.subtract(ln,n,s),l=r.vec3.normalize(cn,c),f=t.south;if(f>0){sn[0]=.5*(t.west+t.east),sn[1]=f;var u=rn(sn,_n);r.vec3.copy(dn,l);var h=nn.fromPointNormal(e.southwestCornerCartesian,e.westNormal,En);An(_n,dn,h,e.southwestCornerCartesian),a=he(u,fn)}else a=_e(tn.southeast(t,on),fn);var _=r.vec3.cross(un,a,c);r.vec3.normalize(e.southNormal,_);var d,E=t.north;if(E<0){sn[0]=.5*(t.west+t.east),sn[1]=E;var T=rn(sn,_n);r.vec3.scale(dn,l,-1);var m=nn.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,En);An(_n,dn,m,e.northeastCornerCartesian),d=he(T,fn)}else d=_e(tn.northwest(t,on),fn);var A=r.vec3.cross(un,c,d);r.vec3.normalize(e.northNormal,A)}}function An(t,e,n,i){var s=t,o=e,a=n.normal,c=r.vec3.dot(a,o);if(!(Math.abs(c)<1e-15)){var l=(-n.distance-r.vec3.dot(a,s))/c;if(!(l<0))return i=r.vec3.scale(i,o,l),r.vec3.add(i,s,i)}}const pn=new i.Extent(0,0,0,0),yn=new i.Extent(0,0,0,0),gn=[],Rn=[],bn=[],In=[],Nn=new i.Point(0,0),Sn=[],wn=new i.Coordinate(0,0),Mn=r.mat4.identity([]);class On extends i.Layer{constructor(t,e){super(t,e),this.Ke(),this.Re={},this.qe=[]}Ke(){let t=this.options.services.map((t=>t.url));this.$e=t.map(((t,e)=>function(t,e){t=g(t);return{baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.mat4.identity([]),Ot:e,De:0}}(t,e))),this.fire("rootready",{roots:this.$e.slice(0)})}getExtent(t){if(!t&&0!==t){const t=new i.Extent;for(let e=0;e<this.$e.length;e++)if(this.$e[e].boundingVolume){const r=this.boundingVolumeToExtent(this.$e[e]);t._combine(r)}return t}return this.$e[t]&&this.$e[t].boundingVolume?this.boundingVolumeToExtent(this.$e[t]):null}boundingVolumeToExtent(t){const e=t.boundingVolume.Je?Mn:t.matrix,n=this.getMap();if(t.boundingVolume.region){const e=t.boundingVolume.region;return new i.Extent(y(e[0]),y(e[1]),y(e[2]),y(e[3]))}if(t.boundingVolume.sphere){const s=t.boundingVolume.sphere,o=ae([],r.vec3.transformMat4([],s,e)),a=s[3],c=n.locate(o,-a,a),l=n.locate(o,a,-a);return new i.Extent(c,l)}if(t.boundingVolume.box){const s=t.boundingVolume.box,o=r.vec3.transformMat4([],s,e),a=new i.Coordinate(ae([],o)),c=s.slice(3);r.mat3.multiply(c,r.mat3.fromMat4([],t.matrix),c);const l=r.vec3.length(c.slice(0,3)),f=r.vec3.length(c.slice(3,6)),u=r.vec3.length(c.slice(6,9)),h=Math.max(l,f,u),_=n.locate(a,-h,h),d=n.locate(a,h,-h);return new i.Extent(_,d)}return null}getRootTiles(){return this.$e}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Qe(),{tiles:In};const e=this.getMap(),n=e.cameraPosition;let i,s;if(e.getGLZoom)s=e.pointToDistance(n[2],0,e.getGLZoom()),wn.set(n[0],n[1]),i=e.pointToCoord(wn,e.getGLZoom());else{const t=e.getGLRes();s=e.pointAtResToDistance(n[2],0,t),wn.set(n[0],n[1]),i=e.pointAtResToCoord(wn,t)}this.tr=this.tr||[],r.vec3.set(this.tr,p(i.x),p(i.y),s),this.er=ee(this.er||[],this.tr[0],this.tr[1],this.tr[2]),this.rr=2*Math.tan(.5*p(e.getFov()));const o=e.projViewMatrix,a={children:[],level:-1};let c=a;const l=[];for(let e=0;e<this.$e.length;e++){let r=1/0;const n=[this.$e[e]],i=this.nr(e);for(;n.length>0;){const e=n.pop();for(e.id||this.ir(e);c.level>=e.De;)c=c.parent;const s=this.sr(e,i,o);if(s<1){let t=c;for(;t&&!t.content;)t=t.parent;0===s&&t&&t.content&&this.ar(l,t);if(!1===this.options.services[e.Ot].alwaysShow)continue;if(!(0===s&&e.De<=r))continue;e.content&&(r=e.De)}e.Dt<1/0&&this.cr(e);const a=this.Fe(e,c);c.children.push(a);const f=e.children,u=f&&f.length,h=a.content;if(!u&&h&&this.ar(l,a),u){h&&"add"===e.refine&&this.ar(l,a),c=a;const r=f[0].parent;let i=!1;for(let s=0,o=f.length;s<o;s++){if(r){const e=t.getCachedTile(f[s].id);if(e&&e.error)continue;i=!0}else{i=!0,f[s].parent=e,f[s].qt=e.qt,f[s].baseUrl=e.baseUrl;const t=f[s].content&&(f[s].content.url||f[s].content.uri);t&&(M(t)||t.indexOf("i3s:")>=0?f[s].baseUrl=e.baseUrl:-1===t.indexOf("http://")&&-1===t.indexOf("https://")?f[s].content.url=e.baseUrl+t:f[s].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}n.push(f[s])}!i&&h&&this.ar(l,a)}}}return{root:a,tiles:l}}ar(t,e){const{viewerRequestVolume:r}=e.node;r&&!function(t,e,r){if(r.region){const e=r.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(r.sphere)return vn(r,e);if(r.box)return 0===Cn(r,e)}return!1}(this.tr,this.er,r)||t.push(e)}Fe(t,e){return{id:t.id,node:t,children:[],level:t.De,parent:e,content:t.content&&t.content.url}}ir(t){t.id=i.Util.GUID(),t.matrix=t.transform||r.mat4.identity([]),t.lr=this.ur(t),t.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(t)||(t.matrix=r.mat4.multiply(t.matrix,t.parent.matrix,t.matrix)),t.Ot=t.parent.Ot,void 0===t.De&&(t.De=t.parent.De+1),t.maxExtent=t.parent.maxExtent),t.refine=t.refine&&t.refine.toLowerCase()||"replace",t.content&&!t.content.url&&t.content.uri&&(t.content.url=t.content.uri),this.hr(t)}hr(t){const e=t.boundingVolume;if(!e||e.Je)return;const n=this.options.services[t.Ot].heightOffset||0,i=this.options.offset,s=m(i)||i[0]||i[1];if(!t.boundingVolume||!n&&r.mat4.exactEquals(t.matrix,Mn)&&!s)return;const{region:o,box:a,sphere:c}=e;if(o){const t=this._r([y(o[0]),y(o[1])]);o[0]=p(t.x),o[1]=p(t.y);const e=this._r([y(o[2]),y(o[3])]);o[2]=p(e.x),o[3]=p(e.y),o[4]+=n,o[5]+=n}else if(a||c){const e=a||c,i=r.vec3.transformMat4(gn,e,t.matrix),s=ae(Rn,i),o=this._r([s[0],s[1]]);s[0]=o.x,s[1]=o.y,s[2]+=n,ee(e,p(s[0]),p(s[1]),s[2])}e.Je=!0}ur(t){return void 0===t.geometricError||!t.boundingVolume}cr(t){let e=t.parent;for(;e&&e.lr&&!(e.Dt<=t.Dt);)e.Dt=t.Dt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const r=e.content.url;e.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const n=this.getRenderer();n&&n.setToRedraw()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const i=(t.asset&&t.asset.gltfUpAxis||e&&e.qt||this.options.services[e.Ot].upAxis||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const s=n.indexOf("realspace/")>-1;t.asset&&t.asset.s3mType&&s&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.qt=i,e){const n=e.boundingVolume;T(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",n&&(e.boundingVolume=n);const i=t.root.transform;i&&(e.parent?o||(e.matrix=r.mat4.multiply([],e.parent.matrix,i)):e.matrix=i),this.hr(e),e.dr=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.lr=this.ur(e);const s=e.content&&(e.content.url||e.content.uri);s&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),o||!s||M(s)||-1!==s.indexOf("http://")||-1!==s.indexOf("https://")||(e.content.url=e.baseUrl+s)}this.Qe(),this.fire("loadtileset",{tileset:t,index:e.Ot,url:n})}sr(t,e,r){if(t.Dt=1/0,0===t.De||t.lr)return 1;if(!this.Er(t,e,r))return-1;if(0===t.geometricError)return 1;let n=this.options.services[t.Ot].maximumScreenSpaceError;null==n&&(n=8);let i=this.Tr(t);return 0===i&&t.parent&&(i=.5*(t.parent.mr||0)),i>=n?1:0}Yt(t,e){e||(e=new i.Point(0,0));const r=this.getMap();return r.getGLZoom?r.coordToPoint(t,r.getGLZoom(),e):r.coordToPointAtRes(t,r.getGLRes(),e)}Er(t,e,n){const s=t.id;let o=this.qe[s];const{boundingVolume:c}=t,l=c.sphere,_=c.region,E=c.box;if(!o){let e,n,a;if(_){e=pn.set(y(_[0]),y(_[1]),y(_[2]),y(_[3]));const t=e.getCenter(),r=this.Ar(t);e=e.convertTo((t=>this.Yt(t,Nn)),yn),a=_[4],n=_[5],o=this.qe[s]=[[e.xmin,e.ymin,a*r[2]],[e.xmax,e.ymax,n*r[2]]],o.center=t}else if(l){const t=ae(gn,l),e=new i.Coordinate(t),r=this.Yt(e,Nn).toArray(),n=this.Ar(e);r.push(t[2]*n[2]),o=this.qe[s]=[r,l[3]*n[2]],o.center=e}else if(E){const e=ae(gn,E),n=new i.Coordinate(e),a=this.Yt(n,Nn).toArray(),c=this.Ar(n);a.push(e[2]*c[2]);const l=E.slice(3);r.mat4.exactEquals(t.matrix,Mn)||r.mat3.multiply(l,r.mat3.fromMat4(Sn,t.matrix),l);for(let t=0;t<l.length;t++)l[t]*=c[t%3],E[3+t]=l[t];o=this.qe[s]=[...a,...l],o.center=n}}if(e){if(_)pn.xmin=o[0][0],pn.ymin=o[0][1],pn.xmax=o[1][0],pn.ymax=o[1][1];else if(l){const t=o[2];pn.xmin=o[0][0]-t,pn.ymin=o[0][1]-t,pn.xmax=o[0][0]+t,pn.ymax=o[0][1]+t}else if(E){const t=o[1],e=o[2];pn.xmin=o[0][0]-t,pn.ymin=o[0][1]-e,pn.xmax=o[0][0]+t,pn.ymax=o[0][1]+e}if(!e.intersects(pn))return!1}return _?f(n,o):l?function(t,e,r){h(t);for(var n=e[0],i=-e[1],s=0;s<6;s++)if((!r||"0"!==r.charAt(s))&&d(a[s],n)<i)return!1;return!0}(n,o):!!E&&function(t,e,r){h(t);for(var n=0;n<6;n++)if(!(r&&"0"===r.charAt(n)||u(a[n],e)))return!1;return!0}(n,o)}Ar(t){const e=this.getMap(),n=e.distanceToPointAtRes(100,100,e.getGLRes(),t);return r.vec3.set(bn,n.x/100*1.01,n.y/100*1.01,n.y/100),bn}_r(t){Array.isArray(t)&&(t=new i.Coordinate(t));let e=this.options.offset;if(m(e)&&(e=e(Array.isArray(t)?new i.Coordinate(t):t)),e[0]||e[1]){const r=this.getMap(),n=r.getGLRes(),i=r.coordToPointAtRes(t,n);return i._sub(e),r.pointAtResToCoord(i,n)}return t}nr(t){const e=this.options.services[t].maxExtent;if(!e)return null;const r=this.$e[t];return r.maxExtent||(r.maxExtent=new i.Extent(e).convertTo((t=>this.Yt(t)))),r.maxExtent}Tr(t){const e=this.rr,r=t.geometricError;if(0===r)return 0;const n=this.getMap();let i;t.boundingVolume.region?i=function(t,e,r){t.pr||(t.pr=new mn(t.boundingVolume.region));return t.pr.distanceToCamera(e,r)}(t,this.er,this.tr):t.boundingVolume.sphere?i=vn(t.boundingVolume,this.er):t.boundingVolume.box&&(i=Cn(t.boundingVolume,this.er));const s=Math.max(Math.abs(i),1e-7),o=r*n.height/(s*e);return t.Dt=i,t.mr=o,o}Qe(){const t=this.getRenderer();t&&t.setToRedraw()}ee(t){return this.qe[t]}identifyAtPoint(t,e={}){const r=this.getMap(),n=this.getRenderer();if(!r||!n)return[];const i=r.getDevicePixelRatio();return n.pick(t.x*i,t.y*i,e)}}function vn(t,e){const n=t.sphere,i=r.vec3.dist(n,e),s=t.sphere[3];return i<s?0:i-s}function Cn(t,e){const n=t.box;return Wr(r.vec3.set(gn,n[0],n[1],n[2]),r.mat3.set(Sn,n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]),e)}On.mergeOptions({"maxGPUMemory":512,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":0,"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"debug":!1,"debugOutline":[0,1,0],"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"antialias":!1,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"],"offset":[0,0]}),On.registerRenderer("gl",Yr),On.registerJSONType("Geo3DTilesLayer");class xn{constructor(t,e,r){this.o=t,this.yr=e||Lt,this.l=r,this.gr={"image/crn":vr.crn&&vr.crn(),"image/ktx2":vr.ktx2&&vr.ktx2(),"image/cttf":vr.ktx2&&vr.ktx2(),"draco":vr.draco&&vr.draco()}}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.Rr(t,e,r,n,i)):At.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.Rr(t,i,r,n)}))}Rr(t,e,r,n,i){const s=i&&i.maxTextureSize,o=this.br(e,r,n,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.yr(a,o.glb,{transferable:!0,requestImage:this.o,decoders:this.gr,supportedFormats:this.l,maxTextureSize:s});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${r}-${n}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}br(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+n;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),l=i.getUint32(20,!0),f=i.getUint32(24,!0),u=28+e;l>=570425344?(u-=8,o=a,l=c,f=0,a=0,c=0):f>=570425344&&(u-=4,o=l,l=a,f=c,a=0,c=0);const h=[t];let _,d,E;if(a>0?(_=Ae(t,u,a),u+=a,o=_.BATCH_LENGTH):_={"BATCH_LENGTH":o},c>0&&(u+=c),l>0&&(d=pe(t,u,l),u+=l,f>0)){const e=ye(0,u,f);E=t.slice(e.offset,e.offset+e.byteLength),u+=f,h.push(E)}const T=_.BATCH_LENGTH,m={};if(_&&_.BATCH_ID){m.BATCH_ID=Re(_.BATCH_ID,t,undefined.offset,T);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:o,transferables:h,featureTable:_,batchTable:d,batchTableBin:E,b3dm:m,glb:{buffer:t,byteOffset:u,byteLength:i.byteLength+i.byteOffset-u}}}Ir(){return null}}class Un{constructor(t,e,r,n){this.o=t,this.yr=e||Lt,this.l=r,this.gr={"image/crn":vr.crn&&vr.crn(),"image/ktx2":vr.ktx2&&vr.ktx2(),"image/cttf":vr.ktx2&&vr.ktx2(),"draco":vr.draco&&vr.draco()},this.Nr=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.Rr(t,e,r,n,i)):At.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.Rr(t,i,r,n)}))}Rr(t,e,r,n,i){return this.Sr(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const o=this.wr(e,r,n,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}Sr(t,e,r,n,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.o,decoders:this.gr,supportedFormats:this.l,maxTextureSize:s},a=new DataView(e,r,n),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let n=I(new Uint8Array(e,c+r,a.byteLength-c));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?At.getArrayBuffer(n,{}).then((t=>this.Mr(n,{buffer:t.data,byteOffset:0},o))):At.getJSON(n,{}).then((t=>this.Mr(n,t,o)))}{const n={buffer:e,byteOffset:c+r,byteLength:a.byteLength-c};return this.Mr(t,n,o)}}Mr(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.yr(n,e,r);return i.load({skipAttributeTransform:!0}).then((r=>{let n=0,s=0;return e.buffer&&(n=e.byteOffset||0,s=e.byteLength||0),r.url=`${t}-${n}-${s}`,{transferables:i.transferables,gltf:r}}))}wr(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:f}=ve(i,32+e,o),u={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(u.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,r=a.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=a.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.Or(new Uint16Array(t,n+c.offset,3*h),e,r)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=Re(a.BATCH_ID,t,c.offset,h);const e=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(u.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.vr(new Uint16Array(t,e+c.offset,2*h))},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.vr(new Uint16Array(t,e+c.offset,2*h))},o.push(u.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},o.push(u.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:l,batchTableBin:f,featureTable:a,i3dm:u,transferables:o}}vr(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)Bn(n,t[2*i],t[2*i+1],65535),r[3*i]=n[0],r[3*i+1]=n[1],r[3*i+2]=n[2];return r}Or(t,e,r){return Oe(new Float32Array(t.length),t,e,r)}Ir(){return null}}function Bn(t,e,r,n){if(t[0]=Pn(e,n),t[1]=Pn(r,n),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*Ln(e),t[1]=(1-Math.abs(e))*Ln(t[1])}return X(t,t)}function Pn(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,r){return t<e?e:t>r?r:t}(t,0,e)/e*2-1}function Ln(t){return t<0?-1:1}class Dn{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.Rr(t,e,r,n)):At.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.Rr(t,i,r,n)}))}Rr(t,e,r,n){return this.Cr(e,r,n,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}Cr(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:f}=ve(i,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,_=a.POINTS_LENGTH;let d,E={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){E=a.extensions["3DTILES_draco_point_compression"],d=new DataView(t,E.byteOffset+c.offset,E.byteLength);const e={attributes:E.properties,useUniqueIDs:!1};return this.Ur||(this.Ur=vr.draco()),this.Ur(d,e).then((e=>{const r=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=a.POSITION,r.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=a.RGB,r.RGBA=a.RGBA,r.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=a.NORMAL,r.NORMAL_OCT16P=a.NORMAL_OCT16P);const n=this.Br(t,e.attributes,c.offset,_,o,u,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Me(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?n.BATCH_ID=Re(a.BATCH_ID,t,c.offset,_):n.BATCH_ID=Fn(_);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:_,batchTable:l,batchTableBin:f,featureTable:a,pnts:n,transferables:o}}))}const T=this.Br(t,a,c.offset,_,o,u,h);if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?T.BATCH_ID=Re(a.BATCH_ID,t,c.offset,_):T.BATCH_ID=Fn(_);const e=T.BATCH_ID.array&&T.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:_,batchTable:l,batchTableBin:f,featureTable:a,pnts:T,transferables:o})}Br(t,e,r,n,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c,array:l}=e.POSITION_QUANTIZED;c=c||0;const f=l?0:r;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.Or(l||new Uint16Array(t,c+f,3*n),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+4*n);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+2*n);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+3*n*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+2*n);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:o},i.push(o.buffer)}return a}Or(t,e,r){return Oe(new Float32Array(t.length),t,e,r)}Ir(){return null}}function Fn(t){const e=w(t),r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Me(e),array:r}}class Gn{constructor(t,e){this.o=t,this.yr=e||Lt}load(t,e,r=0,n=0,i){return e?this.Rr(t,e,r,n,i):At.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.Rr(t,i,r,n)}))}Rr(t,e,r,n,i){n||(n=e.byteLength);const s=this.Pr(e,t,r,n),o=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new xn(this.o,this.yr);else if("i3dm"===s[r].magic)n=new Un(this.o,this.yr);else if("pnts"===s[r].magic)n=new Dn;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new Gn(this.o,this.yr)}o.push(n.load(t,e,s[r].offset,s[r].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Pr(t,e,r,n){const i=new DataView(t,r,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Te(i,c),n=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+r,byteLength:n}),c+=n}return o}}if(s.transcoders){const t=i.Map.VERSION;if(t.indexOf("1.0.0-beta")>=0||t.indexOf("1.0.0-alpha")>=0){const t=s.transcoders.inject(o);i.registerWorkerAdapter("@maptalks/3dtiles",t)}else i.registerWorkerAdapter("@maptalks/3dtiles",(function(){return s.transcoders.inject(o)}))}else i.registerWorkerAdapter("@maptalks/3dtiles",o);t.B3DMLoader=xn,t.CMPTLoader=Gn,t.Geo3DTilesLayer=On,t.Geo3DTilesUtil=C,t.Geo3DTransform=de,Object.defineProperty(t,"t",{value:!0}),"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.16.0")}));
|