@maptalks/3dtiles 0.97.2 → 0.98.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,23 +1,23 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/3dtiles v0.
|
|
2
|
+
* @maptalks/3dtiles v0.98.0
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
4
|
* (c) 2016-2024 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,n){"use strict";function r(t){if(t&&t.t)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var s=r(e),i=r(n);const o='function(t){var e="undefined"!=typeof Float32Array?Float32Array:Array;function n(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}function r(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 s(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],h=e[8],l=e[9],d=e[10],y=e[11],m=e[12],b=e[13],p=e[14],w=e[15],g=n[0],v=n[1],M=n[2],T=n[3];return t[0]=g*r+v*a+M*h+T*m,t[1]=g*s+v*c+M*l+T*b,t[2]=g*i+v*u+M*d+T*p,t[3]=g*o+v*f+M*y+T*w,g=n[4],v=n[5],M=n[6],T=n[7],t[4]=g*r+v*a+M*h+T*m,t[5]=g*s+v*c+M*l+T*b,t[6]=g*i+v*u+M*d+T*p,t[7]=g*o+v*f+M*y+T*w,g=n[8],v=n[9],M=n[10],T=n[11],t[8]=g*r+v*a+M*h+T*m,t[9]=g*s+v*c+M*l+T*b,t[10]=g*i+v*u+M*d+T*p,t[11]=g*o+v*f+M*y+T*w,g=n[12],v=n[13],M=n[14],T=n[15],t[12]=g*r+v*a+M*h+T*m,t[13]=g*s+v*c+M*l+T*b,t[14]=g*i+v*u+M*d+T*p,t[15]=g*o+v*f+M*y+T*w,t}function i(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}function o(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}function a(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,u=n*o,f=r*o,h=r*a,l=s*o,d=s*a,y=s*c,m=i*o,b=i*a,p=i*c;return t[0]=1-h-y,t[1]=f+p,t[2]=l-b,t[3]=0,t[4]=f-p,t[5]=1-u-y,t[6]=d+m,t[7]=0,t[8]=l+b,t[9]=d-m,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function c(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]}function u(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function f(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function h(t,n,r){var s=new e(3);return s[0]=t,s[1]=n,s[2]=r,s}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function d(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function y(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function m(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function b(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function p(t,e){var n=e[0],r=e[1],s=e[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i),t}function w(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function g(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[0],a=n[1],c=n[2];return t[0]=s*c-i*a,t[1]=i*o-r*c,t[2]=r*a-s*o,t}function v(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,t[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,t[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,t}var M=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},T=m,A=f;function _(t,e,n,r,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=s,t}function O(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3];return t[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,t[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,t[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,t[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,t}function x(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function S(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function I(t,e,n,r){var s=e[0],i=e[1],o=e[2],a=e[3],c=n[0],u=n[1],f=n[2],h=n[3],l=void 0,d=void 0,y=void 0,m=void 0,b=void 0;return(d=s*c+i*u+o*f+a*h)<0&&(d=-d,c=-c,u=-u,f=-f,h=-h),1-d>1e-6?(l=Math.acos(d),y=Math.sin(l),m=Math.sin((1-r)*l)/y,b=Math.sin(r*l)/y):(m=1-r,b=r),t[0]=m*s+b*c,t[1]=m*i+b*u,t[2]=m*o+b*f,t[3]=m*a+b*h,t}u(),function(){var t,n=(t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var k,E=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};u(),h(1,0,0),h(0,1,0),x(),x(),k=new e(9),e!=Float32Array&&(k[1]=0,k[2]=0,k[3]=0,k[5]=0,k[6]=0,k[7]=0),k[0]=1,k[4]=1,k[8]=1;\n/*!\n * @maptalks/gltf-loader v0.97.2\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.org\n */\nlet C=0;function U(t){return null==t}function F(t){return!U(t)}function N(t){return!U(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function P(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function B(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 R(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const L=[],z=[],j=[],V=[0,0,0],q=S([]),G=[1,1,1];function $(t,e,n,r,s,i,o){const a=B(o);if((0===s||s===r*a.BYTES_PER_ELEMENT)&&i%a.BYTES_PER_ELEMENT==0){const s=new a(e,i,n*r);return t.set(s),t}0===s&&(s=r*a.BYTES_PER_ELEMENT);const c=new Uint8Array(r*a.BYTES_PER_ELEMENT);for(let o=0;o<n;o++){let n=null;const u=new Uint8Array(e,s*o+i,r*a.BYTES_PER_ELEMENT);c.set(u),n=new a(c.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const X="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function H(t,e,n){const r=new Uint8Array(t,e,n);return X.decode(r)}const J={get:function(t,e={},n){e||(e={});const r=new AbortController,s=r.signal,i=P({},e);i.signal=s,i.method||(i.method="GET"),i.referrerPolicy=i.referrerPolicy||"origin","undefined"==typeof window||i.referrer||(i.referrer=window.location.href),n&&(t=n(t));const o=fetch(t,i).then(t=>{const n=this.t(t,e.responseType);return n.message?n:n.then(n=>"arraybuffer"===e.responseType?{data:n,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:n).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 o.xhr=r,o},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={},n)=>(e||(e={}),e.responseType="arraybuffer",J.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?J.jsonp(t):((e=e||{}).responseType="json",J.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+C++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let n=document.createElement("script");return n.type="text/javascript",n.src=t,new Promise(t=>{window[e]=function(r){document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[e],t(r)},document.getElementsByTagName("head")[0].appendChild(n)})}};class K{constructor(t,e,n,r,s){this.s=t,this.decoders=e,this.i=n,this.images={},this.o={},this.u=r||{},this.h=s}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.m(e,r);return this.getImageByBuffer(s,n)}if(this.o[t.id])return this.o[t.id].then(()=>{const r=this.buffers[t.id],s=this.m(e,r);return this.getImageByBuffer(s,n)});if(D(t.uri)){const r=this.buffers[t.id]=R(t.uri),s=this.m(e,r);return this.getImageByBuffer(s,n)}let r;const s=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.o[t.id]=J.getArrayBuffer(r,this.u,this.h).then(r=>{const s=this.buffers[t.id]=r.data,i=this.m(e,s);return this.getImageByBuffer(i,n)})}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;return n[e.mimeType]?n[e.mimeType](t,{supportedFormats:this.i}):"image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType?(console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null)):this.p(e.id,t)}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.o[t.id]?this.o[t.id].then(()=>this.images[t.id]):this.o[t.id]=this.p(t.id,e)}p(t,e){return new Promise((n,r)=>{let s=e;this.h&&(s=this.h(e)),this.s(s,this.u,(s,i)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=i,n(this.images[t]))})})}}const Y=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],Q=[];class W{constructor(t,e,n,r,s){this.rootPath=t,this.gltf=e,this.v=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.M(),this.u=r,this.h=s}T(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this.A(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const s=n.bufferViews[r.bufferView];return this._(s).then(n=>{const{buffer:s,byteOffset:i}=n;return this.accessors[r.id]=this.A(t,e,s,i)})}_(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]=R(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const n=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=J.getArrayBuffer(t,this.u,!n&&this.h).then(r=>(n&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=r.data,byteOffset:0}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}A(t,e,n,r=0){const s=this.gltf,i=s.accessors[e],o=void 0!==i.bufferView?s.bufferViews[i.bufferView]:{},a=(o.byteOffset||0)+r,c=this.O(i.type),u=B(i.componentType),f=o.byteStride||0,h={array:void 0,name:t,accessorName:e,byteLength:i.count*c*u.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:c,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(h.min=i.min),i.max&&(h.max=i.max),n)if(this.v)h.byteStride=f,h.byteOffset=a+(i.byteOffset||0),!f||f===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(h.array=this.S(n,i.count,c,a+(i.byteOffset||0),u),h.array.buffer.byteLength===h.byteLength&&(h.byteOffset=0)):h.array=new Uint8Array(n,a,o.byteLength);else if(i.interleaved){h.byteStride=0,h.byteOffset=0;const t=new u(i.count*c);if(h.array=$(t,n,i.count,c,f,a+(i.byteOffset||0),i.componentType),h.extensions&&h.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(h.array.length),{decodeMatrix:e}=h.extensions.WEB3D_quantized_attributes;for(let n=0;n<h.array.length;n+=c){Q[0]=h.array[n],Q[1]=h.array[n+1],Q[2]=h.array[n+2],Q[3]=1;const r=O(Q,Q,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}h.componentType=5126,h.array=t}}else h.byteStride=0,h.array=this.S(n,i.count,c,a+(i.byteOffset||0),u),h.byteOffset=h.array.byteOffset;else{h.array=new u(i.count);const t=h.min||h.max;t&&(h.array[0]=t[0],h.array[1]=t[1],h.array[2]=t[2])}return h}M(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}S(t,e,n,r,s){return r%s.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*s.BYTES_PER_ELEMENT),r=0),new s(t,r,n*e)}O(t){const e=Y.indexOf(t);return Y[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map(t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this._(e).then(r=>{const{buffer:s,byteOffset:i}=r,o=H(s,i+(e.byteOffset||0),n);return t.content=o,t})}if(t.uri){if(D(t.uri)){const e=R(t.uri),n=H(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return J.get(e,this.u,this.h).then(e=>(t.content=e,t))}}return Promise.resolve(t)});return Promise.all(n).then(()=>t)}}class Z extends K{constructor(t,e,n,r,s,i,o,a){super(r,s,i,o,a),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new W(t,e,n,o,a)}iterate(t,e){const n=this.gltf[e];if(!n)return;let r=0;for(const e in n)t(e,n[e],r++)}createNode(t){const e={};if(F(t.name)&&(e.name=t.name),F(t.children)&&(e.children=t.children),F(t.jointName)&&(e.jointName=t.jointName),F(t.matrix)&&(e.matrix=t.matrix),F(t.rotation)&&(e.rotation=t.rotation),F(t.scale)&&(e.scale=t.scale),F(t.translation)&&(e.translation=t.translation),F(t.extras)&&(e.extras=t.extras),F(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 n=i(L,e.translation||V),r=a(z,e.rotation||q),c=o(j,e.scale||G);return s(c,r,c),s(t,n,c)}return r(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}I(t){const e={};for(const n in t){const r=t[n];let s,i;r.instanceTechnique&&r.instanceTechnique.values?(s=r.instanceTechnique,i=s.values.diffuse):(s=r,i=s.values.tex||s.values.diffuseTex||s.values.diffuse);const o={baseColorTexture:{index:i}};r.name&&(o.name=r.name),r.extensions&&(o.extensions=r.extensions),r.extras&&(o.extras=r.extras),e[n]=o}return e}k(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 n=this.gltf.bufferViews[e.bufferView],r=(n.byteOffset||0)+this.glbBuffer.byteOffset,s=n.byteLength,i=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,s);return this.getImageByBuffer(i,t)}return this.requestExternalImage(t)}C(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.k(n).then(t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}})}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const s=this.gltf.textures[r];if(!s)return null;const i=this.gltf.samplers[s.sampler];return{format:s.format||6408,internalFormat:s.internalFormat||6408,type:s.type||5121,sampler:i,source:this.gltf.images[s.source]}}getMaterial(){return null}getAnimations(){return null}}class tt extends K{constructor(t,e,n,r,s,i,o,a){super(r,s,i,o,a),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new W(t,e,n,o,a)}iterate(t,e){const n=this.gltf[e];if(n)for(let e=0;e<n.length;e++)t(e,n[e],e)}createNode(t){const e={};return P(e,t),!F(t.weights)&&this.gltf.meshes&&F(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}C(t){const e=this.gltf.textures[t];if(!e)return null;let n=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(n=e.extensions.EXT_texture_webp.source),!F(n))return null;const r=this.gltf.images[n];return this.k(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 s=F(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||9729,n.sampler.minFilter=s.minFilter||9729,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),t.format&&(n.format=t.format),n})}k(t){if(!F(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],n=this.gltf.buffers[e.buffer];if(n.uri)return this.requestImageFromBufferURI(n,e,t);if(this.glbBuffer)return this.U(e,t)}return null}U(t,e){const n=this.m(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}m(t,e,n){n=n||0;const r=(t.byteOffset||0)+n,s=t.byteLength;return new Uint8Array(e,r,s)}F(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);return n.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)))}getAnimations(t){const e=[];return t.forEach(t=>{e.push(this.getSamplers(t.samplers))}),Promise.all(e).then(e=>{for(let n=0;n<e.length;n++)t[n].samplers=e[n];return t})}getSamplers(t){const e=[];for(let n=0;n<t.length;n++)(F(t[n].input)||F(t[n].output))&&(e.push(this.accessor.T("input",t[n].input)),e.push(this.accessor.T("output",t[n].output)));return Promise.all(e).then(e=>{for(let n=0;n<e.length/2;n++)t[n].input=e[2*n],t[n].output=e[2*n+1],t[n].interpolation||(t[n].interpolation="LINEAR");return t})}}const et="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class nt{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),s=r.getUint32(4,!0);if(1===s)return nt.readV1(r,e);if(2===s)return nt.readV2(t,e);throw new Error("Unsupported glb version : "+s)}static readV1(t,e){const n=t.getUint32(8,!0),r=t.getUint32(12,!0);if(n!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb\'s byte length.");const s=rt(t.buffer,20+e,r);return{json:JSON.parse(s),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,s;const i=new DataView(t,e+12);let o=0;for(;o<i.byteLength;){const a=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,1313821514===c)n=rt(t,e+12+o,a);else if(5130562===c){s=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:s,buffer:t,byteLength:r}}}}function rt(t,e,n){if(et){const r=new Uint8Array(t,e,n);return et.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=st[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}(new Uint8Array(t,e,n))}const st=[1,1,1,1,2,2,3,0],it=[0,0,0],ot=[0,0,0,1],at=[1,1,1],ct={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},ut={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},ft={N(t,e,n,r,s,i,o,a){const c=F(t)?e.animations:[e.animations[0]],u={};for(let e=0;e<c.length;e++){const f=c[e],h=f.name||e;if(F(t)&&h!==t)continue;const d=f.channelsMap[n];if(d)for(let t=0;t<d.length;t++){const e=d[t];"translation"===e.target.path?(this.P(s,f.samplers[e.sampler],r,1),u.translation=l(it,s)):"rotation"===e.target.path?(this.B(i,f.samplers[e.sampler],r,1),u.rotation=E(ot,i)):"scale"===e.target.path?(this.P(o,f.samplers[e.sampler],r,1),u.scale=l(at,o)):"weights"===e.target.path&&a&&(this.P(a,f.samplers[e.sampler],r,a.length),u.weights=a)}}return u},P(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.D(ut,e,n,1*r);s&&(t=function(t,e,n,r){for(let s=0;s<t.length;s++)t[s]=e[s]+r*(n[s]-e[s]);return t}(t,s.PREVIOUS,s.NEXT,s.INTERPOLATION));break}case"STEP":{const s=this.D(ut,e,n,1*r);s&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.D(ut,e,n,3*r);s&&(t=this.R(t,s,e.input.array,3*r));break}}return t},B(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.D(ut,e,n,1);r&&I(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.D(ut,e,n,1);r&&(t=_(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.D(ut,e,n,3);if(r){for(let t=0;t<r.PREVIOUS.length;t++)r.PREVIOUS[t]=Math.acos(r.PREVIOUS[t]),r.NEXT[t]=Math.acos(r.NEXT[t]);t=this.R(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},L(t,e){const n=t.length;let r,s,i,o=0,a=n-1,c=Math.floor((o+a)/2);for(;o<=n-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const n=t[c];return r=c,s=c+1,i=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:s,interpolation:i}}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},D(t,e,n,r){const s=e.input.array,i=e.output.array,o=e.output.itemSize;(n<s[0]||n>s[s.length-1])&&(n=Math.max(s[0],Math.min(s[s.length-1],n))),n===s[s.length-1]&&(n=s[0]);const a=this.L(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:u,interpolation:f}=a;t.PREINDEX=c,t.NEXTINDEX=u,t.INTERPOLATION=f;const h=o*r;return t.PREVIOUS=i.subarray(t.PREINDEX*h,(t.PREINDEX+1)*h),t.NEXT=i.subarray(t.NEXTINDEX*h,(t.NEXTINDEX+1)*h),t},R(t,e,n,r){const s=e.INTERPOLATION,i=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-i)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],f=(o-i)*e.NEXT[n],h=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*a+(Math.pow(s,3)-2*Math.pow(s,2)+s)*c+(2*-Math.pow(s,3)+3*Math.pow(s,2))*u+(Math.pow(s,3)-Math.pow(s,2))*f;t[n]=h}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;return d(it,...ct.TRANSLATION),_(ot,...ct.ROTATION),d(at,...ct.SCALE),this.N(r,t,e,n,it,ot,at,s)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach((e,n)=>{let r=-1/0,s=1/0;const i=e.channels;for(let t=0;t<i.length;t++){const n=i[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<s&&(s=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:s}}),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?F(e)?n[e]:n[Object.keys(n)[0]]:null}};let ht=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Ze){}t&&"undefined"!=typeof createImageBitmap&&(ht=!0)}const lt="undefined"==typeof document?null:document.createElement("canvas");class dt{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),this.u=this.options.fetchOptions||{},e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=nt.read(e.buffer,e.byteOffset,e.byteLength);this.j(t,n,r)}else this.j(t,e);this.V=new W(this.rootPath,this.gltf,this.glbBuffer,this.u,this.options.urlModifier),this.q()}q(){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")}}G(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.V.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then(e=>(t.KHR_techniques_webgl=e,t)):Promise.resolve(t)}load(t){t=t||{};const e=this.$(t),n=this.X(),r=this.H(),s=this.G();return Promise.all([e,n,r,s]).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 n=e[t];n.channelsMap={};for(let t=0;t<n.channels.length;t++){const e=n.channels[t];n.channelsMap[e.target.node]||(n.channelsMap[e.target.node]=[]),n.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:n}=this.gltf;for(let n=0;n<e.length;n++)e[n].uri&&e[n].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[n].uri});for(let e=0;e<n.length;e++)n[e].uri&&n[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:n[e].uri})}return t}static getAnimationClip(t,e,n,r){return ft.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return ft.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return B(t)}static readInterleavedArray(t,e,n,r,s,i,o){return $(t,e,n,r,s,i,o)}j(t,e,n){this.gltf=e,this.glbBuffer=n,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=ht?gt.bind(this):this.options.requestImage||yt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new tt(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.u,this.options.urlModifier),this.adapter.iterate((t,e,n)=>{e.id="buffer_"+n},"buffers"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors")):(this.adapter=new Z(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.u,this.options.urlModifier),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"))}J(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||N(t.children[0])))return t;const r=t.children.map(t=>{const n=e[t];return n.nodeIndex=t,this.J(n,e)});t.children=r}var n;return t}$(t){return this.K(t).then(t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.J(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate((r,s,i)=>{const o={};s.name&&(o.name=s.name),s.nodes&&(o.nodes=s.nodes.map(e=>t[e])),this.gltf.scene===r&&(n=i),e.push(o)},"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.I(this.gltf.materials);r.materials=t}return delete this.gltf.buffers,r.json=this.gltf,r})}K(t){return this.Y(t).then(()=>{const t=this.nodes={};return this.adapter.iterate((e,n)=>{const r=this.adapter.createNode(n,this.meshes,this.skins);t[e]=r},"nodes"),t})}W(){this.skins=[];const t=[];return this.adapter.iterate((e,n,r)=>{t.push(this.Z(n).then(t=>{t.index=r,this.skins.push(t)}))},"skins"),t}Z(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))}X(){const t=this.gltf.animations;return F(t)?this.adapter.getAnimations(t):null}Y(t){this.meshes={};let e=[];return this.adapter.iterate((n,r,s)=>{e.push(this.tt(r,t).then(t=>{t.index=s,this.meshes[n]=t}))},"meshes"),e=e.concat(this.W()),Promise.all(e)}tt(t,e){const n=t.primitives.map(t=>this.et(t,e)).filter(t=>!!t);return Promise.all(n).then(e=>{const n={};return P(n,t),n.primitives=e,n})}H(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.C(n));return Promise.all(e).then(e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t].image.array;if(e[t]&&n){let t;t=n instanceof ImageBitmap?n:n.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const n={},r=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(n[r[t]]=e[t]);return n}return e})}et(t,e){let n;const r=[],s=t.extensions;if(F(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const s=this.adapter.accessor.T(`morphTargets_${t}_${e}`,n[t]);s&&r.push(s)}}if(s&&s.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:i,attributes:o}=s.KHR_draco_mesh_compression,a=this.gltf.bufferViews[i],c=this.V._(a).then(n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:i}=a;const c=a.byteLength;i||(i=0);const u=new DataView(r,s+i,c),f={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(u,f).then(t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e})});r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor.T(t,e[t]);n&&r.push(n)}if(F(t.indices)){const e=this.adapter.accessor.T("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then(e=>{if(s&&s.KHR_draco_mesh_compression){const n=t.targets?t.targets.length:0;e[n]=e[n].concat(e.slice(0,n)),e=e[n]}let n,r;const i={attributes:e.reduce((t,e)=>{if("indices"===e.name)n=e;else if(e.name.indexOf("morphTargets_")>-1)r=r||{},r[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],{itemSize:r,array:s}=e,i=s.length/r;for(let e=0;e<i;e++)for(let i=0;i<r;i++){const o=e*r+i;s[o]<t[i]&&(t[i]=s[o]),s[o]>n[i]&&(n[i]=s[o])}if(e.quantization){const r=e.quantization,s=r.range/(1<<r.quantizationBits),i=r.minValues;b(t,t,s),y(t,t,i),b(n,n,s),y(n,n,i)}e.min=t,e.max=n}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 n&&(i.indices=n),r&&(i.morphTargets=r),i.mode=F(t.mode)?t.mode:4,F(t.extras)&&(i.extras=t.extras),i})}}function yt(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!lt)return void n(new Error("There is no canvas to draw image!"));lt.width=r.width,lt.height=r.height;const t=lt.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),s={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,s)},r.onerror=function(t){n(t)},r.src=t}const mt=[],bt=[];let pt,wt;function gt(t,e,n){pt||(pt=new OffscreenCanvas(2,2),wt=pt.getContext("2d",{willReadFrequently:!0}));let r=null;if(N(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),mt.push([t,e,n,this]),function t(){if(!mt.length||bt.length>10)return;const e=mt.shift(),[n,r,s,i]=e;bt.push(e),fetch(n,r).then(t=>t.arrayBuffer()).then(t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)}).then(vt.bind(i)).then(n=>{s.call(i,null,n);const r=bt.indexOf(e);bt.splice(r,1),t()}).catch(n=>{console.warn(n),s.call(i,n);const r=bt.indexOf(e);bt.splice(r,1),t()})}();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(vt.bind(this)).then(t=>{n(null,t)}).catch(t=>{console.warn(t),n(t)})}}function vt(t){let{width:e,height:n}=t;Mt(e)||(e=Tt(e)),Mt(n)||(n=Tt(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),pt.width=e,pt.height=n,wt.drawImage(t,0,0,e,n),t.close();const s=wt.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(s.data)}}function Mt(t){return 0==(t&t-1)&&0!==t}function Tt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var At={exports:{}},_t={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},Ot={exports:{}},xt=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},St=Array.prototype.concat,It=Array.prototype.slice,kt=Ot.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];xt(s)?e=St.call(e,It.call(s)):e.push(s)}return e};kt.wrap=function(t){return function(){return t(kt(arguments))}};var Et=_t,Ct=Ot.exports,Ut=Object.hasOwnProperty,Ft=Object.create(null);for(var Nt in Et)Ut.call(Et,Nt)&&(Ft[Et[Nt]]=Nt);var Pt=At.exports={to:{},get:{}};function Bt(t,e,n){return Math.min(Math.max(e,t),n)}function Dt(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}Pt.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=Pt.get.hsl(t),n="hsl";break;case"hwb":e=Pt.get.hwb(t),n="hwb";break;default:e=Pt.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},Pt.get.rgb=function(t){if(!t)return null;var e,n,r,s=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;s[n]=parseInt(e.slice(i,i+2),16)}r&&(s[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)s[n]=parseInt(e[n]+e[n],16);r&&(s[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)s[n]=parseInt(e[n+1],0);e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:Ut.call(Et,e[1])?((s=Et[e[1]])[3]=1,s):null:null;for(n=0;n<3;n++)s[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}for(n=0;n<3;n++)s[n]=Bt(s[n],0,255);return s[3]=Bt(s[3],0,1),s},Pt.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,Bt(parseFloat(e[2]),0,100),Bt(parseFloat(e[3]),0,100),Bt(isNaN(n)?1:n,0,1)]}return null},Pt.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,Bt(parseFloat(e[2]),0,100),Bt(parseFloat(e[3]),0,100),Bt(isNaN(n)?1:n,0,1)]}return null},Pt.to.hex=function(){var t=Ct(arguments);return"#"+Dt(t[0])+Dt(t[1])+Dt(t[2])+(t[3]<1?Dt(Math.round(255*t[3])):"")},Pt.to.rgb=function(){var t=Ct(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},Pt.to.rgb.percent=function(){var t=Ct(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},Pt.to.hsl=function(){var t=Ct(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},Pt.to.hwb=function(){var t=Ct(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},Pt.to.keyword=function(t){return Ft[t.slice(0,3)]};var Rt={exports:{}},Lt=_t,zt={};for(var jt in Lt)Lt.hasOwnProperty(jt)&&(zt[Lt[jt]]=jt);var Vt=Rt.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var qt in Vt)if(Vt.hasOwnProperty(qt)){if(!("channels"in Vt[qt]))throw new Error("missing channels property: "+qt);if(!("labels"in Vt[qt]))throw new Error("missing channel labels property: "+qt);if(Vt[qt].labels.length!==Vt[qt].channels)throw new Error("channel and label counts mismatch: "+qt);var Gt=Vt[qt].channels,$t=Vt[qt].labels;delete Vt[qt].channels,delete Vt[qt].labels,Object.defineProperty(Vt[qt],"channels",{value:Gt}),Object.defineProperty(Vt[qt],"labels",{value:$t})}function Xt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}Vt.rgb.hsl=function(t){var e,n,r=t[0]/255,s=t[1]/255,i=t[2]/255,o=Math.min(r,s,i),a=Math.max(r,s,i),c=a-o;return a===o?e=0:r===a?e=(s-i)/c:s===a?e=2+(i-r)/c:i===a&&(e=4+(r-s)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},Vt.rgb.hsv=function(t){var e,n,r,s,i,o=t[0]/255,a=t[1]/255,c=t[2]/255,u=Math.max(o,a,c),f=u-Math.min(o,a,c),h=function(t){return(u-t)/6/f+.5};return 0===f?s=i=0:(i=f/u,e=h(o),n=h(a),r=h(c),o===u?s=r-n:a===u?s=1/3+e-r:c===u&&(s=2/3+n-e),s<0?s+=1:s>1&&(s-=1)),[360*s,100*i,100*u]},Vt.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[Vt.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},Vt.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-s)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-s-e)/(1-e)||0),100*e]},Vt.rgb.keyword=function(t){var e=zt[t];if(e)return e;var n,r=1/0;for(var s in Lt)if(Lt.hasOwnProperty(s)){var i=Xt(t,Lt[s]);i<r&&(r=i,n=s)}return n},Vt.keyword.rgb=function(t){return Lt[t]},Vt.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},Vt.rgb.lab=function(t){var e=Vt.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},Vt.hsl.rgb=function(t){var e,n,r,s,i,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),s=[0,0,0];for(var u=0;u<3;u++)(r=o+1/3*-(u-1))<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,s[u]=255*i;return s},Vt.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,s=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,s*=i<=1?i:2-i,[e,100*(0===r?2*s/(i+s):2*n/(r+n)),100*((r+n)/2)]},Vt.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,s=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,s){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},Vt.hsv.hsl=function(t){var e,n,r,s=t[0],i=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-i)*o,n=i*a,[s,100*(n=(n/=(e=(2-i)*a)<=1?e:2-e)||0),100*(r/=2)]},Vt.hwb.rgb=function(t){var e,n,r,s,i,o,a,c=t[0]/360,u=t[1]/100,f=t[2]/100,h=u+f;switch(h>1&&(u/=h,f/=h),r=6*c-(e=Math.floor(6*c)),0!=(1&e)&&(r=1-r),s=u+r*((n=1-f)-u),e){default:case 6:case 0:i=n,o=s,a=u;break;case 1:i=s,o=n,a=u;break;case 2:i=u,o=n,a=s;break;case 3:i=u,o=s,a=n;break;case 4:i=s,o=u,a=n;break;case 5:i=n,o=u,a=s}return[255*i,255*o,255*a]},Vt.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,s=t[3]/100;return[255*(1-Math.min(1,e*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s))]},Vt.xyz.rgb=function(t){var e,n,r,s=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*s+1.8758*i+.0415*o,r=.0557*s+-.204*i+1.057*o,e=(e=3.2406*s+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},Vt.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},Vt.lab.xyz=function(t){var e,n,r,s=t[0];e=t[1]/500+(n=(s+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},Vt.lab.lch=function(t){var e,n=t[0],r=t[1],s=t[2];return(e=360*Math.atan2(s,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+s*s),e]},Vt.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},Vt.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:Vt.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},Vt.hsv.ansi16=function(t){return Vt.rgb.ansi16(Vt.hsv.rgb(t),t[2])},Vt.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},Vt.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},Vt.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},Vt.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},Vt.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},Vt.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(n,r),s),o=Math.min(Math.min(n,r),s),a=i-o;return e=a<=0?0:i===n?(r-s)/a%6:i===r?2+(s-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},Vt.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,s=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(s=(n-.5*r)/(1-r)),[t[0],100*r,100*s]},Vt.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},Vt.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var s,i=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return s=(1-n)*r,[255*(n*i[0]+s),255*(n*i[1]+s),255*(n*i[2]+s)]},Vt.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},Vt.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},Vt.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},Vt.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},Vt.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},Vt.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},Vt.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},Vt.gray.hsl=Vt.gray.hsv=function(t){return[0,0,t[0]]},Vt.gray.hwb=function(t){return[0,100,t[0]]},Vt.gray.cmyk=function(t){return[0,0,0,t[0]]},Vt.gray.lab=function(t){return[t[0],0,0]},Vt.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},Vt.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Ht=Rt.exports;function Jt(t){var e=function(){for(var t={},e=Object.keys(Ht),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),s=Object.keys(Ht[r]),i=s.length,o=0;o<i;o++){var a=s[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function Kt(t,e){return function(n){return e(t(n))}}function Yt(t,e){for(var n=[e[t].parent,t],r=Ht[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=Kt(Ht[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var Qt=Rt.exports,Wt=function(t){for(var e=Jt(t),n={},r=Object.keys(e),s=r.length,i=0;i<s;i++){var o=r[i];null!==e[o].parent&&(n[o]=Yt(o,e))}return n},Zt={};Object.keys(Qt).forEach((function(t){Zt[t]={},Object.defineProperty(Zt[t],"channels",{value:Qt[t].channels}),Object.defineProperty(Zt[t],"labels",{value:Qt[t].labels});var e=Wt(t);Object.keys(e).forEach((function(n){var r=e[n];Zt[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,s=0;s<r;s++)n[s]=Math.round(n[s]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),Zt[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var te=Zt,ee=At.exports,ne=te,re=[].slice,se=["keyword","gray","hex"],ie={};Object.keys(ne).forEach((function(t){ie[re.call(ne[t].labels).sort().join("")]=t}));var oe={};function ae(t,e){if(!(this instanceof ae))return new ae(t,e);if(e&&e in se&&(e=null),e&&!(e in ne))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ae)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var s=ee.get(t);if(null===s)throw new Error("Unable to parse color from string: "+t);this.model=s.model,r=ne[this.model].channels,this.color=s.value.slice(0,r),this.valpha="number"==typeof s.value[r]?s.value[r]:1}else if(t.length){this.model=e||"rgb",r=ne[this.model].channels;var i=re.call(t,0,r);this.color=he(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ie))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ie[a];var c=ne[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=he(u)}if(oe[this.model])for(r=ne[this.model].channels,n=0;n<r;n++){var f=oe[this.model][n];f&&(this.color[n]=f(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ce(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(oe[t]||(oe[t]=[]))[e]=n})),t=t[0],function(r){var s;return arguments.length?(n&&(r=n(r)),(s=this[t]()).color[e]=r,s):(s=this[t]().color[e],n&&(s=n(s)),s)}}function ue(t){return function(e){return Math.max(0,Math.min(t,e))}}function fe(t){return Array.isArray(t)?t:[t]}function he(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function le(t){return null==t}function de(t){return"object"==typeof t&&!!t}function ye(t){return t/Math.PI*180}function me(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}ae.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in ee.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return ee.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return ee.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=ne[this.model].channels,n=ne[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ae(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ae(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ce("rgb",0,ue(255)),green:ce("rgb",1,ue(255)),blue:ce("rgb",2,ue(255)),hue:ce(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ce("hsl",1,ue(100)),lightness:ce("hsl",2,ue(100)),saturationv:ce("hsv",1,ue(100)),value:ce("hsv",2,ue(100)),chroma:ce("hcg",1,ue(100)),gray:ce("hcg",2,ue(100)),white:ce("hwb",1,ue(100)),wblack:ce("hwb",2,ue(100)),cyan:ce("cmyk",0,ue(100)),magenta:ce("cmyk",1,ue(100)),yellow:ce("cmyk",2,ue(100)),black:ce("cmyk",3,ue(100)),x:ce("xyz",0,ue(100)),y:ce("xyz",1,ue(100)),z:ce("xyz",2,ue(100)),l:ce("lab",0,ue(100)),a:ce("lab",1),b:ce("lab",2),keyword:function(t){return arguments.length?new ae(t):ne[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ae(t):ee.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ae.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error(\'Argument to "mix" was not a Color instance, but rather an instance of \'+typeof t);var n=t.rgb(),r=this.rgb(),s=void 0===e?.5:e,i=2*s-1,o=n.alpha()-r.alpha(),a=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-a;return ae.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*s+r.alpha()*(1-s))}},Object.keys(ne).forEach((function(t){if(-1===se.indexOf(t)){var e=ne[t].channels;ae.prototype[t]=function(){if(this.model===t)return new ae(this);if(arguments.length)return new ae(arguments,t);var n="number"==typeof arguments[e]?e:this.valpha;return new ae(fe(ne[this.model][t].raw(this.color)).concat(n),t)},ae[t]=function(n){return"number"==typeof n&&(n=he(re.call(arguments),e)),new ae(n,t)}}}));const be=[1,1,1,1,2,2,3,0];function pe(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=be[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}new Array(3),new Array(3);const we=[1/6378137,1/6378137,1/6356752.314245179],ge=[1/40680631590769,1/40680631590769,1/40408299984661.445],ve=new Array(3),Me=new Array(3),Te=new Array(3);function Ae(t,e){const n=ge,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],u=n[1],f=n[2],h=i*i*c*c,l=o*o*u*u,d=a*a*f*f,y=h+l+d,m=Math.sqrt(1/y),p=b(_e,e,m);if(y<s)return isFinite(m)?p:void 0;const w=r[0],g=r[1],v=r[2],M=Oe;M[0]=p[0]*w*2,M[1]=p[1]*g*2,M[2]=p[2]*v*2;let T,A,_,O,x,S,I,k,E,C,U,F=(1-m)*xe(e)/(.5*xe(M)),N=0;do{F-=N,_=1/(1+F*w),O=1/(1+F*g),x=1/(1+F*v),S=_*_,I=O*O,k=x*x,E=S*_,C=I*O,U=k*x,T=h*S+l*I+d*k-1,A=h*E*w+l*C*g+d*U*v;N=T/(-2*A)}while(Math.abs(T)>1e-12);return t[0]=i*_,t[1]=o*O,t[2]=a*x,t}(ve,e,we,n,.1);let s=T(Me,r,n);s=function(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i);return t}(s,s);const i=M(Te,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=me(w(i,e))*xe(i);return t[0]=ye(o),t[1]=ye(a),t[2]=c,t}const _e=new Array(3),Oe=new Array(3);function xe(t){return f(t)}function Se(t,e,n,r){n=n||0,r=r||n;const s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function Ie(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const ke="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ee(t,e,n){const r=new Uint8Array(t,e,n);return ke?JSON.parse(ke.decode(r)):JSON.parse(pe(r))}function Ce(t,e,n){const r=new Uint8Array(t,e,n);return ke?JSON.parse(ke.decode(r)):JSON.parse(pe(r))}function Ue(t,e,n){return{offset:e,byteLength:n}}function Fe(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=function(t){return Be[t]}(i||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Pe[t]}(o);return{byteStride:0,byteOffset:s+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+s,r*u)}}function Ne(t,e,n,r){const s=Fe(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}const Pe={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Be={"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 De(t){for(const e in Be)if(t===Be[e].ctor)return Be[e].type;throw new Error("unrecognized ctor:"+t)}function Re(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function Le(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,u={},f={},h=null;r>0&&(u=Ee(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(f=Ce(a,e,i),e+=i);const l=Ue(0,e,o);return h=a.slice(l.offset,l.offset+l.byteLength),n.push(h),{featureTable:u,featureTableBin:c,batchTable:f,batchTableBin:h}}const 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"}},je={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Ve={},qe={east:[],north:[],up:[],west:[],south:[],down:[]};let Ge=[],$e=[],Xe=[];const He=[0,0,0];const Je=function(t,e){const n=ze[t][e];let r;const s=t+e;return Ve[s]?r=Ve[s]:(r=function(r,s,i){if(function(t,e){var n=t[0],r=t[1],s=t[2],i=e[0],o=e[1],a=e[2];return Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}(r,He))l(Ge,je[t]),l($e,je[e]),l(Xe,je[n]);else if(Se(r[0],0,1e-14)&&Se(r[1],0,1e-14)){const s=me(r[2]);l(Ge,je[t]),"east"!==t&&"west"!==t&&b(Ge,Ge,s),l($e,je[e]),"east"!==e&&"west"!==e&&b($e,$e,s),l(Xe,je[n]),"east"!==n&&"west"!==n&&b(Xe,Xe,s)}else{!function(t,e){m(e,t,ge),p(e,e)}(r,qe.up);const s=qe.up,i=qe.east;i[0]=-r[1],i[1]=r[0],i[2]=0,p(qe.east,i),g(qe.north,s,i),b(qe.down,qe.up,-1),b(qe.west,qe.east,-1),b(qe.south,qe.north,-1),Ge=qe[t],$e=qe[e],Xe=qe[n]}return i[0]=Ge[0],i[1]=Ge[1],i[2]=Ge[2],i[3]=0,i[4]=$e[0],i[5]=$e[1],i[6]=$e[2],i[7]=0,i[8]=Xe[0],i[9]=Xe[1],i[10]=Xe[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i},Ve[s]=r),r}("east","north"),Ke={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Ye(t){for(const e in Ke)if(t===Ke[e])return+e;throw new Error("unrecognized ctor:"+t)}\n/*!\n * @maptalks/gl v0.97.2\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.com\n */const Qe=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")},We=Qe(),Ze=We.gl_trans__coders=We.gl_trans__coders||{};Ze.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=We.gl_trans__coders=We.gl_trans__coders||{};let i=`${r}\\n const _____getGlobal = ${Qe.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals[\'gl_trans__coders\'] = g___lobals[\'gl_trans__coders\'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+=\'tran_____scoders["\'+t+\'"] =\'+s[t].toString()+"\\n;");return i+="\\n"+e.substring(r.length),i},Ze.registerTranscoder=function(t,e){Ze[t]=e},Ze.getTranscoder=function(t){return Ze[t]};let tn=null;function en(){return tn||(tn={"image/crn":Ze.crn&&Ze.crn(),"image/ktx2":Ze.ktx2&&Ze.ktx2(),"image/cttf":Ze.ktx2&&Ze.ktx2(),"draco":Ze.draco&&Ze.draco()}),tn}class nn{constructor(t,e,n){this.s=t,this.nt=e||dt,this.i=n,this.rt=en()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.st(t,e,n,r,s)):J.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.st(t,s,n,r)})}st(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.it(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.nt(a,o.glb,{transferable:!0,requestImage:this.s,decoders:this.rt,supportedFormats:this.i,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then(e=>{e.url=`${t}-${n}-${r}`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}})}it(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm\'s byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),u=s.getUint32(20,!0),f=s.getUint32(24,!0),h=28+e;u>=570425344?(h-=8,o=a,u=c,f=0,a=0,c=0):f>=570425344&&(h-=4,o=u,u=a,f=c,a=0,c=0);const l=[t];let d,y,m;if(a>0?(d=Ee(t,h,a),h+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(h+=c),u>0&&(y=Ce(t,h,u),h+=u,f>0)){const e=Ue(0,h,f);m=t.slice(e.offset,e.offset+e.byteLength),h+=f,l.push(m)}const b=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=Ne(d.BATCH_ID,t,(void 0).offset,b);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&l.indexOf(e)<0&&l.push(e)}return{count:o,transferables:l,featureTable:d,batchTable:y,batchTableBin:m,b3dm:p,glb:{buffer:t,byteOffset:h,byteLength:s.byteLength+s.byteOffset-h}}}ot(){return null}}class rn{constructor(t,e,n,r){this.s=t,this.nt=e||dt,this.i=n,this.rt=en(),this.ct=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.st(t,e,n,r,s)):J.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.st(t,s,n,r)})}st(t,e,n,r,s){return this.ut(t,e,n,r,s).then(({gltf:s,transferables:i})=>{const o=this.ft(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})})}ut(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.s,decoders:this.rt,supportedFormats:this.i,maxTextureSize:i},a=new DataView(e,n,r),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 r=pe(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?J.getArrayBuffer(r,{}).then(t=>this.ht(r,{buffer:t.data,byteOffset:0},o)):J.getJSON(r,{}).then(t=>this.ht(r,t,o))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.ht(t,r,o)}}ht(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.nt(r,e,n);return s.load({skipAttributeTransform:!0}).then(n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=`${t}-${r}-${i}`,{transferables:s.transferables,gltf:n}})}ft(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=Le(s,32+e,o),h={},l=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;h.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;h.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.lt(new Uint16Array(t,r+c.offset,3*l),e,n)},o.push(h.POSITION.array.buffer)}if(a.BATCH_ID){h.BATCH_ID=Ne(a.BATCH_ID,t,c.offset,l);const e=h.BATCH_ID.array&&h.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;h.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;h.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.dt(new Uint16Array(t,e+c.offset,2*l))},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.dt(new Uint16Array(t,e+c.offset,2*l))},o.push(h.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;h.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,l).slice()},o.push(h.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;h.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.SCALE_NON_UNIFORM.array.buffer)}return{count:l,batchTable:u,batchTableBin:f,featureTable:a,i3dm:h,transferables:o}}dt(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)sn(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}lt(t,e,n){return Re(new Float32Array(t.length),t,e,n)}ot(){return null}}function sn(t,e,n,r){if(t[0]=on(e,r),t[1]=on(n,r),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]))*an(e),t[1]=(1-Math.abs(e))*an(t[1])}return p(t,t)}function on(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function an(t){return t<0?-1:1}class cn{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.st(t,e,n,r)):J.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.st(t,s,n,r)})}st(t,e,n,r){return this.yt(e,n,r,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})}yt(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=Le(s,e+28,o),h=a.QUANTIZED_VOLUME_OFFSET,l=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let y,m={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){m=a.extensions["3DTILES_draco_point_compression"],y=new DataView(t,m.byteOffset+c.offset,m.byteLength);const e={attributes:m.properties,useUniqueIDs:!1};return this.bt||(this.bt=en().draco),this.bt(y,e).then(e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.pt(t,e.attributes,c.offset,d,o,h,l);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:De(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Ne(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=un(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:u,batchTableBin:f,featureTable:a,pnts:r,transferables:o}})}const b=this.pt(t,a,c.offset,d,o,h,l);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?b.BATCH_ID=Ne(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=un(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:u,batchTableBin:f,featureTable:a,pnts:b,transferables:o})}pt(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const f=u?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.lt(u||new Uint16Array(t,c+f,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}lt(t,e,n){return Re(new Float32Array(t.length),t,e,n)}ot(){return null}}function un(t){const e=(n=t)<256?Uint8Array:n<65536?Uint16Array:Uint32Array;var n;const r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:De(e),array:r}}class fn{constructor(t,e,n,r){this.i=n,this.s=t,this.nt=e||dt,this.ct=r}load(t,e,n=0,r=0,s){return e?this.st(t,e,n,r,s):J.getArrayBuffer(t,{}).then(e=>{const s=e.data;return this.st(t,s,n,r)})}st(t,e,n,r,s){r||(r=e.byteLength);const i=this.wt(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new nn(this.s,this.nt,this.i);else if("i3dm"===i[n].magic)r=new rn(this.s,this.nt,this.i,this.ct);else if("pnts"===i[n].magic)r=new cn;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new fn(this.s,this.nt,this.i,this.ct)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then(t=>t))}return Promise.all(o).then(t=>({magic:"cmpt",tiles:t}))}wt(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Ie(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function hn(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];wn(r[n],s,t,e)}}}const ln=[],dn=[],yn=[],mn=[0,0,0],bn=S([]),pn=[1,1,1];function wn(t,e,n,r){const c=e.slice(0);if(t.matrix)c.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=i(ln,t.translation||mn),n=a(dn,t.rotation||bn),r=o(yn,t.scale||pn);s(r,n,r);const u=s([],e,r);c.push(u)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)wn(t.children[e],c,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=c.slice(0),i=s.primitives;for(let s=0,o=i.length;s<o;s++){const o=i[s];o&&(o.matrices=t,r(o,e,s,n))}}}}function gn(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?dt.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===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 u=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);u.set(s);e(new c(u.buffer),t),s.set(u)}}var vn=On("DXT1"),Mn=On("DXT3"),Tn=On("DXT5"),An=On("DX10"),_n=function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var s=r[21];switch(s){case vn:e=8,n="dxt1";break;case Mn:e=16,n="dxt3";break;case Tn:e=16,n="dxt5";break;case 116:n="rgba32f";break;case An:var i=new Uint32Array(t.slice(128,148));n=i[0];var o=i[1];if(i[2],i[3],i[4],3!==o||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=s,String.fromCharCode(255&a,a>>8&255,a>>16&255,a>>24&255)))}var a;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var f=!1;512&r[28]&&(f=!0);var h,l=r[4],d=r[3],y=r[1]+4,m=l,b=d,p=[];s===An&&(y+=20);if(f)for(var w=0;w<6;w++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");l=m,d=b;for(var g=Math.log(l)/Math.log(2)+1,v=0;v<g;v++)h=l*d*16,p.push({offset:y,length:h,shape:[l,d]}),v<u&&(y+=h),l=Math.floor(l/2),d=Math.floor(d/2)}else for(v=0;v<u;v++)h=Math.max(4,l)/4*Math.max(4,d)/4*e,p.push({offset:y,length:h,shape:[l,d]}),y+=h,l=Math.floor(l/2),d=Math.floor(d/2);return{shape:[m,b],images:p,format:n,flags:c,cubemap:f}};function On(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var xn=Math.abs,Sn=Math.sin,In=Math.cos,kn=Math.tan,En=Math.atan,Cn=Math.atan2,Un=Math.sqrt,Fn=Math.log,Nn=Math.hypot,Pn=Math.sinh,Bn=Math.cosh;function Dn(t){var e,n,r,s,i,o,a=[],c=[],u=[],f=[];function h(t,e){for(var n,r=2*In(2*e),s=t.length-1,i=t[s],o=0;--s>=0;)n=r*i-o+t[s],o=i,i=n;return e+n*Sn(2*e)}function l(t,e,n){for(var r,s,i=Sn(e),o=In(e),a=Pn(n),c=Bn(n),u=2*o*c,f=-2*i*a,h=t.length-1,l=t[h],d=0,y=0,m=0;--h>=0;)r=y,s=d,l=u*(y=l)-r-f*(d=m)+t[h],m=f*y-s+u*d;return[(u=i*c)*l-(f=o*a)*m,u*m+f*l]}t.es,i=s=(r=t.es/(1+Un(1-t.es)))/(2-r),a[0]=s*(2+s*(-2/3+s*(s*(116/45+s*(26/45+s*(-2854/675)))-2))),c[0]=s*(s*(2/3+s*(4/3+s*(-82/45+s*(32/45+s*(4642/4725)))))-2),i*=s,a[1]=i*(7/3+s*(s*(-227/45+s*(2704/315+s*(2323/945)))-1.6)),c[1]=i*(5/3+s*(-16/15+s*(-13/9+s*(904/315+s*(-1522/945))))),i*=s,a[2]=i*(56/15+s*(-136/35+s*(-1262/105+s*(73814/2835)))),c[2]=i*(-26/15+s*(34/21+s*(1.6+s*(-12686/2835)))),i*=s,a[3]=i*(4279/630+s*(-332/35+s*(-399572/14175))),c[3]=i*(1237/630+s*(s*(-24832/14175)-2.4)),i*=s,a[4]=i*(4174/315+s*(-144838/6237)),c[4]=i*(-734/315+s*(109598/31185)),i*=s,a[5]=i*(601676/22275),c[5]=i*(444337/155925),i=s*s,e=t.k0/(1+s)*(1+i*(1/4+i*(1/64+i/256))),u[0]=s*(s*(2/3+s*(-37/96+s*(1/360+s*(81/512+s*(-96199/604800)))))-.5),f[0]=s*(.5+s*(-2/3+s*(5/16+s*(41/180+s*(-127/288+s*(7891/37800)))))),u[1]=i*(-1/48+s*(-1/15+s*(437/1440+s*(-46/105+s*(1118711/3870720))))),f[1]=i*(13/48+s*(s*(557/1440+s*(281/630+s*(-1983433/1935360)))-.6)),i*=s,u[2]=i*(-17/480+s*(37/840+s*(209/4480+s*(-5569/90720)))),f[2]=i*(61/240+s*(-103/140+s*(15061/26880+s*(167603/181440)))),i*=s,u[3]=i*(-4397/161280+s*(11/504+s*(830251/7257600))),f[3]=i*(49561/161280+s*(-179/168+s*(6601661/7257600))),i*=s,u[4]=i*(-4583/161280+s*(108847/3991680)),f[4]=i*(34729/80640+s*(-3418889/1995840)),i*=s,u[5]=i*(-20648693/638668800),f[5]=.6650675310896665*i,o=h(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*In(e),s=t.length-1,i=t[s],o=0;for(;--s>=0;)n=r*i-o+t[s],o=i,i=n;return Sn(e)*n}(f,2*o)),t.fwd=function(t,r){var s,i,o,a,u,d=t.phi,y=t.lam;d=h(c,d),s=Sn(d),i=In(d),a=Sn(y),o=In(y),d=Cn(s,o*i),y=Cn(a*i,Nn(s,i*o)),y=function(t){var e=xn(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*Fn(e)/n}(e*(1+e/(Nn(1,e)+1))),t<0?-e:e}(kn(y)),u=l(f,2*d,2*y),d+=u[0],y+=u[1],xn(y)<=2.623395162778?(r.y=e*d+n,r.x=e*y):r.x=r.y=1/0},t.inv=function(t,r){var s,i,o,c,f,d=t.y,y=t.x;d=(d-n)/e,xn(y/=e)<=2.623395162778?(f=l(u,2*d,2*y),d+=f[0],y+=f[1],y=En(Pn(y)),s=Sn(d),i=In(d),c=Sn(y),o=In(y),y=Cn(c,o*i),d=Cn(s*o,Nn(c,o*i)),r.phi=h(a,d),r.lam=y):r.phi=r.lam=1/0}}const Rn=Math.PI/180,Ln=6378137*Math.PI/180,zn={};function jn(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=85.0511287798,r=e[0],s=Math.max(Math.min(n,e[1]),-n);let i;i=0===s?0:Math.log(Math.tan((90+s)*Rn/2))/Rn;return t[0]=r*Ln,t[1]=i*Ln,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return Vn(t,e);if("baidu"===n)return Vn(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const s=JSON.stringify(n);let i=zn[s];return i||(i=zn[s]=function(t){const e={a:6378137,es:.0066943799901413165,x0:le(t.falseEasting)?5e5:t.falseEasting,y0:le(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*qn,phi0:(t.latitudeOfOrigin||0)*qn,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Dn(e);const n={lam:0,phi:0},r={};let s=0,i=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*qn-e.lam0,n.phi=e.originPhi0*qn,e.fwd(n,r),s=e.a*r.x+e.x0,i=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*qn-e.lam0,n.phi=t[1]*qn,e.fwd(n,r);const a=e.a*r.x+e.x0-s,c=e.a*r.y+e.y0-i;return o[0]=a,o[1]=c,o}}}(n)),i.project(e,t)}}function Vn(t,e){return t[0]=e[0],t[1]=e[1],t}const qn=.017453292519943295;const Gn=r([]),$n=en().draco,Xn=en().ktx2,Hn={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},Jn={"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":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function Kn(t,e,n,s,i,o){const a=[],c=[],u=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],s=J.getArrayBuffer(n.url,o);s.xhr.url=n.url,u.push(s.xhr);const i=s.then(t=>({buffer:t}));a.push(i);const f=[];if(nr(r,f),f.length){const t=f.map(t=>{const e=J.getArrayBuffer(t.url,o);return e.xhr.url=t.url,u.push(e.xhr),e.then(e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format})});a.push(...t)}c[e]=f.length}const f=Promise.all(a).then(o=>{for(let t=0;t<o.length;t++)if(!o[t]||!o[t].buffer)return Promise.resolve(null);const a=[];let u=0;for(let t=0;t<c.length;t++){const e=c[t];a.push({geoBuffer:{data:o[u].buffer.data},textureBuffers:o.slice(u+1,e+u+1).map(t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format}))}),u+=1+e}return function(t,e,n,s,i,o){const a={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let u=0;u<t.meshes.length;u++){let{material:f}=t.meshes[u];const{geometry:h}=t.meshes[u];let l;const d=e[u].geoBuffer.data;if(!d)continue;const y=cr(d);l=y?Qn(a,u,h,d,t.transform,t.center,i,o):Zn(a,u,h,d,t.transform,t.center,i,o),c.push(l),a.nodes[u]={mesh:u,nodeIndex:u,matrix:r([])},a.scenes[0].nodes[u]=a.nodes[u],f||(f=Hn);const m=er(u,a,f,e[u].textureBuffers,n,s);c.push(m)}return Promise.all(c).then(()=>({gltf:a,featureTable:{BATCH_LENGTH:0},transferables:a.transferables}))}(t,a,e,i,n,s)});return f.xhr=u,f}const Yn={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Qn(t,e,n,r,s,i,o,a){const c=n.info.compressedAttributes.attributes.reduce((t,e,n)=>{const r=Jn[e];if(!r)return t;return t[r.name||e]=n,t},{});return $n(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then(n=>tr(n,t,e,s,i,o,a))}const Wn={position:function(t,e,n){const r=3*t.vertexCount,s=new Float32Array(e,n,r);return t.position={array:s,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,s=new Float32Array(e,n,r);return t.normal={array:s,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,s=new Float32Array(e,n,r);return t.uv0={array:s,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,s=new Uint8Array(e,n,r);return t.color={array:s,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,s=new Uint32Array(e,n,r);return t.faceRange={array:s,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,s=new Uint16Array(e,n,r);return t["uv-region"]={array:s,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,s=new Uint16Array(e,n,r);return t["uv-region"]={array:s,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Zn(t,e,n,r,s,i,o,a){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)Wn[n[e]]?t=Wn[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let s=e.ordering,i=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<s.length;e++){const n=Wn[s[e]];n||console.log(s[e]),t=n(c,r,t)}for(let e=0;e<i.length;e++){const n=Wn[i[e]];n||console.log(i[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const f={};for(const t in c){const e=Jn[t]&&Jn[t].name;e&&(f[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(h=e)<=255?Uint8Array:h<=65535?Uint16Array:Uint32Array,r=new n(f.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,s=t[e],i=t[e+1];for(let t=s;t<=i;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}f._BATCHID={componentType:Ye(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var h;return tr({attributes:f},t,e,s,i,o,a)}function tr(t,e,n,r,s,i,o){const a={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const u=function(t,e,n,r,s){let i,o=[0,0,0,1];const a=[0,0],u=jn([],n,r,s);u[2]=n[2];const f=e&&c(Gn,e);return gn(t,t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],f||(o=v(o,o,e)),n&&y(o,o,n),jn(a,o,r,s),i=o[2],t[0]=a[0]-u[0],t[1]=a[1]-u[1],t[2]=i-u[2],t)),u}(t.attributes.POSITION,r,s,i,o);e.meshes[n]={primitives:[a],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:s};for(const n in t.attributes)ar(e.transferables,t.attributes[n].array.buffer);return t.indices&&ar(e.transferables,t.indices.array.buffer),a}function er(t,e,n,r,s,i){const o=r.map(t=>function(t,e,n,r,s){if("dds"===e){const e=_n(t),r=e.images.map(e=>new Uint8Array(t,e.offset,e.length)),s="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Yn,format:s})}if("png"===e||"jpg"===e)return function(t,e){rr||(rr=new OffscreenCanvas(2,2),sr=rr.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then(t=>{let{width:n,height:r}=t;ir(n)||(n=or(n)),ir(r)||(r=or(r));const s=e;s&&(n=Math.min(s,n),r=Math.min(s,r)),rr.width=n,rr.height=r,sr.drawImage(t,0,0,n,r),t.close();const i=sr.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(i.data)}}).catch(()=>({width:2,height:2,array:new Uint8Array(4)}))}(t,s).then(t=>{t.mimeType=n;return{image:t,sampler:Yn,format:6408}});if("ktx2"===e)return Xn(t,r).then(t=>(t.mimeType=n,{image:t,sampler:Yn,format:t.format}));return null}(t.data,t.format,t.mimeType,s,i).then(t=>{if(t.image)if(t.image.array)ar(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)ar(e.transferables,t.image.mipmap[n].buffer);return t}));return Promise.all(o).then(r=>{!function t(e,n,r,s){const i=JSON.parse(JSON.stringify(r)),o=n.textures;s.ptr||(s.ptr=0);for(const e in r)r[e]&&r[e].url?(o.push(s[s.ptr++]),i[e]={index:o.length-1},void 0!==r[e].factor&&(i[e].scale=r[e].factor)):de(r[e])&&(i[e]=t(-1,n,r[e],s));e>=0&&(n.materials[e]=i);return i}(t,e,n,r)})}function nr(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):de(t[n])&&nr(t[n],e)}let rr,sr;function ir(t){return 0==(t&t-1)&&0!==t}function or(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function ar(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function cr(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 ur=[];const fr=[],hr=[],lr=[],dr=[],yr=[],mr=[],br=[];function pr(t,e,n,r,s,i){d(dr,t[3*e],t[3*e+1],t[3*e+2]),d(yr,t[3*n],t[3*n+1],t[3*n+2]),d(mr,t[3*r],t[3*r+1],t[3*r+2]);const o=M(fr,mr,yr),a=M(hr,dr,yr),c=g(lr,o,a);p(br,c),s[3*e]=s[3*e]||0,s[3*n]=s[3*n]||0,s[3*r]=s[3*r]||0,s[3*e+1]=s[3*e+1]||0,s[3*n+1]=s[3*n+1]||0,s[3*r+1]=s[3*r+1]||0,s[3*e+2]=s[3*e+2]||0,s[3*n+2]=s[3*n+2]||0,s[3*r+2]=s[3*r+2]||0,s[3*e]+=br[0],s[3*n]+=br[0],s[3*r]+=br[0],s[3*e+1]+=br[1],s[3*n+1]+=br[1],s[3*r+1]+=br[1],s[3*e+2]+=br[2],s[3*n+2]+=br[2],s[3*r+2]+=br[2],i[e]+=1,i[n]+=1,i[r]+=1}const wr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],gr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],vr=2*Math.PI*6378137/360,Mr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let Tr,Ar=!1;if("undefined"!=typeof OffscreenCanvas){try{Tr=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}Tr&&"undefined"!=typeof createImageBitmap&&(Ar=!0)}const _r=r([]),Or=[0,0,0],xr=[],Sr=[],Ir=[],kr=[],Er={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Cr={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Ur;class Fr{constructor(t,e,n,r){this.id=t,this.options=e,this.gt=this.requestImage.bind(this),this.vt=n,this.Mt={},r(null,{},[])}Tt(t){this.At||(this.i=t,this._t=new cn,this.At=new nn(this.gt,dt,t),this.Ot=new rn(this.gt,dt,t))}requestImage(t,e){Ar?fetch(t).then(t=>t.arrayBuffer()).then(t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)}).then(t=>{(void 0).width=t.width,(void 0).height=t.height,Tr.drawImage(t,0,0);const n=Tr.getImageData(0,0,(void 0).width,(void 0).height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})}):this.vt("requestImage",{url:t},null,e)}loadTile(t,e){this.Tt(t.supportedFormats);const{service:n,url:r,arraybuffer:s}=t,i=n.fetchOptions||{};if(i.referrer=t.referrer,i.referrerPolicy=i.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const s=t.i3sInfo,o=n.maxTextureSize||1024,a=Kn(s,t.supportedFormats,this.options.projection,t.projection,o,i);return a.then(t=>{if(delete this.Mt[r],!t)return void e({status:404,url:r,i3sInfo:s});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:s});t.gltf.url=r;const{transferables:n}=t;t.magic="b3dm",this.xt(t.gltf),e(null,t,n)}),void(this.Mt[r]=a.xhr)}if(s){delete this.Mt[r];const n=Ie(new DataView(s),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(Mr){const r=new Uint8Array(t,e,n);return Mr.decode(r)}return pe(new Uint8Array(t,e,n))}(s,0,s.byteLength),i=JSON.parse(n);i.accessors?this.St(i,r,t,"gltf",e):this.It(t.rootIdx,i,s,r,e)}else this.St(s,r,t,n,e)}else{let s=n.urlParams;s&&(s=(r.indexOf("?")>0?"&":"?")+s);const o=r.replace(/\\+/g,"%2B");let a=J.getArrayBuffer(o+(s||""),i);const c=a.xhr;a=a.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]=c}}St(t,e,n,r,s){r=r&&r.toLowerCase();const{service:i}=n;if("b3dm"===r){this.At.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then(t=>{if(t.error)return void s(t);const{content:e,transferables:r}=this.kt(t,n);this.xt(e.gltf),s(null,e,r)}).catch(t=>{s(t)})}else if("pnts"===r){const r=n.transform||_r;this._t.load(e,t).then(t=>{const{content:e,transferables:i}=this.Et(t,r,n.rootIdx);this.Ct(e),s(null,e,i)})}else if("i3dm"===r){const r=n.transform||_r;this.Ot.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then(t=>{const{content:e,transferables:i}=this.Ut(t,r,n.rootIdx);this.xt(e.gltf),s(null,e,i)})}else if("cmpt"===r){new fn(this.gt,dt,this.i,i.maxTextureSize||1024).load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then(t=>{const{content:e,transferables:r}=this.Ft(t,n);this.Nt(e),s(null,e,r)}).catch(t=>{s(t)})}else if("gltf"===r){this.rt||(this.rt=en());const r=e.substring(0,e.lastIndexOf("/")),o=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t,a=new dt(r,o,{transferable:!0,requestImage:this.gt,decoders:this.rt,supportedFormats:this.i,maxTextureSize:i.maxTextureSize||1024});a.load({skipAttributeTransform:!1}).then(t=>{t.url=e,this.Pt(t,null,n),this.xt(t),s(null,{magic:"gltf",gltf:t},a.transferables)})}else s(new Error("unsupported tile format: "+r))}Nt(t){t.content?t.content.forEach(t=>{this.Nt(t)}):this.xt(t.gltf)}Bt(t,e){if(this.Dt(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.Rt()?Ur.subarray(0,n):e,s=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const s=ur;s.length<t.length/3&&(s.length=t.length/3),s.fill(0,0,t.length/3);const i=void 0===e.length?e:e.length;for(let n=0;n<i/3;n++)void 0===e.length?pr(t,3*n,3*n+1,3*n+2,r,s):pr(t,e[3*n],e[3*n+1],e[3*n+2],r,s);for(let t=0;t<r.length;t+=3){const e=s[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:s,byteLength:s.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:s.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}xt(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach(e=>{this.Bt(e,t),e.compressed_int16_params={};const n=e.attributes;for(const t in n)if(Er[t]&&n[t].array&&n[t].array instanceof Float32Array){let r=1;this.Rt()&&"POSITION"===t&&(r=vr,e.compressed_int16_params.compressed_ratio=r);const s=Lr(n[t].array,r,n[t].min,n[t].max,t);if(!s)continue;const{array:i,range:o}=s;n[t].array=i,e.compressed_int16_params[t]=o}})}}Ct(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(Er[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Rt()&&"POSITION"===n&&(r=vr,t.compressed_int16_params.compressed_ratio=r);const{array:s,range:i}=Lr(e[n].array,r,e[n].min,e[n].max,n);e[n].array=s,t.compressed_int16_params[n]=i}}Lt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const s={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(s)}return e}It(t,e,n,r,s){return e.capabilities,void s(null,e)}Ft(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},s=[];for(let t=0;t<n.length;t++){const{magic:i}=n[t];if("b3dm"===i){const{content:i,transferables:o}=this.kt(n[t],e);Dr(s,o),r.content.push(i)}else if("i3dm"===i){const{transform:i,rootIdx:o}=e,{content:a,transferables:c}=this.Ut(n[t],i,o);Dr(s,c),r.content.push(a)}else if("pnts"===i){const{transform:i,rootIdx:o}=e,{content:a,transferables:c}=this.Et(n[t],i,o);Dr(s,c),r.content.push(a)}else if("cmpt"===i){const{content:i,transferables:o}=this.Ft(n[t],e);Dr(s,o),r.content.push(i)}}return{content:r,transferables:s}}kt(t,e){const{gltf:n,transferables:r,featureTable:s}=t;return this.Pt(n,s,e),delete t.transferables,{content:t,transferables:r}}Pt(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;let e=1;const n=[];for(const r in t.meshes){const s=t.meshes[r],{primitives:i}=s;if(i)for(let t=0;t<i.length;t++){const r=i[t].attributes&&i[t].attributes.POSITION;if(!r||!r.array)continue;r.array.buffer.visited||(r.array.buffer.visited=e++);const s=e-1+"-"+(r.byteOffset||0);if(n.indexOf(s)>=0)return!0;n.push(s)}}return!1}(t);this.zt(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.jt(t,e,n.upAxis,n.transform)):this.Vt(t,e,n.upAxis,n.transform)}Ut(t,e,r){const{featureTable:s}=t,i=t.i3dm,o=s&&s.RTC_CENTER||[0,0,0];if(s.EAST_NORTH_UP&&!i.NORMAL_UP&&!i.NORMAL_UP_OCT32P){const e=new Float32Array(3*i.POSITION.array.length),r=[],s=[],a=[];gn(i.POSITION,(t,i)=>{y(a,t,o),Je(a,null,r),n(s,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)),s)}),i.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const a={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Pr(i.POSITION.array,3,o,_r,a);const c=Br(a),u=l([],c),f=[1/0,1/0,1/0],h=[-1/0,-1/0,-1/0];gn(i.POSITION,t=>{t[0]=t[0]+o[0]-u[0],t[1]=t[1]+o[1]-u[1],t[2]=t[2]+o[2]-u[2],t[0]<f[0]&&(f[0]=t[0]),t[1]<f[1]&&(f[1]=t[1]),t[2]<f[2]&&(f[2]=t[2]),t[0]>h[0]&&(h[0]=t[0]),t[1]>h[1]&&(h[1]=t[1]),t[2]>h[2]&&(h[2]=t[2])}),i.POSITION.min=f,i.POSITION.max=h,e&&v(c,c,e);const d=this.qt(c);t.rtcCenter=u,t.rtcCoord=d,t.rootIdx=r;const m=t.transferables;return delete t.transferables,{content:t,transferables:m}}Et(t,e,n){const{featureTable:r}=t,s=t.pnts,i=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&c(_r,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Pr(s.POSITION.array,3,i,e,u);const f=Br(u),h=this.Gt(f),y=l([],f),m=[1/0,1/0,1/0],b=[-1/0,-1/0,-1/0];let p=[0,0,0,1];const w=[0,0,0],g=[0,0];gn(s.POSITION,t=>(p[0]=t[0]+i[0],p[1]=t[1]+i[1],p[2]=t[2]+i[2],e&&!a&&(p=v(p,p,e)),0===A(p)?d(w,0,0,-6378137):Ae(w,p),jn(g,w,o),t[0]=g[0]-h[0],t[1]=g[1]-h[1],t[2]=w[2]-h[2],t[0]<m[0]&&(m[0]=t[0]),t[1]<m[1]&&(m[1]=t[1]),t[2]<m[2]&&(m[2]=t[2]),t[0]>b[0]&&(b[0]=t[0]),t[1]>b[1]&&(b[1]=t[1]),t[2]>b[2]&&(b[2]=t[2]),t)),s.POSITION.min=m,s.POSITION.max=b,e&&v(f,f,e);const M=this.qt(f);t.rtcCenter=y,t.projCenter=h,t.rtcCoord=M,t.rootIdx=n;const T=t.transferables;return delete t.transferables,{content:t,transferables:T}}zt(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],s=n[1],i=n[2],o=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==s||n[t+2]!==i||n[t+3]!==o){a=!1;break}a&&(e[t].image.color=[r/255,s/255,i/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const n=this.Mt[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this.Mt[t.url],e(null)}$t(t,e,n,i){const o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let a=wr;"X"===(n=n&&n.toUpperCase())?a=gr:"Z"===n&&(a=_r),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};hn(t,t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=r(xr);t.matrices&&Rr(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;s(e,a,e),i&&s(e,i,e),Pr(n,u,o||Or,e,c,t.compressUniforms)});const u=Br(c);return{rtcCenter:o,modelCenter:u,upAxisTransform:a}}jt(t,e,n,i){const{modelCenter:o,upAxisTransform:a,rtcCenter:c}=this.$t(t,e,n),u=l([],o);i&&v(o,o,i),t.extensions.CESIUM_RTC.rtcCoord=this.qt(o),c||(hn(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 n=r(xr);t.matrices&&Rr(n,t.matrices),s(n,a,n);const i=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],u=e[7],f=e[8],h=e[9],l=e[10],d=e[11],y=e[12],m=e[13],b=e[14],p=e[15],w=n*a-r*o,g=n*c-s*o,v=n*u-i*o,M=r*c-s*a,T=r*u-i*a,A=s*u-i*c,_=f*m-h*y,O=f*b-l*y,x=f*p-d*y,S=h*b-l*m,I=h*p-d*m,k=l*p-d*b,E=w*k-g*I+v*S+M*x-T*O+A*_;return E?(E=1/E,t[0]=(a*k-c*I+u*S)*E,t[1]=(s*I-r*k-i*S)*E,t[2]=(m*A-b*T+p*M)*E,t[3]=(l*T-h*A-d*M)*E,t[4]=(c*x-o*k-u*O)*E,t[5]=(n*k-s*x+i*O)*E,t[6]=(b*v-y*A-p*g)*E,t[7]=(f*A-l*v+d*g)*E,t[8]=(o*I-a*x+u*_)*E,t[9]=(r*x-n*I-i*_)*E,t[10]=(y*T-m*v+p*w)*E,t[11]=(h*v-f*T-d*w)*E,t[12]=(a*O-o*S-c*_)*E,t[13]=(n*S-r*O+s*_)*E,t[14]=(m*g-y*M-b*w)*E,t[15]=(f*M-h*g+l*w)*E,t):null}(Sr,n),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];gn(e,t=>{v(t,t,n),t[0]=t[0]-u[0],t[1]=t[1]-u[1],t[2]=t[2]-u[2],v(t,t,i),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=u)}Vt(t,e,n,r){const{modelCenter:s,rtcCenter:i}=this.$t(t,e,n,r),o=this.Gt(s);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.qt(s),hn(t,e=>{if(e.attributes&&e.attributes.POSITION){const s=this.Dt(e,t);if(s){const t=e.attributes.POSITION.array.length;(!Ur||Ur.length<t)&&(Ur=new Float32Array(t))}e.attributes.NORMAL&&this.Xt(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.Xt(e.attributes.TANGENT,e.matrices,n);const{newPositions:o}=this.Ht(e.attributes.POSITION,e.matrices,i,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,s),{componentType:a}=e.attributes.POSITION;5126!==a&&(e.attributes.POSITION.array=new Float32Array(o))}});for(const e in t.nodes){t.nodes[e].matrix=_r}}Gt(t){0===A(t)?d(Ir,0,0,-6378137):Ae(Ir,t);const e=this.options.projection;jn(kr,Ir,e);const n=Ir[2],r=[];return r[0]=kr[0],r[1]=kr[1],r[2]=n,r}Xt(t,e,r){let s;s="Y"===r?wr:"X"===r?gr:_r;const i=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}([],s);if(Rr(i,e),c(i,_r))return;const o=n([],i),a=[];gn(t,t=>(function(t,e,n){var r=e[0],s=e[1],i=e[2];t[0]=r*n[0]+s*n[3]+i*n[6],t[1]=r*n[1]+s*n[4]+i*n[7],t[2]=r*n[2]+s*n[5]+i*n[8]}(a,t,o),p(a,a),l(t,a),a))}Ht(t,e,n,s,i,o,a,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const f=r([]);Rr(f,e);const h=this.options.projection;i=i&&i.toUpperCase();const l=n;let m=null;"Y"===i?m=wr:"X"===i&&(m=gr);let b=[0,0,0,1];const p=[0,0,0],w=[0,0],g=s.projCenter,M=jn([],s.rtcCoord,"EPSG:3857"),T=o&&c(_r,o),_=t.min=t.min||[],O=t.max=t.max||[];d(_,1/0,1/0,1/0),d(O,-1/0,-1/0,-1/0);const x=a||{},{decode_position_min:S,decode_position_normConstant:I}=x;let k=[0,0,0,0],E=1;S&&(k=S),I&&(E=I);const C=[];return gn(t,(e,n)=>{if(b[0]=e[0]*E+k[0],b[1]=e[1]*E+k[1],b[2]=e[2]*E+k[2],b=v(b,b,f),m&&(b=v(b,b,m)),l&&y(b,b,l),o&&!T&&(b=v(b,b,o)),0===A(b)?d(p,0,0,-6378137):Ae(p,b),u){const t=Ur;jn(w,p,h),t[3*n]=w[0]-M[0],t[3*n+1]=w[0]-M[1],t[3*n+2]=w[0]-M[2]}if(jn(w,p,h),e instanceof Float32Array)e[0]=w[0]-g[0],e[1]=w[1]-g[1],e[2]=p[2]-g[2];else{const n=w[0]-g[0],r=w[1]-g[1],s=p[2]-g[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(s),C.push(e[3]))}return e[0]<_[0]&&(_[0]=e[0]),e[1]<_[1]&&(_[1]=e[1]),e[2]<_[2]&&(_[2]=e[2]),e[0]>O[0]&&(O[0]=e[0]),e[1]>O[1]&&(O[1]=e[1]),e[2]>O[2]&&(O[2]=e[2]),e}),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:g,newPositions:C}}qt(t){return 0===A(t)?d([],0,0,-6378137):Ae([],t)}onRemove(){}Rt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}Dt(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material];return n&&n.extensions&&n.extensions.KHR_materials_unlit}(t,e))return!1;if(t.attributes.TANGENT)return!1;return!!t.attributes.TEXCOORD_0}}const Nr=[];function Pr(t,e,n,r,s,i){const o=i||{},{decode_position_min:a,decode_position_normConstant:c}=o;let u=[0,0,0,0],f=1;a&&(u=a),c&&(f=c);for(let i=0,o=t.length;i<o;i+=e){const{xmin:o,ymin:a,xmax:c,ymax:h,hmin:l,hmax:m}=s;d(Nr,t[i]*f+u[0],t[i+1]*f+u[1],t[i+2]*f+u[2]),v(Nr,Nr,r);const b=y(Nr,n,Nr);b[0]<o&&(s.xmin=b[0]),b[0]>c&&(s.xmax=b[0]),b[1]<a&&(s.ymin=b[1]),b[1]>h&&(s.ymax=b[1]),e>2&&(b[2]<l&&(s.hmin=b[2]),b[2]>m&&(s.hmax=b[2]))}}function Br(t){const{xmax:e,ymax:n,xmin:r,ymin:s,hmin:i,hmax:o}=t,a=[(r+e)/2,(s+n)/2,(i+o)/2];return e===-1/0&&(a[0]=0),n===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function Dr(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function Rr(t,e){const n=t;for(let t=e.length-1;t>=0;t--)s(n,e[t],n);return n}function Lr(t,e,n,r,s){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let i,o;if(n&&r&&1===e)i=Math.min(...n),o=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);i=e,o=n}return!function(t,e,n,r){for(let s=0;s<t.length;s++){const i=zr(jr(t[s],e,n),e,n);if(Math.abs(i-t[s])>Cr[r])return!1}return!0}(t,i,o,s)&&Cr[s]?null:function(t,e,n){const r=new Int16Array(t.length);for(let s=0;s<t.length;s++)r[s]=jr(t[s],e,n);return{array:r,range:[e,n]}}(t,i,o)}function zr(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function jr(t,e,n){const r=2*(t-e)/(n-e)-1,s=Math.max(-1,Math.min(1,r));return s<0?32768*s:32767*s}let Vr=0;class qr{constructor(t){this.workerId=t,this.workers={},this.Jt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},s){if(this.Kt(e,n))return;const i=this.Yt(e,n),o=r.options,a=this.send.bind(this,t);this.workers[i]=new Fr(n,o,a,s)}removeLayer({mapId:t,layerId:e},n){const r=this.Kt(t,e),s=this.Yt(t,e);delete this.workers[s],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const s=this.Kt(t,e);s&&s.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const s=this.Kt(t,e);s&&s.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.Jt[e];delete this.Jt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,s){const i=s?`${t}-${Vr++}`:null;s&&(this.Jt[i]=s),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(i)},r||[])}Yt(t,e){return`${t}-${e}`}Kt(t,e){const n=this.Yt(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new qr(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},(t,n,r)=>{t&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)})},Object.defineProperty(t,"Qt",{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,n){"use strict";function r(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var s=r(e),i=r(n);const o="${",a=`function(t){var e="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 r(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],l=e[7],f=e[8],h=e[9],d=e[10],y=e[11],m=e[12],b=e[13],p=e[14],g=e[15],w=n[0],v=n[1],M=n[2],T=n[3];return t[0]=w*r+v*a+M*f+T*m,t[1]=w*s+v*c+M*h+T*b,t[2]=w*i+v*u+M*d+T*p,t[3]=w*o+v*l+M*y+T*g,w=n[4],v=n[5],M=n[6],T=n[7],t[4]=w*r+v*a+M*f+T*m,t[5]=w*s+v*c+M*h+T*b,t[6]=w*i+v*u+M*d+T*p,t[7]=w*o+v*l+M*y+T*g,w=n[8],v=n[9],M=n[10],T=n[11],t[8]=w*r+v*a+M*f+T*m,t[9]=w*s+v*c+M*h+T*b,t[10]=w*i+v*u+M*d+T*p,t[11]=w*o+v*l+M*y+T*g,w=n[12],v=n[13],M=n[14],T=n[15],t[12]=w*r+v*a+M*f+T*m,t[13]=w*s+v*c+M*h+T*b,t[14]=w*i+v*u+M*d+T*p,t[15]=w*o+v*l+M*y+T*g,t}function s(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}function i(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}function o(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,u=n*o,l=r*o,f=r*a,h=s*o,d=s*a,y=s*c,m=i*o,b=i*a,p=i*c;return t[0]=1-f-y,t[1]=l+p,t[2]=h-b,t[3]=0,t[4]=l-p,t[5]=1-u-y,t[6]=d+m,t[7]=0,t[8]=h+b,t[9]=d-m,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function a(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]}function c(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function u(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function l(t,n,r){var s=new e(3);return s[0]=t,s[1]=n,s[2]=r,s}function f(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function h(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function d(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function y(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function m(t,e){var n=e[0],r=e[1],s=e[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function b(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function p(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,t[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,t[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var g=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},w=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},v=u;function M(t,e,n,r,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=s,t}function T(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3];return t[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,t[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,t[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,t[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,t}function A(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function _(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function O(t,e,n,r){var s,i,o,a,c,u=e[0],l=e[1],f=e[2],h=e[3],d=n[0],y=n[1],m=n[2],b=n[3];return(i=u*d+l*y+f*m+h*b)<0&&(i=-i,d=-d,y=-y,m=-m,b=-b),1-i>1e-6?(s=Math.acos(i),o=Math.sin(s),a=Math.sin((1-r)*s)/o,c=Math.sin(r*s)/o):(a=1-r,c=r),t[0]=a*u+c*d,t[1]=a*l+c*y,t[2]=a*f+c*m,t[3]=a*h+c*b,t}c(),function(){var t,n=(t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var k,x=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};c(),l(1,0,0),l(0,1,0),A(),A(),k=new e(9),e!=Float32Array&&(k[1]=0,k[2]=0,k[3]=0,k[5]=0,k[6]=0,k[7]=0),k[0]=1,k[4]=1,k[8]=1;\n/*!\n * @maptalks/gltf-loader v0.98.0\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.org\n */\nlet S=0;function I(t){return null==t}function E(t){return!I(t)}function C(t){return!I(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function U(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function F(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 N(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function P(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const B=[],D=[],R=[],L=[0,0,0],j=_([]),z=[1,1,1];function q(t,e,n,r,s,i,o){const a=F(o),c=a.BYTES_PER_ELEMENT;if((0===s||s===r*c)&&i%c==0){const s=new a(e,i,n*r);return t.set(s),t}0===s&&(s=r*c);const u=new Uint8Array(r*c);for(let o=0;o<n;o++){let n=null;const l=new Uint8Array(e,s*o+i,r*c);u.set(l),n=new a(u.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const V="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function G(t,e,n){const r=new Uint8Array(t,e,n);return V.decode(r)}const $={get:function(t,e={},n){e||(e={});const r=new AbortController,s=r.signal,i=U({},e);i.signal=s,i.method||(i.method="GET"),i.referrerPolicy=i.referrerPolicy||"origin","undefined"==typeof window||i.referrer||(i.referrer=window.location.href),n&&(t=n(t));const o=fetch(t,i).then((t=>{const n=this.t(t,e.responseType);return n.message?n:n.then((n=>"arraybuffer"===e.responseType?{data:n,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:n)).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 o.xhr=r,o},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:\`incorrect http request with status code(${o}t.status}): ${o}t.statusText}\`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={},n)=>(e||(e={}),e.responseType="arraybuffer",$.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?$.jsonp(t):((e=e||{}).responseType="json",$.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+S++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let n=document.createElement("script");return n.type="text/javascript",n.src=t,new Promise((t=>{window[e]=function(r){document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[e],t(r)},document.getElementsByTagName("head")[0].appendChild(n)}))}};class X{constructor(t,e,n,r,s){this.i=t,this.decoders=e,this.o=n,this.images={},this.u={},this.h=r||{},this.m=s}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.p(e,r);return this.getImageByBuffer(s,n)}if(this.u[t.id])return this.u[t.id].then((()=>{const r=this.buffers[t.id],s=this.p(e,r);return this.getImageByBuffer(s,n)}));if(N(t.uri)){const r=this.buffers[t.id]=P(t.uri),s=this.p(e,r);return this.getImageByBuffer(s,n)}let r;const s=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.u[t.id]=$.getArrayBuffer(r,this.h,this.m).then((r=>{const s=this.buffers[t.id]=r.data,i=this.p(e,s);return this.getImageByBuffer(i,n)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;return n[e.mimeType]?n[e.mimeType](t,{supportedFormats:this.o}):"image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType?(console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null)):this.v(e.id,t)}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.v(t.id,e)}v(t,e){return new Promise(((n,r)=>{let s=e;this.m&&(s=this.m(e)),this.i(s,this.h,((s,i)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=i,n(this.images[t]))}))}))}}const H=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],J=[];class K{constructor(t,e,n,r,s){this.rootPath=t,this.gltf=e,this.M=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.T(),this.h=r,this.m=s}A(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this._(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const s=n.bufferViews[r.bufferView];return this.O(s).then((n=>{const{buffer:s,byteOffset:i}=n;return this.accessors[r.id]=this._(t,e,s,i)}))}O(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(N(e.uri)){const t=this.buffers[e.id]=P(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const n=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=$.getArrayBuffer(t,this.h,!n&&this.m).then((r=>(n&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=r.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}_(t,e,n,r=0){const s=this.gltf,i=s.accessors[e],o=void 0!==i.bufferView?s.bufferViews[i.bufferView]:{},a=(o.byteOffset||0)+r,c=this.k(i.type),u=F(i.componentType),l=o.byteStride||0,f={array:void 0,name:t,accessorName:e,byteLength:i.count*c*u.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:c,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(f.min=i.min),i.max&&(f.max=i.max),n)if(this.M)f.byteStride=l,f.byteOffset=a+(i.byteOffset||0),!l||l===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(f.array=this.S(n,i.count,c,a+(i.byteOffset||0),u),f.array.buffer.byteLength===f.byteLength&&(f.byteOffset=0)):f.array=new Uint8Array(n,a,o.byteLength);else if(i.interleaved){f.byteStride=0,f.byteOffset=0;const t=new u(i.count*c);if(f.array=q(t,n,i.count,c,l,a+(i.byteOffset||0),i.componentType),f.extensions&&f.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(f.array.length),{decodeMatrix:e}=f.extensions.WEB3D_quantized_attributes;for(let n=0;n<f.array.length;n+=c){J[0]=f.array[n],J[1]=f.array[n+1],J[2]=f.array[n+2],J[3]=1;const r=T(J,J,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}f.componentType=5126,f.array=t}}else f.byteStride=0,f.array=this.S(n,i.count,c,a+(i.byteOffset||0),u),f.byteOffset=f.array.byteOffset;else{f.array=new u(i.count);const t=f.min||f.max;t&&(f.array[0]=t[0],f.array[1]=t[1],f.array[2]=t[2])}return f}T(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}S(t,e,n,r,s){return r%s.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*s.BYTES_PER_ELEMENT),r=0),new s(t,r,n*e)}k(t){const e=H.indexOf(t);return H[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this.O(e).then((r=>{const{buffer:s,byteOffset:i}=r,o=G(s,i+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(N(t.uri)){const e=P(t.uri),n=G(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return $.get(e,this.h,this.m).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class Y extends X{constructor(t,e,n,r,s,i,o,a){super(r,s,i,o,a),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new K(t,e,n,o,a)}iterate(t,e){const n=this.gltf[e];if(!n)return;let r=0;for(const e in n)t(e,n[e],r++)}createNode(t){const e={};if(E(t.name)&&(e.name=t.name),E(t.children)&&(e.children=t.children),E(t.jointName)&&(e.jointName=t.jointName),E(t.matrix)&&(e.matrix=t.matrix),E(t.rotation)&&(e.rotation=t.rotation),E(t.scale)&&(e.scale=t.scale),E(t.translation)&&(e.translation=t.translation),E(t.extras)&&(e.extras=t.extras),E(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 n=s(B,e.translation||L),a=o(D,e.rotation||j),c=i(R,e.scale||z);return r(c,a,c),r(t,n,c)}return n(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}I(t){const e={};for(const n in t){const r=t[n];let s,i;r.instanceTechnique&&r.instanceTechnique.values?(s=r.instanceTechnique,i=s.values.diffuse):(s=r,i=s.values.tex||s.values.diffuseTex||s.values.diffuse);const o={baseColorTexture:{index:i}};r.name&&(o.name=r.name),r.extensions&&(o.extensions=r.extensions),r.extras&&(o.extras=r.extras),e[n]=o}return e}C(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 n=this.gltf.bufferViews[e.bufferView],r=(n.byteOffset||0)+this.glbBuffer.byteOffset,s=n.byteLength,i=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,s);return this.getImageByBuffer(i,t)}return this.requestExternalImage(t)}U(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.C(n).then((t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const s=this.gltf.textures[r];if(!s)return null;const i=this.gltf.samplers[s.sampler];return{format:s.format||6408,internalFormat:s.internalFormat||6408,type:s.type||5121,sampler:i,source:this.gltf.images[s.source]}}getMaterial(){return null}getAnimations(){return null}}const Q=9729;class W extends X{constructor(t,e,n,r,s,i,o,a){super(r,s,i,o,a),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new K(t,e,n,o,a)}iterate(t,e){const n=this.gltf[e];if(n)for(let e=0;e<n.length;e++)t(e,n[e],e)}createNode(t){const e={};return U(e,t),!E(t.weights)&&this.gltf.meshes&&E(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}U(t){const e=this.gltf.textures[t];if(!e)return null;let n=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(n=e.extensions.EXT_texture_webp.source),!E(n))return null;const r=this.gltf.images[n];return this.C(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}};U(n,e);const s=E(e.sampler)?this.gltf.samplers[e.sampler]:void 0;if(s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||Q,n.sampler.minFilter=s.minFilter||Q,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),!n.mipmap&&n.sampler.minFilter!==Q&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:Q}return t.format&&(n.format=t.format),n}))}C(t){if(!E(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],n=this.gltf.buffers[e.buffer];if(n.uri)return this.requestImageFromBufferURI(n,e,t);if(this.glbBuffer)return this.F(e,t)}return null}F(t,e){const n=this.p(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}p(t,e,n){n=n||0;const r=(t.byteOffset||0)+n,s=t.byteLength;return new Uint8Array(e,r,s)}N(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);n.join("");const r="data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)));return r}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let n=0;n<e.length;n++)t[n].samplers=e[n];return t}))}getSamplers(t){const e=[];for(let n=0;n<t.length;n++)(E(t[n].input)||E(t[n].output))&&(e.push(this.accessor.A("input",t[n].input)),e.push(this.accessor.A("output",t[n].output)));return Promise.all(e).then((e=>{for(let n=0;n<e.length/2;n++)t[n].input=e[2*n],t[n].output=e[2*n+1],t[n].interpolation||(t[n].interpolation="LINEAR");return t}))}}const Z="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class tt{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),s=r.getUint32(4,!0);if(1===s)return tt.readV1(r,e);if(2===s)return tt.readV2(t,e);throw new Error("Unsupported glb version : "+s)}static readV1(t,e){const n=t.getUint32(8,!0),r=t.getUint32(12,!0);if(n!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const s=et(t.buffer,20+e,r);return{json:JSON.parse(s),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,s;const i=new DataView(t,e+12);let o=0;for(;o<i.byteLength;){const a=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,1313821514===c)n=et(t,e+12+o,a);else if(5130562===c){s=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:s,buffer:t,byteLength:r}}}}function et(t,e,n){if(Z){const r=new Uint8Array(t,e,n);return Z.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=nt[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}(new Uint8Array(t,e,n))}const nt=[1,1,1,1,2,2,3,0],rt=[0,0,0],st=[0,0,0,1],it=[1,1,1],ot={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},at={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},ct={P(t,e,n,r,s,i,o,a){const c=E(t)?e.animations:[e.animations[0]],u={};for(let e=0;e<c.length;e++){const l=c[e],h=l.name||e;if(E(t)&&h!==t)continue;const d=l.channelsMap[n];if(d)for(let t=0;t<d.length;t++){const e=d[t];"translation"===e.target.path?(this.B(s,l.samplers[e.sampler],r,1),u.translation=f(rt,s)):"rotation"===e.target.path?(this.D(i,l.samplers[e.sampler],r,1),u.rotation=x(st,i)):"scale"===e.target.path?(this.B(o,l.samplers[e.sampler],r,1),u.scale=f(it,o)):"weights"===e.target.path&&a&&(this.B(a,l.samplers[e.sampler],r,a.length),u.weights=a)}}return u},B(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.R(at,e,n,1*r);s&&(t=function(t,e,n,r){for(let s=0;s<t.length;s++)t[s]=e[s]+r*(n[s]-e[s]);return t}(t,s.PREVIOUS,s.NEXT,s.INTERPOLATION));break}case"STEP":{const s=this.R(at,e,n,1*r);s&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.R(at,e,n,3*r);s&&(t=this.L(t,s,e.input.array,3*r));break}}return t},D(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.R(at,e,n,1);r&&O(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.R(at,e,n,1);r&&(t=M(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.R(at,e,n,3);if(r){for(let t=0;t<r.PREVIOUS.length;t++)r.PREVIOUS[t]=Math.acos(r.PREVIOUS[t]),r.NEXT[t]=Math.acos(r.NEXT[t]);t=this.L(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},j(t,e){const n=t.length;let r,s,i,o=0,a=n-1,c=Math.floor((o+a)/2);for(;o<=n-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const n=t[c];return r=c,s=c+1,i=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:s,interpolation:i}}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},R(t,e,n,r){const s=e.input.array,i=e.output.array,o=e.output.itemSize;(n<s[0]||n>s[s.length-1])&&(n=Math.max(s[0],Math.min(s[s.length-1],n))),n===s[s.length-1]&&(n=s[0]);const a=this.j(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:u,interpolation:l}=a;t.PREINDEX=c,t.NEXTINDEX=u,t.INTERPOLATION=l;const f=o*r;return t.PREVIOUS=i.subarray(t.PREINDEX*f,(t.PREINDEX+1)*f),t.NEXT=i.subarray(t.NEXTINDEX*f,(t.NEXTINDEX+1)*f),t},L(t,e,n,r){const s=e.INTERPOLATION,i=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-i)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],l=(o-i)*e.NEXT[n],f=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*a+(Math.pow(s,3)-2*Math.pow(s,2)+s)*c+(2*-Math.pow(s,3)+3*Math.pow(s,2))*u+(Math.pow(s,3)-Math.pow(s,2))*l;t[n]=f}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;return h(rt,...ot.TRANSLATION),M(st,...ot.ROTATION),h(it,...ot.SCALE),this.P(r,t,e,n,rt,st,it,s)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,n)=>{let r=-1/0,s=1/0;const i=e.channels;for(let t=0;t<i.length;t++){const n=i[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<s&&(s=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:s}})),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?E(e)?n[e]:n[Object.keys(n)[0]]:null}};let ut=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Ge){}t&&"undefined"!=typeof createImageBitmap&&(ut=!0)}const lt="undefined"==typeof document?null:document.createElement("canvas");class ft{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),this.h=this.options.fetchOptions||{},e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=tt.read(e.buffer,e.byteOffset,e.byteLength);this.q(t,n,r)}else this.q(t,e);this.V=new K(this.rootPath,this.gltf,this.glbBuffer,this.h,this.options.urlModifier),this.G()}G(){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["image/ktx2"])throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded");if(t.indexOf("EXT_meshopt_compression")>=0)throw new Error("EXT_meshopt_compression extension is not supported yet.")}}$(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.V.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.X(t),n=this.H(),r=this.J(),s=this.$();return Promise.all([e,n,r,s]).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 n=e[t];n.channelsMap={};for(let t=0;t<n.channels.length;t++){const e=n.channels[t];n.channelsMap[e.target.node]||(n.channelsMap[e.target.node]=[]),n.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:n}=this.gltf;for(let n=0;n<e.length;n++)e[n].uri&&e[n].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[n].uri});for(let e=0;e<n.length;e++)n[e].uri&&n[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:n[e].uri})}return t}static getAnimationClip(t,e,n,r){return ct.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return ct.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return F(t)}static readInterleavedArray(t,e,n,r,s,i,o){return q(t,e,n,r,s,i,o)}q(t,e,n){this.gltf=e,this.glbBuffer=n,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=ut?gt.bind(this):this.options.requestImage||ht,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new W(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.h,this.options.urlModifier),this.adapter.iterate(((t,e,n)=>{e.id="buffer_"+n}),"buffers"),this.adapter.iterate(((t,e,n)=>{e.id="image_"+n}),"images"),this.adapter.iterate(((t,e,n)=>{e.id="accessor_"+n}),"accessors")):(this.adapter=new Y(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.h,this.options.urlModifier),this.adapter.iterate(((t,e,n)=>{e.id="accessor_"+n}),"accessors"),this.adapter.iterate(((t,e,n)=>{e.id="image_"+n}),"images"))}K(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||C(t.children[0])))return t;const r=t.children.map((t=>{const n=e[t];return n.nodeIndex=t,this.K(n,e)}));t.children=r}var n;return t}X(t){return this.Y(t).then((t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.K(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((r,s,i)=>{const o={};s.name&&(o.name=s.name),s.nodes&&(o.nodes=s.nodes.map((e=>t[e]))),this.gltf.scene===r&&(n=i),e.push(o)}),"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.I(this.gltf.materials);r.materials=t}return delete this.gltf.buffers,r.json=this.gltf,r}))}Y(t){return this.W(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,n)=>{const r=this.adapter.createNode(n,this.meshes,this.skins);t[e]=r}),"nodes"),t}))}Z(){this.skins=[];const t=[];return this.adapter.iterate(((e,n,r)=>{t.push(this.tt(n).then((t=>{t.index=r,this.skins.push(t)})))}),"skins"),t}tt(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)))}H(){const t=this.gltf.animations;return E(t)?this.adapter.getAnimations(t):null}W(t){this.meshes={};let e=[];return this.adapter.iterate(((n,r,s)=>{e.push(this.et(r,t).then((t=>{t.index=s,this.meshes[n]=t})))}),"meshes"),e=e.concat(this.Z()),Promise.all(e)}et(t,e){const n=t.primitives.map((t=>this.nt(t,e))).filter((t=>!!t));return Promise.all(n).then((e=>{const n={};return U(n,t),n.primitives=e,n}))}J(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.U(n));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image.array;if(n){let t;t=n instanceof ImageBitmap?n:n.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const n={},r=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(n[r[t]]=e[t]);return n}return e}))}nt(t,e){let n;const r=[],s=t.extensions;if(E(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const s=this.adapter.accessor.A(\`morphTargets_${o}t}_${o}e}\`,n[t]);s&&r.push(s)}}if(s&&s.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:i,attributes:o}=s.KHR_draco_mesh_compression,a=this.gltf.bufferViews[i],c=this.V.O(a).then((n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:i}=a;const c=a.byteLength;i||(i=0);const u=new DataView(r,s+i,c),l={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(u,l).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor.A(t,e[t]);n&&r.push(n)}if(E(t.indices)){const e=this.adapter.accessor.A("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then((e=>{if(s&&s.KHR_draco_mesh_compression){const n=t.targets?t.targets.length:0;e[n]=e[n].concat(e.slice(0,n)),e=e[n]}let n,r;const i={attributes:e.reduce(((t,e)=>{if("indices"===e.name)n=e;else if(e.name.indexOf("morphTargets_")>-1)r=r||{},r[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],{itemSize:r,array:s}=e,i=s.length/r;for(let e=0;e<i;e++)for(let i=0;i<r;i++){const o=e*r+i;s[o]<t[i]&&(t[i]=s[o]),s[o]>n[i]&&(n[i]=s[o])}if(e.quantization){const r=e.quantization,s=r.range/(1<<r.quantizationBits),i=r.minValues;y(t,t,s),d(t,t,i),y(n,n,s),d(n,n,i)}e.min=t,e.max=n}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 n&&(i.indices=n),r&&(i.morphTargets=r),i.mode=E(t.mode)?t.mode:4,E(t.extras)&&(i.extras=t.extras),i}))}}function ht(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!lt)return void n(new Error("There is no canvas to draw image!"));lt.width=r.width,lt.height=r.height;const t=lt.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),s={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,s)},r.onerror=function(t){n(t)},r.src=t}const dt=[],yt=[],mt=10;let bt,pt;function gt(t,e,n){bt||(bt=new OffscreenCanvas(2,2),pt=bt.getContext("2d",{willReadFrequently:!0}));let r=null;if(C(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),dt.push([t,e,n,this]),wt();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(vt.bind(this)).then((t=>{n(null,t)})).catch((t=>{console.warn(t),n(t)}))}}function wt(){if(!dt.length||yt.length>mt)return;const t=dt.shift(),[e,n,r,s]=t;yt.push(t),fetch(e,n).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then(vt.bind(s)).then((e=>{r.call(s,null,e);const n=yt.indexOf(t);yt.splice(n,1),wt()})).catch((e=>{console.warn(e),r.call(s,e);const n=yt.indexOf(t);yt.splice(n,1),wt()}))}function vt(t){let{width:e,height:n}=t;Mt(e)||(e=Tt(e)),Mt(n)||(n=Tt(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),bt.width=e,bt.height=n,pt.drawImage(t,0,0,e,n),t.close();const s=pt.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(s.data)}}function Mt(t){return!(t&t-1)&&0!==t}function Tt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function At(t){return t&&t.rt&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var _t={exports:{}},Ot={exports:{}},kt=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},xt=Array.prototype.concat,St=Array.prototype.slice,It=Ot.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];kt(s)?e=xt.call(e,St.call(s)):e.push(s)}return e};It.wrap=function(t){return function(){return t(It(arguments))}};var Et=Ot.exports,Ct={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},Ut=Et,Ft=Object.hasOwnProperty,Nt=Object.create(null);for(var Pt in Ct)Ft.call(Ct,Pt)&&(Nt[Ct[Pt]]=Pt);var Bt=_t.exports={to:{},get:{}};function Dt(t,e,n){return Math.min(Math.max(e,t),n)}function Rt(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}Bt.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=Bt.get.hsl(t),n="hsl";break;case"hwb":e=Bt.get.hwb(t),n="hwb";break;default:e=Bt.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},Bt.get.rgb=function(t){if(!t)return null;var e,n,r,s=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;s[n]=parseInt(e.slice(i,i+2),16)}r&&(s[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)s[n]=parseInt(e[n]+e[n],16);r&&(s[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)s[n]=parseInt(e[n+1],0);e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:Ft.call(Ct,e[1])?((s=Ct[e[1]])[3]=1,s):null:null;for(n=0;n<3;n++)s[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}for(n=0;n<3;n++)s[n]=Dt(s[n],0,255);return s[3]=Dt(s[3],0,1),s},Bt.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,Dt(parseFloat(e[2]),0,100),Dt(parseFloat(e[3]),0,100),Dt(isNaN(n)?1:n,0,1)]}return null},Bt.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,Dt(parseFloat(e[2]),0,100),Dt(parseFloat(e[3]),0,100),Dt(isNaN(n)?1:n,0,1)]}return null},Bt.to.hex=function(){var t=Ut(arguments);return"#"+Rt(t[0])+Rt(t[1])+Rt(t[2])+(t[3]<1?Rt(Math.round(255*t[3])):"")},Bt.to.rgb=function(){var t=Ut(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},Bt.to.rgb.percent=function(){var t=Ut(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},Bt.to.hsl=function(){var t=Ut(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},Bt.to.hwb=function(){var t=Ut(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},Bt.to.keyword=function(t){return Nt[t.slice(0,3)]};var Lt=_t.exports,jt={exports:{}},zt={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},qt={};for(var Vt in zt)zt.hasOwnProperty(Vt)&&(qt[zt[Vt]]=Vt);var Gt=jt.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var $t in Gt)if(Gt.hasOwnProperty($t)){if(!("channels"in Gt[$t]))throw new Error("missing channels property: "+$t);if(!("labels"in Gt[$t]))throw new Error("missing channel labels property: "+$t);if(Gt[$t].labels.length!==Gt[$t].channels)throw new Error("channel and label counts mismatch: "+$t);var Xt=Gt[$t].channels,Ht=Gt[$t].labels;delete Gt[$t].channels,delete Gt[$t].labels,Object.defineProperty(Gt[$t],"channels",{value:Xt}),Object.defineProperty(Gt[$t],"labels",{value:Ht})}function Jt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}Gt.rgb.hsl=function(t){var e,n,r=t[0]/255,s=t[1]/255,i=t[2]/255,o=Math.min(r,s,i),a=Math.max(r,s,i),c=a-o;return a===o?e=0:r===a?e=(s-i)/c:s===a?e=2+(i-r)/c:i===a&&(e=4+(r-s)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},Gt.rgb.hsv=function(t){var e,n,r,s,i,o=t[0]/255,a=t[1]/255,c=t[2]/255,u=Math.max(o,a,c),l=u-Math.min(o,a,c),f=function(t){return(u-t)/6/l+.5};return 0===l?s=i=0:(i=l/u,e=f(o),n=f(a),r=f(c),o===u?s=r-n:a===u?s=1/3+e-r:c===u&&(s=2/3+n-e),s<0?s+=1:s>1&&(s-=1)),[360*s,100*i,100*u]},Gt.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[Gt.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},Gt.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-s)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-s-e)/(1-e)||0),100*e]},Gt.rgb.keyword=function(t){var e=qt[t];if(e)return e;var n,r=1/0;for(var s in zt)if(zt.hasOwnProperty(s)){var i=Jt(t,zt[s]);i<r&&(r=i,n=s)}return n},Gt.keyword.rgb=function(t){return zt[t]},Gt.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},Gt.rgb.lab=function(t){var e=Gt.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},Gt.hsl.rgb=function(t){var e,n,r,s,i,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),s=[0,0,0];for(var u=0;u<3;u++)(r=o+1/3*-(u-1))<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,s[u]=255*i;return s},Gt.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,s=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,s*=i<=1?i:2-i,[e,100*(0===r?2*s/(i+s):2*n/(r+n)),100*((r+n)/2)]},Gt.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,s=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,s){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},Gt.hsv.hsl=function(t){var e,n,r,s=t[0],i=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-i)*o,n=i*a,[s,100*(n=(n/=(e=(2-i)*a)<=1?e:2-e)||0),100*(r/=2)]},Gt.hwb.rgb=function(t){var e,n,r,s,i,o,a,c=t[0]/360,u=t[1]/100,l=t[2]/100,f=u+l;switch(f>1&&(u/=f,l/=f),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),s=u+r*((n=1-l)-u),e){default:case 6:case 0:i=n,o=s,a=u;break;case 1:i=s,o=n,a=u;break;case 2:i=u,o=n,a=s;break;case 3:i=u,o=s,a=n;break;case 4:i=s,o=u,a=n;break;case 5:i=n,o=u,a=s}return[255*i,255*o,255*a]},Gt.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,s=t[3]/100;return[255*(1-Math.min(1,e*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s))]},Gt.xyz.rgb=function(t){var e,n,r,s=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*s+1.8758*i+.0415*o,r=.0557*s+-.204*i+1.057*o,e=(e=3.2406*s+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},Gt.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},Gt.lab.xyz=function(t){var e,n,r,s=t[0];e=t[1]/500+(n=(s+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},Gt.lab.lch=function(t){var e,n=t[0],r=t[1],s=t[2];return(e=360*Math.atan2(s,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+s*s),e]},Gt.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},Gt.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:Gt.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},Gt.hsv.ansi16=function(t){return Gt.rgb.ansi16(Gt.hsv.rgb(t),t[2])},Gt.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},Gt.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},Gt.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},Gt.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},Gt.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},Gt.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(n,r),s),o=Math.min(Math.min(n,r),s),a=i-o;return e=a<=0?0:i===n?(r-s)/a%6:i===r?2+(s-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},Gt.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,s=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(s=(n-.5*r)/(1-r)),[t[0],100*r,100*s]},Gt.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},Gt.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var s,i=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return s=(1-n)*r,[255*(n*i[0]+s),255*(n*i[1]+s),255*(n*i[2]+s)]},Gt.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},Gt.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},Gt.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},Gt.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},Gt.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},Gt.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},Gt.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},Gt.gray.hsl=Gt.gray.hsv=function(t){return[0,0,t[0]]},Gt.gray.hwb=function(t){return[0,100,t[0]]},Gt.gray.cmyk=function(t){return[0,0,0,t[0]]},Gt.gray.lab=function(t){return[t[0],0,0]},Gt.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},Gt.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Kt=jt.exports,Yt=Kt;function Qt(t){var e=function(){for(var t={},e=Object.keys(Yt),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),s=Object.keys(Yt[r]),i=s.length,o=0;o<i;o++){var a=s[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function Wt(t,e){return function(n){return e(t(n))}}function Zt(t,e){for(var n=[e[t].parent,t],r=Yt[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=Wt(Yt[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var te=Kt,ee=function(t){for(var e=Qt(t),n={},r=Object.keys(e),s=r.length,i=0;i<s;i++){var o=r[i];null!==e[o].parent&&(n[o]=Zt(o,e))}return n},ne={};Object.keys(te).forEach((function(t){ne[t]={},Object.defineProperty(ne[t],"channels",{value:te[t].channels}),Object.defineProperty(ne[t],"labels",{value:te[t].labels});var e=ee(t);Object.keys(e).forEach((function(n){var r=e[n];ne[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,s=0;s<r;s++)n[s]=Math.round(n[s]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),ne[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var re=Lt,se=ne,ie=[].slice,oe=["keyword","gray","hex"],ae={};Object.keys(se).forEach((function(t){ae[ie.call(se[t].labels).sort().join("")]=t}));var ce={};function ue(t,e){if(!(this instanceof ue))return new ue(t,e);if(e&&e in oe&&(e=null),e&&!(e in se))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ue)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var s=re.get(t);if(null===s)throw new Error("Unable to parse color from string: "+t);this.model=s.model,r=se[this.model].channels,this.color=s.value.slice(0,r),this.valpha="number"==typeof s.value[r]?s.value[r]:1}else if(t.length){this.model=e||"rgb",r=se[this.model].channels;var i=ie.call(t,0,r);this.color=he(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ae))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ae[a];var c=se[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=he(u)}if(ce[this.model])for(r=se[this.model].channels,n=0;n<r;n++){var l=ce[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function le(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(ce[t]||(ce[t]=[]))[e]=n})),t=t[0],function(r){var s;return arguments.length?(n&&(r=n(r)),(s=this[t]()).color[e]=r,s):(s=this[t]().color[e],n&&(s=n(s)),s)}}function fe(t){return function(e){return Math.max(0,Math.min(t,e))}}function he(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function de(t){return null==t}function ye(t){return"object"==typeof t&&!!t}function me(t){return t/Math.PI*180}ue.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in re.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return re.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return re.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=se[this.model].channels,n=se[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ue(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ue(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:le("rgb",0,fe(255)),green:le("rgb",1,fe(255)),blue:le("rgb",2,fe(255)),hue:le(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:le("hsl",1,fe(100)),lightness:le("hsl",2,fe(100)),saturationv:le("hsv",1,fe(100)),value:le("hsv",2,fe(100)),chroma:le("hcg",1,fe(100)),gray:le("hcg",2,fe(100)),white:le("hwb",1,fe(100)),wblack:le("hwb",2,fe(100)),cyan:le("cmyk",0,fe(100)),magenta:le("cmyk",1,fe(100)),yellow:le("cmyk",2,fe(100)),black:le("cmyk",3,fe(100)),x:le("xyz",0,fe(100)),y:le("xyz",1,fe(100)),z:le("xyz",2,fe(100)),l:le("lab",0,fe(100)),a:le("lab",1),b:le("lab",2),keyword:function(t){return arguments.length?new ue(t):se[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ue(t):re.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ue.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),s=void 0===e?.5:e,i=2*s-1,o=n.alpha()-r.alpha(),a=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-a;return ue.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*s+r.alpha()*(1-s))}},Object.keys(se).forEach((function(t){if(-1===oe.indexOf(t)){var e=se[t].channels;ue.prototype[t]=function(){if(this.model===t)return new ue(this);if(arguments.length)return new ue(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ue((n=se[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ue[t]=function(n){return"number"==typeof n&&(n=he(ie.call(arguments),e)),new ue(n,t)}}}));const be=[1,1,1,1,2,2,3,0];function pe(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=be[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}new Array(3),new Array(3);const ge=[1/6378137,1/6378137,1/6356752.314245179],we=[1/40680631590769,1/40680631590769,1/40408299984661.445],ve=new Array(3),Me=new Array(3),Te=new Array(3);function Ae(t,e){const n=we,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],u=n[1],l=n[2],f=i*i*c*c,h=o*o*u*u,d=a*a*l*l,m=f+h+d,b=Math.sqrt(1/m),p=y(_e,e,b);if(m<s)return isFinite(b)?p:void 0;const g=r[0],w=r[1],v=r[2],M=Oe;M[0]=p[0]*g*2,M[1]=p[1]*w*2,M[2]=p[2]*v*2;let T,A,_,O,k,x,S,I,E,C,U,F=(1-b)*xe(e)/(.5*xe(M)),N=0;do{F-=N,_=1/(1+F*g),O=1/(1+F*w),k=1/(1+F*v),x=_*_,S=O*O,I=k*k,E=x*_,C=S*O,U=I*k,T=f*x+h*S+d*I-1,A=f*E*g+h*C*w+d*U*v;N=T/(-2*A)}while(Math.abs(T)>ke);return t[0]=i*_,t[1]=o*O,t[2]=a*k,t}(ve,e,ge,n,.1);let s=w(Me,r,n);s=function(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i);return t}(s,s);const i=g(Te,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=function(t){return Math.sign?Math.sign(t):0==(t=+t)||isNaN(t)?Number(t):t>0?1:-1}(b(i,e))*xe(i);return t[0]=me(o),t[1]=me(a),t[2]=c,t}const _e=new Array(3),Oe=new Array(3),ke=1e-12;function xe(t){return u(t)}function Se(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const Ie="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ee(t,e,n){const r=new Uint8Array(t,e,n);return Ie?JSON.parse(Ie.decode(r)):JSON.parse(pe(r))}function Ce(t,e,n){const r=new Uint8Array(t,e,n);return Ie?JSON.parse(Ie.decode(r)):JSON.parse(pe(r))}function Ue(t,e,n){return{offset:e,byteLength:n}}function Fe(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=function(t){return Be[t]}(i||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Pe[t]}(o);return{byteStride:0,byteOffset:s+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+s,r*u)}}function Ne(t,e,n,r){const s=Fe(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}const Pe={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Be={"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 De(t){for(const e in Be)if(t===Be[e].ctor)return Be[e].type;throw new Error("unrecognized ctor:"+t)}function Re(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function Le(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,u={},l={},f=null;r>0&&(u=Ee(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(l=Ce(a,e,i),e+=i);const h=Ue(0,e,o);return f=a.slice(h.offset,h.offset+h.byteLength),n.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}const je={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function ze(t){for(const e in je)if(t===je[e])return+e;throw new Error("unrecognized ctor:"+t)}\n/*!\n * @maptalks/gl v0.98.0\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.com\n */const qe=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")},Ve=qe(),Ge=Ve.gl_trans__coders=Ve.gl_trans__coders||{};Ge.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=Ve.gl_trans__coders=Ve.gl_trans__coders||{};let i=\`${o}r}\\n const _____getGlobal = ${o}qe.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};\`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+='tran_____scoders["'+t+'"] ='+s[t].toString()+"\\n;");return i+="\\n"+e.substring(r.length),i},Ge.registerTranscoder=function(t,e){Ge[t]=e},Ge.getTranscoder=function(t){return Ge[t]};let $e=null;function Xe(){return $e||($e={"image/crn":Ge.crn&&Ge.crn(),"image/ktx2":Ge.ktx2&&Ge.ktx2(),"image/cttf":Ge.ktx2&&Ge.ktx2(),"draco":Ge.draco&&Ge.draco()}),$e}class He{constructor(t,e,n){this.i=t,this.st=e||ft,this.o=n,this.it=Xe()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,s)):$.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.ot(t,s,n,r)}))}ot(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.ct(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.st(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.it,supportedFormats:this.o,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${o}t}-${o}n}-${o}r}\`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}ct(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),u=s.getUint32(20,!0),l=s.getUint32(24,!0),f=28+e;u>=570425344?(f-=8,o=a,u=c,l=0,a=0,c=0):l>=570425344&&(f-=4,o=u,u=a,l=c,a=0,c=0);const h=[t];let d,y,m;if(a>0?(d=Ee(t,f,a),f+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(f+=c),u>0&&(y=Ce(t,f,u),f+=u,l>0)){const e=Ue(0,f,l);m=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(m)}const b=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=Ne(d.BATCH_ID,t,undefined.offset,b);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:o,transferables:h,featureTable:d,batchTable:y,batchTableBin:m,b3dm:p,glb:{buffer:t,byteOffset:f,byteLength:s.byteLength+s.byteOffset-f}}}ut(){return null}}class Je{constructor(t,e,n,r){this.i=t,this.st=e||ft,this.o=n,this.it=Xe(),this.lt=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,s)):$.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.ot(t,s,n,r)}))}ot(t,e,n,r,s){return this.ft(t,e,n,r,s).then((({gltf:s,transferables:i})=>{const o=this.ht(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})}))}ft(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.it,supportedFormats:this.o,maxTextureSize:i},a=new DataView(e,n,r),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 r=pe(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?$.getArrayBuffer(r,{}).then((t=>this.dt(r,{buffer:t.data,byteOffset:0},o))):$.getJSON(r,{}).then((t=>this.dt(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.dt(t,r,o)}}dt(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.st(r,e,n);return s.load({skipAttributeTransform:!0}).then((n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=\`${o}t}-${o}r}-${o}i}\`,{transferables:s.transferables,gltf:n}}))}ht(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:l}=Le(s,32+e,o),f={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.yt(new Uint16Array(t,r+c.offset,3*h),e,n)},o.push(f.POSITION.array.buffer)}if(a.BATCH_ID){f.BATCH_ID=Ne(a.BATCH_ID,t,c.offset,h);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.bt(new Uint16Array(t,e+c.offset,2*h))},o.push(f.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.bt(new Uint16Array(t,e+c.offset,2*h))},o.push(f.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},o.push(f.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;f.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(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:l,featureTable:a,i3dm:f,transferables:o}}bt(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)Ke(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}yt(t,e,n){return Re(new Float32Array(t.length),t,e,n)}ut(){return null}}function Ke(t,e,n,r){if(t[0]=Ye(e,r),t[1]=Ye(n,r),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]))*Qe(e),t[1]=(1-Math.abs(e))*Qe(t[1])}return m(t,t)}function Ye(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,n){return t<e?e:t>n?n:t}(t,0,e)/e*2-1}function Qe(t){return t<0?-1:1}class We{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.ot(t,e,n,r)):$.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.ot(t,s,n,r)}))}ot(t,e,n,r){return this.gt(e,n,r,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}))}gt(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:l}=Le(s,e+28,o),f=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let y,m={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){m=a.extensions["3DTILES_draco_point_compression"],y=new DataView(t,m.byteOffset+c.offset,m.byteLength);const e={attributes:m.properties,useUniqueIDs:!1};return this.wt||(this.wt=Xe().draco),this.wt(y,e).then((e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.vt(t,e.attributes,c.offset,d,o,f,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:De(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Ne(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Ze(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:u,batchTableBin:l,featureTable:a,pnts:r,transferables:o}}))}const b=this.vt(t,a,c.offset,d,o,f,h);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?b.BATCH_ID=Ne(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=Ze(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:u,batchTableBin:l,featureTable:a,pnts:b,transferables:o})}vt(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const l=u?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.yt(u||new Uint16Array(t,c+l,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}yt(t,e,n){return Re(new Float32Array(t.length),t,e,n)}ut(){return null}}function Ze(t){const e=(n=t)<256?Uint8Array:n<65536?Uint16Array:Uint32Array;var n;const r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:De(e),array:r}}class tn{constructor(t,e,n,r){this.o=n,this.i=t,this.st=e||ft,this.lt=r}load(t,e,n=0,r=0,s){return e?this.ot(t,e,n,r,s):$.getArrayBuffer(t,{}).then((e=>{const s=e.data;return this.ot(t,s,n,r)}))}ot(t,e,n,r,s){r||(r=e.byteLength);const i=this.Mt(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new He(this.i,this.st,this.o);else if("i3dm"===i[n].magic)r=new Je(this.i,this.st,this.o,this.lt);else if("pnts"===i[n].magic)r=new We;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new tn(this.i,this.st,this.o,this.lt)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Mt(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Se(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function en(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];un(r[n],s,t,e)}}}const nn=[],rn=[],sn=[],on=[0,0,0],an=_([]),cn=[1,1,1];function un(t,e,n,a){const c=e.slice(0);if(t.matrix)c.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=s(nn,t.translation||on),n=o(rn,t.rotation||an),a=i(sn,t.scale||cn);r(a,n,a);const u=r([],e,a);c.push(u)}if(t.children&&t.children.length)for(let e=0,r=t.children.length;e<r;e++)un(t.children[e],c,n,a);if(void 0!==t.mesh){const e=t.mesh,r=n.meshes[e];if(r){const t=c.slice(0),s=r.primitives;for(let r=0,i=s.length;r<i;r++){const i=s[r];i&&(i.matrices=t,a(i,e,r,n))}}}}function ln(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?ft.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===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 u=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);u.set(s);e(new c(u.buffer),t),s.set(u)}}var fn=bn("DXT1"),hn=bn("DXT3"),dn=bn("DXT5"),yn=bn("DX10"),mn=function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var s=r[21];switch(s){case fn:e=8,n="dxt1";break;case hn:e=16,n="dxt3";break;case dn:e=16,n="dxt5";break;case 116:n="rgba32f";break;case yn:var i=new Uint32Array(t.slice(128,148));n=i[0];var o=i[1];if(i[2],i[3],i[4],3!==o||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=s,String.fromCharCode(255&a,a>>8&255,a>>16&255,a>>24&255)))}var a;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var l=!1;512&r[28]&&(l=!0);var f,h=r[4],d=r[3],y=r[1]+4,m=h,b=d,p=[];s===yn&&(y+=20);if(l)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=m,d=b;for(var w=Math.log(h)/Math.log(2)+1,v=0;v<w;v++)f=h*d*16,p.push({offset:y,length:f,shape:[h,d]}),v<u&&(y+=f),h=Math.floor(h/2),d=Math.floor(d/2)}else for(v=0;v<u;v++)f=Math.max(4,h)/4*Math.max(4,d)/4*e,p.push({offset:y,length:f,shape:[h,d]}),y+=f,h=Math.floor(h/2),d=Math.floor(d/2);return{shape:[m,b],images:p,format:n,flags:c,cubemap:l}};function bn(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var pn=At(mn),gn=Math.abs,wn=Math.sin,vn=Math.cos,Mn=Math.tan,Tn=Math.atan,An=Math.atan2,_n=Math.sqrt,On=Math.log,kn=Math.hypot,xn=Math.sinh,Sn=Math.cosh,In=1/0;function En(t){var e,n,r,s,i,o,a=[],c=[],u=[],l=[];function f(t,e){for(var n,r=2*vn(2*e),s=t.length-1,i=t[s],o=0;--s>=0;)n=r*i-o+t[s],o=i,i=n;return e+n*wn(2*e)}function h(t,e,n){for(var r,s,i=wn(e),o=vn(e),a=xn(n),c=Sn(n),u=2*o*c,l=-2*i*a,f=t.length-1,h=t[f],d=0,y=0,m=0;--f>=0;)r=y,s=d,h=u*(y=h)-r-l*(d=m)+t[f],m=l*y-s+u*d;return[(u=i*c)*h-(l=o*a)*m,u*m+l*h]}t.es,i=s=(r=t.es/(1+_n(1-t.es)))/(2-r),a[0]=s*(2+s*(-2/3+s*(s*(116/45+s*(26/45+s*(-2854/675)))-2))),c[0]=s*(s*(2/3+s*(4/3+s*(-82/45+s*(32/45+s*(4642/4725)))))-2),i*=s,a[1]=i*(7/3+s*(s*(-227/45+s*(2704/315+s*(2323/945)))-1.6)),c[1]=i*(5/3+s*(-16/15+s*(-13/9+s*(904/315+s*(-1522/945))))),i*=s,a[2]=i*(56/15+s*(-136/35+s*(-1262/105+s*(73814/2835)))),c[2]=i*(-26/15+s*(34/21+s*(1.6+s*(-12686/2835)))),i*=s,a[3]=i*(4279/630+s*(-332/35+s*(-399572/14175))),c[3]=i*(1237/630+s*(s*(-24832/14175)-2.4)),i*=s,a[4]=i*(4174/315+s*(-144838/6237)),c[4]=i*(-734/315+s*(109598/31185)),i*=s,a[5]=i*(601676/22275),c[5]=i*(444337/155925),i=s*s,e=t.k0/(1+s)*(1+i*(1/4+i*(1/64+i/256))),u[0]=s*(s*(2/3+s*(-37/96+s*(1/360+s*(81/512+s*(-96199/604800)))))-.5),l[0]=s*(.5+s*(-2/3+s*(5/16+s*(41/180+s*(-127/288+s*(7891/37800)))))),u[1]=i*(-1/48+s*(-1/15+s*(437/1440+s*(-46/105+s*(1118711/3870720))))),l[1]=i*(13/48+s*(s*(557/1440+s*(281/630+s*(-1983433/1935360)))-.6)),i*=s,u[2]=i*(-17/480+s*(37/840+s*(209/4480+s*(-5569/90720)))),l[2]=i*(61/240+s*(-103/140+s*(15061/26880+s*(167603/181440)))),i*=s,u[3]=i*(-4397/161280+s*(11/504+s*(830251/7257600))),l[3]=i*(49561/161280+s*(-179/168+s*(6601661/7257600))),i*=s,u[4]=i*(-4583/161280+s*(108847/3991680)),l[4]=i*(34729/80640+s*(-3418889/1995840)),i*=s,u[5]=i*(-20648693/638668800),l[5]=.6650675310896665*i,o=f(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*vn(e),s=t.length-1,i=t[s],o=0;for(;--s>=0;)n=r*i-o+t[s],o=i,i=n;return wn(e)*n}(l,2*o)),t.fwd=function(t,r){var s,i,o,a,u,d=t.phi,y=t.lam;d=f(c,d),s=wn(d),i=vn(d),a=wn(y),o=vn(y),d=An(s,o*i),y=An(a*i,kn(s,i*o)),y=function(t){var e=gn(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*On(e)/n}(e*(1+e/(kn(1,e)+1))),t<0?-e:e}(Mn(y)),u=h(l,2*d,2*y),d+=u[0],y+=u[1],gn(y)<=2.623395162778?(r.y=e*d+n,r.x=e*y):r.x=r.y=In},t.inv=function(t,r){var s,i,o,c,l,d=t.y,y=t.x;d=(d-n)/e,gn(y/=e)<=2.623395162778?(d+=(l=h(u,2*d,2*y))[0],y+=l[1],y=Tn(xn(y)),s=wn(d),i=vn(d),c=wn(y),o=vn(y),y=An(c,o*i),d=An(s*o,kn(c,o*i)),r.phi=f(a,d),r.lam=y):r.phi=r.lam=In}}const Cn=Math.PI/180,Un=6378137*Math.PI/180,Fn=85.0511287798,Nn={};function Pn(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=Fn,r=e[0],s=Math.max(Math.min(n,e[1]),-n);let i;i=0===s?0:Math.log(Math.tan((90+s)*Cn/2))/Cn;return t[0]=r*Un,t[1]=i*Un,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return Bn(t,e);if("baidu"===n)return Bn(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const s=JSON.stringify(n);let i=Nn[s];return i||(i=Nn[s]=function(t){const e={a:Rn,es:Ln,x0:de(t.falseEasting)?5e5:t.falseEasting,y0:de(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*Dn,phi0:(t.latitudeOfOrigin||0)*Dn,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};En(e);const n={lam:0,phi:0},r={};let s=0,i=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*Dn-e.lam0,n.phi=e.originPhi0*Dn,e.fwd(n,r),s=e.a*r.x+e.x0,i=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*Dn-e.lam0,n.phi=t[1]*Dn,e.fwd(n,r);const a=e.a*r.x+e.x0-s,c=e.a*r.y+e.y0-i;return o[0]=a,o[1]=c,o}}}(n)),i.project(e,t)}}function Bn(t,e){return t[0]=e[0],t[1]=e[1],t}const Dn=.017453292519943295,Rn=6378137,Ln=.0066943799901413165;const jn=n([]),zn=Xe().draco,qn=Xe().ktx2,Vn={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},Gn={"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":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function $n(t,e,r,s,i,o){const a=[],c=[],u=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],s=$.getArrayBuffer(n.url,o);s.xhr.url=n.url,u.push(s.xhr);const i=s.then((t=>({buffer:t})));a.push(i);const l=[];if(Zn(r,l),l.length){const t=l.map((t=>{const e=$.getArrayBuffer(t.url,o);return e.xhr.url=t.url,u.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));a.push(...t)}c[e]=l.length}const l=Promise.all(a).then((o=>{for(let t=0;t<o.length;t++)if(!o[t]||!o[t].buffer)return Promise.resolve(null);const a=[];let u=0;for(let t=0;t<c.length;t++){const e=c[t];a.push({geoBuffer:{data:o[u].buffer.data},textureBuffers:o.slice(u+1,e+u+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),u+=1+e}const l=function(t,e,r,s,i,o){const a={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let u=0;u<t.meshes.length;u++){let{material:l}=t.meshes[u];const{geometry:f}=t.meshes[u];let h;const d=e[u].geoBuffer.data;if(!d)continue;h=ir(d)?Hn(a,u,f,d,t.transform,t.center,i,o):Kn(a,u,f,d,t.transform,t.center,i,o),c.push(h),a.nodes[u]={mesh:u,nodeIndex:u,matrix:n([])},a.scenes[0].nodes[u]=a.nodes[u],l||(l=Vn);const y=Qn(u,a,l,e[u].textureBuffers,r,s);c.push(y)}return Promise.all(c).then((()=>({gltf:a,featureTable:{BATCH_LENGTH:0},transferables:a.transferables})))}(t,a,e,i,r,s);return l}));return l.xhr=u,l}const Xn={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Hn(t,e,n,r,s,i,o,a){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=Gn[e];if(!r)return t;return t[r.name||e]=n,t}),{});return zn(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>Yn(n,t,e,s,i,o,a)))}const Jn={position:function(t,e,n){const r=3*t.vertexCount,s=new Float32Array(e,n,r);return t.position={array:s,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,s=new Float32Array(e,n,r);return t.normal={array:s,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,s=new Float32Array(e,n,r);return t.uv0={array:s,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,s=new Uint8Array(e,n,r);return t.color={array:s,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,s=new Uint32Array(e,n,r);return t.faceRange={array:s,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,s=new Uint16Array(e,n,r);return t["uv-region"]={array:s,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,s=new Uint16Array(e,n,r);return t["uv-region"]={array:s,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Kn(t,e,n,r,s,i,o,a){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)Jn[n[e]]?t=Jn[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let s=e.ordering,i=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<s.length;e++){const n=Jn[s[e]];n||console.log(s[e]),t=n(c,r,t)}for(let e=0;e<i.length;e++){const n=Jn[i[e]];n||console.log(i[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const l={};for(const t in c){const e=Gn[t]&&Gn[t].name;e&&(l[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(f=e)<=255?Uint8Array:f<=65535?Uint16Array:Uint32Array,r=new n(l.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,s=t[e],i=t[e+1];for(let t=s;t<=i;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}l._BATCHID={componentType:ze(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var f;return Yn({attributes:l},t,e,s,i,o,a)}function Yn(t,e,n,r,s,i,o){const c={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const u=function(t,e,n,r,s){let i,o=[0,0,0,1];const c=[0,0],u=Pn([],n,r,s);u[2]=n[2];const l=e&&a(jn,e);return ln(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],l||(o=p(o,o,e)),n&&d(o,o,n),Pn(c,o,r,s),i=o[2],t[0]=c[0]-u[0],t[1]=c[1]-u[1],t[2]=i-u[2],t))),u}(t.attributes.POSITION,r,s,i,o);e.meshes[n]={primitives:[c],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:s};for(const n in t.attributes)sr(e.transferables,t.attributes[n].array.buffer);return t.indices&&sr(e.transferables,t.indices.array.buffer),c}function Qn(t,e,n,r,s,i){const o=r.map((t=>function(t,e,n,r,s){if("dds"===e){const e=pn(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),s="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Xn,format:s})}if("png"===e||"jpg"===e)return function(t,e){tr||(tr=new OffscreenCanvas(2,2),er=tr.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;nr(n)||(n=rr(n)),nr(r)||(r=rr(r));const s=e;s&&(n=Math.min(s,n),r=Math.min(s,r)),tr.width=n,tr.height=r,er.drawImage(t,0,0,n,r),t.close();const i=er.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(i.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,s).then((t=>{t.mimeType=n;return{image:t,sampler:Xn,format:6408}}));if("ktx2"===e)return qn(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Xn,format:t.format})));return null}(t.data,t.format,t.mimeType,s,i).then((t=>{if(t.image)if(t.image.array)sr(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)sr(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(o).then((r=>{Wn(t,e,n,r)}))}function Wn(t,e,n,r){const s=JSON.parse(JSON.stringify(n)),i=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(i.push(r[r.ptr++]),s[t]={index:i.length-1},void 0!==n[t].factor&&(s[t].scale=n[t].factor)):ye(n[t])&&(s[t]=Wn(-1,e,n[t],r));return t>=0&&(e.materials[t]=s),s}function Zn(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):ye(t[n])&&Zn(t[n],e)}let tr,er;function nr(t){return!(t&t-1)&&0!==t}function rr(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function sr(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function ir(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()}var or="undefined"!=typeof Float32Array?Float32Array:Array;function ar(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var cr=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};!function(){var t=function(){var t=new or(3);return or!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const ur=[];const lr=[],fr=[],hr=[],dr=[],yr=[],mr=[],br=[];function pr(t,e,n,r,s,i){ar(dr,t[3*e],t[3*e+1],t[3*e+2]),ar(yr,t[3*n],t[3*n+1],t[3*n+2]),ar(mr,t[3*r],t[3*r+1],t[3*r+2]);const o=cr(lr,mr,yr),a=cr(fr,dr,yr),c=function(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[0],a=n[1],c=n[2];return t[0]=s*c-i*a,t[1]=i*o-r*c,t[2]=r*a-s*o,t}(hr,o,a);!function(t,e){var n=e[0],r=e[1],s=e[2],i=n*n+r*r+s*s;i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i)}(br,c),s[3*e]=s[3*e]||0,s[3*n]=s[3*n]||0,s[3*r]=s[3*r]||0,s[3*e+1]=s[3*e+1]||0,s[3*n+1]=s[3*n+1]||0,s[3*r+1]=s[3*r+1]||0,s[3*e+2]=s[3*e+2]||0,s[3*n+2]=s[3*n+2]||0,s[3*r+2]=s[3*r+2]||0,s[3*e]+=br[0],s[3*n]+=br[0],s[3*r]+=br[0],s[3*e+1]+=br[1],s[3*n+1]+=br[1],s[3*r+1]+=br[1],s[3*e+2]+=br[2],s[3*n+2]+=br[2],s[3*r+2]+=br[2],i[e]+=1,i[n]+=1,i[r]+=1}const gr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],wr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],vr=2*Math.PI*6378137/360,Mr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let Tr,Ar,_r=!1;if("undefined"!=typeof OffscreenCanvas){try{Ar=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}Ar&&"undefined"!=typeof createImageBitmap&&(_r=!0)}const Or=n([]),kr=[0,0,0],xr=[],Sr=[],Ir=[],Er=[],Cr={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Ur={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Fr;class Nr{constructor(t,e,n,r){this.id=t,this.options=e,this.Tt=this.requestImage.bind(this),this.At=n,this._t={},r(null,{},[])}Ot(t){this.kt||(this.o=t,this.xt=new We,this.kt=new He(this.Tt,ft,t),this.St=new Je(this.Tt,ft,t))}requestImage(t,e){_r?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{Tr.width=t.width,Tr.height=t.height,Ar.drawImage(t,0,0);const n=Ar.getImageData(0,0,Tr.width,Tr.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.At("requestImage",{url:t},null,e)}loadTile(t,e){this.Ot(t.supportedFormats);const{service:n,url:r,arraybuffer:s}=t,i=n.fetchOptions||{};if(i.referrer=t.referrer,i.referrerPolicy=i.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const s=t.i3sInfo,o=n.maxTextureSize||0,a=$n(s,t.supportedFormats,this.options.projection,t.projection,o,i);return a.then((t=>{if(delete this._t[r],!t)return void e({status:404,url:r,i3sInfo:s});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:s});t.gltf.url=r;const{transferables:i}=t;t.magic="b3dm",this.It(t.gltf),n.compressGeometry&&this.Et(t.gltf),e(null,t,i)})),void(this._t[r]=a.xhr)}if(s){delete this._t[r];const n=Se(new DataView(s),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(Mr){const r=new Uint8Array(t,e,n);return Mr.decode(r)}return pe(new Uint8Array(t,e,n))}(s,0,s.byteLength),i=JSON.parse(n);i.accessors?this.Ct(i,r,t,"gltf",e):this.Ut(t.rootIdx,i,s,r,e)}else this.Ct(s,r,t,n,e)}else{let s=n.urlParams;s&&(s=(r.indexOf("?")>0?"&":"?")+s);const o=r.replace(/\\+/g,"%2B");let a=$.getArrayBuffer(o+(s||""),i);const c=a.xhr;a=a.then((n=>{delete this._t[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this._t[r],e(t)})),this._t[r]=c}}Ct(t,e,n,r,s){r=r&&r.toLowerCase();const{service:i}=n;if("b3dm"===r){this.kt.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||0}).then((t=>{if(t.error)return void s(t);const{content:e,transferables:r}=this.Ft(t,n);this.It(e.gltf),i.compressGeometry&&this.Et(e.gltf),s(null,e,r)})).catch((t=>{s(t)}))}else if("pnts"===r){const r=n.transform||Or;this.xt.load(e,t).then((t=>{const{content:e,transferables:i}=this.Nt(t,r,n.rootIdx);this.Pt(e),s(null,e,i)}))}else if("i3dm"===r){const r=n.transform||Or;this.St.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||0}).then((t=>{const{content:e,transferables:o}=this.Bt(t,r,n.rootIdx);this.It(e.gltf),i.compressGeometry&&this.Et(e.gltf),s(null,e,o)}))}else if("cmpt"===r){new tn(this.Tt,ft,this.o,i.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:i.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Dt(t,n);this.Rt(e),i.compressGeometry&&this.Lt(e),s(null,e,r)})).catch((t=>{s(t)}))}else if("gltf"===r){this.it||(this.it=Xe());const r=e.substring(0,e.lastIndexOf("/")),o=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t,a=new ft(r,o,{transferable:!0,requestImage:this.Tt,decoders:this.it,supportedFormats:this.o,maxTextureSize:i.maxTextureSize||0});a.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.jt(t,null,n),this.It(t),i.compressGeometry&&this.Et(t),s(null,{magic:"gltf",gltf:t},a.transferables)}))}else s(new Error("unsupported tile format: "+r))}Rt(t){t.content?t.content.forEach((t=>{this.Rt(t)})):this.It(t.gltf)}Lt(t){t.content?t.content.forEach((t=>{this.Lt(t)})):this.Et(t.gltf)}zt(t,e){if(this.qt(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.Vt()?Fr.subarray(0,n):e,s=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const s=ur;s.length<t.length/3&&(s.length=t.length/3),s.fill(0,0,t.length/3);const i=void 0===e.length?e:e.length;for(let n=0;n<i/3;n++)void 0===e.length?pr(t,3*n,3*n+1,3*n+2,r,s):pr(t,e[3*n],e[3*n+1],e[3*n+2],r,s);const o=r.getLength?r.getLength():r.length;for(let t=0;t<o;t+=3){const e=s[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:s,byteLength:s.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:s.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}Et(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const t in e){e[t].primitives.forEach((t=>{t.compressed_int16_params={};const e=t.attributes;for(const n in e)if(Cr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=vr,t.compressed_int16_params.compressed_ratio=r);const s=jr(e[n].array,r,e[n].min,e[n].max,n);if(!s)continue;const{array:i,range:o}=s;e[n].componentType=5124,e[n].array=i,t.compressed_int16_params[n]=o}}))}}It(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach((e=>{this.zt(e,t)}))}}Pt(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(Cr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=vr,t.compressed_int16_params.compressed_ratio=r);const{array:s,range:i}=jr(e[n].array,r,e[n].min,e[n].max,n);e[n].array=s,t.compressed_int16_params[n]=i}}Gt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const s={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(s)}return e}Ut(t,e,n,r,s){return e.capabilities,void s(null,e)}Dt(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},s=[];for(let t=0;t<n.length;t++){const{magic:i}=n[t];if("b3dm"===i){const{content:i,transferables:o}=this.Ft(n[t],e);Rr(s,o),r.content.push(i)}else if("i3dm"===i){const{transform:i,rootIdx:o}=e,{content:a,transferables:c}=this.Bt(n[t],i,o);Rr(s,c),r.content.push(a)}else if("pnts"===i){const{transform:i,rootIdx:o}=e,{content:a,transferables:c}=this.Nt(n[t],i,o);Rr(s,c),r.content.push(a)}else if("cmpt"===i){const{content:i,transferables:o}=this.Dt(n[t],e);Rr(s,o),r.content.push(i)}}return{content:r,transferables:s}}Ft(t,e){const{gltf:n,transferables:r,featureTable:s}=t;return this.jt(n,s,e),delete t.transferables,{content:t,transferables:r}}jt(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;const e="visited";let n=1;const r=[];for(const s in t.meshes){const i=t.meshes[s],{primitives:o}=i;if(o)for(let t=0;t<o.length;t++){const s=o[t].attributes&&o[t].attributes.POSITION;if(!s||!s.array)continue;s.array.buffer[e]||(s.array.buffer[e]=n++);const i=n-1+"-"+(s.byteOffset||0);if(r.indexOf(i)>=0)return!0;r.push(i)}}return!1}(t);this.$t(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.Xt(t,e,n.upAxis,n.transform)):this.Ht(t,e,n.upAxis,n.transform)}Bt(t,e,n){const{featureTable:r}=t,s=t.i3dm,i=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,c=e&&a(Or,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Br(s.POSITION.array,3,i,Or,u);const l=Dr(u);e&&!c&&p(l,l,e);const d=this.Jt(l),y=[];Pn(y,d,o),y[2]=d[2];const m=f([],l),b=[0,0,0],g=[0,0,0],w=[0,0],M=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0];ln(s.POSITION,(t=>{b[0]=t[0]+i[0],b[1]=t[1]+i[1],b[2]=t[2]+i[2],e&&!c&&p(b,b,e),0===v(b)?h(g,0,0,-6378137):Ae(g,b),Pn(w,g,o),t[0]=w[0]-y[0],t[1]=w[1]-y[1],t[2]=g[2]-y[2],t[0]<M[0]&&(M[0]=t[0]),t[1]<M[1]&&(M[1]=t[1]),t[2]<M[2]&&(M[2]=t[2]),t[0]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2])})),s.POSITION.min=M,s.POSITION.max=T,e&&p(l,l,e),t.rtcCenter=m,t.rtcCoord=d,t.projCenter=y,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}Nt(t,e,n){const{featureTable:r}=t,s=t.pnts,i=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,c=e&&a(Or,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Br(s.POSITION.array,3,i,e,u);const l=Dr(u),d=this.Kt(l),y=f([],l),m=[1/0,1/0,1/0],b=[-1/0,-1/0,-1/0];let g=[0,0,0,1];const w=[0,0,0],M=[0,0];ln(s.POSITION,(t=>(g[0]=t[0]+i[0],g[1]=t[1]+i[1],g[2]=t[2]+i[2],e&&!c&&(g=p(g,g,e)),0===v(g)?h(w,0,0,-6378137):Ae(w,g),Pn(M,w,o),t[0]=M[0]-d[0],t[1]=M[1]-d[1],t[2]=w[2]-d[2],t[0]<m[0]&&(m[0]=t[0]),t[1]<m[1]&&(m[1]=t[1]),t[2]<m[2]&&(m[2]=t[2]),t[0]>b[0]&&(b[0]=t[0]),t[1]>b[1]&&(b[1]=t[1]),t[2]>b[2]&&(b[2]=t[2]),t))),s.POSITION.min=m,s.POSITION.max=b,e&&p(l,l,e);const T=this.Jt(l);t.rtcCenter=y,t.projCenter=d,t.rtcCoord=T,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}$t(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],s=n[1],i=n[2],o=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==s||n[t+2]!==i||n[t+3]!==o){a=!1;break}a&&(e[t].image.color=[r/255,s/255,i/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const n=this._t[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this._t[t.url],e(null)}Yt(t,e,s,i){const o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let a=gr;"X"===(s=s&&s.toUpperCase())?a=wr:"Z"===s&&(a=Or),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};en(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=n(xr);t.matrices&&Lr(e,t.matrices);const s=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;r(e,a,e),i&&r(e,i,e),Br(s,u,o||kr,e,c,t.compressUniforms)}));const u=Dr(c);return{rtcCenter:o,modelCenter:u,upAxisTransform:a}}Xt(t,e,s,i){const{modelCenter:o,upAxisTransform:a,rtcCenter:c}=this.Yt(t,e,s),u=this.Kt(o);t.extensions.MAPTALKS_RTC.projCenter=u,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Jt(o);const l=f([],o);i&&p(o,o,i),t.extensions.CESIUM_RTC.rtcCoord=this.Jt(o),c||(en(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 s=n(xr);t.matrices&&Lr(s,t.matrices),r(s,a,s);const i=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],u=e[7],l=e[8],f=e[9],h=e[10],d=e[11],y=e[12],m=e[13],b=e[14],p=e[15],g=n*a-r*o,w=n*c-s*o,v=n*u-i*o,M=r*c-s*a,T=r*u-i*a,A=s*u-i*c,_=l*m-f*y,O=l*b-h*y,k=l*p-d*y,x=f*b-h*m,S=f*p-d*m,I=h*p-d*b,E=g*I-w*S+v*x+M*k-T*O+A*_;return E?(E=1/E,t[0]=(a*I-c*S+u*x)*E,t[1]=(s*S-r*I-i*x)*E,t[2]=(m*A-b*T+p*M)*E,t[3]=(h*T-f*A-d*M)*E,t[4]=(c*k-o*I-u*O)*E,t[5]=(n*I-s*k+i*O)*E,t[6]=(b*v-y*A-p*w)*E,t[7]=(l*A-h*v+d*w)*E,t[8]=(o*S-a*k+u*_)*E,t[9]=(r*k-n*S-i*_)*E,t[10]=(y*T-m*v+p*g)*E,t[11]=(f*v-l*T-d*g)*E,t[12]=(a*O-o*x-c*_)*E,t[13]=(n*x-r*O+s*_)*E,t[14]=(m*w-y*M-b*g)*E,t[15]=(l*M-f*w+h*g)*E,t):null}(Sr,s),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];ln(e,(t=>{p(t,t,s),t[0]=t[0]-l[0],t[1]=t[1]-l[1],t[2]=t[2]-l[2],p(t,t,i),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,e,n,r){const{modelCenter:s,rtcCenter:i}=this.Yt(t,e,n,r),o=this.Kt(s);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Jt(s),en(t,(e=>{if(e.attributes&&e.attributes.POSITION){const s=this.qt(e,t);if(s){const t=e.attributes.POSITION.array.length;(!Fr||Fr.length<t)&&(Fr=new Float32Array(t))}e.attributes.NORMAL&&this.Qt(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.Qt(e.attributes.TANGENT,e.matrices,n);const{newPositions:o}=this.Wt(e.attributes.POSITION,e.matrices,i,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,s),{componentType:a}=e.attributes.POSITION;5126!==a&&(e.attributes.POSITION.array=new Float32Array(o))}}));for(const e in t.nodes){t.nodes[e].matrix=Or}}Kt(t){const e=this.options.projection;"identity"===e?f(Ir,t):0===v(t)?h(Ir,0,0,-6378137):Ae(Ir,t),Pn(Er,Ir,e);const n=Ir[2],r=[];return r[0]=Er[0],r[1]=Er[1],r[2]=n,r}Qt(t,e,n){let r;r="Y"===n?gr:"X"===n?wr:Or;const s=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}([],r);if(Lr(s,e),a(s,Or))return;const i=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}([],s),o=[];ln(t,(t=>(function(t,e,n){var r=e[0],s=e[1],i=e[2];t[0]=r*n[0]+s*n[3]+i*n[6],t[1]=r*n[1]+s*n[4]+i*n[7],t[2]=r*n[2]+s*n[5]+i*n[8]}(o,t,i),m(o,o),f(t,o),o)))}Wt(t,e,r,s,i,o,c,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const l=n([]);Lr(l,e);const f=this.options.projection;i=i&&i.toUpperCase();const y=r;let m=null;"Y"===i?m=gr:"X"===i&&(m=wr);let b=[0,0,0,1];const g=[0,0,0],w=[0,0],M=s.projCenter,T=Pn([],s.rtcCoord,"EPSG:3857"),A=o&&a(Or,o),_=t.min=t.min||[],O=t.max=t.max||[];h(_,1/0,1/0,1/0),h(O,-1/0,-1/0,-1/0);const k=c||{},{decode_position_min:x,decode_position_normConstant:S}=k;let I=[0,0,0,0],E=1;x&&(I=x),S&&(E=S);const C=[];return ln(t,((e,n)=>{if(b[0]=e[0]*E+I[0],b[1]=e[1]*E+I[1],b[2]=e[2]*E+I[2],b=p(b,b,l),m&&(b=p(b,b,m)),y&&d(b,b,y),o&&!A&&(b=p(b,b,o)),0===v(b)?h(g,0,0,-6378137):Ae(g,b),u){const t=Fr;Pn(w,g,f),t[3*n]=w[0]-T[0],t[3*n+1]=w[0]-T[1],t[3*n+2]=w[0]-T[2]}if(Pn(w,g,f),e instanceof Float32Array)e[0]=w[0]-M[0],e[1]=w[1]-M[1],e[2]=g[2]-M[2];else{const n=w[0]-M[0],r=w[1]-M[1],s=g[2]-M[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(s),C.push(e[3]))}return e[0]<_[0]&&(_[0]=e[0]),e[1]<_[1]&&(_[1]=e[1]),e[2]<_[2]&&(_[2]=e[2]),e[0]>O[0]&&(O[0]=e[0]),e[1]>O[1]&&(O[1]=e[1]),e[2]>O[2]&&(O[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:M,newPositions:C}}Jt(t){return 0===v(t)?h([],0,0,-6378137):Ae([],t)}onRemove(){}Vt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}qt(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material],r=n&&n.extensions&&n.extensions.KHR_materials_unlit;return r}(t,e))return!1;if(t.attributes.TANGENT)return!1;return!!t.attributes.TEXCOORD_0}}const Pr=[];function Br(t,e,n,r,s,i){const o=i||{},{decode_position_min:a,decode_position_normConstant:c}=o;let u=[0,0,0,0],l=1;a&&(u=a),c&&(l=c);for(let i=0,o=t.length;i<o;i+=e){const{xmin:o,ymin:a,xmax:c,ymax:f,hmin:y,hmax:m}=s;h(Pr,t[i]*l+u[0],t[i+1]*l+u[1],t[i+2]*l+u[2]),p(Pr,Pr,r);const b=d(Pr,n,Pr);b[0]<o&&(s.xmin=b[0]),b[0]>c&&(s.xmax=b[0]),b[1]<a&&(s.ymin=b[1]),b[1]>f&&(s.ymax=b[1]),e>2&&(b[2]<y&&(s.hmin=b[2]),b[2]>m&&(s.hmax=b[2]))}}function Dr(t){const{xmax:e,ymax:n,xmin:r,ymin:s,hmin:i,hmax:o}=t,a=[(r+e)/2,(s+n)/2,(i+o)/2];return e===-1/0&&(a[0]=0),n===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function Rr(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function Lr(t,e){const n=t;for(let t=e.length-1;t>=0;t--)r(n,e[t],n);return n}function jr(t,e,n,r,s){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let i,o;if(n&&r&&1===e)i=Math.min(...n),o=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);i=e,o=n}return!function(t,e,n,r){for(let s=0;s<t.length;s++){const i=zr(qr(t[s],e,n),e,n);if(Math.abs(i-t[s])>Ur[r])return!1}return!0}(t,i,o,s)&&Ur[s]?null:function(t,e,n){const r=new Int16Array(t.length);for(let s=0;s<t.length;s++)r[s]=qr(t[s],e,n);return{array:r,range:[e,n]}}(t,i,o)}function zr(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function qr(t,e,n){const r=2*(t-e)/(n-e)-1,s=Math.max(-1,Math.min(1,r));return s<0?32768*s:32767*s}let Vr=0;class Gr{constructor(t){this.workerId=t,this.workers={},this.Zt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},s){if(this.te(e,n))return;const i=this.ee(e,n),o=r.options,a=this.send.bind(this,t);this.workers[i]=new Nr(n,o,a,s)}removeLayer({mapId:t,layerId:e},n){const r=this.te(t,e),s=this.ee(t,e);delete this.workers[s],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const s=this.te(t,e);s&&s.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const s=this.te(t,e);s&&s.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.Zt[e];delete this.Zt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,s){const i=s?\`${o}t}-${o}Vr++}\`:null;s&&(this.Zt[i]=s),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(i)},r||[])}ee(t,e){return\`${o}t}-${o}e}\`}te(t,e){const n=this.ee(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Gr(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},((t,n,r)=>{t&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}`
|
|
7
7
|
/*!
|
|
8
8
|
* Contains code from THREE.js
|
|
9
9
|
* MIT License
|
|
10
10
|
* https://github.com/mrdoob/three.js
|
|
11
|
-
*/
|
|
12
|
-
var a=[],c=0;c<6;c++)a[c]=[];var h=[];function u(t,e,n){f(t);for(var r=0;r<6;r++)if(!n||"0"!==n.charAt(r)){var s=a[r];if(h[0]=s[0]>0?e[1][0]:e[0][0],h[1]=s[1]>0?e[1][1]:e[0][1],h[2]=s[2]>0?e[1][2]:e[0][2],m(s,h)<0)return!1}return!0}function l(t,e){var n=e,r=t,s=e,i=r[0],o=r[1],a=r[2],c=Math.abs(i*s[3]+o*s[4]+a*s[5])+Math.abs(i*s[6]+o*s[7]+a*s[8])+Math.abs(i*s[9]+o*s[10]+a*s[11]),h=m(t,n);return!(h<=-c)}function f(t){var e=t,n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],c=e[5],h=e[6],u=e[7],l=e[8],f=e[9],m=e[10],p=e[11],b=e[12],g=e[13],y=e[14],w=e[15];d(a[0],i-n,u-o,p-l,w-b),d(a[1],i+n,u+o,p+l,w+b),d(a[2],i+r,u+c,p+f,w+g),d(a[3],i-r,u-c,p-f,w-g),d(a[4],i-s,u-h,p-m,w-y),d(a[5],i+s,u+h,p+m,w+y)}function d(t,e,n,r,s){var i=1/Math.sqrt(e*e+n*n+r*r);return t[0]=e*i,t[1]=n*i,t[2]=r*i,t[3]=s*i,t}function m(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}var p={exports:{}},b={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},g={exports:{}},y=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},w=Array.prototype.concat,v=Array.prototype.slice,T=g.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];y(s)?e=w.call(e,v.call(s)):e.push(s)}return e};T.wrap=function(t){return function(){return t(T(arguments))}};var _=b,M=g.exports,O=Object.hasOwnProperty,x=Object.create(null);for(var A in _)O.call(_,A)&&(x[_[A]]=A);var I=p.exports={to:{},get:{}};function S(t,e,n){return Math.min(Math.max(e,t),n)}function E(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}I.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=I.get.hsl(t),n="hsl";break;case"hwb":e=I.get.hwb(t),n="hwb";break;default:e=I.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},I.get.rgb=function(t){if(!t)return null;var e,n,r,s=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;s[n]=parseInt(e.slice(i,i+2),16)}r&&(s[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)s[n]=parseInt(e[n]+e[n],16);r&&(s[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)s[n]=parseInt(e[n+1],0);e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:O.call(_,e[1])?((s=_[e[1]])[3]=1,s):null:null;for(n=0;n<3;n++)s[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}for(n=0;n<3;n++)s[n]=S(s[n],0,255);return s[3]=S(s[3],0,1),s},I.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,S(parseFloat(e[2]),0,100),S(parseFloat(e[3]),0,100),S(isNaN(n)?1:n,0,1)]}return null},I.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,S(parseFloat(e[2]),0,100),S(parseFloat(e[3]),0,100),S(isNaN(n)?1:n,0,1)]}return null},I.to.hex=function(){var t=M(arguments);return"#"+E(t[0])+E(t[1])+E(t[2])+(t[3]<1?E(Math.round(255*t[3])):"")},I.to.rgb=function(){var t=M(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},I.to.rgb.percent=function(){var t=M(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},I.to.hsl=function(){var t=M(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},I.to.hwb=function(){var t=M(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},I.to.keyword=function(t){return x[t.slice(0,3)]};var N={exports:{}},C=b,P={};for(var R in C)C.hasOwnProperty(R)&&(P[C[R]]=R);var k=N.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var L in k)if(k.hasOwnProperty(L)){if(!("channels"in k[L]))throw new Error("missing channels property: "+L);if(!("labels"in k[L]))throw new Error("missing channel labels property: "+L);if(k[L].labels.length!==k[L].channels)throw new Error("channel and label counts mismatch: "+L);var B=k[L].channels,U=k[L].labels;delete k[L].channels,delete k[L].labels,Object.defineProperty(k[L],"channels",{value:B}),Object.defineProperty(k[L],"labels",{value:U})}function D(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}k.rgb.hsl=function(t){var e,n,r=t[0]/255,s=t[1]/255,i=t[2]/255,o=Math.min(r,s,i),a=Math.max(r,s,i),c=a-o;return a===o?e=0:r===a?e=(s-i)/c:s===a?e=2+(i-r)/c:i===a&&(e=4+(r-s)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},k.rgb.hsv=function(t){var e,n,r,s,i,o=t[0]/255,a=t[1]/255,c=t[2]/255,h=Math.max(o,a,c),u=h-Math.min(o,a,c),l=function(t){return(h-t)/6/u+.5};return 0===u?s=i=0:(i=u/h,e=l(o),n=l(a),r=l(c),o===h?s=r-n:a===h?s=1/3+e-r:c===h&&(s=2/3+n-e),s<0?s+=1:s>1&&(s-=1)),[360*s,100*i,100*h]},k.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[k.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},k.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-s)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-s-e)/(1-e)||0),100*e]},k.rgb.keyword=function(t){var e=P[t];if(e)return e;var n,r=1/0;for(var s in C)if(C.hasOwnProperty(s)){var i=D(t,C[s]);i<r&&(r=i,n=s)}return n},k.keyword.rgb=function(t){return C[t]},k.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},k.rgb.lab=function(t){var e=k.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},k.hsl.rgb=function(t){var e,n,r,s,i,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),s=[0,0,0];for(var h=0;h<3;h++)(r=o+1/3*-(h-1))<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,s[h]=255*i;return s},k.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,s=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,s*=i<=1?i:2-i,[e,100*(0===r?2*s/(i+s):2*n/(r+n)),100*((r+n)/2)]},k.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,s=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,s){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},k.hsv.hsl=function(t){var e,n,r,s=t[0],i=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-i)*o,n=i*a,[s,100*(n=(n/=(e=(2-i)*a)<=1?e:2-e)||0),100*(r/=2)]},k.hwb.rgb=function(t){var e,n,r,s,i,o,a,c=t[0]/360,h=t[1]/100,u=t[2]/100,l=h+u;switch(l>1&&(h/=l,u/=l),r=6*c-(e=Math.floor(6*c)),0!=(1&e)&&(r=1-r),s=h+r*((n=1-u)-h),e){default:case 6:case 0:i=n,o=s,a=h;break;case 1:i=s,o=n,a=h;break;case 2:i=h,o=n,a=s;break;case 3:i=h,o=s,a=n;break;case 4:i=s,o=h,a=n;break;case 5:i=n,o=h,a=s}return[255*i,255*o,255*a]},k.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,s=t[3]/100;return[255*(1-Math.min(1,e*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s))]},k.xyz.rgb=function(t){var e,n,r,s=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*s+1.8758*i+.0415*o,r=.0557*s+-.204*i+1.057*o,e=(e=3.2406*s+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},k.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},k.lab.xyz=function(t){var e,n,r,s=t[0];e=t[1]/500+(n=(s+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},k.lab.lch=function(t){var e,n=t[0],r=t[1],s=t[2];return(e=360*Math.atan2(s,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+s*s),e]},k.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},k.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:k.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},k.hsv.ansi16=function(t){return k.rgb.ansi16(k.hsv.rgb(t),t[2])},k.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},k.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},k.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},k.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},k.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},k.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(n,r),s),o=Math.min(Math.min(n,r),s),a=i-o;return e=a<=0?0:i===n?(r-s)/a%6:i===r?2+(s-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},k.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,s=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(s=(n-.5*r)/(1-r)),[t[0],100*r,100*s]},k.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},k.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var s,i=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return s=(1-n)*r,[255*(n*i[0]+s),255*(n*i[1]+s),255*(n*i[2]+s)]},k.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},k.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},k.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},k.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},k.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},k.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},k.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},k.gray.hsl=k.gray.hsv=function(t){return[0,0,t[0]]},k.gray.hwb=function(t){return[0,100,t[0]]},k.gray.cmyk=function(t){return[0,0,0,t[0]]},k.gray.lab=function(t){return[t[0],0,0]},k.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},k.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var F=N.exports;function j(t){var e=function(){for(var t={},e=Object.keys(F),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),s=Object.keys(F[r]),i=s.length,o=0;o<i;o++){var a=s[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function V(t,e){return function(n){return e(t(n))}}function q(t,e){for(var n=[e[t].parent,t],r=F[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=V(F[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var z=N.exports,G=function(t){for(var e=j(t),n={},r=Object.keys(e),s=r.length,i=0;i<s;i++){var o=r[i];null!==e[o].parent&&(n[o]=q(o,e))}return n},H={};Object.keys(z).forEach((function(t){H[t]={},Object.defineProperty(H[t],"channels",{value:z[t].channels}),Object.defineProperty(H[t],"labels",{value:z[t].labels});var e=G(t);Object.keys(e).forEach((function(n){var r=e[n];H[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,s=0;s<r;s++)n[s]=Math.round(n[s]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),H[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var $=H,X=p.exports,J=$,K=[].slice,Z=["keyword","gray","hex"],W={};Object.keys(J).forEach((function(t){W[K.call(J[t].labels).sort().join("")]=t}));var Y={};function Q(t,e){if(!(this instanceof Q))return new Q(t,e);if(e&&e in Z&&(e=null),e&&!(e in J))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof Q)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var s=X.get(t);if(null===s)throw new Error("Unable to parse color from string: "+t);this.model=s.model,r=J[this.model].channels,this.color=s.value.slice(0,r),this.valpha="number"==typeof s.value[r]?s.value[r]:1}else if(t.length){this.model=e||"rgb",r=J[this.model].channels;var i=K.call(t,0,r);this.color=rt(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in W))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=W[a];var c=J[this.model].labels,h=[];for(n=0;n<c.length;n++)h.push(t[c[n]]);this.color=rt(h)}if(Y[this.model])for(r=J[this.model].channels,n=0;n<r;n++){var u=Y[this.model][n];u&&(this.color[n]=u(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function tt(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(Y[t]||(Y[t]=[]))[e]=n})),t=t[0],function(r){var s;return arguments.length?(n&&(r=n(r)),(s=this[t]()).color[e]=r,s):(s=this[t]().color[e],n&&(s=n(s)),s)}}function et(t){return function(e){return Math.max(0,Math.min(t,e))}}function nt(t){return Array.isArray(t)?t:[t]}function rt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}Q.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in X.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return X.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return X.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=J[this.model].channels,n=J[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new Q(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new Q(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:tt("rgb",0,et(255)),green:tt("rgb",1,et(255)),blue:tt("rgb",2,et(255)),hue:tt(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:tt("hsl",1,et(100)),lightness:tt("hsl",2,et(100)),saturationv:tt("hsv",1,et(100)),value:tt("hsv",2,et(100)),chroma:tt("hcg",1,et(100)),gray:tt("hcg",2,et(100)),white:tt("hwb",1,et(100)),wblack:tt("hwb",2,et(100)),cyan:tt("cmyk",0,et(100)),magenta:tt("cmyk",1,et(100)),yellow:tt("cmyk",2,et(100)),black:tt("cmyk",3,et(100)),x:tt("xyz",0,et(100)),y:tt("xyz",1,et(100)),z:tt("xyz",2,et(100)),l:tt("lab",0,et(100)),a:tt("lab",1),b:tt("lab",2),keyword:function(t){return arguments.length?new Q(t):J[this.model].keyword(this.color)},hex:function(t){return arguments.length?new Q(t):X.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return Q.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),s=void 0===e?.5:e,i=2*s-1,o=n.alpha()-r.alpha(),a=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-a;return Q.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*s+r.alpha()*(1-s))}},Object.keys(J).forEach((function(t){if(-1===Z.indexOf(t)){var e=J[t].channels;Q.prototype[t]=function(){if(this.model===t)return new Q(this);if(arguments.length)return new Q(arguments,t);var n="number"==typeof arguments[e]?e:this.valpha;return new Q(nt(J[this.model][t].raw(this.color)).concat(n),t)},Q[t]=function(n){return"number"==typeof n&&(n=rt(K.call(arguments),e)),new Q(n,t)}}}));var st=Q;function it(t){return null==t}function ot(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function at(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function ct(t){return"object"==typeof t&&!!t}function ht(t){return"number"==typeof t&&!isNaN(t)}function ut(t){return t*Math.PI/180}function lt(t){return t/Math.PI*180}function ft(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function dt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const mt=[1,1,1,1,2,2,3,0];function pt(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=mt[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}function bt(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function gt(t){return t.flat?t.flat(1/0):t.reduce((t,e)=>t.concat(e),[])}function yt(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function wt(t){return 0===t.indexOf("data:")}function vt(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),s=r.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=r.charCodeAt(t);return i.buffer}function Tt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}const _t={};function Mt(t,e){if(!Array.isArray(e)){const t=e;e=_t[t]=_t[t]||st(e).array().map(t=>t/255)}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Ot=Object.freeze({__proto__:null,isNil:it,extend:ot,isFunction:at,isObject:ct,isNumber:ht,toRadian:ut,toDegree:lt,getAbsoluteURL:ft,sign:dt,stringFromUTF8Array:pt,setColumn3:bt,flatArr:gt,getBatchIdArrayType:yt,isBase64:wt,base64URLToArrayBuffer:vt,pushIn:Tt,normalizeColor:Mt});function xt(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function At(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}var It="undefined"!=typeof Float32Array?Float32Array:Array;function St(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 Et(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],h=e[6],u=e[7],l=e[8],f=e[9],d=e[10],m=e[11],p=e[12],b=e[13],g=e[14],y=e[15],w=n[0],v=n[1],T=n[2],_=n[3];return t[0]=w*r+v*a+T*l+_*p,t[1]=w*s+v*c+T*f+_*b,t[2]=w*i+v*h+T*d+_*g,t[3]=w*o+v*u+T*m+_*y,w=n[4],v=n[5],T=n[6],_=n[7],t[4]=w*r+v*a+T*l+_*p,t[5]=w*s+v*c+T*f+_*b,t[6]=w*i+v*h+T*d+_*g,t[7]=w*o+v*u+T*m+_*y,w=n[8],v=n[9],T=n[10],_=n[11],t[8]=w*r+v*a+T*l+_*p,t[9]=w*s+v*c+T*f+_*b,t[10]=w*i+v*h+T*d+_*g,t[11]=w*o+v*u+T*m+_*y,w=n[12],v=n[13],T=n[14],_=n[15],t[12]=w*r+v*a+T*l+_*p,t[13]=w*s+v*c+T*f+_*b,t[14]=w*i+v*h+T*d+_*g,t[15]=w*o+v*u+T*m+_*y,t}function Nt(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}function Ct(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}function Pt(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,h=n*o,u=r*o,l=r*a,f=s*o,d=s*a,m=s*c,p=i*o,b=i*a,g=i*c;return t[0]=1-l-m,t[1]=u+g,t[2]=f-b,t[3]=0,t[4]=u-g,t[5]=1-h-m,t[6]=d+p,t[7]=0,t[8]=f+b,t[9]=d-p,t[10]=1-h-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Rt(){var t=new It(3);return It!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function kt(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function Lt(t,e,n){var r=new It(3);return r[0]=t,r[1]=e,r[2]=n,r}function Bt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Ut(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function Dt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function Ft(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function jt(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function Vt(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function qt(t,e){var n=e[0],r=e[1],s=e[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i),t}function zt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Gt(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[0],a=n[1],c=n[2];return t[0]=s*c-i*a,t[1]=i*o-r*c,t[2]=r*a-s*o,t}var Ht=Ft,$t=jt,Xt=kt;function Jt(t,e,n,r,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=s,t}function Kt(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3];return t[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,t[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,t[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,t[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,t}function Zt(){var t=new It(4);return It!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Wt(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Yt(t,e,n,r){var s=e[0],i=e[1],o=e[2],a=e[3],c=n[0],h=n[1],u=n[2],l=n[3],f=void 0,d=void 0,m=void 0,p=void 0,b=void 0;return(d=s*c+i*h+o*u+a*l)<0&&(d=-d,c=-c,h=-h,u=-u,l=-l),1-d>1e-6?(f=Math.acos(d),m=Math.sin(f),p=Math.sin((1-r)*f)/m,b=Math.sin(r*f)/m):(p=1-r,b=r),t[0]=p*s+b*c,t[1]=p*i+b*h,t[2]=p*o+b*u,t[3]=p*a+b*l,t}Rt(),function(){var t,e=(t=new It(4),It!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var Qt,te=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};Rt(),Lt(1,0,0),Lt(0,1,0),Zt(),Zt(),Qt=new It(9),It!=Float32Array&&(Qt[1]=0,Qt[2]=0,Qt[3]=0,Qt[5]=0,Qt[6]=0,Qt[7]=0),Qt[0]=1,Qt[4]=1,Qt[8]=1;
|
|
11
|
+
*/;for(var c=[],h=0;h<6;h++)c[h]=[];var u=[];function l(t,e,n){_(t);for(var r=0;r<6;r++){var s=c[r];if(u[0]=s[0]>0?e[1][0]:e[0][0],u[1]=s[1]>0?e[1][1]:e[0][1],u[2]=s[2]>0?e[1][2]:e[0][2],O(s,u)<0)return!1}return!0}var f=3,d=4,m=5,p=6,b=7,g=8,y=9,w=10,v=11;function T(t,e){var n=e,r=t,s=e,i=r[0],o=r[1],a=r[2],c=Math.abs(i*s[f]+o*s[d]+a*s[m])+Math.abs(i*s[p]+o*s[b]+a*s[g])+Math.abs(i*s[y]+o*s[w]+a*s[v]),h=O(t,n);return!(h<=-c)}function _(t){var e=t,n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],h=e[6],u=e[7],l=e[8],f=e[9],d=e[10],m=e[11],p=e[12],b=e[13],g=e[14],y=e[15];M(c[0],i-n,u-o,m-l,y-p),M(c[1],i+n,u+o,m+l,y+p),M(c[2],i+r,u+a,m+f,y+b),M(c[3],i-r,u-a,m-f,y-b),M(c[4],i-s,u-h,m-d,y-g),M(c[5],i+s,u+h,m+d,y+g)}function M(t,e,n,r,s){var i=1/Math.sqrt(e*e+n*n+r*r);return t[0]=e*i,t[1]=n*i,t[2]=r*i,t[3]=s*i,t}function O(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var x={exports:{}},I={exports:{}},S=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},E=Array.prototype.concat,C=Array.prototype.slice,N=I.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];S(s)?e=E.call(e,C.call(s)):e.push(s)}return e};N.wrap=function(t){return function(){return t(N(arguments))}};var k=I.exports,P={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},R=k,B=Object.hasOwnProperty,L=Object.create(null);for(var U in P)B.call(P,U)&&(L[P[U]]=U);var D=x.exports={to:{},get:{}};function F(t,e,n){return Math.min(Math.max(e,t),n)}function G(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}D.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=D.get.hsl(t),n="hsl";break;case"hwb":e=D.get.hwb(t),n="hwb";break;default:e=D.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},D.get.rgb=function(t){if(!t)return null;var e,n,r,s=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;s[n]=parseInt(e.slice(i,i+2),16)}r&&(s[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)s[n]=parseInt(e[n]+e[n],16);r&&(s[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)s[n]=parseInt(e[n+1],0);e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:B.call(P,e[1])?((s=P[e[1]])[3]=1,s):null:null;for(n=0;n<3;n++)s[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}for(n=0;n<3;n++)s[n]=F(s[n],0,255);return s[3]=F(s[3],0,1),s},D.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,F(parseFloat(e[2]),0,100),F(parseFloat(e[3]),0,100),F(isNaN(n)?1:n,0,1)]}return null},D.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,F(parseFloat(e[2]),0,100),F(parseFloat(e[3]),0,100),F(isNaN(n)?1:n,0,1)]}return null},D.to.hex=function(){var t=R(arguments);return"#"+G(t[0])+G(t[1])+G(t[2])+(t[3]<1?G(Math.round(255*t[3])):"")},D.to.rgb=function(){var t=R(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},D.to.rgb.percent=function(){var t=R(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},D.to.hsl=function(){var t=R(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},D.to.hwb=function(){var t=R(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},D.to.keyword=function(t){return L[t.slice(0,3)]};var j=x.exports,q={exports:{}},z={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},V={};for(var H in z)z.hasOwnProperty(H)&&(V[z[H]]=H);var $=q.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var X in $)if($.hasOwnProperty(X)){if(!("channels"in $[X]))throw new Error("missing channels property: "+X);if(!("labels"in $[X]))throw new Error("missing channel labels property: "+X);if($[X].labels.length!==$[X].channels)throw new Error("channel and label counts mismatch: "+X);var K=$[X].channels,J=$[X].labels;delete $[X].channels,delete $[X].labels,Object.defineProperty($[X],"channels",{value:K}),Object.defineProperty($[X],"labels",{value:J})}function Z(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}$.rgb.hsl=function(t){var e,n,r=t[0]/255,s=t[1]/255,i=t[2]/255,o=Math.min(r,s,i),a=Math.max(r,s,i),c=a-o;return a===o?e=0:r===a?e=(s-i)/c:s===a?e=2+(i-r)/c:i===a&&(e=4+(r-s)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},$.rgb.hsv=function(t){var e,n,r,s,i,o=t[0]/255,a=t[1]/255,c=t[2]/255,h=Math.max(o,a,c),u=h-Math.min(o,a,c),l=function(t){return(h-t)/6/u+.5};return 0===u?s=i=0:(i=u/h,e=l(o),n=l(a),r=l(c),o===h?s=r-n:a===h?s=1/3+e-r:c===h&&(s=2/3+n-e),s<0?s+=1:s>1&&(s-=1)),[360*s,100*i,100*h]},$.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[$.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},$.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-s)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-s-e)/(1-e)||0),100*e]},$.rgb.keyword=function(t){var e=V[t];if(e)return e;var n,r=1/0;for(var s in z)if(z.hasOwnProperty(s)){var i=Z(t,z[s]);i<r&&(r=i,n=s)}return n},$.keyword.rgb=function(t){return z[t]},$.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},$.rgb.lab=function(t){var e=$.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},$.hsl.rgb=function(t){var e,n,r,s,i,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),s=[0,0,0];for(var h=0;h<3;h++)(r=o+1/3*-(h-1))<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,s[h]=255*i;return s},$.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,s=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,s*=i<=1?i:2-i,[e,100*(0===r?2*s/(i+s):2*n/(r+n)),100*((r+n)/2)]},$.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,s=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,s){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},$.hsv.hsl=function(t){var e,n,r,s=t[0],i=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-i)*o,n=i*a,[s,100*(n=(n/=(e=(2-i)*a)<=1?e:2-e)||0),100*(r/=2)]},$.hwb.rgb=function(t){var e,n,r,s,i,o,a,c=t[0]/360,h=t[1]/100,u=t[2]/100,l=h+u;switch(l>1&&(h/=l,u/=l),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),s=h+r*((n=1-u)-h),e){default:case 6:case 0:i=n,o=s,a=h;break;case 1:i=s,o=n,a=h;break;case 2:i=h,o=n,a=s;break;case 3:i=h,o=s,a=n;break;case 4:i=s,o=h,a=n;break;case 5:i=n,o=h,a=s}return[255*i,255*o,255*a]},$.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,s=t[3]/100;return[255*(1-Math.min(1,e*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s))]},$.xyz.rgb=function(t){var e,n,r,s=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*s+1.8758*i+.0415*o,r=.0557*s+-.204*i+1.057*o,e=(e=3.2406*s+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},$.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},$.lab.xyz=function(t){var e,n,r,s=t[0];e=t[1]/500+(n=(s+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},$.lab.lch=function(t){var e,n=t[0],r=t[1],s=t[2];return(e=360*Math.atan2(s,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+s*s),e]},$.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},$.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:$.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},$.hsv.ansi16=function(t){return $.rgb.ansi16($.hsv.rgb(t),t[2])},$.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},$.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},$.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},$.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},$.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},$.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(n,r),s),o=Math.min(Math.min(n,r),s),a=i-o;return e=a<=0?0:i===n?(r-s)/a%6:i===r?2+(s-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},$.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,s=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(s=(n-.5*r)/(1-r)),[t[0],100*r,100*s]},$.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},$.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var s,i=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return s=(1-n)*r,[255*(n*i[0]+s),255*(n*i[1]+s),255*(n*i[2]+s)]},$.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},$.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},$.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},$.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},$.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},$.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},$.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},$.gray.hsl=$.gray.hsv=function(t){return[0,0,t[0]]},$.gray.hwb=function(t){return[0,100,t[0]]},$.gray.cmyk=function(t){return[0,0,0,t[0]]},$.gray.lab=function(t){return[t[0],0,0]},$.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},$.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var W=q.exports,Y=W;function Q(t){var e=function(){for(var t={},e=Object.keys(Y),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),s=Object.keys(Y[r]),i=s.length,o=0;o<i;o++){var a=s[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function tt(t,e){return function(n){return e(t(n))}}function et(t,e){for(var n=[e[t].parent,t],r=Y[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=tt(Y[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var nt=W,rt=function(t){for(var e=Q(t),n={},r=Object.keys(e),s=r.length,i=0;i<s;i++){var o=r[i];null!==e[o].parent&&(n[o]=et(o,e))}return n},st={};Object.keys(nt).forEach((function(t){st[t]={},Object.defineProperty(st[t],"channels",{value:nt[t].channels}),Object.defineProperty(st[t],"labels",{value:nt[t].labels});var e=rt(t);Object.keys(e).forEach((function(n){var r=e[n];st[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,s=0;s<r;s++)n[s]=Math.round(n[s]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),st[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var it=j,ot=st,at=[].slice,ct=["keyword","gray","hex"],ht={};Object.keys(ot).forEach((function(t){ht[at.call(ot[t].labels).sort().join("")]=t}));var ut={};function lt(t,e){if(!(this instanceof lt))return new lt(t,e);if(e&&e in ct&&(e=null),e&&!(e in ot))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof lt)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var s=it.get(t);if(null===s)throw new Error("Unable to parse color from string: "+t);this.model=s.model,r=ot[this.model].channels,this.color=s.value.slice(0,r),this.valpha="number"==typeof s.value[r]?s.value[r]:1}else if(t.length){this.model=e||"rgb",r=ot[this.model].channels;var i=at.call(t,0,r);this.color=mt(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ht))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ht[a];var c=ot[this.model].labels,h=[];for(n=0;n<c.length;n++)h.push(t[c[n]]);this.color=mt(h)}if(ut[this.model])for(r=ot[this.model].channels,n=0;n<r;n++){var u=ut[this.model][n];u&&(this.color[n]=u(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ft(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(ut[t]||(ut[t]=[]))[e]=n})),t=t[0],function(r){var s;return arguments.length?(n&&(r=n(r)),(s=this[t]()).color[e]=r,s):(s=this[t]().color[e],n&&(s=n(s)),s)}}function dt(t){return function(e){return Math.max(0,Math.min(t,e))}}function mt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}lt.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in it.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return it.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return it.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=ot[this.model].channels,n=ot[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new lt(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new lt(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ft("rgb",0,dt(255)),green:ft("rgb",1,dt(255)),blue:ft("rgb",2,dt(255)),hue:ft(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ft("hsl",1,dt(100)),lightness:ft("hsl",2,dt(100)),saturationv:ft("hsv",1,dt(100)),value:ft("hsv",2,dt(100)),chroma:ft("hcg",1,dt(100)),gray:ft("hcg",2,dt(100)),white:ft("hwb",1,dt(100)),wblack:ft("hwb",2,dt(100)),cyan:ft("cmyk",0,dt(100)),magenta:ft("cmyk",1,dt(100)),yellow:ft("cmyk",2,dt(100)),black:ft("cmyk",3,dt(100)),x:ft("xyz",0,dt(100)),y:ft("xyz",1,dt(100)),z:ft("xyz",2,dt(100)),l:ft("lab",0,dt(100)),a:ft("lab",1),b:ft("lab",2),keyword:function(t){return arguments.length?new lt(t):ot[this.model].keyword(this.color)},hex:function(t){return arguments.length?new lt(t):it.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return lt.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),s=void 0===e?.5:e,i=2*s-1,o=n.alpha()-r.alpha(),a=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-a;return lt.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*s+r.alpha()*(1-s))}},Object.keys(ot).forEach((function(t){if(-1===ct.indexOf(t)){var e=ot[t].channels;lt.prototype[t]=function(){if(this.model===t)return new lt(this);if(arguments.length)return new lt(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new lt((n=ot[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},lt[t]=function(n){return"number"==typeof n&&(n=mt(at.call(arguments),e)),new lt(n,t)}}}));var pt=A(lt);function bt(t){return null==t}function gt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function yt(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function wt(t){return"object"==typeof t&&!!t}function vt(t){return"number"==typeof t&&!isNaN(t)}function Tt(t){return t*Math.PI/180}function _t(t){return t/Math.PI*180}function Mt(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function Ot(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const At=[1,1,1,1,2,2,3,0];function xt(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=At[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}function It(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function St(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function Et(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function Ct(t){return 0===t.indexOf("data:")}function Nt(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),s=r.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=r.charCodeAt(t);return i.buffer}function kt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}const Pt={};function Rt(t,e){if(!Array.isArray(e)){const t=e;e=Pt[t]=Pt[t]||pt(e).array().map((t=>t/255))}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Bt=Object.freeze({__proto__:null,base64URLToArrayBuffer:Nt,extend:gt,flatArr:St,getAbsoluteURL:Mt,getBatchIdArrayType:Et,isBase64:Ct,isFunction:yt,isNil:bt,isNumber:vt,isObject:wt,normalizeColor:Rt,pushIn:kt,setColumn3:It,sign:Ot,stringFromUTF8Array:xt,toDegree:_t,toRadian:Tt});function Lt(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Ut(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}var Dt=1e-6,Ft="undefined"!=typeof Float32Array?Float32Array:Array;function Gt(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 jt(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],h=e[6],u=e[7],l=e[8],f=e[9],d=e[10],m=e[11],p=e[12],b=e[13],g=e[14],y=e[15],w=n[0],v=n[1],T=n[2],_=n[3];return t[0]=w*r+v*a+T*l+_*p,t[1]=w*s+v*c+T*f+_*b,t[2]=w*i+v*h+T*d+_*g,t[3]=w*o+v*u+T*m+_*y,w=n[4],v=n[5],T=n[6],_=n[7],t[4]=w*r+v*a+T*l+_*p,t[5]=w*s+v*c+T*f+_*b,t[6]=w*i+v*h+T*d+_*g,t[7]=w*o+v*u+T*m+_*y,w=n[8],v=n[9],T=n[10],_=n[11],t[8]=w*r+v*a+T*l+_*p,t[9]=w*s+v*c+T*f+_*b,t[10]=w*i+v*h+T*d+_*g,t[11]=w*o+v*u+T*m+_*y,w=n[12],v=n[13],T=n[14],_=n[15],t[12]=w*r+v*a+T*l+_*p,t[13]=w*s+v*c+T*f+_*b,t[14]=w*i+v*h+T*d+_*g,t[15]=w*o+v*u+T*m+_*y,t}function qt(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}function zt(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}function Vt(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,h=n*o,u=r*o,l=r*a,f=s*o,d=s*a,m=s*c,p=i*o,b=i*a,g=i*c;return t[0]=1-l-m,t[1]=u+g,t[2]=f-b,t[3]=0,t[4]=u-g,t[5]=1-h-m,t[6]=d+p,t[7]=0,t[8]=f+b,t[9]=d-p,t[10]=1-h-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ht(){var t=new Ft(3);return Ft!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function $t(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function Xt(t,e,n){var r=new Ft(3);return r[0]=t,r[1]=e,r[2]=n,r}function Kt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Jt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function Zt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function Wt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function Yt(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function Qt(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function te(t,e){var n=e[0],r=e[1],s=e[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function ee(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ne(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[0],a=n[1],c=n[2];return t[0]=s*c-i*a,t[1]=i*o-r*c,t[2]=r*a-s*o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var re=Wt,se=Yt,ie=$t;function oe(t,e,n,r,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=s,t}function ae(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3];return t[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,t[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,t[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,t[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,t}function ce(){var t=new Ft(4);return Ft!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function he(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function ue(t,e,n,r){var s,i,o,a,c,h=e[0],u=e[1],l=e[2],f=e[3],d=n[0],m=n[1],p=n[2],b=n[3];return(i=h*d+u*m+l*p+f*b)<0&&(i=-i,d=-d,m=-m,p=-p,b=-b),1-i>Dt?(s=Math.acos(i),o=Math.sin(s),a=Math.sin((1-r)*s)/o,c=Math.sin(r*s)/o):(a=1-r,c=r),t[0]=a*h+c*d,t[1]=a*u+c*m,t[2]=a*l+c*p,t[3]=a*f+c*b,t}Ht(),function(){var t,e=(t=new Ft(4),Ft!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var le,fe=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};Ht(),Xt(1,0,0),Xt(0,1,0),ce(),ce(),le=new Ft(9),Ft!=Float32Array&&(le[1]=0,le[2]=0,le[3]=0,le[5]=0,le[6]=0,le[7]=0),le[0]=1,le[4]=1,le[8]=1;
|
|
13
12
|
/*!
|
|
14
|
-
* @maptalks/gltf-loader v0.
|
|
13
|
+
* @maptalks/gltf-loader v0.98.0
|
|
15
14
|
* LICENSE : UNLICENSED
|
|
16
15
|
* (c) 2016-2024 maptalks.org
|
|
17
16
|
*/
|
|
18
|
-
let ee=0;function ne(t){return null==t}function re(t){return!ne(t)}function se(t){return!ne(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function ie(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function oe(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 ae(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function ce(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const he=[],ue=[],le=[],fe=[0,0,0],de=Wt([]),me=[1,1,1];function pe(t,e,n,r,s,i,o){const a=oe(o);if((0===s||s===r*a.BYTES_PER_ELEMENT)&&i%a.BYTES_PER_ELEMENT==0){const s=new a(e,i,n*r);return t.set(s),t}0===s&&(s=r*a.BYTES_PER_ELEMENT);const c=new Uint8Array(r*a.BYTES_PER_ELEMENT);for(let o=0;o<n;o++){let n=null;const h=new Uint8Array(e,s*o+i,r*a.BYTES_PER_ELEMENT);c.set(h),n=new a(c.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const be="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function ge(t,e,n){const r=new Uint8Array(t,e,n);return be.decode(r)}const ye={get:function(t,e={},n){e||(e={});const r=new AbortController,s=r.signal,i=ie({},e);i.signal=s,i.method||(i.method="GET"),i.referrerPolicy=i.referrerPolicy||"origin","undefined"==typeof window||i.referrer||(i.referrer=window.location.href),n&&(t=n(t));const o=fetch(t,i).then(t=>{const n=this.s(t,e.responseType);return n.message?n:n.then(n=>"arraybuffer"===e.responseType?{data:n,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:n).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 o.xhr=r,o},s:(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={},n)=>(e||(e={}),e.responseType="arraybuffer",ye.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?ye.jsonp(t):((e=e||{}).responseType="json",ye.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+ee++;t.match(/\?/)?t+="&callback="+e:t+="?callback="+e;let n=document.createElement("script");return n.type="text/javascript",n.src=t,new Promise(t=>{window[e]=function(r){document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[e],t(r)},document.getElementsByTagName("head")[0].appendChild(n)})}};class we{constructor(t,e,n,r,s){this.i=t,this.decoders=e,this.o=n,this.images={},this.h={},this.u=r||{},this.m=s}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.p(e,r);return this.getImageByBuffer(s,n)}if(this.h[t.id])return this.h[t.id].then(()=>{const r=this.buffers[t.id],s=this.p(e,r);return this.getImageByBuffer(s,n)});if(ae(t.uri)){const r=this.buffers[t.id]=ce(t.uri),s=this.p(e,r);return this.getImageByBuffer(s,n)}let r;const s=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.h[t.id]=ye.getArrayBuffer(r,this.u,this.m).then(r=>{const s=this.buffers[t.id]=r.data,i=this.p(e,s);return this.getImageByBuffer(i,n)})}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;return n[e.mimeType]?n[e.mimeType](t,{supportedFormats:this.o}):"image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType?(console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null)):this.v(e.id,t)}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.h[t.id]?this.h[t.id].then(()=>this.images[t.id]):this.h[t.id]=this.v(t.id,e)}v(t,e){return new Promise((n,r)=>{let s=e;this.m&&(s=this.m(e)),this.i(s,this.u,(s,i)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=i,n(this.images[t]))})})}}const ve=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],Te=[];class _e{constructor(t,e,n,r,s){this.rootPath=t,this.gltf=e,this.T=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this._(),this.u=r,this.m=s}M(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this.O(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const s=n.bufferViews[r.bufferView];return this.A(s).then(n=>{const{buffer:s,byteOffset:i}=n;return this.accessors[r.id]=this.O(t,e,s,i)})}A(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(ae(e.uri)){const t=this.buffers[e.id]=ce(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const n=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=ye.getArrayBuffer(t,this.u,!n&&this.m).then(r=>(n&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=r.data,byteOffset:0}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}O(t,e,n,r=0){const s=this.gltf,i=s.accessors[e],o=void 0!==i.bufferView?s.bufferViews[i.bufferView]:{},a=(o.byteOffset||0)+r,c=this.I(i.type),h=oe(i.componentType),u=o.byteStride||0,l={array:void 0,name:t,accessorName:e,byteLength:i.count*c*h.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:c,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(l.min=i.min),i.max&&(l.max=i.max),n)if(this.T)l.byteStride=u,l.byteOffset=a+(i.byteOffset||0),!u||u===c*h.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(l.array=this.S(n,i.count,c,a+(i.byteOffset||0),h),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(n,a,o.byteLength);else if(i.interleaved){l.byteStride=0,l.byteOffset=0;const t=new h(i.count*c);if(l.array=pe(t,n,i.count,c,u,a+(i.byteOffset||0),i.componentType),l.extensions&&l.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(l.array.length),{decodeMatrix:e}=l.extensions.WEB3D_quantized_attributes;for(let n=0;n<l.array.length;n+=c){Te[0]=l.array[n],Te[1]=l.array[n+1],Te[2]=l.array[n+2],Te[3]=1;const r=Kt(Te,Te,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}l.componentType=5126,l.array=t}}else l.byteStride=0,l.array=this.S(n,i.count,c,a+(i.byteOffset||0),h),l.byteOffset=l.array.byteOffset;else{l.array=new h(i.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}_(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}S(t,e,n,r,s){return r%s.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*s.BYTES_PER_ELEMENT),r=0),new s(t,r,n*e)}I(t){const e=ve.indexOf(t);return ve[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map(t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this.A(e).then(r=>{const{buffer:s,byteOffset:i}=r,o=ge(s,i+(e.byteOffset||0),n);return t.content=o,t})}if(t.uri){if(ae(t.uri)){const e=ce(t.uri),n=ge(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return ye.get(e,this.u,this.m).then(e=>(t.content=e,t))}}return Promise.resolve(t)});return Promise.all(n).then(()=>t)}}class Me extends we{constructor(t,e,n,r,s,i,o,a){super(r,s,i,o,a),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new _e(t,e,n,o,a)}iterate(t,e){const n=this.gltf[e];if(!n)return;let r=0;for(const e in n)t(e,n[e],r++)}createNode(t){const e={};if(re(t.name)&&(e.name=t.name),re(t.children)&&(e.children=t.children),re(t.jointName)&&(e.jointName=t.jointName),re(t.matrix)&&(e.matrix=t.matrix),re(t.rotation)&&(e.rotation=t.rotation),re(t.scale)&&(e.scale=t.scale),re(t.translation)&&(e.translation=t.translation),re(t.extras)&&(e.extras=t.extras),re(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 n=Nt(he,e.translation||fe),r=Pt(ue,e.rotation||de),s=Ct(le,e.scale||me);return Et(s,r,s),Et(t,n,s)}return St(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}N(t){const e={};for(const n in t){const r=t[n];let s,i;r.instanceTechnique&&r.instanceTechnique.values?(s=r.instanceTechnique,i=s.values.diffuse):(s=r,i=s.values.tex||s.values.diffuseTex||s.values.diffuse);const o={baseColorTexture:{index:i}};r.name&&(o.name=r.name),r.extensions&&(o.extensions=r.extensions),r.extras&&(o.extras=r.extras),e[n]=o}return e}C(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 n=this.gltf.bufferViews[e.bufferView],r=(n.byteOffset||0)+this.glbBuffer.byteOffset,s=n.byteLength,i=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,s);return this.getImageByBuffer(i,t)}return this.requestExternalImage(t)}P(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.C(n).then(t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}})}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const s=this.gltf.textures[r];if(!s)return null;const i=this.gltf.samplers[s.sampler];return{format:s.format||6408,internalFormat:s.internalFormat||6408,type:s.type||5121,sampler:i,source:this.gltf.images[s.source]}}getMaterial(){return null}getAnimations(){return null}}class Oe extends we{constructor(t,e,n,r,s,i,o,a){super(r,s,i,o,a),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new _e(t,e,n,o,a)}iterate(t,e){const n=this.gltf[e];if(n)for(let e=0;e<n.length;e++)t(e,n[e],e)}createNode(t){const e={};return ie(e,t),!re(t.weights)&&this.gltf.meshes&&re(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}P(t){const e=this.gltf.textures[t];if(!e)return null;let n=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(n=e.extensions.EXT_texture_webp.source),!re(n))return null;const r=this.gltf.images[n];return this.C(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}};ie(n,e);const s=re(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||9729,n.sampler.minFilter=s.minFilter||9729,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),t.format&&(n.format=t.format),n})}C(t){if(!re(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],n=this.gltf.buffers[e.buffer];if(n.uri)return this.requestImageFromBufferURI(n,e,t);if(this.glbBuffer)return this.R(e,t)}return null}R(t,e){const n=this.p(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}p(t,e,n){n=n||0;const r=(t.byteOffset||0)+n,s=t.byteLength;return new Uint8Array(e,r,s)}k(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);return n.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)))}getAnimations(t){const e=[];return t.forEach(t=>{e.push(this.getSamplers(t.samplers))}),Promise.all(e).then(e=>{for(let n=0;n<e.length;n++)t[n].samplers=e[n];return t})}getSamplers(t){const e=[];for(let n=0;n<t.length;n++)(re(t[n].input)||re(t[n].output))&&(e.push(this.accessor.M("input",t[n].input)),e.push(this.accessor.M("output",t[n].output)));return Promise.all(e).then(e=>{for(let n=0;n<e.length/2;n++)t[n].input=e[2*n],t[n].output=e[2*n+1],t[n].interpolation||(t[n].interpolation="LINEAR");return t})}}const xe="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class Ae{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),s=r.getUint32(4,!0);if(1===s)return Ae.readV1(r,e);if(2===s)return Ae.readV2(t,e);throw new Error("Unsupported glb version : "+s)}static readV1(t,e){const n=t.getUint32(8,!0),r=t.getUint32(12,!0);if(n!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const s=Ie(t.buffer,20+e,r);return{json:JSON.parse(s),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,s;const i=new DataView(t,e+12);let o=0;for(;o<i.byteLength;){const a=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,1313821514===c)n=Ie(t,e+12+o,a);else if(5130562===c){s=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:s,buffer:t,byteLength:r}}}}function Ie(t,e,n){if(xe){const r=new Uint8Array(t,e,n);return xe.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=Se[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}(new Uint8Array(t,e,n))}const Se=[1,1,1,1,2,2,3,0],Ee=[0,0,0],Ne=[0,0,0,1],Ce=[1,1,1],Pe={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},Re={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},ke={L(t,e,n,r,s,i,o,a){const c=re(t)?e.animations:[e.animations[0]],h={};for(let e=0;e<c.length;e++){const u=c[e],l=u.name||e;if(re(t)&&l!==t)continue;const f=u.channelsMap[n];if(f)for(let t=0;t<f.length;t++){const e=f[t];"translation"===e.target.path?(this.B(s,u.samplers[e.sampler],r,1),h.translation=Bt(Ee,s)):"rotation"===e.target.path?(this.U(i,u.samplers[e.sampler],r,1),h.rotation=te(Ne,i)):"scale"===e.target.path?(this.B(o,u.samplers[e.sampler],r,1),h.scale=Bt(Ce,o)):"weights"===e.target.path&&a&&(this.B(a,u.samplers[e.sampler],r,a.length),h.weights=a)}}return h},B(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.D(Re,e,n,1*r);s&&(t=function(t,e,n,r){for(let s=0;s<t.length;s++)t[s]=e[s]+r*(n[s]-e[s]);return t}(t,s.PREVIOUS,s.NEXT,s.INTERPOLATION));break}case"STEP":{const s=this.D(Re,e,n,1*r);s&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.D(Re,e,n,3*r);s&&(t=this.F(t,s,e.input.array,3*r));break}}return t},U(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.D(Re,e,n,1);r&&Yt(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.D(Re,e,n,1);r&&(t=Jt(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.D(Re,e,n,3);if(r){for(let t=0;t<r.PREVIOUS.length;t++)r.PREVIOUS[t]=Math.acos(r.PREVIOUS[t]),r.NEXT[t]=Math.acos(r.NEXT[t]);t=this.F(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},j(t,e){const n=t.length;let r,s,i,o=0,a=n-1,c=Math.floor((o+a)/2);for(;o<=n-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const n=t[c];return r=c,s=c+1,i=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:s,interpolation:i}}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},D(t,e,n,r){const s=e.input.array,i=e.output.array,o=e.output.itemSize;(n<s[0]||n>s[s.length-1])&&(n=Math.max(s[0],Math.min(s[s.length-1],n))),n===s[s.length-1]&&(n=s[0]);const a=this.j(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:h,interpolation:u}=a;t.PREINDEX=c,t.NEXTINDEX=h,t.INTERPOLATION=u;const l=o*r;return t.PREVIOUS=i.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=i.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},F(t,e,n,r){const s=e.INTERPOLATION,i=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-i)*e.PREVIOUS[2*r+n],h=e.NEXT[3+n],u=(o-i)*e.NEXT[n],l=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*a+(Math.pow(s,3)-2*Math.pow(s,2)+s)*c+(2*-Math.pow(s,3)+3*Math.pow(s,2))*h+(Math.pow(s,3)-Math.pow(s,2))*u;t[n]=l}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;return Ut(Ee,...Pe.TRANSLATION),Jt(Ne,...Pe.ROTATION),Ut(Ce,...Pe.SCALE),this.L(r,t,e,n,Ee,Ne,Ce,s)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach((e,n)=>{let r=-1/0,s=1/0;const i=e.channels;for(let t=0;t<i.length;t++){const n=i[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<s&&(s=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:s}}),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?re(e)?n[e]:n[Object.keys(n)[0]]:null}};let Le=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(hs){}t&&"undefined"!=typeof createImageBitmap&&(Le=!0)}const Be="undefined"==typeof document?null:document.createElement("canvas");class Ue{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),this.u=this.options.fetchOptions||{},e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=Ae.read(e.buffer,e.byteOffset,e.byteLength);this.V(t,n,r)}else this.V(t,e);this.q=new _e(this.rootPath,this.gltf,this.glbBuffer,this.u,this.options.urlModifier),this.G()}G(){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.q.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then(e=>(t.KHR_techniques_webgl=e,t)):Promise.resolve(t)}load(t){t=t||{};const e=this.$(t),n=this.X(),r=this.J(),s=this.H();return Promise.all([e,n,r,s]).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 n=e[t];n.channelsMap={};for(let t=0;t<n.channels.length;t++){const e=n.channels[t];n.channelsMap[e.target.node]||(n.channelsMap[e.target.node]=[]),n.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:n}=this.gltf;for(let n=0;n<e.length;n++)e[n].uri&&e[n].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[n].uri});for(let e=0;e<n.length;e++)n[e].uri&&n[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:n[e].uri})}return t}static getAnimationClip(t,e,n,r){return ke.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return ke.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return oe(t)}static readInterleavedArray(t,e,n,r,s,i,o){return pe(t,e,n,r,s,i,o)}V(t,e,n){this.gltf=e,this.glbBuffer=n,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=Le?ze.bind(this):this.options.requestImage||De,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Oe(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.u,this.options.urlModifier),this.adapter.iterate((t,e,n)=>{e.id="buffer_"+n},"buffers"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors")):(this.adapter=new Me(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.u,this.options.urlModifier),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"))}K(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||se(t.children[0])))return t;const r=t.children.map(t=>{const n=e[t];return n.nodeIndex=t,this.K(n,e)});t.children=r}var n;return t}$(t){return this.Z(t).then(t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.K(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate((r,s,i)=>{const o={};s.name&&(o.name=s.name),s.nodes&&(o.nodes=s.nodes.map(e=>t[e])),this.gltf.scene===r&&(n=i),e.push(o)},"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.N(this.gltf.materials);r.materials=t}return delete this.gltf.buffers,r.json=this.gltf,r})}Z(t){return this.W(t).then(()=>{const t=this.nodes={};return this.adapter.iterate((e,n)=>{const r=this.adapter.createNode(n,this.meshes,this.skins);t[e]=r},"nodes"),t})}Y(){this.skins=[];const t=[];return this.adapter.iterate((e,n,r)=>{t.push(this.tt(n).then(t=>{t.index=r,this.skins.push(t)}))},"skins"),t}tt(t){const e=t.inverseBindMatrices;return this.adapter.accessor.M("inverseBindMatrices",e).then(e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t))}X(){const t=this.gltf.animations;return re(t)?this.adapter.getAnimations(t):null}W(t){this.meshes={};let e=[];return this.adapter.iterate((n,r,s)=>{e.push(this.et(r,t).then(t=>{t.index=s,this.meshes[n]=t}))},"meshes"),e=e.concat(this.Y()),Promise.all(e)}et(t,e){const n=t.primitives.map(t=>this.nt(t,e)).filter(t=>!!t);return Promise.all(n).then(e=>{const n={};return ie(n,t),n.primitives=e,n})}J(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.P(n));return Promise.all(e).then(e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t].image.array;if(e[t]&&n){let t;t=n instanceof ImageBitmap?n:n.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const n={},r=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(n[r[t]]=e[t]);return n}return e})}nt(t,e){let n;const r=[],s=t.extensions;if(re(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const s=this.adapter.accessor.M(`morphTargets_${t}_${e}`,n[t]);s&&r.push(s)}}if(s&&s.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:i,attributes:o}=s.KHR_draco_mesh_compression,a=this.gltf.bufferViews[i],c=this.q.A(a).then(n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:i}=a;const c=a.byteLength;i||(i=0);const h=new DataView(r,s+i,c),u={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(h,u).then(t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e})});r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor.M(t,e[t]);n&&r.push(n)}if(re(t.indices)){const e=this.adapter.accessor.M("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then(e=>{if(s&&s.KHR_draco_mesh_compression){const n=t.targets?t.targets.length:0;e[n]=e[n].concat(e.slice(0,n)),e=e[n]}let n,r;const i={attributes:e.reduce((t,e)=>{if("indices"===e.name)n=e;else if(e.name.indexOf("morphTargets_")>-1)r=r||{},r[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],{itemSize:r,array:s}=e,i=s.length/r;for(let e=0;e<i;e++)for(let i=0;i<r;i++){const o=e*r+i;s[o]<t[i]&&(t[i]=s[o]),s[o]>n[i]&&(n[i]=s[o])}if(e.quantization){const r=e.quantization,s=r.range/(1<<r.quantizationBits),i=r.minValues;Vt(t,t,s),Dt(t,t,i),Vt(n,n,s),Dt(n,n,i)}e.min=t,e.max=n}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 n&&(i.indices=n),r&&(i.morphTargets=r),i.mode=re(t.mode)?t.mode:4,re(t.extras)&&(i.extras=t.extras),i})}}function De(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Be)return void n(new Error("There is no canvas to draw image!"));Be.width=r.width,Be.height=r.height;const t=Be.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),s={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,s)},r.onerror=function(t){n(t)},r.src=t}const Fe=[],je=[];let Ve,qe;function ze(t,e,n){Ve||(Ve=new OffscreenCanvas(2,2),qe=Ve.getContext("2d",{willReadFrequently:!0}));let r=null;if(se(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),Fe.push([t,e,n,this]),function t(){if(!Fe.length||je.length>10)return;const e=Fe.shift(),[n,r,s,i]=e;je.push(e),fetch(n,r).then(t=>t.arrayBuffer()).then(t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)}).then(Ge.bind(i)).then(n=>{s.call(i,null,n);const r=je.indexOf(e);je.splice(r,1),t()}).catch(n=>{console.warn(n),s.call(i,n);const r=je.indexOf(e);je.splice(r,1),t()})}();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(Ge.bind(this)).then(t=>{n(null,t)}).catch(t=>{console.warn(t),n(t)})}}function Ge(t){let{width:e,height:n}=t;He(e)||(e=$e(e)),He(n)||(n=$e(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),Ve.width=e,Ve.height=n,qe.drawImage(t,0,0,e,n),t.close();const s=qe.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(s.data)}}function He(t){return 0==(t&t-1)&&0!==t}function $e(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const Xe="undefined"==typeof document?null:document.createElement("canvas");class Je extends s.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const s={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(s,r,n)}abortTileLoading(t,e,n){const r={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(r,null,n)}addLayer(t,e,n){const r={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(r,null,n)}removeLayer(t,e){const n={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(n,null,e)}requestImage({url:t},e){const n=new Image;n.onload=()=>{if(!this.isActive())return;if(!Xe)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(Ke(t.width)&&Ke(t.height))return t;let e=t.width,n=t.height;Ke(e)||(e=Ze(e));Ke(n)||(n=Ze(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const s=t.src,i=s.lastIndexOf("/")+1,o=s.substring(i);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);Xe.width=t.width,Xe.height=t.height;const r=Xe.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const s=r.getImageData(0,0,t.width,t.height),i={width:t.width,height:t.height,data:new Uint8Array(s.data)};e(null,i,[i.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function Ke(t){return 0==(t&t-1)&&0!==t}function Ze(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function We(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];sn(r[n],s,t,e)}}}const Ye=[],Qe=[],tn=[],en=[0,0,0],nn=Wt([]),rn=[1,1,1];function sn(t,e,n,r){const s=e.slice(0);if(t.matrix)s.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=Nt(Ye,t.translation||en),n=Pt(Qe,t.rotation||nn),r=Ct(tn,t.scale||rn);Et(r,n,r);const i=Et([],e,r);s.push(i)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)sn(t.children[e],s,n,r);if(void 0!==t.mesh){const e=t.mesh,i=n.meshes[e];if(i){const t=s.slice(0),o=i.primitives;for(let s=0,i=o.length;s<i;s++){const i=o[s];i&&(i.matrices=t,r(i,e,s,n))}}}}function on(t,e,n){let{byteOffset:r,byteStride:s}=e;const{componentType:i,itemSize:o}=e,a=e.array.buffer,c=i?Ue.getTypedArrayCtor(i):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,s=s||0,!s||s===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*c.BYTES_PER_ELEMENT);const h=new Uint8Array(a,s*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(h),t}function an(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}var cn="#include <gl2_vert>\n\nconst 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#ifdef PICKING_MODE\n\n #include <fbo_picking_vert>\n\n#endif\n\n#include <draco_decode_vert>\n\nvoid main() {\n\n #ifdef HAS_POSITION\n\n vec3 localPos = decode_getPosition(POSITION);\n\n #endif\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n\n\n #ifdef PICKING_MODE\n\n fbo_picking_setData(gl_Position.w, true);\n\n #else\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_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 #endif\n\n\n\n\n\n\n\n\n\n}\n\n";const hn=new Array(3),un=new Array(3),ln=[40680631590769,40680631590769,40408299984661.445];function fn(t,e,n,r){const s=ln,i=Math.cos(n);hn[0]=i*Math.cos(e),hn[1]=i*Math.sin(e),hn[2]=Math.sin(n),_n(hn,hn),jt(un,s,hn);const o=Math.sqrt(zt(hn,un));var a,c,h;return c=un,h=o,(a=un)[0]=c[0]/h,a[1]=c[1]/h,a[2]=c[2]/h,Vt(hn,hn,r),Dt(t,un,hn)}const dn=[1/6378137,1/6378137,1/6356752.314245179],mn=[1/40680631590769,1/40680631590769,1/40408299984661.445],pn=new Array(3),bn=new Array(3),gn=new Array(3);function yn(t,e){const n=mn,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],h=n[1],u=n[2],l=i*i*c*c,f=o*o*h*h,d=a*a*u*u,m=l+f+d,p=Math.sqrt(1/m),b=Vt(wn,e,p);if(m<s)return isFinite(p)?b:void 0;const g=r[0],y=r[1],w=r[2],v=vn;v[0]=b[0]*g*2,v[1]=b[1]*y*2,v[2]=b[2]*w*2;let T,_,M,O,x,A,I,S,E,N,C,P=(1-p)*Tn(e)/(.5*Tn(v)),R=0;do{P-=R,M=1/(1+P*g),O=1/(1+P*y),x=1/(1+P*w),A=M*M,I=O*O,S=x*x,E=A*M,N=I*O,C=S*x,T=l*A+f*I+d*S-1,_=l*E*g+f*N*y+d*C*w;R=T/(-2*_)}while(Math.abs(T)>1e-12);return t[0]=i*M,t[1]=o*O,t[2]=a*x,t}(pn,e,dn,n,.1);let s=$t(bn,r,n);s=_n(s,s);const i=Ht(gn,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=dt(zt(i,e))*Tn(i);return t[0]=lt(o),t[1]=lt(a),t[2]=c,t}const wn=new Array(3),vn=new Array(3);function Tn(t){return kt(t)}function _n(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;return i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t}function Mn(t,e){return jt(e,t,mn),qt(e,e)}function On(t,e){const n=t[0],r=t[1],s=Math.cos(r),i=s*Math.cos(n),o=s*Math.sin(n),a=Math.sin(r);return e.x=i,e.y=o,e.z=a,qt(e,e)}var xn=Object.freeze({__proto__:null,radianToCartesian3:fn,cartesian3ToDegree:yn,normalizeCartesian:_n,geodeticSurfaceNormal:Mn,geodeticSurfaceNormalCartographic:On});function An(t,e,n,r){n=n||0,r=r||n;const s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function In(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const Sn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function En(t,e,n){const r=new Uint8Array(t,e,n);return Sn?JSON.parse(Sn.decode(r)):JSON.parse(pt(r))}function Nn(t,e,n){const r=new Uint8Array(t,e,n);return Sn?JSON.parse(Sn.decode(r)):JSON.parse(pt(r))}function Cn(t,e,n){return{offset:e,byteLength:n}}function Pn(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=Dn(i||"UNSIGNED_SHORT"),h=Bn(o);return{byteStride:0,byteOffset:s+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+s,r*h)}}function Rn(t,e,n,r){const s=Pn(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}function kn(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a}=Dn(i||"UNSIGNED_SHORT"),c=Bn(o),h=new a(e,s,n*c);return 1===c?h[r]:h.subarray(r*c,r*c+c)}const Ln={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Bn(t){return t?Ln[t]:1}const Un={"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 Dn(t){return Un[t]}function Fn(t){for(const e in Un)if(t===Un[e].ctor)return Un[e].type;throw new Error("unrecognized ctor:"+t)}function jn(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function Vn(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,h={},u={},l=null;r>0&&(h=En(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(u=Nn(a,e,i),e+=i);const f=Cn(0,e,o);return l=a.slice(f.offset,f.offset+f.byteLength),n.push(l),{featureTable:h,featureTableBin:c,batchTable:u,batchTableBin:l}}const qn={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"}},zn={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Gn={},Hn={east:[],north:[],up:[],west:[],south:[],down:[]};let $n=[],Xn=[],Jn=[];const Kn=[0,0,0];function Zn(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=t[15],n}const Wn=function(t,e){const n=qn[t][e];let r;const s=t+e;return Gn[s]?r=Gn[s]:(r=function(r,s,i){if(function(t,e){var n=t[0],r=t[1],s=t[2],i=e[0],o=e[1],a=e[2];return Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}(r,Kn))Bt($n,zn[t]),Bt(Xn,zn[e]),Bt(Jn,zn[n]);else if(An(r[0],0,1e-14)&&An(r[1],0,1e-14)){const s=dt(r[2]);Bt($n,zn[t]),"east"!==t&&"west"!==t&&Vt($n,$n,s),Bt(Xn,zn[e]),"east"!==e&&"west"!==e&&Vt(Xn,Xn,s),Bt(Jn,zn[n]),"east"!==n&&"west"!==n&&Vt(Jn,Jn,s)}else{Mn(r,Hn.up);const s=Hn.up,i=Hn.east;i[0]=-r[1],i[1]=r[0],i[2]=0,qt(Hn.east,i),Gt(Hn.north,s,i),Vt(Hn.down,Hn.up,-1),Vt(Hn.west,Hn.east,-1),Vt(Hn.south,Hn.north,-1),$n=Hn[t],Xn=Hn[e],Jn=Hn[n]}return i[0]=$n[0],i[1]=$n[1],i[2]=$n[2],i[3]=0,i[4]=Xn[0],i[5]=Xn[1],i[6]=Xn[2],i[7]=0,i[8]=Jn[0],i[9]=Jn[1],i[10]=Jn[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i},Gn[s]=r),r}("east","north"),Yn=[],Qn=[],tr=[],er=[],nr=[],rr=[],sr=[],ir={x:0,y:0},or={x:0,y:0},ar=Math.PI/180;let cr;const hr={width:100,height:10};function ur(){if(!cr){const{width:t,height:e}=hr;OffscreenCanvas?cr=new OffscreenCanvas(t,e):(cr=document.createElement("canvas"),cr.width=t,cr.height=e)}return cr}class lr{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,s=t.length;e<s;e++){const s=t[e][0];n=Math.min(s,n),r=Math.max(s,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},hr,e),this.rt()}getImageData(){return this.imgData}rt(){const t=ur(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const s=r.createLinearGradient(0,0,t.width,0),{colors:i,valueOffset:o}=this;for(let t=0,e=i.length;t<e;t++){const[e,n]=i[t],r=(e-this.min)/o;s.addColorStop(r,n)}r.fillStyle=s,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var fr;function dr(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function mr(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function pr(t,e){for(var n=void 0!==t.base?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:function t(e,n,r,s,i,o){return"function"==typeof i?function(){var a=i.apply(void 0,arguments),c=o.apply(void 0,arguments);return t(e,n,r,s,a,c)}:i.length?function(t,e,n,r,s,i){var o=[];for(let a=0;a<s.length;a++)o[a]=wr(t,e,n,r,s[a],i[a]);return o}(e,n,r,s,i,o):wr(e,n,r,s,i,o)}(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(fr=new Map);const br={width:100,height:1};function gr(t,e){const n=t.stops;if(n&&n.length>1){let t;if(fr){const e=JSON.stringify(n);if(!fr.has(e)){const t=new lr(n,br);fr.set(e,t)}t=fr.get(e)}else t=new lr(n,br);const[r,s,i,o]=t.getColor(e);return[r/255,s/255,i/255,o/255]}return n&&1===n.length?n[0][1]:null}function yr(t,e){return function(t,e,n){return void 0!==t?t:void 0!==e?e:void 0!==n?n:null}(e,t.default)}function wr(t,e,n,r,s,i){var o,a=r-n,c=t-n;return s*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+i*o}function vr(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type)}function Tr(t){return function t(e,n){if(!vr(e))return function(){return e};e=JSON.parse(JSON.stringify(e));let r=!0,s=!0;const i=e.stops;if(i)for(let e=0;e<i.length;e++)if(vr(i[e][1])){const o=t(i[e][1],n);r=r&&o.isZoomConstant,s=s&&o.isFeatureConstant,i[e]=[i[e][0],o]}const o=function t(e,n){var r,s,i;if(vr(e)){var o,a=e.stops&&"object"==typeof e.stops[0][0],c=a||void 0!==e.property,h=a||!c,u=e.type||n||"exponential";if("exponential"===u)o=pr;else if("interval"===u)o=mr;else if("categorical"===u)o=dr;else if("identity"===u)o=yr;else{if("color-interpolate"!==u)throw new Error('Unknown function type "'+u+'"');o=gr}if(a){var l={},f=[];for(let t=0;t<e.stops.length;t++){var d=e.stops[t];void 0===l[d[0].zoom]&&(l[d[0].zoom]={zoom:d[0].zoom,type:e.type,property:e.property,default:e.default,stops:[]}),l[d[0].zoom].stops.push([d[0].value,d[1]])}for(let e in l)f.push([l[e].zoom,t(l[e])]);r=function(t,n){const r=pr({stops:f,base:e.base},t)(t,n);return"function"==typeof r?r(t,n):r},s=!1,i=!1}else h?(r=function(t){const n=o(e,t);return"function"==typeof n?n(t):n},s=!0,i=!1):(r=function(t,n){const r=o(e,n?n[e.property]:null);return"function"==typeof r?r(t,n):r},s=!1,i=!0)}else r=function(){return e},s=!0,i=!0;return r.isZoomConstant=i,r.isFeatureConstant=s,r}(e,n);return o.isZoomConstant=r&&o.isZoomConstant,o.isFeatureConstant=s&&o.isFeatureConstant,o}(t,"exponential")}const{getTextureMagFilter:_r,getTextureMinFilter:Mr,getTextureWrap:Or,getMaterialType:xr,getMaterialFormat:Ar,getPrimitive:Ir,getUniqueREGLBuffer:Sr}=n.reshader.REGLHelper,Er=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Nr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:Cr,logoutIBLResOnCanvas:Pr,getIBLResOnCanvas:Rr,getPBRUniforms:kr}=n.reshader.pbr.PBRUtils,Lr={factor:0,units:0},Br=[1,1,1,1],Ur=[0,0,0],Dr={specularStrength:0,materialShininess:1},Fr=[1,1,1],jr=n.mat4.identity([]),Vr=[0,0],qr=t=>t.material instanceof n.reshader.PhongMaterial,zr=t=>t.material instanceof n.reshader.pbr.StandardMaterial,Gr=[],Hr=new s.Coordinate(0,0),$r=new s.Point(0,0),Xr=new s.Point(0,0),Jr=new s.Point(0,0),Kr=[],Zr=[],Wr=[],Yr=[],Qr=[],ts={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},es=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],ns=function(t,e){const n=2*Math.PI/t,r=[],s=[];for(let s=0;s<=t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=t,r[3*s+1]=i,r[3*s+2]=o}for(let s=t;s<=2*t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=o,r[3*s+1]=t,r[3*s+2]=i}for(let s=2*t;s<=3*t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=t,r[3*s+1]=o,r[3*s+2]=i}const i=r.length/3-1;for(let e=0;e<i;e++)e!==t-1&&e!==2*t-1&&(s[2*e]=e,s[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),s.push(i+1,i+2),s.push(i+1,i+3),s.push(i+1,i+4),{vertices:r,indices:s}}
|
|
17
|
+
let de=0;function me(t){return null==t}function pe(t){return!me(t)}function be(t){return!me(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function ge(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function ye(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 we(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function ve(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const Te=[],_e=[],Me=[],Oe=[0,0,0],Ae=he([]),xe=[1,1,1];function Ie(t,e,n,r,s,i,o){const a=ye(o),c=a.BYTES_PER_ELEMENT;if((0===s||s===r*c)&&i%c==0){const s=new a(e,i,n*r);return t.set(s),t}0===s&&(s=r*c);const h=new Uint8Array(r*c);for(let o=0;o<n;o++){let n=null;const u=new Uint8Array(e,s*o+i,r*c);h.set(u),n=new a(h.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const Se="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ee(t,e,n){const r=new Uint8Array(t,e,n);return Se.decode(r)}const Ce={get:function(t,e={},n){e||(e={});const r=new AbortController,s=r.signal,i=ge({},e);i.signal=s,i.method||(i.method="GET"),i.referrerPolicy=i.referrerPolicy||"origin","undefined"==typeof window||i.referrer||(i.referrer=window.location.href),n&&(t=n(t));const o=fetch(t,i).then((t=>{const n=this.i(t,e.responseType);return n.message?n:n.then((n=>"arraybuffer"===e.responseType?{data:n,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:n)).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 o.xhr=r,o},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={},n)=>(e||(e={}),e.responseType="arraybuffer",Ce.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?Ce.jsonp(t):((e=e||{}).responseType="json",Ce.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+de++;t.match(/\?/)?t+="&callback="+e:t+="?callback="+e;let n=document.createElement("script");return n.type="text/javascript",n.src=t,new Promise((t=>{window[e]=function(r){document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[e],t(r)},document.getElementsByTagName("head")[0].appendChild(n)}))}};class Ne{constructor(t,e,n,r,s){this.o=t,this.decoders=e,this.h=n,this.images={},this.u={},this.m=r||{},this.p=s}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.v(e,r);return this.getImageByBuffer(s,n)}if(this.u[t.id])return this.u[t.id].then((()=>{const r=this.buffers[t.id],s=this.v(e,r);return this.getImageByBuffer(s,n)}));if(we(t.uri)){const r=this.buffers[t.id]=ve(t.uri),s=this.v(e,r);return this.getImageByBuffer(s,n)}let r;const s=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.u[t.id]=Ce.getArrayBuffer(r,this.m,this.p).then((r=>{const s=this.buffers[t.id]=r.data,i=this.v(e,s);return this.getImageByBuffer(i,n)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;return n[e.mimeType]?n[e.mimeType](t,{supportedFormats:this.h}):"image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType?(console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null)):this.T(e.id,t)}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(t.id,e)}T(t,e){return new Promise(((n,r)=>{let s=e;this.p&&(s=this.p(e)),this.o(s,this.m,((s,i)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=i,n(this.images[t]))}))}))}}const ke=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],Pe=[];class Re{constructor(t,e,n,r,s){this.rootPath=t,this.gltf=e,this._=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.M(),this.m=r,this.p=s}O(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this.A(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const s=n.bufferViews[r.bufferView];return this.I(s).then((n=>{const{buffer:s,byteOffset:i}=n;return this.accessors[r.id]=this.A(t,e,s,i)}))}I(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(we(e.uri)){const t=this.buffers[e.id]=ve(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const n=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=Ce.getArrayBuffer(t,this.m,!n&&this.p).then((r=>(n&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=r.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}A(t,e,n,r=0){const s=this.gltf,i=s.accessors[e],o=void 0!==i.bufferView?s.bufferViews[i.bufferView]:{},a=(o.byteOffset||0)+r,c=this.S(i.type),h=ye(i.componentType),u=o.byteStride||0,l={array:void 0,name:t,accessorName:e,byteLength:i.count*c*h.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:c,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(l.min=i.min),i.max&&(l.max=i.max),n)if(this._)l.byteStride=u,l.byteOffset=a+(i.byteOffset||0),!u||u===c*h.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(l.array=this.C(n,i.count,c,a+(i.byteOffset||0),h),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(n,a,o.byteLength);else if(i.interleaved){l.byteStride=0,l.byteOffset=0;const t=new h(i.count*c);if(l.array=Ie(t,n,i.count,c,u,a+(i.byteOffset||0),i.componentType),l.extensions&&l.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(l.array.length),{decodeMatrix:e}=l.extensions.WEB3D_quantized_attributes;for(let n=0;n<l.array.length;n+=c){Pe[0]=l.array[n],Pe[1]=l.array[n+1],Pe[2]=l.array[n+2],Pe[3]=1;const r=ae(Pe,Pe,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}l.componentType=5126,l.array=t}}else l.byteStride=0,l.array=this.C(n,i.count,c,a+(i.byteOffset||0),h),l.byteOffset=l.array.byteOffset;else{l.array=new h(i.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}M(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}C(t,e,n,r,s){return r%s.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*s.BYTES_PER_ELEMENT),r=0),new s(t,r,n*e)}S(t){const e=ke.indexOf(t);return ke[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this.I(e).then((r=>{const{buffer:s,byteOffset:i}=r,o=Ee(s,i+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(we(t.uri)){const e=ve(t.uri),n=Ee(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return Ce.get(e,this.m,this.p).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class Be extends Ne{constructor(t,e,n,r,s,i,o,a){super(r,s,i,o,a),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new Re(t,e,n,o,a)}iterate(t,e){const n=this.gltf[e];if(!n)return;let r=0;for(const e in n)t(e,n[e],r++)}createNode(t){const e={};if(pe(t.name)&&(e.name=t.name),pe(t.children)&&(e.children=t.children),pe(t.jointName)&&(e.jointName=t.jointName),pe(t.matrix)&&(e.matrix=t.matrix),pe(t.rotation)&&(e.rotation=t.rotation),pe(t.scale)&&(e.scale=t.scale),pe(t.translation)&&(e.translation=t.translation),pe(t.extras)&&(e.extras=t.extras),pe(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 n=qt(Te,e.translation||Oe),r=Vt(_e,e.rotation||Ae),s=zt(Me,e.scale||xe);return jt(s,r,s),jt(t,n,s)}return Gt(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}N(t){const e={};for(const n in t){const r=t[n];let s,i;r.instanceTechnique&&r.instanceTechnique.values?(s=r.instanceTechnique,i=s.values.diffuse):(s=r,i=s.values.tex||s.values.diffuseTex||s.values.diffuse);const o={baseColorTexture:{index:i}};r.name&&(o.name=r.name),r.extensions&&(o.extensions=r.extensions),r.extras&&(o.extras=r.extras),e[n]=o}return e}k(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 n=this.gltf.bufferViews[e.bufferView],r=(n.byteOffset||0)+this.glbBuffer.byteOffset,s=n.byteLength,i=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,s);return this.getImageByBuffer(i,t)}return this.requestExternalImage(t)}P(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.k(n).then((t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const s=this.gltf.textures[r];if(!s)return null;const i=this.gltf.samplers[s.sampler];return{format:s.format||6408,internalFormat:s.internalFormat||6408,type:s.type||5121,sampler:i,source:this.gltf.images[s.source]}}getMaterial(){return null}getAnimations(){return null}}const Le=9729;class Ue extends Ne{constructor(t,e,n,r,s,i,o,a){super(r,s,i,o,a),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new Re(t,e,n,o,a)}iterate(t,e){const n=this.gltf[e];if(n)for(let e=0;e<n.length;e++)t(e,n[e],e)}createNode(t){const e={};return ge(e,t),!pe(t.weights)&&this.gltf.meshes&&pe(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}P(t){const e=this.gltf.textures[t];if(!e)return null;let n=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(n=e.extensions.EXT_texture_webp.source),!pe(n))return null;const r=this.gltf.images[n];return this.k(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}};ge(n,e);const s=pe(e.sampler)?this.gltf.samplers[e.sampler]:void 0;if(s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||Le,n.sampler.minFilter=s.minFilter||Le,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),!n.mipmap&&n.sampler.minFilter!==Le&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:Le}return t.format&&(n.format=t.format),n}))}k(t){if(!pe(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],n=this.gltf.buffers[e.buffer];if(n.uri)return this.requestImageFromBufferURI(n,e,t);if(this.glbBuffer)return this.R(e,t)}return null}R(t,e){const n=this.v(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}v(t,e,n){n=n||0;const r=(t.byteOffset||0)+n,s=t.byteLength;return new Uint8Array(e,r,s)}B(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);n.join("");const r="data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)));return r}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let n=0;n<e.length;n++)t[n].samplers=e[n];return t}))}getSamplers(t){const e=[];for(let n=0;n<t.length;n++)(pe(t[n].input)||pe(t[n].output))&&(e.push(this.accessor.O("input",t[n].input)),e.push(this.accessor.O("output",t[n].output)));return Promise.all(e).then((e=>{for(let n=0;n<e.length/2;n++)t[n].input=e[2*n],t[n].output=e[2*n+1],t[n].interpolation||(t[n].interpolation="LINEAR");return t}))}}const De="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class Fe{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),s=r.getUint32(4,!0);if(1===s)return Fe.readV1(r,e);if(2===s)return Fe.readV2(t,e);throw new Error("Unsupported glb version : "+s)}static readV1(t,e){const n=t.getUint32(8,!0),r=t.getUint32(12,!0);if(n!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const s=Ge(t.buffer,20+e,r);return{json:JSON.parse(s),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,s;const i=new DataView(t,e+12);let o=0;for(;o<i.byteLength;){const a=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,1313821514===c)n=Ge(t,e+12+o,a);else if(5130562===c){s=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:s,buffer:t,byteLength:r}}}}function Ge(t,e,n){if(De){const r=new Uint8Array(t,e,n);return De.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=je[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}(new Uint8Array(t,e,n))}const je=[1,1,1,1,2,2,3,0],qe=[0,0,0],ze=[0,0,0,1],Ve=[1,1,1],He={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},$e={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Xe={L(t,e,n,r,s,i,o,a){const c=pe(t)?e.animations:[e.animations[0]],h={};for(let e=0;e<c.length;e++){const u=c[e],l=u.name||e;if(pe(t)&&l!==t)continue;const f=u.channelsMap[n];if(f)for(let t=0;t<f.length;t++){const e=f[t];"translation"===e.target.path?(this.U(s,u.samplers[e.sampler],r,1),h.translation=Kt(qe,s)):"rotation"===e.target.path?(this.D(i,u.samplers[e.sampler],r,1),h.rotation=fe(ze,i)):"scale"===e.target.path?(this.U(o,u.samplers[e.sampler],r,1),h.scale=Kt(Ve,o)):"weights"===e.target.path&&a&&(this.U(a,u.samplers[e.sampler],r,a.length),h.weights=a)}}return h},U(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.F($e,e,n,1*r);s&&(t=function(t,e,n,r){for(let s=0;s<t.length;s++)t[s]=e[s]+r*(n[s]-e[s]);return t}(t,s.PREVIOUS,s.NEXT,s.INTERPOLATION));break}case"STEP":{const s=this.F($e,e,n,1*r);s&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.F($e,e,n,3*r);s&&(t=this.G(t,s,e.input.array,3*r));break}}return t},D(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.F($e,e,n,1);r&&ue(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.F($e,e,n,1);r&&(t=oe(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.F($e,e,n,3);if(r){for(let t=0;t<r.PREVIOUS.length;t++)r.PREVIOUS[t]=Math.acos(r.PREVIOUS[t]),r.NEXT[t]=Math.acos(r.NEXT[t]);t=this.G(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},j(t,e){const n=t.length;let r,s,i,o=0,a=n-1,c=Math.floor((o+a)/2);for(;o<=n-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const n=t[c];return r=c,s=c+1,i=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:s,interpolation:i}}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},F(t,e,n,r){const s=e.input.array,i=e.output.array,o=e.output.itemSize;(n<s[0]||n>s[s.length-1])&&(n=Math.max(s[0],Math.min(s[s.length-1],n))),n===s[s.length-1]&&(n=s[0]);const a=this.j(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:h,interpolation:u}=a;t.PREINDEX=c,t.NEXTINDEX=h,t.INTERPOLATION=u;const l=o*r;return t.PREVIOUS=i.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=i.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},G(t,e,n,r){const s=e.INTERPOLATION,i=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-i)*e.PREVIOUS[2*r+n],h=e.NEXT[3+n],u=(o-i)*e.NEXT[n],l=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*a+(Math.pow(s,3)-2*Math.pow(s,2)+s)*c+(2*-Math.pow(s,3)+3*Math.pow(s,2))*h+(Math.pow(s,3)-Math.pow(s,2))*u;t[n]=l}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;return Jt(qe,...He.TRANSLATION),oe(ze,...He.ROTATION),Jt(Ve,...He.SCALE),this.L(r,t,e,n,qe,ze,Ve,s)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,n)=>{let r=-1/0,s=1/0;const i=e.channels;for(let t=0;t<i.length;t++){const n=i[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<s&&(s=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:s}})),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?pe(e)?n[e]:n[Object.keys(n)[0]]:null}};let Ke=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Fs){}t&&"undefined"!=typeof createImageBitmap&&(Ke=!0)}const Je="undefined"==typeof document?null:document.createElement("canvas");class Ze{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),this.m=this.options.fetchOptions||{},e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=Fe.read(e.buffer,e.byteOffset,e.byteLength);this.q(t,n,r)}else this.q(t,e);this.V=new Re(this.rootPath,this.gltf,this.glbBuffer,this.m,this.options.urlModifier),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["image/ktx2"])throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded");if(t.indexOf("EXT_meshopt_compression")>=0)throw new Error("EXT_meshopt_compression extension is not supported yet.")}}$(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.V.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.X(t),n=this.K(),r=this.J(),s=this.$();return Promise.all([e,n,r,s]).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 n=e[t];n.channelsMap={};for(let t=0;t<n.channels.length;t++){const e=n.channels[t];n.channelsMap[e.target.node]||(n.channelsMap[e.target.node]=[]),n.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:n}=this.gltf;for(let n=0;n<e.length;n++)e[n].uri&&e[n].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[n].uri});for(let e=0;e<n.length;e++)n[e].uri&&n[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:n[e].uri})}return t}static getAnimationClip(t,e,n,r){return Xe.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return Xe.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return ye(t)}static readInterleavedArray(t,e,n,r,s,i,o){return Ie(t,e,n,r,s,i,o)}q(t,e,n){this.gltf=e,this.glbBuffer=n,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=Ke?rn.bind(this):this.options.requestImage||We,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Ue(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.m,this.options.urlModifier),this.adapter.iterate(((t,e,n)=>{e.id="buffer_"+n}),"buffers"),this.adapter.iterate(((t,e,n)=>{e.id="image_"+n}),"images"),this.adapter.iterate(((t,e,n)=>{e.id="accessor_"+n}),"accessors")):(this.adapter=new Be(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.m,this.options.urlModifier),this.adapter.iterate(((t,e,n)=>{e.id="accessor_"+n}),"accessors"),this.adapter.iterate(((t,e,n)=>{e.id="image_"+n}),"images"))}Z(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||be(t.children[0])))return t;const r=t.children.map((t=>{const n=e[t];return n.nodeIndex=t,this.Z(n,e)}));t.children=r}var n;return t}X(t){return this.W(t).then((t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.Z(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((r,s,i)=>{const o={};s.name&&(o.name=s.name),s.nodes&&(o.nodes=s.nodes.map((e=>t[e]))),this.gltf.scene===r&&(n=i),e.push(o)}),"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.N(this.gltf.materials);r.materials=t}return delete this.gltf.buffers,r.json=this.gltf,r}))}W(t){return this.Y(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,n)=>{const r=this.adapter.createNode(n,this.meshes,this.skins);t[e]=r}),"nodes"),t}))}tt(){this.skins=[];const t=[];return this.adapter.iterate(((e,n,r)=>{t.push(this.et(n).then((t=>{t.index=r,this.skins.push(t)})))}),"skins"),t}et(t){const e=t.inverseBindMatrices;return this.adapter.accessor.O("inverseBindMatrices",e).then((e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t)))}K(){const t=this.gltf.animations;return pe(t)?this.adapter.getAnimations(t):null}Y(t){this.meshes={};let e=[];return this.adapter.iterate(((n,r,s)=>{e.push(this.nt(r,t).then((t=>{t.index=s,this.meshes[n]=t})))}),"meshes"),e=e.concat(this.tt()),Promise.all(e)}nt(t,e){const n=t.primitives.map((t=>this.rt(t,e))).filter((t=>!!t));return Promise.all(n).then((e=>{const n={};return ge(n,t),n.primitives=e,n}))}J(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.P(n));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image.array;if(n){let t;t=n instanceof ImageBitmap?n:n.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const n={},r=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(n[r[t]]=e[t]);return n}return e}))}rt(t,e){let n;const r=[],s=t.extensions;if(pe(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const s=this.adapter.accessor.O(`morphTargets_${t}_${e}`,n[t]);s&&r.push(s)}}if(s&&s.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:i,attributes:o}=s.KHR_draco_mesh_compression,a=this.gltf.bufferViews[i],c=this.V.I(a).then((n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:i}=a;const c=a.byteLength;i||(i=0);const h=new DataView(r,s+i,c),u={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(h,u).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor.O(t,e[t]);n&&r.push(n)}if(pe(t.indices)){const e=this.adapter.accessor.O("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then((e=>{if(s&&s.KHR_draco_mesh_compression){const n=t.targets?t.targets.length:0;e[n]=e[n].concat(e.slice(0,n)),e=e[n]}let n,r;const i={attributes:e.reduce(((t,e)=>{if("indices"===e.name)n=e;else if(e.name.indexOf("morphTargets_")>-1)r=r||{},r[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],{itemSize:r,array:s}=e,i=s.length/r;for(let e=0;e<i;e++)for(let i=0;i<r;i++){const o=e*r+i;s[o]<t[i]&&(t[i]=s[o]),s[o]>n[i]&&(n[i]=s[o])}if(e.quantization){const r=e.quantization,s=r.range/(1<<r.quantizationBits),i=r.minValues;Qt(t,t,s),Zt(t,t,i),Qt(n,n,s),Zt(n,n,i)}e.min=t,e.max=n}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 n&&(i.indices=n),r&&(i.morphTargets=r),i.mode=pe(t.mode)?t.mode:4,pe(t.extras)&&(i.extras=t.extras),i}))}}function We(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Je)return void n(new Error("There is no canvas to draw image!"));Je.width=r.width,Je.height=r.height;const t=Je.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),s={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,s)},r.onerror=function(t){n(t)},r.src=t}const Ye=[],Qe=[],tn=10;let en,nn;function rn(t,e,n){en||(en=new OffscreenCanvas(2,2),nn=en.getContext("2d",{willReadFrequently:!0}));let r=null;if(be(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),Ye.push([t,e,n,this]),sn();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(on.bind(this)).then((t=>{n(null,t)})).catch((t=>{console.warn(t),n(t)}))}}function sn(){if(!Ye.length||Qe.length>tn)return;const t=Ye.shift(),[e,n,r,s]=t;Qe.push(t),fetch(e,n).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then(on.bind(s)).then((e=>{r.call(s,null,e);const n=Qe.indexOf(t);Qe.splice(n,1),sn()})).catch((e=>{console.warn(e),r.call(s,e);const n=Qe.indexOf(t);Qe.splice(n,1),sn()}))}function on(t){let{width:e,height:n}=t;an(e)||(e=cn(e)),an(n)||(n=cn(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),en.width=e,en.height=n,nn.drawImage(t,0,0,e,n),t.close();const s=nn.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(s.data)}}function an(t){return!(t&t-1)&&0!==t}function cn(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const hn="undefined"==typeof document?null:document.createElement("canvas");class un extends s.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const s={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(s,r,n)}abortTileLoading(t,e,n){const r={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(r,null,n)}addLayer(t,e,n){const r={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(r,null,n)}removeLayer(t,e){const n={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(n,null,e)}requestImage({url:t},e){const n=new Image;n.onload=()=>{if(!this.isActive())return;if(!hn)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(ln(t.width)&&ln(t.height))return t;let e=t.width,n=t.height;ln(e)||(e=fn(e));ln(n)||(n=fn(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const s=t.src,i=s.lastIndexOf("/")+1,o=s.substring(i);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);hn.width=t.width,hn.height=t.height;const r=hn.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const s=r.getImageData(0,0,t.width,t.height),i={width:t.width,height:t.height,data:new Uint8Array(s.data)};e(null,i,[i.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function ln(t){return!(t&t-1)&&0!==t}function fn(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function dn(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];vn(r[n],s,t,e)}}}const mn=[],pn=[],bn=[],gn=[0,0,0],yn=he([]),wn=[1,1,1];function vn(t,e,n,r){const s=e.slice(0);if(t.matrix)s.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=qt(mn,t.translation||gn),n=Vt(pn,t.rotation||yn),r=zt(bn,t.scale||wn);jt(r,n,r);const i=jt([],e,r);s.push(i)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)vn(t.children[e],s,n,r);if(void 0!==t.mesh){const e=t.mesh,i=n.meshes[e];if(i){const t=s.slice(0),o=i.primitives;for(let s=0,i=o.length;s<i;s++){const i=o[s];i&&(i.matrices=t,r(i,e,s,n))}}}}function Tn(t,e,n){let{byteOffset:r,byteStride:s}=e;const{componentType:i,itemSize:o}=e,a=e.array.buffer,c=i?Ze.getTypedArrayCtor(i):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,s=s||0,!s||s===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*c.BYTES_PER_ELEMENT);const h=new Uint8Array(a,s*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(h),t}function _n(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}var Mn="#include <gl2_vert>\n\nconst 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#ifdef PICKING_MODE\n\n #include <fbo_picking_vert>\n\n#endif\n\n#include <draco_decode_vert>\n\nvoid main() {\n\n #ifdef HAS_POSITION\n\n vec3 localPos = decode_getPosition(POSITION);\n\n #endif\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n\n\n #ifdef PICKING_MODE\n\n fbo_picking_setData(gl_Position.w, true);\n\n #else\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_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 #endif\n\n\n\n\n\n\n\n\n\n}\n\n";const On=new Array(3),An=new Array(3),xn=[40680631590769,40680631590769,40408299984661.445];function In(t,e,n,r){const s=xn,i=Math.cos(n);On[0]=i*Math.cos(e),On[1]=i*Math.sin(e),On[2]=Math.sin(n),Dn(On,On),Yt(An,s,On);const o=Math.sqrt(ee(On,An));var a,c,h;return c=An,h=o,(a=An)[0]=c[0]/h,a[1]=c[1]/h,a[2]=c[2]/h,Qt(On,On,r),Zt(t,An,On)}const Sn=[1/6378137,1/6378137,1/6356752.314245179],En=[1/40680631590769,1/40680631590769,1/40408299984661.445],Cn=new Array(3),Nn=new Array(3),kn=new Array(3);function Pn(t,e){const n=En,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],h=n[1],u=n[2],l=i*i*c*c,f=o*o*h*h,d=a*a*u*u,m=l+f+d,p=Math.sqrt(1/m),b=Qt(Rn,e,p);if(m<s)return isFinite(p)?b:void 0;const g=r[0],y=r[1],w=r[2],v=Bn;v[0]=b[0]*g*2,v[1]=b[1]*y*2,v[2]=b[2]*w*2;let T,_,M,O,A,x,I,S,E,C,N,k=(1-p)*Un(e)/(.5*Un(v)),P=0;do{k-=P,M=1/(1+k*g),O=1/(1+k*y),A=1/(1+k*w),x=M*M,I=O*O,S=A*A,E=x*M,C=I*O,N=S*A,T=l*x+f*I+d*S-1,_=l*E*g+f*C*y+d*N*w;P=T/(-2*_)}while(Math.abs(T)>Ln);return t[0]=i*M,t[1]=o*O,t[2]=a*A,t}(Cn,e,Sn,n,.1);let s=se(Nn,r,n);s=Dn(s,s);const i=re(kn,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=Ot(ee(i,e))*Un(i);return t[0]=_t(o),t[1]=_t(a),t[2]=c,t}const Rn=new Array(3),Bn=new Array(3),Ln=1e-12;function Un(t){return $t(t)}function Dn(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;return i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t}function Fn(t,e){return Yt(e,t,En),te(e,e)}function Gn(t,e){const n=t[0],r=t[1],s=Math.cos(r),i=s*Math.cos(n),o=s*Math.sin(n),a=Math.sin(r);return e.x=i,e.y=o,e.z=a,te(e,e)}var jn=Object.freeze({__proto__:null,cartesian3ToDegree:Pn,geodeticSurfaceNormal:Fn,geodeticSurfaceNormalCartographic:Gn,normalizeCartesian:Dn,radianToCartesian3:In});function qn(t,e,n,r){n=n||0,r=r||n;const s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function zn(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const Vn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Hn(t,e,n){const r=new Uint8Array(t,e,n);return Vn?JSON.parse(Vn.decode(r)):JSON.parse(xt(r))}function $n(t,e,n){const r=new Uint8Array(t,e,n);return Vn?JSON.parse(Vn.decode(r)):JSON.parse(xt(r))}function Xn(t,e,n){return{offset:e,byteLength:n}}function Kn(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=tr(i||"UNSIGNED_SHORT"),h=Yn(o);return{byteStride:0,byteOffset:s+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+s,r*h)}}function Jn(t,e,n,r){const s=Kn(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}function Zn(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a}=tr(i||"UNSIGNED_SHORT"),c=Yn(o),h=new a(e,s,n*c);return 1===c?h[r]:h.subarray(r*c,r*c+c)}const Wn={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Yn(t){return t?Wn[t]:1}const Qn={"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 tr(t){return Qn[t]}function er(t){for(const e in Qn)if(t===Qn[e].ctor)return Qn[e].type;throw new Error("unrecognized ctor:"+t)}function nr(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function rr(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,h={},u={},l=null;r>0&&(h=Hn(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(u=$n(a,e,i),e+=i);const f=Xn(0,e,o);return l=a.slice(f.offset,f.offset+f.byteLength),n.push(l),{featureTable:h,featureTableBin:c,batchTable:u,batchTableBin:l}}const sr={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"}},ir={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},or={},ar={east:[],north:[],up:[],west:[],south:[],down:[]};let cr=[],hr=[],ur=[];const lr=[0,0,0];function fr(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=t[15],n}const dr=function(t,e){const n=sr[t][e];let r;const s=t+e;return or[s]?r=or[s]:(r=function(r,s,i){if(function(t,e){var n=t[0],r=t[1],s=t[2],i=e[0],o=e[1],a=e[2];return Math.abs(n-i)<=Dt*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-o)<=Dt*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-a)<=Dt*Math.max(1,Math.abs(s),Math.abs(a))}(r,lr))Kt(cr,ir[t]),Kt(hr,ir[e]),Kt(ur,ir[n]);else if(qn(r[0],0,1e-14)&&qn(r[1],0,1e-14)){const s=Ot(r[2]);Kt(cr,ir[t]),Kt(hr,ir[e]),Qt(hr,hr,s),Kt(ur,ir[n]),Qt(ur,ur,s)}else{Fn(r,ar.up);const s=ar.up,i=ar.east;i[0]=-r[1],i[1]=r[0],i[2]=0,te(ar.east,i),ne(ar.north,s,i),Qt(ar.down,ar.up,-1),Qt(ar.west,ar.east,-1),Qt(ar.south,ar.north,-1),cr=ar[t],hr=ar[e],ur=ar[n]}return i[0]=cr[0],i[1]=cr[1],i[2]=cr[2],i[3]=0,i[4]=hr[0],i[5]=hr[1],i[6]=hr[2],i[7]=0,i[8]=ur[0],i[9]=ur[1],i[10]=ur[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i},or[s]=r),r}("east","north"),mr=[],pr=[],br=[],gr=[],yr=[],wr=[],vr=[],Tr={x:0,y:0},_r={x:0,y:0},Mr=Math.PI/180;let Or;const Ar={width:100,height:10};function xr(){if(!Or){const{width:t,height:e}=Ar;OffscreenCanvas?Or=new OffscreenCanvas(t,e):(Or=document.createElement("canvas"),Or.width=t,Or.height=e)}return Or}class Ir{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,s=t.length;e<s;e++){const s=t[e][0];n=Math.min(s,n),r=Math.max(s,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},Ar,e),this.st()}getImageData(){return this.imgData}st(){const t=xr(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const s=r.createLinearGradient(0,0,t.width,0),{colors:i,valueOffset:o}=this;for(let t=0,e=i.length;t<e;t++){const[e,n]=i[t],r=(e-this.min)/o;s.addColorStop(r,n)}r.fillStyle=s,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var Sr;function Er(t,e){var n,r,s;if(Dr(t)){var i,o=t.stops&&"object"==typeof t.stops[0][0],a=o||void 0!==t.property,c=o||!a,h=t.type||e||"exponential";if("exponential"===h)i=kr;else if("interval"===h)i=Nr;else if("categorical"===h)i=Cr;else if("identity"===h)i=Br;else{if("color-interpolate"!==h)throw new Error('Unknown function type "'+h+'"');i=Rr}if(o){var u={},l=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===u[f[0].zoom]&&(u[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),u[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in u)l.push([u[t].zoom,Er(u[t])]);n=function(e,n){const r=kr({stops:l,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,s=!1}else c?(n=function(e){const n=i(t,e);return"function"==typeof n?n(e):n},r=!0,s=!1):(n=function(e,n){const r=i(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,s=!0)}else n=function(){return t},r=!0,s=!0;return n.isZoomConstant=s,n.isFeatureConstant=r,n}function Cr(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function Nr(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function kr(t,e){for(var n=void 0!==t.base?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:Lr(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(Sr=new Map);const Pr={width:100,height:1};function Rr(t,e){const n=t.stops;if(n&&n.length>1){let t;if(Sr){const e=JSON.stringify(n);if(!Sr.has(e)){const t=new Ir(n,Pr);Sr.set(e,t)}t=Sr.get(e)}else t=new Ir(n,Pr);const[r,s,i,o]=t.getColor(e);return[r/255,s/255,i/255,o/255]}return n&&1===n.length?n[0][1]:null}function Br(t,e){return function(t,e,n){return void 0!==t?t:void 0!==e?e:null}(e,t.default)}function Lr(t,e,n,r,s,i){return"function"==typeof s?function(){var o=s.apply(void 0,arguments),a=i.apply(void 0,arguments);return Lr(t,e,n,r,o,a)}:s.length?function(t,e,n,r,s,i){var o=[];for(let a=0;a<s.length;a++)o[a]=Ur(t,e,n,r,s[a],i[a]);return o}(t,e,n,r,s,i):Ur(t,e,n,r,s,i)}function Ur(t,e,n,r,s,i){var o,a=r-n,c=t-n;return s*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+i*o}function Dr(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type)}function Fr(t){return Gr(t,"exponential")}function Gr(t,e){if(!Dr(t))return function(){return t};let n=!0,r=!0;const s=(t=JSON.parse(JSON.stringify(t))).stops;if(s)for(let t=0;t<s.length;t++)if(Dr(s[t][1])){const i=Gr(s[t][1],e);n=n&&i.isZoomConstant,r=r&&i.isFeatureConstant,s[t]=[s[t][0],i]}const i=Er(t,e);return i.isZoomConstant=n&&i.isZoomConstant,i.isFeatureConstant=r&&i.isFeatureConstant,i}const{getTextureMagFilter:jr,getTextureMinFilter:qr,getTextureWrap:zr,getMaterialType:Vr,getMaterialFormat:Hr,getPrimitive:$r,getUniqueREGLBuffer:Xr}=n.reshader.REGLHelper,Kr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Jr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:Zr,logoutIBLResOnCanvas:Wr,getIBLResOnCanvas:Yr,getPBRUniforms:Qr}=n.reshader.pbr.PBRUtils,ts={factor:0,units:0},es=[1,1,1,1],ns=[0,0,0],rs={specularStrength:0,materialShininess:1},ss=[1,1,1],is=n.mat4.identity([]),os=[0,0,0],as=[0,0],cs=[],hs=t=>t.material instanceof n.reshader.PhongMaterial,us=t=>t.material instanceof n.reshader.pbr.StandardMaterial,ls=[],fs=new s.Coordinate(0,0),ds=new s.Point(0,0),ms=new s.Point(0,0),ps=new s.Point(0,0),bs=[],gs=[],ys=[],ws=[],vs=[],Ts=[],_s=[],Ms=[],Os=[],As=[],xs=[],Is=[],Ss=[],Es=[],Cs={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},Ns=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],ks=function(t,e){const n=2*Math.PI/t,r=[],s=[];for(let s=0;s<=t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=t,r[3*s+1]=i,r[3*s+2]=o}for(let s=t;s<=2*t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=o,r[3*s+1]=t,r[3*s+2]=i}for(let s=2*t;s<=3*t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=t,r[3*s+1]=o,r[3*s+2]=i}const i=r.length/3-1;for(let e=0;e<i;e++)e!==t-1&&e!==2*t-1&&(s[2*e]=e,s[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),s.push(i+1,i+2),s.push(i+1,i+3),s.push(i+1,i+4),{vertices:r,indices:s}}
|
|
19
18
|
/*!
|
|
20
|
-
* @maptalks/gl v0.
|
|
19
|
+
* @maptalks/gl v0.98.0
|
|
21
20
|
* LICENSE : UNLICENSED
|
|
22
21
|
* (c) 2016-2024 maptalks.com
|
|
23
|
-
*/(100,1),rs=[0,0,0,1],ss=[1,1,1];class is{constructor(t,e){this.st=e,this.it=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.ot=new s.SpatialReference,this.ct=t,this.ht=new n.reshader.Renderer(t),this.ut={},this.lt={},this.ft={},this.dt={},this.pt={},this.bt={},this.gt=new n.reshader.Scene,this.yt=new n.reshader.Scene,this.wt=new n.reshader.Scene,this.vt=new n.reshader.Scene,this.Tt=new n.reshader.ResourceLoader(t.texture(2)),this._t=this.Mt.bind(this),this.Ot(),this.xt=new n.reshader.KHRTechniquesWebglManager(this.ct,this.At(),this.Tt);const r=this.getMap();r.altitudeToPoint&&(this.It=r.altitudeToPoint(100,r.getGLRes())/100)}getI3DMMeshes(){return this.dt}getPNTSMeshes(){return this.ft}getB3DMMeshes(){return this.lt}getPaintedMeshes(){return this.St}getMap(){return this.st.getMap()}paint(t,e,r,s){const i=s&&s.renderTarget,o=s&&s.sceneFilter,a=this.getMap();if(!t.length||!a)return null;const c=this.Et(),h=a.projViewMatrix,l=[],f=[],d=[],m=[],p=[],b=this.Nt(t);for(let r=0,i=t.length;r<i;r++){const i=t[r].data.node;let o=this.Ct(i);if(!o)continue;const a=this.st.Pt(i.Rt),c=a.debugNodes,g=a.heightOffset||0,y=a.coordOffset||Vr;this.pt[i.id]&&(o=this.pt[i.id],o=gt(o));let w=a.polygonOffset||Lr;at(w)&&(w=w()),Array.isArray(o)||(l[0]=o,o=l);for(let t=0,r=o.length;t<r;t++){const r=o[t].properties.magic;if(o[t].properties.heightOffset===g&&o[t].properties.coordOffset[0]===y[0]&&o[t].properties.coordOffset[1]===y[1]||(this.kt(o[t]),o[t].Lt=n.mat4.copy([],o[t].localTransform)),o[t].Bt=i,"b3dm"===r){if(o[t].getBoundingBox&&!u(h,o[t].getBoundingBox()))continue;const{batchIdData:e,batchIdMap:r}=o[t].geometry.properties;if(e&&r){const e=o[t].properties.node.Rt;this.Ut&&this.Ut[e]?n.HighlightUtil.highlightMesh(this.ct,o[t],this.Ut[e],this.Dt,r):this.Ut&&this.Ut[e]||n.HighlightUtil.highlightMesh(this.ct,o[t],null,this.Dt,r),n.HighlightUtil.showOnly(this.ct,o[t],this.Ft&&this.Ft[e],this.jt,r)}if(c&&c.length&&c.indexOf(o[t].Bt.id)<0)continue;s&&s.bloom&&o[t].properties.hlBloomMesh&&(o[t].properties.hlBloomMesh.properties.depthFunc="always",o[t].properties.hlBloomMesh.properties.polygonOffset=w,d.push(o[t].properties.hlBloomMesh)),d.push(o[t])}else"pnts"===r?m.push(o[t]):"i3dm"===r&&p.push(o[t]);o[t].properties.isLeaf=!!e[i.id],o[t].properties.level=b.get(i.Vt),o[t].properties.polygonOffset=w,e[i.id]||f.push(o[t]),this.qt(o[t]),this.zt(o[t],i)}}let g=0;const y=this.xt.getExcludeFilter();g+=this.Gt(this.Ht,c,[o,qr,y],i,f,d,p),g+=this.Gt(this.$t,c,[o,zr,y],i,f,d,p),this.xt.forEachShader((t,e,n)=>{const r=this.Et(n);g+=this.Gt(t,r,[o,e],i,f,d,p)}),this.yt.setMeshes(m);const w=this.Xt();return g+=this.ht.render(this.Jt,w,this.yt,i&&i.fbo),this.St={pntsMeshes:m,i3dmMeshes:p,b3dmMeshes:d},this.vt.setMeshes(r),this.ht.render(this.Kt,c,this.vt,i&&i.fbo),g}Gt(t,e,n,r,s,i,o){t.filter=n.filter(t=>!!t),e.debug=!1,e.debug=!1;let a=0;return this.gt.setMeshes(i),a+=this.ht.render(t,e,this.gt,r&&r.fbo),this.wt.setMeshes(o),a+=this.ht.render(t,e,this.wt,r&&r.fbo),a}Zt(t,e){return e.Bt.Wt-t.Bt.Wt}deleteTile(t){const e=t.node;e.Yt&&(e.Yt.geometry.dispose(),e.Yt.dispose(),delete e.Yt);const n=e.id;this.Qt(n)}Qt(t){const e=this.lt[t]||this.ft[t]||this.dt[t]||this.pt[t]||this.ut[t];this.pt[t]?this.te(t):e&&(this.ee(e),delete this.lt[t],delete this.ft[t],delete this.dt[t],delete this.ut[t])}te(t){let e=this.pt[t];e=gt(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.Qt(n)}delete this.pt[t]}ee(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.ee(t[e]);else{n.HighlightUtil.showOnly(this.ct,t),n.HighlightUtil.highlightMesh(this.ct,t);const e=t.geometry.properties.url;if(e){const n=this.bt[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.bt[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.st;Pr(t.getRenderer().canvas,t.getMap());for(const t in this.pt)this.te(t);this.pt={};for(const t in this.lt)this.Qt(t);this.lt={};for(const t in this.ft)this.Qt(t);this.ft={};for(const t in this.dt)this.Qt(t);this.dt={};for(const t in this.ut)this.Qt(t);this.ut={},this.Ht&&(this.Ht.dispose(),delete this.Ht),this.$t&&(this.$t.dispose(),delete this.$t),this.Jt&&(this.Jt.dispose(),delete this.Jt),this.Kt&&(this.Kt.dispose(),delete this.Kt),this.xt.dispose(),this.picking&&this.picking.dispose()}Ct(t){return this.lt[t.id]||this.ft[t.id]||this.dt[t.id]||this.pt[t.id]}has(t){return this.Ct(t)||this.ut[t.id]}kt(t){const e=t.properties.magic;"b3dm"===e?this.ne(t):"i3dm"===e?this.re(t):"pnts"===e&&this.se(t)}createPntsMesh(t,e,r,s){if(this.ft[e]){const t=this.ft[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:i,featureTable:o,rootIdx:a,compressed_int16_params:c}=t,h=o.POINTS_LENGTH;i.BATCH_ID||(i.BATCH_ID=new Uint8Array(h),i.BATCH_ID.fill(0));const u=new n.reshader.Geometry(i,null,h,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.ct);const l={};i.POSITION?l.HAS_POSITION=1:i.POSITION_QUANTIZED&&(l.HAS_POSITION_QUANTIZED=1),i.RGB?l.HAS_RGB=1:i.RGBA?l.HAS_RGBA=1:i.RGB565&&(l.HAS_RGB565=1),(i.NORMAL||i.NORMAL_OCT16P)&&(l.HAS_NORMAL=1,i.NORMAL_OCT16P&&(l.HAS_NORMAL_OCT16P=1)),this.ie(l,c),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map(t=>t/255));const{rtcCenter:f,rtcCoord:d,projCenter:m}=t,p=this.st.Pt(a),b=new n.reshader.Mesh(u);b.properties.magic="pnts",b.properties.id=e,b.properties.node=r,b.properties.count=h,b.properties.batchTable=t.batchTable,b.properties.batchTableBin=t.batchTableBin,b.properties.serviceIndex=a,b.properties.rtcCoord=d,b.properties.rtcCenter=f,b.properties.projCenter=m,b.setDefines(l),Object.defineProperty(b.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:p&&p.pointColor||[1,1,1,1]}});const g=this.getMap();let y=null,w=null;Object.defineProperty(b.uniforms,"pointSize",{enumerable:!0,get:function(){if(!p)return 2;if(vr(p.pointSize)){const t=JSON.stringify(p.pointSize);t!==y&&(w=Tr(p.pointSize),y=t);return w(g.getZoom())}return p.pointSize||2}});let v=null,T=null;return Object.defineProperty(b.uniforms,"pointOpacity",{enumerable:!0,get:function(){if(!p)return 1;if(vr(p.pointOpacity)){const t=JSON.stringify(p.pointOpacity);t!==v&&(T=Tr(p.pointOpacity),v=t);return T(g.getZoom())}return p.pointOpacity||1}}),this.oe(b,c),this.se(b),b.Lt=n.mat4.copy([],b.localTransform),this.ft[e]=b,s(null,{id:e,mesh:[b]}),[b]}se(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:s}=t.properties;this.ae(e,n,s,r.Rt),t.setLocalTransform(e)}createI3DMMesh(t,e,r,s){if(this.dt[e]){const t=this.dt[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.ut[e]||s(null,{id:e,mesh:t}),t}const i=this.st.Pt(r.Rt),o=this.ce(r.he),{i3dm:a,featureTable:c,gltf:h,batchTable:u,batchTableBin:l,count:f}=t,d=c.INSTANCES_LENGTH,{rtcCenter:m,rtcCoord:p}=t,b=this.ue(Wr,p),g=this.le(Yr,r,m,p);n.mat4.multiply(b,g,b);const{POSITION:y,NORMAL_UP:w,NORMAL_RIGHT:v,SCALE:T,SCALE_NON_UNIFORM:_,INSTANCE_ROTATION:M}=a,O={"instance_vectorA":new Float32Array(4*d),"instance_vectorB":new Float32Array(4*d),"instance_vectorC":new Float32Array(4*d),"aPickingId":new Uint16Array(d)};for(let t=0;t<d;t++)O.aPickingId[t]=t;const x=new Float32Array(3),A=new Float32Array(3),I=[],S=new Float32Array(1),E=new Float32Array(3),N=[],C=[],P=[],R=[],k=new Float32Array(9);!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?Ue.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===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 h=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);h.set(s);e(new c(h.buffer),t),s.set(h)}}(y,(t,e)=>{w?(on(A,v,e),on(x,w,e),n.vec3.cross(I,A,x),n.vec3.normalize(I,I),bt(N,A,0),bt(N,x,1),bt(N,I,2),n.quat.fromMat3(C,N)):M?(on(k,M,e),n.quat.fromMat3(C,k)):n.quat.identity(C),T?(on(S,T,e),n.vec3.set(P,S[0],S[0],S[0])):_?(on(E,_,e),n.vec3.set(P,...E)):n.vec3.set(P,1,1,1),n.mat4.fromRotationTranslationScale(R,C,t,P),an(O.instance_vectorA,e,R,0),an(O.instance_vectorB,e,R,1),an(O.instance_vectorC,e,R,2)});const L={};for(const t in O)L[t]={buffer:this.ct.buffer({dimension:O[t].length/d,data:O[t]}),divisor:1};const B=i.shader||"pbr";let U=0,D=!0;const F=[],j=[];return We(h,(t,s,i,a)=>{const c=this.fe(t,s,i,a,r,!0,B,j),{geometry:h,material:g}=c;g&&!g.isReady()&&(D=!1,U++);const y=new n.reshader.InstancedMesh(L,d,h,g);c.refMeshes||(c.refMeshes=new Set,c.refMeshes.add(y.uuid)),y.properties.magic="i3dm",y.properties.id=e,y.properties.count=f,y.properties.batchTable=u,y.properties.batchTableBin=l,y.properties.serviceIndex=r.Rt,y.properties.rtcCoord=p,y.properties.rtcCenter=m,y.properties.node=r;const w=this.de(t,h,g,r.Rt,a);t.compressed_int16_params&&this.oe(y,t.compressed_int16_params),this.me(y,t.attributes);const v=n.mat4.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.mat4.multiply(v,v,t.matrices[e]);n.mat4.multiply(v,o,v),y.setPositionMatrix(v),this.re(y,b),y.setDefines(w),y.properties.polygonOffset={offset:0,factor:0},F.push(y),delete t.attributes,y.Lt=n.mat4.copy([],y.localTransform)}),os(j),D?(this.dt[e]=F,s(null,{id:e,mesh:F})):(this.ut[e]={meshes:F,count:U},F.pe=s),F}re(t,e){const{rtcCenter:r,rtcCoord:s,node:i}=t.properties;if(!e){e=this.ue(Wr,s);const t=this.le(Yr,i,r,s);n.mat4.multiply(e,t,e)}const o=this.st.Pt(i.Rt),a=t.localTransform||[];if(o.coordOffset){const t=this.be(Yr,i.Rt,s);n.mat4.multiply(a,t,e)}else n.mat4.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||Vr}createB3DMMesh(t,e,r,i){if(t.gltf&&(t.gltf.transferables=null),this.lt[e]||this.ut[e]){const t=this.lt[e];return console.warn(`mesh with id(${e}) was already created.`),this.ut[e]||i(null,{id:e,mesh:t}),t}let o;if(r.maxExtent){const t=new s.Extent(r.maxExtent).convertTo(t=>this._pointToPrj(t));o=[t.xmin,t.ymin,t.xmax,t.ymax]}const a=t.gltf,{projCenter:c}=a.extensions.MAPTALKS_RTC,{rtcCoord:h,center:u}=a.extensions.CESIUM_RTC,l=a.asset.sharePosition,f=this.ce(r.he);let d;d=l?this.ue(Wr,h):this.ae(Wr,h,c,r.Rt);const m=this.st.Pt(r.Rt);let p=m.shader||"pbr";if(m.unlit)p="phong";else if(a.materials)for(let t=0;t<a.materials.length;t++)if(a.materials[t]&&a.materials[t].extensions&&a.materials[t].extensions.KHR_materials_unlit){p="phong";break}const b=[],g=[];let y=0,w=!0;return We(a,(s,i,a,v)=>{const T=this.fe(s,i,a,v,r,!1,p,b),{geometry:_,material:M}=T;M&&!M.isReady()&&(w=!1,y++);const O=new n.reshader.Mesh(_,M);T.refMeshes||(T.refMeshes=new Set,T.refMeshes.add(O.uuid)),O.properties.magic="b3dm",O.properties.id=e,O.properties.node=r,t.batchTable&&(O.properties.batchTable=t.batchTable,O.properties.batchTableBin=t.batchTableBin),O.properties.count=t.featureTable&&t.featureTable.BATCH_LENGTH||0,O.properties.serviceIndex=r.Rt;const x=this.de(s,_,M,r.Rt,v);O.setDefines(x);const A=s.compressUniforms;if(A)for(const t in A)O.setUniform(t,A[t]);s.compressed_int16_params&&this.oe(O,s.compressed_int16_params),this.me(O,s.attributes),o&&(x.USE_MAX_EXTENT=1,O.setUniform("maxPrjExtent",o)),Object.prototype.hasOwnProperty.call(O.uniforms,"polygonOpacity")||Object.defineProperty(O.uniforms,"polygonOpacity",{enumerable:!0,get:function(){return ht(m.opacity)?m.opacity:1}}),Object.prototype.hasOwnProperty.call(O.uniforms,"polygonFill")||Object.defineProperty(O.uniforms,"polygonFill",{enumerable:!0,get:function(){return Mt([],m.polygonFill||Br)}}),Object.prototype.hasOwnProperty.call(O.material.uniforms,"hsv")||Object.defineProperty(O.material.uniforms,"hsv",{enumerable:!0,get:function(){return m.hsv||Ur}});const I=n.mat4.identity([]);if(l&&s.matrices&&s.matrices.length)for(let t=0;t<s.matrices.length;t++)n.mat4.multiply(I,I,s.matrices[t]);l&&n.mat4.multiply(I,f,I),O.properties.node=r,O.properties.projCenter=c,O.properties.nodeMatrix=I,O.properties.isSharedPosition=l,O.properties.rtcCoord=h,O.properties.rtcCenter=u,this.ne(O,d),g.push(O),delete s.attributes,O.Lt=n.mat4.copy([],O.localTransform)}),os(b),w?(this.lt[e]=g,i(null,{id:e,mesh:g})):(this.ut[e]={meshes:g,count:y},g.pe=i),g}ge(t){const e=this.st.ye[t.id];if(!e||t.Yt)return;let r,s,i,o;if(e.length){if(2===e.length){const t=e[0],n=e[1];r=ns.vertices,s=ns.indices,i=t,o=[n,n,n]}}else r=e.boxPosition,s=es,i=e.boxCenter,o=ss;const a=new n.reshader.Geometry({POSITION:r},s,0,{primitive:"lines",positionAttribute:"POSITION"}),c=new n.reshader.Mesh(a,new n.reshader.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),h=[];n.mat4.fromRotationTranslationScale(h,rs,i,o),c.localTransform=h,c.Lt=n.mat4.copy([],h),c.properties.node=t,t.Yt=c}we(t){t.Yt&&(t.Yt.geometry.dispose(),t.Yt.dispose(),delete t.Yt)}oe(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}ne(t,e){const{isSharedPosition:r,rtcCoord:s,rtcCenter:i,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=r?this.ue(Wr,s):this.ae(Wr,s,o,c.Rt));const h=t.localTransform||n.mat4.identity([]);if(r){const t=this.le(Yr,c,i,s);n.mat4.multiply(h,e,a),n.mat4.multiply(h,t,h)}else n.mat4.multiply(h,e,a);const u=this.st.Pt(c.Rt);if(u.coordOffset){const t=this.be(Yr,c.Rt,s);n.mat4.multiply(h,t,h)}t.setLocalTransform(h),t.properties.heightOffset=u.heightOffset||0,t.properties.coordOffset=u.coordOffset&&u.coordOffset.slice(0)||Vr}me(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}le(t,e,r,i){const o=this.getMap(),a=this.st.Pt(e.Rt).heightOffset||0,c=new s.Coordinate(i);let h;h=o.altitudeToPoint?this.It:o.distanceToPointAtRes(100,100,o.getGLRes(),c).y/100;const u=e.matrix?n.mat4.copy(t,e.matrix):n.mat4.identity(t);if(r){Zn(u,n.vec3.transformMat4(Gr,r,u),u)}const l=function(t,e,n,r,s,i,o){e=Bt(Yn,e);const a=fn(Yn,e[0]*ar,e[1]*ar,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(Qn,n),h=r.ellipsoid;let u;u=0===Xt(c)?Ut(tr,0,0,-6378137):yn(tr,c),ir.x=u[0],ir.y=u[1];const l=r.project(ir,or);er[0]=l.x/s,er[1]=l.y/s,er[2]=(u[2]+o)*i;const f=Wn(a,h,nr),d=function(t,e,n){const r=t[0],s=t[1],i=t[2],o=t[4],a=t[5],c=t[6],h=t[8],u=t[9],l=t[10],f=e[0],d=e[1],m=e[2],p=e[3],b=e[4],g=e[5],y=e[6],w=e[7],v=e[8],T=r*f+o*d+h*m,_=s*f+a*d+u*m,M=i*f+c*d+l*m,O=r*p+o*b+h*g,x=s*p+a*b+u*g,A=i*p+c*b+l*g,I=r*y+o*w+h*v,S=s*y+a*w+u*v,E=i*y+c*w+l*v;return n[0]=T,n[1]=_,n[2]=M,n[3]=0,n[4]=O,n[5]=x,n[6]=A,n[7]=0,n[8]=I,n[9]=S,n[10]=E,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],h=e[7],u=e[8],l=e[9],f=e[10],d=e[11],m=e[12],p=e[13],b=e[14],g=e[15],y=n*a-r*o,w=n*c-s*o,v=n*h-i*o,T=r*c-s*a,_=r*h-i*a,M=s*h-i*c,O=u*p-l*m,x=u*b-f*m,A=u*g-d*m,I=l*b-f*p,S=l*g-d*p,E=f*g-d*b,N=y*E-w*S+v*I+T*A-_*x+M*O;return N?(N=1/N,t[0]=(a*E-c*S+h*I)*N,t[1]=(s*S-r*E-i*I)*N,t[2]=(p*M-b*_+g*T)*N,t[3]=(f*_-l*M-d*T)*N,t[4]=(c*A-o*E-h*x)*N,t[5]=(n*E-s*A+i*x)*N,t[6]=(b*v-m*M-g*w)*N,t[7]=(u*M-f*v+d*w)*N,t[8]=(o*S-a*A+h*O)*N,t[9]=(r*A-n*S-i*O)*N,t[10]=(m*_-p*v+g*y)*N,t[11]=(l*v-u*_-d*y)*N,t[12]=(a*x-o*I-c*O)*N,t[13]=(n*I-r*x+s*O)*N,t[14]=(p*w-m*T-b*y)*N,t[15]=(u*T-l*w+f*y)*N,t):null}(rr,f),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}(sr,n),t);return Zn(t,er,d),t}(u,i,u,o.getProjection(),o.getGLRes(),h,a),f=function(t,e){return Ut(t,e[12],e[13],e[14]),t}(Zr,l);let d=this.st.options.offset;if(at(d)){const t=this.st.ve(e.id).center;d=d.call(this.st,t)}return n.vec3.set(Kr,d[0],d[1],0),n.vec3.sub(f,f,Kr),Zn(l,f,l),l}be(t,e,r){const s=this.st.Pt(e);if(!s.coordOffset)return null;const i=this.getMap(),o=i.getGLRes();Hr.set(r[0],r[1]);const a=i.coordToPointAtRes(Hr,o,Xr),c=s.coordOffset,h=Hr.set(r[0]+c[0],r[1]+c[1]),u=i.coordToPointAtRes(h,o,Jr),l=u.x-a.x,f=u.y-a.y,d=this.Te(),m=n.vec3.set(Kr,l,f,(c[2]||0)*d);return n.mat4.fromTranslation(t,m)}Te(){const t=this.getMap();let e;return e=t.altitudeToPoint?this.It:t.distanceToPointAtRes(100,100,t.getGLRes(),Hr).y/100,e}createCMPTMesh(t,e,n,r){if(this.pt[e]){const t=this.pt[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:s}=t,i=[];for(let t=0;t<s.length;t++){const{magic:r}=s[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(s[t],o,n,(t,{mesh:e})=>{i.push(e)}):"i3dm"===r?this.createI3DMMesh(s[t],o,n,(t,{mesh:e})=>{i.push(e)}):"pnts"===r?this.createPntsMesh(s[t],o,n,(t,{mesh:e})=>{i.push(e)}):"cmpt"===r&&this.createCMPTMesh(s[t],o,n,(t,{mesh:e})=>{i.push(e)})}return this.pt[e]=i,r(null,{id:e,mesh:i}),i}de(t,e,n,r,s){const i=("phong"===(this.st.Pt(r).shader||"pbr")?this.Ht:this.$t).getGeometryDefines(e);s.asset&&"S3M"===s.asset.generator&&this._e(i,e),e.data.uvRegion&&(i.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(i.VertexNormal=1),e.data[e.desc.color0Attribute]&&(i.VertexColor=1),e.data[e.desc.uv0Attribute]&&(i.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(i.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(i.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(i.TexCoord2=1),"MESHOPT"===this.st.Me&&(i.MeshOPT_Compress=1),this.hasIBL()&&(i.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(i.HAS_WEB3D_quantized_attributes_TEXCOORD=1),i.HAS_MIN_ALTITUDE=1,i.HAS_LAYER_OPACITY=1,this.ie(i,t.compressed_int16_params);return ot(i,t.compressDefines),i}ie(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}qt(t){const e=this.st.getRenderer();e&&e.updateMaskDefines(t)}_e(t,e){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)}fe(t,e,r,s,i,o,a,c){let h=!1;s.asset&&"S3M"===s.asset.generator&&(h=!0,s.extensions=s.extensions||{});const u=s.url+"-"+e+"-"+r;if(this.bt[u])return this.bt[u];let l,f;c.push(t);const d=s.materials&&s.materials[t.material],m=s.extensions&&s.extensions.KHR_techniques_webgl,p=this.st.Pt(i.Rt);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){const e=this.Oe(t,s,o,h);l=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.xe(t,o,ts);const e=p.ambientLight;let n=p.environmentExposure;const r=p.material,i=this.getMap().getLightManager(),h=i&&i.getAmbientLight();if(e&&(!h||h.color)&&void 0===n){const t=h&&h.color?h.color[0]:.2;n=e[0]/t}l=this.Ae(t.material,s,a,r||Dr,n||1,c,p)}l&&Object.defineProperty(l.uniforms,"alphaTest",{enumerable:!0,get:function(){const t=p.alphaTest;return it(t)?.1:t}}),l&&!l.isReady()?l.Ie=i.id:l||(l=new n.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const b={geometry:f,material:l};return f.properties.url=u,this.bt[u]=b,b}Oe(t,e,n,r){const{geometry:s,material:i}=this.xt.createMesh(t,e,n,r);return{geometry:s,material:i}}xe(t,e,r){const s=t.attributes;let i=s._BATCHID&&s._BATCHID.array;if(i&&i.byteOffset&&(i=new i.constructor(i)),s.COLOR_0){const t=s.COLOR_0.array||s.COLOR_0;if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);s.COLOR_0.array?(s.COLOR_0.array=e,s.COLOR_0.componentType=5121):s.COLOR_0=e}}const o={};for(const t in s){const e=Sr(this.ct,s[t],{dimension:s[t].itemSize}),n=r[t]||t;o[n]={buffer:e},s[t].quantization&&(o[n].quantization=s[t].quantization),n===r.POSITION&&(o[n].array=s[t].array,o[n].min=s[t].min,o[n].max=s[t].max)}const a=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,c=new n.reshader.Geometry(o,a,0,{static:!0,positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":Ir(t.mode)});return i&&a&&(c.properties.batchIdData=i,c.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const s=e[r],i=t[s];let o=n.get(i);o||(o=[],n.set(i,o)),o.push(s)}return n}(i,a)),c.generateBuffers(this.ct,{excludeElementsInVAO:e}),c}ae(t,e,r,s){const i=n.mat4.identity(t),o=this.getMap();Hr.x=r[0],Hr.y=r[1];const a=this._prjToPoint(Hr),c=this.Se(),h=1/(o.getGLZoom?o.getResolution(o.getGLZoom()):o.getGLRes());Hr.x=e[0],Hr.y=e[1];const u=this.Te();let l=this.st.options.offset;at(l)&&(l=l.call(this.st,Hr));const f=this.st.Pt(s).heightOffset||0;return n.vec3.set(Zr,a.x-l[0],a.y-l[1],u*r[2]+u*f),n.mat4.translate(i,i,Zr),n.vec3.set(c,h,h,u),n.mat4.scale(i,i,c),i}zt(t,e){const r=this.st.Ee(Qr,e);t.localTransform=n.mat4.multiply(t.localTransform,r,t.Lt)}ue(t,e){const r=n.mat4.identity(t),s=this.getMap(),i=this.Se();Hr.x=e[0],Hr.y=e[1];const o=s.distanceToPointAtRes(100,100,s.getGLRes(),Hr);let a;return a=s.altitudeToPoint?this.It:o.y/100,n.vec3.set(i,o.x/100*1.01,o.y/100*1.01,a),n.mat4.scale(r,r,i),r}Ot(){const t={x:0,y:0,width:()=>this.it?this.it.width:1,height:()=>this.it?this.it.height:1},e=[],r=[];this.Jt=new n.reshader.MeshShader({vert:cn,frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n\n if (dot(circCoord, circCoord) > 1.0) {\n\n discard;\n\n } else {\n\n gl_FragColor = vColor;\n\n }\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>n.mat4.multiply(r,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,r)=>n.mat3.fromMat4(e,r.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 s=this.At();this.Ht=new n.reshader.PhongShader({extraCommandProps:s}),this.$t=new n.reshader.pbr.StandardShader({extraCommandProps:s}),this.Kt=new n.reshader.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.it?this.it.width:1,height:()=>this.it?this.it.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const i=this.st;Cr(i.getRenderer().canvas,this.ct,i.getMap()),this.picking=new n.reshader.FBORayPicking(this.ht,{vert:this.$t.vert,extraCommandProps:s,uniforms:this.$t.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.Ne=new n.reshader.FBORayPicking(this.ht,{vert:cn,extraCommandProps:s,uniforms:this.Jt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}At(){return{viewport:{x:0,y:0,width:()=>this.it?this.it.width:1,height:()=>this.it?this.it.height:1},cull:{enable:!0},stencil:{enable:!0,func:{cmp:(t,e)=>e.meshProperties.isLeaf?"always":">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:[0,1],func:(t,e)=>e.meshProperties.depthFunc||"<"},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}Xt(t){const e=this.getMap(),r=e.getLightManager(),s=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],i=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:i,lightDir:n.vec3.normalize(s,s)}}Et(){const t=this.getMap(),e=this.st,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:s}=Rr(n),i=kr(t,r,s),o=this.st.getRenderer(),a=o.getMaskUniforms();i.minAltitude=e.options.altitude||0;const c=o.canvas.gl&&o.canvas.gl.wrap?e.options.opacity||0:1;return i.layerOpacity=c,ot(i,{czm_lightDirectionEC:i.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),ot(i,a),i}Ae(t,e,r,s,i,o,a){const c=e.materials&&e.materials[t];if(!c||!c.baseColorTexture&&!c.pbrMetallicRoughness)return null;const h=ot({},s);if(c.baseColorTexture){const t=e.textures[c.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.P(t,o)),h.baseColorFactor=t&&t.image.color||c.baseColorFactor||[1,1,1,1],n&&(h.baseColorTexture=n)}else{if(c.normalTexture){const t=this.P(e.textures[c.normalTexture.index],o);if(t){const e=c.normalTexture.scale||1;h.normalTexture=t,h.normalMapFactor=e}}if(c.occlusionTexture){const t=this.P(e.textures[c.occlusionTexture.index],o);if(t){const e=c.occlusionTexture.strength||1;h.occlusionTexture=t,h.occlusionFactor=e}}if(c.emissiveTexture){const t=this.P(e.textures[c.emissiveTexture.index],o);t&&(h.emissiveTexture=t)}c.emissiveFactor&&(h.emissiveFactor=c.emissiveFactor);const t=c.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(h.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const r=e.textures[t.baseColorTexture.index];if(r.image&&r.image.color)h.baseColorFactor=h.baseColorFactor?n.vec4.multiply(h.baseColorFactor,h.baseColorFactor,r.image.color):r.image.color;else{const t=this.P(r,o);t&&(h.baseColorTexture=t,h.baseColorTexture.getREGLTexture(this.ct))}}if(it(t.metallicFactor)||(h.metallicFactor=t.metallicFactor),it(t.roughnessFactor)||(h.roughnessFactor=t.roughnessFactor),c.metallicRoughnessTexture){const t=this.P(e.textures[c.metallicRoughnessTexture.index],o);t&&(h.metallicRoughnessTexture=t)}}}if(c.s3mMaterial)return new n.reshader.Material(h);if(h.environmentExposure=i,h.alphaTest=.1,a.unlit||c.extensions&&c.extensions.KHR_materials_unlit)return h.ambientColor=[1,1,1],h.light0_diffuse=[0,0,0,0],h.lightSpecular=[0,0,0],new n.reshader.PhongMaterial(h);let u=new n.reshader.pbr.StandardMaterial(h);"phong"===r&&(u=n.reshader.PhongMaterial.convertFrom(u));const l=c.pbrMetallicRoughness,f=l&&l.baseColorTexture&&l.baseColorTexture.extensions;return f&&f.KHR_texture_transform&&(u.set("khr_offset",f.KHR_texture_transform.offset||[0,0]),u.set("khr_rotation",f.KHR_texture_transform.rotation||0),u.set("khr_scale",f.KHR_texture_transform.scale||[1,1])),u.doubleSided=!(!a.doubleSided&&!c.doubleSided),u.once("complete",this._t),u}P(t,e){const r={type:t.type?xr(t.type):"uint8",format:t.format?Ar(t.format):"rgba",flipY:!!t.flipY},s=t.image;if(e.push(s),s.array?r.data=s.array:s.mipmap&&(r.mipmap=s.mipmap),!r.data&&!r.mipmap)return null;if(r.width=s.width,r.height=s.height,r.mipmap&&(r.width<4||r.height<4))return null;const i=t.sampler||t.texture&&t.texture.sampler;return i&&(i.magFilter&&(r.mag=_r(i.magFilter)),i.minFilter&&(r.min=Mr(i.minFilter)),i.wrapS&&(r.wrapS=Or(i.wrapS)),i.wrapT&&(r.wrapT=Or(i.wrapT))),new n.reshader.Texture2D(r,this.Tt)}Mt({target:t}){const e=t.Ie,n=this.ut[e];if(n.count--,!n.count){const t=n.meshes;this.lt[e]=t,delete this.ut[e];const r=t.pe;delete t.pe,r(null,{mesh:n.meshes,id:e})}}Se(){return Fr}Ce(t){return this.st.Ce(t)}_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(),$r)}ce(t){return"Y"===t?Er:"X"===t?Nr:jr}pick(t,e,n=3){const r=this.st;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const s=[],i=this.Et(),o=this.Pe(this.picking,i,this.gt,t,e,n);o&&s.push(o);const a=this.Pe(this.picking,i,this.wt,t,e,n);a&&s.push(a);const c=this.Xt(),h=this.Pe(this.Ne,c,this.yt,t,e,n);return h&&s.push(h),s}Pe(t,e,n,r,s,i){if(!n.getMeshes().length)return null;const o=this.st,a=this.getMap();t.render(n.getMeshes().filter(t=>!t.bloom),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,s,i,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:h,pickingId:u,point:l,coordinate:f}=c,d=(0===h||h)&&t.getMeshAt(h);if(!d||!d.geometry)return null;const m=d.properties;l&&l.length&&(l[0]=Math.round(1e5*l[0])/1e5,l[1]=Math.round(1e5*l[1])/1e5,l[2]=Math.round(1e5*l[2])/1e5);const p={batchId:u},b=o.options.services,g=b&&b[d.properties.serviceIndex];if(g&&g.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=u;for(const s in t)void 0!==t[s].byteOffset?p[s]=kn(t[s],e,n,r):p[s]=t[s][r]}return{service:d.properties.serviceIndex,data:p,point:l,coordinate:f}}Nt(t){let e=new Set;for(let n=0,r=t.length;n<r;n++){const r=t[n].data.node;this.Ct(r)&&e.add(r.Vt)}e=Array.from(e),e.sort();const n=new Map,r=e.length;for(let t=0;t<r;t++)n.set(e[t],t);return n}highlight(t){this.Ut=t;const e=this.st.getRenderer();this.Dt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.Ut=null;const t=this.st.getRenderer();this.Dt=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Ft=t;const e=this.st.getRenderer();this.jt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Ft=null;const t=this.st.getRenderer();this.jt=t.getFrameTimestamp(),t.setToRedraw(!0)}Re(){if(!this.St)return[];const t={},e=[];for(const n in this.St){const r=this.St[n];if(r)for(let n=0;n<r.length;n++){const s=r[n],i=s&&s.geometry;if(!s||!i)continue;const o=s.properties.serviceIndex;t[o]||(t[o]=new Set);const a=i.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}function os(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}const as=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")},cs=as(),hs=cs.gl_trans__coders=cs.gl_trans__coders||{};function us(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}hs.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=cs.gl_trans__coders=cs.gl_trans__coders||{};let i=`${r}\n const _____getGlobal = ${as.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+='tran_____scoders["'+t+'"] ='+s[t].toString()+"\n;");return i+="\n"+e.substring(r.length),i},hs.registerTranscoder=function(t,e){hs[t]=e},hs.getTranscoder=function(t){return hs[t]};const ls=[];class fs{constructor(t,e,n,r,s){this.st=r,this.ke=t,this.Rt=e,this.Le=s,this.Be=n.version,t.indexOf("i3s:tileset:")<0?(this.Be<=1.6?this.Ue="root":this.Ue=0,n.version=this.Be):(this.Ue=t.substring("i3s:tileset:".length),this.Be>1.6&&(this.Ue=parseInt(this.Ue))),this.ke=t,this.De=n}load(){const t=this.De,e=t.layerScene.baseUrl;if(this.Be<=1.6)return t[this.Ue]&&t[this.Ue].lodSelection?(this.Fe=t[this.Ue],this.je()):new Promise(n=>{let r=e+"/nodes/"+this.Ue;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Le(this.Rt,r,()=>{this.Fe=t[this.Ue],n(this.je())})});if(this.Be>=1.7){if(t[this.Ue])return this.Fe=t[this.Ue],this.je();const n=Math.floor(this.Ue/t.nodesPerPage);return new Promise(r=>{let s=e+"/nodepages/"+n;t.layerScene.eslpk&&(s+=".json"),this.Le(this.Rt,s,()=>{this.Fe=t[this.Ue],r(this.je())})})}return null}getTileset(){return this.Ve}getChildrenURL(){return this.qe}je(){const t=this.De,e=t.layerScene.baseUrl,n=this.Fe.children,r=[],s={};if(n)for(let i=0;i<n.length;i++)if(this.Be<=1.6){const o=n[i].id;if(t[o])continue;const a=o;s[a]||(s[a]=new Promise(n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Le(this.Rt,r,()=>{n()})}),r.push(s[a]))}else{const o=n[i];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);s[a]||(s[a]=new Promise(n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.Le(this.Rt,r,()=>{n()})}),r.push(s[a]))}return r.length?Promise.all(r).then(()=>this.ze()):this.ze()}ze(){return Promise.resolve(this.Ge())}He(t){us(this.De,t)}Ge(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.$e(this.Fe,!0)}}$e(t){const e=this.st.getRenderer(),n=this.De.projection,r=!n||n&&4326===n.wkid,s=this.Be,i=this.De,o=t,a=o.obb,c=o.mbs,h={};let u;if(c)u=Ut([],c[0],c[1],c[2]),r||(u=e.Xe(u,u)),u=ds([],u[0],u[1],u[2]),h.sphere=[...u,c[3]];else if(a){u=Ut([],a.center[0],a.center[1],a.center[2]),r||(u=e.Xe(u,u)),u=ds([],u[0],u[1],u[2]);const t=function(t,e,n){const r=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,h=n*o,u=r*o,l=r*a,f=s*o,d=s*a,m=s*c,p=i*o,b=i*a,g=i*c;return t[0]=1-l-m,t[3]=u-g,t[6]=f+b,t[1]=u+g,t[4]=1-h-m,t[7]=d-p,t[2]=f-b,t[5]=d+p,t[8]=1-h-l,t}([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(u,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],s=t[4]+t[7]+t[10],i=t[5]+t[8]+t[11];Ut(ls,n,s,i);const o=Xt(ls);h.sphere=[...u,o]}let l=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===i.lodSelectionMetricType){l=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(l=f/o.lodSelection[t].maxError);(l===1/0||isNaN(l))&&(l=1e5);const d=16*l,m=St([]),p=o.children;let b;if(p){b=[];const t=this.De;for(let e=0;e<p.length;e++){const n=s<=1.6?p[e].id:p[e];if(!t[n]){b=null;break}b.push(this.$e(t[n]))}}const g={refine:"REPLACE",boundingVolume:h,transform:m,geometricError:d};return s<=1.6?t.lodSelection?t.geometryData&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}):g.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!b?g.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}),b&&b.length&&(g.children=b),g}getJSON(){return this.Fe}}function ds(t,e,n,r){return fn(t,ut(e),ut(n),r)}const ms=!!hs.ktx2,ps=n.mat4.identity([]),bs=(()=>{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 gs(t){return t.indexOf("i3s:mesh")>=0}const ys="i3s:mesh:".length;function ws(t,e,n,r,s){const i=e.layerScene.eslpk,o=function(t,e){const n=e.substring(ys);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let u=!1;const l=ps;let f,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;i&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let s=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(s){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",i&&(s+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+s,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}h.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions[f.definition],{geometryBuffers:o}=t;u=r&&2===o.length;const l=hs.draco&&u?o[1]:o[0],m=hs.draco&&u?1:0;let p=c+`/nodes/${f.resource}/geometries/`+m;i&&(p+=".bin");const b={geometry:{url:p,info:l}};if(s&&bs&&u&&!hs.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const g=e.layerScene.materialDefinitions,y=e.layerScene.textureSetDefinitions;let w,v=0;if(d&&(v=g[d.definition]),g){w=function(t,e,n,r,s,i){const o=JSON.parse(JSON.stringify(t));return function t(e,n,r,s,i,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const t=n[e[a].textureSetDefinitionId],c="images/"+t.formats[0].format,h=vs(t.formats,i),u={url:r+`/nodes/${s}/textures/${h.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:h.format,mimeType:c};if(o){let t="";switch(h.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=h.format}u.url+="."+t}e[a]=u}else ct(e[a])&&t(e[a],n,r,s,i,o)}(o,e,n,r,s,i),o}(v,y,c,d.resource,n,e.layerScene.eslpk)}else w={pbrMetallicRoughness:{metallicFactor:0}};b.material=w,h.push(b)}return{dracoCompression:u,meshes:h,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:l}}function vs(t,e){for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&ms)return t[n]}return null}const Ts=new s.Coordinate(0,0),_s=new s.Coordinate(0,0),Ms=new Set,Os=[],xs=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.Je(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.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){let t=!1;const e=this.data.keys();let n=e.next();for(;this.currentSize>this.max&&void 0!==n.value;){!t&&this.data.get(n.value).current&&(t=!0,console.warn(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`));const r=this.getAndRemove(n.value);r&&this.onRemove(r),n=e.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(const r of n)t[e++]=r;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 this.Je(t,e),this}Je(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(s.Browser.mobile?32:1024)*1024,t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)});let As=0;class Is extends(n.MaskRendererMixin(s.renderer.CanvasRenderer)){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>xs.max&&xs.setMaxSize(e),this.tileCache=xs,As++,this.prepareWorker(),this.tilesLoading={},this.Ke={},this.Ze=[],this.Le=this.We.bind(this)}getAnalysisMeshes(){if(!this.painter)return Os;const t=this.painter.getPaintedMeshes();if(!t)return Os;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:s}=t;return n.length&&Tt(e,n),r.length&&Tt(e,r),s.length&&Tt(e,s),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.Ze.length||super.needToRedraw())}getFrameTimestamp(){return this.Ye}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.Ye=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:s}=this.layer.getTiles(),i=s.length;if(!s||!i)return void this.completeRender();this.Qe(),this.tn();const{selectedTiles:o,leaves:a,requests:c}=this.nn(r,s);c.length&&this.loadTiles(c),this.rn(o,a,e),this.sn(),c.length||this.completeRender()}nn(t,e){let n=[];this.in();let r=0;const s=this.an(),i={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const s=e[t],c=s.node;if(i[c.id])continue;i[c.id]=1;let h=!1;const u=this.getCachedTile(c.id);if(this.cn(c.id)?(r++,h=a=!0,this.tilesLoading[c.id].current=!0):u?(this.getTileOpacity(u)<1&&(h=a=!0),o=!0,s.selected=!0,s.data=u):this.painter.has(c)||(h=a=!0,n.push(c)),!h)continue;if(this.hn(s))o=!0;else{this.un(s).length&&(o=!0)}}let c=[],h={};if(o&&({selectedTiles:c,leaves:h}=this.ln(t)),n.length>1&&(n.sort(Ss),s)){const t=s-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c,leaves:h}}ln(t){const e=[],n={};let r;const s=[t],i=[];for(;s.length>0||i.length>0;){if(i.length>0){const t=i[i.length-1];if(t.dn===s.length){i.pop(),t===r&&(t.leave=!0,n[t.node.id]=1),e.push(t);continue}}const t=s.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)n[t.node.id]=1,t.selectionDepth=i.length,e.push(t);else{if(t.selectionDepth=i.length,r=t,0===o.length){t.leave=!0,n[t.node.id]=1,e.push(t);continue}i.push(t),t.dn=s.length}for(let t=0;t<o.length;t++)s.push(o[t])}return{selectedTiles:e,leaves:n}}hn(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}un(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.Vt+1,r=[t.node];for(;r.length>0;){const s=r.pop().children;for(let i=0,o=s.length;i<o;i++){if((!s[i].content||!s[i].content.url)&&s[i].children&&s[i].children.length){r.push(s[i]);continue}const o=s[i].id;if(this.tileCache.has(o)){const n=this.layer.mn(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].Vt<=n&&r.push(s[i])}}return e}rn(t,e,n){this.tileCache.markAll(this,!1);const r=[];for(let e=0,n=t.length;e<n;e++){const n=t[e].data;n.current=!0,n.renderer=this,this.tileCache.add(t[e].node.id,n);const s=n.node,i=this.layer.Pt(s.Rt);s.Yt&&i.debug&&!Array.isArray(i.debug)&&r.push(s.Yt)}this.tileCache.shrink();const s=this.layer.options.services;for(let t=0;t<s.length;t++){const e=s[t],n=Array.isArray(e.debug)&&e.debug;if(n)for(const t of n){const e=this.layer.ye[t],n=e&&e.node;n&&n.Yt&&r.push(n.Yt)}}const i={tiles:t,leaves:e};this.onDrawTileStart(i);const o=this.painter.paint(t,e,r,n);this.onDrawTileEnd(i),o&&this.layer.fire("canvasisdirty",{renderCount:o})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(wt(e)){const n=vt(e);return this.pn(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.Rt,r=this.bn[n];return new fs(e,n,r,this.layer,this.Le).load().then(n=>{this.onTilesetLoad(n,t,e)})}return t&&xt(e)&&!gs(e)&&(e=t.baseUrl+e),this.pn(e,null,t),null}pn(t,e,r){let s=this.o;s||(s=n.reshader.Util.getSupportedFormats(this.gl.gl||this.gl),this.o=s);const i=this.layer.Pt(r.Rt);i.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length).split("/"),r=[];for(let t=0;t<n.length;t++)r.push(encodeURIComponent(n[t]));return e+r.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,r.baseUrl,this.layer.gn[r.Rt]),arraybuffer:e,rootIdx:r.Rt,upAxis:r.he,transform:r.matrix,supportedFormats:s};if(gs(t)){const e=this.bn[r.Rt];if(o.projection=e.projection,o.i3sInfo=ws(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=ot({},i),i.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,(e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:s}=n;"b3dm"===s||"pnts"===s||"i3dm"===s||"cmpt"===s||"gltf"===s?this.Ze.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)})}ge(t){this.painter&&this.painter.ge(t)}we(t){this.painter&&this.painter.we(t)}tn(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.Ze.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.Ze.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,(n,{mesh:r})=>{this.yn(t,e,n,r)}):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,(n,{mesh:r})=>{this.yn(t,e,n,r)}):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,(n,{mesh:r})=>{this.yn(t,e,n,r)}):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,(n,{mesh:r})=>{this.yn(t,e,n,r)}),n++}}yn(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.wn(r);e.memorySize=n,this.onTileLoad(t,e)}}wn(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.wn(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.vn(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.Me=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.Tn(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(t,e,n){if(!this.layer)return;const r=n||e.content.url,s=t&&t.message||t;Ms.has(s)||(console.warn("failed to load 3d tile: "+r),console.warn(t),Ms.add(s)),delete this.tilesLoading[e.id],this._n(e,t),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}_n(t,e){const n={loadTime:s.Util.now(),current:!0,error:e,node:t};n.renderer=this,this.tileCache.add(t.id,n)}vn(t){const e={loadTime:s.Util.now(),current:!0,node:t};e.renderer=this,this.tileCache.add(t.id,e)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.Ke[e]}in(){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},r=this.canvas.gl&&this.canvas.gl.wrap;r?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.Mn(this.canvas,e)),this.regl=this.regl||n.createREGL({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),r&&(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 is(this.regl,t),this.layer.On(),this.layer.fire("contextcreate",{regl:this.regl})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new Je("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let n=this.layer.options||{};n=ot({},n),delete n.offset;const r=t.options.spatialReference;n.projection=r&&r.coordType||r&&r.projection||t.getSpatialReference().getProjection().code;const s=this.layer.getId();e.addLayer(s,n,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),As--,As||xs.reset(),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.sn(!0),this.tileCache.reset(this),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}sn(t){this.xn||(this.xn=Date.now());const e=Date.now();if(!t&&e-this.xn<this.layer.options.retireInterval)return;this.xn=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}an(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}Mn(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let s=0;s<n.length;++s){try{r=t.getContext(n[s],e)}catch(t){}if(r)break}return r}cn(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,n){return Pn(t,e,0,n)}Qe(){if(!this.An)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.An){const s=this.An[r];if("pending"===s.status)continue;s.status="pending";const i=s.rootIdx,o=At(this.layer.Pt(i).fetchOptions);if(n.push(ye.getJSON(r,o).then(t=>{delete this.An[r];const e=this.bn[i];if(e){t.nodes?us(e,t.nodes):(e[t.id]=t,us(e,t.children));for(let t=0;t<s.length;t++)s[t]();this.setToRedraw()}else this.setToRedraw()})),e++,e>=t)break}n.length&&Promise.all(n)}We(t,e,n){this.An||(this.An={}),this.An[e]=this.An[e]||[],this.An[e].rootIdx=t,this.An[e].push(n),this.setToRedraw()}Tn(t,e,n){this.bn||(this.bn=[]);const r=e.Rt;this.bn[r]||(this.bn[r]={});const s=this.bn[r],i=this.layer.Pt(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),s.version=+(i.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),s.projection=t.spatialReference,function(t,e,n,r,s,i,o){if(!i.layerScene){i.layerScene=e,i.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,i.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=s;i.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0;if(t.endsWith(".json")){const e=s.lastIndexOf("/");t=e<0?"./":s.substring(0,e)}i.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new fs(s,n,i,t,o).load()}(this.layer,t,r,0,n,s,this.Le).then(t=>{this.onTilesetLoad(t,e,n)})}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:s,height:i}=this.canvas;return!this.pickingFBO||r.width===s&&r.height===i||r.resize(s,i),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.Ut||(this.Ut=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Ut[n];r||(r=this.Ut[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Ut[e];n||(n=this.Ut[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.Ut)}cancelHighlight(t,e){if(!this.Ut)return;const n=this.Ut[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.Ut[t]=null),this.painter.highlight(this.Ut)}}cancelAllHighlight(){delete this.Ut,this.painter.cancelAllHighlight()}showOnly(t){if(this.Ft||(this.Ft=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Ft[n];r||(r=this.Ft[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Ft[e];n||(n=this.Ft[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Ft)}cancelShowOnly(){delete this.Ft,this.painter.cancelShowOnly()}Re(){return this.painter?this.painter.Re():[]}Xe(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.In();return Ts.set(e[0],e[1]),n.unproject(Ts,_s),t[0]=_s.x,t[1]=_s.y,t}return Ts.set(e[0],e[1]),n.getProjection().unproject(Ts,_s),t[0]=_s.x,t[1]=_s.y,t}Sn(t,e){const n=this.In();return Ts.set(e[0],e[1]),n.project(Ts,_s),t[0]=_s.x,t[1]=_s.y,t}En(t,e){const n=this.In();return Ts.set(e[0],e[1]),n.unproject(Ts,_s),t[0]=_s.x,t[1]=_s.y,t}In(){const t=this.getMap().options.spatialReference.coordType;if(!t)throw new Error("Missing coordType in map spatialReference.");return this.Nn||(this.Nn=s.SpatialReference.getProjectionInstance(t)),this.Nn}}function Ss(t,e){return t.Wt-e.Wt}function Es(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function Ns(t,e,n){return Math.sqrt(function(t,e,n){const r=Ft(Cs,n,t),s=Es(Ps,e,0),i=Es(Rs,e,1),o=Es(ks,e,2),a=Xt(s),c=Xt(i),h=Xt(o);qt(s,s),qt(i,i),qt(o,o);const u=Ls;u[0]=zt(r,s),u[1]=zt(r,i),u[2]=zt(r,o);let l,f=0;u[0]<-a?(l=u[0]+a,f+=l*l):u[0]>a&&(l=u[0]-a,f+=l*l);u[1]<-c?(l=u[1]+c,f+=l*l):u[1]>c&&(l=u[1]-c,f+=l*l);u[2]<-h?(l=u[2]+h,f+=l*l):u[2]>h&&(l=u[2]-h,f+=l*l);return f}(t,e,n))}const Cs=[],Ps=[],Rs=[],ks=[],Ls=[];const Bs=2*Math.PI;class Us{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],s=t.west;let i=t.east;return i<s&&(i+=Bs,n<0&&(n+=Bs)),(n>s||An(n,s,1e-14))&&(n<i||An(n,i,1e-14))&&r>=t.south&&r<=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 Ds=[0,0,1];function Fs(t,e){return fn(e,t[0],t[1],t[2])}class js{constructor(t,e){this.normal=n.vec3.copy([],t),this.distance=e}static fromPointNormal(t,e,r){const s=-n.vec3.dot(e,t);return n.vec3.copy(r.normal,e),r.distance=s,r}}const Vs=[],qs=[],zs=[],Gs=[],Hs=[],$s=[],Xs=[],Js=[],Ks=[],Zs=[],Ws=new js([1,0,0],0),Ys=[];class Qs{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new Us(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let r=0;if(!Us.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,s=this.northeastCornerCartesian,i=this.westNormal,o=this.southNormal,a=this.eastNormal,c=this.northNormal,h=n.vec3.subtract(Ys,t,e),u=n.vec3.dot(h,i),l=n.vec3.dot(h,o),f=n.vec3.subtract(Ys,t,s),d=n.vec3.dot(f,a),m=n.vec3.dot(f,c);u>0?r+=u*u:d>0&&(r+=d*d),l>0?r+=l*l:m>0&&(r+=m*m)}const s=e[2],i=this.minimumHeight,o=this.maximumHeight;if(s>o){const t=s-o;r+=t*t}else if(s<i){const t=i-s;r+=t*t}return Math.sqrt(r)}computeBox(t){const e=this;Fs(Us.southwest(t,qs),e.southwestCornerCartesian),Fs(Us.northeast(t,qs),e.northeastCornerCartesian),Vs[0]=t.west,Vs[1]=.5*(t.south+t.north),Vs[2]=0;const r=Fs(Vs,zs),s=n.vec3.cross(Hs,r,Ds);n.vec3.normalize(e.westNormal,s),Vs[0]=t.east;const i=Fs(Vs,Js),o=n.vec3.cross(Hs,Ds,i);n.vec3.normalize(e.eastNormal,o);const a=n.vec3.subtract(Hs,r,i),c=n.vec3.normalize(Gs,a),h=t.south;let u;if(h>0){Vs[0]=.5*(t.west+t.east),Vs[1]=h;const r=Fs(Vs,Ks);n.vec3.copy(Zs,c);const s=js.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Ws);ti(Ks,Zs,s,e.southwestCornerCartesian),u=Mn(r,$s)}else u=On(Us.southeast(t,qs),$s);const l=n.vec3.cross(Xs,u,a);n.vec3.normalize(e.southNormal,l);const f=t.north;let d;if(f<0){Vs[0]=.5*(t.west+t.east),Vs[1]=f;const r=Fs(Vs,Ks);n.vec3.scale(Zs,c,-1);const s=js.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Ws);ti(Ks,Zs,s,e.northeastCornerCartesian),d=Mn(r,$s)}else d=On(Us.northwest(t,qs),$s);const m=n.vec3.cross(Xs,a,d);n.vec3.normalize(e.northNormal,m)}}function ti(t,e,r,s){const i=t,o=e,a=r.normal,c=n.vec3.dot(a,o);if(Math.abs(c)<1e-15)return;const h=(-r.distance-n.vec3.dot(a,i))/c;return h<0?void 0:(s=n.vec3.scale(s,o,h),n.vec3.add(s,i,s))}const ei={"maxGPUMemory":s.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"debug":!1,"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!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]},ni=[],ri=[],si=[],ii=[],oi=[],ai=[],ci=[],hi=[],ui=[],li=[],fi=new s.Coordinate(0,0),di=new s.Point(0,0),mi=[],pi=[],bi=[],gi=[],yi=new s.Coordinate(0,0),wi=n.mat4.identity([]),vi=[0,0],Ti=[0,0,0],_i=[1,1,1],Mi=[0,0,0],Oi=[0,0,0],xi=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class Ai extends(n.MaskLayerMixin(s.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new Ai(t.id,t.options):null}constructor(t,e){super(t,e),this.Cn(),this.Ke={},this.ye=[]}Cn(){const t=this.options.services.map(t=>t.url);this.Pn=this.Pn||{},this.gn=this.gn||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.Pn[n];void 0===r&&(r=this.Pn[n]=this.gn.length),this.gn[r]=Ei(n,r,this.options.services[e])}this.fire("rootready",{roots:this.gn.slice(0)})}showService(t){return this.updateService(t,{visible:1}),this}hideService(t){return this.updateService(t,{visible:0}),this}setToRedraw(){const t=this.getRenderer();t&&t.setToRedraw()}addService(t){this.options.services=this.options.services||[],this.options.services.push(t),this.Cn();const e=this.getRenderer();return e&&e.setToRedraw(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(Pi(n[t].coordOffset,e.coordOffset)&&Pi(n[t].heightOffset,e.heightOffset)&&Pi(n[t].scale,e.scale)&&Pi(n[t].rotation,e.rotation)),ot(n[t],e));const s=n[t].url,i=this.Pn[s];this.gn&&this.gn[i]&&(it(e.visible)||(this.gn[i].visible=e.visible),r&&this.gn[i].version++);const o=this.getRenderer();return o&&o.setToRedraw(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.Pn[n];this.gn[r]&&(this.gn[r]=null),delete this.Pn[n],e.splice(t,1)}const n=this.getRenderer();return n&&n.setToRedraw(),this}getTileUrl(t,e,n){const r=n&&n.service&&n.service.subdomains;if(r&&n.domainKey){const e=r.length;if(e){const s=[...t].reduce((t,e)=>t+e.charCodeAt(),0)%e;return t.replace(n.domainKey,r[s])}}return t}getExtent(t){if(!t&&0!==t){const t=new s.Extent;for(let e=0;e<this.gn.length;e++)if(this.gn[e].boundingVolume){const n=this.boundingVolumeToExtent(this.gn[e]);t._combine(n)}return t}return this.gn[t]&&this.gn[t].boundingVolume?this.boundingVolumeToExtent(this.gn[t]):null}boundingVolumeToExtent(t){const e=t.boundingVolume.Rn?wi:t.matrix,r=this.getMap(),i="identity"===r.getProjection().code.toLowerCase(),o=this.getRenderer();if(t.boundingVolume.region){const e=t.boundingVolume.region;return new s.Extent(lt(e[0]),lt(e[1]),lt(e[2]),lt(e[3]))}if(t.boundingVolume.sphere){const a=t.boundingVolume.sphere,c=yn([],n.vec3.transformMat4([],a,e));i&&o.Sn(c,c);const h=a[3],u=r.locate(c,-h,h),l=r.locate(c,h,-h);return new s.Extent(u,l)}if(t.boundingVolume.box){const a=t.boundingVolume.box,c=n.vec3.transformMat4([],a,e),h=new s.Coordinate(yn([],c));i&&o.Sn(h,h);const u=a.slice(3);n.mat3.multiply(u,n.mat3.fromMat4([],t.matrix),u);const l=n.vec3.length(u.slice(0,3)),f=n.vec3.length(u.slice(3,6)),d=n.vec3.length(u.slice(6,9)),m=Math.max(l,f,d),p=r.locate(h,-m,m),b=r.locate(h,m,-m);return new s.Extent(p,b)}return null}getRootTiles(){return this.gn}getTiles(){const t=this.getRenderer();if(!t.ready)return this.kn(),{tiles:li};const e=this.getMap(),r=e.cameraPosition,s=e.pointAtResToDistance(r[2],0,e.getGLRes()),i=this.Ln(r);this.Bn=this.Bn||[],n.vec3.set(this.Bn,ut(i.x),ut(i.y),s),this.Un=fn(this.Un||[],this.Bn[0],this.Bn[1],this.Bn[2]),this.Dn=2*Math.tan(.5*ut(e.getFov()));const o=e.projViewMatrix,a={children:[],level:-1};let c=a;const h=[];for(let e=0;e<this.gn.length;e++){const n=this.gn[e];if(!n||!n.visible)continue;const r=[n],s=this.Fn(e);for(;r.length>0;){const e=r.pop();for(e.id||this.jn(e);c.level>=e.Vt;)c=c.parent;const n=this.Vn(e,s,o);if(n<1&&(n<0||!this.options.alwaysShowTopTiles||!Ci(e))){let t=c;for(;t&&!t.content;)t=t.parent;0===n&&t&&t.content&&this.qn(h,t);continue}e.Wt<1/0&&this.zn(e);const i=this.mn(e,c);c.children.push(i);const a=e.children,u=a&&a.length,l=i.content;if(!u&&l&&this.qn(h,i),u){l&&"add"===e.refine&&this.qn(h,i),c=i;const n=a[0].parent;let s=!1;for(let i=0,o=a.length;i<o;i++){if(n){const e=t.getCachedTile(a[i].id);if(e&&e.error&&404!==e.error.status)continue;s=!0}else{s=!0,a[i].parent=e,a[i].he=e.he,a[i].baseUrl=e.baseUrl;const t=a[i].content&&(a[i].content.url||a[i].content.uri);t&&(wt(t)||t.indexOf("i3s:")>=0?a[i].baseUrl=e.baseUrl:xt(t)?a[i].content.url=e.baseUrl+t:a[i].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}r.push(a[i])}!s&&l&&this.qn(h,i)}}}return{root:a,tiles:h}}qn(t,e){const{viewerRequestVolume:n}=e.node;n&&!function(t,e,n){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return Ii(n,e);if(n.box)return 0===Si(n,e)}return!1}(this.Bn,this.Un,n)||t.push(e)}mn(t,e){return{id:t.id,node:t,children:[],level:t.Vt,parent:e,content:t.content&&t.content.url}}jn(t){const e=this.getId();t.id=e+":"+s.Util.GUID(),t.matrix=t.transform||n.mat4.identity([]),t.Gn=this.Hn(t),t.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(t)||(t.matrix=n.mat4.multiply(t.matrix,t.parent.matrix,t.matrix)),t.Rt=t.parent.Rt,void 0===t.Vt&&(t.Vt=t.parent.Vt+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)}Pt(t){return this.gn[t].service}$n(t){const e=t.boundingVolume;if(!e||e.Rn&&!this.Xn(t))return;const r=this.Pt(t.Rt),s=r.heightOffset||0,i=this.options.offset,o=at(i)||i[0]||i[1],a=r.coordOffset||vi;if(!Array.isArray(a))throw new Error("service.coordOffset must be an array");if(!e.Rn&&(!t.boundingVolume||!s&&n.mat4.exactEquals(t.matrix,wi)&&!o&&a===vi))return;e.box&&e.region&&delete e.region;const{region:c,box:h,sphere:u}=e;if(e.coordOffset=[a[0],a[1]],e.heightOffset=s,c){e.originalVolume||(e.originalVolume=c.slice(0));const t=e.originalVolume,n=this.Jn([lt(t[0]),lt(t[1])]);c[0]=ut(n.x+a[0]),c[1]=ut(n.y+a[1]);const r=this.Jn([lt(t[2]),lt(t[3])]);c[2]=ut(r.x+a[0]),c[3]=ut(r.y+a[1]),c[4]=t[4]+s+(a[2]||0),c[5]=t[5]+s+(a[2]||0)}else if(h||u){e.originalVolume||(e.originalVolume=(h||u).slice(0));const r=h||u,i=e.originalVolume,o=n.vec3.transformMat4(ni,i,t.matrix),c=yn(ri,o),l=this.Jn([c[0]+a[0],c[1]+a[1]]);c[0]=l.x,c[1]=l.y,c[2]+=s+(a[2]||0),fn(r,ut(c[0]),ut(c[1]),c[2])}e.Rn=!0}Xn(t){const e=t.boundingVolume,n=this.Pt(t.Rt),r=n.heightOffset||0,s=n.coordOffset||vi;return e.coordOffset[0]!==s[0]||e.coordOffset[1]!==s[1]||e.heightOffset!==r}Hn(t){return void 0===t.geometricError||!t.boundingVolume}zn(t){let e=t.parent;for(;e&&e.Gn&&!(e.Wt<=t.Wt);)e.Wt=t.Wt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const r=this.getRenderer();r&&r.setToRedraw()}}onTilesetLoad(t,e,r){if(!t)return void console.warn("invalid tileset at : "+r);const s=this.Pt(e.Rt),i=(t.asset&&t.asset.gltfUpAxis||e&&e.he||s.upAxis||"Y").toUpperCase();t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const o=r.indexOf("realspace/")>-1;0===e.Vt&&(t.asset&&t.asset.s3mType&&o||s.isSuperMapiServer)&&(t.root.baseUrl+="data/path/");const a=t.asset.i3s,c=!!t.asset.s3mType;if(t.root.he=i,e){const r=e.Rt,s=this.gn[r];c&&!s.isS3M&&(s.isS3M=c);const i=e.boundingVolume;ot(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",i&&(e.boundingVolume=i);const o=t.root.transform;o&&(e.parent?a||(e.matrix=n.mat4.multiply([],e.parent.matrix,o)):e.matrix=o),e.Kn=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.Gn=this.Hn(e);const h=e.content&&(e.content.url||e.content.uri);h&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!a&&h&&!wt(h)&&xt(h)&&(e.content.url=e.baseUrl+h),t.root&&!e.parent&&this.Zn(e)}this.kn(),this.fire("loadtileset",{tileset:t,index:e&&e.Rt,url:r})}Vn(t,e,n){if(t.Wt=1/0,0===t.Vt||t.Gn)return this.Zn(t),1;if(this.$n(t),!this.Wn(t,e,n))return-1;if(0===t.geometricError)return 1;let r=this.Pt(t.Rt).maximumScreenSpaceError;null==r&&(r=16);let s=this.Yn(t);return 0===s&&t.parent&&(s=.5*(t.parent.Qn||0)),s>=r?1:0}Ce(t,e){e||(e=new s.Point(0,0));const n=this.getMap();return n.getGLZoom?n.coordToPoint(t,n.getGLZoom(),e):n.coordToPointAtRes(t,n.getGLRes(),e)}Wn(t,e,n){const r=t.id;let i=this.ye[r];const{boundingVolume:o}=t,c=o.region,h=o.box,u=o.sphere,d=this.tr(t.Rt);if(!i||i.version!==d.version){if(c)i=this.ye[r]=this.er(t);else if(h)i=this.ye[r]=this.nr(t);else if(u){i=this.ye[r]=this.rr(t);const e=yn(ni,u),n=new s.Coordinate(e);i.center=n}i.version=d.version,t.Yt&&(this.getRenderer().we(t.Yt),delete t.Yt)}return this.Pt(t.Rt).debug&&(this.ye[r].node=t,this.getRenderer().ge(t)),i.obbox?function(t,e,n){f(t);for(var r=0;r<6;r++){if(!n||"0"!==n.charAt(r))if(!l(a[r],e))return!1}return!0}(n,i.obbox):!!u&&function(t,e,n){f(t);for(var r=e[0],s=-e[1],i=0;i<6;i++){if(!n||"0"!==n.charAt(i))if(m(a[i],r)<s)return!1}return!0}(n,i)}er(t){const e=this.getMap(),r=e.getGLRes(),i=t.boundingVolume.region;let{ws:o,en:a}=function(t){const e=t[0],n=t[1],r=t[2],s=t[3],i=t[4],o=t[5],a=fn([],e,n,i),c=fn([],r,s,o),h=yn(a,a),u=yn(c,c);return{ws:h,en:u}}(i);o=new s.Coordinate(o),a=new s.Coordinate(a);const c=e.coordToPointAtRes(o,r);c.z=e.altitudeToPoint(o.z,r);const h=e.coordToPointAtRes(a,r);h.z=e.altitudeToPoint(a.z,r);const u=[h.x,c.y,h.z,h.x,h.y,h.z,c.x,h.y,h.z,c.x,c.y,h.z,h.x,c.y,c.z,h.x,h.y,c.z,c.x,h.y,c.z,c.x,c.y,c.z],l=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],f=this.tr(t.Rt);t!==f||f.sr||(f.sr=l);const d=this.Ee([],t),m=n.mat4.exactEquals(wi,d);if(!m){n.vec3.transformMat4(l,l,d);const t=ni;for(let e=0;e<u.length;e+=3){let r=n.vec3.set(t,u[e],u[e+1],u[e+2]);m||(r=n.vec3.transformMat4(r,r,d)),u[e]=r[0],u[e+1]=r[1],u[e+2]=r[2]}}const p=e.pointAtResToCoord(new s.Point(l),r);p.z=(o.z+a.z)/2;const b=this.ir(u,l);for(let t=0;t<u.length;t++)u[t]-=l[t%3];return{obbox:b,boxPosition:u,boxCenter:l,center:p}}nr(t){const e=this.getRenderer(),r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),i=r.getGLRes(),{boxCenter:o,boxCoord:a}=this.or(t),c=t.boundingVolume.box,h=function(t,e,n){return function(t,e,n,r,s,i,o,a,c,h,u,l,f,d,m,p,b){return t[0]=e||0,t[1]=i||0,t[2]=h||0,t[3]=d||0,t[4]=n||0,t[5]=o||0,t[6]=u||0,t[7]=m||0,t[8]=r||0,t[9]=a||0,t[10]=l||0,t[11]=p||0,t[12]=s||0,t[13]=c||0,t[14]=f||0,t[15]=b||0,t}(t,e[0],e[3],e[6],n[0],e[1],e[4],e[7],n[1],e[2],e[5],e[8],n[2],0,0,0,1)}([],this.ar(c,t.matrix),c),u=this.Ee([],t),l=n.mat4.exactEquals(wi,u);l||n.vec3.transformMat4(o,o,u);const f=[],d=ni;for(let t=0;t<xi.length;t+=3){d[0]=xi[t],d[1]=xi[t+1],d[2]=xi[t+2],n.vec3.transformMat4(d,d,h),yn(d,d),s&&e.Sn(d,d);const o=fi.set(...d);let a=r.coordToPointAtRes(o,i,di);a=n.vec3.set(d,a.x,a.y,r.altitudeToPoint(o.z,i)),l||(a=n.vec3.transformMat4(a,a,u)),f[t]=a[0],f[t+1]=a[1],f[t+2]=a[2]}const m=this.ir(f,o);for(let t=0;t<f.length;t++)f[t]-=o[t%3];return{obbox:m,boxPosition:f,boxCenter:o,center:a}}rr(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),i=t.boundingVolume.sphere,o=i;let a=ni;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:yn(a,o),r&&n.Sn(a,a);const c=new s.Coordinate(a),h=this.Ce(c,di).toArray();h[2]=e.altitudeToPoint(c.z,e.getGLRes());const u=this.cr(c);return[h,i[3]*u[2]]}ir(t,e){const r=Ni(oi,t,0,1,4,5),s=Ni(ai,t,0,3,4,7),i=Ni(ci,t,0,1,2,3);return[...e,...n.vec3.sub(ni,r,e),...n.vec3.sub(ri,s,e),...n.vec3.sub(si,i,e)]}or(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),i=e.getGLRes(),o=t.boundingVolume.box.slice(0,3);yn(o,o),r&&n.Sn(o,o);const a=new s.Coordinate(o),c=e.coordToPointAtRes(a,i);return{boxCenter:[c.x,c.y,e.altitudeToPoint(a.z,i)],boxCoord:a}}Ee(t,e){const r=this.tr(e.Rt),s=this.Pt(e.Rt),i=r.sr,o=n.mat4.fromTranslation(pi,n.vec3.set(ni,-i[0],-i[1],-i[2])),a=n.mat4.fromTranslation(bi,i),c=s.rotation||Ti,h=n.quat.fromEuler(ui,...c),u=s.scale,l=u&&n.vec3.set(Mi,u,u,u)||_i,f=n.mat4.fromRotationTranslationScale(gi,h,Oi,l);return t=n.mat4.multiply(t,f,o),n.mat4.multiply(t,a,t)}Zn(t){const e=this.Pt(t.Rt);if(!t.boundingVolume||this.hr(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,s=t.boundingVolume.sphere;let i=null;if(n){i=this.ur(t).boxCenter}else if(r){i=this.lr(t).boxCenter}else s&&(i=this.rr(t)[0]);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.dr=[a[0]||0,a[1]||0],t.mr=o,t.sr=i}hr(t,e){if(!t.dr)return!1;const n=e.coordOffset||vi;return t.dr[0]===n[0]&&t.dr[1]===n[1]&&t.mr===(e.heightOffset||0)}lr(t){return t.boundingVolume?(this.$n(t),this.er(t)):null}ur(t){return t.boundingVolume?(this.$n(t),this.or(t)):null}ar(t,e){let r=t.slice(3,12);const s=n.mat3.fromMat4(mi,e);return r=n.mat3.multiply(r,s,r),r}cr(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let s;return s=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:r.y/100,n.vec3.set(hi,r.x/100*1.01,r.y/100*1.01,s),hi}Jn(t){Array.isArray(t)&&(t=new s.Coordinate(t));let e=this.options.offset;if(at(e)&&(e=e.call(this,Array.isArray(t)?new s.Coordinate(t):t)),e[0]||e[1]){const n=this.getMap(),r=n.getGLRes(),s=n.coordToPointAtRes(t,r);return s._sub(e),n.pointAtResToCoord(s,r)}return t}tr(t){return this.gn[t]}Fn(t){const e=this.Pt(t).maxExtent;if(!e)return null;const n=this.gn[t];return n.maxExtent||(n.maxExtent=new s.Extent(e).convertTo(t=>this.Ce(t))),n.maxExtent}Yn(t){const e=this.Dn,n=t.geometricError;if(0===n)return t.Qn=0,0;const r=this.Pt(t.Rt).scale||1,s=this.getMap();let i;t.boundingVolume.region?i=function(t,e,n){t.pr||(t.pr=new Qs(t.boundingVolume.region));return t.pr.distanceToCamera(e,n)}(t,this.Un,this.Bn):t.boundingVolume.sphere?i=Ii(t.boundingVolume,this.Un):t.boundingVolume.box&&(i=Si(t.boundingVolume,this.Un));const o=Math.max(Math.abs(i),1e-7),a=n*r*s.height/(o*e);return t.Wt=i,t.Qn=a,a}kn(){const t=this.getRenderer();t&&t.setToRedraw()}ve(t){return this.ye[t]}identify(t,e={}){const n=this.getMap(),r=this.getRenderer();if(!n||!r)return[];const i=n.coordToContainerPoint(new s.Coordinate(t));return this.identifyAtPoint(i,e)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&Tt(n,r)}const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];const i=r.getDevicePixelRatio();return Tt(n,s.pick(t.x*i,t.y*i,e)),n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Re():[]}highlight(t){const e=this.getRenderer();return e?(e.highlight(t),this):(this.Ut||(this.Ut=[]),this.Ut.push(t),this)}On(){if(this.Ut){for(let t=0;t<this.Ut.length;t++)this.highlight(this.Ut[t]);delete this.Ut}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Ft||(this.Ft=[]),this.Ft.push(t),this)}br(){if(this.Ft){for(let t=0;t<this.Ft.length;t++)this.showOnly(this.Ft[t]);delete this.Ft}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);const r=this.getRenderer();return r?(r.setToRedraw(),this):this}setServiceDebugBoundingVolume(t,e){const n=this.options.services[t];n&&(n.debug=e);const r=this.getRenderer();return r?(r.setToRedraw(),this):this}Ln(t){const e=this.getMap(),n=e.getGLRes();yi.set(t[0],t[1]);const r=e.pointAtResToCoord(yi,n);return"identity"===e.getProjection().code.toLowerCase()?(ri[0]=r.x,ri[1]=r.y,this.getRenderer().En(ni,ri),r.set(ni[0],ni[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function Ii(t,e){const r=t.sphere,s=n.vec3.dist(r,e),i=t.sphere[3];return s<i?0:s-i}function Si(t,e){const r=t.box;return Ns(n.vec3.set(ni,r[0],r[1],r[2]),n.mat3.set(mi,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}function Ei(t,e,r){const s=(t=ft(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,service:r,visible:it(r.visible)?1:r.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.mat4.identity([]),Rt:e,Vt:0,domainKey:s}}function Ni(t,e,r,s,i,o){return r=n.vec3.set(ni,e[3*r],e[3*r+1],e[3*r+2]),s=n.vec3.set(ri,e[3*s],e[3*s+1],e[3*s+2]),i=n.vec3.set(si,e[3*i],e[3*i+1],e[3*i+2]),o=n.vec3.set(ii,e[3*o],e[3*o+1],e[3*o+2]),t[0]=(r[0]+s[0]+i[0]+o[0])/4,t[1]=(r[1]+s[1]+i[1]+o[1])/4,t[2]=(r[2]+s[2]+i[2]+o[2])/4,t}function Ci(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function Pi(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?n.vec2.exactEquals(t,e):n.vec3.exactEquals(t,e):t===e}Ai.mergeOptions(ei),Ai.registerRenderer("gl",Is),Ai.registerJSONType("Geo3DTilesLayer");let Ri=null;function ki(){return Ri||(Ri={"image/crn":hs.crn&&hs.crn(),"image/ktx2":hs.ktx2&&hs.ktx2(),"image/cttf":hs.ktx2&&hs.ktx2(),"draco":hs.draco&&hs.draco()}),Ri}class Li{constructor(t,e,n){this.i=t,this.gr=e||Ue,this.o=n,this.yr=ki()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.wr(t,e,n,r,s)):ye.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.wr(t,s,n,r)})}wr(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.vr(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.gr(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.yr,supportedFormats:this.o,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then(e=>{e.url=`${t}-${n}-${r}`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}})}vr(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),h=s.getUint32(20,!0),u=s.getUint32(24,!0),l=28+e;h>=570425344?(l-=8,o=a,h=c,u=0,a=0,c=0):u>=570425344&&(l-=4,o=h,h=a,u=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=En(t,l,a),l+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(l+=c),h>0&&(m=Nn(t,l,h),l+=h,u>0)){const e=Cn(0,l,u);p=t.slice(e.offset,e.offset+e.byteLength),l+=u,f.push(p)}const b=d.BATCH_LENGTH,g={};if(d&&d.BATCH_ID){g.BATCH_ID=Rn(d.BATCH_ID,t,(void 0).offset,b);const e=g.BATCH_ID.array&&g.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:g,glb:{buffer:t,byteOffset:l,byteLength:s.byteLength+s.byteOffset-l}}}Tr(){return null}}class Bi{constructor(t,e,n,r){this.i=t,this.gr=e||Ue,this.o=n,this.yr=ki(),this._r=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.wr(t,e,n,r,s)):ye.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.wr(t,s,n,r)})}wr(t,e,n,r,s){return this.Mr(t,e,n,r,s).then(({gltf:s,transferables:i})=>{const o=this.Or(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})})}Mr(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.yr,supportedFormats:this.o,maxTextureSize:i},a=new DataView(e,n,r),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 r=pt(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?ye.getArrayBuffer(r,{}).then(t=>this.xr(r,{buffer:t.data,byteOffset:0},o)):ye.getJSON(r,{}).then(t=>this.xr(r,t,o))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.xr(t,r,o)}}xr(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.gr(r,e,n);return s.load({skipAttributeTransform:!0}).then(n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=`${t}-${r}-${i}`,{transferables:s.transferables,gltf:n}})}Or(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:u}=Vn(s,32+e,o),l={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;l.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Ar(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Rn(a.BATCH_ID,t,c.offset,f);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:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).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:f,componentType:5126,array:this.Ir(new Uint16Array(t,e+c.offset,2*f))},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Ir(new Uint16Array(t,e+c.offset,2*f))},o.push(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).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:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:h,batchTableBin:u,featureTable:a,i3dm:l,transferables:o}}Ir(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)Ui(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}Ar(t,e,n){return jn(new Float32Array(t.length),t,e,n)}Tr(){return null}}function Ui(t,e,n,r){if(t[0]=Di(e,r),t[1]=Di(n,r),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]))*Fi(e),t[1]=(1-Math.abs(e))*Fi(t[1])}return qt(t,t)}function Di(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function Fi(t){return t<0?-1:1}class ji{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.wr(t,e,n,r)):ye.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.wr(t,s,n,r)})}wr(t,e,n,r){return this.Sr(e,n,r,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})}Sr(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:u}=Vn(s,e+28,o),l=a.QUANTIZED_VOLUME_OFFSET,f=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,p={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){p=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,p.byteOffset+c.offset,p.byteLength);const e={attributes:p.properties,useUniqueIDs:!1};return this.Er||(this.Er=ki().draco),this.Er(m,e).then(e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.Nr(t,e.attributes,c.offset,d,o,l,f);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Fn(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?r.BATCH_ID=Rn(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Vi(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:r,transferables:o}})}const b=this.Nr(t,a,c.offset,d,o,l,f);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?b.BATCH_ID=Rn(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=Vi(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:b,transferables:o})}Nr(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:h}=e.POSITION_QUANTIZED;c=c||0;const u=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Ar(h||new Uint16Array(t,c+u,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}Ar(t,e,n){return jn(new Float32Array(t.length),t,e,n)}Tr(){return null}}function Vi(t){const e=yt(t),n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Fn(e),array:n}}class qi{constructor(t,e,n,r){this.o=n,this.i=t,this.gr=e||Ue,this._r=r}load(t,e,n=0,r=0,s){return e?this.wr(t,e,n,r,s):ye.getArrayBuffer(t,{}).then(e=>{const s=e.data;return this.wr(t,s,n,r)})}wr(t,e,n,r,s){r||(r=e.byteLength);const i=this.Cr(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new Li(this.i,this.gr,this.o);else if("i3dm"===i[n].magic)r=new Bi(this.i,this.gr,this.o,this._r);else if("pnts"===i[n].magic)r=new ji;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new qi(this.i,this.gr,this.o,this._r)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then(t=>t))}return Promise.all(o).then(t=>({magic:"cmpt",tiles:t}))}Cr(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=In(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(i.transcoders){const t=s.Map.VERSION;if(t.indexOf("1.0.0-beta")>=0||t.indexOf("1.0.0-alpha")>=0){const t=i.transcoders.inject(o);s.registerWorkerAdapter("@maptalks/3dtiles",t)}else s.registerWorkerAdapter("@maptalks/3dtiles",(function(){return i.transcoders.inject(o)}))}else s.registerWorkerAdapter("@maptalks/3dtiles",o);t.B3DMLoader=Li,t.CMPTLoader=qi,t.Geo3DTilesLayer=Ai,t.Geo3DTilesUtil=Ot,t.Geo3DTransform=xn,Object.defineProperty(t,"t",{value:!0}),"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.97.2")}));
|
|
22
|
+
*/(100,1),Ps=[0,0,0,1],Rs=[1,1,1];class Bs{constructor(t,e){this.it=e,this.ot=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.ct=t,this.ht=new n.reshader.Renderer(t),this.ut={},this.lt={},this.ft={},this.dt={},this.bt={},this.gt={},this.yt=new n.reshader.Scene,this.wt=new n.reshader.Scene,this.vt=new n.reshader.Scene,this.Tt=new n.reshader.Scene,this._t=new n.reshader.ResourceLoader(t.texture(2)),this.Mt=this.Ot.bind(this),this.At=new n.reshader.KHRTechniquesWebglManager(this.ct,this.xt(),this._t);const r=this.getMap();this.It=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this.dt}getPNTSMeshes(){return this.ft}getB3DMMeshes(){return this.lt}getPaintedMeshes(){return this.St}getMap(){return this.it.getMap()}paint(t,e,r,s){const i=s&&s.renderTarget,o=s&&s.sceneFilter,a=this.getMap();if(!t.length||!a)return null;const c=this.Et(),h=a.projViewMatrix,u=[],f=[],d=[],m=[],p=[];for(let r=0,i=t.length;r<i;r++){const i=t[r].data.node;let o=this.Ct(i);if(!o)continue;const a=this.it.Nt(i.kt),c=a.debugNodes,b=a.heightOffset||0,g=a.coordOffset||as;this.bt[i.id]&&(o=this.bt[i.id],o=St(o));let y=a.polygonOffset||ts;yt(y)&&(y=y()),Array.isArray(o)||(u[0]=o,o=u);for(let a=0,u=o.length;a<u;a++){const u=o[a].properties.magic;if(o[a].properties.heightOffset===b&&o[a].properties.coordOffset[0]===g[0]&&o[a].properties.coordOffset[1]===g[1]||(this.Pt(o[a]),o[a].Rt=n.mat4.copy([],o[a].localTransform)),o[a].Bt=i,"b3dm"===u){if(o[a].getBoundingBox&&!l(h,o[a].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=o[a].geometry.properties;if(t&&e){const t=o[a].properties.node.kt;this.Lt&&this.Lt[t]?n.HighlightUtil.highlightMesh(this.ct,o[a],this.Lt[t],this.Ut,e):this.Lt&&this.Lt[t]||n.HighlightUtil.highlightMesh(this.ct,o[a],null,this.Ut,e),n.HighlightUtil.showOnly(this.ct,o[a],this.Dt&&this.Dt[t],this.Ft,e)}if(c&&c.length&&c.indexOf(o[a].Bt.id)<0)continue;s&&s.bloom&&o[a].properties.hlBloomMesh&&(o[a].properties.hlBloomMesh.properties.depthFunc="always",o[a].properties.hlBloomMesh.properties.polygonOffset=y,d.push(o[a].properties.hlBloomMesh)),d.push(o[a])}else"pnts"===u?m.push(o[a]):"i3dm"===u&&p.push(o[a]);o[a].properties.isLeaf=!!e[i.id],o[a].properties.selectionDepth=255-t[r].selectionDepth,o[a].properties.polygonOffset=y,e[i.id]||f.push(o[a]),this.Gt(o[a]),this.jt(o[a],i)}}let b=0;const g=this.At.getExcludeFilter();n.ContextUtil.setIncludeUniformValues(c,s),b+=this.qt(this.zt,c,[o,hs,g],i,f,d,p),b+=this.qt(this.Vt,c,[o,us,g],i,f,d,p),this.At.forEachShader(((t,e,n)=>{const r=this.Et(n);b+=this.qt(t,r,[o,e],i,f,d,p)})),this.wt.setMeshes(m);const y=this.Ht();return b+=this.ht.render(this.$t,y,this.wt,i&&i.fbo),this.St={pntsMeshes:m,i3dmMeshes:p,b3dmMeshes:d},this.Tt.setMeshes(r),this.ht.render(this.Xt,c,this.Tt,i&&i.fbo),b}prepareRender(t){this.Kt(t)}Kt(t){t&&t.states&&t.states.includesChanged&&(this.Vt.dispose(),delete this.Vt,this.zt.dispose(),delete this.zt),this.Jt(t)}qt(t,e,n,r,s,i,o){t.filter=n.filter((t=>!!t)),e.stencilEnable=!1;const a=r&&r.fbo;let c=0;const h=[];for(let n=0;n<i.length;n++){const{isLeaf:r,selectionDepth:s}=i[n].properties;r&&255===s?(e.stencilEnable&&(this.Zt(a),this.yt.setMeshes(h),c+=this.ht.render(t,e,this.yt,a),h.length=0,e.stencilEnable=!1),h.push(i[n])):(e.stencilEnable||(this.yt.setMeshes(h),c+=this.ht.render(t,e,this.yt,a),h.length=0,e.stencilEnable=!0),h.push(i[n])),n===i.length-1&&(e.stencilEnable&&this.Zt(a),this.yt.setMeshes(h),c+=this.ht.render(t,e,this.yt,a))}return this.yt.setMeshes(i.filter((t=>t.properties.isLeaf))),this.vt.setMeshes(o),c+=this.ht.render(t,e,this.vt,r&&r.fbo),c}Zt(t){this.ct.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.yt.getMeshes()}getCurrentI3DMMeshes(){return this.vt.getMeshes()}Wt(t,e){return e.Bt.Yt-t.Bt.Yt}deleteTile(t){const e=t.node;e.Qt&&(e.Qt.geometry.dispose(),e.Qt.dispose(),delete e.Qt);const n=e.id;this.te(n)}te(t){const e=this.lt[t]||this.ft[t]||this.dt[t]||this.bt[t]||this.ut[t];this.bt[t]?this.ee(t):e&&(this.ne(e),delete this.lt[t],delete this.ft[t],delete this.dt[t],delete this.ut[t])}ee(t){let e=this.bt[t];e=St(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.te(n)}delete this.bt[t]}ne(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.ne(t[e]);else{n.HighlightUtil.showOnly(this.ct,t),n.HighlightUtil.highlightMesh(this.ct,t);const e=t.geometry.properties.url;if(e){const n=this.gt[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.gt[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.it;Wr(t.getRenderer().canvas,t.getMap());for(const t in this.bt)this.ee(t);this.bt={};for(const t in this.lt)this.te(t);this.lt={};for(const t in this.ft)this.te(t);this.ft={};for(const t in this.dt)this.te(t);this.dt={};for(const t in this.ut)this.te(t);this.ut={},this.zt&&(this.zt.dispose(),delete this.zt),this.Vt&&(this.Vt.dispose(),delete this.Vt),this.$t&&(this.$t.dispose(),delete this.$t),this.Xt&&(this.Xt.dispose(),delete this.Xt),this.At.dispose(),this.picking&&this.picking.dispose()}Ct(t){return this.lt[t.id]||this.ft[t.id]||this.dt[t.id]||this.bt[t.id]}has(t){return this.Ct(t)||this.ut[t.id]}Pt(t){const e=t.properties.magic;"b3dm"===e?this.re(t):"i3dm"===e?this.se(t):"pnts"===e&&this.ie(t)}createPntsMesh(t,e,r,s){if(this.ft[e]){const t=this.ft[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:i,featureTable:o,rootIdx:a,compressed_int16_params:c}=t,h=o.POINTS_LENGTH;i.BATCH_ID||(i.BATCH_ID=new Uint8Array(h),i.BATCH_ID.fill(0));const u=new n.reshader.Geometry(i,null,h,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.ct);const l={};i.POSITION?l.HAS_POSITION=1:i.POSITION_QUANTIZED&&(l.HAS_POSITION_QUANTIZED=1),i.RGB?l.HAS_RGB=1:i.RGBA?l.HAS_RGBA=1:i.RGB565&&(l.HAS_RGB565=1),(i.NORMAL||i.NORMAL_OCT16P)&&(l.HAS_NORMAL=1,i.NORMAL_OCT16P&&(l.HAS_NORMAL_OCT16P=1)),this.oe(l,c),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:f,rtcCoord:d,projCenter:m}=t,p=this.it.Nt(a),b=new n.reshader.Mesh(u);b.properties.magic="pnts",b.properties.id=e,b.properties.node=r,b.properties.count=h,b.properties.batchTable=t.batchTable,b.properties.batchTableBin=t.batchTableBin,b.properties.serviceIndex=a,b.properties.rtcCoord=d,b.properties.rtcCenter=f,b.properties.projCenter=m,b.setDefines(l),b.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:p&&p.pointColor||[1,1,1,1]}));const g=this.getMap();let y=null,w=null;b.setFunctionUniform("pointSize",(function(){if(!p)return 2;if(Dr(p.pointSize)){const t=JSON.stringify(p.pointSize);t!==y&&(w=Fr(p.pointSize),y=t);return w(g.getZoom())}return p.pointSize||2}));let v=null,T=null;return b.setFunctionUniform("pointOpacity",(function(){if(!p)return 1;if(Dr(p.pointOpacity)){const t=JSON.stringify(p.pointOpacity);t!==v&&(T=Fr(p.pointOpacity),v=t);return T(g.getZoom())}return p.pointOpacity||1})),this.ae(b,c),this.ie(b),b.Rt=n.mat4.copy([],b.localTransform),this.ft[e]=b,s(null,{id:e,mesh:[b]}),[b]}ie(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:s}=t.properties;this.ce(e,n,s,r.kt),t.setLocalTransform(e)}createI3DMMesh(t,e,r,s){if(this.dt[e]){const t=this.dt[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.ut[e]||s(null,{id:e,mesh:t}),t}const i=this.it.Nt(r.kt),o=this.he(r.ue),{i3dm:a,featureTable:c,gltf:h,batchTable:u,batchTableBin:l,count:f}=t,d=c.INSTANCES_LENGTH,{rtcCenter:m,rtcCoord:p,projCenter:b}=t,g=this.le(ws,r,m,p);fr(g,os,g);const y=n.mat4.getRotation(vs,g);n.quat.normalize(y,y);const w=n.mat4.getScaling(Ts,g),v=n.mat4.fromScaling(_s,w),T=this.fe(Ms,b,r),_=this.de(xs),M=this.me(Is,p),O=n.vec3.div(Ss,M,_),A=n.mat4.fromScaling(Es,O),{POSITION:x,NORMAL_UP:I,NORMAL_RIGHT:S,SCALE:E,SCALE_NON_UNIFORM:C}=a,N={"instance_vectorA":new Float32Array(4*d),"instance_vectorB":new Float32Array(4*d),"instance_vectorC":new Float32Array(4*d),"aPickingId":new Uint16Array(d)};for(let t=0;t<d;t++)N.aPickingId[t]=t;const k=new Float32Array(3),P=new Float32Array(3),R=[],B=new Float32Array(1),L=new Float32Array(3),U=[],D=[],F=[],G=[];!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?Ze.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===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 h=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);h.set(s),e(new c(h.buffer),t),s.set(h)}}(x,((t,e)=>{I?(Tn(P,S,e),Tn(k,I,e),n.vec3.cross(R,P,k),n.vec3.normalize(R,R),It(U,P,0),It(U,k,1),It(U,R,2),n.quat.fromMat3(D,U),n.quat.normalize(D,D),n.quat.multiply(D,y,D)):n.quat.identity(D),E?(Tn(B,E,e),n.vec3.set(F,B[0],B[0],B[0])):C?(Tn(L,C,e),n.vec3.set(F,...L)):n.vec3.set(F,1,1,1),n.mat4.fromRotationTranslationScale(G,D,t,F),_n(N.instance_vectorA,e,G,0),_n(N.instance_vectorB,e,G,1),_n(N.instance_vectorC,e,G,2)}));const j={};for(const t in N)j[t]={buffer:this.ct.buffer({dimension:N[t].length/d,data:N[t]}),divisor:1};const q=i.shader||"pbr";let z=0,V=!0;const H=[],$=[];return dn(h,((t,s,i,a)=>{const h=this.pe(t,s,i,a,r,!0,q,$),{geometry:y,material:w}=h;w&&!w.isReady()&&(V=!1,z++);const _=new n.reshader.InstancedMesh(j,d,y,w);h.refMeshes||(h.refMeshes=new Set,h.refMeshes.add(_.uuid)),_.properties.magic="i3dm",_.properties.id=e,_.properties.count=f,_.properties.batchTable=u,_.properties.batchTableBin=l,_.properties.serviceIndex=r.kt,_.properties.rtcCoord=p,_.properties.rtcCenter=m,_.properties.projCenter=b,_.properties.node=r;const M=this.be(t,y,w,r.kt,a);t.compressed_int16_params&&this.ae(_,t.compressed_int16_params),this.ge(_,t.attributes);const O=n.mat4.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.mat4.multiply(O,O,t.matrices[e]);n.mat4.multiply(O,o,O),n.mat4.multiply(O,A,O),c.EAST_NORTH_UP||I?n.mat4.multiply(O,v,O):n.mat4.multiply(O,g,O),_.setPositionMatrix(O),this.se(_,T),_.setDefines(M),_.properties.polygonOffset={offset:0,factor:0},H.push(_),delete t.attributes,_.Rt=n.mat4.copy([],_.localTransform)})),Ls($),V?(this.dt[e]=H,s(null,{id:e,mesh:H})):(this.ut[e]={meshes:H,count:z},H.ye=s),H}se(t,e){const{rtcCoord:r,node:s,projCenter:i}=t.properties;e||(e=this.fe(Ms,i,s));const o=this.it.Nt(s.kt),a=t.localTransform||[];if(o.coordOffset){const t=this.we(ws,s.kt,r);n.mat4.multiply(a,t,e)}else n.mat4.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||as}fe(t,e,r){n.mat4.fromScaling(t,this.de(xs));const s=this.ve(gs,e,r.kt);return n.mat4.multiply(t,n.mat4.fromTranslation(Os,s),t),t}createB3DMMesh(t,e,r,i){if(t.gltf&&(t.gltf.transferables=null),this.lt[e]||this.ut[e]){const t=this.lt[e];return console.warn(`mesh with id(${e}) was already created.`),this.ut[e]||i(null,{id:e,mesh:t}),t}let o;if(r.maxExtent){const t=new s.Extent(r.maxExtent).convertTo((t=>this._pointToPrj(t)));o=[t.xmin,t.ymin,t.xmax,t.ymax]}const a=t.gltf,{projCenter:c}=a.extensions.MAPTALKS_RTC,{rtcCoord:h,center:u}=a.extensions.CESIUM_RTC,l=a.asset.sharePosition,f=this.he(r.ue),d=this.Te(Ms,l,h,u,c,r),m=this.it.Nt(r.kt);let p=m.shader||"pbr";if(m.unlit)p="phong";else if(a.materials)for(let t=0;t<a.materials.length;t++)if(a.materials[t]&&a.materials[t].extensions&&a.materials[t].extensions.KHR_materials_unlit){p="phong";break}const b=[],g=[];let y=0,w=!0;return dn(a,((s,i,a,v)=>{const T=this.pe(s,i,a,v,r,!1,p,b),{geometry:_,material:M}=T;M&&!M.isReady()&&(w=!1,y++);const O=new n.reshader.Mesh(_,M);T.refMeshes||(T.refMeshes=new Set,T.refMeshes.add(O.uuid)),O.properties.magic="b3dm",O.properties.id=e,O.properties.node=r,t.batchTable&&(O.properties.batchTable=t.batchTable,O.properties.batchTableBin=t.batchTableBin),O.properties.count=t.featureTable&&t.featureTable.BATCH_LENGTH||0,O.properties.serviceIndex=r.kt;const A=this.be(s,_,M,r.kt,v);O.setDefines(A);const x=s.compressUniforms;if(x)for(const t in x)O.setUniform(t,x[t]);s.compressed_int16_params&&this.ae(O,s.compressed_int16_params),this.ge(O,s.attributes),o&&(A.USE_MAX_EXTENT=1,O.setUniform("maxPrjExtent",o)),O.hasFunctionUniform("polygonOpacity")||O.setFunctionUniform("polygonOpacity",(function(){return vt(m.opacity)?m.opacity:1})),O.hasFunctionUniform("polygonFill")||O.setFunctionUniform("polygonFill",(function(){return Rt([],m.polygonFill||es)})),O.material.hasFunctionUniform("hsv")||O.material.setFunctionUniform("hsv",(function(){return m.hsv||ns}));const I=n.mat4.identity([]);if(l&&s.matrices&&s.matrices.length)for(let t=0;t<s.matrices.length;t++)n.mat4.multiply(I,I,s.matrices[t]);l&&n.mat4.multiply(I,f,I),O.properties.node=r,O.properties.projCenter=c,O.properties.nodeMatrix=I,O.properties.isSharedPosition=l,O.properties.rtcCoord=h,O.properties.rtcCenter=u,this.re(O,d),g.push(O),delete s.attributes,O.Rt=n.mat4.copy([],O.localTransform)})),Ls(b),w?(this.lt[e]=g,i(null,{id:e,mesh:g})):(this.ut[e]={meshes:g,count:y},g.ye=i),g}_e(t){const e=this.it.Me(t.id);if(!e||t.Qt)return;let r,s,i,o;if(e.obbox)r=e.boxPosition,s=Ns,i=e.boxCenter,o=Rs;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];r=ks.vertices,s=ks.indices,i=t,o=[n,n,n]}const a=new n.reshader.Geometry({POSITION:r},s,0,{primitive:"lines",positionAttribute:"POSITION"}),c=new n.reshader.Mesh(a,new n.reshader.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),h=[];n.mat4.fromRotationTranslationScale(h,Ps,i,o),c.localTransform=h,c.Rt=n.mat4.copy([],h),c.properties.node=t,t.Qt=c}Oe(t){t.Qt&&(t.Qt.geometry.dispose(),t.Qt.dispose(),delete t.Qt)}ae(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}re(t,e){const{isSharedPosition:r,rtcCoord:s,rtcCenter:i,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this.Te(e||Ms,r,s,i,o,c));const h=t.localTransform||n.mat4.identity([]);n.mat4.multiply(h,e,a);const u=this.it.Nt(c.kt);if(u.coordOffset){const t=this.we(ws,c.kt,s);n.mat4.multiply(h,t,h)}t.setLocalTransform(h),t.properties.heightOffset=u.heightOffset||0,t.properties.coordOffset=u.coordOffset&&u.coordOffset.slice(0)||as}Te(t,e,r,s,i,o){if(e){const e=this.me(Is,r),i=n.mat4.fromScaling(ys,e),a=this.le(ws,o,s,r);n.mat4.multiply(t,a,i)}else this.ce(t,r,i,o.kt);return t}ge(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}le(t,e,r,s){const i=this.getMap(),o=this.it.Nt(e.kt).heightOffset||0,a=e.matrix?n.mat4.copy(t,e.matrix):n.mat4.identity(t);if(r){fr(a,n.vec3.transformMat4(ls,r,a),a)}const c=function(t,e,n,r,s,i,o){e=Kt(mr,e);const a=In(mr,e[0]*Mr,e[1]*Mr,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(pr,n),h=r.ellipsoid;let u;u=0===ie(c)?Jt(br,0,0,-6378137):Pn(br,c),Tr.x=u[0],Tr.y=u[1];const l=r.project(Tr,_r);gr[0]=l.x/s,gr[1]=l.y/s,gr[2]=(u[2]+o)*i;const f=dr(a,h,yr),d=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],h=e[7],u=e[8],l=e[9],f=e[10],d=e[11],m=e[12],p=e[13],b=e[14],g=e[15],y=n*a-r*o,w=n*c-s*o,v=n*h-i*o,T=r*c-s*a,_=r*h-i*a,M=s*h-i*c,O=u*p-l*m,A=u*b-f*m,x=u*g-d*m,I=l*b-f*p,S=l*g-d*p,E=f*g-d*b,C=y*E-w*S+v*I+T*x-_*A+M*O;return C?(C=1/C,t[0]=(a*E-c*S+h*I)*C,t[1]=(s*S-r*E-i*I)*C,t[2]=(p*M-b*_+g*T)*C,t[3]=(f*_-l*M-d*T)*C,t[4]=(c*x-o*E-h*A)*C,t[5]=(n*E-s*x+i*A)*C,t[6]=(b*v-m*M-g*w)*C,t[7]=(u*M-f*v+d*w)*C,t[8]=(o*S-a*x+h*O)*C,t[9]=(r*x-n*S-i*O)*C,t[10]=(m*_-p*v+g*y)*C,t[11]=(l*v-u*_-d*y)*C,t[12]=(a*A-o*I-c*O)*C,t[13]=(n*I-r*A+s*O)*C,t[14]=(p*w-m*T-b*y)*C,t[15]=(u*T-l*w+f*y)*C,t):null}(wr,f),m=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}(vr,n);return fr(function(t,e,n){const r=t[0],s=t[1],i=t[2],o=t[4],a=t[5],c=t[6],h=t[8],u=t[9],l=t[10],f=e[0],d=e[1],m=e[2],p=e[3],b=e[4],g=e[5],y=e[6],w=e[7],v=e[8],T=r*f+o*d+h*m,_=s*f+a*d+u*m,M=i*f+c*d+l*m,O=r*p+o*b+h*g,A=s*p+a*b+u*g,x=i*p+c*b+l*g,I=r*y+o*w+h*v,S=s*y+a*w+u*v,E=i*y+c*w+l*v;return n[0]=T,n[1]=_,n[2]=M,n[3]=0,n[4]=O,n[5]=A,n[6]=x,n[7]=0,n[8]=I,n[9]=S,n[10]=E,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(d,m,t),gr,t),t}(a,s,a,i.getProjection(),i.getGLRes(),this.It,o),h=function(t,e){return Jt(t,e[12],e[13],e[14]),t}(gs,c);let u=this.it.options.offset;if(yt(u)){const t=this.it.Me(e.id).boxCoord;u=u.call(this.it,t)}return n.vec3.set(bs,u[0],u[1],0),n.vec3.sub(h,h,bs),fr(c,h,c),c}we(t,e,r){const s=this.it.Nt(e);if(!s.coordOffset)return null;const i=this.getMap(),o=i.getGLRes();fs.set(r[0],r[1]);const a=i.coordToPointAtRes(fs,o,ms),c=s.coordOffset,h=fs.set(r[0]+c[0],r[1]+c[1]),u=i.coordToPointAtRes(h,o,ps),l=u.x-a.x,f=u.y-a.y,d=this.It,m=n.vec3.set(bs,l,f,(c[2]||0)*d);return n.mat4.fromTranslation(t,m)}createCMPTMesh(t,e,n,r){if(this.bt[e]){const t=this.bt[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:s}=t,i=[];for(let t=0;t<s.length;t++){const{magic:r}=s[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"i3dm"===r?this.createI3DMMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"pnts"===r?this.createPntsMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"cmpt"===r&&this.createCMPTMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)}))}return this.bt[e]=i,r(null,{id:e,mesh:i}),i}be(t,e,n,r,s){const i=("phong"===(this.it.Nt(r).shader||"pbr")?this.zt:this.Vt).getGeometryDefines(e);s.asset&&"S3M"===s.asset.generator&&this.Ae(i,e),e.data.uvRegion&&(i.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(i.VertexNormal=1),e.data[e.desc.color0Attribute]&&(i.VertexColor=1),e.data[e.desc.uv0Attribute]&&(i.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(i.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(i.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(i.TexCoord2=1),"MESHOPT"===this.it.xe&&(i.MeshOPT_Compress=1),this.hasIBL()&&(i.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(i.HAS_WEB3D_quantized_attributes_TEXCOORD=1),i.HAS_MIN_ALTITUDE=1,i.HAS_LAYER_OPACITY=1,this.oe(i,t.compressed_int16_params);return gt(i,t.compressDefines),i}oe(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}Gt(t){const e=this.it.getRenderer();e&&e.updateMaskDefines(t)}Ae(t,e){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)}pe(t,e,r,s,i,o,a,c){let h=!1;s.asset&&"S3M"===s.asset.generator&&(h=!0,s.extensions=s.extensions||{});const u=s.url+"-"+e+"-"+r;if(this.gt[u])return this.gt[u];let l,f;c.push(t);const d=s.materials&&s.materials[t.material],m=s.extensions&&s.extensions.KHR_techniques_webgl,p=this.it.Nt(i.kt);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){const e=this.Ie(t,s,o,h);l=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.Se(t,o,Cs);const e=p.material;l=this.Ee(t.material,s,a,e||rs,c,p)}l&&(l.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return bt(t)?.1:t})),l.setFunctionUniform("environmentExposure",(()=>{const t=p.ambientLight;let e=p.environmentExposure;const n=this.getMap().getLightManager(),r=n&&n.getAmbientLight();if(t&&(!r||r.color)&&void 0===e){const n=r&&r.color?r.color[0]:.2;e=t[0]/n}return e||1}))),l&&!l.isReady()?l.Ce=i.id:l||(l=new n.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const b={geometry:f,material:l};return f.properties.url=u,this.gt[u]=b,b}Ie(t,e,n,r){const{geometry:s,material:i}=this.At.createMesh(t,e,n,r);return{geometry:s,material:i}}Se(t,e,r){const s=t.attributes,i="COLOR_0";let o=s._BATCHID&&s._BATCHID.array;if(o&&o.byteOffset&&(o=new o.constructor(o)),s[i]){const t=s[i].array||s[i];if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);s[i].array?(s[i].array=e,s[i].componentType=5121):s[i]=e}}const a={};for(const t in s){const e=Xr(this.ct,s[t],{dimension:s[t].itemSize}),n=r[t]||t;a[n]={buffer:e},s[t].quantization&&(a[n].quantization=s[t].quantization),n===r.POSITION&&(a[n].array=s[t].array,a[n].min=s[t].min,a[n].max=s[t].max)}const c=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,h=new n.reshader.Geometry(a,c,0,{static:!0,positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":$r(t.mode)});return o&&c&&(h.properties.batchIdData=o,h.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const s=e[r],i=t[s];let o=n.get(i);o||(o=[],n.set(i,o)),o.push(s)}return n}(o,c)),h.generateBuffers(this.ct,{excludeElementsInVAO:e}),h}ce(t,e,r,s){const i=n.mat4.identity(t),o=this.de(ss);return this.ve(gs,r,s),n.mat4.translate(i,i,gs),n.mat4.scale(i,i,o),i}ve(t,e,r){const s=this.It;fs.x=e[0],fs.y=e[1];const i=this._prjToPoint(fs);let o=this.it.options.offset;yt(o)&&(o=o.call(this.it,fs));const a=this.it.Nt(r).heightOffset||0;return n.vec3.set(t,i.x-o[0],i.y-o[1],s*e[2]+s*a),t}jt(t,e){const r=this.it.Ne(As,e);t.localTransform=n.mat4.multiply(t.localTransform,r,t.Rt)}me(t,e){const r=this.getMap();fs.x=e[0],fs.y=e[1];const s=r.distanceToPointAtRes(100,100,r.getGLRes(),fs),i=this.It;return n.vec3.set(t,s.x/100,s.y/100,i),t}Jt(t){if(this.Vt)return;const e={x:0,y:0,width:()=>this.ot?this.ot.width:1,height:()=>this.ot?this.ot.height:1},r=[],s=[];this.$t=new n.reshader.MeshShader({vert:Mn,frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n\n if (dot(circCoord, circCoord) > 1.0) {\n\n discard;\n\n } else {\n\n gl_FragColor = vColor;\n\n }\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>n.mat4.multiply(s,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>n.mat3.fromMat4(r,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const i={},o=[];n.ContextUtil.fillIncludes(i,o,t);const a=this.xt();this.zt=new n.reshader.PhongShader({uniforms:o,defines:i,extraCommandProps:a}),this.Vt=new n.reshader.pbr.StandardShader({uniforms:o,defines:i,extraCommandProps:a}),this.Xt=new n.reshader.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.ot?this.ot.width:1,height:()=>this.ot?this.ot.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const c=this.it;Zr(c.getRenderer().canvas,this.ct,c.getMap()),this.picking=new n.reshader.FBORayPicking(this.ht,{vert:this.Vt.vert,extraCommandProps:a,uniforms:this.Vt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.ke=new n.reshader.FBORayPicking(this.ht,{vert:Mn,extraCommandProps:a,uniforms:this.$t.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}xt(){return{viewport:{x:0,y:0,width:()=>this.ot?this.ot.width:1,height:()=>this.ot?this.ot.height:1},cull:{enable:!0},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:">=",ref:(t,e)=>e.meshProperties.selectionDepth},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:[0,1],func:(t,e)=>e.meshProperties.depthFunc||"<"},blend:{enable:!0,func:{src:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}Ht(t){const e=this.getMap(),r=e.getLightManager(),s=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],i=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:i,lightDir:n.vec3.normalize(cs,s)}}Et(){const t=this.getMap(),e=this.it,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:s}=Yr(n),i=Qr(t,r,s),o=this.it.getRenderer(),a=o.getMaskUniforms();i.minAltitude=e.options.altitude||0;const c=o.canvas.gl&&o.canvas.gl.wrap?e.options.opacity||0:1;return i.layerOpacity=c,gt(i,{czm_lightDirectionEC:i.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),gt(i,a),i}Ee(t,e,r,s,i,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=gt({},s);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.P(t,i)),c.baseColorFactor=t&&t.image.color||a.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(a.normalTexture){const t=this.P(e.textures[a.normalTexture.index],i);if(t){const e=a.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=e}}if(a.occlusionTexture){const t=this.P(e.textures[a.occlusionTexture.index],i);if(t){const e=a.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=e}}if(a.emissiveTexture){const t=this.P(e.textures[a.emissiveTexture.index],i);t&&(c.emissiveTexture=t)}a.emissiveFactor&&(c.emissiveFactor=a.emissiveFactor);const t=a.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const r=e.textures[t.baseColorTexture.index];if(r&&r.image&&r.image.color)c.baseColorFactor=c.baseColorFactor?n.vec4.multiply(c.baseColorFactor,c.baseColorFactor,r.image.color):r.image.color;else{const t=this.P(r,i);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.ct))}}if(bt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),bt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.P(e.textures[a.metallicRoughnessTexture.index],i);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.reshader.Material(c);if(o.unlit||a.extensions&&a.extensions.KHR_materials_unlit){c.ambientColor=[1,1,1],c.light0_diffuse=[0,0,0,0],c.lightSpecular=[0,0,0];const t=new n.reshader.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let h=new n.reshader.pbr.StandardMaterial(c);"phong"===r&&(h=n.reshader.PhongMaterial.convertFrom(h));const u=a.pbrMetallicRoughness,l=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return l&&l.KHR_texture_transform&&(h.set("khr_offset",l.KHR_texture_transform.offset||[0,0]),h.set("khr_rotation",l.KHR_texture_transform.rotation||0),h.set("khr_scale",l.KHR_texture_transform.scale||[1,1])),h.doubleSided=!(!o.doubleSided&&!a.doubleSided),h.once("complete",this.Mt),h}P(t,e){if(!t)return null;const r={type:t.type?Vr(t.type):"uint8",format:t.format?Hr(t.format):"rgba",flipY:!!t.flipY},s=t.image;if(e.push(s),s.array?r.data=s.array:s.mipmap&&(r.mipmap=s.mipmap),!r.data&&!r.mipmap)return null;if(r.width=s.width,r.height=s.height,r.mipmap&&(r.width<4||r.height<4))return null;const i=t.sampler||t.texture&&t.texture.sampler;return i&&(i.magFilter&&(r.mag=jr(i.magFilter)),i.minFilter&&(r.min=qr(i.minFilter)),i.wrapS&&(r.wrapS=zr(i.wrapS)),i.wrapT&&(r.wrapT=zr(i.wrapT))),new n.reshader.Texture2D(r,this._t)}Ot({target:t}){const e=t.Ce,n=this.ut[e];if(n.count--,!n.count){const t=n.meshes;this.lt[e]=t,delete this.ut[e];const r=t.ye;delete t.ye,r(null,{mesh:n.meshes,id:e})}}de(t){const e=1/this.getMap().getGLRes(),n=this.It;return t[0]=t[1]=e,t[2]=n,t}Pe(t){return this.it.Pe(t)}_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(),ds)}he(t){return"Y"===t?Kr:"X"===t?Jr:is}pick(t,e,n=3){const r=this.it;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const s=[],i=this.Et(),o=this.Re(this.picking,i,this.yt,t,e,n);o&&s.push(o);const a=this.Re(this.picking,i,this.vt,t,e,n);a&&s.push(a);const c=this.Ht(),h=this.Re(this.ke,c,this.wt,t,e,n);return h&&s.push(h),s}Re(t,e,n,r,s,i){if(!n.getMeshes().length)return null;const o=this.it,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,s,i,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:h,pickingId:u,point:l,coordinate:f}=c,d=(0===h||h)&&t.getMeshAt(h);if(!d||!d.geometry)return null;const m=d.properties;l&&l.length&&(l[0]=Math.round(1e5*l[0])/1e5,l[1]=Math.round(1e5*l[1])/1e5,l[2]=Math.round(1e5*l[2])/1e5);const p={batchId:u},b=o.options.services,g=b&&b[d.properties.serviceIndex];if(g&&g.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=u;for(const s in t)void 0!==t[s].byteOffset?p[s]=Zn(t[s],e,n,r):p[s]=t[s][r]}return{service:d.properties.serviceIndex,data:p,point:l,coordinate:f}}highlight(t){this.Lt=t;const e=this.it.getRenderer();this.Ut=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.Lt=null;const t=this.it.getRenderer();this.Ut=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Dt=t;const e=this.it.getRenderer();this.Ft=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Dt=null;const t=this.it.getRenderer();this.Ft=t.getFrameTimestamp(),t.setToRedraw(!0)}Be(){if(!this.St)return[];const t={},e=[];for(const n in this.St){const r=this.St[n];if(r)for(let n=0;n<r.length;n++){const s=r[n],i=s&&s.geometry;if(!s||!i)continue;const o=s.properties.serviceIndex;t[o]||(t[o]=new Set);const a=i.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}function Ls(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}const Us=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")},Ds=Us(),Fs=Ds.gl_trans__coders=Ds.gl_trans__coders||{};function Gs(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}Fs.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=Ds.gl_trans__coders=Ds.gl_trans__coders||{};let i=`${r}\n const _____getGlobal = ${Us.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+='tran_____scoders["'+t+'"] ='+s[t].toString()+"\n;");return i+="\n"+e.substring(r.length),i},Fs.registerTranscoder=function(t,e){Fs[t]=e},Fs.getTranscoder=function(t){return Fs[t]};const js=[];class qs{constructor(t,e,n,r,s){this.it=r,this.Le=t,this.kt=e,this.Ue=s,this.De=n.version,t.indexOf("i3s:tileset:")<0?(this.De<=1.6?this.Fe="root":this.Fe=0,n.version=this.De):(this.Fe=t.substring(12),this.De>1.6&&(this.Fe=parseInt(this.Fe))),this.Le=t,this.Ge=n}load(){const t=this.Ge,e=t.layerScene.baseUrl;if(this.De<=1.6)return t[this.Fe]&&t[this.Fe].lodSelection?(this.je=t[this.Fe],this.qe()):new Promise((n=>{let r=e+"/nodes/"+this.Fe;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Ue(this.kt,r,(()=>{this.je=t[this.Fe],n(this.qe())}))}));if(this.De>=1.7){if(t[this.Fe])return this.je=t[this.Fe],this.qe();const n=Math.floor(this.Fe/t.nodesPerPage);return new Promise((r=>{let s=e+"/nodepages/"+n;t.layerScene.eslpk&&(s+=".json"),this.Ue(this.kt,s,(()=>{this.je=t[this.Fe],r(this.qe())}))}))}return null}getTileset(){return this.ze}getChildrenURL(){return this.Ve}qe(){const t=this.Ge,e=t.layerScene.baseUrl,n=this.je.children,r=[],s={};if(n)for(let i=0;i<n.length;i++)if(this.De<=1.6){const o=n[i].id;if(t[o])continue;const a=o;s[a]||(s[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Ue(this.kt,r,(()=>{n()}))})),r.push(s[a]))}else{const o=n[i];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);s[a]||(s[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.Ue(this.kt,r,(()=>{n()}))})),r.push(s[a]))}return r.length?Promise.all(r).then((()=>this.He())):this.He()}He(){return Promise.resolve(this.$e())}Xe(t){Gs(this.Ge,t)}$e(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.Ke(this.je,!0)}}Ke(t){const e=this.it.getRenderer(),n=this.Ge.projection,r=!n||n&&4326===n.wkid,s=this.De,i=this.Ge,o=t,a=o.obb,c=o.mbs,h={};let u;if(c)u=Jt([],c[0],c[1],c[2]),r||(u=e.Je(u,u)),u=zs([],u[0],u[1],u[2]),h.sphere=[...u,c[3]];else if(a){u=Jt([],a.center[0],a.center[1],a.center[2]),r||(u=e.Je(u,u)),u=zs([],u[0],u[1],u[2]);const t=function(t,e,n){const r=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,h=n*o,u=r*o,l=r*a,f=s*o,d=s*a,m=s*c,p=i*o,b=i*a,g=i*c;return t[0]=1-l-m,t[3]=u-g,t[6]=f+b,t[1]=u+g,t[4]=1-h-m,t[7]=d-p,t[2]=f-b,t[5]=d+p,t[8]=1-h-l,t}([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(u,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],s=t[4]+t[7]+t[10],i=t[5]+t[8]+t[11];Jt(js,n,s,i);const o=ie(js);h.sphere=[...u,o]}let l=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===i.lodSelectionMetricType){l=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(l=f/o.lodSelection[t].maxError);(l===1/0||isNaN(l))&&(l=1e5);const d=16*l,m=Gt([]),p=o.children;let b;if(p){b=[];const t=this.Ge;for(let e=0;e<p.length;e++){const n=s<=1.6?p[e].id:p[e];if(!t[n]){b=null;break}b.push(this.Ke(t[n]))}}const g={refine:"REPLACE",boundingVolume:h,transform:m,geometricError:d};return s<=1.6?t.lodSelection?t.geometryData&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}):g.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!b?g.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}),b&&b.length&&(g.children=b),g}getJSON(){return this.je}}function zs(t,e,n,r){return In(t,Tt(e),Tt(n),r)}const Vs=!!Fs.ktx2,Hs=n.mat4.identity([]),$s=(()=>{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 Xs(t){return t.indexOf("i3s:mesh")>=0}const Ks=9;function Js(t,e,n,r,s){const i=e.layerScene.eslpk,o=function(t,e){const n=e.substring(Ks);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let u=!1;const l=Hs;let f,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;i&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let s=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(s){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",i&&(s+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+s,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}h.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions[f.definition],{geometryBuffers:o}=t;u=r&&2===o.length;const l=Fs.draco&&u?o[1]:o[0],m=Fs.draco&&u?1:0;let p=c+`/nodes/${f.resource}/geometries/`+m;i&&(p+=".bin");const b={geometry:{url:p,info:l}};if(s&&$s&&u&&!Fs.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const g=e.layerScene.materialDefinitions,y=e.layerScene.textureSetDefinitions;let w,v=0;if(d&&(v=g[d.definition]),g){w=function(t,e,n,r,s,i){const o=JSON.parse(JSON.stringify(t));return Zs(o,e,n,r,s,i),o}(v,y,c,d.resource,n,e.layerScene.eslpk)}else w={pbrMetallicRoughness:{metallicFactor:0}};b.material=w,h.push(b)}return{dracoCompression:u,meshes:h,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:l}}function Zs(t,e,n,r,s,i){for(const o in t)if(t[o]&&t[o].textureSetDefinitionId>=0){const a=e[t[o].textureSetDefinitionId],c="images/"+a.formats[0].format,h=Ws(a.formats,s),u={url:n+`/nodes/${r}/textures/${h.name}`,factor:void 0===t[o].factor?1:t[o].factor,format:h.format,mimeType:c};if(i){let t="";switch(h.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=h.format}u.url+="."+t}t[o]=u}else wt(t[o])&&Zs(t[o],e,n,r,s,i)}function Ws(t,e){for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&Vs)return t[n]}return null}const Ys=new s.Coordinate(0,0),Qs=new s.Coordinate(0,0),ti=new Set,ei=[],ni=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.Ze(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.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){let t=!1;const e=this.data.keys();let n=e.next();for(;this.currentSize>this.max&&void 0!==n.value;){!t&&this.data.get(n.value).current&&(t=!0,console.warn(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`));const r=this.getAndRemove(n.value);r&&this.onRemove(r),n=e.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(const r of n)t[e++]=r;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 this.Ze(t,e),this}Ze(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(s.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let ri=0;class si extends(n.MaskRendererMixin(s.renderer.CanvasRenderer)){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>ni.max&&ni.setMaxSize(e),this.tileCache=ni,ri++,this.prepareWorker(),this.tilesLoading={},this.We={},this.Ye=[],this.Ue=this.Qe.bind(this)}getAnalysisMeshes(){if(!this.painter)return ei;const t=this.painter.getPaintedMeshes();if(!t)return ei;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:s}=t;return n.length&&kt(e,n),r.length&&kt(e,r),s.length&&kt(e,s),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.Ye.length||super.needToRedraw())}getFrameTimestamp(){return this.tn}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.tn=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:s}=this.layer.getTiles(),i=s.length;if(!s||!i)return void this.completeRender();this.painter.prepareRender(e),this.nn(),this.rn(e);const{selectedTiles:o,leaves:a,requests:c}=this.sn(r,s);c.length&&this.loadTiles(c),this.an(o,a,e),this.cn(),c.length||this.completeRender()}sn(t,e){let n=[];this.hn();let r=0;const s=this.un(),i={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const s=e[t],c=s.node;if(i[c.id])continue;i[c.id]=1;let h=!1;const u=this.getCachedTile(c.id);if(this.ln(c.id)?(r++,h=a=!0,this.tilesLoading[c.id].current=!0):u?(this.getTileOpacity(u)<1&&(h=a=!0),o=!0,s.selected=!0,s.data=u):this.painter.has(c)||(h=a=!0,n.push(c)),!h)continue;if(this.dn(s))o=!0;else{this.mn(s).length&&(o=!0)}}let c=[],h={};if(o&&({selectedTiles:c,leaves:h}=this.pn(t)),n.length>1&&(n.sort(ii),s)){const t=s-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c,leaves:h}}pn(t){const e=[],n={};let r;const s=[t],i=[];for(;s.length>0||i.length>0;){if(i.length>0){const t=i[i.length-1];if(t.bn===s.length){i.pop(),t===r&&(t.leave=!0,n[t.node.id]=1),e.push(t);continue}}const t=s.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)n[t.node.id]=1,t.selectionDepth=i.length,e.push(t);else{if(t.selectionDepth=i.length,r=t,0===o.length){t.leave=!0,n[t.node.id]=1,e.push(t);continue}i.push(t),t.bn=s.length}for(let t=0;t<o.length;t++)s.push(o[t])}return{selectedTiles:e,leaves:n}}dn(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}mn(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.gn+1,r=[t.node];for(;r.length>0;){const s=r.pop().children;for(let i=0,o=s.length;i<o;i++){if((!s[i].content||!s[i].content.url)&&s[i].children&&s[i].children.length){r.push(s[i]);continue}const o=s[i].id;if(this.tileCache.has(o)){const n=this.layer.yn(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].gn<=n&&r.push(s[i])}}return e}an(t,e,n){this.tileCache.markAll(this,!1);const r=[];for(let e=0,n=t.length;e<n;e++){const n=t[e].data;n.current=!0,n.renderer=this,this.tileCache.add(t[e].node.id,n);const s=n.node,i=this.layer.Nt(s.kt);s.Qt&&i.debug&&!Array.isArray(i.debug)&&r.push(s.Qt)}this.tileCache.shrink();const s=this.layer.options.services;for(let t=0;t<s.length;t++){const e=s[t],n=Array.isArray(e.debug)&&e.debug;if(n)for(const t of n){const e=this.layer.Me(t),n=e&&e.node;n&&n.Qt&&r.push(n.Qt)}}const i={tiles:t,leaves:e};this.onDrawTileStart(i);const o=this.painter.paint(t,e,r,n);this.layer.fire("drawtiles",{count:o}),this.onDrawTileEnd(i),o&&this.layer.fire("canvasisdirty",{renderCount:o})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(Ct(e)){const n=Nt(e);return this.wn(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.kt,r=this.vn[n];return new qs(e,n,r,this.layer,this.Ue).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Lt(e)&&!Xs(e)&&(e=t.baseUrl+e),this.wn(e,null,t),null}wn(t,e,r){let s=this.h;s||(s=n.reshader.Util.getSupportedFormats(this.gl.gl||this.gl),this.h=s);const i=this.layer.Nt(r.kt);i.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length),r=n.split("/"),s=[];for(let t=0;t<r.length;t++)s.push(encodeURIComponent(r[t]));return e+s.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,this.layer.Tn[r.kt]),arraybuffer:e,rootIdx:r.kt,upAxis:r.ue,transform:r.matrix,supportedFormats:s};if(Xs(t)){const e=this.vn[r.kt];if(o.projection=e.projection,o.i3sInfo=Js(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=gt({},i),i.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:s}=n;"b3dm"===s||"pnts"===s||"i3dm"===s||"cmpt"===s||"gltf"===s?this.Ye.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}_e(t){this.painter&&this.painter._e(t)}Oe(t){this.painter&&this.painter.Oe(t)}rn(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.Ye.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.Ye.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this._n(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this._n(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this._n(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this._n(t,e,n,r)})),n++}}_n(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.Mn(r);e.memorySize=n,this.onTileLoad(t,e)}}Mn(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Mn(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.On(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.xe=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.An(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(t,e,n){if(!this.layer)return;const r=n||e.content.url,s=t&&t.message||t;t&&(404===t.status||204===t.status)||ti.has(s)||(console.warn("failed to load 3d tile: "+r),console.warn(t),ti.add(s)),delete this.tilesLoading[e.id],this.xn(e,t),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}getShadowMeshes(){if(!this.painter)return;const t=[],e=this.painter.getCurrentB3DMMeshes();for(const n in e)e[n]&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&t.push(n[e]);return t}xn(t,e){const n={loadTime:s.Util.now(),current:!0,error:e,node:t};n.renderer=this,this.tileCache.add(t.id,n)}On(t){const e={loadTime:s.Util.now(),current:!0,node:t};e.renderer=this,this.tileCache.add(t.id,e)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.We[e]}hn(){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},r=this.canvas.gl&&this.canvas.gl.wrap;r?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.In(this.canvas,e)),this.regl=this.regl||n.createREGL({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),r&&(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 Bs(this.regl,t),this.layer.Sn(),this.layer.fire("contextcreate",{regl:this.regl})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new un("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let n=this.layer.options||{};n=gt({},n),delete n.offset;const r=t.options.spatialReference;n.projection=r&&r.coordType||r&&r.projection||t.getSpatialReference().getProjection().code;const s=this.layer.getId();e.addLayer(s,n,(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),ri--,ri||ni.reset(),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.cn(!0),this.tileCache.reset(this),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}cn(t){this.En||(this.En=Date.now());const e=Date.now();if(!t&&e-this.En<this.layer.options.retireInterval)return;this.En=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}un(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}In(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let s=0;s<n.length;++s){try{r=t.getContext(n[s],e)}catch(t){}if(r)break}return r}ln(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,n){return Kn(t,e,0,n)}nn(){if(!this.Cn)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.Cn){const s=this.Cn[r];if("pending"===s.status)continue;s.status="pending";const i=s.rootIdx,o=Ut(this.layer.Nt(i).fetchOptions);if(n.push(Ce.getJSON(r,o).then((t=>{delete this.Cn[r];const e=this.vn[i];if(e){t.nodes?Gs(e,t.nodes):(e[t.id]=t,Gs(e,t.children));for(let t=0;t<s.length;t++)s[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}n.length&&Promise.all(n)}Qe(t,e,n){this.Cn||(this.Cn={}),this.Cn[e]=this.Cn[e]||[],this.Cn[e].rootIdx=t,this.Cn[e].push(n),this.setToRedraw()}An(t,e,n){this.vn||(this.vn=[]);const r=e.kt;this.vn[r]||(this.vn[r]={});const s=this.vn[r],i=this.layer.Nt(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),s.version=+(i.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),s.projection=t.spatialReference,function(t,e,n,r,s,i,o){if(!i.layerScene){i.layerScene=e,i.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,i.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=s;if(i.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=s.lastIndexOf("/");t=e<0?"./":s.substring(0,e)}i.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new qs(s,n,i,t,o).load()}(this.layer,t,r,0,n,s,this.Ue).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:s,height:i}=this.canvas;return!this.pickingFBO||r.width===s&&r.height===i||r.resize(s,i),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.Lt||(this.Lt=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Lt[n];r||(r=this.Lt[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Lt[e];n||(n=this.Lt[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.Lt)}cancelHighlight(t,e){if(!this.Lt)return;const n=this.Lt[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.Lt[t]=null),this.painter.highlight(this.Lt)}}cancelAllHighlight(){delete this.Lt,this.painter.cancelAllHighlight()}showOnly(t){if(this.Dt||(this.Dt=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Dt[n];r||(r=this.Dt[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Dt[e];n||(n=this.Dt[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Dt)}cancelShowOnly(){delete this.Dt,this.painter.cancelShowOnly()}Be(){return this.painter?this.painter.Be():[]}Je(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.Nn();return Ys.set(e[0],e[1]),n.unproject(Ys,Qs),t[0]=Qs.x,t[1]=Qs.y,t}return Ys.set(e[0],e[1]),n.getProjection().unproject(Ys,Qs),t[0]=Qs.x,t[1]=Qs.y,t}kn(t,e){const n=this.Nn();return Ys.set(e[0],e[1]),n.project(Ys,Qs),t[0]=Qs.x,t[1]=Qs.y,t}Pn(t,e){const n=this.Nn();return Ys.set(e[0],e[1]),n.unproject(Ys,Qs),t[0]=Qs.x,t[1]=Qs.y,t}Nn(){const t=this.getMap().options.spatialReference.coordType;if(!t)throw new Error("Missing coordType in map spatialReference.");return this.Rn||(this.Rn=s.SpatialReference.getProjectionInstance(t)),this.Rn}}function ii(t,e){return t.Yt-e.Yt}function oi(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function ai(t,e,n){return Math.sqrt(function(t,e,n){const r=Wt(ci,n,t),s=oi(hi,e,0),i=oi(ui,e,1),o=oi(li,e,2),a=ie(s),c=ie(i),h=ie(o);te(s,s),te(i,i),te(o,o);const u=fi;u[0]=ee(r,s),u[1]=ee(r,i),u[2]=ee(r,o);let l,f=0;u[0]<-a?(l=u[0]+a,f+=l*l):u[0]>a&&(l=u[0]-a,f+=l*l);u[1]<-c?(l=u[1]+c,f+=l*l):u[1]>c&&(l=u[1]-c,f+=l*l);u[2]<-h?(l=u[2]+h,f+=l*l):u[2]>h&&(l=u[2]-h,f+=l*l);return f}(t,e,n))}const ci=[],hi=[],ui=[],li=[],fi=[];const di=2*Math.PI;class mi{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],s=t.west;let i=t.east;return i<s&&(i+=di,n<0&&(n+=di)),(n>s||qn(n,s,1e-14))&&(n<i||qn(n,i,1e-14))&&r>=t.south&&r<=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 pi=[0,0,1];function bi(t,e){return In(e,t[0],t[1],t[2])}class gi{constructor(t,e){this.normal=n.vec3.copy([],t),this.distance=e}static fromPointNormal(t,e,r){const s=-n.vec3.dot(e,t);return n.vec3.copy(r.normal,e),r.distance=s,r}}const yi=[],wi=[],vi=[],Ti=[],_i=[],Mi=[],Oi=[],Ai=[],xi=[],Ii=[],Si=new gi([1,0,0],0),Ei=[];class Ci{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new mi(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let r=0;if(!mi.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,s=this.northeastCornerCartesian,i=this.westNormal,o=this.southNormal,a=this.eastNormal,c=this.northNormal,h=n.vec3.subtract(Ei,t,e),u=n.vec3.dot(h,i),l=n.vec3.dot(h,o),f=n.vec3.subtract(Ei,t,s),d=n.vec3.dot(f,a),m=n.vec3.dot(f,c);u>0?r+=u*u:d>0&&(r+=d*d),l>0?r+=l*l:m>0&&(r+=m*m)}const s=e[2],i=this.minimumHeight,o=this.maximumHeight;if(s>o){const t=s-o;r+=t*t}else if(s<i){const t=i-s;r+=t*t}return Math.sqrt(r)}computeBox(t){const e=this;bi(mi.southwest(t,wi),e.southwestCornerCartesian),bi(mi.northeast(t,wi),e.northeastCornerCartesian),yi[0]=t.west,yi[1]=.5*(t.south+t.north),yi[2]=0;const r=bi(yi,vi),s=n.vec3.cross(_i,r,pi);n.vec3.normalize(e.westNormal,s),yi[0]=t.east;const i=bi(yi,Ai),o=n.vec3.cross(_i,pi,i);n.vec3.normalize(e.eastNormal,o);const a=n.vec3.subtract(_i,r,i),c=n.vec3.normalize(Ti,a),h=t.south;let u;if(h>0){yi[0]=.5*(t.west+t.east),yi[1]=h;const r=bi(yi,xi);n.vec3.copy(Ii,c);const s=gi.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Si);Ni(xi,Ii,s,e.southwestCornerCartesian),u=Fn(r,Mi)}else u=Gn(mi.southeast(t,wi),Mi);const l=n.vec3.cross(Oi,u,a);n.vec3.normalize(e.southNormal,l);const f=t.north;let d;if(f<0){yi[0]=.5*(t.west+t.east),yi[1]=f;const r=bi(yi,xi);n.vec3.scale(Ii,c,-1);const s=gi.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Si);Ni(xi,Ii,s,e.northeastCornerCartesian),d=Fn(r,Mi)}else d=Gn(mi.northwest(t,wi),Mi);const m=n.vec3.cross(Oi,a,d);n.vec3.normalize(e.northNormal,m)}}function Ni(t,e,r,s){const i=t,o=e,a=r.normal,c=n.vec3.dot(a,o);if(Math.abs(c)<1e-15)return;const h=(-r.distance-n.vec3.dot(a,i))/c;return h<0?void 0:(s=n.vec3.scale(s,o,h),n.vec3.add(s,i,s))}function ki(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const Pi=s.BBOXUtil,Ri={"services":[],"maxGPUMemory":s.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"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"]},Bi=[0,0,0],Li=[0,0,0],Ui=[0,0,0],Di=[0,0,0],Fi=[0,0,0],Gi=[0,0,0],ji=[0,0,0],qi=[1,1,1],zi=[0,0,0,0],Vi=[],Hi=new s.Coordinate(0,0),$i=new s.Point(0,0),Xi=[0,0,0,0,0,0,0,0,0],Ki=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ji=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Zi=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Wi=new s.Point(0,0),Yi=n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Qi=[0,0],to=[0,0,0],eo=[1,1,1],no=[0,0,0],ro=[0,0,0],so=[0,0,0,0],io=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class oo extends(n.MaskLayerMixin(s.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new oo(t.id,t.options):null}constructor(t,e){super(t,e),this.Bn(),this.Ln=[]}Bn(){const t=this.options.services.map((t=>t.url));this.Un=this.Un||{},this.Tn=this.Tn||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.Un[n];void 0===r&&(r=this.Un[n]=this.Tn.length),this.Tn[r]=ho(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Tn.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Dn(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Bn(),this.Dn(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(fo(n[t].coordOffset,e.coordOffset)&&fo(n[t].heightOffset,e.heightOffset)&&fo(n[t].scale,e.scale)&&fo(n[t].rotation,e.rotation)),gt(n[t],e));const s=n[t].url,i=this.Un[s],o=this.Tn&&this.Tn[i];return o&&(bt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Dn(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.Un[n];this.Tn[r]&&(this.Tn[r]=null),delete this.Un[n],e.splice(t,1)}return this.Dn(),this}getTileUrl(t,e){const n=e&&e.service&&e.service.subdomains;if(n&&e.domainKey){const r=n.length;if(r){const s=[...t].reduce(((t,e)=>t+e.charCodeAt(0)),0),i=s%r;return t.replace(e.domainKey,n[i])}}return t}getExtent(t){if(!t&&0!==t){const t=new s.Extent;for(let e=0;e<this.Tn.length;e++){const n=this.Tn[e];if(n&&n.boundingVolume){const e=this.boundingVolumeToExtent(n);t._combine(e)}}return t}const e=this.Tn[t];return e&&e.boundingVolume?this.boundingVolumeToExtent(e):null}boundingVolumeToExtent(t){const e=t.boundingVolume.Fn?Yi:t.matrix,r=this.getMap(),i="identity"===r.getProjection().code.toLowerCase(),o=this.getRenderer();if(t.boundingVolume.region){const e=t.boundingVolume.region;return new s.Extent(_t(e[0]),_t(e[1]),_t(e[2]),_t(e[3]))}if(t.boundingVolume.sphere){const a=t.boundingVolume.sphere,c=Pn([],n.vec3.transformMat4([0,0,0],a,e));i&&o.kn(c,c);const h=a[3],u=r.locate(c,-h,h),l=r.locate(c,h,-h);return new s.Extent(u,l)}if(t.boundingVolume.box){const a=t.boundingVolume.box,c=n.vec3.transformMat4([0,0,0],a,e),h=new s.Coordinate(Pn([],c));i&&o.kn(h,h);const u=a.slice(3);n.mat3.multiply(u,n.mat3.fromMat4([0,0,0,0,0,0,0,0,0],t.matrix),u);const l=n.vec3.length(u.slice(0,3)),f=n.vec3.length(u.slice(3,6)),d=n.vec3.length(u.slice(6,9)),m=Math.max(l,f,d),p=r.locate(h,-m,m),b=r.locate(h,m,-m);return new s.Extent(p,b)}return null}getRootTiles(){return this.Tn}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Dn(),{tiles:Vi};const e=this.getMap(),r=e.cameraPosition,s=e.pointAtResToDistance(r[2],0,e.getGLRes()),i=this.Gn(r);this.jn=this.jn||[0,0,0],n.vec3.set(this.jn,Tt(i.x),Tt(i.y),s),this.qn=In(this.qn||[],this.jn[0],this.jn[1],this.jn[2]),this.zn=2*Math.tan(.5*Tt(e.getFov()));const o=e.projViewMatrix,a=e.getExtent(),c=a.getWidth()/2,h=a.getHeight()/2;a.xmin-=c,a.ymin-=h,a.xmax+=c,a.ymax+=h;const u=ki(a),l=(this.getMasks()||[]).filter((t=>t&&t instanceof n.ClipOutsideMask));l.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=ki(e)}catch(t){console.error(t)}}));const f={children:[],level:-1};let d=f;const m=[];for(let e=0;e<this.Tn.length;e++){const n=this.Tn[e];if(!n||!n.visible)continue;const r=[n],s=this.Vn(e);for(;r.length>0;){const e=r.pop();for(e.id||this.Hn(e);d.level>=e.gn;)d=d.parent;const n=this.$n(e,s,o,u,l);if(!(n===mo.VISIBLE||n!==mo.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&lo(e))){let t=d;for(;t&&!t.content;)t=t.parent;n===mo.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.Xn(m,t);continue}e.Yt<1/0&&this.Kn(e);const i=this.yn(e,d);d.children.push(i);const a=e.children,c=a&&a.length,h=i.content;if(!c&&h&&this.Xn(m,i),c){h&&"add"===e.refine&&this.Xn(m,i),d=i;const n=a[0].parent;let s=!1;for(let i=0,o=a.length;i<o;i++){if(n){const e=t.getCachedTile(a[i].id);if(e&&e.error&&404!==e.error.status)continue;s=!0}else{s=!0,a[i].parent=e,a[i].ue=e.ue,a[i].baseUrl=e.baseUrl;const t=a[i].content&&(a[i].content.url||a[i].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?a[i].baseUrl=e.baseUrl:Lt(t)?a[i].content.url=e.baseUrl+t:a[i].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}r.push(a[i])}!s&&h&&this.Xn(m,i)}}}return{root:f,tiles:m}}Xn(t,e){const{viewerRequestVolume:n,matrix:r}=e.node;n&&!function(t,e,n,r){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return ao(n,e,r)<=0;if(n.box)return 0===co(n,e,r)}return!1}(this.jn,this.qn,n,r)||t.push(e)}yn(t,e){return{id:t.id,node:t,children:[],level:t.gn,parent:e,content:t.content&&t.content.url}}Hn(t){const e=this.getId();t.id=e+":"+s.Util.GUID(),t.matrix=t.transform||n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t.Jn=this.Zn(t),t.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(t)||(t.matrix=n.mat4.multiply(t.matrix,t.parent.matrix,t.matrix)),t.kt=t.parent.kt,void 0===t.gn&&(t.gn=t.parent.gn+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)}Nt(t){return this.Tn[t].service}Wn(t){const e=t.boundingVolume;if(!e||e.Fn&&!this.Yn(t))return;const r=this.Nt(t.kt),s=r.heightOffset||0,i=this.options.offset,o=yt(i)||i[0]||i[1],a=r.coordOffset||Qi;if(!Array.isArray(a))throw new Error("service.coordOffset must be an array");if(!e.Fn&&(!t.boundingVolume||!s&&n.mat4.exactEquals(t.matrix,Yi)&&!o&&a===Qi))return;e.box&&e.region&&delete e.region;const{region:c,box:h,sphere:u}=e;if(e.coordOffset=[a[0],a[1]],e.heightOffset=s,c){e.originalVolume||(e.originalVolume=c.slice(0));const t=e.originalVolume,n=this.Qn([_t(t[0]),_t(t[1])]);c[0]=Tt(n.x+a[0]),c[1]=Tt(n.y+a[1]);const r=this.Qn([_t(t[2]),_t(t[3])]);c[2]=Tt(r.x+a[0]),c[3]=Tt(r.y+a[1]),c[4]=t[4]+s+(a[2]||0),c[5]=t[5]+s+(a[2]||0)}else if(h||u){e.originalVolume||(e.originalVolume=(h||u).slice(0));const r=h||u,i=e.originalVolume,o=n.vec3.transformMat4(Bi,i,t.matrix),c=Pn(Li,o),l=this.Qn([c[0]+a[0],c[1]+a[1]]);c[0]=l.x,c[1]=l.y,c[2]+=s+(a[2]||0),In(r,Tt(c[0]),Tt(c[1]),c[2])}e.Fn=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}Yn(t){const e=t.boundingVolume,n=this.Nt(t.kt),r=n.heightOffset||0,s=n.coordOffset||Qi;return e.coordOffset[0]!==s[0]||e.coordOffset[1]!==s[1]||e.heightOffset!==r}Zn(t){return void 0===t.geometricError||!t.boundingVolume}Kn(t){let e=t.parent;for(;e&&e.Jn&&!(e.Yt<=t.Yt);)e.Yt=t.Yt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1),this.Dn()}}onTilesetLoad(t,e,r){if(!t)return void console.warn("invalid tileset at : "+r);const s=(t.asset&&t.asset.gltfUpAxis||e&&e.ue||"Y").toUpperCase();t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const i=r.indexOf("realspace/")>-1;0===e.gn&&t.asset&&t.asset.s3mType&&i&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.ue=s,e){const r=e.boundingVolume;gt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",r&&(e.boundingVolume=r);const s=t.root.transform;s&&(e.parent?o||(e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,s)):e.matrix=s),delete e.content,t.root.content&&(e.content=t.root.content),e.Jn=this.Zn(e);const i=e.content&&(e.content.url||e.content.uri);i&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!o&&i&&!Ct(i)&&Lt(i)&&(e.content.url=e.baseUrl+i),t.root&&!e.parent&&this.tr(e)}this.Dn(),this.fire("loadtileset",{tileset:t,index:e&&e.kt,url:r})}er(t,e,n){if(!t.extent||!Pi||!e)return!0;const r=t.extent;so[0]=r.xmin,so[1]=r.ymin,so[2]=r.xmax,so[3]=r.ymax;if(!Pi.bboxIntersect(so,e))return!1;if(n.length){for(let t=0,e=n.length;t<e;t++){const e=n[t].maskGeoJSON;if(!e||!e.bbox||Pi.bboxInMask(so,e))return!0}return!1}return!0}$n(t,e,n,r,s){if(!this.er(t,r,s))return mo.OUT_OF_FRUSTUM;if(t.Yt=1/0,0===t.gn||t.Jn)return this.tr(t),mo.VISIBLE;if(this.Wn(t),!this.nr(t,e,n))return mo.OUT_OF_FRUSTUM;if(0===t.geometricError)return mo.VISIBLE;let i=this.Nt(t.kt).maximumScreenSpaceError;null==i&&(i=16);let o=this.rr(t);return 0===o&&t.parent&&(o=.5*(t.parent.sr||0)),o>=i?mo.VISIBLE:mo.SCREEN_ERROR_TOO_SMALL}Pe(t,e){e||(e=new s.Point(0,0));const n=this.getMap();return n.coordToPointAtRes(t,n.getGLRes(),e)}nr(t,e,n){const r=t.id;let s=this.Ln[r];const{boundingVolume:i}=t,o=i.region,a=i.box,h=i.sphere,u=this.ir(t.kt),l=this.getRenderer();s&&s.version===u.version||(o?s=this.Ln[r]=this.ar(t):a?s=this.Ln[r]=this.cr(t):h&&(s=this.Ln[r]=this.hr(t)),s.version=u.version,t.Qt&&(l.Oe(t.Qt),delete t.Qt));return this.Nt(t.kt).debug&&(this.Ln[r].node=t,l._e(t)),s.obbox?function(t,e,n){_(t);for(var r=0;r<6;r++)if(!T(c[r],e))return!1;return!0}(n,s.obbox):!!h&&function(t,e,n){_(t);for(var r=e[0],s=-e[1],i=0;i<6;i++)if(O(c[i],r)<s)return!1;return!0}(n,s.sphereBox)}ar(t){const e=this.getMap(),r=e.getGLRes(),i=t.boundingVolume.region;let{ws:o,en:a}=function(t){const e=t[0],n=t[1],r=t[2],s=t[3],i=t[4],o=t[5],a=In([],e,n,i),c=In([],r,s,o),h=Pn(a,a),u=Pn(c,c);return{ws:h,en:u}}(i);o=new s.Coordinate(o),a=new s.Coordinate(a);const c=e.coordToPointAtRes(o,r);c.z=e.altitudeToPoint(o.z,r);const h=e.coordToPointAtRes(a,r);h.z=e.altitudeToPoint(a.z,r);const u=[h.x,c.y,h.z,h.x,h.y,h.z,c.x,h.y,h.z,c.x,c.y,h.z,h.x,c.y,c.z,h.x,h.y,c.z,c.x,h.y,c.z,c.x,c.y,c.z],l=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],f=this.ir(t.kt);t!==f||f.ur||(f.ur=l);const d=this.Ne([],t),m=n.mat4.exactEquals(Yi,d);if(!m){n.vec3.transformMat4(l,l,d);const t=Bi;for(let e=0;e<u.length;e+=3){let r=n.vec3.set(t,u[e],u[e+1],u[e+2]);m||(r=n.vec3.transformMat4(r,r,d)),u[e]=r[0],u[e+1]=r[1],u[e+2]=r[2]}}const p=e.pointAtResToCoord(new s.Point(l),r);p.z=(o.z+a.z)/2;const b=this.lr(u,l);for(let t=0;t<u.length;t++)u[t]-=l[t%3];return{obbox:b,boxPosition:u,boxCenter:l,boxCoord:p}}cr(t){const e=this.getRenderer(),r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),i=r.getGLRes(),{boxCenter:o,boxCoord:a}=this.dr(t),c=t.boundingVolume.box,h=function(t,e,n){return function(t,e,n,r,s,i,o,a,c,h,u,l,f,d,m,p,b){return t[0]=e||0,t[1]=i||0,t[2]=h||0,t[3]=0,t[4]=n||0,t[5]=o||0,t[6]=u||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=l||0,t[11]=0,t[12]=s||0,t[13]=c||0,t[14]=f||0,t[15]=b,t}(t,e[0],e[3],e[6],n[0],e[1],e[4],e[7],n[1],e[2],e[5],e[8],n[2],0,0,0,1)}([],this.mr(c,t.matrix),c),u=this.Ne([],t),l=n.mat4.exactEquals(Yi,u);l||n.vec3.transformMat4(o,o,u);const f=[],d=Bi;for(let t=0;t<io.length;t+=3){d[0]=io[t],d[1]=io[t+1],d[2]=io[t+2],n.vec3.transformMat4(d,d,h),Pn(d,d),s&&e.kn(d,d);const o=Hi.set(d[0],d[1],d[2]);r.coordToPointAtRes(o,i,$i);let a=n.vec3.set(d,$i.x,$i.y,r.altitudeToPoint(o.z,i));l||(a=n.vec3.transformMat4(a,a,u)),f[t]=a[0],f[t+1]=a[1],f[t+2]=a[2]}const m=this.lr(f,o);for(let t=0;t<f.length;t++)f[t]-=o[t%3];return{obbox:m,boxPosition:f,boxCenter:o,boxCoord:a}}hr(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),i=t.boundingVolume.sphere,o=i;let a=Bi;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:Pn(a,o),r&&n.kn(a,a);const c=new s.Coordinate(a),h=this.Pe(c,$i).toArray();h[2]=e.altitudeToPoint(c.z,e.getGLRes());const u=this.pr(c);return{boxCenter:h,boxCoord:c,sphereBox:[h,i[3]*u[2]]}}lr(t,e){const r=uo(Fi,t,0,1,4,5),s=uo(Gi,t,0,3,4,7),i=uo(ji,t,0,1,2,3);return[...e,...n.vec3.sub(Bi,r,e),...n.vec3.sub(Li,s,e),...n.vec3.sub(Ui,i,e)]}dr(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),i=e.getGLRes(),o=t.boundingVolume.box.slice(0,3);Pn(o,o),r&&n.kn(o,o);const a=new s.Coordinate(o),c=e.coordToPointAtRes(a,i);return{boxCenter:[c.x,c.y,e.altitudeToPoint(a.z,i)],boxCoord:a}}Ne(t,e){const r=this.ir(e.kt),s=this.Nt(e.kt),i=r.ur,o=n.mat4.fromTranslation(Ki,n.vec3.set(Bi,-i[0],-i[1],-i[2])),a=n.mat4.fromTranslation(Ji,i),c=s.rotation||to,h=n.quat.fromEuler(zi,...c),u=s.scale,l=u&&n.vec3.set(no,u,u,u)||eo,f=n.mat4.fromRotationTranslationScale(Zi,h,ro,l);return t=n.mat4.multiply(t,f,o),n.mat4.multiply(t,a,t)}tr(t){const e=this.Nt(t.kt);if(!t.boundingVolume||this.br(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,s=t.boundingVolume.sphere;let i=null;n?i=this.gr(t).boxCenter:r?i=this.yr(t).boxCenter:s&&(i=this.hr(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.wr=[a[0]||0,a[1]||0],t.vr=o,t.ur=i}br(t,e){if(!t.wr)return!1;const n=e.coordOffset||Qi;return t.wr[0]===n[0]&&t.wr[1]===n[1]&&t.vr===(e.heightOffset||0)}yr(t){return this.Wn(t),this.ar(t)}gr(t){return this.Wn(t),this.dr(t)}mr(t,e){let r=t.slice(3,12);const s=n.mat3.fromMat4(Xi,e);return r=n.mat3.multiply(r,s,r),r}pr(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let s;return s=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:r.y/100,n.vec3.set(qi,r.x/100*1.01,r.y/100*1.01,s),qi}Qn(t){Array.isArray(t)&&(t=new s.Coordinate(t));let e=this.options.offset;if(yt(e)&&(e=e.call(this,Array.isArray(t)?new s.Coordinate(t):t)),e[0]||e[1]){const n=this.getMap(),r=n.getGLRes(),s=n.coordToPointAtRes(t,r);return $i.set(e[0],e[1]),s._sub($i),n.pointAtResToCoord(s,r)}return t}ir(t){return this.Tn[t]}Vn(t){const e=this.Nt(t).maxExtent;if(!e)return null;const n=this.Tn[t];return n.maxExtent||(n.maxExtent=new s.Extent(e).convertTo((t=>this.Pe(t)))),n.maxExtent}rr(t){const e=this.zn,n=t.geometricError;if(0===n)return t.sr=0,0;const r=this.Nt(t.kt).scale||1,s=this.getMap();let i;t.boundingVolume.region?i=function(t,e,n){t.Tr||(t.Tr=new Ci(t.boundingVolume.region));return t.Tr.distanceToCamera(e,n)}(t,this.qn,this.jn):t.boundingVolume.sphere?i=ao(t.boundingVolume,this.qn):t.boundingVolume.box&&(i=co(t.boundingVolume,this.qn));const o=Math.max(Math.abs(i),1e-7),a=n*r*s.height/(o*e);return t.Yt=i,t.sr=a,a}Dn(){const t=this.getRenderer();t&&t.setToRedraw()}Me(t){return this.Ln[t]}identify(t,e={}){const n=this.getMap(),r=this.getRenderer();if(!n||!r)return[];Array.isArray(t)&&(t=new s.Coordinate(t));const i=n.coordToContainerPoint(t);return this.identifyAtPoint(i,e)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&kt(n,r)}const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];const i=r.getDevicePixelRatio();return kt(n,s.pick(t.x*i,t.y*i,e)),e&&e.filter&&!e.excludeMasks?n.filter((t=>e.filter(t))):n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Be():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.Lt||(this.Lt=[]),this.Lt.push(t),this)}Sn(){if(this.Lt){for(let t=0;t<this.Lt.length;t++)this.highlight(this.Lt[t]);delete this.Lt}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Dt||(this.Dt=[]),this.Dt.push(t),this)}_r(){if(this.Dt){for(let t=0;t<this.Dt.length;t++)this.showOnly(this.Dt[t]);delete this.Dt}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);return this.getRenderer()?(this.Dn(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Dn(),this):this}Gn(t){const e=this.getMap(),n=e.getGLRes();Wi.set(t[0],t[1]);const r=e.pointAtResToCoord(Wi,n);return"identity"===e.getProjection().code.toLowerCase()?(Li[0]=r.x,Li[1]=r.y,this.getRenderer().Pn(Bi,Li),r.set(Bi[0],Bi[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function ao(t,e,r){let s=t.sphere;r&&(s=n.vec3.transformMat4([0,0,0],s,r));const i=n.vec3.dist(s,e),o=t.sphere[3];return i<o?0:i-o}function co(t,e,r){const s=t.box;let i=n.vec3.set(Bi,s[0],s[1],s[2]);r&&(i=n.vec3.transformMat4([0,0,0],i,r));return ai(i,n.mat3.set(Xi,s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11]),e)}function ho(t,e,r){const s=(t=Mt(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,Jn:!0,service:r,visible:!!bt(r.visible)||r.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),kt:e,gn:0,domainKey:s}}function uo(t,e,r,s,i,o){const a=n.vec3.set(Bi,e[3*r],e[3*r+1],e[3*r+2]),c=n.vec3.set(Li,e[3*s],e[3*s+1],e[3*s+2]),h=n.vec3.set(Ui,e[3*i],e[3*i+1],e[3*i+2]),u=n.vec3.set(Di,e[3*o],e[3*o+1],e[3*o+2]);return t[0]=(a[0]+c[0]+h[0]+u[0])/4,t[1]=(a[1]+c[1]+h[1]+u[1])/4,t[2]=(a[2]+c[2]+h[2]+u[2])/4,t}function lo(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e&&(e.content||e.hasParentContent))return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function fo(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?n.vec2.exactEquals(t,e):n.vec3.exactEquals(t,e):t===e}var mo;oo.mergeOptions(Ri),oo.registerRenderer("gl",si),oo.registerJSONType("Geo3DTilesLayer"),function(t){t[t.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",t[t.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",t[t.VISIBLE=2]="VISIBLE"}(mo||(mo={}));let po=null;function bo(){return po||(po={"image/crn":Fs.crn&&Fs.crn(),"image/ktx2":Fs.ktx2&&Fs.ktx2(),"image/cttf":Fs.ktx2&&Fs.ktx2(),"draco":Fs.draco&&Fs.draco()}),po}class go{constructor(t,e,n){this.o=t,this.Mr=e||Ze,this.h=n,this.Or=bo()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Ar(t,e,n,r,s)):Ce.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Ar(t,s,n,r)}))}Ar(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.Ir(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.Mr(a,o.glb,{transferable:!0,requestImage:this.o,decoders:this.Or,supportedFormats:this.h,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}Ir(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),h=s.getUint32(20,!0),u=s.getUint32(24,!0),l=28+e;h>=570425344?(l-=8,o=a,h=c,u=0,a=0,c=0):u>=570425344&&(l-=4,o=h,h=a,u=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=Hn(t,l,a),l+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(l+=c),h>0&&(m=$n(t,l,h),l+=h,u>0)){const e=Xn(0,l,u);p=t.slice(e.offset,e.offset+e.byteLength),l+=u,f.push(p)}const b=d.BATCH_LENGTH,g={};if(d&&d.BATCH_ID){g.BATCH_ID=Jn(d.BATCH_ID,t,undefined.offset,b);const e=g.BATCH_ID.array&&g.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:g,glb:{buffer:t,byteOffset:l,byteLength:s.byteLength+s.byteOffset-l}}}Sr(){return null}}class yo{constructor(t,e,n,r){this.o=t,this.Mr=e||Ze,this.h=n,this.Or=bo(),this.Er=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Ar(t,e,n,r,s)):Ce.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Ar(t,s,n,r)}))}Ar(t,e,n,r,s){return this.Cr(t,e,n,r,s).then((({gltf:s,transferables:i})=>{const o=this.Nr(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})}))}Cr(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.o,decoders:this.Or,supportedFormats:this.h,maxTextureSize:i},a=new DataView(e,n,r),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 r=xt(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?Ce.getArrayBuffer(r,{}).then((t=>this.kr(r,{buffer:t.data,byteOffset:0},o))):Ce.getJSON(r,{}).then((t=>this.kr(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.kr(t,r,o)}}kr(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.Mr(r,e,n);return s.load({skipAttributeTransform:!0}).then((n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=`${t}-${r}-${i}`,{transferables:s.transferables,gltf:n}}))}Nr(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:u}=rr(s,32+e,o),l={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;l.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Pr(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Jn(a.BATCH_ID,t,c.offset,f);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:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).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:f,componentType:5126,array:this.Rr(new Uint16Array(t,e+c.offset,2*f))},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Rr(new Uint16Array(t,e+c.offset,2*f))},o.push(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).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:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:h,batchTableBin:u,featureTable:a,i3dm:l,transferables:o}}Rr(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)wo(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}Pr(t,e,n){return nr(new Float32Array(t.length),t,e,n)}Sr(){return null}}function wo(t,e,n,r){if(t[0]=vo(e,r),t[1]=vo(n,r),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]))*To(e),t[1]=(1-Math.abs(e))*To(t[1])}return te(t,t)}function vo(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,n){return t<e?e:t>n?n:t}(t,0,e)/e*2-1}function To(t){return t<0?-1:1}class _o{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.Ar(t,e,n,r)):Ce.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Ar(t,s,n,r)}))}Ar(t,e,n,r){return this.Br(e,n,r,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}))}Br(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:u}=rr(s,e+28,o),l=a.QUANTIZED_VOLUME_OFFSET,f=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,p={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){p=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,p.byteOffset+c.offset,p.byteLength);const e={attributes:p.properties,useUniqueIDs:!1};return this.Lr||(this.Lr=bo().draco),this.Lr(m,e).then((e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.Ur(t,e.attributes,c.offset,d,o,l,f);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:er(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?r.BATCH_ID=Jn(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Mo(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:r,transferables:o}}))}const b=this.Ur(t,a,c.offset,d,o,l,f);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?b.BATCH_ID=Jn(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=Mo(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:b,transferables:o})}Ur(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:h}=e.POSITION_QUANTIZED;c=c||0;const u=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Pr(h||new Uint16Array(t,c+u,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}Pr(t,e,n){return nr(new Float32Array(t.length),t,e,n)}Sr(){return null}}function Mo(t){const e=Et(t),n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:er(e),array:n}}class Oo{constructor(t,e,n,r){this.h=n,this.o=t,this.Mr=e||Ze,this.Er=r}load(t,e,n=0,r=0,s){return e?this.Ar(t,e,n,r,s):Ce.getArrayBuffer(t,{}).then((e=>{const s=e.data;return this.Ar(t,s,n,r)}))}Ar(t,e,n,r,s){r||(r=e.byteLength);const i=this.Dr(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new go(this.o,this.Mr,this.h);else if("i3dm"===i[n].magic)r=new yo(this.o,this.Mr,this.h,this.Er);else if("pnts"===i[n].magic)r=new _o;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new Oo(this.o,this.Mr,this.h,this.Er)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Dr(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=zn(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(i.transcoders){const t=s.Map.VERSION;if(t.indexOf("1.0.0-beta")>=0||t.indexOf("1.0.0-alpha")>=0){const t=i.transcoders.inject(a);s.registerWorkerAdapter("@maptalks/3dtiles",t)}else s.registerWorkerAdapter("@maptalks/3dtiles",(function(){return i.transcoders.inject(a)}))}else s.registerWorkerAdapter("@maptalks/3dtiles",a);t.B3DMLoader=go,t.CMPTLoader=Oo,t.Geo3DTilesLayer=oo,t.Geo3DTilesUtil=Bt,t.Geo3DTransform=jn,"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.98.0")}));
|
|
23
|
+
//# sourceMappingURL=maptalks.3dtiles.js.map
|