@maptalks/3dtiles 0.99.0 → 0.100.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.100.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){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,e){var n="undefined"!=typeof Float32Array?Float32Array:Array;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 i(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],l=e[8],h=e[9],d=e[10],m=e[11],y=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*l+T*y,t[1]=w*i+v*c+M*h+T*b,t[2]=w*s+v*u+M*d+T*p,t[3]=w*o+v*f+M*m+T*g,w=n[4],v=n[5],M=n[6],T=n[7],t[4]=w*r+v*a+M*l+T*y,t[5]=w*i+v*c+M*h+T*b,t[6]=w*s+v*u+M*d+T*p,t[7]=w*o+v*f+M*m+T*g,w=n[8],v=n[9],M=n[10],T=n[11],t[8]=w*r+v*a+M*l+T*y,t[9]=w*i+v*c+M*h+T*b,t[10]=w*s+v*u+M*d+T*p,t[11]=w*o+v*f+M*m+T*g,w=n[12],v=n[13],M=n[14],T=n[15],t[12]=w*r+v*a+M*l+T*y,t[13]=w*i+v*c+M*h+T*b,t[14]=w*s+v*u+M*d+T*p,t[15]=w*o+v*f+M*m+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 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],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,u=n*o,f=r*o,l=r*a,h=i*o,d=i*a,m=i*c,y=s*o,b=s*a,p=s*c;return t[0]=1-l-m,t[1]=f+p,t[2]=h-b,t[3]=0,t[4]=f-p,t[5]=1-u-m,t[6]=d+y,t[7]=0,t[8]=h+b,t[9]=d-y,t[10]=1-u-l,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 n(3);return n!=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.hypot(e,n,r)}function l(t,e,r){var i=new n(3);return i[0]=t,i[1]=e,i[2]=r,i}function h(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 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 y(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function b(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function p(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function g(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[3]*r+n[7]*i+n[11]*s+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*i+n[8]*s+n[12])/o,t[1]=(n[1]*r+n[5]*i+n[9]*s+n[13])/o,t[2]=(n[2]*r+n[6]*i+n[10]*s+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 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=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},M=f;function T(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t}function A(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*s+n[12]*o,t[1]=n[1]*r+n[5]*i+n[9]*s+n[13]*o,t[2]=n[2]*r+n[6]*i+n[10]*s+n[14]*o,t[3]=n[3]*r+n[7]*i+n[11]*s+n[15]*o,t}function _(){var t=new n(4);return n!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function O(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function k(t,e,n,r){var i,s,o,a,c,u=e[0],f=e[1],l=e[2],h=e[3],d=n[0],m=n[1],y=n[2],b=n[3];return(s=u*d+f*m+l*y+h*b)<0&&(s=-s,d=-d,m=-m,y=-y,b=-b),1-s>1e-6?(i=Math.acos(s),o=Math.sin(i),a=Math.sin((1-r)*i)/o,c=Math.sin(r*i)/o):(a=1-r,c=r),t[0]=a*u+c*d,t[1]=a*f+c*m,t[2]=a*l+c*y,t[3]=a*h+c*b,t}u(),function(){var t,e=(t=new n(4),n!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var x,S=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};u(),l(1,0,0),l(0,1,0),_(),_(),x=new n(9),n!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[5]=0,x[6]=0,x[7]=0),x[0]=1,x[4]=1,x[8]=1;\n/*!\n * @maptalks/gltf-loader v0.99.0\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.org\n */\nlet I=0;function E(t){return null==t}function C(t){return!E(t)}function U(t){return!E(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function F(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 N(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 P(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function B(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const D=[],R=[],L=[],z=[0,0,0],j=O([]),q=[1,1,1];function V(t,e,n,r,i,s,o){const a=N(o),c=a.BYTES_PER_ELEMENT;if((0===i||i===r*c)&&s%c==0){const i=new a(e,s,n*r);return t.set(i),t}0===i&&(i=r*c);const u=new Uint8Array(r*c);for(let o=0;o<n;o++){let n=null;const f=new Uint8Array(e,i*o+s,r*c);u.set(f),n=new a(u.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const G="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function $(t,e,n){const r=new Uint8Array(t,e,n);return G.decode(r)}const X={get:function(t,e={},n){e||(e={});const r=new AbortController,i=r.signal,s=F({},e);s.signal=i,s.method||(s.method="GET"),s.referrerPolicy=s.referrerPolicy||"origin","undefined"==typeof window||s.referrer||(s.referrer=window.location.href),n&&(t=n(t));const o=fetch(t,s).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",X.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?X.jsonp(t):((e=e||{}).responseType="json",X.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+I++;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 H{constructor(t,e,n,r,i){this.i=t,this.decoders=e,this.o=n,this.images={},this.u={},this.h=r||{},this.m=i}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],i=this.p(e,r);return this.getImageByBuffer(i,n)}if(this.u[t.id])return this.u[t.id].then((()=>{const r=this.buffers[t.id],i=this.p(e,r);return this.getImageByBuffer(i,n)}));if(P(t.uri)){const r=this.buffers[t.id]=B(t.uri),i=this.p(e,r);return this.getImageByBuffer(i,n)}let r;const i=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||i?t.uri:this.rootPath+"/"+t.uri,this.u[t.id]=X.getArrayBuffer(r,this.h,this.m).then((r=>{const i=this.buffers[t.id]=r.data,s=this.p(e,i);return this.getImageByBuffer(s,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 i=e;this.m&&(i=this.m(e)),this.i(i,this.h,((i,s)=>{i?r(i):(URL.revokeObjectURL(e),this.images[t]=s,n(this.images[t]))}))}))}}const J=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],K=[];class Y{constructor(t,e,n,r,i){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=i}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 i=n.bufferViews[r.bufferView];return this.O(i).then((n=>{const{buffer:i,byteOffset:s}=n;return this.accessors[r.id]=this._(t,e,i,s)}))}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(P(e.uri)){const t=this.buffers[e.id]=B(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]=X.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 i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+r,c=this.k(s.type),u=N(s.componentType),f=o.byteStride||0,l={array:void 0,name:t,accessorName:e,byteLength:s.count*c*u.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c,max:s.max,min:s.min,extensions:s.extensions};if(s.min&&(l.min=s.min),s.max&&(l.max=s.max),n)if(this.M)l.byteStride=f,l.byteOffset=a+(s.byteOffset||0),!f||f===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(l.array=this.S(n,s.count,c,a+(s.byteOffset||0),u),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(n,a,o.byteLength);else if(s.interleaved){l.byteStride=0,l.byteOffset=0;const t=new u(s.count*c);if(l.array=V(t,n,s.count,c,f,a+(s.byteOffset||0),s.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){K[0]=l.array[n],K[1]=l.array[n+1],K[2]=l.array[n+2],K[3]=1;const r=A(K,K,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,s.count,c,a+(s.byteOffset||0),u),l.byteOffset=l.array.byteOffset;else{l.array=new u(s.count);const t=l.min||l.max;t&&(l.array[0]=t[0],l.array[1]=t[1],l.array[2]=t[2])}return l}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,i){return r%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*i.BYTES_PER_ELEMENT),r=0),new i(t,r,n*e)}k(t){const e=J.indexOf(t);return J[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:i,byteOffset:s}=r,o=$(i,s+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(P(t.uri)){const e=B(t.uri),n=$(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return X.get(e,this.h,this.m).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class Q extends H{constructor(t,e,n,r,i,s,o,a){super(r,i,s,o,a),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new Y(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(C(t.name)&&(e.name=t.name),C(t.children)&&(e.children=t.children),C(t.jointName)&&(e.jointName=t.jointName),C(t.matrix)&&(e.matrix=t.matrix),C(t.rotation)&&(e.rotation=t.rotation),C(t.scale)&&(e.scale=t.scale),C(t.translation)&&(e.translation=t.translation),C(t.extras)&&(e.extras=t.extras),C(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const n=s(D,e.translation||z),r=a(R,e.rotation||j),c=o(L,e.scale||q);return i(c,r,c),i(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 i,s;r.instanceTechnique&&r.instanceTechnique.values?(i=r.instanceTechnique,s=i.values.diffuse):(i=r,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={baseColorTexture:{index:s}};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,i=n.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,i);return this.getImageByBuffer(s,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 i=this.gltf.textures[r];if(!i)return null;const s=this.gltf.samplers[i.sampler];return{format:i.format||6408,internalFormat:i.internalFormat||6408,type:i.type||5121,sampler:s,source:this.gltf.images[i.source]}}getMaterial(){return null}getAnimations(){return null}}const W=9729;class Z extends H{constructor(t,e,n,r,i,s,o,a){super(r,i,s,o,a),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new Y(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 F(e,t),!C(t.weights)&&this.gltf.meshes&&C(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}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),!C(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}};F(n,e);const i=C(e.sampler)?this.gltf.samplers[e.sampler]:void 0;if(i&&(n.sampler=i,n.sampler.magFilter=i.magFilter||W,n.sampler.minFilter=i.minFilter||W,n.sampler.wrapS=i.wrapS||10497,n.sampler.wrapT=i.wrapT||10497),!n.mipmap&&n.sampler.minFilter!==W&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:W}return t.format&&(n.format=t.format),n}))}C(t){if(!C(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,i=t.byteLength;return new Uint8Array(e,r,i)}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++)(C(t[n].input)||C(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 tt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class et{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),i=r.getUint32(4,!0);if(1===i)return et.readV1(r,e);if(2===i)return et.readV2(t,e);throw new Error("Unsupported glb version : "+i)}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 i=nt(t.buffer,20+e,r);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,i;const s=new DataView(t,e+12);let o=0;for(;o<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,1313821514===c)n=nt(t,e+12+o,a);else if(5130562===c){i=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:i,buffer:t,byteLength:r}}}}function nt(t,e,n){if(tt){const r=new Uint8Array(t,e,n);return tt.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=rt[i>>3&7];if(!(64&i)||!n||r+n>e)return null;for(i&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;i=i<<6|63&e}}n+=String.fromCharCode(i)}return n}(new Uint8Array(t,e,n))}const rt=[1,1,1,1,2,2,3,0],it=[0,0,0],st=[0,0,0,1],ot=[1,1,1],at={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},ct={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},ut={P(t,e,n,r,i,s,o,a){const c=C(t)?e.animations:[e.animations[0]],u={};for(let e=0;e<c.length;e++){const f=c[e],l=f.name||e;if(C(t)&&l!==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.B(i,f.samplers[e.sampler],r,1),u.translation=h(it,i)):"rotation"===e.target.path?(this.D(s,f.samplers[e.sampler],r,1),u.rotation=S(st,s)):"scale"===e.target.path?(this.B(o,f.samplers[e.sampler],r,1),u.scale=h(ot,o)):"weights"===e.target.path&&a&&(this.B(a,f.samplers[e.sampler],r,a.length),u.weights=a)}}return u},B(t,e,n,r){switch(e.interpolation){case"LINEAR":{const i=this.R(ct,e,n,1*r);i&&(t=function(t,e,n,r){for(let i=0;i<t.length;i++)t[i]=e[i]+r*(n[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.R(ct,e,n,1*r);i&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.R(ct,e,n,3*r);i&&(t=this.L(t,i,e.input.array,3*r));break}}return t},D(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.R(ct,e,n,1);r&&k(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.R(ct,e,n,1);r&&(t=T(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.R(ct,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,i,s,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,i=c+1,s=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:i,interpolation:s}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},R(t,e,n,r){const i=e.input.array,s=e.output.array,o=e.output.itemSize;(n<i[0]||n>i[i.length-1])&&(n=Math.max(i[0],Math.min(i[i.length-1],n))),n===i[i.length-1]&&(n=i[0]);const a=this.j(i,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 l=o*r;return t.PREVIOUS=s.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=s.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},L(t,e,n,r){const i=e.INTERPOLATION,s=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-s)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],f=(o-s)*e.NEXT[n],l=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(2*-Math.pow(i,3)+3*Math.pow(i,2))*u+(Math.pow(i,3)-Math.pow(i,2))*f;t[n]=l}return t},getAnimationClip(t,e,n,r){const i=t.nodes[e]&&t.nodes[e].weights;return d(it,...at.TRANSLATION),T(st,...at.ROTATION),d(ot,...at.SCALE),this.P(r,t,e,n,it,st,ot,i)},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,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const n=s[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?C(e)?n[e]:n[Object.keys(n)[0]]:null}};let ft=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(t){}t&&"undefined"!=typeof createImageBitmap&&(ft=!0)}const lt="undefined"==typeof document?null:document.createElement("canvas");class ht{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}=et.read(e.buffer,e.byteOffset,e.byteLength);this.q(t,n,r)}else this.q(t,e);this.V=new Y(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(),i=this.$();return Promise.all([e,n,r,i]).then((t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0])))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const 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 ut.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return ut.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return N(t)}static readInterleavedArray(t,e,n,r,i,s,o){return V(t,e,n,r,i,s,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=ft?wt.bind(this):this.options.requestImage||dt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Z(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 Q(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)||U(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,i,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===r&&(n=s),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 C(t)?this.adapter.getAnimations(t):null}W(t){this.meshes={};let e=[];return this.adapter.iterate(((n,r,i)=>{e.push(this.et(r,t).then((t=>{t.index=i,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 F(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=[],i=t.extensions;if(C(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const i=this.adapter.accessor.A(\`morphTargets_${o}t}_${o}e}\`,n[t]);i&&r.push(i)}}if(i&&i.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:s,attributes:o}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[s],c=this.V.O(a).then((n=>{const{buffer:r,byteOffset:i}=n;let{byteOffset:s}=a;const c=a.byteLength;s||(s=0);const u=new DataView(r,i+s,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.A(t,e[t]);n&&r.push(n)}if(C(t.indices)){const e=this.adapter.accessor.A("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then((e=>{if(i&&i.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 s={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:i}=e,s=i.length/r;for(let e=0;e<s;e++)for(let s=0;s<r;s++){const o=e*r+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>n[s]&&(n[s]=i[o])}if(e.quantization){const r=e.quantization,i=r.range/(1<<r.quantizationBits),s=r.minValues;y(t,t,i),m(t,t,s),y(n,n,i),m(n,n,s)}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&&(s.indices=n),r&&(s.morphTargets=r),s.mode=C(t.mode)?t.mode:4,C(t.extras)&&(s.extras=t.extras),s}))}}function dt(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),i={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,i)},r.onerror=function(t){n(t)},r.src=t}const mt=[],yt=[],bt=10;let pt,gt;function wt(t,e,n){pt||(pt=new OffscreenCanvas(2,2),gt=pt.getContext("2d",{willReadFrequently:!0}));let r=null;if(U(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),mt.push([t,e,n,this]),vt();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(Mt.bind(this)).then((t=>{n(null,t)})).catch((t=>{console.warn(t),n(t)}))}}function vt(){if(!mt.length||yt.length>bt)return;const t=mt.shift(),[e,n,r,i]=t;yt.push(t),fetch(e,n).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then(Mt.bind(i)).then((e=>{r.call(i,null,e);const n=yt.indexOf(t);yt.splice(n,1),vt()})).catch((e=>{console.warn(e),r.call(i,e);const n=yt.indexOf(t);yt.splice(n,1),vt()}))}function Mt(t){let{width:e,height:n}=t;Tt(e)||(e=At(e)),Tt(n)||(n=At(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),pt.width=e,pt.height=n,gt.drawImage(t,0,0,e,n),t.close();const i=gt.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(i.data)}}function Tt(t){return!(t&t-1)&&0!==t}function At(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function _t(t){return t&&t.rt&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ot={exports:{}},kt={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,Et=kt.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];xt(i)?e=St.call(e,It.call(i)):e.push(i)}return e};Et.wrap=function(t){return function(){return t(Et(arguments))}};var Ct=kt.exports,Ut={"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]},Ft=Ct,Nt=Object.hasOwnProperty,Pt=Object.create(null);for(var Bt in Ut)Nt.call(Ut,Bt)&&(Pt[Ut[Bt]]=Bt);var Dt=Ot.exports={to:{},get:{}};function Rt(t,e,n){return Math.min(Math.max(e,t),n)}function Lt(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}Dt.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=Dt.get.hsl(t),n="hsl";break;case"hwb":e=Dt.get.hwb(t),n="hwb";break;default:e=Dt.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},Dt.get.rgb=function(t){if(!t)return null;var e,n,r,i=[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 s=2*n;i[n]=parseInt(e.slice(s,s+2),16)}r&&(i[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++)i[n]=parseInt(e[n]+e[n],16);r&&(i[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++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[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]:Nt.call(Ut,e[1])?((i=Ut[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=Rt(i[n],0,255);return i[3]=Rt(i[3],0,1),i},Dt.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,Rt(parseFloat(e[2]),0,100),Rt(parseFloat(e[3]),0,100),Rt(isNaN(n)?1:n,0,1)]}return null},Dt.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,Rt(parseFloat(e[2]),0,100),Rt(parseFloat(e[3]),0,100),Rt(isNaN(n)?1:n,0,1)]}return null},Dt.to.hex=function(){var t=Ft(arguments);return"#"+Lt(t[0])+Lt(t[1])+Lt(t[2])+(t[3]<1?Lt(Math.round(255*t[3])):"")},Dt.to.rgb=function(){var t=Ft(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]+")"},Dt.to.rgb.percent=function(){var t=Ft(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]+")"},Dt.to.hsl=function(){var t=Ft(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},Dt.to.hwb=function(){var t=Ft(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},Dt.to.keyword=function(t){return Pt[t.slice(0,3)]};var zt=Ot.exports,jt={exports:{}},qt={"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]},Vt={};for(var Gt in qt)qt.hasOwnProperty(Gt)&&(Vt[qt[Gt]]=Gt);var $t=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 Xt in $t)if($t.hasOwnProperty(Xt)){if(!("channels"in $t[Xt]))throw new Error("missing channels property: "+Xt);if(!("labels"in $t[Xt]))throw new Error("missing channel labels property: "+Xt);if($t[Xt].labels.length!==$t[Xt].channels)throw new Error("channel and label counts mismatch: "+Xt);var Ht=$t[Xt].channels,Jt=$t[Xt].labels;delete $t[Xt].channels,delete $t[Xt].labels,Object.defineProperty($t[Xt],"channels",{value:Ht}),Object.defineProperty($t[Xt],"labels",{value:Jt})}function Kt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}$t.rgb.hsl=function(t){var e,n,r=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(r,i,s),a=Math.max(r,i,s),c=a-o;return a===o?e=0:r===a?e=(i-s)/c:i===a?e=2+(s-r)/c:s===a&&(e=4+(r-i)/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]},$t.rgb.hsv=function(t){var e,n,r,i,s,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),l=function(t){return(u-t)/6/f+.5};return 0===f?i=s=0:(s=f/u,e=l(o),n=l(a),r=l(c),o===u?i=r-n:a===u?i=1/3+e-r:c===u&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*u]},$t.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[$t.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)))]},$t.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-i)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-i-e)/(1-e)||0),100*e]},$t.rgb.keyword=function(t){var e=Vt[t];if(e)return e;var n,r=1/0;for(var i in qt)if(qt.hasOwnProperty(i)){var s=Kt(t,qt[i]);s<r&&(r=s,n=i)}return n},$t.keyword.rgb=function(t){return qt[t]},$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)]},$t.rgb.lab=function(t){var e=$t.rgb.xyz(t),n=e[0],r=e[1],i=e[2];return r/=100,i/=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-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},$t.hsl.rgb=function(t){var e,n,r,i,s,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[s=255*c,s,s];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),i=[0,0,0];for(var u=0;u<3;u++)(r=o+1/3*-(u-1))<0&&r++,r>1&&r--,s=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,i[u]=255*s;return i},$t.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,i=n,s=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,i*=s<=1?s:2-s,[e,100*(0===r?2*i/(s+i):2*n/(r+n)),100*((r+n)/2)]},$t.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*s),c=255*r*(1-n*(1-s));switch(r*=255,i){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]}},$t.hsv.hsl=function(t){var e,n,r,i=t[0],s=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-s)*o,n=s*a,[i,100*(n=(n/=(e=(2-s)*a)<=1?e:2-e)||0),100*(r/=2)]},$t.hwb.rgb=function(t){var e,n,r,i,s,o,a,c=t[0]/360,u=t[1]/100,f=t[2]/100,l=u+f;switch(l>1&&(u/=l,f/=l),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),i=u+r*((n=1-f)-u),e){default:case 6:case 0:s=n,o=i,a=u;break;case 1:s=i,o=n,a=u;break;case 2:s=u,o=n,a=i;break;case 3:s=u,o=i,a=n;break;case 4:s=i,o=u,a=n;break;case 5:s=n,o=u,a=i}return[255*s,255*o,255*a]},$t.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},$t.xyz.rgb=function(t){var e,n,r,i=t[0]/100,s=t[1]/100,o=t[2]/100;return n=-.9689*i+1.8758*s+.0415*o,r=.0557*i+-.204*s+1.057*o,e=(e=3.2406*i+-1.5372*s+-.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))]},$t.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))]},$t.lab.xyz=function(t){var e,n,r,i=t[0];e=t[1]/500+(n=(i+16)/116),r=n-t[2]/200;var s=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=s>.008856?s:(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]},$t.lab.lch=function(t){var e,n=t[0],r=t[1],i=t[2];return(e=360*Math.atan2(i,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+i*i),e]},$t.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)]},$t.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],i=1 in arguments?arguments[1]:$t.rgb.hsv(t)[2];if(0===(i=Math.round(i/50)))return 30;var s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===i&&(s+=60),s},$t.hsv.ansi16=function(t){return $t.rgb.ansi16($t.hsv.rgb(t),t[2])},$t.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)},$t.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]},$t.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]},$t.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},$t.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]},$t.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255,s=Math.max(Math.max(n,r),i),o=Math.min(Math.min(n,r),i),a=s-o;return e=a<=0?0:s===n?(r-i)/a%6:s===r?2+(i-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},$t.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,i=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},$t.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},$t.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 i,s=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0;break;case 1:s[0]=c,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=a;break;case 3:s[0]=0,s[1]=c,s[2]=1;break;case 4:s[0]=a,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=c}return i=(1-n)*r,[255*(n*s[0]+i),255*(n*s[1]+i),255*(n*s[2]+i)]},$t.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]},$t.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]},$t.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)]},$t.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},$t.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},$t.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},$t.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},$t.gray.hsl=$t.gray.hsv=function(t){return[0,0,t[0]]},$t.gray.hwb=function(t){return[0,100,t[0]]},$t.gray.cmyk=function(t){return[0,0,0,t[0]]},$t.gray.lab=function(t){return[t[0],0,0]},$t.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},$t.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Yt=jt.exports,Qt=Yt;function Wt(t){var e=function(){for(var t={},e=Object.keys(Qt),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(),i=Object.keys(Qt[r]),s=i.length,o=0;o<s;o++){var a=i[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function Zt(t,e){return function(n){return e(t(n))}}function te(t,e){for(var n=[e[t].parent,t],r=Qt[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=Zt(Qt[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var ee=Yt,ne=function(t){for(var e=Wt(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s];null!==e[o].parent&&(n[o]=te(o,e))}return n},re={};Object.keys(ee).forEach((function(t){re[t]={},Object.defineProperty(re[t],"channels",{value:ee[t].channels}),Object.defineProperty(re[t],"labels",{value:ee[t].labels});var e=ne(t);Object.keys(e).forEach((function(n){var r=e[n];re[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,i=0;i<r;i++)n[i]=Math.round(n[i]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),re[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 ie=zt,se=re,oe=[].slice,ae=["keyword","gray","hex"],ce={};Object.keys(se).forEach((function(t){ce[oe.call(se[t].labels).sort().join("")]=t}));var ue={};function fe(t,e){if(!(this instanceof fe))return new fe(t,e);if(e&&e in ae&&(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 fe)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=ie.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=se[this.model].channels,this.color=i.value.slice(0,r),this.valpha="number"==typeof i.value[r]?i.value[r]:1}else if(t.length){this.model=e||"rgb",r=se[this.model].channels;var s=oe.call(t,0,r);this.color=de(s,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 ce))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ce[a];var c=se[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=de(u)}if(ue[this.model])for(r=se[this.model].channels,n=0;n<r;n++){var f=ue[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 le(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(ue[t]||(ue[t]=[]))[e]=n})),t=t[0],function(r){var i;return arguments.length?(n&&(r=n(r)),(i=this[t]()).color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function he(t){return function(e){return Math.max(0,Math.min(t,e))}}function de(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function me(t){return null==t}function ye(t){return"object"==typeof t&&!!t}function be(t){return t/Math.PI*180}fe.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in ie.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return ie.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 ie.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 fe(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 fe(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:le("rgb",0,he(255)),green:le("rgb",1,he(255)),blue:le("rgb",2,he(255)),hue:le(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:le("hsl",1,he(100)),lightness:le("hsl",2,he(100)),saturationv:le("hsv",1,he(100)),value:le("hsv",2,he(100)),chroma:le("hcg",1,he(100)),gray:le("hcg",2,he(100)),white:le("hwb",1,he(100)),wblack:le("hwb",2,he(100)),cyan:le("cmyk",0,he(100)),magenta:le("cmyk",1,he(100)),yellow:le("cmyk",2,he(100)),black:le("cmyk",3,he(100)),x:le("xyz",0,he(100)),y:le("xyz",1,he(100)),z:le("xyz",2,he(100)),l:le("lab",0,he(100)),a:le("lab",1),b:le("lab",2),keyword:function(t){return arguments.length?new fe(t):se[this.model].keyword(this.color)},hex:function(t){return arguments.length?new fe(t):ie.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 fe.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(),i=void 0===e?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,c=1-a;return fe.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*i+r.alpha()*(1-i))}},Object.keys(se).forEach((function(t){if(-1===ae.indexOf(t)){var e=se[t].channels;fe.prototype[t]=function(){if(this.model===t)return new fe(this);if(arguments.length)return new fe(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new fe((n=se[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},fe[t]=function(n){return"number"==typeof n&&(n=de(oe.call(arguments),e)),new fe(n,t)}}}));const pe=[1,1,1,1,2,2,3,0];function ge(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=pe[i>>3&7];if(!(64&i)||!n||r+n>e)return null;for(i&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;i=i<<6|63&e}}n+=String.fromCharCode(i)}return n}new Array(3),new Array(3);const we=[1/6378137,1/6378137,1/6356752.314245179],ve=[1/40680631590769,1/40680631590769,1/40408299984661.445],Me=new Array(3),Te=new Array(3),Ae=new Array(3);function _e(t,e){const n=ve,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],u=n[1],f=n[2],l=s*s*c*c,h=o*o*u*u,d=a*a*f*f,m=l+h+d,b=Math.sqrt(1/m),p=y(Oe,e,b);if(m<i)return isFinite(b)?p:void 0;const g=r[0],w=r[1],v=r[2],M=ke;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)*Se(e)/(.5*Se(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=l*x+h*S+d*I-1,A=l*E*g+h*C*w+d*U*v;N=T/(-2*A)}while(Math.abs(T)>xe);return t[0]=s*_,t[1]=o*O,t[2]=a*k,t}(Me,e,we,n,.1);let i=v(Te,r,n);i=function(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s);return t}(i,i);const s=w(Ae,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=function(t){return Math.sign?Math.sign(t):0==(t=+t)||isNaN(t)?Number(t):t>0?1:-1}(p(s,e))*Se(s);return t[0]=be(o),t[1]=be(a),t[2]=c,t}const Oe=new Array(3),ke=new Array(3),xe=1e-12;function Se(t){return f(t)}function Ie(t,e){let n="";for(let r=0;r<4;r++){const i=t.getUint8(e+r);n+=String.fromCharCode(i)}return n}const Ee="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ce(t,e,n){const r=new Uint8Array(t,e,n);return Ee?JSON.parse(Ee.decode(r)):JSON.parse(ge(r))}function Ue(t,e,n){const r=new Uint8Array(t,e,n);return Ee?JSON.parse(Ee.decode(r)):JSON.parse(ge(r))}function Fe(t,e,n){return{offset:e,byteLength:n}}function Ne(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=function(t){return De[t]}(s||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Be[t]}(o);return{byteStride:0,byteOffset:i+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+i,r*u)}}function Pe(t,e,n,r){const i=Ne(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const Be={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const De={"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 Re(t){for(const e in De)if(t===De[e].ctor)return De[e].type;throw new Error("unrecognized ctor:"+t)}function Le(t,e,n,r){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*r[0]+n[0],i[3*t+1]=e[3*t+1]/65535*r[1]+n[1],i[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return i}function ze(t,e,n){const r=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,u={},f={},l=null;r>0&&(u=Ce(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(f=Ue(a,e,s),e+=s);const h=Fe(0,e,o);return l=a.slice(h.offset,h.offset+h.byteLength),n.push(l),{featureTable:u,featureTableBin:c,batchTable:f,batchTableBin:l}}const je={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function qe(t){for(const e in je)if(t===je[e])return+e;throw new Error("unrecognized ctor:"+t)}let Ve=null;function Ge(){return Ve||(Ve={"image/crn":e.crn&&e.crn(),"image/ktx2":e.ktx2&&e.ktx2(),"image/cttf":e.ktx2&&e.ktx2(),"draco":e.draco&&e.draco()}),Ve}class $e{constructor(t,e,n){this.i=t,this.it=e||ht,this.o=n,this.st=Ge()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,i)):X.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r,i){const s=i&&i.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.it(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.st,supportedFormats:this.o,maxTextureSize:s});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${o}t}-${o}n}-${o}r}\`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}ct(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),u=i.getUint32(20,!0),f=i.getUint32(24,!0),l=28+e;u>=570425344?(l-=8,o=a,u=c,f=0,a=0,c=0):f>=570425344&&(l-=4,o=u,u=a,f=c,a=0,c=0);const h=[t];let d,m,y;if(a>0?(d=Ce(t,l,a),l+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(l+=c),u>0&&(m=Ue(t,l,u),l+=u,f>0)){const e=Fe(0,l,f);y=t.slice(e.offset,e.offset+e.byteLength),l+=f,h.push(y)}const b=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=Pe(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:m,batchTableBin:y,b3dm:p,glb:{buffer:t,byteOffset:l,byteLength:i.byteLength+i.byteOffset-l}}}ut(){return null}}class Xe{constructor(t,e,n,r){this.i=t,this.it=e||ht,this.o=n,this.st=Ge(),this.ft=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,i)):X.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r,i){return this.lt(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.ht(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}lt(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.st,supportedFormats:this.o,maxTextureSize:s},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=ge(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?X.getArrayBuffer(r,{}).then((t=>this.dt(r,{buffer:t.data,byteOffset:0},o))):X.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("/")),i=new this.it(r,e,n);return i.load({skipAttributeTransform:!0}).then((n=>{let r=0,s=0;return e.buffer&&(r=e.byteOffset||0,s=e.byteLength||0),n.url=\`${o}t}-${o}r}-${o}s}\`,{transferables:i.transferables,gltf:n}}))}ht(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=ze(i,32+e,o),l={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).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:h,componentType:5126,array:this.yt(new Uint16Array(t,r+c.offset,3*h),e,n)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Pe(a.BATCH_ID,t,c.offset,h);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:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).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:h,componentType:5126,array:this.bt(new Uint16Array(t,e+c.offset,2*h))},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.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(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).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:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:f,featureTable:a,i3dm:l,transferables:o}}bt(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)He(r,t[2*i],t[2*i+1],65535),n[3*i]=r[0],n[3*i+1]=r[1],n[3*i+2]=r[2];return n}yt(t,e,n){return Le(new Float32Array(t.length),t,e,n)}ut(){return null}}function He(t,e,n,r){if(t[0]=Je(e,r),t[1]=Je(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]))*Ke(e),t[1]=(1-Math.abs(e))*Ke(t[1])}return b(t,t)}function Je(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 Ke(t){return t<0?-1:1}class Ye{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.ot(t,e,n,r)):X.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,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 i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=ze(i,e+28,o),l=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,y={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){y=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,y.byteOffset+c.offset,y.byteLength);const e={attributes:y.properties,useUniqueIDs:!1};return this.wt||(this.wt=Ge().draco),this.wt(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.vt(t,e.attributes,c.offset,d,o,l,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:Re(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Pe(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Qe(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.vt(t,a,c.offset,d,o,l,h);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?b.BATCH_ID=Pe(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=Qe(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})}vt(t,e,n,r,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.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.yt(u||new Uint16Array(t,c+f,3*r),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},i.push(o.buffer)}return a}yt(t,e,n){return Le(new Float32Array(t.length),t,e,n)}ut(){return null}}function Qe(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:Re(e),array:r}}class We{constructor(t,e,n,r){this.o=n,this.i=t,this.it=e||ht,this.ft=r}load(t,e,n=0,r=0,i){return e?this.ot(t,e,n,r,i):X.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.ot(t,i,n,r)}))}ot(t,e,n,r,i){r||(r=e.byteLength);const s=this.Mt(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new $e(this.i,this.it,this.o);else if("i3dm"===s[n].magic)r=new Xe(this.i,this.it,this.o,this.ft);else if("pnts"===s[n].magic)r=new Ye;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new We(this.i,this.it,this.o,this.ft)}o.push(r.load(t,e,s[n].offset,s[n].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Mt(t,e,n,r){const i=new DataView(t,n,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Ie(i,c),r=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function Ze(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,i=r.length;n<i;n++){const i=[];an(r[n],i,t,e)}}}const tn=[],en=[],nn=[],rn=[0,0,0],sn=O([]),on=[1,1,1];function an(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=s(tn,t.translation||rn),n=a(en,t.rotation||sn),r=o(nn,t.scale||on);i(r,n,r);const u=i([],e,r);c.push(u)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)an(t.children[e],c,n,r);if(void 0!==t.mesh){const e=t.mesh,i=n.meshes[e];if(i){const t=c.slice(0),s=i.primitives;for(let i=0,o=s.length;i<o;i++){const o=s[i];o&&(o.matrices=t,r(o,e,i,n))}}}}function cn(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?ht.getTypedArrayCtor(s):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,i=i||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,i*o);for(let r=0;r<i*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<i;t++){const i=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);u.set(i);e(new c(u.buffer),t),i.set(u)}}var un=mn("DXT1"),fn=mn("DXT3"),ln=mn("DXT5"),hn=mn("DX10"),dn=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 i=r[21];switch(i){case un:e=8,n="dxt1";break;case fn:e=16,n="dxt3";break;case ln:e=16,n="dxt5";break;case 116:n="rgba32f";break;case hn:var s=new Uint32Array(t.slice(128,148));n=s[0];var o=s[1];if(s[2],s[3],s[4],3!==o||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=i,String.fromCharCode(255&a,a>>8&255,a>>16&255,a>>24&255)))}var a;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var f=!1;512&r[28]&&(f=!0);var l,h=r[4],d=r[3],m=r[1]+4,y=h,b=d,p=[];i===hn&&(m+=20);if(f)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=y,d=b;for(var w=Math.log(h)/Math.log(2)+1,v=0;v<w;v++)l=h*d*16,p.push({offset:m,length:l,shape:[h,d]}),v<u&&(m+=l),h=Math.floor(h/2),d=Math.floor(d/2)}else for(v=0;v<u;v++)l=Math.max(4,h)/4*Math.max(4,d)/4*e,p.push({offset:m,length:l,shape:[h,d]}),m+=l,h=Math.floor(h/2),d=Math.floor(d/2);return{shape:[y,b],images:p,format:n,flags:c,cubemap:f}};function mn(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var yn=_t(dn),bn=Math.abs,pn=Math.sin,gn=Math.cos,wn=Math.tan,vn=Math.atan,Mn=Math.atan2,Tn=Math.sqrt,An=Math.log,_n=Math.hypot,On=Math.sinh,kn=Math.cosh,xn=1/0;function Sn(t){var e,n,r,i,s,o,a=[],c=[],u=[],f=[];function l(t,e){for(var n,r=2*gn(2*e),i=t.length-1,s=t[i],o=0;--i>=0;)n=r*s-o+t[i],o=s,s=n;return e+n*pn(2*e)}function h(t,e,n){for(var r,i,s=pn(e),o=gn(e),a=On(n),c=kn(n),u=2*o*c,f=-2*s*a,l=t.length-1,h=t[l],d=0,m=0,y=0;--l>=0;)r=m,i=d,h=u*(m=h)-r-f*(d=y)+t[l],y=f*m-i+u*d;return[(u=s*c)*h-(f=o*a)*y,u*y+f*h]}t.es,s=i=(r=t.es/(1+Tn(1-t.es)))/(2-r),a[0]=i*(2+i*(-2/3+i*(i*(116/45+i*(26/45+i*(-2854/675)))-2))),c[0]=i*(i*(2/3+i*(4/3+i*(-82/45+i*(32/45+i*(4642/4725)))))-2),s*=i,a[1]=s*(7/3+i*(i*(-227/45+i*(2704/315+i*(2323/945)))-1.6)),c[1]=s*(5/3+i*(-16/15+i*(-13/9+i*(904/315+i*(-1522/945))))),s*=i,a[2]=s*(56/15+i*(-136/35+i*(-1262/105+i*(73814/2835)))),c[2]=s*(-26/15+i*(34/21+i*(1.6+i*(-12686/2835)))),s*=i,a[3]=s*(4279/630+i*(-332/35+i*(-399572/14175))),c[3]=s*(1237/630+i*(i*(-24832/14175)-2.4)),s*=i,a[4]=s*(4174/315+i*(-144838/6237)),c[4]=s*(-734/315+i*(109598/31185)),s*=i,a[5]=s*(601676/22275),c[5]=s*(444337/155925),s=i*i,e=t.k0/(1+i)*(1+s*(1/4+s*(1/64+s/256))),u[0]=i*(i*(2/3+i*(-37/96+i*(1/360+i*(81/512+i*(-96199/604800)))))-.5),f[0]=i*(.5+i*(-2/3+i*(5/16+i*(41/180+i*(-127/288+i*(7891/37800)))))),u[1]=s*(-1/48+i*(-1/15+i*(437/1440+i*(-46/105+i*(1118711/3870720))))),f[1]=s*(13/48+i*(i*(557/1440+i*(281/630+i*(-1983433/1935360)))-.6)),s*=i,u[2]=s*(-17/480+i*(37/840+i*(209/4480+i*(-5569/90720)))),f[2]=s*(61/240+i*(-103/140+i*(15061/26880+i*(167603/181440)))),s*=i,u[3]=s*(-4397/161280+i*(11/504+i*(830251/7257600))),f[3]=s*(49561/161280+i*(-179/168+i*(6601661/7257600))),s*=i,u[4]=s*(-4583/161280+i*(108847/3991680)),f[4]=s*(34729/80640+i*(-3418889/1995840)),s*=i,u[5]=s*(-20648693/638668800),f[5]=.6650675310896665*s,o=l(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*gn(e),i=t.length-1,s=t[i],o=0;for(;--i>=0;)n=r*s-o+t[i],o=s,s=n;return pn(e)*n}(f,2*o)),t.fwd=function(t,r){var i,s,o,a,u,d=t.phi,m=t.lam;d=l(c,d),i=pn(d),s=gn(d),a=pn(m),o=gn(m),d=Mn(i,o*s),m=Mn(a*s,_n(i,s*o)),m=function(t){var e=bn(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*An(e)/n}(e*(1+e/(_n(1,e)+1))),t<0?-e:e}(wn(m)),u=h(f,2*d,2*m),d+=u[0],m+=u[1],bn(m)<=2.623395162778?(r.y=e*d+n,r.x=e*m):r.x=r.y=xn},t.inv=function(t,r){var i,s,o,c,f,d=t.y,m=t.x;d=(d-n)/e,bn(m/=e)<=2.623395162778?(d+=(f=h(u,2*d,2*m))[0],m+=f[1],m=vn(On(m)),i=pn(d),s=gn(d),c=pn(m),o=gn(m),m=Mn(c,o*s),d=Mn(i*o,_n(c,o*s)),r.phi=l(a,d),r.lam=m):r.phi=r.lam=xn}}const In=Math.PI/180,En=6378137*Math.PI/180,Cn=85.0511287798,Un={};function Fn(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=Cn,r=e[0],i=Math.max(Math.min(n,e[1]),-n);let s;s=0===i?0:Math.log(Math.tan((90+i)*In/2))/In;return t[0]=r*En,t[1]=s*En,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return Nn(t,e);if("baidu"===n)return Nn(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 i=JSON.stringify(n);let s=Un[i];return s||(s=Un[i]=function(t){const e={a:Bn,es:Dn,x0:me(t.falseEasting)?5e5:t.falseEasting,y0:me(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*Pn,phi0:(t.latitudeOfOrigin||0)*Pn,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Sn(e);const n={lam:0,phi:0},r={};let i=0,s=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*Pn-e.lam0,n.phi=e.originPhi0*Pn,e.fwd(n,r),i=e.a*r.x+e.x0,s=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*Pn-e.lam0,n.phi=t[1]*Pn,e.fwd(n,r);const a=e.a*r.x+e.x0-i,c=e.a*r.y+e.y0-s;return o[0]=a,o[1]=c,o}}}(n)),s.project(e,t)}}function Nn(t,e){return t[0]=e[0],t[1]=e[1],t}const Pn=.017453292519943295,Bn=6378137,Dn=.0066943799901413165;const Rn=r([]),Ln=Ge().draco,zn=Ge().ktx2,jn={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},qn={"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 Vn(t,e,n,i,s,o){const a=[],c=[],u=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],i=X.getArrayBuffer(n.url,o);i.xhr.url=n.url,u.push(i.xhr);const s=i.then((t=>({buffer:t})));a.push(s);const f=[];if(Qn(r,f),f.length){const t=f.map((t=>{const e=X.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}const f=function(t,e,n,i,s,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:l}=t.meshes[u];let h;const d=e[u].geoBuffer.data;if(!d)continue;h=rr(d)?$n(a,u,l,d,t.transform,t.center,s,o):Hn(a,u,l,d,t.transform,t.center,s,o),c.push(h),a.nodes[u]={mesh:u,nodeIndex:u,matrix:r([])},a.scenes[0].nodes[u]=a.nodes[u],f||(f=jn);const m=Kn(u,a,f,e[u].textureBuffers,n,i);c.push(m)}return Promise.all(c).then((()=>({gltf:a,featureTable:{BATCH_LENGTH:0},transferables:a.transferables})))}(t,a,e,s,n,i);return f}));return f.xhr=u,f}const Gn={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function $n(t,e,n,r,i,s,o,a){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=qn[e];if(!r)return t;return t[r.name||e]=n,t}),{});return Ln(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>Jn(n,t,e,i,s,o,a)))}const Xn={position:function(t,e,n){const r=3*t.vertexCount,i=new Float32Array(e,n,r);return t.position={array:i,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,i=new Float32Array(e,n,r);return t.normal={array:i,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,i=new Float32Array(e,n,r);return t.uv0={array:i,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,i=new Uint8Array(e,n,r);return t.color={array:i,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,i=new Uint32Array(e,n,r);return t.faceRange={array:i,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,i=new Uint16Array(e,n,r);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,i=new Uint16Array(e,n,r);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Hn(t,e,n,r,i,s,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++)Xn[n[e]]?t=Xn[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let i=e.ordering,s=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<i.length;e++){const n=Xn[i[e]];n||console.log(i[e]),t=n(c,r,t)}for(let e=0;e<s.length;e++){const n=Xn[s[e]];n||console.log(s[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=qn[t]&&qn[t].name;e&&(f[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(l=e)<=255?Uint8Array:l<=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,i=t[e],s=t[e+1];for(let t=i;t<=s;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}f._BATCHID={componentType:qe(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var l;return Jn({attributes:f},t,e,i,s,o,a)}function Jn(t,e,n,r,i,s,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,i){let s,o=[0,0,0,1];const a=[0,0],u=Fn([],n,r,i);u[2]=n[2];const f=e&&c(Rn,e);return cn(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],f||(o=g(o,o,e)),n&&m(o,o,n),Fn(a,o,r,i),s=o[2],t[0]=a[0]-u[0],t[1]=a[1]-u[1],t[2]=s-u[2],t))),u}(t.attributes.POSITION,r,i,s,o);e.meshes[n]={primitives:[a],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:i};for(const n in t.attributes)nr(e.transferables,t.attributes[n].array.buffer);return t.indices&&nr(e.transferables,t.indices.array.buffer),a}function Kn(t,e,n,r,i,s){const o=r.map((t=>function(t,e,n,r,i){if("dds"===e){const e=yn(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),i="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Gn,format:i})}if("png"===e||"jpg"===e)return function(t,e){Wn||(Wn=new OffscreenCanvas(2,2),Zn=Wn.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;tr(n)||(n=er(n)),tr(r)||(r=er(r));const i=e;i&&(n=Math.min(i,n),r=Math.min(i,r)),Wn.width=n,Wn.height=r,Zn.drawImage(t,0,0,n,r),t.close();const s=Zn.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(s.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,i).then((t=>{t.mimeType=n;return{image:t,sampler:Gn,format:6408}}));if("ktx2"===e)return zn(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Gn,format:t.format})));return null}(t.data,t.format,t.mimeType,i,s).then((t=>{if(t.image)if(t.image.array)nr(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)nr(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(o).then((r=>{Yn(t,e,n,r)}))}function Yn(t,e,n,r){const i=JSON.parse(JSON.stringify(n)),s=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(s.push(r[r.ptr++]),i[t]={index:s.length-1},void 0!==n[t].factor&&(i[t].scale=n[t].factor)):ye(n[t])&&(i[t]=Yn(-1,e,n[t],r));return t>=0&&(e.materials[t]=i),i}function Qn(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])&&Qn(t[n],e)}let Wn,Zn;function tr(t){return!(t&t-1)&&0!==t}function er(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function nr(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function rr(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 ir="undefined"!=typeof Float32Array?Float32Array:Array;function sr(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var or=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 ir(3);return ir!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const ar=[];const cr=[],ur=[],fr=[],lr=[],hr=[],dr=[],mr=[];function yr(t,e,n,r,i,s){sr(lr,t[3*e],t[3*e+1],t[3*e+2]),sr(hr,t[3*n],t[3*n+1],t[3*n+2]),sr(dr,t[3*r],t[3*r+1],t[3*r+2]);const o=or(cr,dr,hr),a=or(ur,lr,hr),c=function(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[0],a=n[1],c=n[2];return t[0]=i*c-s*a,t[1]=s*o-r*c,t[2]=r*a-i*o,t}(fr,o,a);!function(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;s>0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s)}(mr,c),i[3*e]=i[3*e]||0,i[3*n]=i[3*n]||0,i[3*r]=i[3*r]||0,i[3*e+1]=i[3*e+1]||0,i[3*n+1]=i[3*n+1]||0,i[3*r+1]=i[3*r+1]||0,i[3*e+2]=i[3*e+2]||0,i[3*n+2]=i[3*n+2]||0,i[3*r+2]=i[3*r+2]||0,i[3*e]+=mr[0],i[3*n]+=mr[0],i[3*r]+=mr[0],i[3*e+1]+=mr[1],i[3*n+1]+=mr[1],i[3*r+1]+=mr[1],i[3*e+2]+=mr[2],i[3*n+2]+=mr[2],i[3*r+2]+=mr[2],s[e]+=1,s[n]+=1,s[r]+=1}const br=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],pr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],gr=2*Math.PI*6378137/360,wr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let vr,Mr,Tr=!1;if("undefined"!=typeof OffscreenCanvas){try{Mr=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}Mr&&"undefined"!=typeof createImageBitmap&&(Tr=!0)}const Ar=r([]),_r=[0,0,0],Or=[],kr=[],xr=[],Sr=[],Ir={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Er={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Cr;class Ur{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 Ye,this.kt=new $e(this.Tt,ht,t),this.St=new Xe(this.Tt,ht,t))}requestImage(t,e){Tr?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{vr.width=t.width,vr.height=t.height,Mr.drawImage(t,0,0);const n=Mr.getImageData(0,0,vr.width,vr.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:i}=t,s=n.fetchOptions||{};if(s.referrer=t.referrer,s.referrerPolicy=s.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const i=t.i3sInfo,o=n.maxTextureSize||0,a=Vn(i,t.supportedFormats,this.options.projection,t.projection,o,s);return a.then((t=>{if(delete this._t[r],!t)return void e({status:404,url:r,i3sInfo:i});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:i});t.gltf.url=r;const{transferables:s}=t;t.magic="b3dm",this.It(t.gltf),n.compressGeometry&&this.Et(t.gltf),e(null,t,s)})),void(this._t[r]=a.xhr)}if(i){delete this._t[r];const n=Ie(new DataView(i),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(wr){const r=new Uint8Array(t,e,n);return wr.decode(r)}return ge(new Uint8Array(t,e,n))}(i,0,i.byteLength),s=JSON.parse(n);s.accessors?this.Ct(s,r,t,"gltf",e):this.Ut(t.rootIdx,s,i,r,e)}else this.Ct(i,r,t,n,e)}else{let i=n.urlParams;i&&(i=(r.indexOf("?")>0?"&":"?")+i);const o=r.replace(/\\+/g,"%2B");let a=X.getArrayBuffer(o+(i||""),s);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,i){r=r&&r.toLowerCase();const{service:s}=n;if("b3dm"===r){this.kt.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:r}=this.Ft(t,n);this.It(e.gltf),s.compressGeometry&&this.Et(e.gltf),i(null,e,r)})).catch((t=>{i(t)}))}else if("pnts"===r){const r=n.transform||Ar;this.xt.load(e,t).then((t=>{const{content:e,transferables:s}=this.Nt(t,r,n.rootIdx);this.Pt(e),i(null,e,s)}))}else if("i3dm"===r){const r=n.transform||Ar;this.St.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{const{content:e,transferables:o}=this.Bt(t,r,n.rootIdx);this.It(e.gltf),s.compressGeometry&&this.Et(e.gltf),i(null,e,o)}))}else if("cmpt"===r){new We(this.Tt,ht,this.o,s.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Dt(t,n);this.Rt(e),s.compressGeometry&&this.Lt(e),i(null,e,r)})).catch((t=>{i(t)}))}else if("gltf"===r){this.st||(this.st=Ge());const r=e.substring(0,e.lastIndexOf("/")),o=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t,a=new ht(r,o,{transferable:!0,requestImage:this.Tt,decoders:this.st,supportedFormats:this.o,maxTextureSize:s.maxTextureSize||0});a.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.zt(t,null,n),this.It(t),s.compressGeometry&&this.Et(t),i(null,{magic:"gltf",gltf:t},a.transferables)}))}else i(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)}jt(t,e){if(this.qt(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.Vt()?Cr.subarray(0,n):e,i=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const i=ar;i.length<t.length/3&&(i.length=t.length/3),i.fill(0,0,t.length/3);const s=void 0===e.length?e:e.length;for(let n=0;n<s/3;n++)void 0===e.length?yr(t,3*n,3*n+1,3*n+2,r,i):yr(t,e[3*n],e[3*n+1],e[3*n+2],r,i);const o=r.getLength?r.getLength():r.length;for(let t=0;t<o;t+=3){const e=i[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:i,byteLength:i.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:i.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(Ir[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=gr,t.compressed_int16_params.compressed_ratio=r);const i=Rr(e[n].array,r,e[n].min,e[n].max,n);if(!i)continue;const{array:s,range:o}=i;e[n].componentType=5124,e[n].array=s,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.jt(e,t)}))}}Pt(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(Ir[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=gr,t.compressed_int16_params.compressed_ratio=r);const{array:i,range:s}=Rr(e[n].array,r,e[n].min,e[n].max,n);e[n].array=i,t.compressed_int16_params[n]=s}}Gt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const i={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(i)}return e}Ut(t,e,n,r,i){return e.capabilities,void i(null,e)}Dt(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},i=[];for(let t=0;t<n.length;t++){const{magic:s}=n[t];if("b3dm"===s){const{content:s,transferables:o}=this.Ft(n[t],e);Br(i,o),r.content.push(s)}else if("i3dm"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Bt(n[t],s,o);Br(i,c),r.content.push(a)}else if("pnts"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Nt(n[t],s,o);Br(i,c),r.content.push(a)}else if("cmpt"===s){const{content:s,transferables:o}=this.Dt(n[t],e);Br(i,o),r.content.push(s)}}return{content:r,transferables:i}}Ft(t,e){const{gltf:n,transferables:r,featureTable:i}=t;return this.zt(n,i,e),delete t.transferables,{content:t,transferables:r}}zt(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;const e="visited";let n=1;const r=[];for(const i in t.meshes){const s=t.meshes[i],{primitives:o}=s;if(o)for(let t=0;t<o.length;t++){const i=o[t].attributes&&o[t].attributes.POSITION;if(!i||!i.array)continue;i.array.buffer[e]||(i.array.buffer[e]=n++);const s=n-1+"-"+(i.byteOffset||0);if(r.indexOf(s)>=0)return!0;r.push(s)}}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,i=t.i3dm,s=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&c(Ar,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Nr(i.POSITION.array,3,s,Ar,u);const f=Pr(u);e&&!a&&g(f,f,e);const l=this.Jt(f),m=[];Fn(m,l,o),m[2]=l[2];const y=h([],f),b=[0,0,0],p=[0,0,0],w=[0,0],v=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0];cn(i.POSITION,(t=>{b[0]=t[0]+s[0],b[1]=t[1]+s[1],b[2]=t[2]+s[2],e&&!a&&g(b,b,e),0===M(b)?d(p,0,0,-6378137):_e(p,b),Fn(w,p,o),t[0]=w[0]-m[0],t[1]=w[1]-m[1],t[2]=p[2]-m[2],t[0]<v[0]&&(v[0]=t[0]),t[1]<v[1]&&(v[1]=t[1]),t[2]<v[2]&&(v[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])})),i.POSITION.min=v,i.POSITION.max=T,e&&g(f,f,e),t.rtcCenter=y,t.rtcCoord=l,t.projCenter=m,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}Nt(t,e,n){const{featureTable:r}=t,i=t.pnts,s=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&c(Ar,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Nr(i.POSITION.array,3,s,e,u);const f=Pr(u),l=this.Kt(f),m=h([],f),y=[1/0,1/0,1/0],b=[-1/0,-1/0,-1/0];let p=[0,0,0,1];const w=[0,0,0],v=[0,0];cn(i.POSITION,(t=>(p[0]=t[0]+s[0],p[1]=t[1]+s[1],p[2]=t[2]+s[2],e&&!a&&(p=g(p,p,e)),0===M(p)?d(w,0,0,-6378137):_e(w,p),Fn(v,w,o),t[0]=v[0]-l[0],t[1]=v[1]-l[1],t[2]=w[2]-l[2],t[0]<y[0]&&(y[0]=t[0]),t[1]<y[1]&&(y[1]=t[1]),t[2]<y[2]&&(y[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))),i.POSITION.min=y,i.POSITION.max=b,e&&g(f,f,e);const T=this.Jt(f);t.rtcCenter=m,t.projCenter=l,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],i=n[1],s=n[2],o=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==i||n[t+2]!==s||n[t+3]!==o){a=!1;break}a&&(e[t].image.color=[r/255,i/255,s/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,n,s){const o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let a=br;"X"===(n=n&&n.toUpperCase())?a=pr:"Z"===n&&(a=Ar),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};Ze(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=r(Or);t.matrices&&Dr(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;i(e,a,e),s&&i(e,s,e),Nr(n,u,o||_r,e,c,t.compressUniforms)}));const u=Pr(c);return{rtcCenter:o,modelCenter:u,upAxisTransform:a}}Xt(t,e,n,s){const{modelCenter:o,upAxisTransform:a,rtcCenter:c}=this.Yt(t,e,n),u=this.Kt(o);t.extensions.MAPTALKS_RTC.projCenter=u,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Jt(o);const f=h([],o);s&&g(o,o,s),t.extensions.CESIUM_RTC.rtcCoord=this.Jt(o),c||(Ze(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(Or);t.matrices&&Dr(n,t.matrices),i(n,a,n);const s=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],u=e[7],f=e[8],l=e[9],h=e[10],d=e[11],m=e[12],y=e[13],b=e[14],p=e[15],g=n*a-r*o,w=n*c-i*o,v=n*u-s*o,M=r*c-i*a,T=r*u-s*a,A=i*u-s*c,_=f*y-l*m,O=f*b-h*m,k=f*p-d*m,x=l*b-h*y,S=l*p-d*y,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]=(i*S-r*I-s*x)*E,t[2]=(y*A-b*T+p*M)*E,t[3]=(h*T-l*A-d*M)*E,t[4]=(c*k-o*I-u*O)*E,t[5]=(n*I-i*k+s*O)*E,t[6]=(b*v-m*A-p*w)*E,t[7]=(f*A-h*v+d*w)*E,t[8]=(o*S-a*k+u*_)*E,t[9]=(r*k-n*S-s*_)*E,t[10]=(m*T-y*v+p*g)*E,t[11]=(l*v-f*T-d*g)*E,t[12]=(a*O-o*x-c*_)*E,t[13]=(n*x-r*O+i*_)*E,t[14]=(y*w-m*M-b*g)*E,t[15]=(f*M-l*w+h*g)*E,t):null}(kr,n),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];cn(e,(t=>{g(t,t,n),t[0]=t[0]-f[0],t[1]=t[1]-f[1],t[2]=t[2]-f[2],g(t,t,s),t[0]<o[0]&&(o[0]=t[0]),t[1]<o[1]&&(o[1]=t[1]),t[2]<o[2]&&(o[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),e.min=o,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=f)}Ht(t,e,n,r){const{modelCenter:i,rtcCenter:s}=this.Yt(t,e,n,r),o=this.Kt(i);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Jt(i),Ze(t,(e=>{if(e.attributes&&e.attributes.POSITION){const i=this.qt(e,t);if(i){const t=e.attributes.POSITION.array.length;(!Cr||Cr.length<t)&&(Cr=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,s,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,i),{componentType:a}=e.attributes.POSITION;5126!==a&&(e.attributes.POSITION.array=new Float32Array(o))}}));for(const e in t.nodes){t.nodes[e].matrix=Ar}}Kt(t){const e=this.options.projection;"identity"===e?h(xr,t):0===M(t)?d(xr,0,0,-6378137):_e(xr,t),Fn(Sr,xr,e);const n=xr[2],r=[];return r[0]=Sr[0],r[1]=Sr[1],r[2]=n,r}Qt(t,e,n){let r;r="Y"===n?br:"X"===n?pr:Ar;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}([],r);if(Dr(i,e),c(i,Ar))return;const s=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}([],i),o=[];cn(t,(t=>(function(t,e,n){var r=e[0],i=e[1],s=e[2];t[0]=r*n[0]+i*n[3]+s*n[6],t[1]=r*n[1]+i*n[4]+s*n[7],t[2]=r*n[2]+i*n[5]+s*n[8]}(o,t,s),b(o,o),h(t,o),o)))}Wt(t,e,n,i,s,o,a,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const f=r([]);Dr(f,e);const l=this.options.projection;s=s&&s.toUpperCase();const h=n;let y=null;"Y"===s?y=br:"X"===s&&(y=pr);let b=[0,0,0,1];const p=[0,0,0],w=[0,0],v=i.projCenter,T=Fn([],i.rtcCoord,"EPSG:3857"),A=o&&c(Ar,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 k=a||{},{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 cn(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=g(b,b,f),y&&(b=g(b,b,y)),h&&m(b,b,h),o&&!A&&(b=g(b,b,o)),0===M(b)?d(p,0,0,-6378137):_e(p,b),u){const t=Cr;Fn(w,p,l),t[3*n]=w[0]-T[0],t[3*n+1]=w[0]-T[1],t[3*n+2]=w[0]-T[2]}if(Fn(w,p,l),e instanceof Float32Array)e[0]=w[0]-v[0],e[1]=w[1]-v[1],e[2]=p[2]-v[2];else{const n=w[0]-v[0],r=w[1]-v[1],i=p[2]-v[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(i),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:v,newPositions:C}}Jt(t){return 0===M(t)?d([],0,0,-6378137):_e([],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 Fr=[];function Nr(t,e,n,r,i,s){const o=s||{},{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 s=0,o=t.length;s<o;s+=e){const{xmin:o,ymin:a,xmax:c,ymax:l,hmin:h,hmax:y}=i;d(Fr,t[s]*f+u[0],t[s+1]*f+u[1],t[s+2]*f+u[2]),g(Fr,Fr,r);const b=m(Fr,n,Fr);b[0]<o&&(i.xmin=b[0]),b[0]>c&&(i.xmax=b[0]),b[1]<a&&(i.ymin=b[1]),b[1]>l&&(i.ymax=b[1]),e>2&&(b[2]<h&&(i.hmin=b[2]),b[2]>y&&(i.hmax=b[2]))}}function Pr(t){const{xmax:e,ymax:n,xmin:r,ymin:i,hmin:s,hmax:o}=t,a=[(r+e)/2,(i+n)/2,(s+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 Br(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function Dr(t,e){const n=t;for(let t=e.length-1;t>=0;t--)i(n,e[t],n);return n}function Rr(t,e,n,r,i){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let s,o;if(n&&r&&1===e)s=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);s=e,o=n}return!function(t,e,n,r){for(let i=0;i<t.length;i++){const s=Lr(zr(t[i],e,n),e,n);if(Math.abs(s-t[i])>Er[r])return!1}return!0}(t,s,o,i)&&Er[i]?null:function(t,e,n){const r=new Int16Array(t.length);for(let i=0;i<t.length;i++)r[i]=zr(t[i],e,n);return{array:r,range:[e,n]}}(t,s,o)}function Lr(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function zr(t,e,n){const r=2*(t-e)/(n-e)-1,i=Math.max(-1,Math.min(1,r));return i<0?32768*i:32767*i}let jr=0;class qr{constructor(t){this.workerId=t,this.workers={},this.Zt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},i){if(this.te(e,n))return;const s=this.ee(e,n),o=r.options,a=this.send.bind(this,t);this.workers[s]=new Ur(n,o,a,i)}removeLayer({mapId:t,layerId:e},n){const r=this.te(t,e),i=this.ee(t,e);delete this.workers[i],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const i=this.te(t,e);i&&i.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const i=this.te(t,e);i&&i.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,i){const s=i?\`${o}t}-${o}jr++}\`:null;i&&(this.Zt[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(s)},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 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&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}(this.exports=this.exports||{},transcoders));`
|
|
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,e,n){var r="undefined"!=typeof Float32Array?Float32Array:Array;function a(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i(t,e,n){var r=e[0],a=e[1],i=e[2],o=e[3],s=e[4],c=e[5],u=e[6],l=e[7],f=e[8],h=e[9],y=e[10],d=e[11],b=e[12],m=e[13],p=e[14],g=e[15],v=n[0],w=n[1],M=n[2],T=n[3];return t[0]=v*r+w*s+M*f+T*b,t[1]=v*a+w*c+M*h+T*m,t[2]=v*i+w*u+M*y+T*p,t[3]=v*o+w*l+M*d+T*g,v=n[4],w=n[5],M=n[6],T=n[7],t[4]=v*r+w*s+M*f+T*b,t[5]=v*a+w*c+M*h+T*m,t[6]=v*i+w*u+M*y+T*p,t[7]=v*o+w*l+M*d+T*g,v=n[8],w=n[9],M=n[10],T=n[11],t[8]=v*r+w*s+M*f+T*b,t[9]=v*a+w*c+M*h+T*m,t[10]=v*i+w*u+M*y+T*p,t[11]=v*o+w*l+M*d+T*g,v=n[12],w=n[13],M=n[14],T=n[15],t[12]=v*r+w*s+M*f+T*b,t[13]=v*a+w*c+M*h+T*m,t[14]=v*i+w*u+M*y+T*p,t[15]=v*o+w*l+M*d+T*g,t}function o(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 s(){var t=new r(3);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function c(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function u(t,e,n){var a=new r(3);return a[0]=t,a[1]=e,a[2]=n,a}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function f(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function h(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){var n=e[0],r=e[1],a=e[2],i=n*n+r*r+a*a;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 d(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function b(t,e,n){var r=e[0],a=e[1],i=e[2],o=n[3]*r+n[7]*a+n[11]*i+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*a+n[8]*i+n[12])/o,t[1]=(n[1]*r+n[5]*a+n[9]*i+n[13])/o,t[2]=(n[2]*r+n[6]*a+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 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},p=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},g=c;function v(){var t=new r(4);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}s(),function(){var t,e=(t=new r(4),r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var w;function M(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}s(),u(1,0,0),u(0,1,0),v(),v(),w=new r(9),r!=Float32Array&&(w[1]=0,w[2]=0,w[3]=0,w[5]=0,w[6]=0,w[7]=0),w[0]=1,w[4]=1,w[8]=1;var T={exports:{}},A={exports:{}},k=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))},O=Array.prototype.concat,S=Array.prototype.slice,x=A.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var a=t[n];k(a)?e=O.call(e,S.call(a)):e.push(a)}return e};x.wrap=function(t){return function(){return t(x(arguments))}};var _=A.exports,I={"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]},F=_,C=Object.hasOwnProperty,E=Object.create(null);for(var U in I)C.call(I,U)&&(E[I[U]]=U);var N=T.exports={to:{},get:{}};function z(t,e,n){return Math.min(Math.max(e,t),n)}function D(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}N.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=N.get.hsl(t),n="hsl";break;case"hwb":e=N.get.hwb(t),n="hwb";break;default:e=N.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},N.get.rgb=function(t){if(!t)return null;var e,n,r,a=[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;a[n]=parseInt(e.slice(i,i+2),16)}r&&(a[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++)a[n]=parseInt(e[n]+e[n],16);r&&(a[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++)a[n]=parseInt(e[n+1],0);e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[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]:C.call(I,e[1])?((a=I[e[1]])[3]=1,a):null:null;for(n=0;n<3;n++)a[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}for(n=0;n<3;n++)a[n]=z(a[n],0,255);return a[3]=z(a[3],0,1),a},N.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,z(parseFloat(e[2]),0,100),z(parseFloat(e[3]),0,100),z(isNaN(n)?1:n,0,1)]}return null},N.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,z(parseFloat(e[2]),0,100),z(parseFloat(e[3]),0,100),z(isNaN(n)?1:n,0,1)]}return null},N.to.hex=function(){var t=F(arguments);return"#"+D(t[0])+D(t[1])+D(t[2])+(t[3]<1?D(Math.round(255*t[3])):"")},N.to.rgb=function(){var t=F(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]+")"},N.to.rgb.percent=function(){var t=F(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]+")"},N.to.hsl=function(){var t=F(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},N.to.hwb=function(){var t=F(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},N.to.keyword=function(t){return E[t.slice(0,3)]};var P=T.exports,L={exports:{}},j={"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]},B={};for(var q in j)j.hasOwnProperty(q)&&(B[j[q]]=q);var R=L.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 V in R)if(R.hasOwnProperty(V)){if(!("channels"in R[V]))throw new Error("missing channels property: "+V);if(!("labels"in R[V]))throw new Error("missing channel labels property: "+V);if(R[V].labels.length!==R[V].channels)throw new Error("channel and label counts mismatch: "+V);var G=R[V].channels,$=R[V].labels;delete R[V].channels,delete R[V].labels,Object.defineProperty(R[V],"channels",{value:G}),Object.defineProperty(R[V],"labels",{value:$})}R.rgb.hsl=function(t){var e,n,r=t[0]/255,a=t[1]/255,i=t[2]/255,o=Math.min(r,a,i),s=Math.max(r,a,i),c=s-o;return s===o?e=0:r===s?e=(a-i)/c:a===s?e=2+(i-r)/c:i===s&&(e=4+(r-a)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+s)/2,[e,100*(s===o?0:n<=.5?c/(s+o):c/(2-s-o)),100*n]},R.rgb.hsv=function(t){var e,n,r,a,i,o=t[0]/255,s=t[1]/255,c=t[2]/255,u=Math.max(o,s,c),l=u-Math.min(o,s,c),f=function(t){return(u-t)/6/l+.5};return 0===l?a=i=0:(i=l/u,e=f(o),n=f(s),r=f(c),o===u?a=r-n:s===u?a=1/3+e-r:c===u&&(a=2/3+n-e),a<0?a+=1:a>1&&(a-=1)),[360*a,100*i,100*u]},R.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[R.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)))]},R.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-a)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-a-e)/(1-e)||0),100*e]},R.rgb.keyword=function(t){var e=B[t];if(e)return e;var n,r,a,i=1/0;for(var o in j)if(j.hasOwnProperty(o)){var s=j[o],c=(r=t,a=s,Math.pow(r[0]-a[0],2)+Math.pow(r[1]-a[1],2)+Math.pow(r[2]-a[2],2));c<i&&(i=c,n=o)}return n},R.keyword.rgb=function(t){return j[t]},R.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)]},R.rgb.lab=function(t){var e=R.rgb.xyz(t),n=e[0],r=e[1],a=e[2];return r/=100,a/=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-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},R.hsl.rgb=function(t){var e,n,r,a,i,o=t[0]/360,s=t[1]/100,c=t[2]/100;if(0===s)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+s):c+s-c*s),a=[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,a[u]=255*i;return a},R.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,a=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,a*=i<=1?i:2-i,[e,100*(0===r?2*a/(i+a):2*n/(r+n)),100*((r+n)/2)]},R.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,a=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),s=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,a){case 0:return[r,c,o];case 1:return[s,r,o];case 2:return[o,r,c];case 3:return[o,s,r];case 4:return[c,o,r];case 5:return[r,o,s]}},R.hsv.hsl=function(t){var e,n,r,a=t[0],i=t[1]/100,o=t[2]/100,s=Math.max(o,.01);return r=(2-i)*o,n=i*s,[a,100*(n=(n/=(e=(2-i)*s)<=1?e:2-e)||0),100*(r/=2)]},R.hwb.rgb=function(t){var e,n,r,a,i,o,s,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),a=u+r*((n=1-l)-u),e){default:case 6:case 0:i=n,o=a,s=u;break;case 1:i=a,o=n,s=u;break;case 2:i=u,o=n,s=a;break;case 3:i=u,o=a,s=n;break;case 4:i=a,o=u,s=n;break;case 5:i=n,o=u,s=a}return[255*i,255*o,255*s]},R.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,a=t[3]/100;return[255*(1-Math.min(1,e*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,r*(1-a)+a))]},R.xyz.rgb=function(t){var e,n,r,a=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*a+1.8758*i+.0415*o,r=.0557*a+-.204*i+1.057*o,e=(e=3.2406*a+-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))]},R.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))]},R.lab.xyz=function(t){var e,n,r,a=t[0];e=t[1]/500+(n=(a+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),s=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=s>.008856?s:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},R.lab.lch=function(t){var e,n=t[0],r=t[1],a=t[2];return(e=360*Math.atan2(a,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+a*a),e]},R.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)]},R.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],a=1 in arguments?arguments[1]:R.rgb.hsv(t)[2];if(0===(a=Math.round(a/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===a&&(i+=60),i},R.hsv.ansi16=function(t){return R.rgb.ansi16(R.hsv.rgb(t),t[2])},R.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)},R.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]},R.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]},R.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},R.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]},R.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255,i=Math.max(Math.max(n,r),a),o=Math.min(Math.min(n,r),a),s=i-o;return e=s<=0?0:i===n?(r-a)/s%6:i===r?2+(a-n)/s:4+(n-r)/s+4,e/=6,[360*(e%=1),100*s,100*(s<1?o/(1-s):0)]},R.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,a=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(a=(n-.5*r)/(1-r)),[t[0],100*r,100*a]},R.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},R.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 a,i=[0,0,0],o=e%1*6,s=o%1,c=1-s;switch(Math.floor(o)){case 0:i[0]=1,i[1]=s,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]=s;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=s,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return a=(1-n)*r,[255*(n*i[0]+a),255*(n*i[1]+a),255*(n*i[2]+a)]},R.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]},R.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]},R.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)]},R.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},R.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},R.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},R.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},R.gray.hsl=R.gray.hsv=function(t){return[0,0,t[0]]},R.gray.hwb=function(t){return[0,100,t[0]]},R.gray.cmyk=function(t){return[0,0,0,t[0]]},R.gray.lab=function(t){return[t[0],0,0]},R.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},R.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var X=L.exports,H=X;function J(t){var e=function(){for(var t={},e=Object.keys(H),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(),a=Object.keys(H[r]),i=a.length,o=0;o<i;o++){var s=a[o],c=e[s];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(s))}return e}function Y(t,e){return function(n){return e(t(n))}}function K(t,e){for(var n=[e[t].parent,t],r=H[e[t].parent][t],a=e[t].parent;e[a].parent;)n.unshift(e[a].parent),r=Y(H[e[a].parent][a],r),a=e[a].parent;return r.conversion=n,r}var Q=X,Z=function(t){for(var e=J(t),n={},r=Object.keys(e),a=r.length,i=0;i<a;i++){var o=r[i];null!==e[o].parent&&(n[o]=K(o,e))}return n},W={};Object.keys(Q).forEach((function(t){W[t]={},Object.defineProperty(W[t],"channels",{value:Q[t].channels}),Object.defineProperty(W[t],"labels",{value:Q[t].labels});var e=Z(t);Object.keys(e).forEach((function(n){var r=e[n];W[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,a=0;a<r;a++)n[a]=Math.round(n[a]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),W[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 tt=P,et=W,nt=[].slice,rt=["keyword","gray","hex"],at={};Object.keys(et).forEach((function(t){at[nt.call(et[t].labels).sort().join("")]=t}));var it={};function ot(t,e){if(!(this instanceof ot))return new ot(t,e);if(e&&e in rt&&(e=null),e&&!(e in et))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 ot)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var a=tt.get(t);if(null===a)throw new Error("Unable to parse color from string: "+t);this.model=a.model,r=et[this.model].channels,this.color=a.value.slice(0,r),this.valpha="number"==typeof a.value[r]?a.value[r]:1}else if(t.length){this.model=e||"rgb",r=et[this.model].channels;var i=nt.call(t,0,r);this.color=ut(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 s=o.sort().join("");if(!(s in at))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=at[s];var c=et[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=ut(u)}if(it[this.model])for(r=et[this.model].channels,n=0;n<r;n++){var l=it[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 st(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(it[t]||(it[t]=[]))[e]=n})),t=t[0],function(r){var a;return arguments.length?(n&&(r=n(r)),(a=this[t]()).color[e]=r,a):(a=this[t]().color[e],n&&(a=n(a)),a)}}function ct(t){return function(e){return Math.max(0,Math.min(t,e))}}function ut(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function lt(t){return null==t}function ft(t){return"object"==typeof t&&!!t}function ht(t){return t/Math.PI*180}ot.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in tt.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return tt.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 tt.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=et[this.model].channels,n=et[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 ot(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 ot(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:st("rgb",0,ct(255)),green:st("rgb",1,ct(255)),blue:st("rgb",2,ct(255)),hue:st(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:st("hsl",1,ct(100)),lightness:st("hsl",2,ct(100)),saturationv:st("hsv",1,ct(100)),value:st("hsv",2,ct(100)),chroma:st("hcg",1,ct(100)),gray:st("hcg",2,ct(100)),white:st("hwb",1,ct(100)),wblack:st("hwb",2,ct(100)),cyan:st("cmyk",0,ct(100)),magenta:st("cmyk",1,ct(100)),yellow:st("cmyk",2,ct(100)),black:st("cmyk",3,ct(100)),x:st("xyz",0,ct(100)),y:st("xyz",1,ct(100)),z:st("xyz",2,ct(100)),l:st("lab",0,ct(100)),a:st("lab",1),b:st("lab",2),keyword:function(t){return arguments.length?new ot(t):et[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ot(t):tt.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 ot.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(),a=void 0===e?.5:e,i=2*a-1,o=n.alpha()-r.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-s;return ot.rgb(s*n.red()+c*r.red(),s*n.green()+c*r.green(),s*n.blue()+c*r.blue(),n.alpha()*a+r.alpha()*(1-a))}},Object.keys(et).forEach((function(t){if(-1===rt.indexOf(t)){var e=et[t].channels;ot.prototype[t]=function(){if(this.model===t)return new ot(this);if(arguments.length)return new ot(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ot((n=et[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ot[t]=function(n){return"number"==typeof n&&(n=ut(nt.call(arguments),e)),new ot(n,t)}}}));const yt=[1,1,1,1,2,2,3,0];function dt(t){const e=t.length;let n="";for(let r=0;r<e;){let a=t[r++];if(128&a){let n=yt[a>>3&7];if(!(64&a)||!n||r+n>e)return null;for(a&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;a=a<<6|63&e}}n+=String.fromCharCode(a)}return n}new Array(3),new Array(3);const bt=[1/6378137,1/6378137,1/6356752.314245179],mt=[1/40680631590769,1/40680631590769,1/40408299984661.445],pt=new Array(3),gt=new Array(3),vt=new Array(3);function wt(t,e){const n=mt,r=function(t,e,n,r,a){const i=e[0],o=e[1],s=e[2],c=n[0],u=n[1],l=n[2],f=i*i*c*c,h=o*o*u*u,y=s*s*l*l,d=f+h+y,b=Math.sqrt(1/d),m=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(Mt,e,b);if(d<a)return isFinite(b)?m:void 0;const p=r[0],g=r[1],v=r[2],w=Tt;w[0]=m[0]*p*2,w[1]=m[1]*g*2,w[2]=m[2]*v*2;let M,T,A,k,O,S,x,_,I,F,C,E=(1-b)*kt(e)/(.5*kt(w)),U=0;do{E-=U,A=1/(1+E*p),k=1/(1+E*g),O=1/(1+E*v),S=A*A,x=k*k,_=O*O,I=S*A,F=x*k,C=_*O,M=f*S+h*x+y*_-1,T=f*I*p+h*F*g+y*C*v;U=M/(-2*T)}while(Math.abs(M)>At);return t[0]=i*A,t[1]=o*k,t[2]=s*O,t}(pt,e,bt,n,.1);let a=p(gt,r,n);a=function(t,e){const n=e[0],r=e[1],a=e[2];let i=n*n+r*r+a*a;i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i);return t}(a,a);const i=m(vt,e,r),o=Math.atan2(a[1],a[0]),s=Math.asin(a[2]),c=(u=d(i,e),(Math.sign?Math.sign(u):0==(u=+u)||isNaN(u)?Number(u):u>0?1:-1)*kt(i));var u;return t[0]=ht(o),t[1]=ht(s),t[2]=c,t}const Mt=new Array(3),Tt=new Array(3),At=1e-12;function kt(t){return c(t)}function Ot(t,e){let n="";for(let r=0;r<4;r++){const a=t.getUint8(e+r);n+=String.fromCharCode(a)}return n}const St="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function xt(t,e,n){const r=new Uint8Array(t,e,n);return St?JSON.parse(St.decode(r)):JSON.parse(dt(r))}function _t(t,e,n){const r=new Uint8Array(t,e,n);return St?JSON.parse(St.decode(r)):JSON.parse(dt(r))}function It(t,e,n){return{offset:e,byteLength:n}}function Ft(t,e,n,r){const{byteOffset:a,componentType:i,type:o}=t,{ctor:s,type:c}=function(t){return Ut[t]}(i||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Et[t]}(o);return{byteStride:0,byteOffset:a+n,itemSize:u,count:r*u,componentType:c,array:new s(e,n+a,r*u)}}function Ct(t,e,n,r){const a=Ft(t,e,n,r);return a.array.buffer.byteLength!==e.byteLength&&(a.array=a.array.slice()),a}const Et={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Ut={"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 Nt(t){for(const e in Ut)if(t===Ut[e].ctor)return Ut[e].type;throw new Error("unrecognized ctor:"+t)}function zt(t,e,n,r){const a=t,i=e.length/3;for(let t=0;t<i;t++)a[3*t]=e[3*t]/65535*r[0]+n[0],a[3*t+1]=e[3*t+1]/65535*r[1]+n[1],a[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return a}function Dt(t,e,n){const r=t.getUint32(12,!0),a=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),s=t.buffer;let c,u={},l={},f=null;r>0&&(u=xt(s,e,r),e+=r),a>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,a),e+=a),i>0&&(l=_t(s,e,i),e+=i);const h=It(0,e,o);return f=s.slice(h.offset,h.offset+h.byteLength),n.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}const Pt={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Lt(t){for(const e in Pt)if(t===Pt[e])return+e;throw new Error("unrecognized ctor:"+t)}let jt=null;function Bt(){return jt||(jt={"image/crn":n.crn&&n.crn(),"image/ktx2":n.ktx2&&n.ktx2(),"image/cttf":n.ktx2&&n.ktx2(),"draco":n.draco&&n.draco()}),jt}class qt{constructor(t,n,r){this.i=t,this.o=n||e.GLTFLoader,this.u=r,this.h=Bt()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,n,r=0,a=0,i){return n?(a||(a=n.byteLength),this.m(t,n,r,a,i)):e.Ajax.getArrayBuffer(t,{}).then((e=>{const n=e.data;return a||(a=n.byteLength),this.m(t,n,r,a)}))}m(t,e,n,r,a){const i=a&&a.maxTextureSize,o=this.p(e,n,r,t);if(o.error)return Promise.resolve(o);const s=t.substring(0,t.lastIndexOf("/")),c=new this.o(s,o.glb,{transferable:!0,requestImage:this.i,decoders:this.h,supportedFormats:this.u,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${o}t}-${o}n}-${o}r}\`;const a=c.transferables;for(let t=0;t<o.transferables.length;t++)a.indexOf(o.transferables[t])<0&&a.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:a,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}p(t,e,n,r){const a=new DataView(t,e,n),i=a.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,s=a.getUint32(12,!0),c=a.getUint32(16,!0),u=a.getUint32(20,!0),l=a.getUint32(24,!0),f=28+e;u>=570425344?(f-=8,o=s,u=c,l=0,s=0,c=0):l>=570425344&&(f-=4,o=u,u=s,l=c,s=0,c=0);const h=[t];let y,d,b;if(s>0?(y=xt(t,f,s),f+=s,o=y.BATCH_LENGTH):y={"BATCH_LENGTH":o},c>0&&(f+=c),u>0&&(d=_t(t,f,u),f+=u,l>0)){const e=It(0,f,l);b=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(b)}const m=y.BATCH_LENGTH,p={};if(y&&y.BATCH_ID){p.BATCH_ID=Ct(y.BATCH_ID,t,undefined.offset,m);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:y,batchTable:d,batchTableBin:b,b3dm:p,glb:{buffer:t,byteOffset:f,byteLength:a.byteLength+a.byteOffset-f}}}v(){return null}}class Rt{constructor(t,n,r,a){this.i=t,this.o=n||e.GLTFLoader,this.u=r,this.h=Bt(),this.M=a}load(t,n,r=0,a=0,i){return n?(a||(a=n.byteLength),this.m(t,n,r,a,i)):e.Ajax.getArrayBuffer(t,{}).then((e=>{const n=e.data;return a||(a=n.byteLength),this.m(t,n,r,a)}))}m(t,e,n,r,a){return this.T(t,e,n,r,a).then((({gltf:a,transferables:i})=>{const o=this.A(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 a.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:a})}))}T(t,n,r,a,i){const o=i&&i.maxTextureSize,s={transferable:!0,requestImage:this.i,decoders:this.h,supportedFormats:this.u,maxTextureSize:o},c=new DataView(n,r,a),u=32+c.getUint32(12,!0)+c.getUint32(16,!0)+c.getUint32(20,!0)+c.getUint32(24,!0);if(0===c.getUint32(28,!0)){let a=dt(new Uint8Array(n,u+r,c.byteLength-u));-1==a.indexOf("://")&&(a=t.substring(0,t.lastIndexOf("/"))+"/"+a);return a.indexOf(".glb")>0?e.Ajax.getArrayBuffer(a,{}).then((t=>this.k(a,{buffer:t.data,byteOffset:0},s))):e.Ajax.getJSON(a,{}).then((t=>this.k(a,t,s)))}{const e={buffer:n,byteOffset:u+r,byteLength:c.byteLength-u};return this.k(t,e,s)}}k(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),a=new this.o(r,e,n);return a.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:a.transferables,gltf:n}}))}A(t,e,n,r){const a=new DataView(t,e,n),i=a.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.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:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,32+e,o),f={},h=s.INSTANCES_LENGTH;if(s.POSITION){const{byteOffset:e}=s.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(s.POSITION_QUANTIZED){const e=s.QUANTIZED_VOLUME_OFFSET,n=s.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=s.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,r+c.offset,3*h),e,n)},o.push(f.POSITION.array.buffer)}if(s.BATCH_ID){f.BATCH_ID=Ct(s.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(s.NORMAL_UP){let{byteOffset:e}=s.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=s.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(s.NORMAL_UP_OCT32P){let{byteOffset:e}=s.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.S(new Uint16Array(t,e+c.offset,2*h))},o.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.S(new Uint16Array(t,e+c.offset,2*h))},o.push(f.NORMAL_RIGHT.array.buffer)}if(s.SCALE){const{byteOffset:e}=s.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(s.SCALE_NON_UNIFORM){const{byteOffset:e}=s.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:s,i3dm:f,transferables:o}}S(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let a=0;a<e;a++)Vt(r,t[2*a],t[2*a+1],65535),n[3*a]=r[0],n[3*a+1]=r[1],n[3*a+2]=r[2];return n}O(t,e,n){return zt(new Float32Array(t.length),t,e,n)}v(){return null}}function Vt(t,e,n,r){if(t[0]=Gt(e,r),t[1]=Gt(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]))*$t(e),t[1]=(1-Math.abs(e))*$t(t[1])}return y(t,t)}function Gt(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 $t(t){return t<0?-1:1}class Xt{constructor(){}load(t,n,r=0,a=0){return n?(a||(a=n.byteLength),this.m(t,n,r,a)):e.Ajax.getArrayBuffer(t,{}).then((e=>{const n=e.data;return a||(a=n.byteLength),this.m(t,n,r,a)}))}m(t,e,n,r){return this._(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}))}_(t,e,n,r){const a=new DataView(t,e,n),i=a.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.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:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,e+28,o),f=s.QUANTIZED_VOLUME_OFFSET,h=s.QUANTIZED_VOLUME_SCALE,y=s.POINTS_LENGTH;let d,b={};if(s.extensions&&s.extensions["3DTILES_draco_point_compression"]){b=s.extensions["3DTILES_draco_point_compression"],d=new DataView(t,b.byteOffset+c.offset,b.byteLength);const e={attributes:b.properties,useUniqueIDs:!1};return this.I||(this.I=Bt().draco),this.I(d,e).then((e=>{const n=e.attributes;!s.POSITION&&!s.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=s.POSITION,n.POSITION_QUANTIZED=s.POSITION_QUANTIZED),!(s.RGB||s.RGBA||s.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=s.RGB,n.RGBA=s.RGBA,n.RGB565=s.RGB565),!s.NORMAL&&!s.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=s.NORMAL,n.NORMAL_OCT16P=s.NORMAL_OCT16P);const r=this.F(t,e.attributes,c.offset,y,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:Nt(t.constructor),array:t},o.push(t.buffer)}else if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?r.BATCH_ID=Ct(s.BATCH_ID,t,c.offset,y):r.BATCH_ID=Ht(y);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:r,transferables:o}}))}const m=this.F(t,s,c.offset,y,o,f,h);if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?m.BATCH_ID=Ct(s.BATCH_ID,t,c.offset,y):m.BATCH_ID=Ht(y);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:m,transferables:o})}F(t,e,n,r,a,i,o){const s={};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)}s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},a.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;s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.O(u||new Uint16Array(t,c+l,3*r),i,o)},a.push(s.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)}s.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},a.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)}s.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},a.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)}s.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},a.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)}s.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},a.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)}s.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},a.push(o.buffer)}return s}O(t,e,n){return zt(new Float32Array(t.length),t,e,n)}v(){return null}}function Ht(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:Nt(e),array:r}}class Jt{constructor(t,n,r,a){this.u=r,this.i=t,this.o=n||e.GLTFLoader,this.M=a}load(t,n,r=0,a=0,i){return n?this.m(t,n,r,a,i):e.Ajax.getArrayBuffer(t,{}).then((e=>{const n=e.data;return this.m(t,n,r,a)}))}m(t,e,n,r,a){r||(r=e.byteLength);const i=this.C(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new qt(this.i,this.o,this.u);else if("i3dm"===i[n].magic)r=new Rt(this.i,this.o,this.u,this.M);else if("pnts"===i[n].magic)r=new Xt;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new Jt(this.i,this.o,this.u,this.M)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,a).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}C(t,e,n,r){const a=new DataView(t,n,r),i=a.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===a.byteLength)return[];const o=[],s=a.getUint32(12,!0);let c=16;for(let e=0;e<s;e++){const e=Ot(a,c),r=a.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function Yt(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,a=r.length;n<a;n++){const a=[];ne(r[n],a,t,e)}}}const Kt=[],Qt=[],Zt=[],Wt=[0,0,0],te=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),ee=[1,1,1];function ne(t,e,n,r){const a=e.slice(0);if(t.matrix)a.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(Kt,t.translation||Wt),n=function(t,e){var n=e[0],r=e[1],a=e[2],i=e[3],o=n+n,s=r+r,c=a+a,u=n*o,l=r*o,f=r*s,h=a*o,y=a*s,d=a*c,b=i*o,m=i*s,p=i*c;return t[0]=1-f-d,t[1]=l+p,t[2]=h-m,t[3]=0,t[4]=l-p,t[5]=1-u-d,t[6]=y+b,t[7]=0,t[8]=h+m,t[9]=y-b,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(Qt,t.rotation||te),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(Zt,t.scale||ee);i(r,n,r);const o=i([],e,r);a.push(o)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)ne(t.children[e],a,n,r);if(void 0!==t.mesh){const e=t.mesh,i=n.meshes[e];if(i){const t=a.slice(0),o=i.primitives;for(let a=0,i=o.length;a<i;a++){const i=o[a];i&&(i.matrices=t,r(i,e,a,n))}}}}function re(t,n){let{byteOffset:r,byteStride:a,count:i}=t;const{componentType:o,itemSize:s}=t,c=t.array.buffer,u=o?e.GLTFLoader.getTypedArrayCtor(o):t.array.constructor;if(r=void 0===r?t.array.byteOffset:r,a=a||0,i=i||t.array.length/s,(!a||a===s*u.BYTES_PER_ELEMENT)&&r%u.BYTES_PER_ELEMENT==0){const t=new u(c,r,i*s);for(let e=0;e<i*s;e+=s){n(new u(t.buffer,r+e*u.BYTES_PER_ELEMENT,s),e/s)}return}const l=new Uint8Array(s*u.BYTES_PER_ELEMENT);a||(a=s*u.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const e=new Uint8Array(c,a*t+r,s*u.BYTES_PER_ELEMENT);l.set(e);n(new u(l.buffer),t),e.set(l)}}var ae=ce("DXT1"),ie=ce("DXT3"),oe=ce("DXT5"),se=ce("DX10");function ce(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var ue=M((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 a=r[21];switch(a){case ae:e=8,n="dxt1";break;case ie:e=16,n="dxt3";break;case oe:e=16,n="dxt5";break;case 116:n="rgba32f";break;case se: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: "+(s=a,String.fromCharCode(255&s,s>>8&255,s>>16&255,s>>24&255)))}var s;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],y=r[3],d=r[1]+4,b=h,m=y,p=[];a===se&&(d+=20);if(l)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=b,y=m;for(var v=Math.log(h)/Math.log(2)+1,w=0;w<v;w++)f=h*y*16,p.push({offset:d,length:f,shape:[h,y]}),w<u&&(d+=f),h=Math.floor(h/2),y=Math.floor(y/2)}else for(w=0;w<u;w++)f=Math.max(4,h)/4*Math.max(4,y)/4*e,p.push({offset:d,length:f,shape:[h,y]}),d+=f,h=Math.floor(h/2),y=Math.floor(y/2);return{shape:[b,m],images:p,format:n,flags:c,cubemap:l}})),le=Math.abs,fe=Math.sin,he=Math.cos,ye=Math.tan,de=Math.atan,be=Math.atan2,me=Math.sqrt,pe=Math.log,ge=Math.hypot,ve=Math.sinh,we=Math.cosh,Me=1/0;function Te(t){var e,n,r,a,i,o,s=[],c=[],u=[],l=[];function f(t,e){for(var n,r=2*he(2*e),a=t.length-1,i=t[a],o=0;--a>=0;)n=r*i-o+t[a],o=i,i=n;return e+n*fe(2*e)}function h(t,e,n){for(var r,a,i=fe(e),o=he(e),s=ve(n),c=we(n),u=2*o*c,l=-2*i*s,f=t.length-1,h=t[f],y=0,d=0,b=0;--f>=0;)r=d,a=y,h=u*(d=h)-r-l*(y=b)+t[f],b=l*d-a+u*y;return[(u=i*c)*h-(l=o*s)*b,u*b+l*h]}t.es,i=a=(r=t.es/(1+me(1-t.es)))/(2-r),s[0]=a*(2+a*(-2/3+a*(a*(116/45+a*(26/45+a*(-2854/675)))-2))),c[0]=a*(a*(2/3+a*(4/3+a*(-82/45+a*(32/45+a*(4642/4725)))))-2),i*=a,s[1]=i*(7/3+a*(a*(-227/45+a*(2704/315+a*(2323/945)))-1.6)),c[1]=i*(5/3+a*(-16/15+a*(-13/9+a*(904/315+a*(-1522/945))))),i*=a,s[2]=i*(56/15+a*(-136/35+a*(-1262/105+a*(73814/2835)))),c[2]=i*(-26/15+a*(34/21+a*(1.6+a*(-12686/2835)))),i*=a,s[3]=i*(4279/630+a*(-332/35+a*(-399572/14175))),c[3]=i*(1237/630+a*(a*(-24832/14175)-2.4)),i*=a,s[4]=i*(4174/315+a*(-144838/6237)),c[4]=i*(-734/315+a*(109598/31185)),i*=a,s[5]=i*(601676/22275),c[5]=i*(444337/155925),i=a*a,e=t.k0/(1+a)*(1+i*(1/4+i*(1/64+i/256))),u[0]=a*(a*(2/3+a*(-37/96+a*(1/360+a*(81/512+a*(-96199/604800)))))-.5),l[0]=a*(.5+a*(-2/3+a*(5/16+a*(41/180+a*(-127/288+a*(7891/37800)))))),u[1]=i*(-1/48+a*(-1/15+a*(437/1440+a*(-46/105+a*(1118711/3870720))))),l[1]=i*(13/48+a*(a*(557/1440+a*(281/630+a*(-1983433/1935360)))-.6)),i*=a,u[2]=i*(-17/480+a*(37/840+a*(209/4480+a*(-5569/90720)))),l[2]=i*(61/240+a*(-103/140+a*(15061/26880+a*(167603/181440)))),i*=a,u[3]=i*(-4397/161280+a*(11/504+a*(830251/7257600))),l[3]=i*(49561/161280+a*(-179/168+a*(6601661/7257600))),i*=a,u[4]=i*(-4583/161280+a*(108847/3991680)),l[4]=i*(34729/80640+a*(-3418889/1995840)),i*=a,u[5]=i*(-20648693/638668800),l[5]=.6650675310896665*i,o=f(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*he(e),a=t.length-1,i=t[a],o=0;for(;--a>=0;)n=r*i-o+t[a],o=i,i=n;return fe(e)*n}(l,2*o)),t.fwd=function(t,r){var a,i,o,s,u,y=t.phi,d=t.lam;y=f(c,y),a=fe(y),i=he(y),s=fe(d),o=he(d),y=be(a,o*i),d=be(s*i,ge(a,i*o)),d=function(t){var e=le(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*pe(e)/n}(e*(1+e/(ge(1,e)+1))),t<0?-e:e}(ye(d)),u=h(l,2*y,2*d),y+=u[0],d+=u[1],le(d)<=2.623395162778?(r.y=e*y+n,r.x=e*d):r.x=r.y=Me},t.inv=function(t,r){var a,i,o,c,l,y=t.y,d=t.x;y=(y-n)/e,le(d/=e)<=2.623395162778?(y+=(l=h(u,2*y,2*d))[0],d+=l[1],d=de(ve(d)),a=fe(y),i=he(y),c=fe(d),o=he(d),d=be(c,o*i),y=be(a*o,ge(c,o*i)),r.phi=f(s,y),r.lam=d):r.phi=r.lam=Me}}const Ae=Math.PI/180,ke=6378137*Math.PI/180,Oe=85.0511287798,Se={};function xe(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=Oe,r=e[0],a=Math.max(Math.min(n,e[1]),-n);let i;i=0===a?0:Math.log(Math.tan((90+a)*Ae/2))/Ae;return t[0]=r*ke,t[1]=i*ke,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return _e(t,e);if("baidu"===n)return _e(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 a=JSON.stringify(n);let i=Se[a];return i||(i=Se[a]=function(t){const e={a:Fe,es:Ce,x0:lt(t.falseEasting)?5e5:t.falseEasting,y0:lt(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*Ie,phi0:(t.latitudeOfOrigin||0)*Ie,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Te(e);const n={lam:0,phi:0},r={};let a=0,i=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*Ie-e.lam0,n.phi=e.originPhi0*Ie,e.fwd(n,r),a=e.a*r.x+e.x0,i=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*Ie-e.lam0,n.phi=t[1]*Ie,e.fwd(n,r);const s=e.a*r.x+e.x0-a,c=e.a*r.y+e.y0-i;return o[0]=s,o[1]=c,o}}}(n)),i.project(e,t)}}function _e(t,e){return t[0]=e[0],t[1]=e[1],t}const Ie=.017453292519943295,Fe=6378137,Ce=.0066943799901413165;const Ee=a([]),Ue=Bt().draco,Ne=Bt().ktx2,ze={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},De={"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 Pe(t,n,r,i,o,s){const c=[],u=[],l=[];for(let n=0;n<t.meshes.length;n++){const{geometry:r,material:a}=t.meshes[n],i=e.Ajax.getArrayBuffer(r.url,s);i.xhr.url=r.url,l.push(i.xhr);const o=i.then((t=>({buffer:t})));c.push(o);const f=[];if($e(a,f),f.length){const t=f.map((t=>{const n=e.Ajax.getArrayBuffer(t.url,s);return n.xhr.url=t.url,l.push(n.xhr),n.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));c.push(...t)}u[n]=f.length}const f=Promise.all(c).then((e=>{for(let t=0;t<e.length;t++)if(!e[t]||!e[t].buffer)return Promise.resolve(null);const s=[];let c=0;for(let t=0;t<u.length;t++){const n=u[t];s.push({geoBuffer:{data:e[c].buffer.data},textureBuffers:e.slice(c+1,n+c+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),c+=1+n}const l=function(t,e,n,r,i,o){const s={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 y=e[u].geoBuffer.data;if(!y)continue;h=Qe(y)?je(s,u,f,y,t.transform,t.center,i,o):qe(s,u,f,y,t.transform,t.center,i,o),c.push(h),s.nodes[u]={mesh:u,nodeIndex:u,matrix:a([])},s.scenes[0].nodes[u]=s.nodes[u],l||(l=ze);const d=Ve(u,s,l,e[u].textureBuffers,n,r);c.push(d)}return Promise.all(c).then((()=>({gltf:s,featureTable:{BATCH_LENGTH:0},transferables:s.transferables})))}(t,s,n,o,r,i);return l}));return f.xhr=l,f}const Le={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function je(t,e,n,r,a,i,o,s){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=De[e];if(!r)return t;return t[r.name||e]=n,t}),{});return Ue(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>Re(n,t,e,a,i,o,s)))}const Be={position:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.position={array:a,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,a=new Float32Array(e,n,r);return t.normal={array:a,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,a=new Float32Array(e,n,r);return t.uv0={array:a,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,a=new Uint8Array(e,n,r);return t.color={array:a,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,a=new Uint32Array(e,n,r);return t.faceRange={array:a,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function qe(t,e,n,r,a,i,o,s){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++)Be[n[e]]?t=Be[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let a=e.ordering,i=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<a.length;e++){const n=Be[a[e]];n||console.log(a[e]),t=n(c,r,t)}for(let e=0;e<i.length;e++){const n=Be[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=De[t]&&De[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,a=t[e],i=t[e+1];for(let t=a;t<=i;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}l._BATCHID={componentType:Lt(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var f;return Re({attributes:l},t,e,a,i,o,s)}function Re(t,e,n,r,a,i,s){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,a){let i,s=[0,0,0,1];const c=[0,0],u=xe([],n,r,a);u[2]=n[2];const l=e&&o(Ee,e);return re(t,(t=>(s[0]=t[0],s[1]=t[1],s[2]=t[2],l||(s=b(s,s,e)),n&&h(s,s,n),xe(c,s,r,a),i=s[2],t[0]=c[0]-u[0],t[1]=c[1]-u[1],t[2]=i-u[2],t))),u}(t.attributes.POSITION,r,a,i,s);e.meshes[n]={primitives:[c],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:a};for(const n in t.attributes)Ke(e.transferables,t.attributes[n].array.buffer);return t.indices&&Ke(e.transferables,t.indices.array.buffer),c}function Ve(t,e,n,r,a,i){const o=r.map((t=>function(t,e,n,r,a){if("dds"===e){const e=ue(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),a="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Le,format:a})}if("png"===e||"jpg"===e)return function(t,e){Xe||(Xe=new OffscreenCanvas(2,2),He=Xe.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;Je(n)||(n=Ye(n)),Je(r)||(r=Ye(r));const a=e;a&&(n=Math.min(a,n),r=Math.min(a,r)),Xe.width=n,Xe.height=r,He.drawImage(t,0,0,n,r),t.close();const i=He.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,a).then((t=>{t.mimeType=n;return{image:t,sampler:Le,format:6408}}));if("ktx2"===e)return Ne(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Le,format:t.format})));return null}(t.data,t.format,t.mimeType,a,i).then((t=>{if(t.image)if(t.image.array)Ke(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)Ke(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(o).then((r=>{Ge(t,e,n,r)}))}function Ge(t,e,n,r){const a=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++]),a[t]={index:i.length-1},void 0!==n[t].factor&&(a[t].scale=n[t].factor)):ft(n[t])&&(a[t]=Ge(-1,e,n[t],r));return t>=0&&(e.materials[t]=a),a}function $e(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}):ft(t[n])&&$e(t[n],e)}let Xe,He;function Je(t){return!(t&t-1)&&0!==t}function Ye(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Ke(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function Qe(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 Ze="undefined"!=typeof Float32Array?Float32Array:Array;function We(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var tn=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 Ze(3);return Ze!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const en=[];const nn=[],rn=[],an=[],on=[],sn=[],cn=[],un=[];function ln(t,e,n,r,a,i){We(on,t[3*e],t[3*e+1],t[3*e+2]),We(sn,t[3*n],t[3*n+1],t[3*n+2]),We(cn,t[3*r],t[3*r+1],t[3*r+2]);const o=tn(nn,cn,sn),s=tn(rn,on,sn),c=function(t,e,n){var r=e[0],a=e[1],i=e[2],o=n[0],s=n[1],c=n[2];return t[0]=a*c-i*s,t[1]=i*o-r*c,t[2]=r*s-a*o,t}(an,o,s);!function(t,e){var n=e[0],r=e[1],a=e[2],i=n*n+r*r+a*a;i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i)}(un,c),a[3*e]=a[3*e]||0,a[3*n]=a[3*n]||0,a[3*r]=a[3*r]||0,a[3*e+1]=a[3*e+1]||0,a[3*n+1]=a[3*n+1]||0,a[3*r+1]=a[3*r+1]||0,a[3*e+2]=a[3*e+2]||0,a[3*n+2]=a[3*n+2]||0,a[3*r+2]=a[3*r+2]||0,a[3*e]+=un[0],a[3*n]+=un[0],a[3*r]+=un[0],a[3*e+1]+=un[1],a[3*n+1]+=un[1],a[3*r+1]+=un[1],a[3*e+2]+=un[2],a[3*n+2]+=un[2],a[3*r+2]+=un[2],i[e]+=1,i[n]+=1,i[r]+=1}const fn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],hn=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],yn=2*Math.PI*6378137/360,dn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let bn,mn,pn=!1;if("undefined"!=typeof OffscreenCanvas){try{mn=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}mn&&"undefined"!=typeof createImageBitmap&&(pn=!0)}const gn=a([]),vn=[0,0,0],wn=[],Mn=[],Tn=[],An=[],kn={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},On={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Sn;class xn{constructor(t,e,n,r){this.id=t,this.options=e,this.U=this.requestImage.bind(this),this.N=n,this.D={},r(null,{},[])}P(t){this.L||(this.u=t,this.j=new Xt,this.L=new qt(this.U,e.GLTFLoader,t),this.B=new Rt(this.U,e.GLTFLoader,t))}requestImage(t,e){pn?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{bn.width=t.width,bn.height=t.height,mn.drawImage(t,0,0);const n=mn.getImageData(0,0,bn.width,bn.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.N("requestImage",{url:t},null,e)}loadTile(t,n){this.P(t.supportedFormats);const{service:r,url:a,arraybuffer:i}=t,o=r.fetchOptions||{};if(o.referrer=t.referrer,o.referrerPolicy=o.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(a)){const e=t.i3sInfo,i=r.maxTextureSize||0,s=Pe(e,t.supportedFormats,this.options.projection,t.projection,i,o);return s.then((t=>{if(delete this.D[a],!t)return void n({status:404,url:a,i3sInfo:e});if(!Object.keys(t.gltf.meshes).length)return void n({status:404,url:a,i3sInfo:e});t.gltf.url=a;const{transferables:i}=t;t.magic="b3dm",this.q(t.gltf),r.compressGeometry&&this.R(t.gltf),n(null,t,i)})),void(this.D[a]=s.xhr)}if(i){delete this.D[a];const e=Ot(new DataView(i),0);if("{"===e[0]||" "===e[0]||"<"===e[0]){const e=function(t,e,n){if(dn){const r=new Uint8Array(t,e,n);return dn.decode(r)}return dt(new Uint8Array(t,e,n))}(i,0,i.byteLength),r=JSON.parse(e);r.accessors?this.V(r,a,t,"gltf",n):this.G(t.rootIdx,r,i,a,n)}else this.V(i,a,t,e,n)}else{let i=r.urlParams;i&&(i=(a.indexOf("?")>0?"&":"?")+i);const s=a.replace(/\\+/g,"%2B");let c=e.Ajax.getArrayBuffer(s+(i||""),o);const u=c.xhr;c=c.then((e=>{delete this.D[a],e&&e.status?n(e):(t.arraybuffer=e&&e.data,this.loadTile(t,n))})).catch((t=>{delete this.D[a],n(t)})),this.D[a]=u}}V(t,n,r,a,i){a=a&&a.toLowerCase();const{service:o}=r;if("b3dm"===a){this.L.load(n,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:n}=this.$(t,r);this.q(e.gltf),o.compressGeometry&&this.R(e.gltf),i(null,e,n)})).catch((t=>{i(t)}))}else if("pnts"===a){const e=r.transform||gn;this.j.load(n,t).then((t=>{const{content:n,transferables:a}=this.X(t,e,r.rootIdx);this.H(n),i(null,n,a)}))}else if("i3dm"===a){const e=r.transform||gn;this.B.load(n,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:n,transferables:a}=this.J(t,e,r.rootIdx);this.q(n.gltf),o.compressGeometry&&this.R(n.gltf),i(null,n,a)}))}else if("cmpt"===a){new Jt(this.U,e.GLTFLoader,this.u,o.maxTextureSize||0).load(n,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:n}=this.Y(t,r);this.K(e),o.compressGeometry&&this.Z(e),i(null,e,n)})).catch((t=>{i(t)}))}else if("gltf"===a){this.h||(this.h=Bt());const a=n.substring(0,n.lastIndexOf("/")),s=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t,c=new e.GLTFLoader(a,s,{transferable:!0,requestImage:this.U,decoders:this.h,supportedFormats:this.u,maxTextureSize:o.maxTextureSize||0});c.load({skipAttributeTransform:!1}).then((t=>{t.url=n,this.W(t,null,r),this.q(t),o.compressGeometry&&this.R(t),i(null,{magic:"gltf",gltf:t},c.transferables)}))}else i(new Error("unsupported tile format: "+a))}K(t){t.content?t.content.forEach((t=>{this.K(t)})):this.q(t.gltf)}Z(t){t.content?t.content.forEach((t=>{this.Z(t)})):this.R(t.gltf)}tt(t,e){if(this.et(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.nt()?Sn.subarray(0,n):e,a=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const a=en;a.length<t.length/3&&(a.length=t.length/3),a.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?ln(t,3*n,3*n+1,3*n+2,r,a):ln(t,e[3*n],e[3*n+1],e[3*n+2],r,a);const o=r.getLength?r.getLength():r.length;for(let t=0;t<o;t+=3){const e=a[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:a,byteLength:a.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:a.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}R(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(kn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=yn,t.compressed_int16_params.compressed_ratio=r);const a=Un(e[n].array,r,e[n].min,e[n].max,n);if(!a)continue;const{array:i,range:o}=a;e[n].componentType=5124,e[n].array=i,t.compressed_int16_params[n]=o}}))}}q(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.tt(e,t)}))}}H(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(kn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=yn,t.compressed_int16_params.compressed_ratio=r);const{array:a,range:i}=Un(e[n].array,r,e[n].min,e[n].max,n);e[n].array=a,t.compressed_int16_params[n]=i}}rt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const a={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(a)}return e}G(t,e,n,r,a){return e.capabilities,void a(null,e)}Y(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},a=[];for(let t=0;t<n.length;t++){const{magic:i}=n[t];if("b3dm"===i){const{content:i,transferables:o}=this.$(n[t],e);Cn(a,o),r.content.push(i)}else if("i3dm"===i){const{transform:i,rootIdx:o}=e,{content:s,transferables:c}=this.J(n[t],i,o);Cn(a,c),r.content.push(s)}else if("pnts"===i){const{transform:i,rootIdx:o}=e,{content:s,transferables:c}=this.X(n[t],i,o);Cn(a,c),r.content.push(s)}else if("cmpt"===i){const{content:i,transferables:o}=this.Y(n[t],e);Cn(a,o),r.content.push(i)}}return{content:r,transferables:a}}$(t,e){const{gltf:n,transferables:r,featureTable:a}=t;return this.W(n,a,e),delete t.transferables,{content:t,transferables:r}}W(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;const e="visited";let n=1;const r=[];for(const a in t.meshes){const i=t.meshes[a],{primitives:o}=i;if(o)for(let t=0;t<o.length;t++){const a=o[t].attributes&&o[t].attributes.POSITION;if(!a||!a.array)continue;a.array.buffer[e]||(a.array.buffer[e]=n++);const i=n-1+"-"+(a.byteOffset||0);if(r.indexOf(i)>=0)return!0;r.push(i)}}return!1}(t);this.it(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.ot(t,e,n.upAxis,n.transform)):this.st(t,e,n.upAxis,n.transform)}J(t,e,n){const{featureTable:r}=t,a=t.i3dm,i=r&&r.RTC_CENTER||[0,0,0],s=this.options.projection,c=e&&o(gn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};In(a.POSITION.array,3,i,gn,u);const h=Fn(u);e&&!c&&b(h,h,e);const y=this.ct(h),d=[];xe(d,y,s),d[2]=y[2];const m=l([],h),p=[0,0,0],v=[0,0,0],w=[0,0],M=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0];re(a.POSITION,(t=>{p[0]=t[0]+i[0],p[1]=t[1]+i[1],p[2]=t[2]+i[2],e&&!c&&b(p,p,e),0===g(p)?f(v,0,0,-6378137):wt(v,p),xe(w,v,s),t[0]=w[0]-d[0],t[1]=w[1]-d[1],t[2]=v[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]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2])})),a.POSITION.min=M,a.POSITION.max=T,e&&b(h,h,e),t.rtcCenter=m,t.rtcCoord=y,t.projCenter=d,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}X(t,e,n){const{featureTable:r}=t,a=t.pnts,i=r&&r.RTC_CENTER||[0,0,0],s=this.options.projection,c=e&&o(gn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};In(a.POSITION.array,3,i,e,u);const h=Fn(u),y=this.ut(h),d=l([],h),m=[1/0,1/0,1/0],p=[-1/0,-1/0,-1/0];let v=[0,0,0,1];const w=[0,0,0],M=[0,0];re(a.POSITION,(t=>(v[0]=t[0]+i[0],v[1]=t[1]+i[1],v[2]=t[2]+i[2],e&&!c&&(v=b(v,v,e)),0===g(v)?f(w,0,0,-6378137):wt(w,v),xe(M,w,s),t[0]=M[0]-y[0],t[1]=M[1]-y[1],t[2]=w[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]>p[0]&&(p[0]=t[0]),t[1]>p[1]&&(p[1]=t[1]),t[2]>p[2]&&(p[2]=t[2]),t))),a.POSITION.min=m,a.POSITION.max=p,e&&b(h,h,e);const T=this.ct(h);t.rtcCenter=d,t.projCenter=y,t.rtcCoord=T,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}it(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],a=n[1],i=n[2],o=n[3];let s=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==a||n[t+2]!==i||n[t+3]!==o){s=!1;break}s&&(e[t].image.color=[r/255,a/255,i/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const n=this.D[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.D[t.url],e(null)}lt(t,e,n,r){const o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let s=fn;"X"===(n=n&&n.toUpperCase())?s=hn:"Z"===n&&(s=gn),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};Yt(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=a(wn);t.matrices&&En(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;i(e,s,e),r&&i(e,r,e),In(n,u,o||vn,e,c,t.compressUniforms)}));const u=Fn(c);return{rtcCenter:o,modelCenter:u,upAxisTransform:s}}ot(t,e,n,r){const{modelCenter:o,upAxisTransform:s,rtcCenter:c}=this.lt(t,e,n),u=this.ut(o);t.extensions.MAPTALKS_RTC.projCenter=u,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ct(o);const f=l([],o);r&&b(o,o,r),t.extensions.CESIUM_RTC.rtcCoord=this.ct(o),c||(Yt(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=a(wn);t.matrices&&En(n,t.matrices),i(n,s,n);const r=function(t,e){var n=e[0],r=e[1],a=e[2],i=e[3],o=e[4],s=e[5],c=e[6],u=e[7],l=e[8],f=e[9],h=e[10],y=e[11],d=e[12],b=e[13],m=e[14],p=e[15],g=n*s-r*o,v=n*c-a*o,w=n*u-i*o,M=r*c-a*s,T=r*u-i*s,A=a*u-i*c,k=l*b-f*d,O=l*m-h*d,S=l*p-y*d,x=f*m-h*b,_=f*p-y*b,I=h*p-y*m,F=g*I-v*_+w*x+M*S-T*O+A*k;return F?(F=1/F,t[0]=(s*I-c*_+u*x)*F,t[1]=(a*_-r*I-i*x)*F,t[2]=(b*A-m*T+p*M)*F,t[3]=(h*T-f*A-y*M)*F,t[4]=(c*S-o*I-u*O)*F,t[5]=(n*I-a*S+i*O)*F,t[6]=(m*w-d*A-p*v)*F,t[7]=(l*A-h*w+y*v)*F,t[8]=(o*_-s*S+u*k)*F,t[9]=(r*S-n*_-i*k)*F,t[10]=(d*T-b*w+p*g)*F,t[11]=(f*w-l*T-y*g)*F,t[12]=(s*O-o*x-c*k)*F,t[13]=(n*x-r*O+a*k)*F,t[14]=(b*v-d*M-m*g)*F,t[15]=(l*M-f*v+h*g)*F,t):null}(Mn,n),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];re(e,(t=>{b(t,t,n),t[0]=t[0]-f[0],t[1]=t[1]-f[1],t[2]=t[2]-f[2],b(t,t,r),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=f)}st(t,e,n,r){const{modelCenter:a,rtcCenter:i}=this.lt(t,e,n,r),o=this.ut(a);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ct(a),Yt(t,(e=>{if(e.attributes&&e.attributes.POSITION){const a=this.et(e,t);if(a){const t=e.attributes.POSITION.array.length;(!Sn||Sn.length<t)&&(Sn=new Float32Array(t))}e.attributes.NORMAL&&this.ft(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.ft(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,a),{componentType:s}=e.attributes.POSITION;5126!==s&&(e.attributes.POSITION.array=new Float32Array(o))}}));for(const e in t.nodes){t.nodes[e].matrix=gn}}ut(t){const e=this.options.projection;"identity"===e?l(Tn,t):0===g(t)?f(Tn,0,0,-6378137):wt(Tn,t),xe(An,Tn,e);const n=Tn[2],r=[];return r[0]=An[0],r[1]=An[1],r[2]=n,r}ft(t,e,n){let r;r="Y"===n?fn:"X"===n?hn:gn;const a=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(En(a,e),o(a,gn))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}([],a),s=[];re(t,(t=>(function(t,e,n){var r=e[0],a=e[1],i=e[2];t[0]=r*n[0]+a*n[3]+i*n[6],t[1]=r*n[1]+a*n[4]+i*n[7],t[2]=r*n[2]+a*n[5]+i*n[8]}(s,t,i),y(s,s),l(t,s),s)))}ht(t,e,n,r,i,s,c,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const l=a([]);En(l,e);const y=this.options.projection;i=i&&i.toUpperCase();const d=n;let m=null;"Y"===i?m=fn:"X"===i&&(m=hn);let p=[0,0,0,1];const v=[0,0,0],w=[0,0],M=r.projCenter,T=xe([],r.rtcCoord,"EPSG:3857"),A=s&&o(gn,s),k=t.min=t.min||[],O=t.max=t.max||[];f(k,1/0,1/0,1/0),f(O,-1/0,-1/0,-1/0);const S=c||{},{decode_position_min:x,decode_position_normConstant:_}=S;let I=[0,0,0,0],F=1;x&&(I=x),_&&(F=_);const C=[];return re(t,((e,n)=>{if(p[0]=e[0]*F+I[0],p[1]=e[1]*F+I[1],p[2]=e[2]*F+I[2],p=b(p,p,l),m&&(p=b(p,p,m)),d&&h(p,p,d),s&&!A&&(p=b(p,p,s)),0===g(p)?f(v,0,0,-6378137):wt(v,p),u){const t=Sn;xe(w,v,y),t[3*n]=w[0]-T[0],t[3*n+1]=w[0]-T[1],t[3*n+2]=w[0]-T[2]}if(xe(w,v,y),e instanceof Float32Array)e[0]=w[0]-M[0],e[1]=w[1]-M[1],e[2]=v[2]-M[2];else{const n=w[0]-M[0],r=w[1]-M[1],a=v[2]-M[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(a),C.push(e[3]))}return e[0]<k[0]&&(k[0]=e[0]),e[1]<k[1]&&(k[1]=e[1]),e[2]<k[2]&&(k[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}}ct(t){return 0===g(t)?f([],0,0,-6378137):wt([],t)}onRemove(){}nt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}et(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 _n=[];function In(t,e,n,r,a,i){const o=i||{},{decode_position_min:s,decode_position_normConstant:c}=o;let u=[0,0,0,0],l=1;s&&(u=s),c&&(l=c);for(let i=0,o=t.length;i<o;i+=e){const{xmin:o,ymin:s,xmax:c,ymax:y,hmin:d,hmax:m}=a;f(_n,t[i]*l+u[0],t[i+1]*l+u[1],t[i+2]*l+u[2]),b(_n,_n,r);const p=h(_n,n,_n);p[0]<o&&(a.xmin=p[0]),p[0]>c&&(a.xmax=p[0]),p[1]<s&&(a.ymin=p[1]),p[1]>y&&(a.ymax=p[1]),e>2&&(p[2]<d&&(a.hmin=p[2]),p[2]>m&&(a.hmax=p[2]))}}function Fn(t){const{xmax:e,ymax:n,xmin:r,ymin:a,hmin:i,hmax:o}=t,s=[(r+e)/2,(a+n)/2,(i+o)/2];return e===-1/0&&(s[0]=0),n===-1/0&&(s[1]=0),o===-1/0&&(s[2]=0),isNaN(s[2])&&(s[2]=0),s}function Cn(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function En(t,e){const n=t;for(let t=e.length-1;t>=0;t--)i(n,e[t],n);return n}function Un(t,e,n,r,a){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 a=0;a<t.length;a++){const i=Nn(zn(t[a],e,n),e,n);if(Math.abs(i-t[a])>On[r])return!1}return!0}(t,i,o,a)&&On[a]?null:function(t,e,n){const r=new Int16Array(t.length);for(let a=0;a<t.length;a++)r[a]=zn(t[a],e,n);return{array:r,range:[e,n]}}(t,i,o)}function Nn(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function zn(t,e,n){const r=2*(t-e)/(n-e)-1,a=Math.max(-1,Math.min(1,r));return a<0?32768*a:32767*a}let Dn=0;class Pn{constructor(t){this.workerId=t,this.workers={},this.yt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},a){if(this.dt(e,n))return;const i=this.bt(e,n),o=r.options,s=this.send.bind(this,t);this.workers[i]=new xn(n,o,s,a)}removeLayer({mapId:t,layerId:e},n){const r=this.dt(t,e),a=this.bt(t,e);delete this.workers[a],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const a=this.dt(t,e);a&&a.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const a=this.dt(t,e);a&&a.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.yt[e];delete this.yt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,a){const i=a?\`${o}t}-${o}Dn++}\`:null;a&&(this.yt[i]=a),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(i)},r||[])}bt(t,e){return\`${o}t}-${o}e}\`}dt(t,e){const n=this.bt(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Pn(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)}))}}(this.exports=this.exports||{},gltfLoader,transcoders));`
|
|
7
7
|
/*!
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 x(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var A={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,R={"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]},P=k,L=Object.hasOwnProperty,B=Object.create(null);for(var U in R)L.call(R,U)&&(B[R[U]]=U);var D=A.exports={to:{},get:{}};function F(t,e,n){return Math.min(Math.max(e,t),n)}function j(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]:L.call(R,e[1])?((s=R[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=P(arguments);return"#"+j(t[0])+j(t[1])+j(t[2])+(t[3]<1?j(Math.round(255*t[3])):"")},D.to.rgb=function(){var t=P(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=P(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=P(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=P(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 B[t.slice(0,3)]};var q=A.exports,z={exports:{}},G={"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]},H={};for(var V in G)G.hasOwnProperty(V)&&(H[G[V]]=V);var $=z.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 W(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=H[t];if(e)return e;var n,r=1/0;for(var s in G)if(G.hasOwnProperty(s)){var i=W(t,G[s]);i<r&&(r=i,n=s)}return n},$.keyword.rgb=function(t){return G[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 Z=z.exports,Y=Z;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=Z,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=q,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=x(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 xt=[1,1,1,1,2,2,3,0];function At(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=xt[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 Rt={};function Pt(t,e){if(!Array.isArray(e)){const t=e;e=Rt[t]=Rt[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 Lt=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:Pt,pushIn:kt,setColumn3:It,sign:Ot,stringFromUTF8Array:At,toDegree:_t,toRadian:Tt});function Bt(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 jt(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 qt(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 zt(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 Gt(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 Ht(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 Vt(){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 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 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 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=Zt,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}Vt(),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};Vt(),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;
|
|
8
|
+
* Contains code from THREE.js
|
|
9
|
+
* MIT License
|
|
10
|
+
* https://github.com/mrdoob/three.js
|
|
11
|
+
*/;for(var c=[],h=0;h<6;h++)c[h]=[];var u=[];function l(t,e,n){M(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,y=7,b=8,g=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[y]+a*s[b])+Math.abs(i*s[g]+o*s[w]+a*s[v]),h=O(t,n);return!(h<=-c)}function M(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],y=e[13],b=e[14],g=e[15];_(c[0],i-n,u-o,m-l,g-p),_(c[1],i+n,u+o,m+l,g+p),_(c[2],i+r,u+a,m+f,g+y),_(c[3],i-r,u-a,m-f,g-y),_(c[4],i-s,u-h,m-d,g-b),_(c[5],i+s,u+h,m+d,g+b)}function _(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))},C=Array.prototype.concat,N=Array.prototype.slice,k=I.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];S(s)?e=C.call(e,N.call(s)):e.push(s)}return e};k.wrap=function(t){return function(){return t(k(arguments))}};var R=I.exports,E={"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]},L=R,P=Object.hasOwnProperty,U=Object.create(null);for(var B in E)P.call(E,B)&&(U[E[B]]=B);var F=x.exports={to:{},get:{}};function D(t,e,n){return Math.min(Math.max(e,t),n)}function j(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}F.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=F.get.hsl(t),n="hsl";break;case"hwb":e=F.get.hwb(t),n="hwb";break;default:e=F.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},F.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]:P.call(E,e[1])?((s=E[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]=D(s[n],0,255);return s[3]=D(s[3],0,1),s},F.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,D(parseFloat(e[2]),0,100),D(parseFloat(e[3]),0,100),D(isNaN(n)?1:n,0,1)]}return null},F.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,D(parseFloat(e[2]),0,100),D(parseFloat(e[3]),0,100),D(isNaN(n)?1:n,0,1)]}return null},F.to.hex=function(){var t=L(arguments);return"#"+j(t[0])+j(t[1])+j(t[2])+(t[3]<1?j(Math.round(255*t[3])):"")},F.to.rgb=function(){var t=L(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]+")"},F.to.rgb.percent=function(){var t=L(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]+")"},F.to.hsl=function(){var t=L(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},F.to.hwb=function(){var t=L(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},F.to.keyword=function(t){return U[t.slice(0,3)]};var z=x.exports,G={exports:{}},H={"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]},q={};for(var V in H)H.hasOwnProperty(V)&&(q[H[V]]=V);var $=G.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 J in $)if($.hasOwnProperty(J)){if(!("channels"in $[J]))throw new Error("missing channels property: "+J);if(!("labels"in $[J]))throw new Error("missing channel labels property: "+J);if($[J].labels.length!==$[J].channels)throw new Error("channel and label counts mismatch: "+J);var X=$[J].channels,K=$[J].labels;delete $[J].channels,delete $[J].labels,Object.defineProperty($[J],"channels",{value:X}),Object.defineProperty($[J],"labels",{value:K})}function W(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=q[t];if(e)return e;var n,r=1/0;for(var s in H)if(H.hasOwnProperty(s)){var i=W(t,H[s]);i<r&&(r=i,n=s)}return n},$.keyword.rgb=function(t){return H[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 Z=G.exports,Q=Z;function Y(t){var e=function(){for(var t={},e=Object.keys(Q),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(Q[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=Q[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=tt(Q[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var nt=Z,rt=function(t){for(var e=Y(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=z,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 yt(t){return null==t}function bt(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 gt(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 Mt(t){return t/Math.PI*180}function _t(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 Ct(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function Nt(t){return 0===t.indexOf("data:")}function kt(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 Rt(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 Et={};function Lt(t,e){if(!Array.isArray(e)){const t=e;e=Et[t]=Et[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 Pt=Object.freeze({__proto__:null,base64URLToArrayBuffer:kt,extend:bt,flatArr:St,getAbsoluteURL:_t,getBatchIdArrayType:Ct,isBase64:Nt,isFunction:gt,isNil:yt,isNumber:vt,isObject:wt,normalizeColor:Lt,pushIn:Rt,setColumn3:It,sign:Ot,stringFromUTF8Array:xt,toDegree:Mt,toRadian:Tt});function Ut(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Bt(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}var Ft=1e-6,Dt="undefined"!=typeof Float32Array?Float32Array:Array;function jt(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 zt(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],y=e[13],b=e[14],g=e[15],w=n[0],v=n[1],T=n[2],M=n[3];return t[0]=w*r+v*a+T*l+M*p,t[1]=w*s+v*c+T*f+M*y,t[2]=w*i+v*h+T*d+M*b,t[3]=w*o+v*u+T*m+M*g,w=n[4],v=n[5],T=n[6],M=n[7],t[4]=w*r+v*a+T*l+M*p,t[5]=w*s+v*c+T*f+M*y,t[6]=w*i+v*h+T*d+M*b,t[7]=w*o+v*u+T*m+M*g,w=n[8],v=n[9],T=n[10],M=n[11],t[8]=w*r+v*a+T*l+M*p,t[9]=w*s+v*c+T*f+M*y,t[10]=w*i+v*h+T*d+M*b,t[11]=w*o+v*u+T*m+M*g,w=n[12],v=n[13],T=n[14],M=n[15],t[12]=w*r+v*a+T*l+M*p,t[13]=w*s+v*c+T*f+M*y,t[14]=w*i+v*h+T*d+M*b,t[15]=w*o+v*u+T*m+M*g,t}function Gt(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 Ht(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 qt(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,y=i*a,b=i*c;return t[0]=1-l-m,t[1]=u+b,t[2]=f-y,t[3]=0,t[4]=u-b,t[5]=1-h-m,t[6]=d+p,t[7]=0,t[8]=f+y,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 Vt(){var t=new Dt(3);return Dt!=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 Jt(t,e,n){var r=new Dt(3);return r[0]=t,r[1]=e,r[2]=n,r}function Xt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Kt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,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 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 Qt(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,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=Zt,se=Qt,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 Dt(4);return Dt!=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],y=n[3];return(i=h*d+u*m+l*p+f*y)<0&&(i=-i,d=-d,m=-m,p=-p,y=-y),1-i>Ft?(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*y,t}Vt(),function(){var t,e=(t=new Dt(4),Dt!=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};Vt(),Jt(1,0,0),Jt(0,1,0),ce(),ce(),le=new Dt(9),Dt!=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;
|
|
12
12
|
/*!
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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],xe=he([]),Ae=[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],Re=[];class Pe{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){Re[0]=l.array[n],Re[1]=l.array[n+1],Re[2]=l.array[n+2],Re[3]=1;const r=ae(Re,Re,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 Le 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 Pe(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=zt(Te,e.translation||Oe),r=Ht(_e,e.rotation||xe),s=Gt(Me,e.scale||Ae);return qt(s,r,s),qt(t,n,s)}return jt(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)}R(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 Be=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 Pe(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}R(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||Be,n.sampler.minFilter=s.minFilter||Be,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),!n.mipmap&&n.sampler.minFilter!==Be&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:Be}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.P(e,t)}return null}P(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)}L(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=je(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=je(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 je(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=qe[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 qe=[1,1,1,1,2,2,3,0],ze=[0,0,0],Ge=[0,0,0,1],He=[1,1,1],Ve={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={B(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(ze,s)):"rotation"===e.target.path?(this.D(i,u.samplers[e.sampler],r,1),h.rotation=fe(Ge,i)):"scale"===e.target.path?(this.U(o,u.samplers[e.sampler],r,1),h.scale=Kt(He,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.j(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.j(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},q(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.q(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},j(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(ze,...Ve.TRANSLATION),oe(Ge,...Ve.ROTATION),Jt(He,...Ve.SCALE),this.B(r,t,e,n,ze,Ge,He,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 We{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.G(t,n,r)}else this.G(t,e);this.H=new Pe(this.rootPath,this.gltf,this.glbBuffer,this.m,this.options.urlModifier),this.V()}V(){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.H.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)}G(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||Ze,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 Le(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"))}W(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.W(n,e)}));t.children=r}var n;return t}X(t){return this.Z(t).then((t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.W(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.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.R(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.H.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),Wt(t,t,i),Qt(n,n,s),Wt(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 Ze(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=zt(mn,t.translation||gn),n=Ht(pn,t.rotation||yn),r=Gt(bn,t.scale||wn);qt(r,n,r);const i=qt([],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?We.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),xn=new Array(3),An=[40680631590769,40680631590769,40408299984661.445];function In(t,e,n,r){const s=An,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(xn,s,On);const o=Math.sqrt(ee(On,xn));var a,c,h;return c=xn,h=o,(a=xn)[0]=c[0]/h,a[1]=c[1]/h,a[2]=c[2]/h,Qt(On,On,r),Wt(t,xn,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 Rn(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(Pn,e,p);if(m<s)return isFinite(p)?b:void 0;const g=r[0],y=r[1],w=r[2],v=Ln;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,C,N,k=(1-p)*Un(e)/(.5*Un(v)),R=0;do{k-=R,M=1/(1+k*g),O=1/(1+k*y),x=1/(1+k*w),A=M*M,I=O*O,S=x*x,E=A*M,C=I*O,N=S*x,T=l*A+f*I+d*S-1,_=l*E*g+f*C*y+d*N*w;R=T/(-2*_)}while(Math.abs(T)>Bn);return t[0]=i*M,t[1]=o*O,t[2]=a*x,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 Pn=new Array(3),Ln=new Array(3),Bn=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 jn(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 qn=Object.freeze({__proto__:null,cartesian3ToDegree:Rn,geodeticSurfaceNormal:Fn,geodeticSurfaceNormalCartographic:jn,normalizeCartesian:Dn,radianToCartesian3:In});function zn(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 Gn(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const Hn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Vn(t,e,n){const r=new Uint8Array(t,e,n);return Hn?JSON.parse(Hn.decode(r)):JSON.parse(At(r))}function $n(t,e,n){const r=new Uint8Array(t,e,n);return Hn?JSON.parse(Hn.decode(r)):JSON.parse(At(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 Wn(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 Zn={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Yn(t){return t?Zn[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=Vn(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(zn(r[0],0,1e-14)&&zn(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 xr={width:100,height:10};function Ar(){if(!Or){const{width:t,height:e}=xr;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({},xr,e),this.st()}getImageData(){return this.imgData}st(){const t=Ar(),{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=Lr;else{if("color-interpolate"!==h)throw new Error('Unknown function type "'+h+'"');i=Pr}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]:Br(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 Rr={width:100,height:1};function Pr(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,Rr);Sr.set(e,t)}t=Sr.get(e)}else t=new Ir(n,Rr);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 Lr(t,e){return function(t,e,n){return void 0!==t?t:void 0!==e?e:null}(e,t.default)}function Br(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 Br(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 jr(t,"exponential")}function jr(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=jr(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:qr,getTextureMinFilter:zr,getTextureWrap:Gr,getMaterialType:Hr,getMaterialFormat:Vr,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:Wr,logoutIBLResOnCanvas:Zr,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=[],xs=[],As=[],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}}
|
|
13
|
+
* @maptalks/gltf-loader v0.100.0
|
|
14
|
+
* LICENSE : UNLICENSED
|
|
15
|
+
* (c) 2016-2024 maptalks.org
|
|
16
|
+
*/
|
|
17
|
+
let de=0;function me(t){return null==t}function pe(t){return!me(t)}function ye(t){return!me(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function be(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 ge(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=[],Me=[],_e=[],Oe=[0,0,0],Ae=he([]),xe=[1,1,1];function Ie(t,e,n,r,s,i,o){const a=ge(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 Ce(t,e,n){const r=new Uint8Array(t,e,n);return Se.decode(r)}const Ne={get:function(t,e={},n){e||(e={});const r=new AbortController,s=r.signal,i=be({},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",Ne.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?Ne.jsonp(t):((e=e||{}).responseType="json",Ne.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 ke{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]=Ne.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 Re=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],Ee=[];class Le{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._(),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]=Ne.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=ge(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.M)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){Ee[0]=l.array[n],Ee[1]=l.array[n+1],Ee[2]=l.array[n+2],Ee[3]=1;const r=ae(Ee,Ee,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}_(){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=Re.indexOf(t);return Re[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=Ce(s,i+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(we(t.uri)){const e=ve(t.uri),n=Ce(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return Ne.get(e,this.m,this.p).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class Pe extends ke{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 Le(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=Gt(Te,e.translation||Oe),r=qt(Me,e.rotation||Ae),s=Ht(_e,e.scale||xe);return zt(s,r,s),zt(t,n,s)}return jt(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)}R(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 Ue=9729;class Be extends ke{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 Le(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 be(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}R(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}};be(n,e);const s=pe(e.sampler)?this.gltf.samplers[e.sampler]:void 0;if(s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||Ue,n.sampler.minFilter=s.minFilter||Ue,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),!n.mipmap&&n.sampler.minFilter!==Ue&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:Ue}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.L(e,t)}return null}L(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)}P(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 Fe="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class De{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 De.readV1(r,e);if(2===s)return De.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=je(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=je(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 je(t,e,n){if(Fe){const r=new Uint8Array(t,e,n);return Fe.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=ze[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 ze=[1,1,1,1,2,2,3,0],Ge=[0,0,0],He=[0,0,0,1],qe=[1,1,1],Ve={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},$e={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Je={U(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.B(s,u.samplers[e.sampler],r,1),h.translation=Xt(Ge,s)):"rotation"===e.target.path?(this.F(i,u.samplers[e.sampler],r,1),h.rotation=fe(He,i)):"scale"===e.target.path?(this.B(o,u.samplers[e.sampler],r,1),h.scale=Xt(qe,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($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.D($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.D($e,e,n,3*r);s&&(t=this.j(t,s,e.input.array,3*r));break}}return t},F(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.D($e,e,n,1);r&&ue(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.D($e,e,n,1);r&&(t=oe(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.D($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.j(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},G(t,e){const 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.G(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},j(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 Kt(Ge,...Ve.TRANSLATION),oe(He,...Ve.ROTATION),Kt(qe,...Ve.SCALE),this.U(r,t,e,n,Ge,He,qe,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 Xe=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Ds){}t&&"undefined"!=typeof createImageBitmap&&(Xe=!0)}const Ke="undefined"==typeof document?null:document.createElement("canvas");class We{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}=De.read(e.buffer,e.byteOffset,e.byteLength);this.H(t,n,r)}else this.H(t,e);this.q=new Le(this.rootPath,this.gltf,this.glbBuffer,this.m,this.options.urlModifier),this.V()}V(){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.q.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.J(t),n=this.X(),r=this.K(),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 Je.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return Je.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return ge(t)}static readInterleavedArray(t,e,n,r,s,i,o){return Ie(t,e,n,r,s,i,o)}H(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=Xe?rn.bind(this):this.options.requestImage||Ze,this.options.transferable&&(this.transferables=[]),2===this.version?(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="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 Pe(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"))}W(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||ye(t.children[0])))return t;const r=t.children.map((t=>{const n=e[t];return n.nodeIndex=t,this.W(n,e)}));t.children=r}var n;return t}J(t){return this.Z(t).then((t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.W(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.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)))}X(){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 be(n,t),n.primitives=e,n}))}K(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.R(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.q.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;Yt(t,t,s),Wt(t,t,i),Yt(n,n,s),Wt(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 Ze(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Ke)return void n(new Error("There is no canvas to draw image!"));Ke.width=r.width,Ke.height=r.height;const t=Ke.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 Qe=[],Ye=[],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(ye(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),Qe.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(!Qe.length||Ye.length>tn)return;const t=Qe.shift(),[e,n,r,s]=t;Ye.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=Ye.indexOf(t);Ye.splice(n,1),sn()})).catch((e=>{console.warn(e),r.call(s,e);const n=Ye.indexOf(t);Ye.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=[],yn=[],bn=[0,0,0],gn=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=Gt(mn,t.translation||bn),n=qt(pn,t.rotation||gn),r=Ht(yn,t.scale||wn);zt(r,n,r);const i=zt([],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?We.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 Mn(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 _n="#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),Fn(On,On),Qt(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,Yt(On,On,r),Wt(t,An,On)}const Sn=[1/6378137,1/6378137,1/6356752.314245179],Cn=[1/40680631590769,1/40680631590769,1/40408299984661.445],Nn=new Array(3),kn=new Array(3),Rn=new Array(3);function En(t,e){const n=Cn,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),y=Yt(Ln,e,p);if(m<s)return isFinite(p)?y:void 0;const b=r[0],g=r[1],w=r[2],v=Pn;v[0]=y[0]*b*2,v[1]=y[1]*g*2,v[2]=y[2]*w*2;let T,M,_,O,A,x,I,S,C,N,k,R=(1-p)*Bn(e)/(.5*Bn(v)),E=0;do{R-=E,_=1/(1+R*b),O=1/(1+R*g),A=1/(1+R*w),x=_*_,I=O*O,S=A*A,C=x*_,N=I*O,k=S*A,T=l*x+f*I+d*S-1,M=l*C*b+f*N*g+d*k*w;E=T/(-2*M)}while(Math.abs(T)>Un);return t[0]=i*_,t[1]=o*O,t[2]=a*A,t}(Nn,e,Sn,n,.1);let s=se(kn,r,n);s=Fn(s,s);const i=re(Rn,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=Ot(ee(i,e))*Bn(i);return t[0]=Mt(o),t[1]=Mt(a),t[2]=c,t}const Ln=new Array(3),Pn=new Array(3),Un=1e-12;function Bn(t){return $t(t)}function Fn(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 Dn(t,e){return Qt(e,t,Cn),te(e,e)}function jn(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 zn=Object.freeze({__proto__:null,cartesian3ToDegree:En,geodeticSurfaceNormal:Dn,geodeticSurfaceNormalCartographic:jn,normalizeCartesian:Fn,radianToCartesian3:In});function Gn(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 Hn(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const qn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Vn(t,e,n){const r=new Uint8Array(t,e,n);return qn?JSON.parse(qn.decode(r)):JSON.parse(xt(r))}function $n(t,e,n){const r=new Uint8Array(t,e,n);return qn?JSON.parse(qn.decode(r)):JSON.parse(xt(r))}function Jn(t,e,n){return{offset:e,byteLength:n}}function Xn(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=tr(i||"UNSIGNED_SHORT"),h=Qn(o);return{byteStride:0,byteOffset:s+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+s,r*h)}}function Kn(t,e,n,r){const s=Xn(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}function Wn(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a}=tr(i||"UNSIGNED_SHORT"),c=Qn(o),h=new a(e,s,n*c);return 1===c?h[r]:h.subarray(r*c,r*c+c)}const Zn={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Qn(t){return t?Zn[t]:1}const Yn={"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 Yn[t]}function er(t){for(const e in Yn)if(t===Yn[e].ctor)return Yn[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=Vn(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=Jn(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)<=Ft*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-o)<=Ft*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-a)<=Ft*Math.max(1,Math.abs(s),Math.abs(a))}(r,lr))Xt(cr,ir[t]),Xt(hr,ir[e]),Xt(ur,ir[n]);else if(Gn(r[0],0,1e-14)&&Gn(r[1],0,1e-14)){const s=Ot(r[2]);Xt(cr,ir[t]),Xt(hr,ir[e]),Yt(hr,hr,s),Xt(ur,ir[n]),Yt(ur,ur,s)}else{Dn(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),Yt(ar.down,ar.up,-1),Yt(ar.west,ar.east,-1),Yt(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=[],yr=[],br=[],gr=[],wr=[],vr=[],Tr={x:0,y:0},Mr={x:0,y:0},_r=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 Cr(t,e){var n,r,s;if(Fr(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=Rr;else if("interval"===h)i=kr;else if("categorical"===h)i=Nr;else if("identity"===h)i=Pr;else{if("color-interpolate"!==h)throw new Error('Unknown function type "'+h+'"');i=Lr}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,Cr(u[t])]);n=function(e,n){const r=Rr({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 Nr(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 kr(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 Rr(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]:Ur(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 Er={width:100,height:1};function Lr(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,Er);Sr.set(e,t)}t=Sr.get(e)}else t=new Ir(n,Er);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 Pr(t,e){return function(t,e,n){return void 0!==t?t:void 0!==e?e:null}(e,t.default)}function Ur(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 Ur(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]=Br(t,e,n,r,s[a],i[a]);return o}(t,e,n,r,s,i):Br(t,e,n,r,s,i)}function Br(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 Fr(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type)}function Dr(t){return jr(t,"exponential")}function jr(t,e){if(!Fr(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(Fr(s[t][1])){const i=jr(s[t][1],e);n=n&&i.isZoomConstant,r=r&&i.isFeatureConstant,s[t]=[s[t][0],i]}const i=Cr(t,e);return i.isZoomConstant=n&&i.isZoomConstant,i.isFeatureConstant=r&&i.isFeatureConstant,i}const{getTextureMagFilter:zr,getTextureMinFilter:Gr,getTextureWrap:Hr,getMaterialType:qr,getMaterialFormat:Vr,getPrimitive:$r,getUniqueREGLBuffer:Jr}=n.reshader.REGLHelper,Xr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Kr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:Wr,logoutIBLResOnCanvas:Zr,getIBLResOnCanvas:Qr,getPBRUniforms:Yr}=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),ys=[],bs=[],gs=[],ws=[],vs=[],Ts=[],Ms=[],_s=[],Os=[],As=[],xs=[],Is=[],Ss=[],Cs=[],Ns={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},ks=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],Rs=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}}
|
|
18
18
|
/*!
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/(100,1),Rs=[0,0,0,1],Ps=[1,1,1];class Ls{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.xt=new n.reshader.KHRTechniquesWebglManager(this.ct,this.At(),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.Rt(o[a]),o[a].Pt=n.mat4.copy([],o[a].localTransform)),o[a].Lt=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.Bt&&this.Bt[t]?n.HighlightUtil.highlightMesh(this.ct,o[a],this.Bt[t],this.Ut,e):this.Bt&&this.Bt[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].Lt.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.jt(o[a]),this.qt(o[a],i)}}let b=0;const g=this.xt.getExcludeFilter();n.ContextUtil.setIncludeUniformValues(c,s),b+=this.zt(this.Gt,c,[o,hs,g],i,f,d,p),b+=this.zt(this.Ht,c,[o,us,g],i,f,d,p),this.xt.forEachShader(((t,e,n)=>{const r=this.Et(n);b+=this.zt(t,r,[o,e],i,f,d,p)})),this.wt.setMeshes(m);const y=this.Vt();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.Ht.dispose(),delete this.Ht,this.Gt.dispose(),delete this.Gt),this.Jt(t)}zt(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.Wt(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.Wt(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}Wt(t){this.ct.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.yt.getMeshes()}getCurrentI3DMMeshes(){return this.vt.getMeshes()}Zt(t,e){return e.Lt.Yt-t.Lt.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;Zr(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.Gt&&(this.Gt.dispose(),delete this.Gt),this.Ht&&(this.Ht.dispose(),delete this.Ht),this.$t&&(this.$t.dispose(),delete this.$t),this.Xt&&(this.Xt.dispose(),delete this.Xt),this.xt.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]}Rt(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.Pt=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(As),M=this.me(Is,p),O=n.vec3.div(Ss,M,_),x=n.mat4.fromScaling(Es,O),{POSITION:A,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),R=new Float32Array(3),P=[],L=new Float32Array(1),B=new Float32Array(3),U=[],D=[],F=[],j=[];!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?We.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)}}(A,((t,e)=>{I?(Tn(R,S,e),Tn(k,I,e),n.vec3.cross(P,R,k),n.vec3.normalize(P,P),It(U,R,0),It(U,k,1),It(U,P,2),n.quat.fromMat3(D,U),n.quat.normalize(D,D),n.quat.multiply(D,y,D)):n.quat.identity(D),E?(Tn(L,E,e),n.vec3.set(F,L[0],L[0],L[0])):C?(Tn(B,C,e),n.vec3.set(F,...B)):n.vec3.set(F,1,1,1),n.mat4.fromRotationTranslationScale(j,D,t,F),_n(N.instance_vectorA,e,j,0),_n(N.instance_vectorB,e,j,1),_n(N.instance_vectorC,e,j,2)}));const q={};for(const t in N)q[t]={buffer:this.ct.buffer({dimension:N[t].length/d,data:N[t]}),divisor:1};const z=i.shader||"pbr";let G=0,H=!0;const V=[],$=[];return dn(h,((t,s,i,a)=>{const h=this.pe(t,s,i,a,r,!0,z,$),{geometry:y,material:w}=h;w&&!w.isReady()&&(H=!1,G++);const _=new n.reshader.InstancedMesh(q,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,x,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},V.push(_),delete t.attributes,_.Pt=n.mat4.copy([],_.localTransform)})),Bs($),H?(this.dt[e]=V,s(null,{id:e,mesh:V})):(this.ut[e]={meshes:V,count:G},V.ye=s),V}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(As));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 x=this.be(s,_,M,r.kt,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.ae(O,s.compressed_int16_params),this.ge(O,s.attributes),o&&(x.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 Pt([],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.Pt=n.mat4.copy([],O.localTransform)})),Bs(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=Ps;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,Rs,i,o),c.localTransform=h,c.Pt=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):Rn(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,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,C=y*E-w*S+v*I+T*A-_*x+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*A-o*E-h*x)*C,t[5]=(n*E-s*A+i*x)*C,t[6]=(b*v-m*M-g*w)*C,t[7]=(u*M-f*v+d*w)*C,t[8]=(o*S-a*A+h*O)*C,t[9]=(r*A-n*S-i*O)*C,t[10]=(m*_-p*v+g*y)*C,t[11]=(l*v-u*_-d*y)*C,t[12]=(a*x-o*I-c*O)*C,t[13]=(n*I-r*x+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,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}(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.Gt:this.Ht).getGeometryDefines(e);s.asset&&"S3M"===s.asset.generator&&this.xe(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.Ae&&(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))}jt(t){const e=this.it.getRenderer();e&&e.updateMaskDefines(t)}xe(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.xt.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}qt(t,e){const r=this.it.Ne(xs,e);t.localTransform=n.mat4.multiply(t.localTransform,r,t.Pt)}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.Ht)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.At();this.Gt=new n.reshader.PhongShader({uniforms:o,defines:i,extraCommandProps:a}),this.Ht=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;Wr(c.getRenderer().canvas,this.ct,c.getMap()),this.picking=new n.reshader.FBORayPicking(this.ht,{vert:this.Ht.vert,extraCommandProps:a,uniforms:this.Ht.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())}At(){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}}}Vt(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.R(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.R(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.R(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.R(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.R(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.R(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}R(t,e){if(!t)return null;const r={type:t.type?Hr(t.type):"uint8",format:t.format?Vr(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=qr(i.magFilter)),i.minFilter&&(r.min=zr(i.minFilter)),i.wrapS&&(r.wrapS=Gr(i.wrapS)),i.wrapT&&(r.wrapT=Gr(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}Re(t){return this.it.Re(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.Pe(this.picking,i,this.yt,t,e,n);o&&s.push(o);const a=this.Pe(this.picking,i,this.vt,t,e,n);a&&s.push(a);const c=this.Vt(),h=this.Pe(this.ke,c,this.wt,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.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]=Wn(t[s],e,n,r):p[s]=t[s][r]}return{service:d.properties.serviceIndex,data:p,point:l,coordinate:f}}highlight(t){this.Bt=t;const e=this.it.getRenderer();this.Ut=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.Bt=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)}Le(){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 Bs(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 js(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 qs=[];class zs{constructor(t,e,n,r,s){this.it=r,this.Be=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.Be=t,this.je=n}load(){const t=this.je,e=t.layerScene.baseUrl;if(this.De<=1.6)return t[this.Fe]&&t[this.Fe].lodSelection?(this.qe=t[this.Fe],this.ze()):new Promise((n=>{let r=e+"/nodes/"+this.Fe;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Ue(this.kt,r,(()=>{this.qe=t[this.Fe],n(this.ze())}))}));if(this.De>=1.7){if(t[this.Fe])return this.qe=t[this.Fe],this.ze();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.qe=t[this.Fe],r(this.ze())}))}))}return null}getTileset(){return this.Ge}getChildrenURL(){return this.He}ze(){const t=this.je,e=t.layerScene.baseUrl,n=this.qe.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.Ve())):this.Ve()}Ve(){return Promise.resolve(this.$e())}Xe(t){js(this.je,t)}$e(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.Ke(this.qe,!0)}}Ke(t){const e=this.it.getRenderer(),n=this.je.projection,r=!n||n&&4326===n.wkid,s=this.De,i=this.je,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=Gs([],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=Gs([],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(qs,n,s,i);const o=ie(qs);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=jt([]),p=o.children;let b;if(p){b=[];const t=this.je;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.qe}}function Gs(t,e,n,r){return In(t,Tt(e),Tt(n),r)}const Hs=!!Fs.ktx2,Vs=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=Vs;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 Ws(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 Ws(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=Zs(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])&&Ws(t[o],e,n,r,s,i)}function Zs(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&&Hs)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.We(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.We(t,e),this}We(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.Ze={},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 zs(e,n,r,this.layer,this.Ue).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Bt(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.Ae=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.xn(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.An(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}An(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.Ze[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 Ls(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?js(e,t.nodes):(e[t.id]=t,js(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()}xn(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 zs(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.Bt||(this.Bt=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Bt[n];r||(r=this.Bt[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Bt[e];n||(n=this.Bt[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.Bt)}cancelHighlight(t,e){if(!this.Bt)return;const n=this.Bt[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.Bt[t]=null),this.painter.highlight(this.Bt)}}cancelAllHighlight(){delete this.Bt,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()}Le(){return this.painter?this.painter.Le():[]}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}Rn(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.Pn||(this.Pn=s.SpatialReference.getProjectionInstance(t)),this.Pn}}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=Zt(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||zn(n,s,1e-14))&&(n<i||zn(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=[],xi=[],Ai=[],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,xi),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,Ai);n.vec3.copy(Ii,c);const s=gi.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Si);Ni(Ai,Ii,s,e.southwestCornerCartesian),u=Fn(r,Mi)}else u=jn(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,Ai);n.vec3.scale(Ii,c,-1);const s=gi.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Si);Ni(Ai,Ii,s,e.northeastCornerCartesian),d=Fn(r,Mi)}else d=jn(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 Ri=s.BBOXUtil,Pi={"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"]},Li=[0,0,0],Bi=[0,0,0],Ui=[0,0,0],Di=[0,0,0],Fi=[0,0,0],ji=[0,0,0],qi=[0,0,0],zi=[1,1,1],Gi=[0,0,0,0],Hi=[],Vi=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],Wi=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Zi=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.Ln(),this.Bn=[]}Ln(){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.Ln(),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=Rn([],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(Rn([],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:Hi};const e=this.getMap(),r=e.cameraPosition,s=e.pointAtResToDistance(r[2],0,e.getGLRes()),i=this.jn(r);this.qn=this.qn||[0,0,0],n.vec3.set(this.qn,Tt(i.x),Tt(i.y),s),this.zn=In(this.zn||[],this.qn[0],this.qn[1],this.qn[2]),this.Gn=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.Hn(e);for(;r.length>0;){const e=r.pop();for(e.id||this.Vn(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:Bt(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.qn,this.zn,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}}Vn(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.Wn(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}Zn(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(Li,i,t.matrix),c=Rn(Bi,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}Wn(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.Wn(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)&&Bt(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||!Ri||!e)return!0;const r=t.extent;so[0]=r.xmin,so[1]=r.ymin,so[2]=r.xmax,so[3]=r.ymax;if(!Ri.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||Ri.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.Zn(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}Re(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.Bn[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.Bn[r]=this.ar(t):a?s=this.Bn[r]=this.cr(t):h&&(s=this.Bn[r]=this.hr(t)),s.version=u.version,t.Qt&&(l.Oe(t.Qt),delete t.Qt));return this.Nt(t.kt).debug&&(this.Bn[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=Rn(a,a),u=Rn(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=Li;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=Li;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),Rn(d,d),s&&e.kn(d,d);const o=Vi.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=Li;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:Rn(a,o),r&&n.kn(a,a);const c=new s.Coordinate(a),h=this.Re(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(ji,t,0,3,4,7),i=uo(qi,t,0,1,2,3);return[...e,...n.vec3.sub(Li,r,e),...n.vec3.sub(Bi,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);Rn(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(Li,-i[0],-i[1],-i[2])),a=n.mat4.fromTranslation(Ji,i),c=s.rotation||to,h=n.quat.fromEuler(Gi,...c),u=s.scale,l=u&&n.vec3.set(no,u,u,u)||eo,f=n.mat4.fromRotationTranslationScale(Wi,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.Zn(t),this.ar(t)}gr(t){return this.Zn(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(zi,r.x/100*1.01,r.y/100*1.01,s),zi}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]}Hn(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.Re(t)))),n.maxExtent}rr(t){const e=this.Gn,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.zn,this.qn):t.boundingVolume.sphere?i=ao(t.boundingVolume,this.zn):t.boundingVolume.box&&(i=co(t.boundingVolume,this.zn));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.Bn[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.Le():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.Bt||(this.Bt=[]),this.Bt.push(t),this)}Sn(){if(this.Bt){for(let t=0;t<this.Bt.length;t++)this.highlight(this.Bt[t]);delete this.Bt}}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}jn(t){const e=this.getMap(),n=e.getGLRes();Zi.set(t[0],t[1]);const r=e.pointAtResToCoord(Zi,n);return"identity"===e.getProjection().code.toLowerCase()?(Bi[0]=r.x,Bi[1]=r.y,this.getRenderer().Rn(Li,Bi),r.set(Li[0],Li[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(Li,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(Li,e[3*r],e[3*r+1],e[3*r+2]),c=n.vec3.set(Bi,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(Pi),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||We,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=Vn(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||We,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=At(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.Rr(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.Pr(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.Pr(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}}Pr(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}Rr(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.Lr(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}))}Lr(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.Br||(this.Br=bo().draco),this.Br(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.Rr(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}Rr(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||We,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=Gn(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=Lt,t.Geo3DTransform=qn,"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.99.0")}));
|
|
19
|
+
* @maptalks/gl v0.100.0
|
|
20
|
+
* LICENSE : UNLICENSED
|
|
21
|
+
* (c) 2016-2024 maptalks.com
|
|
22
|
+
*/(100,1),Es=[0,0,0,1],Ls=[1,1,1];class Ps{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.yt={},this.bt={},this.gt=new n.reshader.Scene,this.wt=new n.reshader.Scene,this.vt=new n.reshader.Scene,this.Tt=new n.reshader.Scene,this.Mt=new n.reshader.ResourceLoader(t.texture(2)),this._t=this.Ot.bind(this),this.At=new n.reshader.KHRTechniquesWebglManager(this.ct,this.xt(),this.Mt);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.Ct(),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.Nt(i);if(!o)continue;const a=this.it.kt(i.Rt),c=a.debugNodes,y=a.heightOffset||0,b=a.coordOffset||as;this.yt[i.id]&&(o=this.yt[i.id],o=St(o));let g=a.polygonOffset||ts;gt(g)&&(g=g()),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===y&&o[a].properties.coordOffset[0]===b[0]&&o[a].properties.coordOffset[1]===b[1]||(this.Et(o[a]),o[a].Lt=n.mat4.copy([],o[a].localTransform)),o[a].Pt=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.Rt;this.Ut&&this.Ut[t]?n.HighlightUtil.highlightMesh(this.ct,o[a],this.Ut[t],this.Bt,e):this.Ut&&this.Ut[t]||n.HighlightUtil.highlightMesh(this.ct,o[a],null,this.Bt,e),n.HighlightUtil.showOnly(this.ct,o[a],this.Ft&&this.Ft[t],this.Dt,e)}if(c&&c.length&&c.indexOf(o[a].Pt.id)<0)continue;s&&s.bloom&&o[a].properties.hlBloomMesh&&(o[a].properties.hlBloomMesh.properties.depthFunc="always",o[a].properties.hlBloomMesh.properties.polygonOffset=g,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=g,e[i.id]||f.push(o[a]),this.jt(o[a]),this.zt(o[a],i)}}let y=0;const b=this.At.getExcludeFilter();n.ContextUtil.setIncludeUniformValues(c,s),y+=this.Gt(this.Ht,c,[o,hs,b],i,f,d,p),y+=this.Gt(this.qt,c,[o,us,b],i,f,d,p),this.At.forEachShader(((t,e,n)=>{const r=this.Ct(n);y+=this.Gt(t,r,[o,e],i,f,d,p)})),this.wt.setMeshes(m);const g=this.Vt();return y+=this.ht.render(this.$t,g,this.wt,i&&i.fbo),this.St={pntsMeshes:m,i3dmMeshes:p,b3dmMeshes:d},this.Tt.setMeshes(r),this.ht.render(this.Jt,c,this.Tt,i&&i.fbo),y}prepareRender(t){this.Xt(t)}Xt(t){t&&t.states&&t.states.includesChanged&&(this.qt.dispose(),delete this.qt,this.Ht.dispose(),delete this.Ht),this.Kt(t)}Gt(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.Wt(a),this.gt.setMeshes(h),c+=this.ht.render(t,e,this.gt,a),h.length=0,e.stencilEnable=!1),h.push(i[n])):(e.stencilEnable||(this.gt.setMeshes(h),c+=this.ht.render(t,e,this.gt,a),h.length=0,e.stencilEnable=!0),h.push(i[n])),n===i.length-1&&(e.stencilEnable&&this.Wt(a),this.gt.setMeshes(h),c+=this.ht.render(t,e,this.gt,a))}return this.gt.setMeshes(i.filter((t=>t.properties.isLeaf))),this.vt.setMeshes(o),c+=this.ht.render(t,e,this.vt,r&&r.fbo),c}Wt(t){this.ct.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.gt.getMeshes()}getCurrentI3DMMeshes(){return this.vt.getMeshes()}Zt(t,e){return e.Pt.Qt-t.Pt.Qt}deleteTile(t){const e=t.node;e.Yt&&(e.Yt.geometry.dispose(),e.Yt.dispose(),delete e.Yt);const n=e.id;this.te(n)}te(t){const e=this.lt[t]||this.ft[t]||this.dt[t]||this.yt[t]||this.ut[t];this.yt[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.yt[t];e=St(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.te(n)}delete this.yt[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.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.it;Zr(t.getRenderer().canvas,t.getMap());for(const t in this.yt)this.ee(t);this.yt={};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.Ht&&(this.Ht.dispose(),delete this.Ht),this.qt&&(this.qt.dispose(),delete this.qt),this.$t&&(this.$t.dispose(),delete this.$t),this.Jt&&(this.Jt.dispose(),delete this.Jt),this.At.dispose(),this.picking&&this.picking.dispose()}Nt(t){return this.lt[t.id]||this.ft[t.id]||this.dt[t.id]||this.yt[t.id]}has(t){return this.Nt(t)||this.ut[t.id]}Et(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.kt(a),y=new n.reshader.Mesh(u);y.properties.magic="pnts",y.properties.id=e,y.properties.node=r,y.properties.count=h,y.properties.batchTable=t.batchTable,y.properties.batchTableBin=t.batchTableBin,y.properties.serviceIndex=a,y.properties.rtcCoord=d,y.properties.rtcCenter=f,y.properties.projCenter=m,y.setDefines(l),y.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:p&&p.pointColor||[1,1,1,1]}));const b=this.getMap();let g=null,w=null;y.setFunctionUniform("pointSize",(function(){if(!p)return 2;if(Fr(p.pointSize)){const t=JSON.stringify(p.pointSize);t!==g&&(w=Dr(p.pointSize),g=t);return w(b.getZoom())}return p.pointSize||2}));let v=null,T=null;return y.setFunctionUniform("pointOpacity",(function(){if(!p)return 1;if(Fr(p.pointOpacity)){const t=JSON.stringify(p.pointOpacity);t!==v&&(T=Dr(p.pointOpacity),v=t);return T(b.getZoom())}return p.pointOpacity||1})),this.ae(y,c),this.ie(y),y.Lt=n.mat4.copy([],y.localTransform),this.ft[e]=y,s(null,{id:e,mesh:[y]}),[y]}ie(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:s}=t.properties;this.ce(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.it.kt(r.Rt),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:y}=t,b=this.le(ws,r,m,p);fr(b,os,b);const g=n.mat4.getRotation(vs,b);n.quat.normalize(g,g);const w=n.mat4.getScaling(Ts,b),v=n.mat4.fromScaling(Ms,w),T=this.fe(_s,y,r),M=this.de(xs),_=this.me(Is,p),O=n.vec3.div(Ss,_,M),A=n.mat4.fromScaling(Cs,O),{POSITION:x,NORMAL_UP:I,NORMAL_RIGHT:S,SCALE:C,SCALE_NON_UNIFORM:N}=a,k={"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++)k.aPickingId[t]=t;const R=new Float32Array(3),E=new Float32Array(3),L=[],P=new Float32Array(1),U=new Float32Array(3),B=[],F=[],D=[],j=[];!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?We.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(E,S,e),Tn(R,I,e),n.vec3.cross(L,E,R),n.vec3.normalize(L,L),It(B,E,0),It(B,R,1),It(B,L,2),n.quat.fromMat3(F,B),n.quat.normalize(F,F),n.quat.multiply(F,g,F)):n.quat.identity(F),C?(Tn(P,C,e),n.vec3.set(D,P[0],P[0],P[0])):N?(Tn(U,N,e),n.vec3.set(D,...U)):n.vec3.set(D,1,1,1),n.mat4.fromRotationTranslationScale(j,F,t,D),Mn(k.instance_vectorA,e,j,0),Mn(k.instance_vectorB,e,j,1),Mn(k.instance_vectorC,e,j,2)}));const z={};for(const t in k)z[t]={buffer:this.ct.buffer({dimension:k[t].length/d,data:k[t]}),divisor:1};const G=i.shader||"pbr";let H=0,q=!0;const V=[],$=[];return dn(h,((t,s,i,a)=>{const h=this.pe(t,s,i,a,r,!0,G,$),{geometry:g,material:w}=h;w&&!w.isReady()&&(q=!1,H++);const M=new n.reshader.InstancedMesh(z,d,g,w);h.refMeshes||(h.refMeshes=new Set,h.refMeshes.add(M.uuid)),M.properties.magic="i3dm",M.properties.id=e,M.properties.count=f,M.properties.batchTable=u,M.properties.batchTableBin=l,M.properties.serviceIndex=r.Rt,M.properties.rtcCoord=p,M.properties.rtcCenter=m,M.properties.projCenter=y,M.properties.node=r;const _=this.ye(t,g,w,r.Rt,a);t.compressed_int16_params&&this.ae(M,t.compressed_int16_params),this.be(M,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,b,O),M.setPositionMatrix(O),this.se(M,T),M.setDefines(_),M.properties.polygonOffset={offset:0,factor:0},V.push(M),delete t.attributes,M.Lt=n.mat4.copy([],M.localTransform)})),Us($),q?(this.dt[e]=V,s(null,{id:e,mesh:V})):(this.ut[e]={meshes:V,count:H},V.ge=s),V}se(t,e){const{rtcCoord:r,node:s,projCenter:i}=t.properties;e||(e=this.fe(_s,i,s));const o=this.it.kt(s.Rt),a=t.localTransform||[];if(o.coordOffset){const t=this.we(ws,s.Rt,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(bs,e,r.Rt);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(_s,l,h,u,c,r),m=this.it.kt(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 y=[],b=[];let g=0,w=!0;return dn(a,((s,i,a,v)=>{const T=this.pe(s,i,a,v,r,!1,p,y),{geometry:M,material:_}=T;_&&!_.isReady()&&(w=!1,g++);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 A=this.ye(s,M,_,r.Rt,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.be(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 Lt([],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),b.push(O),delete s.attributes,O.Lt=n.mat4.copy([],O.localTransform)})),Us(y),w?(this.lt[e]=b,i(null,{id:e,mesh:b})):(this.ut[e]={meshes:b,count:g},b.ge=i),b}Me(t){const e=this.it._e(t.id);if(!e||t.Yt)return;let r,s,i,o;if(e.obbox)r=e.boxPosition,s=ks,i=e.boxCenter,o=Ls;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];r=Rs.vertices,s=Rs.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,Es,i,o),c.localTransform=h,c.Lt=n.mat4.copy([],h),c.properties.node=t,t.Yt=c}Oe(t){t.Yt&&(t.Yt.geometry.dispose(),t.Yt.dispose(),delete t.Yt)}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||_s,r,s,i,o,c));const h=t.localTransform||n.mat4.identity([]);n.mat4.multiply(h,e,a);const u=this.it.kt(c.Rt);if(u.coordOffset){const t=this.we(ws,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)||as}Te(t,e,r,s,i,o){if(e){const e=this.me(Is,r),i=n.mat4.fromScaling(gs,e),a=this.le(ws,o,s,r);n.mat4.multiply(t,a,i)}else this.ce(t,r,i,o.Rt);return t}be(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.kt(e.Rt).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=Xt(mr,e);const a=In(mr,e[0]*_r,e[1]*_r,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)?Kt(yr,0,0,-6378137):En(yr,c),Tr.x=u[0],Tr.y=u[1];const l=r.project(Tr,Mr);br[0]=l.x/s,br[1]=l.y/s,br[2]=(u[2]+o)*i;const f=dr(a,h,gr),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],y=e[14],b=e[15],g=n*a-r*o,w=n*c-s*o,v=n*h-i*o,T=r*c-s*a,M=r*h-i*a,_=s*h-i*c,O=u*p-l*m,A=u*y-f*m,x=u*b-d*m,I=l*y-f*p,S=l*b-d*p,C=f*b-d*y,N=g*C-w*S+v*I+T*x-M*A+_*O;return N?(N=1/N,t[0]=(a*C-c*S+h*I)*N,t[1]=(s*S-r*C-i*I)*N,t[2]=(p*_-y*M+b*T)*N,t[3]=(f*M-l*_-d*T)*N,t[4]=(c*x-o*C-h*A)*N,t[5]=(n*C-s*x+i*A)*N,t[6]=(y*v-m*_-b*w)*N,t[7]=(u*_-f*v+d*w)*N,t[8]=(o*S-a*x+h*O)*N,t[9]=(r*x-n*S-i*O)*N,t[10]=(m*M-p*v+b*g)*N,t[11]=(l*v-u*M-d*g)*N,t[12]=(a*A-o*I-c*O)*N,t[13]=(n*I-r*A+s*O)*N,t[14]=(p*w-m*T-y*g)*N,t[15]=(u*T-l*w+f*g)*N,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],y=e[4],b=e[5],g=e[6],w=e[7],v=e[8],T=r*f+o*d+h*m,M=s*f+a*d+u*m,_=i*f+c*d+l*m,O=r*p+o*y+h*b,A=s*p+a*y+u*b,x=i*p+c*y+l*b,I=r*g+o*w+h*v,S=s*g+a*w+u*v,C=i*g+c*w+l*v;return n[0]=T,n[1]=M,n[2]=_,n[3]=0,n[4]=O,n[5]=A,n[6]=x,n[7]=0,n[8]=I,n[9]=S,n[10]=C,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(d,m,t),br,t),t}(a,s,a,i.getProjection(),i.getGLRes(),this.It,o),h=function(t,e){return Kt(t,e[12],e[13],e[14]),t}(bs,c);let u=this.it.options.offset;if(gt(u)){const t=this.it._e(e.id).boxCoord;u=u.call(this.it,t)}return n.vec3.set(ys,u[0],u[1],0),n.vec3.sub(h,h,ys),fr(c,h,c),c}we(t,e,r){const s=this.it.kt(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(ys,l,f,(c[2]||0)*d);return n.mat4.fromTranslation(t,m)}createCMPTMesh(t,e,n,r){if(this.yt[e]){const t=this.yt[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.yt[e]=i,r(null,{id:e,mesh:i}),i}ye(t,e,n,r,s){const i=("phong"===(this.it.kt(r).shader||"pbr")?this.Ht:this.qt).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 bt(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))}jt(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.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.it.kt(i.Rt);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,Ns);const e=p.material;l=this.Ce(t.material,s,a,e||rs,c,p)}l&&(l.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return yt(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.Ne=i.id:l||(l=new n.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const y={geometry:f,material:l};return f.properties.url=u,this.bt[u]=y,y}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=Jr(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(bs,r,s),n.mat4.translate(i,i,bs),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;gt(o)&&(o=o.call(this.it,fs));const a=this.it.kt(r).heightOffset||0;return n.vec3.set(t,i.x-o[0],i.y-o[1],s*e[2]+s*a),t}zt(t,e){const r=this.it.ke(As,e);t.localTransform=n.mat4.multiply(t.localTransform,r,t.Lt)}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}Kt(t){if(this.qt)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:_n,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.Ht=new n.reshader.PhongShader({uniforms:o,defines:i,extraCommandProps:a}),this.qt=new n.reshader.pbr.StandardShader({uniforms:o,defines:i,extraCommandProps:a}),this.Jt=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;Wr(c.getRenderer().canvas,this.ct,c.getMap()),this.picking=new n.reshader.FBORayPicking(this.ht,{vert:this.qt.vert,extraCommandProps:a,uniforms:this.qt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.Re=new n.reshader.FBORayPicking(this.ht,{vert:_n,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}}}Vt(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)}}Ct(){const t=this.getMap(),e=this.it,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:s}=Qr(n),i=Yr(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,bt(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}),bt(i,a),i}Ce(t,e,r,s,i,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=bt({},s);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.R(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.R(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.R(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.R(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.R(r,i);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.ct))}}if(yt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),yt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.R(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._t),h}R(t,e){if(!t)return null;const r={type:t.type?qr(t.type):"uint8",format:t.format?Vr(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=zr(i.magFilter)),i.minFilter&&(r.min=Gr(i.minFilter)),i.wrapS&&(r.wrapS=Hr(i.wrapS)),i.wrapT&&(r.wrapT=Hr(i.wrapT))),new n.reshader.Texture2D(r,this.Mt)}Ot({target:t}){const e=t.Ne,n=this.ut[e];if(n.count--,!n.count){const t=n.meshes;this.lt[e]=t,delete this.ut[e];const r=t.ge;delete t.ge,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}Ee(t){return this.it.Ee(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?Xr:"X"===t?Kr: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.Ct(),o=this.Le(this.picking,i,this.gt,t,e,n);o&&s.push(o);const a=this.Le(this.picking,i,this.vt,t,e,n);a&&s.push(a);const c=this.Vt(),h=this.Le(this.Re,c,this.wt,t,e,n);return h&&s.push(h),s}Le(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},y=o.options.services,b=y&&y[d.properties.serviceIndex];if(b&&b.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]=Wn(t[s],e,n,r):p[s]=t[s][r]}return{service:d.properties.serviceIndex,data:p,point:l,coordinate:f}}highlight(t){this.Ut=t;const e=this.it.getRenderer();this.Bt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.Ut=null;const t=this.it.getRenderer();this.Bt=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Ft=t;const e=this.it.getRenderer();this.Dt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Ft=null;const t=this.it.getRenderer();this.Dt=t.getFrameTimestamp(),t.setToRedraw(!0)}Pe(){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 Us(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 Bs=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")},Fs=Bs(),Ds=Fs.gl_trans__coders=Fs.gl_trans__coders||{};function js(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}Ds.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=Fs.gl_trans__coders=Fs.gl_trans__coders||{};let i=`${r}\n const _____getGlobal = ${Bs.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},Ds.registerTranscoder=function(t,e){Ds[t]=e},Ds.getTranscoder=function(t){return Ds[t]};const zs=[];class Gs{constructor(t,e,n,r,s){this.it=r,this.Ue=t,this.Rt=e,this.Be=s,this.Fe=n.version,t.indexOf("i3s:tileset:")<0?(this.Fe<=1.6?this.De="root":this.De=0,n.version=this.Fe):(this.De=t.substring(12),this.Fe>1.6&&(this.De=parseInt(this.De))),this.Ue=t,this.je=n}load(){const t=this.je,e=t.layerScene.baseUrl;if(this.Fe<=1.6)return t[this.De]&&t[this.De].lodSelection?(this.ze=t[this.De],this.Ge()):new Promise((n=>{let r=e+"/nodes/"+this.De;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Be(this.Rt,r,(()=>{this.ze=t[this.De],n(this.Ge())}))}));if(this.Fe>=1.7){if(t[this.De])return this.ze=t[this.De],this.Ge();const n=Math.floor(this.De/t.nodesPerPage);return new Promise((r=>{let s=e+"/nodepages/"+n;t.layerScene.eslpk&&(s+=".json"),this.Be(this.Rt,s,(()=>{this.ze=t[this.De],r(this.Ge())}))}))}return null}getTileset(){return this.He}getChildrenURL(){return this.qe}Ge(){const t=this.je,e=t.layerScene.baseUrl,n=this.ze.children,r=[],s={};if(n)for(let i=0;i<n.length;i++)if(this.Fe<=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.Be(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.Be(this.Rt,r,(()=>{n()}))})),r.push(s[a]))}return r.length?Promise.all(r).then((()=>this.Ve())):this.Ve()}Ve(){return Promise.resolve(this.$e())}Je(t){js(this.je,t)}$e(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.Xe(this.ze,!0)}}Xe(t){const e=this.it.getRenderer(),n=this.je.projection,r=!n||n&&4326===n.wkid,s=this.Fe,i=this.je,o=t,a=o.obb,c=o.mbs,h={};let u;if(c)u=Kt([],c[0],c[1],c[2]),r||(u=e.Ke(u,u)),u=Hs([],u[0],u[1],u[2]),h.sphere=[...u,c[3]];else if(a){u=Kt([],a.center[0],a.center[1],a.center[2]),r||(u=e.Ke(u,u)),u=Hs([],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,y=i*a,b=i*c;return t[0]=1-l-m,t[3]=u-b,t[6]=f+y,t[1]=u+b,t[4]=1-h-m,t[7]=d-p,t[2]=f-y,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];Kt(zs,n,s,i);const o=ie(zs);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=jt([]),p=o.children;let y;if(p){y=[];const t=this.je;for(let e=0;e<p.length;e++){const n=s<=1.6?p[e].id:p[e];if(!t[n]){y=null;break}y.push(this.Xe(t[n]))}}const b={refine:"REPLACE",boundingVolume:h,transform:m,geometricError:d};return s<=1.6?t.lodSelection?t.geometryData&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}):b.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!y?b.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}),y&&y.length&&(b.children=y),b}getJSON(){return this.ze}}function Hs(t,e,n,r){return In(t,Tt(e),Tt(n),r)}const qs=!!Ds.ktx2,Vs=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 Js(t){return t.indexOf("i3s:mesh")>=0}const Xs=9;function Ks(t,e,n,r,s){const i=e.layerScene.eslpk,o=function(t,e){const n=e.substring(Xs);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let u=!1;const l=Vs;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=Ds.draco&&u?o[1]:o[0],m=Ds.draco&&u?1:0;let p=c+`/nodes/${f.resource}/geometries/`+m;i&&(p+=".bin");const y={geometry:{url:p,info:l}};if(s&&$s&&u&&!Ds.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const b=e.layerScene.materialDefinitions,g=e.layerScene.textureSetDefinitions;let w,v=0;if(d&&(v=b[d.definition]),b){w=function(t,e,n,r,s,i){const o=JSON.parse(JSON.stringify(t));return Ws(o,e,n,r,s,i),o}(v,g,c,d.resource,n,e.layerScene.eslpk)}else w={pbrMetallicRoughness:{metallicFactor:0}};y.material=w,h.push(y)}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 Ws(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=Zs(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])&&Ws(t[o],e,n,r,s,i)}function Zs(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&&qs)return t[n]}return null}const Qs=new s.Coordinate(0,0),Ys=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.We(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.We(t,e),this}We(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.Ze={},this.Qe=[],this.Be=this.Ye.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&&Rt(e,n),r.length&&Rt(e,r),s.length&&Rt(e,s),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.Qe.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.yn===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.yn=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.bn+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.gn(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].bn<=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.kt(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._e(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.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(Nt(e)){const n=kt(e);return this.wn(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.Rt,r=this.vn[n];return new Gs(e,n,r,this.layer,this.Be).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Ut(e)&&!Js(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.kt(r.Rt);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.Rt]),arraybuffer:e,rootIdx:r.Rt,upAxis:r.ue,transform:r.matrix,supportedFormats:s};if(Js(t)){const e=this.vn[r.Rt];if(o.projection=e.projection,o.i3sInfo=Ks(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=bt({},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.Qe.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Me(t){this.painter&&this.painter.Me(t)}Oe(t){this.painter&&this.painter.Oe(t)}rn(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.Qe.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.Qe.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})),n++}}Mn(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this._n(r);e.memorySize=n,this.onTileLoad(t,e)}}_n(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this._n(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.Ze[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 Ps(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=bt({},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.Cn||(this.Cn=Date.now());const e=Date.now();if(!t&&e-this.Cn<this.layer.options.retireInterval)return;this.Cn=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 Xn(t,e,0,n)}nn(){if(!this.Nn)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.Nn){const s=this.Nn[r];if("pending"===s.status)continue;s.status="pending";const i=s.rootIdx,o=Bt(this.layer.kt(i).fetchOptions);if(n.push(Ne.getJSON(r,o).then((t=>{delete this.Nn[r];const e=this.vn[i];if(e){t.nodes?js(e,t.nodes):(e[t.id]=t,js(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)}Ye(t,e,n){this.Nn||(this.Nn={}),this.Nn[e]=this.Nn[e]||[],this.Nn[e].rootIdx=t,this.Nn[e].push(n),this.setToRedraw()}An(t,e,n){this.vn||(this.vn=[]);const r=e.Rt;this.vn[r]||(this.vn[r]={});const s=this.vn[r],i=this.layer.kt(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 Gs(s,n,i,t,o).load()}(this.layer,t,r,0,n,s,this.Be).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()}Pe(){return this.painter?this.painter.Pe():[]}Ke(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.kn();return Qs.set(e[0],e[1]),n.unproject(Qs,Ys),t[0]=Ys.x,t[1]=Ys.y,t}return Qs.set(e[0],e[1]),n.getProjection().unproject(Qs,Ys),t[0]=Ys.x,t[1]=Ys.y,t}Rn(t,e){const n=this.kn();return Qs.set(e[0],e[1]),n.project(Qs,Ys),t[0]=Ys.x,t[1]=Ys.y,t}En(t,e){const n=this.kn();return Qs.set(e[0],e[1]),n.unproject(Qs,Ys),t[0]=Ys.x,t[1]=Ys.y,t}kn(){const t=this.getMap().options.spatialReference.coordType;if(!t)throw new Error("Missing coordType in map spatialReference.");return this.Ln||(this.Ln=s.SpatialReference.getProjectionInstance(t)),this.Ln}}function ii(t,e){return t.Qt-e.Qt}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=Zt(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||Gn(n,s,1e-14))&&(n<i||Gn(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 yi(t,e){return In(e,t[0],t[1],t[2])}class bi{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 gi=[],wi=[],vi=[],Ti=[],Mi=[],_i=[],Oi=[],Ai=[],xi=[],Ii=[],Si=new bi([1,0,0],0),Ci=[];class Ni{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(Ci,t,e),u=n.vec3.dot(h,i),l=n.vec3.dot(h,o),f=n.vec3.subtract(Ci,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;yi(mi.southwest(t,wi),e.southwestCornerCartesian),yi(mi.northeast(t,wi),e.northeastCornerCartesian),gi[0]=t.west,gi[1]=.5*(t.south+t.north),gi[2]=0;const r=yi(gi,vi),s=n.vec3.cross(Mi,r,pi);n.vec3.normalize(e.westNormal,s),gi[0]=t.east;const i=yi(gi,Ai),o=n.vec3.cross(Mi,pi,i);n.vec3.normalize(e.eastNormal,o);const a=n.vec3.subtract(Mi,r,i),c=n.vec3.normalize(Ti,a),h=t.south;let u;if(h>0){gi[0]=.5*(t.west+t.east),gi[1]=h;const r=yi(gi,xi);n.vec3.copy(Ii,c);const s=bi.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Si);ki(xi,Ii,s,e.southwestCornerCartesian),u=Dn(r,_i)}else u=jn(mi.southeast(t,wi),_i);const l=n.vec3.cross(Oi,u,a);n.vec3.normalize(e.southNormal,l);const f=t.north;let d;if(f<0){gi[0]=.5*(t.west+t.east),gi[1]=f;const r=yi(gi,xi);n.vec3.scale(Ii,c,-1);const s=bi.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Si);ki(xi,Ii,s,e.northeastCornerCartesian),d=Dn(r,_i)}else d=jn(mi.northwest(t,wi),_i);const m=n.vec3.cross(Oi,a,d);n.vec3.normalize(e.northNormal,m)}}function ki(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 Ri(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const Ei=s.BBOXUtil,Li={"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"]},Pi=[0,0,0],Ui=[0,0,0],Bi=[0,0,0],Fi=[0,0,0],Di=[0,0,0],ji=[0,0,0],zi=[0,0,0],Gi=[1,1,1],Hi=[0,0,0,0],qi=[],Vi=new s.Coordinate(0,0),$i=new s.Point(0,0),Ji=[0,0,0,0,0,0,0,0,0],Xi=[0,0,0,0,0,0,0,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],Wi=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Zi=new s.Point(0,0),Qi=n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Yi=[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.Pn(),this.Un=[]}Pn(){const t=this.options.services.map((t=>t.url));this.Bn=this.Bn||{},this.Tn=this.Tn||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.Bn[n];void 0===r&&(r=this.Bn[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.Fn(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Pn(),this.Fn(),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)),bt(n[t],e));const s=n[t].url,i=this.Bn[s],o=this.Tn&&this.Tn[i];return o&&(yt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Fn(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.Bn[n];this.Tn[r]&&(this.Tn[r]=null),delete this.Bn[n],e.splice(t,1)}return this.Fn(),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.Dn?Qi: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(Mt(e[0]),Mt(e[1]),Mt(e[2]),Mt(e[3]))}if(t.boundingVolume.sphere){const a=t.boundingVolume.sphere,c=En([],n.vec3.transformMat4([0,0,0],a,e));i&&o.Rn(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(En([],c));i&&o.Rn(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),y=r.locate(h,m,-m);return new s.Extent(p,y)}return null}getRootTiles(){return this.Tn}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Fn(),{tiles:qi};const e=this.getMap(),r=e.cameraPosition,s=e.pointAtResToDistance(r[2],0,e.getGLRes()),i=this.jn(r);this.zn=this.zn||[0,0,0],n.vec3.set(this.zn,Tt(i.x),Tt(i.y),s),this.Gn=In(this.Gn||[],this.zn[0],this.zn[1],this.zn[2]),this.Hn=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=Ri(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=Ri(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.qn(e);for(;r.length>0;){const e=r.pop();for(e.id||this.Vn(e);d.level>=e.bn;)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.Jn(m,t);continue}e.Qt<1/0&&this.Xn(e);const i=this.gn(e,d);d.children.push(i);const a=e.children,c=a&&a.length,h=i.content;if(!c&&h&&this.Jn(m,i),c){h&&"add"===e.refine&&this.Jn(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&&(Nt(t)||t.indexOf("i3s:")>=0?a[i].baseUrl=e.baseUrl:Ut(t)?a[i].content.url=e.baseUrl+t:a[i].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}r.push(a[i])}!s&&h&&this.Jn(m,i)}}}return{root:f,tiles:m}}Jn(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.zn,this.Gn,n,r)||t.push(e)}gn(t,e){return{id:t.id,node:t,children:[],level:t.bn,parent:e,content:t.content&&t.content.url}}Vn(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.Kn=this.Wn(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.bn&&(t.bn=t.parent.bn+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)}kt(t){return this.Tn[t].service}Zn(t){const e=t.boundingVolume;if(!e||e.Dn&&!this.Qn(t))return;const r=this.kt(t.Rt),s=r.heightOffset||0,i=this.options.offset,o=gt(i)||i[0]||i[1],a=r.coordOffset||Yi;if(!Array.isArray(a))throw new Error("service.coordOffset must be an array");if(!e.Dn&&(!t.boundingVolume||!s&&n.mat4.exactEquals(t.matrix,Qi)&&!o&&a===Yi))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.Yn([Mt(t[0]),Mt(t[1])]);c[0]=Tt(n.x+a[0]),c[1]=Tt(n.y+a[1]);const r=this.Yn([Mt(t[2]),Mt(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(Pi,i,t.matrix),c=En(Ui,o),l=this.Yn([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.Dn=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}Qn(t){const e=t.boundingVolume,n=this.kt(t.Rt),r=n.heightOffset||0,s=n.coordOffset||Yi;return e.coordOffset[0]!==s[0]||e.coordOffset[1]!==s[1]||e.heightOffset!==r}Wn(t){return void 0===t.geometricError||!t.boundingVolume}Xn(t){let e=t.parent;for(;e&&e.Kn&&!(e.Qt<=t.Qt);)e.Qt=t.Qt,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.Fn()}}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.bn&&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;bt(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.Kn=this.Wn(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&&!Nt(i)&&Ut(i)&&(e.content.url=e.baseUrl+i),t.root&&!e.parent&&this.tr(e)}this.Fn(),this.fire("loadtileset",{tileset:t,index:e&&e.Rt,url:r})}er(t,e,n){if(!t.extent||!Ei||!e)return!0;const r=t.extent;so[0]=r.xmin,so[1]=r.ymin,so[2]=r.xmax,so[3]=r.ymax;if(!Ei.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||Ei.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.Qt=1/0,0===t.bn||t.Kn)return this.tr(t),mo.VISIBLE;if(this.Zn(t),!this.nr(t,e,n))return mo.OUT_OF_FRUSTUM;if(0===t.geometricError)return mo.VISIBLE;let i=this.kt(t.Rt).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}Ee(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.Un[r];const{boundingVolume:i}=t,o=i.region,a=i.box,h=i.sphere,u=this.ir(t.Rt),l=this.getRenderer();s&&s.version===u.version||(o?s=this.Un[r]=this.ar(t):a?s=this.Un[r]=this.cr(t):h&&(s=this.Un[r]=this.hr(t)),s.version=u.version,t.Yt&&(l.Oe(t.Yt),delete t.Yt));return this.kt(t.Rt).debug&&(this.Un[r].node=t,l.Me(t)),s.obbox?function(t,e,n){M(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){M(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=En(a,a),u=En(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.Rt);t!==f||f.ur||(f.ur=l);const d=this.ke([],t),m=n.mat4.exactEquals(Qi,d);if(!m){n.vec3.transformMat4(l,l,d);const t=Pi;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 y=this.lr(u,l);for(let t=0;t<u.length;t++)u[t]-=l[t%3];return{obbox:y,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,y){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]=y,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.ke([],t),l=n.mat4.exactEquals(Qi,u);l||n.vec3.transformMat4(o,o,u);const f=[],d=Pi;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),En(d,d),s&&e.Rn(d,d);const o=Vi.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=Pi;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:En(a,o),r&&n.Rn(a,a);const c=new s.Coordinate(a),h=this.Ee(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(Di,t,0,1,4,5),s=uo(ji,t,0,3,4,7),i=uo(zi,t,0,1,2,3);return[...e,...n.vec3.sub(Pi,r,e),...n.vec3.sub(Ui,s,e),...n.vec3.sub(Bi,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);En(o,o),r&&n.Rn(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}}ke(t,e){const r=this.ir(e.Rt),s=this.kt(e.Rt),i=r.ur,o=n.mat4.fromTranslation(Xi,n.vec3.set(Pi,-i[0],-i[1],-i[2])),a=n.mat4.fromTranslation(Ki,i),c=s.rotation||to,h=n.quat.fromEuler(Hi,...c),u=s.scale,l=u&&n.vec3.set(no,u,u,u)||eo,f=n.mat4.fromRotationTranslationScale(Wi,h,ro,l);return t=n.mat4.multiply(t,f,o),n.mat4.multiply(t,a,t)}tr(t){const e=this.kt(t.Rt);if(!t.boundingVolume||this.yr(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,s=t.boundingVolume.sphere;let i=null;n?i=this.br(t).boxCenter:r?i=this.gr(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}yr(t,e){if(!t.wr)return!1;const n=e.coordOffset||Yi;return t.wr[0]===n[0]&&t.wr[1]===n[1]&&t.vr===(e.heightOffset||0)}gr(t){return this.Zn(t),this.ar(t)}br(t){return this.Zn(t),this.dr(t)}mr(t,e){let r=t.slice(3,12);const s=n.mat3.fromMat4(Ji,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(Gi,r.x/100*1.01,r.y/100*1.01,s),Gi}Yn(t){Array.isArray(t)&&(t=new s.Coordinate(t));let e=this.options.offset;if(gt(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]}qn(t){const e=this.kt(t).maxExtent;if(!e)return null;const n=this.Tn[t];return n.maxExtent||(n.maxExtent=new s.Extent(e).convertTo((t=>this.Ee(t)))),n.maxExtent}rr(t){const e=this.Hn,n=t.geometricError;if(0===n)return t.sr=0,0;const r=this.kt(t.Rt).scale||1,s=this.getMap();let i;t.boundingVolume.region?i=function(t,e,n){t.Tr||(t.Tr=new Ni(t.boundingVolume.region));return t.Tr.distanceToCamera(e,n)}(t,this.Gn,this.zn):t.boundingVolume.sphere?i=ao(t.boundingVolume,this.Gn):t.boundingVolume.box&&(i=co(t.boundingVolume,this.Gn));const o=Math.max(Math.abs(i),1e-7),a=n*r*s.height/(o*e);return t.Qt=i,t.sr=a,a}Fn(){const t=this.getRenderer();t&&t.setToRedraw()}_e(t){return this.Un[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&&Rt(n,r)}const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];const i=r.getDevicePixelRatio();return Rt(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.Pe():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.Ut||(this.Ut=[]),this.Ut.push(t),this)}Sn(){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)}Mr(){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);return this.getRenderer()?(this.Fn(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Fn(),this):this}jn(t){const e=this.getMap(),n=e.getGLRes();Zi.set(t[0],t[1]);const r=e.pointAtResToCoord(Zi,n);return"identity"===e.getProjection().code.toLowerCase()?(Ui[0]=r.x,Ui[1]=r.y,this.getRenderer().En(Pi,Ui),r.set(Pi[0],Pi[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(Pi,s[0],s[1],s[2]);r&&(i=n.vec3.transformMat4([0,0,0],i,r));return ai(i,n.mat3.set(Ji,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=_t(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,Kn:!0,service:r,visible:!!yt(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]),Rt:e,bn:0,domainKey:s}}function uo(t,e,r,s,i,o){const a=n.vec3.set(Pi,e[3*r],e[3*r+1],e[3*r+2]),c=n.vec3.set(Ui,e[3*s],e[3*s+1],e[3*s+2]),h=n.vec3.set(Bi,e[3*i],e[3*i+1],e[3*i+2]),u=n.vec3.set(Fi,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(Li),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 yo(){return po||(po={"image/crn":Ds.crn&&Ds.crn(),"image/ktx2":Ds.ktx2&&Ds.ktx2(),"image/cttf":Ds.ktx2&&Ds.ktx2(),"draco":Ds.draco&&Ds.draco()}),po}class bo{constructor(t,e,n){this.o=t,this._r=e||We,this.h=n,this.Or=yo()}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)):Ne.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._r(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=Vn(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=Jn(0,l,u);p=t.slice(e.offset,e.offset+e.byteLength),l+=u,f.push(p)}const y=d.BATCH_LENGTH,b={};if(d&&d.BATCH_ID){b.BATCH_ID=Kn(d.BATCH_ID,t,undefined.offset,y);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:b,glb:{buffer:t,byteOffset:l,byteLength:s.byteLength+s.byteOffset-l}}}Sr(){return null}}class go{constructor(t,e,n,r){this.o=t,this._r=e||We,this.h=n,this.Or=yo(),this.Cr=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Ar(t,e,n,r,s)):Ne.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.Nr(t,e,n,r,s).then((({gltf:s,transferables:i})=>{const o=this.kr(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})}))}Nr(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?Ne.getArrayBuffer(r,{}).then((t=>this.Rr(r,{buffer:t.data,byteOffset:0},o))):Ne.getJSON(r,{}).then((t=>this.Rr(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Rr(t,r,o)}}Rr(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this._r(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}}))}kr(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.Er(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Kn(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.Lr(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.Lr(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}}Lr(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}Er(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 Mo{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.Ar(t,e,n,r)):Ne.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.Pr(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}))}Pr(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.Ur||(this.Ur=yo().draco),this.Ur(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.Br(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=Kn(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=_o(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 y=this.Br(t,a,c.offset,d,o,l,f);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?y.BATCH_ID=Kn(a.BATCH_ID,t,c.offset,d):y.BATCH_ID=_o(d);const e=y.BATCH_ID.array&&y.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:y,transferables:o})}Br(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.Er(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}Er(t,e,n){return nr(new Float32Array(t.length),t,e,n)}Sr(){return null}}function _o(t){const e=Ct(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._r=e||We,this.Cr=r}load(t,e,n=0,r=0,s){return e?this.Ar(t,e,n,r,s):Ne.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.Fr(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new bo(this.o,this._r,this.h);else if("i3dm"===i[n].magic)r=new go(this.o,this._r,this.h,this.Cr);else if("pnts"===i[n].magic)r=new Mo;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new Oo(this.o,this._r,this.h,this.Cr)}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})))}Fr(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=Hn(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=bo,t.CMPTLoader=Oo,t.Geo3DTilesLayer=oo,t.Geo3DTilesUtil=Pt,t.Geo3DTransform=zn,"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.100.0")}));
|
|
23
23
|
//# sourceMappingURL=maptalks.3dtiles.js.map
|