@maptalks/3dtiles 0.13.0 → 0.13.1

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.
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * @maptalks/3dtiles v0.13.1
3
+ * LICENSE : UNLICENSED
4
+ * (c) 2016-2022 maptalks.org
5
+ */
6
+ import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as n,mat4 as r,vec3 as s,mat3 as i,vec4 as o,quat as a,createREGL as c}from"@maptalks/gl";import{intersectsBox as h,intersectsSphere as f,intersectsOrientedBox as l}from"frustum-intersects";import{GLTFLoader as u,Ajax as d}from"@maptalks/gltf-loader";import{vec3 as m,mat4 as b,mat3 as y}from"gl-matrix";const p='function(t){var e=1e-6,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 s(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],h=e[8],l=e[9],y=e[10],d=e[11],m=e[12],b=e[13],p=e[14],w=e[15],g=n[0],T=n[1],_=n[2],A=n[3];return t[0]=g*r+T*a+_*h+A*m,t[1]=g*s+T*c+_*l+A*b,t[2]=g*i+T*u+_*y+A*p,t[3]=g*o+T*f+_*d+A*w,g=n[4],T=n[5],_=n[6],A=n[7],t[4]=g*r+T*a+_*h+A*m,t[5]=g*s+T*c+_*l+A*b,t[6]=g*i+T*u+_*y+A*p,t[7]=g*o+T*f+_*d+A*w,g=n[8],T=n[9],_=n[10],A=n[11],t[8]=g*r+T*a+_*h+A*m,t[9]=g*s+T*c+_*l+A*b,t[10]=g*i+T*u+_*y+A*p,t[11]=g*o+T*f+_*d+A*w,g=n[12],T=n[13],_=n[14],A=n[15],t[12]=g*r+T*a+_*h+A*m,t[13]=g*s+T*c+_*l+A*b,t[14]=g*i+T*u+_*y+A*p,t[15]=g*o+T*f+_*d+A*w,t}function i(){var t=new n(3);return n!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function o(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function a(t,e,r){var s=new n(3);return s[0]=t,s[1]=e,s[2]=r,s}function c(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function u(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function f(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],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 l(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function y(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 d(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function m(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[0],a=n[1],c=n[2];return t[0]=s*c-i*a,t[1]=i*o-r*c,t[2]=r*a-s*o,t}function b(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,t[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,t[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,t}var 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},w=h,g=o;function T(t,e,n,r,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=s,t}function _(){var t=new n(4);return n!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function A(t,n,r,s){var i=n[0],o=n[1],a=n[2],c=n[3],u=r[0],f=r[1],h=r[2],l=r[3],y=void 0,d=void 0,m=void 0,b=void 0,p=void 0;return(d=i*u+o*f+a*h+c*l)<0&&(d=-d,u=-u,f=-f,h=-h,l=-l),1-d>e?(y=Math.acos(d),m=Math.sin(y),b=Math.sin((1-s)*y)/m,p=Math.sin(s*y)/m):(b=1-s,p=s),t[0]=b*i+p*u,t[1]=b*o+p*f,t[2]=b*a+p*h,t[3]=b*c+p*l,t}i(),function(){var t,e=(t=new n(4),n!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var S,O=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};i(),a(1,0,0),a(0,1,0),_(),_(),S=new n(9),n!=Float32Array&&(S[1]=0,S[2]=0,S[3]=0,S[5]=0,S[6]=0,S[7]=0),S[0]=1,S[4]=1,S[8]=1;\n/*!\n * @maptalks/gltf-loader v0.25.6\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.org\n */\nlet I=0;function M(t){return null==t}function x(t){return!M(t)}function v(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 U(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView\'s component type: "+t)}function N(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function 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 E=[],P=[],L=[],C=[0,0,0],D=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),F=[1,1,1];function k(t,e,n,r,s,i,o){const a=U(o);if((0===s||s===r*a.BYTES_PER_ELEMENT)&&i%a.BYTES_PER_ELEMENT==0){const s=new a(e,i,n*r);return t.set(s),t}const c=new Uint8Array(r*a.BYTES_PER_ELEMENT);for(let o=0;o<n;o++){let n=null;const u=new Uint8Array(e,s*o+i,r*a.BYTES_PER_ELEMENT);c.set(u),n=new a(c.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const R="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function z(t,e,n){const r=new Uint8Array(t,e,n);return R.decode(r)}const V={get:function(t,e={}){e||(e={});const n=new AbortController,r={signal:n.signal,method:e.method||"GET",referrerPolicy:"origin"};"POST"===e.method&&(M(e.body)||(r.body=JSON.stringify(e.body))),M(e.headers)||(r.headers=e.headers),M(e.credentials)||(r.credentials=e.credentials);const s=fetch(t,r).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 s.xhr=n,s},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",V.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?V.jsonp(t):((e=e||{}).responseType="json",V.get(t,e))}};V.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 q{constructor(t,e,n){this.i=t,this.decoders=e,this.o=n,this.images={},this.u={}}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.h(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.h(e,r);return this.getImageByBuffer(s,n)}));if(N(t.uri)){const r=this.buffers[t.id]=B(t.uri),s=this.h(e,r);return this.getImageByBuffer(s,n)}return this.u[t.id]=V.getArrayBuffer(t.uri,null).then((r=>{const s=this.buffers[t.id]=r.data,i=this.h(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;if(n[e.mimeType])return n[e.mimeType](t,{supportedFormats:this.o});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const n=new Blob([t],{type:e.mimeType}),r=URL.createObjectURL(n);return this.l(e.id,r)}}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;if(this.u[t.id])return this.u[t.id].then((()=>this.images[t.id]));return this.u[t.id]=this.l(t.id,e)}l(t,e){return new Promise(((n,r)=>{this.i(e,((s,i)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=i,n(this.images[t]))}))}))}}const $=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class j{constructor(t,e,n){this.rootPath=t,this.gltf=e,this.m=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.p()}g(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this.T(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const s=n.bufferViews[r.bufferView];return this._(s).then((n=>{const{buffer:s,byteOffset:i}=n;return this.accessors[r.id]=this.T(t,e,s,i)}))}_(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then((()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}));if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(N(e.uri)){const t=this.buffers[e.id]=B(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;t=e.uri.indexOf("://")>0||e.uri.indexOf("blob:")>=0?e.uri:this.rootPath+"/"+e.uri;return this.requests[e.id]=V.getArrayBuffer(t,null).then((t=>({buffer:this.buffers[e.id]=t.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}T(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.A(i.type),u=U(i.componentType),f=o.byteStride||0;const h={array:undefined,name:t,accessorName:e,byteLength:i.count*c*u.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:c};if(i.min&&(h.min=i.min),i.max&&(h.max=i.max),n)if(this.m)h.byteStride=f,h.byteOffset=a+(i.byteOffset||0),!f||f===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(h.array=this.S(n,i.count,c,a+(i.byteOffset||0),u),h.array.buffer.byteLength===h.byteLength&&(h.byteOffset=0)):h.array=new Uint8Array(n,a,o.byteLength);else if(i.interleaved){h.byteStride=0,h.byteOffset=0;const t=new u(i.count*c);h.array=k(t,n,i.count,c,f,a+(i.byteOffset||0),i.componentType)}else h.byteStride=0,h.array=this.S(n,i.count,c,a+(i.byteOffset||0),u),h.byteOffset=h.array.byteOffset;else{h.array=new u(i.count);const t=h.min||h.max;t&&(h.array[0]=t[0],h.array[1]=t[1],h.array[2]=t[2])}return h}p(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}S(t,e,n,r,s){return r%s.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*s.BYTES_PER_ELEMENT),r=0),new s(t,r,n*e)}A(t){const e=$.indexOf(t);return $[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this._(e).then((r=>{const{buffer:s,byteOffset:i}=r,o=z(s,i+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(N(t.uri)){const e=B(t.uri),n=z(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return V.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class G extends q{constructor(t,e,n,r,s,i){super(r,s,i),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new j(t,e,n)}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(x(t.name)&&(e.name=t.name),x(t.children)&&(e.children=t.children),x(t.jointName)&&(e.jointName=t.jointName),x(t.matrix)&&(e.matrix=t.matrix),x(t.rotation)&&(e.rotation=t.rotation),x(t.scale)&&(e.scale=t.scale),x(t.translation)&&(e.translation=t.translation),x(t.extras)&&(e.extras=t.extras),x(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=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}(E,e.translation||C),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,u=n*o,f=r*o,h=r*a,l=s*o,y=s*a,d=s*c,m=i*o,b=i*a,p=i*c;return t[0]=1-h-d,t[1]=f+p,t[2]=l-b,t[3]=0,t[4]=f-p,t[5]=1-u-d,t[6]=y+m,t[7]=0,t[8]=l+b,t[9]=y-m,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(P,e.rotation||D),i=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(L,e.scale||F);return s(i,r,i),s(t,n,i)}return r(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}O(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}I(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)}M(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.I(n).then((t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const s=this.gltf.textures[r];if(!s)return null;const i=this.gltf.samplers[s.sampler];return{format:s.format||6408,internalFormat:s.internalFormat||6408,type:s.type||5121,sampler:i,source:this.gltf.images[s.source]}}getMaterial(){return null}getAnimations(){return null}}class H extends q{constructor(t,e,n,r,s,i){super(r,s,i),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new j(t,e,n)}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 v(e,t),!x(t.weights)&&this.gltf.meshes&&x(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}M(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.I(n).then((t=>{if(!t)return null;const r={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extensions:n.extensions,extras:n.extras}};v(r,e);const s=x(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return s&&(r.sampler=s),t.format&&(r.format=t.format),r}))}I(t){if(!x(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.v(e,t)}return null}v(t,e){const n=this.h(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}h(t,e,n){n=n||0;const r=t.byteOffset+n,s=t.byteLength;return new Uint8Array(e,r,s)}U(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++)(x(t[n].input)||x(t[n].output))&&(e.push(this.accessor.g("input",t[n].input)),e.push(this.accessor.g("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 J="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null,K=1313821514,X=5130562;class Q{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 Q.readV1(r,e);if(2===s)return Q.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=W(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,c===K)n=W(t,e+12+o,a);else if(c===X){s=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:s,buffer:t,byteLength:r}}}}function W(t,e,n){if(J){const r=new Uint8Array(t,e,n);return J.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=Y[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 Y=[1,1,1,1,2,2,3,0];const Z=[0,0,0],tt=[0,0,0,1],et=[1,1,1],nt={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},rt={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},st={N(t,e,n,r,s,i,o,a){const u=x(t)?e.animations:[e.animations[0]],f={};for(let e=0;e<u.length;e++){const h=u[e],l=h.name||e;if(x(t)&&l!==t)continue;const y=h.channelsMap[n];if(y)for(let t=0;t<y.length;t++){const e=y[t];"translation"===e.target.path?(this.B(s,h.samplers[e.sampler],r,1),f.translation=c(Z,s)):"rotation"===e.target.path?(this.P(i,h.samplers[e.sampler],r,1),f.rotation=O(tt,i)):"scale"===e.target.path?(this.B(o,h.samplers[e.sampler],r,1),f.scale=c(et,o)):"weights"===e.target.path&&a&&(this.B(a,h.samplers[e.sampler],r,a.length),f.weights=a)}}return f},B(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.L(rt,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.L(rt,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.L(rt,e,n,3*r);s&&(t=this.C(t,s,e.input.array,3*r));break}}return t},P(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.L(rt,e,n,1);r&&A(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.L(rt,e,n,1);r&&(t=T(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.L(rt,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.C(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},D(t,e){const 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},L(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.D(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:u,interpolation:f}=a;t.PREINDEX=c,t.NEXTINDEX=u,t.INTERPOLATION=f;const h=o*r;return t.PREVIOUS=i.subarray(t.PREINDEX*h,(t.PREINDEX+1)*h),t.NEXT=i.subarray(t.NEXTINDEX*h,(t.NEXTINDEX+1)*h),t},C(t,e,n,r){const s=e.INTERPOLATION,i=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-i)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],f=(o-i)*e.NEXT[n],h=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*a+(Math.pow(s,3)-2*Math.pow(s,2)+s)*c+(2*-Math.pow(s,3)+3*Math.pow(s,2))*u+(Math.pow(s,3)-Math.pow(s,2))*f;t[n]=h}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;u(Z,...nt.TRANSLATION),T(tt,...nt.ROTATION),u(et,...nt.SCALE);return this.N(r,t,e,n,Z,tt,et,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?x(e)?n[e]:n[Object.keys(n)[0]]:null}};let it=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(t){}t&&"undefined"!=typeof createImageBitmap&&(it=!0)}const ot="undefined"==typeof document?null:document.createElement("canvas");class at{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=Q.read(e.buffer,e.byteOffset,e.byteLength);this.F(t,n,r)}else this.F(t,e);this.k=new j(this.rootPath,this.gltf,this.glbBuffer),this.R()}R(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}V(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.k.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.q(t),n=this.$(),r=this.j(),s=this.V();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 st.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return st.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return U(t)}static readInterleavedArray(t,e,n,r,s,i,o){return k(t,e,n,r,s,i,o)}F(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=it?ht:this.options.requestImage||ct,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new H(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),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 G(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,n)=>{e.id="accessor_"+n}),"accessors"),this.adapter.iterate(((t,e,n)=>{e.id="image_"+n}),"images"))}G(t,e){if(t.children&&t.children.length>0){if(!(n=t.children[0],"number"==typeof n&&isFinite(n)||function(t){return!M(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const r=t.children.map((t=>{const n=e[t];return n.nodeIndex=t,this.G(n,e)}));t.children=r}var n;return t}q(t){return this.H(t).then((t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.G(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={asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.O(this.gltf.materials);r.materials=t}return r}))}H(t){return this.J(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}))}K(){this.skins=[];const t=[];return this.adapter.iterate(((e,n,r)=>{t.push(this.X(n).then((t=>{t.index=r,this.skins.push(t)})))}),"skins"),t}X(t){const e=t.inverseBindMatrices;return this.adapter.accessor.g("inverseBindMatrices",e).then((e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t)))}$(){const t=this.gltf.animations;return x(t)?this.adapter.getAnimations(t):null}J(t){this.meshes={};let e=[];return this.adapter.iterate(((n,r,s)=>{e.push(this.W(r,t).then((t=>{t.index=s,this.meshes[n]=t})))}),"meshes"),e=e.concat(this.K()),Promise.all(e)}W(t,e){const n=t.primitives.map((t=>this.Y(t,e))).filter((t=>!!t));return Promise.all(n).then((e=>{const n={};return v(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.M(n));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++)if(e[t]&&e[t].image.array){const n=e[t].image.array.buffer;n&&this.transferables.indexOf(n)<0&&this.transferables.push(n)}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}))}Y(t,e){let n;const r=[],s=t.extensions;if(x(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.g(`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.k._(a).then((n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:i,byteLength:c}=a;i||(i=0);const u=new DataView(r,s+i,c),f={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(u,f).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor.g(t,e[t]);n&&r.push(n)}if(x(t.indices)){const e=this.adapter.accessor.g("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;l(t,t,s),f(t,t,i),l(n,n,s),f(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=x(t.mode)?t.mode:4,x(t.extras)&&(i.extras=t.extras),i}))}}function ct(t,e){const n=new Image;n.crossOrigin="",n.onload=()=>{if(!ot)return void e(new Error("There is no canvas to draw image!"));ot.width=n.width,ot.height=n.height;const t=ot.getContext("2d");t.drawImage(n,0,0,n.width,n.height);const r=t.getImageData(0,0,n.width,n.height),s={width:n.width,height:n.height,data:new Uint8Array(r.data)};e(null,s)},n.onerror=function(t){e(t)},n.src=t}let ut,ft;function ht(t,e){ut||(ut=new OffscreenCanvas(2,2),ft=ut.getContext("2d")),fetch(t).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{let{width:n,height:r}=t;lt(n)||(n=yt(n)),lt(r)||(r=yt(r)),ut.width=n,ut.height=r,ft.drawImage(t,0,0,n,r),t.close();const s=ft.getImageData(0,0,n,r);e(null,{width:n,height:r,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function lt(t){return 0==(t&t-1)&&0!==t}function yt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function dt(t){return t/Math.PI*180}function mt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const bt=[1,1,1,1,2,2,3,0];function pt(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=bt[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}new Array(3),new Array(3);const wt=[1/6378137,1/6378137,1/6356752.314245179],gt=[1/40680631590769,1/40680631590769,1/40408299984661.445],Tt=new Array(3),_t=new Array(3),At=new Array(3);function St(t,e){const n=gt,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],u=n[1],f=n[2],h=i*i*c*c,y=o*o*u*u,d=a*a*f*f,m=h+y+d,b=Math.sqrt(1/m),p=l(Ot,e,b);if(m<s)return isFinite(b)?p:void 0;const w=r[0],g=r[1],T=r[2],_=It;_[0]=p[0]*w*2,_[1]=p[1]*g*2,_[2]=p[2]*T*2;let A,S,O,I,M,x,v,U,N,B,E,P=(1-b)*Mt(e)/(.5*Mt(_)),L=0;do{P-=L,O=1/(1+P*w),I=1/(1+P*g),M=1/(1+P*T),x=O*O,v=I*I,U=M*M,N=x*O,B=v*I,E=U*M,A=h*x+y*v+d*U-1,S=h*N*w+y*B*g+d*E*T;L=A/(-2*S)}while(Math.abs(A)>1e-12);return t[0]=i*O,t[1]=o*I,t[2]=a*M,t}(Tt,e,wt,n,.1);let s=w(_t,r,n);s=function(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i);return t}(s,s);const i=p(At,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=mt(d(i,e))*Mt(i);return t[0]=dt(o),t[1]=dt(a),t[2]=c,t}const Ot=new Array(3),It=new Array(3);function Mt(t){return o(t)}function xt(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const vt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ut(t,e,n){const r=new Uint8Array(t,e,n);return vt?JSON.parse(vt.decode(r)):JSON.parse(pt(r))}function Nt(t,e,n){const r=new Uint8Array(t,e,n);return vt?JSON.parse(vt.decode(r)):JSON.parse(pt(r))}function Bt(t,e,n){return{offset:e,byteLength:n}}function Et(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=function(t){return Ct[t]}(i),u=function(t){if(!t)return 1;return Lt[t]}(o);return{byteStride:0,byteOffset:s+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+s,r*u)}}function Pt(t,e,n,r){t.componentType||(t.componentType="UNSIGNED_SHORT");const s=Et(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}const Lt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Ct={"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 Dt(t){for(let e in Ct)if(t===Ct[e].ctor)return Ct[e].type;throw new Error("unrecognized ctor:"+t)}function Ft(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 kt(t,e,n){let r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0);const a=t.buffer;let c,u,f={},h={};r>0&&(f=Ut(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(h=Nt(a,e,i),e+=i);const l=Bt(0,e,o);return u=a.slice(l.offset,l.offset+l.byteLength),n.push(u),{featureTable:f,featureTableBin:c,batchTable:h,batchTableBin:u}}var Rt={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},zt={},Vt={east:[],north:[],up:[],west:[],south:[],down:[]},qt=[],$t=[],jt=[];const Gt=[0,0,0];function Ht(t,e,n,r){n=n||0,r=r||n;var s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}const Jt=(Wt={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"}}[Kt="east"][Xt="north"],zt[Yt=Kt+Xt]?Qt=zt[Yt]:(Qt=function(t,n,r){if(u=Gt,f=(a=t)[0],d=a[1],b=a[2],p=u[0],w=u[1],g=u[2],Math.abs(f-p)<=e*Math.max(1,Math.abs(f),Math.abs(p))&&Math.abs(d-w)<=e*Math.max(1,Math.abs(d),Math.abs(w))&&Math.abs(b-g)<=e*Math.max(1,Math.abs(b),Math.abs(g)))c(qt,Rt[Kt]),c($t,Rt[Xt]),c(jt,Rt[Wt]);else if(Ht(t[0],0,1e-14)&&Ht(t[1],0,1e-14)){var s=mt(t[2]);c(qt,Rt[Kt]),"east"!==Kt&&"west"!==Kt&&l(qt,qt,s),c($t,Rt[Xt]),"east"!==Xt&&"west"!==Xt&&l($t,$t,s),c(jt,Rt[Wt]),"east"!==Wt&&"west"!==Wt&&l(jt,jt,s)}else{!function(t,e){h(e,t,gt),y(e,e)}(t,Vt.up);var i=Vt.up,o=Vt.east;o[0]=-t[1],o[1]=t[0],o[2]=0,y(Vt.east,o),m(Vt.north,i,o),l(Vt.down,Vt.up,-1),l(Vt.west,Vt.east,-1),l(Vt.south,Vt.north,-1),qt=Vt[Kt],$t=Vt[Xt],jt=Vt[Wt]}var a,u,f,d,b,p,w,g;return r[0]=qt[0],r[1]=qt[1],r[2]=qt[2],r[3]=0,r[4]=$t[0],r[5]=$t[1],r[6]=$t[2],r[7]=0,r[8]=jt[0],r[9]=jt[1],r[10]=jt[2],r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r},zt[Yt]=Qt),Qt);\n/*!\n * @maptalks/gl v0.67.5\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.com\n */var Kt,Xt,Qt,Wt,Yt;const Zt=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")},te=Zt(),ee=te.gl_trans__coders=te.gl_trans__coders||{};ee.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=te.gl_trans__coders=te.gl_trans__coders||{};let i=`${r}\\n const _____getGlobal = ${Zt.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},ee.registerTranscoder=function(t,e){ee[t]=e},ee.getTranscoder=function(t){return ee[t]};class ne{constructor(t,e,n){this.i=t,this.Z=e||at,this.o=n,this.tt={"image/crn":ee.crn&&ee.crn(),"image/ktx2":ee.ktx2&&ee.ktx2(),"image/cttf":ee.ktx2&&ee.ktx2(),"draco":ee.draco&&ee.draco()}}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.et(t,e,n,r)):V.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.et(t,s,n,r)}))}et(t,e,n,r){const s=this.nt(e,n,r,t);if(s.error)return Promise.resolve(s);const i=t.substring(0,t.lastIndexOf("/")),o=new this.Z(i,s.glb,{transferable:!0,requestImage:this.i,decoders:this.tt,supportedFormats:this.o});return o.load().then((e=>{e.url=`${t}-${n}-${r}`;const i=o.transferables;for(let t=0;t<s.transferables.length;t++)i.indexOf(s.transferables[t])<0&&i.push(s.transferables[t]);return{magic:"b3dm",count:s.count,transferables:i,featureTable:s.featureTable,batchTable:s.batchTable,batchTableBin:s.batchTableBin,gltf:e}}))}nt(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm\'s byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),u=s.getUint32(20,!0),f=s.getUint32(24,!0),h=28+e;u>=570425344?(h-=8,o=a,u=c,f=0,a=0,c=0):f>=570425344&&(h-=4,o=u,u=a,f=c,a=0,c=0);const l=[t];let y,d,m;if(a>0?(y=Ut(t,h,a),h+=a,o=y.BATCH_LENGTH):y={"BATCH_LENGTH":o},c>0&&(h+=c),u>0&&(d=Nt(t,h,u),h+=u,f>0)){const e=Bt(0,h,f);m=t.slice(e.offset,e.offset+e.byteLength),h+=f,l.push(m)}const b=y.BATCH_LENGTH,p={};if(y&&y.BATCH_ID){p.BATCH_ID=Pt(y.BATCH_ID,t,undefined.offset,b);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&l.indexOf(e)<0&&l.push(e)}return{count:o,transferables:l,featureTable:y,batchTable:d,batchTableBin:m,b3dm:p,glb:{buffer:t,byteOffset:h,byteLength:s.byteLength+s.byteOffset-h}}}rt(){return null}}class re{constructor(t,e,n){this.i=t,this.Z=e||at,this.o=n,this.tt={"image/crn":ee.crn&&ee.crn(),"image/ktx2":ee.ktx2&&ee.ktx2(),"image/cttf":ee.ktx2&&ee.ktx2(),"draco":ee.draco&&ee.draco()}}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.et(t,e,n,r)):V.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.et(t,s,n,r)}))}et(t,e,n,r){return this.st(t,e,n,r).then((({gltf:s,transferables:i})=>{const o=this.it(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})}))}st(t,e,n,r){const s={transferable:!0,requestImage:this.i,decoders:this.tt,supportedFormats:this.o},i=new DataView(e,n,r),o=32+i.getUint32(12,!0)+i.getUint32(16,!0)+i.getUint32(20,!0)+i.getUint32(24,!0);if(0===i.getUint32(28,!0)){let r=pt(new Uint8Array(e,o+n,i.byteLength-o));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?V.getArrayBuffer(r,{}).then((t=>this.ot(r,{buffer:t.data,byteOffset:0},s))):V.getJSON(r,{}).then((t=>this.ot(r,t,s)))}{const r={buffer:e,byteOffset:o+n,byteLength:i.byteLength-o};return this.ot(t,r,s)}}ot(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.Z(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}}))}it(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=kt(s,32+e,o),h={},l=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;h.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;h.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.at(new Uint16Array(t,r+c.offset,3*l),e,n)},o.push(h.POSITION.array.buffer)}if(a.BATCH_ID){h.BATCH_ID=Pt(a.BATCH_ID,t,c.offset,l);const e=h.BATCH_ID.array&&h.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;h.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;h.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.ct(new Uint16Array(t,e+c.offset,2*l))},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.ct(new Uint16Array(t,e+c.offset,2*l))},o.push(h.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;h.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,l).slice()},o.push(h.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;h.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.SCALE_NON_UNIFORM.array.buffer)}return{count:l,batchTable:u,batchTableBin:f,featureTable:a,i3dm:h,transferables:o}}ct(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)se(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}at(t,e,n){return Ft(new Float32Array(t.length),t,e,n)}rt(){return null}}function se(t,e,n,r){if(t[0]=ie(e,r),t[1]=ie(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]))*oe(e),t[1]=(1-Math.abs(e))*oe(t[1])}return y(t,t)}function ie(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 oe(t){return t<0?-1:1}class ae{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.et(t,e,n,r)):V.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.et(t,s,n,r)}))}et(t,e,n,r){return this.ut(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}))}ut(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=kt(s,e+28,o),h=a.QUANTIZED_VOLUME_OFFSET,l=a.QUANTIZED_VOLUME_SCALE,y=a.POINTS_LENGTH;let d,m={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){m=a.extensions["3DTILES_draco_point_compression"],d=new DataView(t,m.byteOffset+c.offset,m.byteLength);const e={attributes:m.properties,useUniqueIDs:!1};return this.ft||(this.ft=ee.draco()),this.ft(d,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.ht(t,e.attributes,c.offset,y,o,h,l);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Dt(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Pt(a.BATCH_ID,t,c.offset,y):r.BATCH_ID=ce(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:f,featureTable:a,pnts:r,transferables:o}}))}const b=this.ht(t,a,c.offset,y,o,h,l);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?b.BATCH_ID=Pt(a.BATCH_ID,t,c.offset,y):b.BATCH_ID=ce(y);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:y,batchTable:u,batchTableBin:f,featureTable:a,pnts:b,transferables:o})}ht(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,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.at(u||new Uint16Array(t,c+f,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}at(t,e,n){return Ft(new Float32Array(t.length),t,e,n)}rt(){return null}}function ce(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:Dt(e),array:r}}class ue{constructor(t,e){this.i=t,this.Z=e||at}load(t,e,n=0,r=0){return e?this.et(t,e,n,r):V.getArrayBuffer(t,{}).then((e=>{const s=e.data;return this.et(t,s,n,r)}))}et(t,e,n,r){r||(r=e.byteLength);const s=this.lt(e,t,n,r),i=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new ne(this.i,this.Z);else if("i3dm"===s[n].magic)r=new re(this.i,this.Z);else if("pnts"===s[n].magic)r=new ae;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new ue(this.i,this.Z)}i.push(r.load(t,e,s[n].offset,s[n].byteLength).then((t=>t)))}return Promise.all(i).then((t=>({magic:"cmpt",tiles:t})))}lt(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=xt(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function fe(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=[];he(r[n],s,t,e)}}}function he(t,e,n,r){if(t.matrix&&e.push(t.matrix),t.children&&t.children.length)for(let s=0,i=t.children.length;s<i;s++)he(t.children[s],e,n,r);if(void 0!==t.mesh){const s=t.mesh,i=n.meshes[s];if(i){const t=e.slice(0),o=i.primitives;for(let e=0,i=o.length;e<i;e++){const i=o[e];i&&(i.matrices=t,r(i,s,e,n))}}}}function le(t,e){let{componentType:n,byteOffset:r,byteStride:s,count:i,itemSize:o}=t;const a=t.array.buffer,c=n?at.getTypedArrayCtor(n):t.array.constructor;if(r=void 0===r?t.array.byteOffset:r,s=s||0,i=i||t.array.length/o,(!s||s===o*c.BYTES_PER_ELEMENT)&&r%c.BYTES_PER_ELEMENT==0){const t=new c(a,r,i*o);for(let n=0;n<i*o;n+=o){e(new c(t.buffer,r+n*c.BYTES_PER_ELEMENT,o),n/o)}return}const u=new Uint8Array(o*c.BYTES_PER_ELEMENT);s||(s=o*c.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const n=new Uint8Array(a,s*t+r,o*c.BYTES_PER_ELEMENT);u.set(n);e(new c(u.buffer),t),n.set(u)}}const ye=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],de=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],me="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let be,pe,we=!1;if("undefined"!=typeof OffscreenCanvas){try{pe=new OffscreenCanvas(2,2).getContext("2d")}catch(t){}pe&&"undefined"!=typeof createImageBitmap&&(we=!0)}const ge=r([]),Te=[0,0,0],_e=[],Ae=[];class Se{constructor(t,e,n,r){this.id=t,this.options=e,this.yt=this.requestImage.bind(this),this.dt=n,this.bt={},r(null,{},[])}wt(t){this.gt||(this.Tt=new ae,this.gt=new ne(this.yt,at,t),this._t=new re(this.yt,at,t))}requestImage(t,e){we?fetch(t).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{be.width=t.width,be.height=t.height,pe.drawImage(t,0,0);const n=pe.getImageData(0,0,be.width,be.height);e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.dt("requestImage",{url:t},null,e)}loadTile(t,e){this.wt(t.supportedFormats);const n=t.url,r=t.arraybuffer;if(r){delete this.bt[n];const s=xt(new DataView(r),0);if("{"===s[0]||" "===s[0]){const t=function(t,e,n){if(me){const r=new Uint8Array(t,e,n);return me.decode(r)}return pt(new Uint8Array(t,e,n))}(r,0,r.byteLength),n=JSON.parse(t);e(null,n)}else if("b3dm"===s){this.gt.load(n,r).then((n=>{if(n.error)return void e(n);const{content:r,transferables:s}=this.At(n,t);e(null,r,s)})).catch((t=>{e(t)}))}else if("pnts"===s){const s=t.transform;this.Tt.load(n,r).then((n=>{const{content:r,transferables:i}=this.St(n,s,t.rootIdx);e(null,r,i)}))}else if("i3dm"===s){const s=t.transform;this._t.load(n,r).then((n=>{const{content:r,transferables:i}=this.St(n,s,t.rootIdx);e(null,r,i)}))}else if("cmpt"===s){new ue(this.yt,at).load(n,r).then((n=>{const{content:r,transferables:s}=this.Ot(n,t);e(null,r,s)})).catch((t=>{e(t)}))}}else{const r=this.options.services[t.rootIdx];let s=r.urlParams;s&&(s=(n.indexOf("?")>0?"&":"?")+s);let i=V.getArrayBuffer(n+(s||""),r.fetchOptions);const o=i.xhr;i=i.then((r=>{delete this.bt[n],r&&r.status?e(r):(t.arraybuffer=r&&r.data,this.loadTile(t,e))})).catch((t=>{delete this.bt[n],e(t)})),this.bt[n]=o}}Ot(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},s=[];for(let t=0;t<n.length;t++){const{magic:i}=n[t];if("b3dm"===i){const{content:i,transferables:o}=this.At(n[t],e);Me(s,o),r.content.push(i)}else if("i3dm"===i||"pnts"===i){const{transform:i,rootIdx:o}=e,{content:a,transferables:c}=this.St(n[t],i,o);Me(s,c),r.content.push(a)}else if("cmpt"===i){const{content:i,transferables:o}=this.Ot(n[t],e);Me(s,o),r.content.push(i)}}return{content:r,transferables:s}}At(t,e){const{gltf:n,transferables:r,featureTable:s}=t;return this.It(t.gltf),this.convertCoordinates(n,s,e.upAxis,e.transform),delete t.transferables,{content:t,transferables:r}}St(t,e,n){const{featureTable:r}=t,s=t.pnts||t.i3dm;let i=r&&r.RTC_CENTER||[0,0,0];if(r.EAST_NORTH_UP&&!s.NORMAL_UP&&!s.NORMAL_UP_OCT32P){const e=new Float32Array(3*s.POSITION.array.length),n=[],r=[],o=[];le(s.POSITION,((t,s)=>{f(o,t,i),Jt(o,null,n),function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10]}(r,n);!function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8]}(e.subarray(9*s,9*(s+1)),r)})),s.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const o={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Oe(s.POSITION.array,3,i,ge,o);const a=Ie(o),u=c([],a),h=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0];le(s.POSITION,(t=>{t[0]=t[0]+i[0]-u[0],t[1]=t[1]+i[1]-u[1],t[2]=t[2]+i[2]-u[2],t[0]<h[0]&&(h[0]=t[0]),t[1]<h[1]&&(h[1]=t[1]),t[2]<h[2]&&(h[2]=t[2]),t[0]>l[0]&&(l[0]=t[0]),t[1]>l[1]&&(l[1]=t[1]),t[2]>l[2]&&(l[2]=t[2])})),s.POSITION.min=h,s.POSITION.max=l,e&&b(a,a,e);const y=this.Mt(a);t.rtcCenter=u,t.rtcCoord=y,t.rootIdx=n;const d=t.transferables;return delete t.transferables,{content:t,transferables:d}}It(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t].image&&e[t].image.array;if(n){const r=n[0],s=n[1],i=n[2],o=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==s||n[t+2]!==i||n[t+3]!==o){a=!1;break}a&&(e[t].image.color=[r/255,s/255,i/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const n=this.bt[t.url];n&&n.abort(),delete this.bt[t.url],e(null)}convertCoordinates(t,e,n,i){let o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center,a=ye;"X"===(n=n&&n.toUpperCase())?a=de:"Z"===n&&(a=ge),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o);const u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};fe(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=r(_e);if(t.matrices)for(let n=t.matrices.length-1;n>=0;n--)s(e,e,t.matrices[n]);const n=t.attributes.POSITION.array,i=t.attributes.POSITION.itemSize;s(e,a,e),Oe(n,i,o||Te,e,u)}));const f=Ie(u),h=c([],f);i&&b(f,f,i),t.extensions.CESIUM_RTC.coord=this.Mt(f),o||(fe(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(_e);if(t.matrices)for(let e=t.matrices.length-1;e>=0;e--)s(n,n,t.matrices[e]);s(n,a,n);const i=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],u=e[7],f=e[8],h=e[9],l=e[10],y=e[11],d=e[12],m=e[13],b=e[14],p=e[15],w=n*a-r*o,g=n*c-s*o,T=n*u-i*o,_=r*c-s*a,A=r*u-i*a,S=s*u-i*c,O=f*m-h*d,I=f*b-l*d,M=f*p-y*d,x=h*b-l*m,v=h*p-y*m,U=l*p-y*b,N=w*U-g*v+T*x+_*M-A*I+S*O;return N?(N=1/N,t[0]=(a*U-c*v+u*x)*N,t[1]=(s*v-r*U-i*x)*N,t[2]=(m*S-b*A+p*_)*N,t[3]=(l*A-h*S-y*_)*N,t[4]=(c*M-o*U-u*I)*N,t[5]=(n*U-s*M+i*I)*N,t[6]=(b*T-d*S-p*g)*N,t[7]=(f*S-l*T+y*g)*N,t[8]=(o*v-a*M+u*O)*N,t[9]=(r*M-n*v-i*O)*N,t[10]=(d*A-m*T+p*w)*N,t[11]=(h*T-f*A-y*w)*N,t[12]=(a*I-o*x-c*O)*N,t[13]=(n*x-r*I+s*O)*N,t[14]=(m*g-d*_-b*w)*N,t[15]=(f*_-h*g+l*w)*N,t):null}(Ae,n),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];le(e,(t=>{b(t,t,n),t[0]=t[0]-h[0],t[1]=t[1]-h[1],t[2]=t[2]-h[2],b(t,t,i),t[0]<o[0]&&(o[0]=t[0]),t[1]<o[1]&&(o[1]=t[1]),t[2]<o[2]&&(o[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),e.min=o,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=h)}Mt(t){return 0===g(t)?u([],0,0,-6378137):St([],t)}onRemove(){}}function Oe(t,e,n,r,s){const i=[];for(let o=0,a=t.length;o<a;o+=e){const{xmin:a,ymin:c,xmax:h,ymax:l,hmin:y,hmax:d}=s;u(i,t[o],t[o+1],t[o+2]),b(i,i,r);const m=f(i,n,i);m[0]<a&&(s.xmin=m[0]),m[0]>h&&(s.xmax=m[0]),m[1]<c&&(s.ymin=m[1]),m[1]>l&&(s.ymax=m[1]),e>2&&(m[2]<y&&(s.hmin=m[2]),m[2]>d&&(s.hmax=m[2]))}}function Ie(t){const{xmax:e,ymax:n,xmin:r,ymin:s,hmin:i,hmax:o}=t,a=[(r+e)/2,(s+n)/2,(i+o)/2];return e===-1/0&&(a[0]=0),n===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function Me(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}let xe=0;class ve{constructor(t){this.workerId=t,this.workers={},this.xt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},s){if(this.vt(e,n))return;const i=this.Ut(e,n),o=r.options,a=this.send.bind(this,t);this.workers[i]=new Se(n,o,a,s)}removeLayer({mapId:t,layerId:e},n){const r=this.vt(t,e),s=this.Ut(t,e);delete this.workers[s],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const s=this.vt(t,e);s&&s.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const s=this.vt(t,e);s&&s.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.xt[e];delete this.xt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,s){const i=s?`${t}-${xe++}`:null;s&&(this.xt[i]=s),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(i)},r||[])}Ut(t,e){return`${t}-${e}`}vt(t,e){const n=this.Ut(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new ve(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)=>{e(t,n,r)}))},Object.defineProperty(t,"Nt",{value:!0})}';function g(t){return null==t}function T(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 _(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function w(t){return t*Math.PI/180}function O(t){return t/Math.PI*180}function A(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function I(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const x=[1,1,1,1,2,2,3,0];function S(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=x[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 N(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function M(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function E(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function v(t){return 0===t.indexOf("data:")}function L(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}var R=Object.freeze({__proto__:null,isNil:g,extend:T,isFunction:_,toRadian:w,toDegree:O,getAbsoluteURL:A,sign:I,stringFromUTF8Array:S,setColumn3:N,flatArr:M,getBatchIdArrayType:E,isBase64:v,base64URLToArrayBuffer:L});const B="undefined"==typeof document?null:document.createElement("canvas");class U extends t.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(!B)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(P(t.width)&&P(t.height))return t;let e=t.width,n=t.height;P(e)||(e=C(e));P(n)||(n=C(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);B.width=t.width,B.height=t.height;const r=B.getContext("2d");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 P(t){return 0==(t&t-1)&&0!==t}function C(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}class D{constructor(t,e){this.max=t,this.currentSize=0,this.onRemove=e,this.reset()}reset(){if(this.data){const t=this.data.values();for(const e of t)this.onRemove(e)}return this.data=new Map,this.currentSize=0,this}clear(){this.reset(),delete this.onRemove}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const 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){const t=this.data.keys();let e=t.next();for(;this.currentSize>this.max&&void 0!==e.value;){if(!this.data.get(e.value).current){const t=this.getAndRemove(e.value);t&&this.onRemove(t)}e=t.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(let 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 e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e),this}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t){const e=this.data.values();for(const n of e)n.current=t}}function V(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=[];F(r[n],s,t,e)}}}function F(t,e,n,r){if(t.matrix&&e.push(t.matrix),t.children&&t.children.length)for(let s=0,i=t.children.length;s<i;s++)F(t.children[s],e,n,r);if(void 0!==t.mesh){const s=t.mesh,i=n.meshes[s];if(i){const t=e.slice(0),o=i.primitives;for(let e=0,i=o.length;e<i;e++){const i=o[e];i&&(i.matrices=t,r(i,s,e,n))}}}}function H(t,e,n){let{componentType:r,byteOffset:s,byteStride:i,itemSize:o}=e;const a=e.array.buffer,c=r?u.getTypedArrayCtor(r):e.array.constructor;if(s=void 0===s?e.array.byteOffset:s,i=i||0,!i||i===o*c.BYTES_PER_ELEMENT&&s%c.BYTES_PER_ELEMENT==0){const e=new c(a,s+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}i||(i=o*c.BYTES_PER_ELEMENT);const h=new Uint8Array(a,i*n+s,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(h),t}function k(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]}const G=new Array(3),z=new Array(3),q=[40680631590769,40680631590769,40408299984661.445];function j(t,e,n,r){const s=q,i=Math.cos(n);G[0]=i*Math.cos(e),G[1]=i*Math.sin(e),G[2]=Math.sin(n),et(G,G),m.multiply(z,s,G);const o=Math.sqrt(m.dot(G,z));var a,c,h;return c=z,h=o,(a=z)[0]=c[0]/h,a[1]=c[1]/h,a[2]=c[2]/h,m.scale(G,G,r),m.add(t,z,G)}const $=[1/6378137,1/6378137,1/6356752.314245179],X=[1/40680631590769,1/40680631590769,1/40408299984661.445],Z=new Array(3),Y=new Array(3),K=new Array(3);function Q(t,e){const n=X,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],h=n[1],f=n[2],l=i*i*c*c,u=o*o*h*h,d=a*a*f*f,b=l+u+d,y=Math.sqrt(1/b),p=m.scale(W,e,y);if(b<s)return isFinite(y)?p:void 0;const g=r[0],T=r[1],_=r[2],w=J;w[0]=p[0]*g*2,w[1]=p[1]*T*2,w[2]=p[2]*_*2;let O,A,I,x,S,N,M,E,v,L,R,B=(1-y)*tt(e)/(.5*tt(w)),U=0;do{B-=U,I=1/(1+B*g),x=1/(1+B*T),S=1/(1+B*_),N=I*I,M=x*x,E=S*S,v=N*I,L=M*x,R=E*S,O=l*N+u*M+d*E-1,A=l*v*g+u*L*T+d*R*_;U=O/(-2*A)}while(Math.abs(O)>1e-12);return t[0]=i*I,t[1]=o*x,t[2]=a*S,t}(Z,e,$,n,.1);let s=m.mul(Y,r,n);s=et(s,s);const i=m.sub(K,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=I(m.dot(i,e))*tt(i);return t[0]=O(o),t[1]=O(a),t[2]=c,t}const W=new Array(3),J=new Array(3);function tt(t){return m.length(t)}function et(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 nt(t,e){return m.multiply(e,t,X),m.normalize(e,e)}var rt=Object.freeze({__proto__:null,radianToCartesian3:j,cartesian3ToDegree:Q,normalizeCartesian:et,geodeticSurfaceNormal:nt});function st(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const it="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function ot(t,e,n){const r=new Uint8Array(t,e,n);return it?JSON.parse(it.decode(r)):JSON.parse(S(r))}function at(t,e,n){const r=new Uint8Array(t,e,n);return it?JSON.parse(it.decode(r)):JSON.parse(S(r))}function ct(t,e,n){return{offset:e,byteLength:n}}function ht(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=function(t){return ut[t]}(i),h=function(t){if(!t)return 1;return lt[t]}(o);return{byteStride:0,byteOffset:s+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+s,r*h)}}function ft(t,e,n,r){t.componentType||(t.componentType="UNSIGNED_SHORT");const s=ht(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}const lt={"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 dt(t){for(let e in ut)if(t===ut[e].ctor)return ut[e].type;throw new Error("unrecognized ctor:"+t)}function mt(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 bt(t,e,n){let r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0);const a=t.buffer;let c,h,f={},l={};r>0&&(f=ot(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(l=at(a,e,i),e+=i);const u=ct(0,e,o);return h=a.slice(u.offset,u.offset+u.byteLength),n.push(h),{featureTable:f,featureTableBin:c,batchTable:l,batchTableBin:h}}var yt={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},pt={},gt={east:[],north:[],up:[],west:[],south:[],down:[]},Tt=[],_t=[],wt=[];const Ot=[0,0,0];function At(t,e,n,r){n=n||0,r=r||n;var s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function It(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 xt=(Et={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"}}[St="east"][Nt="north"],pt[vt=St+Nt]?Mt=pt[vt]:(Mt=function(t,e,n){if(m.equals(t,Ot))m.copy(Tt,yt[St]),m.copy(_t,yt[Nt]),m.copy(wt,yt[Et]);else if(At(t[0],0,1e-14)&&At(t[1],0,1e-14)){var r=I(t[2]);m.copy(Tt,yt[St]),"east"!==St&&"west"!==St&&m.scale(Tt,Tt,r),m.copy(_t,yt[Nt]),"east"!==Nt&&"west"!==Nt&&m.scale(_t,_t,r),m.copy(wt,yt[Et]),"east"!==Et&&"west"!==Et&&m.scale(wt,wt,r)}else{nt(t,gt.up);var s=gt.up,i=gt.east;i[0]=-t[1],i[1]=t[0],i[2]=0,m.normalize(gt.east,i),m.cross(gt.north,s,i),m.scale(gt.down,gt.up,-1),m.scale(gt.west,gt.east,-1),m.scale(gt.south,gt.north,-1),Tt=gt[St],_t=gt[Nt],wt=gt[Et]}return n[0]=Tt[0],n[1]=Tt[1],n[2]=Tt[2],n[3]=0,n[4]=_t[0],n[5]=_t[1],n[6]=_t[2],n[7]=0,n[8]=wt[0],n[9]=wt[1],n[10]=wt[2],n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n},pt[vt]=Mt),Mt);var St,Nt,Mt,Et,vt;const Lt=[],Rt=[],Bt=[],Ut=[],Pt=[],Ct=[],Dt=[],Vt={x:0,y:0},Ft={x:0,y:0},Ht=Math.PI/180;const{getTextureMagFilter:kt,getTextureMinFilter:Gt,getTextureWrap:zt,getMaterialType:qt,getMaterialFormat:jt,getPrimitive:$t,getUniqueREGLBuffer:Xt}=n.REGLHelper,Zt=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Yt=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:Kt,logoutIBLResOnCanvas:Qt,getIBLResOnCanvas:Wt,getPBRUniforms:Jt}=n.pbr.PBRUtils,te={factor:0,units:0},ee={specularStrength:0,materialShininess:1},ne=[1,1,1],re=r.identity([]),se=t=>t.material instanceof n.PhongMaterial,ie=t=>t.material instanceof n.pbr.StandardMaterial,oe=[!0,!0,!0,!0],ae=[],ce=new t.Coordinate(0,0),he=[],fe=[],le={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT"};class ue{constructor(e,r){this.t=r,this.i=r.getRenderer().canvas,this.o=new t.SpatialReference,this.h=e,this.l=new n.Renderer(e),this.u={},this.m={},this.p={},this.g={},this.T={},this._={},this.O={},this.A=new n.Scene,this.I=new n.Scene,this.S=new n.Scene,this.N=new n.Scene,this.M=new n.ResourceLoader(e.texture(2)),this.v=this.L.bind(this),this.R=new n.PhongMaterial({"baseColorFactor":[1,1,1,1]}),this.B(),this.U=new n.KHRTechniquesWebglManager(this.h,this.P(),this.M)}getI3DMMeshes(){return this.T}getPNTSMeshes(){return this.g}getB3DMMeshes(){return this.p}getMap(){return this.t.getMap()}paint(t,e,n,r){const s=this.getMap();if(!t.length||!s)return;const i=this.C(),o=s.projViewMatrix,a=this.t.options.services,c=[];let f=[];for(let n=0,r=t.length;n<r;n++){let r=this.D(t[n].data.node);if(!r){if(r=this._[t[n].data.node.id],!r)continue;r=M(r)}const s=t[n].node;let l=a[s.V].polygonOffset||te;_(l)&&(l=l());const u=a[s.V].ambientLight;for(let a=0,d=r.length;a<d;a++)"b3dm"===r[a].properties.magic&&(r[a].getBoundingBox&&!h(o,r[a].getBoundingBox())||(r[a].properties.level=t[n].selectionDepth,r[a].properties.polygonOffset=l,Object.prototype.hasOwnProperty.call(r[a].uniforms,"ambientColor")||Object.defineProperty(r[a].uniforms,"ambientColor",{enumerable:!0,get:function(){return u||i.ambientColor}}),r[a].F=s,e[s.id]||c.push(r[a]),f.push(r[a])))}let l=0;const u=this.U.getExcludeFilter();l+=this.H(this.k,i,[n,se,u],r,c,f),l+=this.H(this.G,i,[n,ie,u],r,c,f),this.U.forEachShader(((t,e,s)=>{const i=this.C(s);l+=this.H(t,i,[n,e],r,c,f)}));const d=[];for(const t in this.g)d.push(this.g[t]);this.I.setMeshes(d);const m=this.q();return l+=this.l.render(this.j,m,this.I,r&&r.fbo),l}H(t,e,n,r,s,i){t.filter=n.filter((t=>!!t)),e.debug=!1,this.A.setMeshes(s),e.stencilEnable=!1,e.debug=!1,e.cullFace="back",e.colorMask=oe;let o=0;this.A.setMeshes(i),o+=this.l.render(t,e,this.A,r&&r.fbo),e.stencilEnable=!1;const a=[];for(const t in this.T)a.push(...this.T[t]);return this.S.setMeshes(a),o+=this.l.render(t,e,this.S,r&&r.fbo),o}$(t,e){return e.F.X-t.F.X}paintRegion(t,e,n,r,s){const i=this.getMap();if(!t.length&&!e.length)return;const o=i.projViewMatrix,a=[];for(let n=0,r=(t=t.concat(e)).length;n<r;n++){const e=t[n].node,r=this.Z(e);r&&(r.getBoundingBox&&!h(o,r.getBoundingBox())||a.push(r))}this.Y.filter=r,this.N.setMeshes(a);const c=this.K(n);this.l.render(this.Y,c,this.N,s&&s.fbo)}deleteTile(t){const e=t.node.id;this.W(e)}W(t){const e=this.m[t];e&&(e.geometry.dispose(),e.dispose(),delete this.m[t]);let n=this.p[t]||this.g[t]||this.T[t]||this._[t]||this.u[t];this._[t]?this.J(t):n&&(this.tt(n),delete this.p[t],delete this.g[t],delete this.T[t],delete this.u[t])}J(t){let e=this._[t];e=M(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.W(n)}delete this._[t]}tt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.tt(t[e]);else{const e=t.geometry.properties.url;if(e){const t=this.O[e];t&&(t.refCount--,t.refCount<=0&&(t.geometry.dispose(),t.material.dispose(),delete this.O[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.t;Qt(t.getRenderer().canvas,t.getMap());for(const t in this._)this.J(t);this._={};for(const t in this.p)this.W(t);this.p={};for(const t in this.g)this.W(t);this.g={};for(const t in this.T)this.W(t);this.T={};for(const t in this.u)this.W(t);this.u={};for(const t in this.m)this.W(t);this.m={},this.k&&(this.k.dispose(),delete this.k),this.G&&(this.G.dispose(),delete this.G),this.j&&(this.j.dispose(),delete this.j),this.Y&&(this.Y.dispose(),delete this.Y),this.U.dispose()}Z(e){if(!e.boundingVolume||!e.boundingVolume.region)return null;if(this.m[e.id])return this.m[e.id];const s=e.boundingVolume.region;let i=new t.Coordinate(O(s[0]),O(s[1])),o=new t.Coordinate(O(s[2]),O(s[3]));i=this.et(i),o=this.et(o);const a=i.add(o).nt(.5);i._sub(a),o._sub(a);const c=this.rt(s[4],s[5]),h=c.x,f=c.y,l=[i.x,i.y,f,o.x,i.y,f,o.x,o.y,f,i.x,o.y,f,i.x,i.y,h,o.x,i.y,h,o.x,o.y,h,i.x,o.y,h],u=new n.Geometry({aPosition:l},[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],0,{primitive:"lines"});u.generateBuffers(this.h);const d=new n.Mesh(u),m=r.identity([]);return d.setLocalTransform(r.translate(m,m,[a.x,a.y,0])),this.m[e.id]=d,d}D(t){return this.p[t.id]}has(t){return this.D(t)||this.g[t.id]||this.T[t.id]||this._[t.id]||this.u[t.id]}createPntsMesh(t,e,s,i){if(this.g[e]){const t=this.g[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:c}=t,h=a.POINTS_LENGTH,f=new n.Geometry(o,null,h,{primitive:"points",positionAttribute:"POSITION"});f.generateBuffers(this.h);const l={};o.POSITION?l.HAS_POSITION=1:o.POSITION_QUANTIZED&&(l.HAS_POSITION_QUANTIZED=1),o.RGB?l.HAS_RGB=1:o.RGBA?l.HAS_RGBA=1:o.RGB565&&(l.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(l.HAS_NORMAL=1,o.NORMAL_OCT16P&&(l.HAS_NORMAL_OCT16P=1)),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:u,rtcCoord:d}=t,m=this.st(d),b=this.it(s,u,d);r.multiply(b,b,m);const y=this.t.options.services[c],p=new n.Mesh(f);return p.properties.magic="pnts",p.properties.id=e,p.properties.count=h,p.properties.batchTable=t.batchTable,p.properties.batchTableBin=t.batchTableBin,p.setDefines(l),Object.defineProperty(p.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:y&&y.pointColor||[1,1,1,1]}}),Object.defineProperty(p.uniforms,"pointSize",{enumerable:!0,get:function(){return y&&y.pointSize||2}}),Object.defineProperty(p.uniforms,"pointOpacity",{enumerable:!0,get:function(){return y&&y.pointOpacity||1}}),p.setLocalTransform(b),this.g[e]=p,i(null,{id:e,mesh:[p]}),[p]}createI3DMMesh(t,e,i,o){if(this.T[e]){const t=this.T[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.u[e]||o(null,{id:e,mesh:t}),t}const c=this.ot(i.at),{i3dm:h,featureTable:f,gltf:l,batchTable:d,batchTableBin:m,count:b}=t,y=f.INSTANCES_LENGTH,{rtcCenter:p,rtcCoord:g}=t,T=this.st(g),_=this.it(i,p,g),{POSITION:w,NORMAL_UP:O,NORMAL_RIGHT:A,SCALE:I,SCALE_NON_UNIFORM:x,INSTANCE_ROTATION:S}=h,M={"instance_vectorA":new Float32Array(4*y),"instance_vectorB":new Float32Array(4*y),"instance_vectorC":new Float32Array(4*y)},E=new Float32Array(3),v=new Float32Array(3),L=[],R=new Float32Array(1),B=new Float32Array(3),U=[],P=[],C=[],D=[],F=new Float32Array(9);!function(t,e){let{componentType:n,byteOffset:r,byteStride:s,count:i,itemSize:o}=t;const a=t.array.buffer,c=n?u.getTypedArrayCtor(n):t.array.constructor;if(r=void 0===r?t.array.byteOffset:r,s=s||0,i=i||t.array.length/o,(!s||s===o*c.BYTES_PER_ELEMENT)&&r%c.BYTES_PER_ELEMENT==0){const t=new c(a,r,i*o);for(let n=0;n<i*o;n+=o)e(new c(t.buffer,r+n*c.BYTES_PER_ELEMENT,o),n/o);return}const h=new Uint8Array(o*c.BYTES_PER_ELEMENT);s||(s=o*c.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const n=new Uint8Array(a,s*t+r,o*c.BYTES_PER_ELEMENT);h.set(n),e(new c(h.buffer),t),n.set(h)}}(w,((t,e)=>{O?(H(v,A,e),H(E,O,e),s.cross(L,v,E),s.normalize(L,L),N(U,v,0),N(U,E,1),N(U,L,2),a.fromMat3(P,U)):S?(H(F,S,e),a.fromMat3(P,F)):a.identity(P),I?(H(R,I,e),s.set(C,R[0],R[0],R[0])):x?(H(B,x,e),s.set(C,...B)):s.set(C,1,1,1),r.fromRotationTranslationScale(D,P,t,C),k(M.instance_vectorA,e,D,0),k(M.instance_vectorB,e,D,1),k(M.instance_vectorC,e,D,2)}));const G={};for(const t in M)G[t]={buffer:this.h.buffer({dimension:M[t].length/y,data:M[t]}),divisor:1};const z=this.t.options.services[i.V].shader||"phong";let q=0,j=!0;const $=[];return V(l,((t,s,o,a)=>{let{geometry:h,material:f}=this.ct(t,s,o,a,i,!0,z);f&&!f.isReady()&&(j=!1,q++);const l=new n.InstancedMesh(G,y,h,f);l.properties.magic="i3dm",l.properties.id=e,l.properties.count=b,l.properties.batchTable=d,l.properties.batchTableBin=m;const u=this.ht(t,h,f,i.V),p=r.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(p,p,t.matrices[e]);r.multiply(p,c,p),l.setPositionMatrix(p),r.multiply(T,_,T),l.setLocalTransform(T),l.setDefines(u),l.properties.polygonOffset={offset:0,factor:0},$.push(l)})),j?(this.T[e]=$,o(null,{id:e,mesh:$})):(this.u[e]={meshes:$,count:q},$.ft=o),$}createB3DMMesh(e,s,i,o){if(this.p[s]||this.u[s]){const t=this.p[s];return console.warn(`mesh with id(${s}) was already created.`),this.u[s]||o(null,{id:s,mesh:t}),t}let a;if(i.maxExtent){const e=new t.Extent(i.maxExtent).convertTo((t=>this._pointToPrj(t)));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const c=this.ot(i.at),h=e.gltf,{center:f,coord:l}=h.extensions.CESIUM_RTC,u=this.t.options.services[i.V].heightOffset||0;u&&(l[2]+=u);const d=this.st(l,i.V),m=this.t.options.services[i.V].shader||"phong",b=[];let y=0,p=!0;return V(h,((t,o,h,u)=>{let{geometry:g,material:T}=this.ct(t,o,h,u,i,!1,m);T&&!T.isReady()&&(p=!1,y++);const _=new n.Mesh(g,T);_.properties.magic="b3dm",_.properties.id=s,_.properties.batchTable=e.batchTable,_.properties.batchTableBin=e.batchTableBin,_.properties.count=e.featureTable.BATCH_LENGTH;const w=this.ht(t,g,T,i.V);_.setDefines(w),a&&(w.USE_MAX_EXTENT=1,_.setUniform("maxPrjExtent",a));let O=r.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(O,O,t.matrices[e]);const A=this.it(i,f,l);r.multiply(O,c,O),r.multiply(O,d,O),r.multiply(O,A,O),_.setLocalTransform(O),b.push(_)})),p?(this.p[s]=b,o(null,{id:s,mesh:b})):(this.u[s]={meshes:b,count:y},b.ft=o),b}it(e,n,i){const o=this.getMap(),a=this.t.options.services[e.V].heightOffset||0,c=new t.Coordinate(i),h=o.distanceToPointAtRes(100,0,o.getGLRes(),c).x/100;let f=e.matrix?r.copy([],e.matrix):r.identity([]);if(n){It(f,s.transformMat4(ae,n,f),f)}const l=function(t,e,n,r,s,i,o){e=m.copy(Lt,e);const a=j(Lt,e[0]*Ht,e[1]*Ht,e[2]),c=b.getTranslation(Rt,n),h=r.ellipsoid;var f;f=0===m.len(c)?m.set(Bt,0,0,-6378137):Q(Bt,c),Vt.x=f[0],Vt.y=f[1];const l=r.project(Vt,Ft);Ut[0]=l.x/s,Ut[1]=l.y/s,Ut[2]=(f[2]+o)*i;const u=xt(a,h,Pt),d=function(t,e,n){var r=t[0],s=t[1],i=t[2],o=t[4],a=t[5],c=t[6],h=t[8],f=t[9],l=t[10],u=e[0],d=e[1],m=e[2],b=e[3],y=e[4],p=e[5],g=e[6],T=e[7],_=e[8],w=r*u+o*d+h*m,O=s*u+a*d+f*m,A=i*u+c*d+l*m,I=r*b+o*y+h*p,x=s*b+a*y+f*p,S=i*b+c*y+l*p,N=r*g+o*T+h*_,M=s*g+a*T+f*_,E=i*g+c*T+l*_;return n[0]=w,n[1]=O,n[2]=A,n[3]=0,n[4]=I,n[5]=x,n[6]=S,n[7]=0,n[8]=N,n[9]=M,n[10]=E,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(b.invert(Ct,u),y.fromMat4(Dt,n),t);return It(t,Ut,d),t}(f,i,f,o.getProjection(),o.getGLRes(),h,a),u=(d=fe,p=l,m.set(d,p[12],p[13],p[14]),d);var d,p;let g=this.t.options.offset;if(_(g)){g=g(this.t.lt(e.id).center)}return s.set(he,g[0],g[1],0),s.sub(u,u,he),It(l,u,l),l}createCMPTMesh(t,e,n,r){if(this._[e]){const t=this._[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._[e]=i,r(null,{id:e,mesh:i}),i}ht(t,e,n,r){return("phong"===(this.t.options.services[r].shader||"phong")?this.k:this.G).getGeometryDefines(e)}ct(t,e,n,r,s,i,o){const a=r.url+"-"+e+"-"+n;if(this.O[a])return this.O[a].refCount++,this.O[a];let c,h;const f=r.materials[t.material];if(r.extensions&&r.extensions.KHR_techniques_webgl&&f.extensions&&f.extensions.KHR_techniques_webgl){const e=this.ut(t,r,i);c=e.material,h=e.geometry}else{h=this.dt(t,i,le);const e=this.t.options.services[s.V].material;c=this.bt(t.material,r,o,e||ee)}c&&!c.isReady()?c.yt=s.id:c||(c=this.R);const l={refCount:1,geometry:h,material:c};return h.properties.url=a,this.O[a]=l,l}ut(t,e,n){const{geometry:r,material:s}=this.U.createMesh(t,e,n);return{geometry:r,material:s}}dt(t,e,r){const s=t.attributes,i=r.COLOR_0;if(s[i]&&s[i]instanceof Float32Array){const t=new Uint8Array(s[i].length);for(let e=0;e<t.length;e++)t[e]=Math.round(255*s[i][e]);s[i]=t}const o={};for(const t in s){const e=Xt(this.h,s[t],{dimension:s[t].itemSize}),n=r[t]||t;o[n]={buffer:e},n===r.POSITION&&(o[n].array=s[t].array,o[n].min=s[t].min,o[n].max=s[t].max)}delete t.attributes;const a=new n.Geometry(o,t.indices.array?t.indices.array:t.indices,0,{positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,primitive:void 0===t.mode?"triangles":$t(t.mode)});return a.generateBuffers(this.h,{excludeElementsInVAO:e}),a}st(t){const e=r.identity([]),n=this.getMap(),i=this.gt();ce.x=t[0],ce.y=t[1];const o=n.distanceToPointAtRes(100,100,n.getGLRes(),ce);return s.set(i,o.x/100*1.01,o.y/100*1.01,o.y/100),r.scale(e,e,i),e}B(){const t={x:0,y:0,width:()=>this.i?this.i.width:1,height:()=>this.i?this.i.height:1};this.Y=new n.MeshShader({vert:"attribute vec3 aPosition;\n\n\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main() {\n\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n}\n\n",frag:"precision mediump float;\nuniform vec3 color;\nvoid main() {\n gl_FragColor = vec4(color, 1.0);\n}\n",uniforms:["color",{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply([],e.projViewMatrix,e.modelMatrix)}],extraCommandProps:{viewport:t}});const e=[],s=[];this.j=new n.MeshShader({vert:"const float SHIFT_RIGHT_11 = 1.0 / 2048.0;\n\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\n\nconst float SHIFT_LEFT_11 = 2048.0;\n\nconst float SHIFT_LEFT_5 = 32.0;\n\nconst float NORMALIZE_6 = 1.0 / 64.0;\n\nconst float NORMALIZE_5 = 1.0 / 32.0;\n\n\n\n#ifdef HAS_POSITION\n\n attribute vec3 POSITION;\n\n#endif\n\n\n\n#if defined(HAS_RGB)\n\n attribute vec3 RGB;\n\n#elif defined(HAS_RGBA)\n\n attribute vec4 RGBA;\n\n#elif defined(HAS_RGB565)\n\n attribute float RGB565;\n\n#endif\n\n\n\nuniform vec4 pointColor;\n\nuniform float pointSize;\n\n\n\nuniform mat4 projViewModelMatrix;\n\nuniform float pointOpacity;\n\n\n\nvarying vec4 vColor;\n\n\n\n#ifdef HAS_NORMAL\n\n #ifdef HAS_NORMAL_OCT16P\n\n attribute vec2 NORMAL_OCT16P;\n\n float signNotZero(float value) {\n\n return value >= 0.0 ? 1.0 : -1.0;\n\n }\n\n vec2 signNotZero(vec2 value) {\n\n return vec2(signNotZero(value.x), signNotZero(value.y));\n\n }\n\n vec3 octDecode(vec2 encoded, float range) {\n\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n\n return vec3(0.0, 0.0, 0.0);\n\n }\n\n encoded = encoded / range * 2.0 - 1.0;\n\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n\n if (v.z < 0.0) {\n\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n\n }\n\n return normalize(v);\n\n }\n\n vec3 octDecode(vec2 encoded) {\n\n return octDecode(encoded, 255.0);\n\n }\n\n #else\n\n attribute vec3 NORMAL;\n\n #endif\n\n uniform vec3 lightDir;\n\n uniform mat3 modelNormalMatrix;\n\n uniform mat4 positionMatrix;\n\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n\n return max(dot(-lightDir, normal), 0.0);\n\n }\n\n#endif\n\n\n\nvoid main() {\n\n #if defined(HAS_RGB)\n\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n\n #elif defined(HAS_RGBA)\n\n vColor = RGBA / 255.0 * pointOpacity;\n\n #elif defined(HAS_RGB565)\n\n float compressed = RGB565;\n\n float r = floor(compressed * SHIFT_RIGHT_11);\n\n compressed -= r * SHIFT_LEFT_11;\n\n float g = floor(compressed * SHIFT_RIGHT_5);\n\n compressed -= g * SHIFT_LEFT_5;\n\n float b = compressed;\n\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n\n vColor = vec4(rgb, 1.0);\n\n #else\n\n vColor = pointColor;\n\n #endif\n\n\n\n #ifdef HAS_POSITION\n\n vec3 localPos = POSITION;\n\n #endif\n\n\n\n #ifdef HAS_NORMAL\n\n mat3 positionNormalMatrix = mat3(positionMatrix);\n\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n\n #ifdef HAS_NORMAL_OCT16P\n\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n\n #else\n\n vec3 localNormal = NORMAL;\n\n #endif\n\n vec3 normal = normalize(normalMatrix * localNormal);\n\n float colorStrength = getLambertDiffuse(lightDir, normal);\n\n colorStrength = max(colorStrength, 0.5);\n\n vColor *= colorStrength;\n\n #endif\n\n\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n}\n\n",frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n gl_FragColor = vColor;\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply(s,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,n)=>i.fromMat4(e,n.modelMatrix)}],extraCommandProps:{viewport:t,blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const o=this.P();this.k=new n.PhongShader({extraCommandProps:o}),this.G=new n.pbr.StandardShader({extraCommandProps:o});const a=this.t;Kt(a.getRenderer().canvas,this.h,a.getMap())}P(){return{viewport:{x:0,y:0,width:()=>this.i?this.i.width:1,height:()=>this.i?this.i.height:1},colorMask:(t,e)=>e.colorMask||oe,cull:{enable:!0,face:(t,e)=>e.cullFace},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"keep"}},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}K(t){return{projViewMatrix:this.getMap().projViewMatrix,color:t&&t.color||[0,1,0]}}q(t){const e=this.getMap(),n=e.getLightManager(),r=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1],i=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:i,lightDir:s.normalize(r,r)}}C(){const t=this.getMap(),e=this.t.getRenderer().canvas,{iblTexes:n,dfgLUT:r}=Wt(e),s=Jt(t,n,r);return T(s,{lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[e.width,e.height],polygonFill:[1,1,1,1],polygonOpacity:1}),s}bt(t,e,r,s){const i=e.materials[t];if(!i||!i.baseColorTexture&&!i.pbrMetallicRoughness)return null;const a=T({},s);if(i.baseColorTexture){const t=e.textures[i.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Tt(t)),a.baseColorFactor=t&&t.image.color||i.baseColorFactor||[1,1,1,1],n&&(a.baseColorTexture=n)}else{if(i.normalTexture){const t=this.Tt(e.textures[i.normalTexture.index]),n=i.normalTexture.scale||1;a.normalTexture=t,a.normalMapFactor=n}if(i.occlusionTexture){const t=this.Tt(e.textures[i.occlusionTexture.index]),n=i.occlusionTexture.strength||1;a.occlusionTexture=t,a.occlusionFactor=n}if(i.emissiveTexture){const t=this.Tt(e.textures[i.emissiveTexture.index]);a.emissiveTexture=t}i.emissiveFactor;const t=i.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(a.baseColorFactor=t.baseColorFactor),t.baseColorTexture){const n=e.textures[t.baseColorTexture.index];n.image.color?a.baseColorFactor=a.baseColorFactor?o.multiply(a.baseColorFactor,a.baseColorFactor,n.image.color):n.image.color:a.baseColorTexture=this.Tt(n)}if(g(t.metallicFactor)||(a.metallicFactor=t.metallicFactor),g(t.roughnessFactor)||(a.roughnessFactor=t.roughnessFactor),i.metallicRoughnessTexture){const t=this.Tt(e.textures[i.metallicRoughnessTexture.index]);a.metallicRoughnessTexture=t}}}let c=new n.pbr.StandardMaterial(a);return"phong"===r&&(c=n.PhongMaterial.convertFrom(c)),c.once("complete",this.v),c}Tt(t){const e={type:t.type?qt(t.type):"uint8",format:t.format?jt(t.format):"rgba",flipY:!1},r=t.image;r.array?e.data=r.array:r.mipmap&&(e.mipmap=r.mipmap),e.width=r.width,e.height=r.height;const s=t.sampler||t.texture.sampler;return s&&(s.magFilter&&(e.mag=kt(s.magFilter)),s.minFilter&&(e.min=Gt(s.minFilter)),s.wrapS&&(e.wrapS=zt(s.wrapS)),s.wrapT&&(e.wrapT=zt(s.wrapT))),new n.Texture2D(e,this.M)}_t(t){const e=t.image,n=window.URL||window.webkitURL,r=new Blob([e.array],{type:e.mimeType});return n.createObjectURL(r)}L({target:t}){const e=t.yt,n=this.u[e];if(n.count--,!n.count){const t=n.meshes;this.p[e]=t,delete this.u[e];const r=t.ft;delete t.ft,r(null,{mesh:n.meshes,id:e})}}gt(){return ne}et(t){return this.t.et(t)}rt(t,e){const n=this.getMap();return n.getGLZoom?n.distanceToPoint(t,e,n.getGLZoom()):n.distanceToPointAtRes(t,e,n.getGLRes())}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes())}ot(t){return"Y"===t?Zt:"X"===t?Yt:re}}class de extends t.renderer.CanvasRenderer{constructor(t){super(t),this.prepareWorker(),this.tilesLoading={},this.tileCache=new D(1024*t.options.maxGPUMemory*1024,this.deleteTile.bind(this)),this.wt={},this.Ot=[]}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.Ot.length||super.needToRedraw())}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){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.At();const{selectedTiles:o,leaves:a,requests:c}=this.It(r,s);c.length&&this.loadTiles(c),this.xt(o,a,e),this.St(),c.length||this.completeRender()}It(t,e){let n=[];this.Nt();let r=0;const s=this.Mt(),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 f=this.Et(c.id);if(this.vt(c.id)?(r++,h=a=!0,this.tilesLoading[c.id].current=!0):f?(this.getTileOpacity(f)<1&&(h=a=!0),o=!0,s.selected=!0,s.data=f):this.painter.has(c)||(h=a=!0,n.push(c)),!h)continue;if(this.Lt(s))o=!0;else{this.Rt(s).length&&(o=!0)}}let c=[],h={};if(o&&({selectedTiles:c,leaves:h}=this.Bt(t)),n.length>1&&(n.sort(me),s)){const t=s-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c,leaves:h}}Bt(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.Ut===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.Ut=s.length}for(let t=0;t<o.length;t++)s.push(o[t])}return{selectedTiles:e,leaves:n}}Lt(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}Rt(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.Pt+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.Ct(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].Pt<=n&&r.push(s[i])}}return e}xt(t,e,n){this.tileCache.markAll(!1);for(let e=0,n=t.length;e<n;e++){const n=t[e].data;n.current=!0,this.tileCache.add(t[e].node.id,n)}this.tileCache.shrink();const r={tiles:t,leaves:e};this.onDrawTileStart(r);const s=n&&n.renderTarget,i=n&&n.sceneFilter,o=this.painter.paint(t,e,i,s);this.layer.options.debug&&this.painter.paintRegion(t,{color:this.layer.options.debugOutline},i,s),this.onDrawTileEnd(r),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(v(e)){const n=L(e);return void this.Dt(e,n,t)}t&&-1===e.indexOf("http://")&&-1===e.indexOf("https://")&&(e=t.baseUrl+e);const n=this.layer.options.services[t.V];if(n.ajaxInMainThread){let r=n.urlParams;r&&(r=(e.indexOf("?")>0?"&":"?")+r);let s=d.getArrayBuffer(e+(r||""),n.fetchOptions);const i=s.xhr;s=s.then((n=>{delete this.wt[e],n?this.Dt(e,n.data,t):this.onTileError(null,t)})).catch((n=>{delete this.wt[e],this.onTileError(n,t)})),this.wt[e]=i}else this.Dt(e,null,t)}Dt(t,e,r){let s=this.Vt;s||(s=n.Util.getSupportedFormats(this.gl.gl||this.gl),this.Vt=s),this.workerConn.loadTile(this.layer.getId(),{url:t,arraybuffer:e,rootIdx:r.V,upAxis:r.at,transform:r.matrix,supportedFormats:s},((e,n)=>{if(e)return void this.onTileError(e,r);const{magic:s}=n;"b3dm"===s||"pnts"===s||"i3dm"===s||"cmpt"===s?this.Ot.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}At(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.Ot.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.Ot.shift(),{magic:r}=t;"b3dm"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ft(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Ft(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ft(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Ft(t,e,n,r)})),n++}}Ft(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.Ht(r);e.memorySize=n,this.onTileLoad(t,e)}}Ht(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Ht(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.kt(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n))}onTileError(t,e){if(!this.layer)return;const n=e.content.url;console.warn("failed to load 3d tile: "+n),console.warn(t),delete this.tilesLoading[e.id],this.kt(e),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}Et(t){return this.tileCache.get(t)}kt(e){const n={loadTime:t.Util.now(),current:!0,node:e};this.tileCache.add(e.id,n)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;if(this.layer.options.services[t.node.V].ajaxInMainThread){const t=this.wt[e];t&&t.abort()}else this.workerConn.abortTileLoading(this.layer.getId(),e);delete this.wt[e]}Nt(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}createContext(){const t=this.layer,e=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:t.options.antialias};this.canvas.gl&&this.canvas.gl.wrap?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.Gt(this.canvas,e)),this.regl=this.regl||c({gl:this.gl,attributes:e,extensions:["OES_element_index_uint","WEBGL_compressed_texture_s3tc"],optionalExtensions:t.options.optionalExtensions||[]}),this.painter=new ue(this.regl,t)}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new U("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let n=this.layer.options||{};n=T({},n),delete n.offset,n.projection=t.getSpatialReference().getProjection().code;const r=this.layer.getId();e.addLayer(r,n,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.St(!0),this.tileCache.reset(),this.tilesLoading={},super.clear()}clearCanvas(){this.regl&&this.regl.clear({color:[0,0,0,0],depth:1,stencil:0}),super.clearCanvas()}getTileOpacity(){return 1}getStencilValue(){return 0}St(t){this.zt||(this.zt=Date.now());const e=Date.now();if(t||!(e-this.zt<this.layer.options.retireInterval)){this.zt=e;for(const e in this.tilesLoading){const n=this.tilesLoading[e];!t&&n.current||this.abortTileLoading(n)}}}Mt(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}Gt(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}vt(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 ht(t,e,0,n)}}function me(t,e){return t.X-e.X}function be(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function ye(t,e,n){return Math.sqrt(function(t,e,n){var r=m.subtract(pe,n,t),s=be(ge,e,0),i=be(Te,e,1),o=be(_e,e,2),a=m.len(s),c=m.len(i),h=m.len(o);m.normalize(s,s),m.normalize(i,i),m.normalize(o,o);var f=we;f[0]=m.dot(r,s),f[1]=m.dot(r,i),f[2]=m.dot(r,o);var l,u=0;f[0]<-a?u+=(l=f[0]+a)*l:f[0]>a&&(u+=(l=f[0]-a)*l);f[1]<-c?u+=(l=f[1]+c)*l:f[1]>c&&(u+=(l=f[1]-c)*l);f[2]<-h?u+=(l=f[2]+h)*l:f[2]>h&&(u+=(l=f[2]-h)*l);return u}(t,e,n))}const pe=[],ge=[],Te=[],_e=[],we=[];const Oe=t.projection.EPSG3857,Ae=new t.Extent(0,0,0,0),Ie=new t.Extent(0,0,0,0),xe=[],Se=[],Ne=[],Me=[],Ee=new t.Point(0,0),ve=new t.Coordinate(0,0),Le=new t.Coordinate(0,0),Re=[],Be=new t.Coordinate(0,0),Ue=r.identity([]);class Pe extends t.Layer{constructor(t,e){super(t,e),this.qt(),this.wt={},this.jt=[]}qt(){let t=this.options.services.map((t=>t.url));this.$t=t.map(((t,e)=>function(t,e){t=A(t);return{baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.identity([]),V:e,Pt:0}}(t,e))),this.fire("rootready",{roots:this.$t.slice(0)})}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.$t.length;t++)if(this.$t[t].boundingVolume){const n=this.boundingVolumeToExtent(this.$t[t]);e._combine(n)}return e}return this.$t[e]&&this.$t[e].boundingVolume?this.boundingVolumeToExtent(this.$t[e]):null}boundingVolumeToExtent(e){const n=e.boundingVolume.Xt?Ue:e.matrix,r=this.getMap();if(e.boundingVolume.region){const n=e.boundingVolume.region;return new t.Extent(O(n[0]),O(n[1]),O(n[2]),O(n[3]))}if(e.boundingVolume.sphere){const i=e.boundingVolume.sphere,o=Q([],s.transformMat4([],i,n)),a=i[3],c=r.locate(o,-a,a),h=r.locate(o,a,-a);return new t.Extent(c,h)}if(e.boundingVolume.box){const o=e.boundingVolume.box,a=s.transformMat4([],o,n),c=new t.Coordinate(Q([],a)),h=o.slice(3);i.multiply(h,i.fromMat4([],e.matrix),h);const f=s.length(h.slice(0,3)),l=s.length(h.slice(3,6)),u=s.length(h.slice(6,9)),d=Math.max(f,l,u),m=r.locate(c,-d,d),b=r.locate(c,d,-d);return new t.Extent(m,b)}return null}getRootTiles(){return this.$t}getTiles(){if(!this.getRenderer().ready)return this.Zt(),{tiles:Me};const t=this.getMap(),e=t.cameraPosition;let n,r;if(t.getGLZoom)r=t.pointToDistance(e[2],0,t.getGLZoom()),Be.set(e[0],e[1]),n=t.pointToCoord(Be,t.getGLZoom());else{const s=t.getGLRes();r=t.pointAtResToDistance(e[2],0,s),Be.set(e[0],e[1]),n=t.pointAtResToCoord(Be,s)}this.Yt=this.Yt||[],s.set(this.Yt,w(n.x),w(n.y),r),this.Kt=j(this.Kt||[],this.Yt[0],this.Yt[1],this.Yt[2]),this.Qt=2*Math.tan(.5*w(t.getFov())),this.Wt=Oe.project(n).toArray();const i=t.projViewMatrix,o={children:[],level:-1};let a=o;const c=[];for(let t=0;t<this.$t.length;t++){let e=1/0;const n=[this.$t[t]],r=this.Jt(t);for(;n.length>0;){const t=n.pop();for(t.id||this.te(t);a.level>=t.Pt;)a=a.parent;const s=this.ee(t,r,i);if(s<1){let n=a;for(;n&&!n.content;)n=n.parent;0===s&&n&&n.content&&this.ne(c,n);if(!1===this.options.services[t.V].alwaysShow)continue;if(!(0===s&&t.Pt<=e))continue;t.content&&(e=t.Pt)}t.X<1/0&&this.re(t);const o=this.Ct(t,a);a.children.push(o);const h=t.children,f=h&&h.length,l=o.content;if(!f&&l&&this.ne(c,o),f){l&&"add"===t.refine&&this.ne(c,o),a=o;const e=h[0].parent;for(let r=0,s=h.length;r<s;r++){if(!e){h[r].parent=t,h[r].at=t.at,h[r].baseUrl=t.baseUrl;const e=h[r].content&&(h[r].content.url||h[r].content.uri);e&&(v(e)?h[r].baseUrl=t.baseUrl:-1===e.indexOf("http://")&&-1===e.indexOf("https://")?h[r].content.url=t.baseUrl+e:h[r].baseUrl=e.substring(0,e.lastIndexOf("/")+1))}n.push(h[r])}}}}return{root:o,tiles:c}}ne(t,e){const{viewerRequestVolume:n}=e.node;n&&!function(t,e,n){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return Ce(n,e);if(n.box)return 0===De(n,e)}return!1}
7
+ /*!
8
+ * @maptalks/gl v0.67.5
9
+ * LICENSE : UNLICENSED
10
+ * (c) 2016-2022 maptalks.com
11
+ */(this.Yt,this.Kt,n)||t.push(e)}Ct(t,e){return{id:t.id,node:t,children:[],level:t.Pt,parent:e,content:t.content&&t.content.url}}te(e){e.id=t.Util.GUID(),e.matrix=e.transform||r.identity([]),e.se=this.ie(e),e.parent&&(e.matrix=r.multiply(e.matrix,e.parent.matrix,e.matrix),e.V=e.parent.V,void 0===e.Pt&&(e.Pt=e.parent.Pt+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri),this.oe(e)}oe(t){const e=t.boundingVolume;if(!e||e.Xt)return;const n=this.options.services[t.V].heightOffset||0,i=this.options.offset,o=_(i)||i[0]||i[1];if(!t.boundingVolume||!n&&r.exactEquals(t.matrix,Ue)&&!o)return;const{region:a,box:c,sphere:h}=e;if(a){const t=this.ae([O(a[0]),O(a[1])]);a[0]=w(t.x),a[1]=w(t.y);const e=this.ae([O(a[2]),O(a[3])]);a[2]=w(e.x),a[3]=w(e.y),a[4]+=n,a[5]+=n}else if(c||h){const e=c||h,r=s.transformMat4(xe,e,t.matrix),i=Q(Se,r),o=this.ae([i[0],i[1]]);i[0]=o.x,i[1]=o.y,i[2]+=n,j(e,w(i[0]),w(i[1]),i[2])}e.Xt=!0}ie(t){return void 0===t.geometricError||!t.boundingVolume}re(t){let e=t.parent;for(;e&&e.se&&!(e.X<=t.X);)e.X=t.X,e=t.parent}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const s=(t.asset&&t.asset.gltfUpAxis||e&&e.at||this.options.services[e.V].upAxis||"Y").toUpperCase();if(t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1),t.root.at=s,e){const n=e.boundingVolume;T(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",n&&(e.boundingVolume=n);const s=t.root.transform;s&&(e.parent?e.matrix=r.multiply([],e.parent.matrix,s):e.matrix=s),this.oe(e),e.ce=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.se=this.ie(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),i&&!v(i)&&-1===i.indexOf("http://")&&-1===i.indexOf("https://")&&(e.content.url=e.baseUrl+i)}this.Zt(),this.fire("loadtileset",{tileset:t,index:e.V,url:n})}ee(t,e,n){if(t.X=1/0,0===t.Pt||t.se)return 1;if(!this.he(t,e,n))return-1;if(0===t.geometricError)return 1;let r=this.options.services[t.V].maximumScreenSpaceError;null==r&&(r=8);let s=this.fe(t);return 0===s&&t.parent&&(s=.5*(t.parent.le||0)),s>=r?1:0}et(e,n){n||(n=new t.Point(0,0));const r=this.getMap();return r.getGLZoom?r.coordToPoint(e,r.getGLZoom(),n):r.coordToPointAtRes(e,r.getGLRes(),n)}he(e,n,s){const o=e.id;let a=this.jt[o];const{boundingVolume:c}=e,u=c.sphere,d=c.region,m=c.box;if(!a){let n,s,c;if(d){n=Ae.set(O(d[0]),O(d[1]),O(d[2]),O(d[3]));const t=n.getCenter(),e=this.ue(t);n=n.convertTo((t=>this.et(t,Ee)),Ie),c=d[4],s=d[5],a=this.jt[o]=[[n.xmin,n.ymin,c*e[2]],[n.xmax,n.ymax,s*e[2]]],a.center=t}else if(u){const e=Q(xe,u),n=new t.Coordinate(e),r=this.et(n,Ee).toArray(),s=this.ue(n);r.push(e[2]*s[2]),a=this.jt[o]=[r,u[3]*s[2]],a.center=n}else if(m){const n=Q(xe,m),s=new t.Coordinate(n),c=this.et(s,Ee).toArray(),h=this.ue(s);c.push(n[2]*h[2]);const f=m.slice(3);r.exactEquals(e.matrix,Ue)||i.multiply(f,i.fromMat4(Re,e.matrix),f);for(let t=0;t<f.length;t++)f[t]*=h[t%3],m[3+t]=f[t];a=this.jt[o]=[...c,...f],a.center=s}}if(n){if(d)Ae.xmin=a[0][0],Ae.ymin=a[0][1],Ae.xmax=a[1][0],Ae.ymax=a[1][1];else if(u){const t=a[2];Ae.xmin=a[0][0]-t,Ae.ymin=a[0][1]-t,Ae.xmax=a[0][0]+t,Ae.ymax=a[0][1]+t}else if(m){const t=a[1],e=a[2];Ae.xmin=a[0][0]-t,Ae.ymin=a[0][1]-e,Ae.xmax=a[0][0]+t,Ae.ymax=a[0][1]+e}if(!n.intersects(Ae))return!1}return d?h(s,a):u?f(s,a):!!m&&l(s,a)}ue(t){const e=this.getMap(),n=e.distanceToPointAtRes(100,100,e.getGLRes(),t);return s.set(Ne,n.x/100*1.01,n.y/100*1.01,n.y/100),Ne}ae(e){Array.isArray(e)&&(e=new t.Coordinate(e));let n=this.options.offset;if(_(n)&&(n=n(Array.isArray(e)?new t.Coordinate(e):e)),n[0]||n[1]){const t=this.getMap(),r=t.getGLRes(),s=t.coordToPointAtRes(e,r);return s._sub(n),t.pointAtResToCoord(s,r)}return e}Jt(e){const n=this.options.services[e].maxExtent;if(!n)return null;const r=this.$t[e];return r.maxExtent||(r.maxExtent=new t.Extent(n).convertTo((t=>this.et(t)))),r.maxExtent}fe(t){const e=this.Qt,n=t.geometricError;if(0===n)return 0;const r=this.getMap();let s;if(t.boundingVolume.region){const e=this.jt[t.id].center,n=(r.getGLZoom?r.distanceToPoint(100,0,r.getGLZoom(),e):r.distanceToPointAtRes(100,0,r.getGLRes(),e)).x/100;s=function(t,e,n,r){const s=t.boundingVolume.region;let i=t.de;i||(i=t.de=[Ve(s[0],s[1]),Ve(s[0],s[3]),Ve(s[2],s[1]),Ve(s[2],s[3]),Ve(s[0],s[1]),Ve(s[0],s[3]),Ve(s[2],s[1]),Ve(s[2],s[3])],t.me=[Math.min.apply(Math,i.map((t=>t[0]))),Math.min.apply(Math,i.map((t=>t[1])))],t.be=[Math.max.apply(Math,i.map((t=>t[0]))),Math.max.apply(Math,i.map((t=>t[1])))]);if(n[0]>=s[0]&&n[0]<=s[2]&&n[1]>=s[1]&&n[1]<=s[3])return n[2]<=s[5]?0:n[2]-s[5];const o=(a=t.me,c=t.be,h=e,f=Math.max(a[0]-h[0],0,h[0]-c[0]),l=Math.max(a[1]-h[1],0,h[1]-c[1]),Math.sqrt(f*f+l*l)/r);var a,c,h,f,l;let u=0;n[2]>s[5]&&(u=n[2]-s[5]);return Math.sqrt(o*o+u*u)}(t,this.Wt,this.Yt,n)}else t.boundingVolume.sphere?s=Ce(t.boundingVolume,this.Kt):t.boundingVolume.box&&(s=De(t.boundingVolume,this.Kt));const i=Math.max(Math.abs(s),1e-7),o=n*r.height/(i*e);return t.X=s,t.le=o,o}Zt(){const t=this.getRenderer();t&&t.setToRedraw()}lt(t){return this.jt[t]}}function Ce(t,e){const n=t.sphere,r=s.dist(n,e),i=t.sphere[3];return r<i?0:r-i}function De(t,e){const n=t.box;return ye(s.set(xe,n[0],n[1],n[2]),i.set(Re,n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]),e)}function Ve(t,e){return ve.x=O(t),ve.y=O(e),Oe.project(ve,Le).toArray()}Pe.mergeOptions({"maxGPUMemory":512,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":0,"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"debug":!1,"debugOutline":[0,1,0],"meshLimitPerFrame":1,"antialias":!1,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"],"offset":[0,0]}),Pe.registerRenderer("gl",de);const Fe=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")},He=Fe(),ke=He.gl_trans__coders=He.gl_trans__coders||{};ke.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=He.gl_trans__coders=He.gl_trans__coders||{};let i=`${r}\n const _____getGlobal = ${Fe.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},ke.registerTranscoder=function(t,e){ke[t]=e},ke.getTranscoder=function(t){return ke[t]};class Ge{constructor(t,e,n){this.ye=t,this.pe=e||u,this.Vt=n,this.ge={"image/crn":ke.crn&&ke.crn(),"image/ktx2":ke.ktx2&&ke.ktx2(),"image/cttf":ke.ktx2&&ke.ktx2(),"draco":ke.draco&&ke.draco()}}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.Te(t,e,n,r)):d.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Te(t,s,n,r)}))}Te(t,e,n,r){const s=this._e(e,n,r,t);if(s.error)return Promise.resolve(s);const i=t.substring(0,t.lastIndexOf("/")),o=new this.pe(i,s.glb,{transferable:!0,requestImage:this.ye,decoders:this.ge,supportedFormats:this.Vt});return o.load().then((e=>{e.url=`${t}-${n}-${r}`;const i=o.transferables;for(let t=0;t<s.transferables.length;t++)i.indexOf(s.transferables[t])<0&&i.push(s.transferables[t]);return{magic:"b3dm",count:s.count,transferables:i,featureTable:s.featureTable,batchTable:s.batchTable,batchTableBin:s.batchTableBin,gltf:e}}))}_e(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),f=s.getUint32(24,!0),l=28+e;h>=570425344?(l-=8,o=a,h=c,f=0,a=0,c=0):f>=570425344&&(l-=4,o=h,h=a,f=c,a=0,c=0);const u=[t];let d,m,b;if(a>0?(d=ot(t,l,a),l+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(l+=c),h>0&&(m=at(t,l,h),l+=h,f>0)){const e=ct(0,l,f);b=t.slice(e.offset,e.offset+e.byteLength),l+=f,u.push(b)}const y=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=ft(d.BATCH_ID,t,undefined.offset,y);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&u.indexOf(e)<0&&u.push(e)}return{count:o,transferables:u,featureTable:d,batchTable:m,batchTableBin:b,b3dm:p,glb:{buffer:t,byteOffset:l,byteLength:s.byteLength+s.byteOffset-l}}}we(){return null}}class ze{constructor(t,e,n){this.ye=t,this.pe=e||u,this.Vt=n,this.ge={"image/crn":ke.crn&&ke.crn(),"image/ktx2":ke.ktx2&&ke.ktx2(),"image/cttf":ke.ktx2&&ke.ktx2(),"draco":ke.draco&&ke.draco()}}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.Te(t,e,n,r)):d.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Te(t,s,n,r)}))}Te(t,e,n,r){return this.Oe(t,e,n,r).then((({gltf:s,transferables:i})=>{const o=this.Ae(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})}))}Oe(t,e,n,r){const s={transferable:!0,requestImage:this.ye,decoders:this.ge,supportedFormats:this.Vt},i=new DataView(e,n,r),o=32+i.getUint32(12,!0)+i.getUint32(16,!0)+i.getUint32(20,!0)+i.getUint32(24,!0);if(0===i.getUint32(28,!0)){let r=S(new Uint8Array(e,o+n,i.byteLength-o));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?d.getArrayBuffer(r,{}).then((t=>this.Ie(r,{buffer:t.data,byteOffset:0},s))):d.getJSON(r,{}).then((t=>this.Ie(r,t,s)))}{const r={buffer:e,byteOffset:o+n,byteLength:i.byteLength-o};return this.Ie(t,r,s)}}Ie(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.pe(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}}))}Ae(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:f}=bt(s,32+e,o),l={},u=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:new Float32Array(t,e+c.offset,3*u).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:u,componentType:5126,array:this.xe(new Uint16Array(t,r+c.offset,3*u),e,n)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=ft(a.BATCH_ID,t,c.offset,u);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:u,componentType:5126,array:new Float32Array(t,e+c.offset,3*u).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:new Float32Array(t,e+c.offset,3*u).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:u,componentType:5126,array:this.Se(new Uint16Array(t,e+c.offset,2*u))},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:this.Se(new Uint16Array(t,e+c.offset,2*u))},o.push(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:u,componentType:5126,array:new Float32Array(t,e+c.offset,u).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:u,componentType:5126,array:new Float32Array(t,e+c.offset,3*u).slice()},o.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:u,batchTable:h,batchTableBin:f,featureTable:a,i3dm:l,transferables:o}}Se(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)qe(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}xe(t,e,n){return mt(new Float32Array(t.length),t,e,n)}we(){return null}}function qe(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]))*$e(e),t[1]=(1-Math.abs(e))*$e(t[1])}return m.normalize(t,t)}function je(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 $e(t){return t<0?-1:1}class Xe{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.Te(t,e,n,r)):d.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Te(t,s,n,r)}))}Te(t,e,n,r){return this.Ne(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}))}Ne(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:f}=bt(s,e+28,o),l=a.QUANTIZED_VOLUME_OFFSET,u=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,b={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){b=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,b.byteOffset+c.offset,b.byteLength);const e={attributes:b.properties,useUniqueIDs:!1};return this.Me||(this.Me=ke.draco()),this.Me(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.Ee(t,e.attributes,c.offset,d,o,l,u);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:dt(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?r.BATCH_ID=ft(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Ze(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:h,batchTableBin:f,featureTable:a,pnts:r,transferables:o}}))}const y=this.Ee(t,a,c.offset,d,o,l,u);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?y.BATCH_ID=ft(a.BATCH_ID,t,c.offset,d):y.BATCH_ID=Ze(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:f,featureTable:a,pnts:y,transferables:o})}Ee(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,array:h}=e.POSITION_QUANTIZED;c=c||0;const f=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.xe(h||new Uint16Array(t,c+f,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}xe(t,e,n){return mt(new Float32Array(t.length),t,e,n)}we(){return null}}function Ze(t){const e=E(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:dt(e),array:n}}class Ye{constructor(t,e){this.ye=t,this.pe=e||u}load(t,e,n=0,r=0){return e?this.Te(t,e,n,r):d.getArrayBuffer(t,{}).then((e=>{const s=e.data;return this.Te(t,s,n,r)}))}Te(t,e,n,r){r||(r=e.byteLength);const s=this.ve(e,t,n,r),i=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new Ge(this.ye,this.pe);else if("i3dm"===s[n].magic)r=new ze(this.ye,this.pe);else if("pnts"===s[n].magic)r=new Xe;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new Ye(this.ye,this.pe)}i.push(r.load(t,e,s[n].offset,s[n].byteLength).then((t=>t)))}return Promise.all(i).then((t=>({magic:"cmpt",tiles:t})))}ve(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=st(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(e.transcoders){const n=t.Map.VERSION;if(n.indexOf("1.0.0-beta")>=0||n.indexOf("1.0.0-alpha")>=0){const n=e.transcoders.inject(p);t.registerWorkerAdapter("@maptalks/3dtiles",n)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(p)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",p);export{Ge as B3DMLoader,Ye as CMPTLoader,Pe as Geo3DTilesLayer,R as Geo3DTilesUtil,rt as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.13.1");
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@maptalks/3dtiles",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "3d tiles layer for maptalks",
5
5
  "main": "dist/maptalks.3dtiles.js",
6
- "module": "dist/maptalks.3dtiles.es.js",
6
+ "browser": "dist/maptalks.3dtiles.js",
7
+ "module": "dist/maptalks.3dtiles.mjs",
7
8
  "scripts": {
8
9
  "lint": "eslint src/**/*.js test/**/*.js",
9
- "build": "npm run lint && rollup --environment BUILD:production -c build/rollup.config.js",
10
- "build-dev": "rollup -c build/rollup.config.js",
11
- "dev": "rollup -w -c build/rollup.config.js",
10
+ "build": "npm run lint && rollup --environment BUILD:production -c rollup.config.js",
11
+ "build-dev": "rollup -c rollup.config.js",
12
+ "dev": "rollup -w -c rollup.config.js",
12
13
  "test": "electron-mocha -t 5000 --require-main ./test/ignore-gpu-blacklist.js --renderer ./test/**/*.spec.js",
13
14
  "tdd": "electron-mocha --interactive --renderer ./test/**/*.spec.js",
14
15
  "pretest": "npm run build",
@@ -26,7 +27,9 @@
26
27
  "maps"
27
28
  ],
28
29
  "files": [
29
- "dist/maptalks.3dtiles.js"
30
+ "dist/maptalks.3dtiles.js",
31
+ "dist/maptalks.3dtiles.mjs",
32
+ "dist/maptalks.3dtiles-browser.mjs"
30
33
  ],
31
34
  "author": "fuzhenn",
32
35
  "license": "UNLICENSED",
@@ -43,12 +46,13 @@
43
46
  "@babel/core": "^7.15.0",
44
47
  "@babel/eslint-parser": "^7.15.0",
45
48
  "@babel/preset-env": "^7.15.0",
46
- "@maptalks/gl": "<2.0.0",
47
- "@maptalks/transcoders.crn": "^0.65.0",
48
- "@maptalks/transcoders.draco": "^0.60.0",
49
- "@maptalks/transcoders.ktx2": "^0.65.0",
49
+ "@maptalks/gl": "^0.67.5",
50
+ "@maptalks/transcoders.crn": "^0.67.5",
51
+ "@maptalks/transcoders.draco": "^0.67.5",
52
+ "@maptalks/transcoders.ktx2": "^0.67.5",
50
53
  "@rollup/plugin-commonjs": "^20.0.0",
51
54
  "@rollup/plugin-node-resolve": "^13.0.4",
55
+ "@rollup/plugin-replace": "4.0.0",
52
56
  "electron": "^4.2.12",
53
57
  "electron-mocha": "^6.0.4",
54
58
  "eslint": "^7.32.0",
@@ -57,6 +61,6 @@
57
61
  "maptalks": "^1.0.0-beta.6",
58
62
  "pixelmatch": "^4.0.2",
59
63
  "rollup": "^2.56.2",
60
- "rollup-plugin-terser": "^5.3.1"
64
+ "rollup-plugin-terser": "^7.0.2"
61
65
  }
62
66
  }