@maptalks/3dtiles 0.123.0 → 0.124.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/maptalks.3dtiles.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/3dtiles v0.
|
|
2
|
+
* @maptalks/3dtiles v0.124.0
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
4
|
* (c) 2016-2026 maptalks.org
|
|
5
5
|
*/
|
|
6
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks"),require("@maptalks/gl")):"function"==typeof define&&define.amd?define(["exports","maptalks","@maptalks/gl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).maptalks=t.maptalks||{},t.maptalks,t.maptalks)}(this,(function(t,e,n){"use strict";function r(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var i=r(e),s=r(n);const o="${",a=`function(t){\n/*!\n * @maptalks/gl v0.123.0\n * LICENSE : UNLICENSED\n * (c) 2016-2026 maptalks.com\n */\nconst e=function(){if("undefined"!=typeof undefinedThis)return globalThis;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")},n=e(),r=n.gl_trans__coders=n.gl_trans__coders||{};function a(){return e().maptalks_gltf_loader}r.inject=function(t){const r=t.toString(),a=r.indexOf("{")+1,o=r.substring(0,a),i=n.gl_trans__coders=n.gl_trans__coders||{};let s=\`${o}o}\\n const _____getGlobal = ${o}e.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};\`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\\n;");return s+="\\n("+e().maptalks_gltf_loader_bundle.toString()+")({});\\n",s+="\\n"+r.substring(o.length),s},r.registerTranscoder=function(t,e){r[t]=e},r.getTranscoder=function(t){return r[t]};var o="undefined"!=typeof Float32Array?Float32Array:Array;function i(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],a=e[1],o=e[2],i=e[3],s=e[4],c=e[5],u=e[6],l=e[7],f=e[8],h=e[9],y=e[10],d=e[11],b=e[12],m=e[13],p=e[14],g=e[15],v=n[0],w=n[1],M=n[2],T=n[3];return t[0]=v*r+w*s+M*f+T*b,t[1]=v*a+w*c+M*h+T*m,t[2]=v*o+w*u+M*y+T*p,t[3]=v*i+w*l+M*d+T*g,v=n[4],w=n[5],M=n[6],T=n[7],t[4]=v*r+w*s+M*f+T*b,t[5]=v*a+w*c+M*h+T*m,t[6]=v*o+w*u+M*y+T*p,t[7]=v*i+w*l+M*d+T*g,v=n[8],w=n[9],M=n[10],T=n[11],t[8]=v*r+w*s+M*f+T*b,t[9]=v*a+w*c+M*h+T*m,t[10]=v*o+w*u+M*y+T*p,t[11]=v*i+w*l+M*d+T*g,v=n[12],w=n[13],M=n[14],T=n[15],t[12]=v*r+w*s+M*f+T*b,t[13]=v*a+w*c+M*h+T*m,t[14]=v*o+w*u+M*y+T*p,t[15]=v*i+w*l+M*d+T*g,t}function c(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function u(){var t=new o(3);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function l(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function f(t,e,n){var r=new o(3);return r[0]=t,r[1]=e,r[2]=n,r}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function y(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function d(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function b(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function m(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function p(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[3]*r+n[7]*a+n[11]*o+n[15];return i=i||1,t[0]=(n[0]*r+n[4]*a+n[8]*o+n[12])/i,t[1]=(n[1]*r+n[5]*a+n[9]*o+n[13])/i,t[2]=(n[2]*r+n[6]*a+n[10]*o+n[14])/i,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var g=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},v=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},w=l;function M(){var t=new o(4);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}u(),function(){var t,e=(t=new o(4),o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var T;function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}u(),f(1,0,0),f(0,1,0),M(),M(),T=new o(9),o!=Float32Array&&(T[1]=0,T[2]=0,T[3]=0,T[5]=0,T[6]=0,T[7]=0),T[0]=1,T[4]=1,T[8]=1;var k={exports:{}},_={exports:{}},O=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},S=Array.prototype.concat,x=Array.prototype.slice,F=_.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var a=t[n];O(a)?e=S.call(e,x.call(a)):e.push(a)}return e};F.wrap=function(t){return function(){return t(F(arguments))}};var I=_.exports,C={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},E=I,U=Object.hasOwnProperty,N=Object.create(null);for(var z in C)U.call(C,z)&&(N[C[z]]=z);var L=k.exports={to:{},get:{}};function j(t,e,n){return Math.min(Math.max(e,t),n)}function D(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}L.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=L.get.hsl(t),n="hsl";break;case"hwb":e=L.get.hwb(t),n="hwb";break;default:e=L.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},L.get.rgb=function(t){if(!t)return null;var e,n,r,a=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;a[n]=parseInt(e.slice(o,o+2),16)}r&&(a[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)a[n]=parseInt(e[n]+e[n],16);r&&(a[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)a[n]=parseInt(e[n+1],0);e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:U.call(C,e[1])?((a=C[e[1]])[3]=1,a):null:null;for(n=0;n<3;n++)a[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}for(n=0;n<3;n++)a[n]=j(a[n],0,255);return a[3]=j(a[3],0,1),a},L.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},L.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},L.to.hex=function(){var t=E(arguments);return"#"+D(t[0])+D(t[1])+D(t[2])+(t[3]<1?D(Math.round(255*t[3])):"")},L.to.rgb=function(){var t=E(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},L.to.rgb.percent=function(){var t=E(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},L.to.hsl=function(){var t=E(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},L.to.hwb=function(){var t=E(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},L.to.keyword=function(t){return N[t.slice(0,3)]};var P=k.exports,B={exports:{}},q={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},R={};for(var V in q)q.hasOwnProperty(V)&&(R[q[V]]=V);var G=B.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var $ in G)if(G.hasOwnProperty($)){if(!("channels"in G[$]))throw new Error("missing channels property: "+$);if(!("labels"in G[$]))throw new Error("missing channel labels property: "+$);if(G[$].labels.length!==G[$].channels)throw new Error("channel and label counts mismatch: "+$);var X=G[$].channels,H=G[$].labels;delete G[$].channels,delete G[$].labels,Object.defineProperty(G[$],"channels",{value:X}),Object.defineProperty(G[$],"labels",{value:H})}G.rgb.hsl=function(t){var e,n,r=t[0]/255,a=t[1]/255,o=t[2]/255,i=Math.min(r,a,o),s=Math.max(r,a,o),c=s-i;return s===i?e=0:r===s?e=(a-o)/c:a===s?e=2+(o-r)/c:o===s&&(e=4+(r-a)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(i+s)/2,[e,100*(s===i?0:n<=.5?c/(s+i):c/(2-s-i)),100*n]},G.rgb.hsv=function(t){var e,n,r,a,o,i=t[0]/255,s=t[1]/255,c=t[2]/255,u=Math.max(i,s,c),l=u-Math.min(i,s,c),f=function(t){return(u-t)/6/l+.5};return 0===l?a=o=0:(o=l/u,e=f(i),n=f(s),r=f(c),i===u?a=r-n:s===u?a=1/3+e-r:c===u&&(a=2/3+n-e),a<0?a+=1:a>1&&(a-=1)),[360*a,100*o,100*u]},G.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[G.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},G.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-a)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-a-e)/(1-e)||0),100*e]},G.rgb.keyword=function(t){var e=R[t];if(e)return e;var n,r,a,o=1/0;for(var i in q)if(q.hasOwnProperty(i)){var s=q[i],c=(r=t,a=s,Math.pow(r[0]-a[0],2)+Math.pow(r[1]-a[1],2)+Math.pow(r[2]-a[2],2));c<o&&(o=c,n=i)}return n},G.keyword.rgb=function(t){return q[t]},G.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},G.rgb.lab=function(t){var e=G.rgb.xyz(t),n=e[0],r=e[1],a=e[2];return r/=100,a/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},G.hsl.rgb=function(t){var e,n,r,a,o,i=t[0]/360,s=t[1]/100,c=t[2]/100;if(0===s)return[o=255*c,o,o];e=2*c-(n=c<.5?c*(1+s):c+s-c*s),a=[0,0,0];for(var u=0;u<3;u++)(r=i+1/3*-(u-1))<0&&r++,r>1&&r--,o=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,a[u]=255*o;return a},G.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,a=n,o=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,a*=o<=1?o:2-o,[e,100*(0===r?2*a/(o+a):2*n/(r+n)),100*((r+n)/2)]},G.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,a=Math.floor(e)%6,o=e-Math.floor(e),i=255*r*(1-n),s=255*r*(1-n*o),c=255*r*(1-n*(1-o));switch(r*=255,a){case 0:return[r,c,i];case 1:return[s,r,i];case 2:return[i,r,c];case 3:return[i,s,r];case 4:return[c,i,r];case 5:return[r,i,s]}},G.hsv.hsl=function(t){var e,n,r,a=t[0],o=t[1]/100,i=t[2]/100,s=Math.max(i,.01);return r=(2-o)*i,n=o*s,[a,100*(n=(n/=(e=(2-o)*s)<=1?e:2-e)||0),100*(r/=2)]},G.hwb.rgb=function(t){var e,n,r,a,o,i,s,c=t[0]/360,u=t[1]/100,l=t[2]/100,f=u+l;switch(f>1&&(u/=f,l/=f),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),a=u+r*((n=1-l)-u),e){default:case 6:case 0:o=n,i=a,s=u;break;case 1:o=a,i=n,s=u;break;case 2:o=u,i=n,s=a;break;case 3:o=u,i=a,s=n;break;case 4:o=a,i=u,s=n;break;case 5:o=n,i=u,s=a}return[255*o,255*i,255*s]},G.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,a=t[3]/100;return[255*(1-Math.min(1,e*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,r*(1-a)+a))]},G.xyz.rgb=function(t){var e,n,r,a=t[0]/100,o=t[1]/100,i=t[2]/100;return n=-.9689*a+1.8758*o+.0415*i,r=.0557*a+-.204*o+1.057*i,e=(e=3.2406*a+-1.5372*o+-.4986*i)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},G.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},G.lab.xyz=function(t){var e,n,r,a=t[0];e=t[1]/500+(n=(a+16)/116),r=n-t[2]/200;var o=Math.pow(n,3),i=Math.pow(e,3),s=Math.pow(r,3);return n=o>.008856?o:(n-16/116)/7.787,e=i>.008856?i:(e-16/116)/7.787,r=s>.008856?s:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},G.lab.lch=function(t){var e,n=t[0],r=t[1],a=t[2];return(e=360*Math.atan2(a,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+a*a),e]},G.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},G.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],a=1 in arguments?arguments[1]:G.rgb.hsv(t)[2];if(0===(a=Math.round(a/50)))return 30;var o=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===a&&(o+=60),o},G.hsv.ansi16=function(t){return G.rgb.ansi16(G.hsv.rgb(t),t[2])},G.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},G.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},G.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},G.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},G.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},G.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255,o=Math.max(Math.max(n,r),a),i=Math.min(Math.min(n,r),a),s=o-i;return e=s<=0?0:o===n?(r-a)/s%6:o===r?2+(a-n)/s:4+(n-r)/s+4,e/=6,[360*(e%=1),100*s,100*(s<1?i/(1-s):0)]},G.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,a=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(a=(n-.5*r)/(1-r)),[t[0],100*r,100*a]},G.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},G.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var a,o=[0,0,0],i=e%1*6,s=i%1,c=1-s;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=c,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=c,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=c}return a=(1-n)*r,[255*(n*o[0]+a),255*(n*o[1]+a),255*(n*o[2]+a)]},G.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},G.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},G.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},G.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},G.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},G.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},G.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},G.gray.hsl=G.gray.hsv=function(t){return[0,0,t[0]]},G.gray.hwb=function(t){return[0,100,t[0]]},G.gray.cmyk=function(t){return[0,0,0,t[0]]},G.gray.lab=function(t){return[t[0],0,0]},G.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},G.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var J=B.exports,Y=J;function K(t){var e=function(){for(var t={},e=Object.keys(Y),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),a=Object.keys(Y[r]),o=a.length,i=0;i<o;i++){var s=a[i],c=e[s];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(s))}return e}function Q(t,e){return function(n){return e(t(n))}}function Z(t,e){for(var n=[e[t].parent,t],r=Y[e[t].parent][t],a=e[t].parent;e[a].parent;)n.unshift(e[a].parent),r=Q(Y[e[a].parent][a],r),a=e[a].parent;return r.conversion=n,r}var W=J,tt=function(t){for(var e=K(t),n={},r=Object.keys(e),a=r.length,o=0;o<a;o++){var i=r[o];null!==e[i].parent&&(n[i]=Z(i,e))}return n},et={};Object.keys(W).forEach((function(t){et[t]={},Object.defineProperty(et[t],"channels",{value:W[t].channels}),Object.defineProperty(et[t],"labels",{value:W[t].labels});var e=tt(t);Object.keys(e).forEach((function(n){var r=e[n];et[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,a=0;a<r;a++)n[a]=Math.round(n[a]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),et[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var nt=P,rt=et,at=[].slice,ot=["keyword","gray","hex"],it={};Object.keys(rt).forEach((function(t){it[at.call(rt[t].labels).sort().join("")]=t}));var st={};function ct(t,e){if(!(this instanceof ct))return new ct(t,e);if(e&&e in ot&&(e=null),e&&!(e in rt))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ct)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var a=nt.get(t);if(null===a)throw new Error("Unable to parse color from string: "+t);this.model=a.model,r=rt[this.model].channels,this.color=a.value.slice(0,r),this.valpha="number"==typeof a.value[r]?a.value[r]:1}else if(t.length){this.model=e||"rgb",r=rt[this.model].channels;var o=at.call(t,0,r);this.color=ft(o,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var i=Object.keys(t);"alpha"in t&&(i.splice(i.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var s=i.sort().join("");if(!(s in it))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=it[s];var c=rt[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=ft(u)}if(st[this.model])for(r=rt[this.model].channels,n=0;n<r;n++){var l=st[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ut(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(st[t]||(st[t]=[]))[e]=n})),t=t[0],function(r){var a;return arguments.length?(n&&(r=n(r)),(a=this[t]()).color[e]=r,a):(a=this[t]().color[e],n&&(a=n(a)),a)}}function lt(t){return function(e){return Math.max(0,Math.min(t,e))}}function ft(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function ht(t){return null==t}function yt(t){return"object"==typeof t&&!!t}function dt(t){return t/Math.PI*180}ct.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in nt.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return nt.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return nt.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=rt[this.model].channels,n=rt[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ct(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ct(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ut("rgb",0,lt(255)),green:ut("rgb",1,lt(255)),blue:ut("rgb",2,lt(255)),hue:ut(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ut("hsl",1,lt(100)),lightness:ut("hsl",2,lt(100)),saturationv:ut("hsv",1,lt(100)),value:ut("hsv",2,lt(100)),chroma:ut("hcg",1,lt(100)),gray:ut("hcg",2,lt(100)),white:ut("hwb",1,lt(100)),wblack:ut("hwb",2,lt(100)),cyan:ut("cmyk",0,lt(100)),magenta:ut("cmyk",1,lt(100)),yellow:ut("cmyk",2,lt(100)),black:ut("cmyk",3,lt(100)),x:ut("xyz",0,lt(100)),y:ut("xyz",1,lt(100)),z:ut("xyz",2,lt(100)),l:ut("lab",0,lt(100)),a:ut("lab",1),b:ut("lab",2),keyword:function(t){return arguments.length?new ct(t):rt[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ct(t):nt.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ct.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),a=void 0===e?.5:e,o=2*a-1,i=n.alpha()-r.alpha(),s=((o*i==-1?o:(o+i)/(1+o*i))+1)/2,c=1-s;return ct.rgb(s*n.red()+c*r.red(),s*n.green()+c*r.green(),s*n.blue()+c*r.blue(),n.alpha()*a+r.alpha()*(1-a))}},Object.keys(rt).forEach((function(t){if(-1===ot.indexOf(t)){var e=rt[t].channels;ct.prototype[t]=function(){if(this.model===t)return new ct(this);if(arguments.length)return new ct(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ct((n=rt[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ct[t]=function(n){return"number"==typeof n&&(n=ft(at.call(arguments),e)),new ct(n,t)}}}));const bt=[1,1,1,1,2,2,3,0];function mt(t){const e=t.length;let n="";for(let r=0;r<e;){let a=t[r++];if(128&a){let n=bt[a>>3&7];if(!(64&a)||!n||r+n>e)return null;for(a&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;a=a<<6|63&e}}n+=String.fromCharCode(a)}return n}new Array(3),new Array(3);const pt=[1/6378137,1/6378137,1/6356752.314245179],gt=[1/40680631590769,1/40680631590769,1/40408299984661.445],vt=new Array(3),wt=new Array(3),Mt=new Array(3);function Tt(t,e){const n=gt,r=function(t,e,n,r,a){const o=e[0],i=e[1],s=e[2],c=n[0],u=n[1],l=n[2],f=o*o*c*c,h=i*i*u*u,y=s*s*l*l,d=f+h+y,b=Math.sqrt(1/d),m=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(At,e,b);if(d<a)return isFinite(b)?m:void 0;const p=r[0],g=r[1],v=r[2],w=kt;w[0]=m[0]*p*2,w[1]=m[1]*g*2,w[2]=m[2]*v*2;let M,T,A,k,_,O,S,x,F,I,C,E=(1-b)*Ot(e)/(.5*Ot(w)),U=0;do{E-=U,A=1/(1+E*p),k=1/(1+E*g),_=1/(1+E*v),O=A*A,S=k*k,x=_*_,F=O*A,I=S*k,C=x*_,M=f*O+h*S+y*x-1,T=f*F*p+h*I*g+y*C*v;U=M/(-2*T)}while(Math.abs(M)>_t);return t[0]=o*A,t[1]=i*k,t[2]=s*_,t}(vt,e,pt,n,.1);let a=v(wt,r,n);a=function(t,e){const n=e[0],r=e[1],a=e[2];let o=n*n+r*r+a*a;o>0&&(o=Math.sqrt(o),t[0]=e[0]/o,t[1]=e[1]/o,t[2]=e[2]/o);return t}(a,a);const o=g(Mt,e,r),i=Math.atan2(a[1],a[0]),s=Math.asin(a[2]),c=(u=m(o,e),(Math.sign?Math.sign(u):0==(u=+u)||isNaN(u)?Number(u):u>0?1:-1)*Ot(o));var u;return t[0]=dt(i),t[1]=dt(s),t[2]=c,t}const At=new Array(3),kt=new Array(3),_t=1e-12;function Ot(t){return l(t)}function St(t,e){let n="";for(let r=0;r<4;r++){const a=t.getUint8(e+r);n+=String.fromCharCode(a)}return n}const xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ft(t,e,n){const r=new Uint8Array(t,e,n);return xt?JSON.parse(xt.decode(r)):JSON.parse(mt(r))}function It(t,e,n){const r=new Uint8Array(t,e,n);return xt?JSON.parse(xt.decode(r)):JSON.parse(mt(r))}function Ct(t,e,n){return{offset:e,byteLength:n}}function Et(t,e,n,r){const{byteOffset:a,componentType:o,type:i}=t,{ctor:s,type:c}=function(t){return zt[t]}(o||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Nt[t]}(i);return{byteStride:0,byteOffset:a+n,itemSize:u,count:r*u,componentType:c,array:new s(e,n+a,r*u)}}function Ut(t,e,n,r){const a=Et(t,e,n,r);return a.array.buffer.byteLength!==e.byteLength&&(a.array=a.array.slice()),a}const Nt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const zt={"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 Lt(t){for(const e in zt)if(t===zt[e].ctor)return zt[e].type;throw new Error("unrecognized ctor:"+t)}function jt(t,e,n,r){const a=t,o=e.length/3;for(let t=0;t<o;t++)a[3*t]=e[3*t]/65535*r[0]+n[0],a[3*t+1]=e[3*t+1]/65535*r[1]+n[1],a[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return a}function Dt(t,e,n){const r=t.getUint32(12,!0),a=t.getUint32(16,!0),o=t.getUint32(20,!0),i=t.getUint32(24,!0),s=t.buffer;let c,u={},l={},f=null;r>0&&(u=Ft(s,e,r),e+=r),a>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,a),e+=a),o>0&&(l=It(s,e,o),e+=o);const h=Ct(0,e,i);return f=s.slice(h.offset,h.offset+h.byteLength),n.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}const Pt={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Bt(t){for(const e in Pt)if(t===Pt[e])return+e;throw new Error("unrecognized ctor:"+t)}let qt=null;function Rt(){return qt||(qt={"image/crn":r.crn&&r.crn(),"image/ktx2":r.ktx2&&r.ktx2(),"image/cttf":r.ktx2&&r.ktx2(),"draco":r.draco&&r.draco()}),qt}const{Ajax:Vt,GLTFLoader:Gt}=a();class $t{constructor(t,e,n){this.o=t,this.i=e||Gt,this.u=n,this.h=Rt()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,a){return e?(r||(r=e.byteLength),this.m(t,e,n,r,a)):Vt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r,a){const o=a&&a.maxTextureSize,i=this.p(e,n,r,t);if(i.error)return Promise.resolve(i);const s=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.i(s,i.glb,{transferable:!0,requestImage:this.o,decoders:this.h,supportedFormats:this.u,maxTextureSize:o})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${o}t}-${o}n}-${o}r}\`;const a=c.transferables;for(let t=0;t<i.transferables.length;t++)a.indexOf(i.transferables[t])<0&&a.push(i.transferables[t]);return{magic:"b3dm",count:i.count,transferables:a,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,gltf:e}}))}p(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported b3dm version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let i,s=a.getUint32(12,!0),c=a.getUint32(16,!0),u=a.getUint32(20,!0),l=a.getUint32(24,!0),f=28+e;u>=570425344?(f-=8,i=s,u=c,l=0,s=0,c=0):l>=570425344&&(f-=4,i=u,u=s,l=c,s=0,c=0);const h=[t];let y,d,b;if(s>0?(y=Ft(t,f,s),f+=s,i=y.BATCH_LENGTH):y={"BATCH_LENGTH":i},c>0&&(f+=c),u>0&&(d=It(t,f,u),f+=u,l>0)){const e=Ct(0,f,l);b=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(b)}const m=y.BATCH_LENGTH,p={};if(y&&y.BATCH_ID){p.BATCH_ID=Ut(y.BATCH_ID,t,undefined.offset,m);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:i,transferables:h,featureTable:y,batchTable:d,batchTableBin:b,b3dm:p,glb:{buffer:t,byteOffset:f,byteLength:a.byteLength+a.byteOffset-f}}}v(){return null}}const{Ajax:Xt,GLTFLoader:Ht}=a();class Jt{constructor(t,e,n,r){this.o=t,this.i=e||Ht,this.u=n,this.h=Rt(),this.M=r}load(t,e,n=0,r=0,a){return e?(r||(r=e.byteLength),this.m(t,e,n,r,a)):Xt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r,a){return this.T(t,e,n,r,a).then((({gltf:a,transferables:o})=>{const i=this.A(e,n,r,t);if(i.error)return Promise.resolve(i);for(let t=0;t<o.length;t++)-1===i.transferables.indexOf(o[t])&&i.transferables.push(o[t]);return delete a.transferables,Promise.resolve({magic:"i3dm",count:i.count,transferables:i.transferables,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,i3dm:i.i3dm,gltf:a})}))}T(t,e,n,r,a){const o=a&&a.maxTextureSize,i={transferable:!0,requestImage:this.o,decoders:this.h,supportedFormats:this.u,maxTextureSize:o},s=new DataView(e,n,r),c=32+s.getUint32(12,!0)+s.getUint32(16,!0)+s.getUint32(20,!0)+s.getUint32(24,!0);if(0===s.getUint32(28,!0)){let r=mt(new Uint8Array(e,c+n,s.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?Xt.getArrayBuffer(r,{}).then((t=>this.k(r,{buffer:t.data,byteOffset:0},i))):Xt.getJSON(r,{}).then((t=>this.k(r,t,i)))}{const r={buffer:e,byteOffset:c+n,byteLength:s.byteLength-c};return this.k(t,r,i)}}k(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),a=new this.i(r,e,n);return a.load({skipAttributeTransform:!0}).then((n=>{let r=0,o=0;return e.buffer&&(r=e.byteOffset||0,o=e.byteLength||0),n.url=\`${o}t}-${o}r}-${o}o}\`,{transferables:a.transferables,gltf:n}}))}A(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,32+e,i),f={},h=s.INSTANCES_LENGTH;if(s.POSITION){const{byteOffset:e}=s.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.POSITION.array.buffer)}else if(s.POSITION_QUANTIZED){const e=s.QUANTIZED_VOLUME_OFFSET,n=s.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=s.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this._(new Uint16Array(t,r+c.offset,3*h),e,n)},i.push(f.POSITION.array.buffer)}if(s.BATCH_ID){f.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,h);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}if(s.NORMAL_UP){let{byteOffset:e}=s.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.NORMAL_RIGHT.array.buffer)}else if(s.NORMAL_UP_OCT32P){let{byteOffset:e}=s.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,e+c.offset,2*h))},i.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,e+c.offset,2*h))},i.push(f.NORMAL_RIGHT.array.buffer)}if(s.SCALE){const{byteOffset:e}=s.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},i.push(f.SCALE.array.buffer)}else if(s.SCALE_NON_UNIFORM){const{byteOffset:e}=s.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:l,featureTable:s,i3dm:f,transferables:i}}O(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let a=0;a<e;a++)Yt(r,t[2*a],t[2*a+1],65535),n[3*a]=r[0],n[3*a+1]=r[1],n[3*a+2]=r[2];return n}_(t,e,n){return jt(new Float32Array(t.length),t,e,n)}v(){return null}}function Yt(t,e,n,r){if(t[0]=Kt(e,r),t[1]=Kt(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]))*Qt(e),t[1]=(1-Math.abs(e))*Qt(t[1])}return b(t,t)}function Kt(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 Qt(t){return t<0?-1:1}const{Ajax:Zt}=a();class Wt{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.m(t,e,n,r)):Zt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r){return this.S(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}))}S(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,e+28,i),f=s.QUANTIZED_VOLUME_OFFSET,h=s.QUANTIZED_VOLUME_SCALE,y=s.POINTS_LENGTH;let d,b={};if(s.extensions&&s.extensions["3DTILES_draco_point_compression"]){b=s.extensions["3DTILES_draco_point_compression"],d=new DataView(t,b.byteOffset+c.offset,b.byteLength);const e={attributes:b.properties,useUniqueIDs:!1};return this.F||(this.F=Rt().draco),this.F(d,e).then((e=>{const n=e.attributes;!s.POSITION&&!s.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=s.POSITION,n.POSITION_QUANTIZED=s.POSITION_QUANTIZED),!(s.RGB||s.RGBA||s.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=s.RGB,n.RGBA=s.RGBA,n.RGB565=s.RGB565),!s.NORMAL&&!s.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=s.NORMAL,n.NORMAL_OCT16P=s.NORMAL_OCT16P);const r=this.I(t,e.attributes,c.offset,y,i,f,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Lt(t.constructor),array:t},i.push(t.buffer)}else if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?r.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,y):r.BATCH_ID=te(y);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return{count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:r,transferables:i}}))}const m=this.I(t,s,c.offset,y,i,f,h);if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?m.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,y):m.BATCH_ID=te(y);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return Promise.resolve({count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:m,transferables:i})}I(t,e,n,r,a,o,i){const s={};if(e.POSITION){let{byteOffset:o,array:i}=e.POSITION;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},a.push(i.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const l=u?0:n;s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this._(u||new Uint16Array(t,c+l,3*r),o,i)},a.push(s.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:o,array:i}=e.RGBA;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+4*r);i=new Uint8Array(e)}s.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:i},a.push(i.buffer)}else if(e.RGB){let{byteOffset:o,array:i}=e.RGB;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r);i=new Uint8Array(e)}s.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:i},a.push(i.buffer)}else if(e.RGB565){let{byteOffset:o,array:i}=e.RGB565;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint16Array(e)}s.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:i},a.push(i.buffer)}if(e.NORMAL){let{byteOffset:o,array:i}=e.NORMAL;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}s.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},a.push(i.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:o,array:i}=e.NORMAL_OCT16P;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint8Array(e)}s.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:i},a.push(i.buffer)}return s}_(t,e,n){return jt(new Float32Array(t.length),t,e,n)}v(){return null}}function te(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:Lt(e),array:r}}const{Ajax:ee,GLTFLoader:ne}=a();class re{constructor(t,e,n,r){this.u=n,this.o=t,this.i=e||ne,this.M=r}load(t,e,n=0,r=0,a){return e?this.m(t,e,n,r,a):ee.getArrayBuffer(t,{}).then((e=>{const a=e.data;return this.m(t,a,n,r)}))}m(t,e,n,r,a){r||(r=e.byteLength);const o=this.C(e,t,n,r),i=[];for(let n=0;n<o.length;n++){let r;if("b3dm"===o[n].magic)r=new $t(this.o,this.i,this.u);else if("i3dm"===o[n].magic)r=new Jt(this.o,this.i,this.u,this.M);else if("pnts"===o[n].magic)r=new Wt;else{if("cmpt"!==o[n].magic){console.warn("Unsupported magic in CMPT tile:",o[n].magic);continue}r=new re(this.o,this.i,this.u,this.M)}i.push(r.load(t,e,o[n].offset,o[n].byteLength,a).then((t=>t)))}return Promise.all(i).then((t=>({magic:"cmpt",tiles:t})))}C(t,e,n,r){const a=new DataView(t,n,r),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported cmpt version: "+o+", url:"+e;return console.warn(t),{error:t}}if(16===a.byteLength)return[];const i=[],s=a.getUint32(12,!0);let c=16;for(let e=0;e<s;e++){const e=St(a,c),r=a.getUint32(c+8,!0);i.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return i}}const{GLTFLoader:ae}=a();function oe(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,a=r.length;n<a;n++){const a=[];he(r[n],a,t,e)}}}const ie=[],se=[],ce=[],ue=[0,0,0],le=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),fe=[1,1,1];function he(t,e,n,r){const a=e.slice(0);if(t.matrix)a.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(ie,t.translation||ue),n=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,s=r+r,c=a+a,u=n*i,l=r*i,f=r*s,h=a*i,y=a*s,d=a*c,b=o*i,m=o*s,p=o*c;return t[0]=1-f-d,t[1]=l+p,t[2]=h-m,t[3]=0,t[4]=l-p,t[5]=1-u-d,t[6]=y+b,t[7]=0,t[8]=h+m,t[9]=y-b,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(se,t.rotation||le),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ce,t.scale||fe);s(r,n,r);const o=s([],e,r);a.push(o)}if(t.children&&t.children.length)for(let e=0,o=t.children.length;e<o;e++)he(t.children[e],a,n,r);if(void 0!==t.mesh){const e=t.mesh,o=n.meshes[e];if(o){const t=a.slice(0),i=o.primitives;for(let a=0,o=i.length;a<o;a++){const o=i[a];o&&(o.matrices=t,r(o,e,a,n))}}}}function ye(t,e){let{byteOffset:n,byteStride:r,count:a}=t;const{componentType:o,itemSize:i}=t,s=t.array.buffer,c=o?ae.getTypedArrayCtor(o):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,a=a||t.array.length/i,(!r||r===i*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(s,n,a*i);for(let r=0;r<a*i;r+=i){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,i),r/i)}return}const u=new Uint8Array(i*c.BYTES_PER_ELEMENT);r||(r=i*c.BYTES_PER_ELEMENT);for(let t=0;t<a;t++){const a=new Uint8Array(s,r*t+n,i*c.BYTES_PER_ELEMENT);u.set(a);e(new c(u.buffer),t),a.set(u)}}var de=ge("DXT1"),be=ge("DXT3"),me=ge("DXT5"),pe=ge("DX10");function ge(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var ve=A((function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var a=r[21];switch(a){case de:e=8,n="dxt1";break;case be:e=16,n="dxt3";break;case me:e=16,n="dxt5";break;case 116:n="rgba32f";break;case pe:var o=new Uint32Array(t.slice(128,148));n=o[0];var i=o[1];if(o[2],o[3],o[4],3!==i||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(s=a,String.fromCharCode(255&s,s>>8&255,s>>16&255,s>>24&255)))}var s;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var l=!1;512&r[28]&&(l=!0);var f,h=r[4],y=r[3],d=r[1]+4,b=h,m=y,p=[];a===pe&&(d+=20);if(l)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=b,y=m;for(var v=Math.log(h)/Math.log(2)+1,w=0;w<v;w++)f=h*y*16,p.push({offset:d,length:f,shape:[h,y]}),w<u&&(d+=f),h=Math.floor(h/2),y=Math.floor(y/2)}else for(w=0;w<u;w++)f=Math.max(4,h)/4*Math.max(4,y)/4*e,p.push({offset:d,length:f,shape:[h,y]}),d+=f,h=Math.floor(h/2),y=Math.floor(y/2);return{shape:[b,m],images:p,format:n,flags:c,cubemap:l}})),we=Math.abs,Me=Math.sin,Te=Math.cos,Ae=Math.tan,ke=Math.atan,_e=Math.atan2,Oe=Math.sqrt,Se=Math.log,xe=Math.hypot,Fe=Math.sinh,Ie=Math.cosh,Ce=1/0;function Ee(t){var e,n,r,a,o,i,s=[],c=[],u=[],l=[];function f(t,e){for(var n,r=2*Te(2*e),a=t.length-1,o=t[a],i=0;--a>=0;)n=r*o-i+t[a],i=o,o=n;return e+n*Me(2*e)}function h(t,e,n){for(var r,a,o=Me(e),i=Te(e),s=Fe(n),c=Ie(n),u=2*i*c,l=-2*o*s,f=t.length-1,h=t[f],y=0,d=0,b=0;--f>=0;)r=d,a=y,h=u*(d=h)-r-l*(y=b)+t[f],b=l*d-a+u*y;return[(u=o*c)*h-(l=i*s)*b,u*b+l*h]}t.es,o=a=(r=t.es/(1+Oe(1-t.es)))/(2-r),s[0]=a*(2+a*(-2/3+a*(a*(116/45+a*(26/45+a*(-2854/675)))-2))),c[0]=a*(a*(2/3+a*(4/3+a*(-82/45+a*(32/45+a*(4642/4725)))))-2),o*=a,s[1]=o*(7/3+a*(a*(-227/45+a*(2704/315+a*(2323/945)))-1.6)),c[1]=o*(5/3+a*(-16/15+a*(-13/9+a*(904/315+a*(-1522/945))))),o*=a,s[2]=o*(56/15+a*(-136/35+a*(-1262/105+a*(73814/2835)))),c[2]=o*(-26/15+a*(34/21+a*(1.6+a*(-12686/2835)))),o*=a,s[3]=o*(4279/630+a*(-332/35+a*(-399572/14175))),c[3]=o*(1237/630+a*(a*(-24832/14175)-2.4)),o*=a,s[4]=o*(4174/315+a*(-144838/6237)),c[4]=o*(-734/315+a*(109598/31185)),o*=a,s[5]=o*(601676/22275),c[5]=o*(444337/155925),o=a*a,e=t.k0/(1+a)*(1+o*(1/4+o*(1/64+o/256))),u[0]=a*(a*(2/3+a*(-37/96+a*(1/360+a*(81/512+a*(-96199/604800)))))-.5),l[0]=a*(.5+a*(-2/3+a*(5/16+a*(41/180+a*(-127/288+a*(7891/37800)))))),u[1]=o*(-1/48+a*(-1/15+a*(437/1440+a*(-46/105+a*(1118711/3870720))))),l[1]=o*(13/48+a*(a*(557/1440+a*(281/630+a*(-1983433/1935360)))-.6)),o*=a,u[2]=o*(-17/480+a*(37/840+a*(209/4480+a*(-5569/90720)))),l[2]=o*(61/240+a*(-103/140+a*(15061/26880+a*(167603/181440)))),o*=a,u[3]=o*(-4397/161280+a*(11/504+a*(830251/7257600))),l[3]=o*(49561/161280+a*(-179/168+a*(6601661/7257600))),o*=a,u[4]=o*(-4583/161280+a*(108847/3991680)),l[4]=o*(34729/80640+a*(-3418889/1995840)),o*=a,u[5]=o*(-20648693/638668800),l[5]=.6650675310896665*o,i=f(c,t.phi0),n=-e*(i+function(t,e){var n,r=2*Te(e),a=t.length-1,o=t[a],i=0;for(;--a>=0;)n=r*o-i+t[a],i=o,o=n;return Me(e)*n}(l,2*i)),t.fwd=function(t,r){var a,o,i,s,u,y=t.phi,d=t.lam;y=f(c,y),a=Me(y),o=Te(y),s=Me(d),i=Te(d),y=_e(a,i*o),d=_e(s*o,xe(a,o*i)),d=function(t){var e=we(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*Se(e)/n}(e*(1+e/(xe(1,e)+1))),t<0?-e:e}(Ae(d)),u=h(l,2*y,2*d),y+=u[0],d+=u[1],we(d)<=2.623395162778?(r.y=e*y+n,r.x=e*d):r.x=r.y=Ce},t.inv=function(t,r){var a,o,i,c,l,y=t.y,d=t.x;y=(y-n)/e,we(d/=e)<=2.623395162778?(y+=(l=h(u,2*y,2*d))[0],d+=l[1],d=ke(Fe(d)),a=Me(y),o=Te(y),c=Me(d),i=Te(d),d=_e(c,i*o),y=_e(a*i,xe(c,i*o)),r.phi=f(s,y),r.lam=d):r.phi=r.lam=Ce}}const Ue=Math.PI/180,Ne=6378137*Math.PI/180,ze=85.0511287798,Le={};function je(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=ze,r=e[0],a=Math.max(Math.min(n,e[1]),-n);let o;o=0===a?0:Math.log(Math.tan((90+a)*Ue/2))/Ue;return t[0]=r*Ne,t[1]=o*Ne,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return De(t,e);if("baidu"===n)return De(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const a=JSON.stringify(n);let o=Le[a];return o||(o=Le[a]=function(t){const e={a:Be,es:qe,x0:ht(t.falseEasting)?5e5:t.falseEasting,y0:ht(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*Pe,phi0:(t.latitudeOfOrigin||0)*Pe,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Ee(e);const n={lam:0,phi:0},r={};let a=0,o=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*Pe-e.lam0,n.phi=e.originPhi0*Pe,e.fwd(n,r),a=e.a*r.x+e.x0,o=e.a*r.y+e.y0);return{project:function(t,i){n.lam=t[0]*Pe-e.lam0,n.phi=t[1]*Pe,e.fwd(n,r);const s=e.a*r.x+e.x0-a,c=e.a*r.y+e.y0-o;return i[0]=s,i[1]=c,i}}}(n)),o.project(e,t)}}function De(t,e){return t[0]=e[0],t[1]=e[1],t}const Pe=.017453292519943295,Be=6378137,qe=.0066943799901413165;const{Ajax:Re}=a(),Ve=i([]),Ge=Rt().draco,$e=Rt().ktx2,Xe={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},He={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function Je(t,e,n,r,a,o){const s=[],c=[],u=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],a=Re.getArrayBuffer(n.url,o);a.xhr.url=n.url,u.push(a.xhr);const i=a.then((t=>({buffer:t})));s.push(i);const l=[];if(nn(r,l),l.length){const t=l.map((t=>{const e=Re.getArrayBuffer(t.url,o);return e.xhr.url=t.url,u.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));s.push(...t)}c[e]=l.length}const l=Promise.all(s).then((o=>{for(let t=0;t<o.length;t++)if(!o[t]||!o[t].buffer)return Promise.resolve(null);const s=[];let u=0;for(let t=0;t<c.length;t++){const e=c[t];s.push({geoBuffer:{data:o[u].buffer.data},textureBuffers:o.slice(u+1,e+u+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),u+=1+e}const l=function(t,e,n,r,a,o){const s={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let u=0;u<t.meshes.length;u++){let{material:l}=t.meshes[u];const{geometry:f}=t.meshes[u];let h;const y=e[u].geoBuffer.data;if(!y)continue;h=un(y)?Ke(s,u,f,y,t.transform,t.center,a,o):Ze(s,u,f,y,t.transform,t.center,a,o),c.push(h),s.nodes[u]={mesh:u,nodeIndex:u,matrix:i([])},s.scenes[0].nodes[u]=s.nodes[u],l||(l=Xe);const d=tn(u,s,l,e[u].textureBuffers,n,r);c.push(d)}return Promise.all(c).then((()=>({gltf:s,featureTable:{BATCH_LENGTH:0},transferables:s.transferables})))}(t,s,e,a,n,r);return l}));return l.xhr=u,l}const Ye={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Ke(t,e,n,r,a,o,i,s){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=He[e];if(!r)return t;return t[r.name||e]=n,t}),{});return Ge(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>We(n,t,e,a,o,i,s)))}const Qe={position:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.position={array:a,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.normal={array:a,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,a=new Float32Array(e,n,r);return t.uv0={array:a,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,a=new Uint8Array(e,n,r);return t.color={array:a,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,a=new Uint32Array(e,n,r);return t.faceRange={array:a,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Ze(t,e,n,r,a,o,i,s){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)Qe[n[e]]?t=Qe[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let a=e.ordering,o=e.featureAttributeOrder;const i=null;i&&i.geometryData&&i.geometryData[0]&&i.geometryData[0].params;for(let e=0;e<a.length;e++){const n=Qe[a[e]];n||console.log(a[e]),t=n(c,r,t)}for(let e=0;e<o.length;e++){const n=Qe[o[e]];n||console.log(o[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const l={};for(const t in c){const e=He[t]&&He[t].name;e&&(l[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(f=e)<=255?Uint8Array:f<=65535?Uint16Array:Uint32Array,r=new n(l.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,a=t[e],o=t[e+1];for(let t=a;t<=o;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}l._BATCHID={componentType:Bt(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var f;return We({attributes:l},t,e,a,o,i,s)}function We(t,e,n,r,a,o,i){const s={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const u=function(t,e,n,r,a){let o,i=[0,0,0,1];const s=[0,0],u=je([],n,r,a);u[2]=n[2];const l=e&&c(Ve,e);return ye(t,(t=>(i[0]=t[0],i[1]=t[1],i[2]=t[2],l||(i=p(i,i,e)),n&&d(i,i,n),je(s,i,r,a),o=i[2],t[0]=s[0]-u[0],t[1]=s[1]-u[1],t[2]=o-u[2],t))),u}(t.attributes.POSITION,r,a,o,i);e.meshes[n]={primitives:[s],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:a};for(const n in t.attributes)cn(e.transferables,t.attributes[n].array.buffer);return t.indices&&cn(e.transferables,t.indices.array.buffer),s}function tn(t,e,n,r,a,o){const i=r.map((t=>function(t,e,n,r,a){if("dds"===e){const e=ve(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),a="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Ye,format:a})}if("png"===e||"jpg"===e)return function(t,e){rn||(rn=new OffscreenCanvas(2,2),an=rn.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;on(n)||(n=sn(n)),on(r)||(r=sn(r));const a=e;a&&(n=Math.min(a,n),r=Math.min(a,r)),rn.width=n,rn.height=r,an.drawImage(t,0,0,n,r),t.close();const o=an.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(o.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,a).then((t=>{t.mimeType=n;return{image:t,sampler:Ye,format:6408}}));if("ktx2"===e)return $e(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Ye,format:t.format})));return null}(t.data,t.format,t.mimeType,a,o).then((t=>{if(t.image)if(t.image.array)cn(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)cn(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(i).then((r=>{en(t,e,n,r)}))}function en(t,e,n,r){const a=JSON.parse(JSON.stringify(n)),o=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(o.push(r[r.ptr++]),a[t]={index:o.length-1},void 0!==n[t].factor&&(a[t].scale=n[t].factor)):yt(n[t])&&(a[t]=en(-1,e,n[t],r));return t>=0&&(e.materials[t]=a),a}function nn(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):yt(t[n])&&nn(t[n],e)}let rn,an;function on(t){return!(t&t-1)&&0!==t}function sn(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function cn(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function un(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}var ln="undefined"!=typeof Float32Array?Float32Array:Array;function fn(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var hn=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};!function(){var t=function(){var t=new ln(3);return ln!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const yn=[];const dn=[],bn=[],mn=[],pn=[],gn=[],vn=[],wn=[];function Mn(t,e,n,r,a,o){fn(pn,t[3*e],t[3*e+1],t[3*e+2]),fn(gn,t[3*n],t[3*n+1],t[3*n+2]),fn(vn,t[3*r],t[3*r+1],t[3*r+2]);const i=hn(dn,vn,gn),s=hn(bn,pn,gn),c=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[0],s=n[1],c=n[2];return t[0]=a*c-o*s,t[1]=o*i-r*c,t[2]=r*s-a*i,t}(mn,i,s);!function(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o)}(wn,c),a[3*e]=a[3*e]||0,a[3*n]=a[3*n]||0,a[3*r]=a[3*r]||0,a[3*e+1]=a[3*e+1]||0,a[3*n+1]=a[3*n+1]||0,a[3*r+1]=a[3*r+1]||0,a[3*e+2]=a[3*e+2]||0,a[3*n+2]=a[3*n+2]||0,a[3*r+2]=a[3*r+2]||0,a[3*e]+=wn[0],a[3*n]+=wn[0],a[3*r]+=wn[0],a[3*e+1]+=wn[1],a[3*n+1]+=wn[1],a[3*r+1]+=wn[1],a[3*e+2]+=wn[2],a[3*n+2]+=wn[2],a[3*r+2]+=wn[2],o[e]+=1,o[n]+=1,o[r]+=1}const{Ajax:Tn,GLTFLoader:An}=a(),kn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],_n=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],On=2*Math.PI*6378137/360,Sn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let xn,Fn,In=!1;if("undefined"!=typeof OffscreenCanvas){try{Fn=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}Fn&&"undefined"!=typeof createImageBitmap&&(In=!0)}const Cn=i([]),En=[0,0,0],Un=[],Nn=[],zn=[],Ln=[],jn={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Dn={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Pn;class Bn{constructor(t,e,n,r){this.id=t,this.options=e,this.U=(...t)=>this.requestImage.call(this,...t),this.N=n,this.L={},r(null,{},[])}j(t){this.D||(this.u=t,this.P=new Wt,this.D=new $t(this.U,An,t),this.B=new Jt(this.U,An,t))}requestImage(t,e){In?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{xn.width=t.width,xn.height=t.height,Fn.drawImage(t,0,0);const n=Fn.getImageData(0,0,xn.width,xn.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.N("requestImage",{url:t},null,e)}loadTile(t,e){this.j(t.supportedFormats);const{service:n,url:r,arraybuffer:a}=t,o=n.fetchOptions||{};if(o.referrer=t.referrer,o.referrerPolicy=o.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const a=t.i3sInfo,i=n.maxTextureSize||0,s=Je(a,t.supportedFormats,this.options.projection,t.projection,i,o);return s.then((t=>{if(delete this.L[r],!t)return void e({status:404,url:r,i3sInfo:a});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:a});t.gltf.url=r;const{transferables:o}=t;t.magic="b3dm",n.createNormalIfMissed&&this.q(t.gltf),Yn(n)&&this.R(t.gltf),e(null,t,o)})),void(this.L[r]=s.xhr)}if(a){delete this.L[r];const n=St(new DataView(a),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(Sn){const r=new Uint8Array(t,e,n);return Sn.decode(r)}return mt(new Uint8Array(t,e,n))}(a,0,a.byteLength),o=JSON.parse(n);o.accessors?this.V(o,r,t,"gltf",e):this.G(t.rootIdx,o,a,r,e)}else this.V(a,r,t,n,e)}else{let a=n.urlParams;a&&(a=(r.indexOf("?")>0?"&":"?")+a);const i=r.replace(/\\+/g,"%2B");let s=Tn.getArrayBuffer(i+(a||""),o);const c=s.xhr;s=s.then((n=>{delete this.L[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.L[r],e(t)})),this.L[r]=c}}V(t,e,n,r,a){r=r&&r.toLowerCase();const{service:o}=n;if("b3dm"===r){this.D.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{if(t.error)return void a(t);const{content:e,transferables:r}=this.$(t,n);o.createNormalIfMissed&&this.q(e.gltf),Yn(o)&&this.R(e.gltf),a(null,e,r)})).catch((t=>{a(t)}))}else if("pnts"===r){const r=n.transform||Cn;this.P.load(e,t).then((t=>{const{content:e,transferables:o}=this.X(t,r,n.rootIdx);this.H(e),a(null,e,o)}))}else if("i3dm"===r){const r=n.transform||Cn;this.B.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:i}=this.J(t,r,n.rootIdx);o.createNormalIfMissed&&this.q(e.gltf),Yn(o)&&this.R(e.gltf),a(null,e,i)}))}else if("cmpt"===r){new re(this.U,An,this.u,o.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Y(t,n);this.K(e,o),Yn(o)&&this.Z(e),a(null,e,r)})).catch((t=>{a(t)}))}else if("gltf"===r){this.h||(this.h=Rt());const r=e.substring(0,e.lastIndexOf("/")),i=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t;let s;try{s=new An(r,i,{transferable:!0,requestImage:this.U,decoders:this.h,supportedFormats:this.u,maxTextureSize:o.maxTextureSize||0})}catch(t){a(t)}s.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.W(t,null,n),o.createNormalIfMissed&&this.q(t),Yn(o)&&this.R(t),a(null,{magic:"gltf",gltf:t},s.transferables)}))}else a(new Error("unsupported tile format: "+r))}K(t,e){t.content?t.content.forEach((t=>{this.K(t,e)})):e.createNormalIfMissed&&this.q(t.gltf)}Z(t){t.content?t.content.forEach((t=>{this.Z(t)})):this.R(t.gltf)}tt(t,e){if(this.et(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.nt()?Pn.subarray(0,n):e,a=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const a=yn;a.length<t.length/3&&(a.length=t.length/3),a.fill(0,0,t.length/3);const o=void 0===e.length?e:e.length;for(let n=0;n<o/3;n++)void 0===e.length?Mn(t,3*n,3*n+1,3*n+2,r,a):Mn(t,e[3*n],e[3*n+1],e[3*n+2],r,a);for(let t=0;t<r.length;t+=3){const e=a[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:a,byteLength:a.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:a.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}R(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const t in e){e[t].primitives.forEach((t=>{t.compressed_int16_params={};const e=t.attributes;for(const n in e)if(jn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=On,t.compressed_int16_params.compressed_ratio=r);const a=Xn(e[n].array,r,e[n].min,e[n].max,n);if(!a)continue;const{array:o,range:i}=a;e[n].componentType=5124,e[n].array=o,t.compressed_int16_params[n]=i}}))}}q(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach((e=>{this.tt(e,t)}))}}H(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(jn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=On,t.compressed_int16_params.compressed_ratio=r);const{array:a,range:o}=Xn(e[n].array,r,e[n].min,e[n].max,n);e[n].array=a,t.compressed_int16_params[n]=o}}rt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const a={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(a)}return e}G(t,e,n,r,a){return e.capabilities,void a(null,e)}Y(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},a=[];for(let t=0;t<n.length;t++){const{magic:o}=n[t];if("b3dm"===o){const{content:o,transferables:i}=this.$(n[t],e);Gn(a,i),r.content.push(o)}else if("i3dm"===o){const{transform:o,rootIdx:i}=e,{content:s,transferables:c}=this.J(n[t],o,i);Gn(a,c),r.content.push(s)}else if("pnts"===o){const{transform:o,rootIdx:i}=e,{content:s,transferables:c}=this.X(n[t],o,i);Gn(a,c),r.content.push(s)}else if("cmpt"===o){const{content:o,transferables:i}=this.Y(n[t],e);Gn(a,i),r.content.push(o)}}return{content:r,transferables:a}}$(t,e){const{gltf:n,transferables:r,featureTable:a}=t;return this.W(n,a,e),delete t.transferables,{content:t,transferables:r}}W(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;if(t.extensions&&t.extensions.KHR_techniques_webgl)return!0;const e="visited";let n=1;const r=[];for(const a in t.meshes){const o=t.meshes[a],{primitives:i}=o;if(i)for(let t=0;t<i.length;t++){const a=i[t].attributes&&i[t].attributes.POSITION;if(!a||!a.array)continue;a.array.buffer[e]||(a.array.buffer[e]=n++);const o=n-1+"-"+(a.byteOffset||0);if(r.indexOf(o)>=0)return!0;r.push(o)}}return!1}(t);this.ot(t);n.service.createNormalIfMissed||this.it(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.st(t,e,n.upAxis,n.transform)):this.ct(t,e,n.upAxis,n.transform)}J(t,e,n){const{featureTable:r}=t,a=t.i3dm,o=r&&r.RTC_CENTER||[0,0,0],i=this.options.projection,s=e&&c(Cn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Rn(a.POSITION.array,3,o,Cn,u);const l=Vn(u);e&&!s&&p(l,l,e);const f=this.ut(l),d=[];je(d,f,i),d[2]=f[2];const b=h([],l),m=[0,0,0],g=[0,0,0],v=[0,0],M=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0];ye(a.POSITION,(t=>{m[0]=t[0]+o[0],m[1]=t[1]+o[1],m[2]=t[2]+o[2],e&&!s&&p(m,m,e),0===w(m)?y(g,0,0,-6378137):Tt(g,m),je(v,g,i),t[0]=v[0]-d[0],t[1]=v[1]-d[1],t[2]=g[2]-d[2],t[0]<M[0]&&(M[0]=t[0]),t[1]<M[1]&&(M[1]=t[1]),t[2]<M[2]&&(M[2]=t[2]),t[0]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2])})),a.POSITION.min=M,a.POSITION.max=T,e&&p(l,l,e),t.rtcCenter=b,t.rtcCoord=f,t.projCenter=d,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}X(t,e,n){const{featureTable:r}=t,a=t.pnts,o=r&&r.RTC_CENTER||[0,0,0],i=this.options.projection,s=e&&c(Cn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Rn(a.POSITION.array,3,o,e,u);const l=Vn(u),f=this.lt(l),d=h([],l),b=[1/0,1/0,1/0],m=[-1/0,-1/0,-1/0];let g=[0,0,0,1];const v=[0,0,0],M=[0,0];ye(a.POSITION,(t=>(g[0]=t[0]+o[0],g[1]=t[1]+o[1],g[2]=t[2]+o[2],e&&!s&&(g=p(g,g,e)),0===w(g)?y(v,0,0,-6378137):Tt(v,g),je(M,v,i),t[0]=M[0]-f[0],t[1]=M[1]-f[1],t[2]=v[2]-f[2],t[0]<b[0]&&(b[0]=t[0]),t[1]<b[1]&&(b[1]=t[1]),t[2]<b[2]&&(b[2]=t[2]),t[0]>m[0]&&(m[0]=t[0]),t[1]>m[1]&&(m[1]=t[1]),t[2]>m[2]&&(m[2]=t[2]),t))),a.POSITION.min=b,a.POSITION.max=m,e&&p(l,l,e);const T=this.ut(l);t.rtcCenter=d,t.projCenter=f,t.rtcCoord=T,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}ot(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],a=n[1],o=n[2],i=n[3];let s=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==a||n[t+2]!==o||n[t+3]!==i){s=!1;break}s&&(e[t].image.color=[r/255,a/255,o/255,i/255],delete e[t].image.array)}}}it(t){const e=t.meshes;for(const n in e){const r=e[n];if(!r)continue;const a=r.primitives;if(a)for(let e=0;e<a.length;e++){if(!a[e])continue;if(!a[e].attributes||a[e].attributes.NORMAL)continue;const n=a[e].material;if(!ht(n)){const e=t.materials[n];if(!e)continue;e.extensions||(e.extensions={}),e.extensions.KHR_materials_unlit={}}}}}abortTileLoading(t,e){const n=this.L[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this.L[t.url],e(null)}ft(t,e,n,r){const a=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let o=kn;"X"===(n=n&&n.toUpperCase())?o=_n:"Z"===n&&(o=Cn),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),a&&(t.extensions.CESIUM_RTC.center=a),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};oe(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=i(Un);t.matrices&&$n(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;s(e,o,e),r&&s(e,r,e),Rn(n,u,a||En,e,c,t.compressUniforms)}));const u=Vn(c);return{rtcCenter:a,modelCenter:u,upAxisTransform:o}}st(t,e,n,r){const{modelCenter:a,upAxisTransform:o,rtcCenter:c}=this.ft(t,e,n),u=this.lt(a);t.extensions.MAPTALKS_RTC.projCenter=u,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ut(a);const l=h([],a);r&&p(a,a,r),t.extensions.CESIUM_RTC.rtcCoord=this.ut(a),c||(oe(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=i(Un);t.matrices&&$n(n,t.matrices),s(n,o,n);const r=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],s=e[5],c=e[6],u=e[7],l=e[8],f=e[9],h=e[10],y=e[11],d=e[12],b=e[13],m=e[14],p=e[15],g=n*s-r*i,v=n*c-a*i,w=n*u-o*i,M=r*c-a*s,T=r*u-o*s,A=a*u-o*c,k=l*b-f*d,_=l*m-h*d,O=l*p-y*d,S=f*m-h*b,x=f*p-y*b,F=h*p-y*m,I=g*F-v*x+w*S+M*O-T*_+A*k;return I?(I=1/I,t[0]=(s*F-c*x+u*S)*I,t[1]=(a*x-r*F-o*S)*I,t[2]=(b*A-m*T+p*M)*I,t[3]=(h*T-f*A-y*M)*I,t[4]=(c*O-i*F-u*_)*I,t[5]=(n*F-a*O+o*_)*I,t[6]=(m*w-d*A-p*v)*I,t[7]=(l*A-h*w+y*v)*I,t[8]=(i*x-s*O+u*k)*I,t[9]=(r*O-n*x-o*k)*I,t[10]=(d*T-b*w+p*g)*I,t[11]=(f*w-l*T-y*g)*I,t[12]=(s*_-i*S-c*k)*I,t[13]=(n*S-r*_+a*k)*I,t[14]=(b*v-d*M-m*g)*I,t[15]=(l*M-f*v+h*g)*I,t):null}(Nn,n),a=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];ye(e,(t=>{p(t,t,n),t[0]=t[0]-l[0],t[1]=t[1]-l[1],t[2]=t[2]-l[2],p(t,t,r),t[0]<a[0]&&(a[0]=t[0]),t[1]<a[1]&&(a[1]=t[1]),t[2]<a[2]&&(a[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=a,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=l)}ct(t,e,n,r){const{modelCenter:a,rtcCenter:o}=this.ft(t,e,n,r),i=this.lt(a);t.extensions.MAPTALKS_RTC.projCenter=i,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ut(a),oe(t,(e=>{if(e.attributes&&e.attributes.POSITION){const a=this.et(e,t);if(a){const t=e.attributes.POSITION.array.length;(!Pn||Pn.length<t)&&(Pn=new Float32Array(t))}e.attributes.NORMAL&&this.ht(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.ht(e.attributes.TANGENT,e.matrices,n);const{newPositions:i}=this.yt(e.attributes.POSITION,e.matrices,o,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,a),{componentType:s}=e.attributes.POSITION;5126!==s&&(e.attributes.POSITION.array=new Float32Array(i))}}));for(const e in t.nodes){t.nodes[e].matrix=Cn}}lt(t){const e=this.options.projection;"identity"===e?h(zn,t):0===w(t)?y(zn,0,0,-6378137):Tt(zn,t),je(Ln,zn,e);const n=zn[2],r=[];return r[0]=Ln[0],r[1]=Ln[1],r[2]=n,r}ht(t,e,n){let r;r="Y"===n?kn:"X"===n?_n:Cn;const a=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],r);if($n(a,e),c(a,Cn))return;const o=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}([],a),i=[];ye(t,(t=>(function(t,e,n){var r=e[0],a=e[1],o=e[2];t[0]=r*n[0]+a*n[3]+o*n[6],t[1]=r*n[1]+a*n[4]+o*n[7],t[2]=r*n[2]+a*n[5]+o*n[8]}(i,t,o),b(i,i),h(t,i),i)))}yt(t,e,n,r,a,o,s,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const l=i([]);$n(l,e);const f=this.options.projection;a=a&&a.toUpperCase();const h=n;let b=null;"Y"===a?b=kn:"X"===a&&(b=_n);let m=[0,0,0,1];const g=[0,0,0],v=[0,0],M=r.projCenter,T=je([],r.rtcCoord,"EPSG:3857"),A=o&&c(Cn,o),k=t.min=t.min||[],_=t.max=t.max||[];y(k,1/0,1/0,1/0),y(_,-1/0,-1/0,-1/0);const O=s||{},{decode_position_min:S,decode_position_normConstant:x}=O;let F=[0,0,0,0],I=1;S&&(F=S),x&&(I=x);const C=[];return ye(t,((e,n)=>{if(m[0]=e[0]*I+F[0],m[1]=e[1]*I+F[1],m[2]=e[2]*I+F[2],m=p(m,m,l),b&&(m=p(m,m,b)),h&&d(m,m,h),o&&!A&&(m=p(m,m,o)),0===w(m)?y(g,0,0,-6378137):Tt(g,m),u){const t=Pn;je(v,g,f),t[3*n]=v[0]-T[0],t[3*n+1]=v[0]-T[1],t[3*n+2]=v[0]-T[2]}if(je(v,g,f),e instanceof Float32Array)e[0]=v[0]-M[0],e[1]=v[1]-M[1],e[2]=g[2]-M[2];else{const n=v[0]-M[0],r=v[1]-M[1],a=g[2]-M[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(a),C.push(e[3]))}return e[0]<k[0]&&(k[0]=e[0]),e[1]<k[1]&&(k[1]=e[1]),e[2]<k[2]&&(k[2]=e[2]),e[0]>_[0]&&(_[0]=e[0]),e[1]>_[1]&&(_[1]=e[1]),e[2]>_[2]&&(_[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:M,newPositions:C}}ut(t){return 0===w(t)?y([],0,0,-6378137):Tt([],t)}onRemove(){}nt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}et(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material],r=n&&n.extensions&&n.extensions.KHR_materials_unlit;return r}(t,e))return!1;return!t.attributes.TANGENT}}const qn=[];function Rn(t,e,n,r,a,o){const i=o||{},{decode_position_min:s,decode_position_normConstant:c}=i;let u=[0,0,0,0],l=1;s&&(u=s),c&&(l=c);for(let o=0,i=t.length;o<i;o+=e){const{xmin:i,ymin:s,xmax:c,ymax:f,hmin:h,hmax:b}=a;y(qn,t[o]*l+u[0],t[o+1]*l+u[1],t[o+2]*l+u[2]),p(qn,qn,r);const m=d(qn,n,qn);m[0]<i&&(a.xmin=m[0]),m[0]>c&&(a.xmax=m[0]),m[1]<s&&(a.ymin=m[1]),m[1]>f&&(a.ymax=m[1]),e>2&&(m[2]<h&&(a.hmin=m[2]),m[2]>b&&(a.hmax=m[2]))}}function Vn(t){const{xmax:e,ymax:n,xmin:r,ymin:a,hmin:o,hmax:i}=t,s=[(r+e)/2,(a+n)/2,(o+i)/2];return e===-1/0&&(s[0]=0),n===-1/0&&(s[1]=0),i===-1/0&&(s[2]=0),isNaN(s[2])&&(s[2]=0),s}function Gn(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function $n(t,e){const n=t;for(let t=e.length-1;t>=0;t--)s(n,e[t],n);return n}function Xn(t,e,n,r,a){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let o,i;if(n&&r&&1===e)o=Math.min(...n),i=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);o=e,i=n}return!function(t,e,n,r){for(let a=0;a<t.length;a++){const o=Hn(Jn(t[a],e,n),e,n);if(Math.abs(o-t[a])>Dn[r])return!1}return!0}(t,o,i,a)&&Dn[a]?null:function(t,e,n){const r=new Int16Array(t.length);for(let a=0;a<t.length;a++)r[a]=Jn(t[a],e,n);return{array:r,range:[e,n]}}(t,o,i)}function Hn(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function Jn(t,e,n){const r=2*(t-e)/(n-e)-1,a=Math.max(-1,Math.min(1,r));return a<0?32768*a:32767*a}function Yn(t){return void 0===t.compressGeometry||t.compressGeometry}let Kn=0;class Qn{constructor(t){this.workerId=t,this.workers={},this.dt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},a){if(this.bt(e,n))return;const o=this.gt(e,n),i=r.options;this.workers[o]=new Bn(n,i,((...e)=>this.send.call(this,t,...e)),a)}removeLayer({mapId:t,layerId:e},n){const r=this.bt(t,e),a=this.gt(t,e);delete this.workers[a],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const a=this.bt(t,e);a&&a.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const a=this.bt(t,e);a&&a.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.dt[e];delete this.dt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,a){const o=a?\`${o}t}-${o}Kn++}\`:null;a&&(this.dt[o]=a),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(o)},r||[])}gt(t,e){return\`${o}t}-${o}e}\`}bt(t,e){const n=this.gt(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Qn(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},((t,n,r)=>{t&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}`
|
|
6
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks"),require("@maptalks/gl")):"function"==typeof define&&define.amd?define(["exports","maptalks","@maptalks/gl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).maptalks=t.maptalks||{},t.maptalks,t.maptalks)}(this,(function(t,e,n){"use strict";function r(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var i=r(e),s=r(n);const o="${",a=`function(t){\n/*!\n * @maptalks/gl v0.124.0\n * LICENSE : UNLICENSED\n * (c) 2016-2026 maptalks.com\n */\nconst e=function(){if("undefined"!=typeof undefinedThis)return globalThis;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")},n=e(),r=n.gl_trans__coders=n.gl_trans__coders||{};function a(){return e().maptalks_gltf_loader}r.inject=function(t){const r=t.toString(),a=r.indexOf("{")+1,o=r.substring(0,a),i=n.gl_trans__coders=n.gl_trans__coders||{};let s=\`${o}o}\\n const _____getGlobal = ${o}e.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};\`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\\n;");return s+="\\n("+e().maptalks_gltf_loader_bundle.toString()+")({});\\n",s+="\\n"+r.substring(o.length),s},r.registerTranscoder=function(t,e){r[t]=e},r.getTranscoder=function(t){return r[t]};var o="undefined"!=typeof Float32Array?Float32Array:Array;function i(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],a=e[1],o=e[2],i=e[3],s=e[4],c=e[5],u=e[6],l=e[7],f=e[8],h=e[9],y=e[10],d=e[11],b=e[12],m=e[13],p=e[14],g=e[15],v=n[0],w=n[1],M=n[2],T=n[3];return t[0]=v*r+w*s+M*f+T*b,t[1]=v*a+w*c+M*h+T*m,t[2]=v*o+w*u+M*y+T*p,t[3]=v*i+w*l+M*d+T*g,v=n[4],w=n[5],M=n[6],T=n[7],t[4]=v*r+w*s+M*f+T*b,t[5]=v*a+w*c+M*h+T*m,t[6]=v*o+w*u+M*y+T*p,t[7]=v*i+w*l+M*d+T*g,v=n[8],w=n[9],M=n[10],T=n[11],t[8]=v*r+w*s+M*f+T*b,t[9]=v*a+w*c+M*h+T*m,t[10]=v*o+w*u+M*y+T*p,t[11]=v*i+w*l+M*d+T*g,v=n[12],w=n[13],M=n[14],T=n[15],t[12]=v*r+w*s+M*f+T*b,t[13]=v*a+w*c+M*h+T*m,t[14]=v*o+w*u+M*y+T*p,t[15]=v*i+w*l+M*d+T*g,t}function c(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function u(){var t=new o(3);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function l(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function f(t,e,n){var r=new o(3);return r[0]=t,r[1]=e,r[2]=n,r}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function y(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function d(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function b(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function m(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function p(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[3]*r+n[7]*a+n[11]*o+n[15];return i=i||1,t[0]=(n[0]*r+n[4]*a+n[8]*o+n[12])/i,t[1]=(n[1]*r+n[5]*a+n[9]*o+n[13])/i,t[2]=(n[2]*r+n[6]*a+n[10]*o+n[14])/i,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var g=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},v=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},w=l;function M(){var t=new o(4);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}u(),function(){var t,e=(t=new o(4),o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var T;function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}u(),f(1,0,0),f(0,1,0),M(),M(),T=new o(9),o!=Float32Array&&(T[1]=0,T[2]=0,T[3]=0,T[5]=0,T[6]=0,T[7]=0),T[0]=1,T[4]=1,T[8]=1;var k={exports:{}},_={exports:{}},O=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},S=Array.prototype.concat,x=Array.prototype.slice,F=_.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var a=t[n];O(a)?e=S.call(e,x.call(a)):e.push(a)}return e};F.wrap=function(t){return function(){return t(F(arguments))}};var I=_.exports,C={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},E=I,U=Object.hasOwnProperty,N=Object.create(null);for(var z in C)U.call(C,z)&&(N[C[z]]=z);var L=k.exports={to:{},get:{}};function j(t,e,n){return Math.min(Math.max(e,t),n)}function D(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}L.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=L.get.hsl(t),n="hsl";break;case"hwb":e=L.get.hwb(t),n="hwb";break;default:e=L.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},L.get.rgb=function(t){if(!t)return null;var e,n,r,a=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;a[n]=parseInt(e.slice(o,o+2),16)}r&&(a[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)a[n]=parseInt(e[n]+e[n],16);r&&(a[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)a[n]=parseInt(e[n+1],0);e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:U.call(C,e[1])?((a=C[e[1]])[3]=1,a):null:null;for(n=0;n<3;n++)a[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}for(n=0;n<3;n++)a[n]=j(a[n],0,255);return a[3]=j(a[3],0,1),a},L.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},L.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},L.to.hex=function(){var t=E(arguments);return"#"+D(t[0])+D(t[1])+D(t[2])+(t[3]<1?D(Math.round(255*t[3])):"")},L.to.rgb=function(){var t=E(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},L.to.rgb.percent=function(){var t=E(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},L.to.hsl=function(){var t=E(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},L.to.hwb=function(){var t=E(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},L.to.keyword=function(t){return N[t.slice(0,3)]};var P=k.exports,B={exports:{}},q={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},R={};for(var V in q)q.hasOwnProperty(V)&&(R[q[V]]=V);var G=B.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var $ in G)if(G.hasOwnProperty($)){if(!("channels"in G[$]))throw new Error("missing channels property: "+$);if(!("labels"in G[$]))throw new Error("missing channel labels property: "+$);if(G[$].labels.length!==G[$].channels)throw new Error("channel and label counts mismatch: "+$);var X=G[$].channels,H=G[$].labels;delete G[$].channels,delete G[$].labels,Object.defineProperty(G[$],"channels",{value:X}),Object.defineProperty(G[$],"labels",{value:H})}G.rgb.hsl=function(t){var e,n,r=t[0]/255,a=t[1]/255,o=t[2]/255,i=Math.min(r,a,o),s=Math.max(r,a,o),c=s-i;return s===i?e=0:r===s?e=(a-o)/c:a===s?e=2+(o-r)/c:o===s&&(e=4+(r-a)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(i+s)/2,[e,100*(s===i?0:n<=.5?c/(s+i):c/(2-s-i)),100*n]},G.rgb.hsv=function(t){var e,n,r,a,o,i=t[0]/255,s=t[1]/255,c=t[2]/255,u=Math.max(i,s,c),l=u-Math.min(i,s,c),f=function(t){return(u-t)/6/l+.5};return 0===l?a=o=0:(o=l/u,e=f(i),n=f(s),r=f(c),i===u?a=r-n:s===u?a=1/3+e-r:c===u&&(a=2/3+n-e),a<0?a+=1:a>1&&(a-=1)),[360*a,100*o,100*u]},G.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[G.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},G.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-a)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-a-e)/(1-e)||0),100*e]},G.rgb.keyword=function(t){var e=R[t];if(e)return e;var n,r,a,o=1/0;for(var i in q)if(q.hasOwnProperty(i)){var s=q[i],c=(r=t,a=s,Math.pow(r[0]-a[0],2)+Math.pow(r[1]-a[1],2)+Math.pow(r[2]-a[2],2));c<o&&(o=c,n=i)}return n},G.keyword.rgb=function(t){return q[t]},G.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},G.rgb.lab=function(t){var e=G.rgb.xyz(t),n=e[0],r=e[1],a=e[2];return r/=100,a/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},G.hsl.rgb=function(t){var e,n,r,a,o,i=t[0]/360,s=t[1]/100,c=t[2]/100;if(0===s)return[o=255*c,o,o];e=2*c-(n=c<.5?c*(1+s):c+s-c*s),a=[0,0,0];for(var u=0;u<3;u++)(r=i+1/3*-(u-1))<0&&r++,r>1&&r--,o=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,a[u]=255*o;return a},G.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,a=n,o=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,a*=o<=1?o:2-o,[e,100*(0===r?2*a/(o+a):2*n/(r+n)),100*((r+n)/2)]},G.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,a=Math.floor(e)%6,o=e-Math.floor(e),i=255*r*(1-n),s=255*r*(1-n*o),c=255*r*(1-n*(1-o));switch(r*=255,a){case 0:return[r,c,i];case 1:return[s,r,i];case 2:return[i,r,c];case 3:return[i,s,r];case 4:return[c,i,r];case 5:return[r,i,s]}},G.hsv.hsl=function(t){var e,n,r,a=t[0],o=t[1]/100,i=t[2]/100,s=Math.max(i,.01);return r=(2-o)*i,n=o*s,[a,100*(n=(n/=(e=(2-o)*s)<=1?e:2-e)||0),100*(r/=2)]},G.hwb.rgb=function(t){var e,n,r,a,o,i,s,c=t[0]/360,u=t[1]/100,l=t[2]/100,f=u+l;switch(f>1&&(u/=f,l/=f),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),a=u+r*((n=1-l)-u),e){default:case 6:case 0:o=n,i=a,s=u;break;case 1:o=a,i=n,s=u;break;case 2:o=u,i=n,s=a;break;case 3:o=u,i=a,s=n;break;case 4:o=a,i=u,s=n;break;case 5:o=n,i=u,s=a}return[255*o,255*i,255*s]},G.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,a=t[3]/100;return[255*(1-Math.min(1,e*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,r*(1-a)+a))]},G.xyz.rgb=function(t){var e,n,r,a=t[0]/100,o=t[1]/100,i=t[2]/100;return n=-.9689*a+1.8758*o+.0415*i,r=.0557*a+-.204*o+1.057*i,e=(e=3.2406*a+-1.5372*o+-.4986*i)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},G.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},G.lab.xyz=function(t){var e,n,r,a=t[0];e=t[1]/500+(n=(a+16)/116),r=n-t[2]/200;var o=Math.pow(n,3),i=Math.pow(e,3),s=Math.pow(r,3);return n=o>.008856?o:(n-16/116)/7.787,e=i>.008856?i:(e-16/116)/7.787,r=s>.008856?s:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},G.lab.lch=function(t){var e,n=t[0],r=t[1],a=t[2];return(e=360*Math.atan2(a,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+a*a),e]},G.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},G.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],a=1 in arguments?arguments[1]:G.rgb.hsv(t)[2];if(0===(a=Math.round(a/50)))return 30;var o=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===a&&(o+=60),o},G.hsv.ansi16=function(t){return G.rgb.ansi16(G.hsv.rgb(t),t[2])},G.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},G.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},G.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},G.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},G.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},G.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255,o=Math.max(Math.max(n,r),a),i=Math.min(Math.min(n,r),a),s=o-i;return e=s<=0?0:o===n?(r-a)/s%6:o===r?2+(a-n)/s:4+(n-r)/s+4,e/=6,[360*(e%=1),100*s,100*(s<1?i/(1-s):0)]},G.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,a=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(a=(n-.5*r)/(1-r)),[t[0],100*r,100*a]},G.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},G.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var a,o=[0,0,0],i=e%1*6,s=i%1,c=1-s;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=c,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=c,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=c}return a=(1-n)*r,[255*(n*o[0]+a),255*(n*o[1]+a),255*(n*o[2]+a)]},G.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},G.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},G.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},G.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},G.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},G.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},G.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},G.gray.hsl=G.gray.hsv=function(t){return[0,0,t[0]]},G.gray.hwb=function(t){return[0,100,t[0]]},G.gray.cmyk=function(t){return[0,0,0,t[0]]},G.gray.lab=function(t){return[t[0],0,0]},G.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},G.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var J=B.exports,Y=J;function K(t){var e=function(){for(var t={},e=Object.keys(Y),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),a=Object.keys(Y[r]),o=a.length,i=0;i<o;i++){var s=a[i],c=e[s];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(s))}return e}function Q(t,e){return function(n){return e(t(n))}}function Z(t,e){for(var n=[e[t].parent,t],r=Y[e[t].parent][t],a=e[t].parent;e[a].parent;)n.unshift(e[a].parent),r=Q(Y[e[a].parent][a],r),a=e[a].parent;return r.conversion=n,r}var W=J,tt=function(t){for(var e=K(t),n={},r=Object.keys(e),a=r.length,o=0;o<a;o++){var i=r[o];null!==e[i].parent&&(n[i]=Z(i,e))}return n},et={};Object.keys(W).forEach((function(t){et[t]={},Object.defineProperty(et[t],"channels",{value:W[t].channels}),Object.defineProperty(et[t],"labels",{value:W[t].labels});var e=tt(t);Object.keys(e).forEach((function(n){var r=e[n];et[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,a=0;a<r;a++)n[a]=Math.round(n[a]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),et[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var nt=P,rt=et,at=[].slice,ot=["keyword","gray","hex"],it={};Object.keys(rt).forEach((function(t){it[at.call(rt[t].labels).sort().join("")]=t}));var st={};function ct(t,e){if(!(this instanceof ct))return new ct(t,e);if(e&&e in ot&&(e=null),e&&!(e in rt))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ct)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var a=nt.get(t);if(null===a)throw new Error("Unable to parse color from string: "+t);this.model=a.model,r=rt[this.model].channels,this.color=a.value.slice(0,r),this.valpha="number"==typeof a.value[r]?a.value[r]:1}else if(t.length){this.model=e||"rgb",r=rt[this.model].channels;var o=at.call(t,0,r);this.color=ft(o,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var i=Object.keys(t);"alpha"in t&&(i.splice(i.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var s=i.sort().join("");if(!(s in it))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=it[s];var c=rt[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=ft(u)}if(st[this.model])for(r=rt[this.model].channels,n=0;n<r;n++){var l=st[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ut(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(st[t]||(st[t]=[]))[e]=n})),t=t[0],function(r){var a;return arguments.length?(n&&(r=n(r)),(a=this[t]()).color[e]=r,a):(a=this[t]().color[e],n&&(a=n(a)),a)}}function lt(t){return function(e){return Math.max(0,Math.min(t,e))}}function ft(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function ht(t){return null==t}function yt(t){return"object"==typeof t&&!!t}function dt(t){return t/Math.PI*180}ct.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in nt.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return nt.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return nt.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=rt[this.model].channels,n=rt[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ct(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ct(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ut("rgb",0,lt(255)),green:ut("rgb",1,lt(255)),blue:ut("rgb",2,lt(255)),hue:ut(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ut("hsl",1,lt(100)),lightness:ut("hsl",2,lt(100)),saturationv:ut("hsv",1,lt(100)),value:ut("hsv",2,lt(100)),chroma:ut("hcg",1,lt(100)),gray:ut("hcg",2,lt(100)),white:ut("hwb",1,lt(100)),wblack:ut("hwb",2,lt(100)),cyan:ut("cmyk",0,lt(100)),magenta:ut("cmyk",1,lt(100)),yellow:ut("cmyk",2,lt(100)),black:ut("cmyk",3,lt(100)),x:ut("xyz",0,lt(100)),y:ut("xyz",1,lt(100)),z:ut("xyz",2,lt(100)),l:ut("lab",0,lt(100)),a:ut("lab",1),b:ut("lab",2),keyword:function(t){return arguments.length?new ct(t):rt[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ct(t):nt.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ct.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),a=void 0===e?.5:e,o=2*a-1,i=n.alpha()-r.alpha(),s=((o*i==-1?o:(o+i)/(1+o*i))+1)/2,c=1-s;return ct.rgb(s*n.red()+c*r.red(),s*n.green()+c*r.green(),s*n.blue()+c*r.blue(),n.alpha()*a+r.alpha()*(1-a))}},Object.keys(rt).forEach((function(t){if(-1===ot.indexOf(t)){var e=rt[t].channels;ct.prototype[t]=function(){if(this.model===t)return new ct(this);if(arguments.length)return new ct(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ct((n=rt[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ct[t]=function(n){return"number"==typeof n&&(n=ft(at.call(arguments),e)),new ct(n,t)}}}));const bt=[1,1,1,1,2,2,3,0];function mt(t){const e=t.length;let n="";for(let r=0;r<e;){let a=t[r++];if(128&a){let n=bt[a>>3&7];if(!(64&a)||!n||r+n>e)return null;for(a&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;a=a<<6|63&e}}n+=String.fromCharCode(a)}return n}new Array(3),new Array(3);const pt=[1/6378137,1/6378137,1/6356752.314245179],gt=[1/40680631590769,1/40680631590769,1/40408299984661.445],vt=new Array(3),wt=new Array(3),Mt=new Array(3);function Tt(t,e){const n=gt,r=function(t,e,n,r,a){const o=e[0],i=e[1],s=e[2],c=n[0],u=n[1],l=n[2],f=o*o*c*c,h=i*i*u*u,y=s*s*l*l,d=f+h+y,b=Math.sqrt(1/d),m=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(At,e,b);if(d<a)return isFinite(b)?m:void 0;const p=r[0],g=r[1],v=r[2],w=kt;w[0]=m[0]*p*2,w[1]=m[1]*g*2,w[2]=m[2]*v*2;let M,T,A,k,_,O,S,x,F,I,C,E=(1-b)*Ot(e)/(.5*Ot(w)),U=0;do{E-=U,A=1/(1+E*p),k=1/(1+E*g),_=1/(1+E*v),O=A*A,S=k*k,x=_*_,F=O*A,I=S*k,C=x*_,M=f*O+h*S+y*x-1,T=f*F*p+h*I*g+y*C*v;U=M/(-2*T)}while(Math.abs(M)>_t);return t[0]=o*A,t[1]=i*k,t[2]=s*_,t}(vt,e,pt,n,.1);let a=v(wt,r,n);a=function(t,e){const n=e[0],r=e[1],a=e[2];let o=n*n+r*r+a*a;o>0&&(o=Math.sqrt(o),t[0]=e[0]/o,t[1]=e[1]/o,t[2]=e[2]/o);return t}(a,a);const o=g(Mt,e,r),i=Math.atan2(a[1],a[0]),s=Math.asin(a[2]),c=(u=m(o,e),(Math.sign?Math.sign(u):0==(u=+u)||isNaN(u)?Number(u):u>0?1:-1)*Ot(o));var u;return t[0]=dt(i),t[1]=dt(s),t[2]=c,t}const At=new Array(3),kt=new Array(3),_t=1e-12;function Ot(t){return l(t)}function St(t,e){let n="";for(let r=0;r<4;r++){const a=t.getUint8(e+r);n+=String.fromCharCode(a)}return n}const xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ft(t,e,n){const r=new Uint8Array(t,e,n);return xt?JSON.parse(xt.decode(r)):JSON.parse(mt(r))}function It(t,e,n){const r=new Uint8Array(t,e,n);return xt?JSON.parse(xt.decode(r)):JSON.parse(mt(r))}function Ct(t,e,n){return{offset:e,byteLength:n}}function Et(t,e,n,r){const{byteOffset:a,componentType:o,type:i}=t,{ctor:s,type:c}=function(t){return zt[t]}(o||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Nt[t]}(i);return{byteStride:0,byteOffset:a+n,itemSize:u,count:r*u,componentType:c,array:new s(e,n+a,r*u)}}function Ut(t,e,n,r){const a=Et(t,e,n,r);return a.array.buffer.byteLength!==e.byteLength&&(a.array=a.array.slice()),a}const Nt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const zt={"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 Lt(t){for(const e in zt)if(t===zt[e].ctor)return zt[e].type;throw new Error("unrecognized ctor:"+t)}function jt(t,e,n,r){const a=t,o=e.length/3;for(let t=0;t<o;t++)a[3*t]=e[3*t]/65535*r[0]+n[0],a[3*t+1]=e[3*t+1]/65535*r[1]+n[1],a[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return a}function Dt(t,e,n){const r=t.getUint32(12,!0),a=t.getUint32(16,!0),o=t.getUint32(20,!0),i=t.getUint32(24,!0),s=t.buffer;let c,u={},l={},f=null;r>0&&(u=Ft(s,e,r),e+=r),a>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,a),e+=a),o>0&&(l=It(s,e,o),e+=o);const h=Ct(0,e,i);return f=s.slice(h.offset,h.offset+h.byteLength),n.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}const Pt={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Bt(t){for(const e in Pt)if(t===Pt[e])return+e;throw new Error("unrecognized ctor:"+t)}let qt=null;function Rt(){return qt||(qt={"image/crn":r.crn&&r.crn(),"image/ktx2":r.ktx2&&r.ktx2(),"image/cttf":r.ktx2&&r.ktx2(),"draco":r.draco&&r.draco()}),qt}const{Ajax:Vt,GLTFLoader:Gt}=a();class $t{constructor(t,e,n){this.o=t,this.i=e||Gt,this.u=n,this.h=Rt()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,a){return e?(r||(r=e.byteLength),this.m(t,e,n,r,a)):Vt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r,a){const o=a&&a.maxTextureSize,i=this.p(e,n,r,t);if(i.error)return Promise.resolve(i);const s=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.i(s,i.glb,{transferable:!0,requestImage:this.o,decoders:this.h,supportedFormats:this.u,maxTextureSize:o})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${o}t}-${o}n}-${o}r}\`;const a=c.transferables;for(let t=0;t<i.transferables.length;t++)a.indexOf(i.transferables[t])<0&&a.push(i.transferables[t]);return{magic:"b3dm",count:i.count,transferables:a,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,gltf:e}}))}p(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported b3dm version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let i,s=a.getUint32(12,!0),c=a.getUint32(16,!0),u=a.getUint32(20,!0),l=a.getUint32(24,!0),f=28+e;u>=570425344?(f-=8,i=s,u=c,l=0,s=0,c=0):l>=570425344&&(f-=4,i=u,u=s,l=c,s=0,c=0);const h=[t];let y,d,b;if(s>0?(y=Ft(t,f,s),f+=s,i=y.BATCH_LENGTH):y={"BATCH_LENGTH":i},c>0&&(f+=c),u>0&&(d=It(t,f,u),f+=u,l>0)){const e=Ct(0,f,l);b=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(b)}const m=y.BATCH_LENGTH,p={};if(y&&y.BATCH_ID){p.BATCH_ID=Ut(y.BATCH_ID,t,undefined.offset,m);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:i,transferables:h,featureTable:y,batchTable:d,batchTableBin:b,b3dm:p,glb:{buffer:t,byteOffset:f,byteLength:a.byteLength+a.byteOffset-f}}}v(){return null}}const{Ajax:Xt,GLTFLoader:Ht}=a();class Jt{constructor(t,e,n,r){this.o=t,this.i=e||Ht,this.u=n,this.h=Rt(),this.M=r}load(t,e,n=0,r=0,a){return e?(r||(r=e.byteLength),this.m(t,e,n,r,a)):Xt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r,a){return this.T(t,e,n,r,a).then((({gltf:a,transferables:o})=>{const i=this.A(e,n,r,t);if(i.error)return Promise.resolve(i);for(let t=0;t<o.length;t++)-1===i.transferables.indexOf(o[t])&&i.transferables.push(o[t]);return delete a.transferables,Promise.resolve({magic:"i3dm",count:i.count,transferables:i.transferables,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,i3dm:i.i3dm,gltf:a})}))}T(t,e,n,r,a){const o=a&&a.maxTextureSize,i={transferable:!0,requestImage:this.o,decoders:this.h,supportedFormats:this.u,maxTextureSize:o},s=new DataView(e,n,r),c=32+s.getUint32(12,!0)+s.getUint32(16,!0)+s.getUint32(20,!0)+s.getUint32(24,!0);if(0===s.getUint32(28,!0)){let r=mt(new Uint8Array(e,c+n,s.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?Xt.getArrayBuffer(r,{}).then((t=>this.k(r,{buffer:t.data,byteOffset:0},i))):Xt.getJSON(r,{}).then((t=>this.k(r,t,i)))}{const r={buffer:e,byteOffset:c+n,byteLength:s.byteLength-c};return this.k(t,r,i)}}k(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),a=new this.i(r,e,n);return a.load({skipAttributeTransform:!0}).then((n=>{let r=0,o=0;return e.buffer&&(r=e.byteOffset||0,o=e.byteLength||0),n.url=\`${o}t}-${o}r}-${o}o}\`,{transferables:a.transferables,gltf:n}}))}A(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,32+e,i),f={},h=s.INSTANCES_LENGTH;if(s.POSITION){const{byteOffset:e}=s.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.POSITION.array.buffer)}else if(s.POSITION_QUANTIZED){const e=s.QUANTIZED_VOLUME_OFFSET,n=s.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=s.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this._(new Uint16Array(t,r+c.offset,3*h),e,n)},i.push(f.POSITION.array.buffer)}if(s.BATCH_ID){f.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,h);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}if(s.NORMAL_UP){let{byteOffset:e}=s.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.NORMAL_RIGHT.array.buffer)}else if(s.NORMAL_UP_OCT32P){let{byteOffset:e}=s.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,e+c.offset,2*h))},i.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,e+c.offset,2*h))},i.push(f.NORMAL_RIGHT.array.buffer)}if(s.SCALE){const{byteOffset:e}=s.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},i.push(f.SCALE.array.buffer)}else if(s.SCALE_NON_UNIFORM){const{byteOffset:e}=s.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:l,featureTable:s,i3dm:f,transferables:i}}O(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let a=0;a<e;a++)Yt(r,t[2*a],t[2*a+1],65535),n[3*a]=r[0],n[3*a+1]=r[1],n[3*a+2]=r[2];return n}_(t,e,n){return jt(new Float32Array(t.length),t,e,n)}v(){return null}}function Yt(t,e,n,r){if(t[0]=Kt(e,r),t[1]=Kt(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]))*Qt(e),t[1]=(1-Math.abs(e))*Qt(t[1])}return b(t,t)}function Kt(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 Qt(t){return t<0?-1:1}const{Ajax:Zt}=a();class Wt{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.m(t,e,n,r)):Zt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r){return this.S(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}))}S(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,e+28,i),f=s.QUANTIZED_VOLUME_OFFSET,h=s.QUANTIZED_VOLUME_SCALE,y=s.POINTS_LENGTH;let d,b={};if(s.extensions&&s.extensions["3DTILES_draco_point_compression"]){b=s.extensions["3DTILES_draco_point_compression"],d=new DataView(t,b.byteOffset+c.offset,b.byteLength);const e={attributes:b.properties,useUniqueIDs:!1};return this.F||(this.F=Rt().draco),this.F(d,e).then((e=>{const n=e.attributes;!s.POSITION&&!s.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=s.POSITION,n.POSITION_QUANTIZED=s.POSITION_QUANTIZED),!(s.RGB||s.RGBA||s.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=s.RGB,n.RGBA=s.RGBA,n.RGB565=s.RGB565),!s.NORMAL&&!s.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=s.NORMAL,n.NORMAL_OCT16P=s.NORMAL_OCT16P);const r=this.I(t,e.attributes,c.offset,y,i,f,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Lt(t.constructor),array:t},i.push(t.buffer)}else if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?r.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,y):r.BATCH_ID=te(y);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return{count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:r,transferables:i}}))}const m=this.I(t,s,c.offset,y,i,f,h);if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?m.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,y):m.BATCH_ID=te(y);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return Promise.resolve({count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:m,transferables:i})}I(t,e,n,r,a,o,i){const s={};if(e.POSITION){let{byteOffset:o,array:i}=e.POSITION;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},a.push(i.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const l=u?0:n;s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this._(u||new Uint16Array(t,c+l,3*r),o,i)},a.push(s.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:o,array:i}=e.RGBA;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+4*r);i=new Uint8Array(e)}s.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:i},a.push(i.buffer)}else if(e.RGB){let{byteOffset:o,array:i}=e.RGB;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r);i=new Uint8Array(e)}s.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:i},a.push(i.buffer)}else if(e.RGB565){let{byteOffset:o,array:i}=e.RGB565;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint16Array(e)}s.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:i},a.push(i.buffer)}if(e.NORMAL){let{byteOffset:o,array:i}=e.NORMAL;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}s.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},a.push(i.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:o,array:i}=e.NORMAL_OCT16P;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint8Array(e)}s.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:i},a.push(i.buffer)}return s}_(t,e,n){return jt(new Float32Array(t.length),t,e,n)}v(){return null}}function te(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:Lt(e),array:r}}const{Ajax:ee,GLTFLoader:ne}=a();class re{constructor(t,e,n,r){this.u=n,this.o=t,this.i=e||ne,this.M=r}load(t,e,n=0,r=0,a){return e?this.m(t,e,n,r,a):ee.getArrayBuffer(t,{}).then((e=>{const a=e.data;return this.m(t,a,n,r)}))}m(t,e,n,r,a){r||(r=e.byteLength);const o=this.C(e,t,n,r),i=[];for(let n=0;n<o.length;n++){let r;if("b3dm"===o[n].magic)r=new $t(this.o,this.i,this.u);else if("i3dm"===o[n].magic)r=new Jt(this.o,this.i,this.u,this.M);else if("pnts"===o[n].magic)r=new Wt;else{if("cmpt"!==o[n].magic){console.warn("Unsupported magic in CMPT tile:",o[n].magic);continue}r=new re(this.o,this.i,this.u,this.M)}i.push(r.load(t,e,o[n].offset,o[n].byteLength,a).then((t=>t)))}return Promise.all(i).then((t=>({magic:"cmpt",tiles:t})))}C(t,e,n,r){const a=new DataView(t,n,r),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported cmpt version: "+o+", url:"+e;return console.warn(t),{error:t}}if(16===a.byteLength)return[];const i=[],s=a.getUint32(12,!0);let c=16;for(let e=0;e<s;e++){const e=St(a,c),r=a.getUint32(c+8,!0);i.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return i}}const{GLTFLoader:ae}=a();function oe(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,a=r.length;n<a;n++){const a=[];he(r[n],a,t,e)}}}const ie=[],se=[],ce=[],ue=[0,0,0],le=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),fe=[1,1,1];function he(t,e,n,r){const a=e.slice(0);if(t.matrix)a.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(ie,t.translation||ue),n=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,s=r+r,c=a+a,u=n*i,l=r*i,f=r*s,h=a*i,y=a*s,d=a*c,b=o*i,m=o*s,p=o*c;return t[0]=1-f-d,t[1]=l+p,t[2]=h-m,t[3]=0,t[4]=l-p,t[5]=1-u-d,t[6]=y+b,t[7]=0,t[8]=h+m,t[9]=y-b,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(se,t.rotation||le),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ce,t.scale||fe);s(r,n,r);const o=s([],e,r);a.push(o)}if(t.children&&t.children.length)for(let e=0,o=t.children.length;e<o;e++)he(t.children[e],a,n,r);if(void 0!==t.mesh){const e=t.mesh,o=n.meshes[e];if(o){const t=a.slice(0),i=o.primitives;for(let a=0,o=i.length;a<o;a++){const o=i[a];o&&(o.matrices=t,r(o,e,a,n))}}}}function ye(t,e){let{byteOffset:n,byteStride:r,count:a}=t;const{componentType:o,itemSize:i}=t,s=t.array.buffer,c=o?ae.getTypedArrayCtor(o):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,a=a||t.array.length/i,(!r||r===i*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(s,n,a*i);for(let r=0;r<a*i;r+=i){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,i),r/i)}return}const u=new Uint8Array(i*c.BYTES_PER_ELEMENT);r||(r=i*c.BYTES_PER_ELEMENT);for(let t=0;t<a;t++){const a=new Uint8Array(s,r*t+n,i*c.BYTES_PER_ELEMENT);u.set(a);e(new c(u.buffer),t),a.set(u)}}var de=ge("DXT1"),be=ge("DXT3"),me=ge("DXT5"),pe=ge("DX10");function ge(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var ve=A((function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var a=r[21];switch(a){case de:e=8,n="dxt1";break;case be:e=16,n="dxt3";break;case me:e=16,n="dxt5";break;case 116:n="rgba32f";break;case pe:var o=new Uint32Array(t.slice(128,148));n=o[0];var i=o[1];if(o[2],o[3],o[4],3!==i||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(s=a,String.fromCharCode(255&s,s>>8&255,s>>16&255,s>>24&255)))}var s;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var l=!1;512&r[28]&&(l=!0);var f,h=r[4],y=r[3],d=r[1]+4,b=h,m=y,p=[];a===pe&&(d+=20);if(l)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=b,y=m;for(var v=Math.log(h)/Math.log(2)+1,w=0;w<v;w++)f=h*y*16,p.push({offset:d,length:f,shape:[h,y]}),w<u&&(d+=f),h=Math.floor(h/2),y=Math.floor(y/2)}else for(w=0;w<u;w++)f=Math.max(4,h)/4*Math.max(4,y)/4*e,p.push({offset:d,length:f,shape:[h,y]}),d+=f,h=Math.floor(h/2),y=Math.floor(y/2);return{shape:[b,m],images:p,format:n,flags:c,cubemap:l}})),we=Math.abs,Me=Math.sin,Te=Math.cos,Ae=Math.tan,ke=Math.atan,_e=Math.atan2,Oe=Math.sqrt,Se=Math.log,xe=Math.hypot,Fe=Math.sinh,Ie=Math.cosh,Ce=1/0;function Ee(t){var e,n,r,a,o,i,s=[],c=[],u=[],l=[];function f(t,e){for(var n,r=2*Te(2*e),a=t.length-1,o=t[a],i=0;--a>=0;)n=r*o-i+t[a],i=o,o=n;return e+n*Me(2*e)}function h(t,e,n){for(var r,a,o=Me(e),i=Te(e),s=Fe(n),c=Ie(n),u=2*i*c,l=-2*o*s,f=t.length-1,h=t[f],y=0,d=0,b=0;--f>=0;)r=d,a=y,h=u*(d=h)-r-l*(y=b)+t[f],b=l*d-a+u*y;return[(u=o*c)*h-(l=i*s)*b,u*b+l*h]}t.es,o=a=(r=t.es/(1+Oe(1-t.es)))/(2-r),s[0]=a*(2+a*(-2/3+a*(a*(116/45+a*(26/45+a*(-2854/675)))-2))),c[0]=a*(a*(2/3+a*(4/3+a*(-82/45+a*(32/45+a*(4642/4725)))))-2),o*=a,s[1]=o*(7/3+a*(a*(-227/45+a*(2704/315+a*(2323/945)))-1.6)),c[1]=o*(5/3+a*(-16/15+a*(-13/9+a*(904/315+a*(-1522/945))))),o*=a,s[2]=o*(56/15+a*(-136/35+a*(-1262/105+a*(73814/2835)))),c[2]=o*(-26/15+a*(34/21+a*(1.6+a*(-12686/2835)))),o*=a,s[3]=o*(4279/630+a*(-332/35+a*(-399572/14175))),c[3]=o*(1237/630+a*(a*(-24832/14175)-2.4)),o*=a,s[4]=o*(4174/315+a*(-144838/6237)),c[4]=o*(-734/315+a*(109598/31185)),o*=a,s[5]=o*(601676/22275),c[5]=o*(444337/155925),o=a*a,e=t.k0/(1+a)*(1+o*(1/4+o*(1/64+o/256))),u[0]=a*(a*(2/3+a*(-37/96+a*(1/360+a*(81/512+a*(-96199/604800)))))-.5),l[0]=a*(.5+a*(-2/3+a*(5/16+a*(41/180+a*(-127/288+a*(7891/37800)))))),u[1]=o*(-1/48+a*(-1/15+a*(437/1440+a*(-46/105+a*(1118711/3870720))))),l[1]=o*(13/48+a*(a*(557/1440+a*(281/630+a*(-1983433/1935360)))-.6)),o*=a,u[2]=o*(-17/480+a*(37/840+a*(209/4480+a*(-5569/90720)))),l[2]=o*(61/240+a*(-103/140+a*(15061/26880+a*(167603/181440)))),o*=a,u[3]=o*(-4397/161280+a*(11/504+a*(830251/7257600))),l[3]=o*(49561/161280+a*(-179/168+a*(6601661/7257600))),o*=a,u[4]=o*(-4583/161280+a*(108847/3991680)),l[4]=o*(34729/80640+a*(-3418889/1995840)),o*=a,u[5]=o*(-20648693/638668800),l[5]=.6650675310896665*o,i=f(c,t.phi0),n=-e*(i+function(t,e){var n,r=2*Te(e),a=t.length-1,o=t[a],i=0;for(;--a>=0;)n=r*o-i+t[a],i=o,o=n;return Me(e)*n}(l,2*i)),t.fwd=function(t,r){var a,o,i,s,u,y=t.phi,d=t.lam;y=f(c,y),a=Me(y),o=Te(y),s=Me(d),i=Te(d),y=_e(a,i*o),d=_e(s*o,xe(a,o*i)),d=function(t){var e=we(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*Se(e)/n}(e*(1+e/(xe(1,e)+1))),t<0?-e:e}(Ae(d)),u=h(l,2*y,2*d),y+=u[0],d+=u[1],we(d)<=2.623395162778?(r.y=e*y+n,r.x=e*d):r.x=r.y=Ce},t.inv=function(t,r){var a,o,i,c,l,y=t.y,d=t.x;y=(y-n)/e,we(d/=e)<=2.623395162778?(y+=(l=h(u,2*y,2*d))[0],d+=l[1],d=ke(Fe(d)),a=Me(y),o=Te(y),c=Me(d),i=Te(d),d=_e(c,i*o),y=_e(a*i,xe(c,i*o)),r.phi=f(s,y),r.lam=d):r.phi=r.lam=Ce}}const Ue=Math.PI/180,Ne=6378137*Math.PI/180,ze=85.0511287798,Le={};function je(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=ze,r=e[0],a=Math.max(Math.min(n,e[1]),-n);let o;o=0===a?0:Math.log(Math.tan((90+a)*Ue/2))/Ue;return t[0]=r*Ne,t[1]=o*Ne,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return De(t,e);if("baidu"===n)return De(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const a=JSON.stringify(n);let o=Le[a];return o||(o=Le[a]=function(t){const e={a:Be,es:qe,x0:ht(t.falseEasting)?5e5:t.falseEasting,y0:ht(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*Pe,phi0:(t.latitudeOfOrigin||0)*Pe,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Ee(e);const n={lam:0,phi:0},r={};let a=0,o=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*Pe-e.lam0,n.phi=e.originPhi0*Pe,e.fwd(n,r),a=e.a*r.x+e.x0,o=e.a*r.y+e.y0);return{project:function(t,i){n.lam=t[0]*Pe-e.lam0,n.phi=t[1]*Pe,e.fwd(n,r);const s=e.a*r.x+e.x0-a,c=e.a*r.y+e.y0-o;return i[0]=s,i[1]=c,i}}}(n)),o.project(e,t)}}function De(t,e){return t[0]=e[0],t[1]=e[1],t}const Pe=.017453292519943295,Be=6378137,qe=.0066943799901413165;const{Ajax:Re}=a(),Ve=i([]),Ge=Rt().draco,$e=Rt().ktx2,Xe={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},He={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function Je(t,e,n,r,a,o){const s=[],c=[],u=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],a=Re.getArrayBuffer(n.url,o);a.xhr.url=n.url,u.push(a.xhr);const i=a.then((t=>({buffer:t})));s.push(i);const l=[];if(nn(r,l),l.length){const t=l.map((t=>{const e=Re.getArrayBuffer(t.url,o);return e.xhr.url=t.url,u.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));s.push(...t)}c[e]=l.length}const l=Promise.all(s).then((o=>{for(let t=0;t<o.length;t++)if(!o[t]||!o[t].buffer)return Promise.resolve(null);const s=[];let u=0;for(let t=0;t<c.length;t++){const e=c[t];s.push({geoBuffer:{data:o[u].buffer.data},textureBuffers:o.slice(u+1,e+u+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),u+=1+e}const l=function(t,e,n,r,a,o){const s={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let u=0;u<t.meshes.length;u++){let{material:l}=t.meshes[u];const{geometry:f}=t.meshes[u];let h;const y=e[u].geoBuffer.data;if(!y)continue;h=un(y)?Ke(s,u,f,y,t.transform,t.center,a,o):Ze(s,u,f,y,t.transform,t.center,a,o),c.push(h),s.nodes[u]={mesh:u,nodeIndex:u,matrix:i([])},s.scenes[0].nodes[u]=s.nodes[u],l||(l=Xe);const d=tn(u,s,l,e[u].textureBuffers,n,r);c.push(d)}return Promise.all(c).then((()=>({gltf:s,featureTable:{BATCH_LENGTH:0},transferables:s.transferables})))}(t,s,e,a,n,r);return l}));return l.xhr=u,l}const Ye={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Ke(t,e,n,r,a,o,i,s){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=He[e];if(!r)return t;return t[r.name||e]=n,t}),{});return Ge(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>We(n,t,e,a,o,i,s)))}const Qe={position:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.position={array:a,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.normal={array:a,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,a=new Float32Array(e,n,r);return t.uv0={array:a,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,a=new Uint8Array(e,n,r);return t.color={array:a,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,a=new Uint32Array(e,n,r);return t.faceRange={array:a,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Ze(t,e,n,r,a,o,i,s){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)Qe[n[e]]?t=Qe[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let a=e.ordering,o=e.featureAttributeOrder;const i=null;i&&i.geometryData&&i.geometryData[0]&&i.geometryData[0].params;for(let e=0;e<a.length;e++){const n=Qe[a[e]];n||console.log(a[e]),t=n(c,r,t)}for(let e=0;e<o.length;e++){const n=Qe[o[e]];n||console.log(o[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const l={};for(const t in c){const e=He[t]&&He[t].name;e&&(l[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(f=e)<=255?Uint8Array:f<=65535?Uint16Array:Uint32Array,r=new n(l.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,a=t[e],o=t[e+1];for(let t=a;t<=o;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}l._BATCHID={componentType:Bt(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var f;return We({attributes:l},t,e,a,o,i,s)}function We(t,e,n,r,a,o,i){const s={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const u=function(t,e,n,r,a){let o,i=[0,0,0,1];const s=[0,0],u=je([],n,r,a);u[2]=n[2];const l=e&&c(Ve,e);return ye(t,(t=>(i[0]=t[0],i[1]=t[1],i[2]=t[2],l||(i=p(i,i,e)),n&&d(i,i,n),je(s,i,r,a),o=i[2],t[0]=s[0]-u[0],t[1]=s[1]-u[1],t[2]=o-u[2],t))),u}(t.attributes.POSITION,r,a,o,i);e.meshes[n]={primitives:[s],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:a};for(const n in t.attributes)cn(e.transferables,t.attributes[n].array.buffer);return t.indices&&cn(e.transferables,t.indices.array.buffer),s}function tn(t,e,n,r,a,o){const i=r.map((t=>function(t,e,n,r,a){if("dds"===e){const e=ve(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),a="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Ye,format:a})}if("png"===e||"jpg"===e)return function(t,e){rn||(rn=new OffscreenCanvas(2,2),an=rn.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;on(n)||(n=sn(n)),on(r)||(r=sn(r));const a=e;a&&(n=Math.min(a,n),r=Math.min(a,r)),rn.width=n,rn.height=r,an.drawImage(t,0,0,n,r),t.close();const o=an.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(o.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,a).then((t=>{t.mimeType=n;return{image:t,sampler:Ye,format:6408}}));if("ktx2"===e)return $e(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Ye,format:t.format})));return null}(t.data,t.format,t.mimeType,a,o).then((t=>{if(t.image)if(t.image.array)cn(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)cn(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(i).then((r=>{en(t,e,n,r)}))}function en(t,e,n,r){const a=JSON.parse(JSON.stringify(n)),o=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(o.push(r[r.ptr++]),a[t]={index:o.length-1},void 0!==n[t].factor&&(a[t].scale=n[t].factor)):yt(n[t])&&(a[t]=en(-1,e,n[t],r));return t>=0&&(e.materials[t]=a),a}function nn(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):yt(t[n])&&nn(t[n],e)}let rn,an;function on(t){return!(t&t-1)&&0!==t}function sn(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function cn(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function un(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}var ln="undefined"!=typeof Float32Array?Float32Array:Array;function fn(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var hn=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};!function(){var t=function(){var t=new ln(3);return ln!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const yn=[];const dn=[],bn=[],mn=[],pn=[],gn=[],vn=[],wn=[];function Mn(t,e,n,r,a,o){fn(pn,t[3*e],t[3*e+1],t[3*e+2]),fn(gn,t[3*n],t[3*n+1],t[3*n+2]),fn(vn,t[3*r],t[3*r+1],t[3*r+2]);const i=hn(dn,vn,gn),s=hn(bn,pn,gn),c=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[0],s=n[1],c=n[2];return t[0]=a*c-o*s,t[1]=o*i-r*c,t[2]=r*s-a*i,t}(mn,i,s);!function(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o)}(wn,c),a[3*e]=a[3*e]||0,a[3*n]=a[3*n]||0,a[3*r]=a[3*r]||0,a[3*e+1]=a[3*e+1]||0,a[3*n+1]=a[3*n+1]||0,a[3*r+1]=a[3*r+1]||0,a[3*e+2]=a[3*e+2]||0,a[3*n+2]=a[3*n+2]||0,a[3*r+2]=a[3*r+2]||0,a[3*e]+=wn[0],a[3*n]+=wn[0],a[3*r]+=wn[0],a[3*e+1]+=wn[1],a[3*n+1]+=wn[1],a[3*r+1]+=wn[1],a[3*e+2]+=wn[2],a[3*n+2]+=wn[2],a[3*r+2]+=wn[2],o[e]+=1,o[n]+=1,o[r]+=1}const{Ajax:Tn,GLTFLoader:An}=a(),kn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],_n=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],On=2*Math.PI*6378137/360,Sn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let xn,Fn,In=!1;if("undefined"!=typeof OffscreenCanvas){try{Fn=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}Fn&&"undefined"!=typeof createImageBitmap&&(In=!0)}const Cn=i([]),En=[0,0,0],Un=[],Nn=[],zn=[],Ln=[],jn={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Dn={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Pn;class Bn{constructor(t,e,n,r){this.id=t,this.options=e,this.U=(...t)=>this.requestImage.call(this,...t),this.N=n,this.L={},r(null,{},[])}j(t){this.D||(this.u=t,this.P=new Wt,this.D=new $t(this.U,An,t),this.B=new Jt(this.U,An,t))}requestImage(t,e){In?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{xn.width=t.width,xn.height=t.height,Fn.drawImage(t,0,0);const n=Fn.getImageData(0,0,xn.width,xn.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.N("requestImage",{url:t},null,e)}loadTile(t,e){this.j(t.supportedFormats);const{service:n,url:r,arraybuffer:a}=t,o=n.fetchOptions||{};if(o.referrer=t.referrer,o.referrerPolicy=o.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const a=t.i3sInfo,i=n.maxTextureSize||0,s=Je(a,t.supportedFormats,this.options.projection,t.projection,i,o);return s.then((t=>{if(delete this.L[r],!t)return void e({status:404,url:r,i3sInfo:a});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:a});t.gltf.url=r;const{transferables:o}=t;t.magic="b3dm",n.createNormalIfMissed&&this.q(t.gltf),Yn(n)&&this.R(t.gltf),e(null,t,o)})),void(this.L[r]=s.xhr)}if(a){delete this.L[r];const n=St(new DataView(a),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(Sn){const r=new Uint8Array(t,e,n);return Sn.decode(r)}return mt(new Uint8Array(t,e,n))}(a,0,a.byteLength),o=JSON.parse(n);o.accessors?this.V(o,r,t,"gltf",e):this.G(t.rootIdx,o,a,r,e)}else this.V(a,r,t,n,e)}else{let a=n.urlParams;a&&(a=(r.indexOf("?")>0?"&":"?")+a);const i=r.replace(/\\+/g,"%2B");let s=Tn.getArrayBuffer(i+(a||""),o);const c=s.xhr;s=s.then((n=>{delete this.L[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.L[r],e(t)})),this.L[r]=c}}V(t,e,n,r,a){r=r&&r.toLowerCase();const{service:o}=n;if("b3dm"===r){this.D.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{if(t.error)return void a(t);const{content:e,transferables:r}=this.$(t,n);o.createNormalIfMissed&&this.q(e.gltf),Yn(o)&&this.R(e.gltf),a(null,e,r)})).catch((t=>{a(t)}))}else if("pnts"===r){const r=n.transform||Cn;this.P.load(e,t).then((t=>{const{content:e,transferables:o}=this.X(t,r,n.rootIdx);this.H(e),a(null,e,o)}))}else if("i3dm"===r){const r=n.transform||Cn;this.B.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:i}=this.J(t,r,n.rootIdx);o.createNormalIfMissed&&this.q(e.gltf),Yn(o)&&this.R(e.gltf),a(null,e,i)}))}else if("cmpt"===r){new re(this.U,An,this.u,o.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Y(t,n);this.K(e,o),Yn(o)&&this.Z(e),a(null,e,r)})).catch((t=>{a(t)}))}else if("gltf"===r){this.h||(this.h=Rt());const r=e.substring(0,e.lastIndexOf("/")),i=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t;let s;try{s=new An(r,i,{transferable:!0,requestImage:this.U,decoders:this.h,supportedFormats:this.u,maxTextureSize:o.maxTextureSize||0})}catch(t){a(t)}s.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.W(t,null,n),o.createNormalIfMissed&&this.q(t),Yn(o)&&this.R(t),a(null,{magic:"gltf",gltf:t},s.transferables)}))}else a(new Error("unsupported tile format: "+r))}K(t,e){t.content?t.content.forEach((t=>{this.K(t,e)})):e.createNormalIfMissed&&this.q(t.gltf)}Z(t){t.content?t.content.forEach((t=>{this.Z(t)})):this.R(t.gltf)}tt(t,e){if(this.et(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.nt()?Pn.subarray(0,n):e,a=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const a=yn;a.length<t.length/3&&(a.length=t.length/3),a.fill(0,0,t.length/3);const o=void 0===e.length?e:e.length;for(let n=0;n<o/3;n++)void 0===e.length?Mn(t,3*n,3*n+1,3*n+2,r,a):Mn(t,e[3*n],e[3*n+1],e[3*n+2],r,a);for(let t=0;t<r.length;t+=3){const e=a[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:a,byteLength:a.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:a.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}R(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const t in e){e[t].primitives.forEach((t=>{t.compressed_int16_params={};const e=t.attributes;for(const n in e)if(jn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=On,t.compressed_int16_params.compressed_ratio=r);const a=Xn(e[n].array,r,e[n].min,e[n].max,n);if(!a)continue;const{array:o,range:i}=a;e[n].componentType=5124,e[n].array=o,t.compressed_int16_params[n]=i}}))}}q(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach((e=>{this.tt(e,t)}))}}H(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(jn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=On,t.compressed_int16_params.compressed_ratio=r);const{array:a,range:o}=Xn(e[n].array,r,e[n].min,e[n].max,n);e[n].array=a,t.compressed_int16_params[n]=o}}rt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const a={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(a)}return e}G(t,e,n,r,a){return e.capabilities,void a(null,e)}Y(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},a=[];for(let t=0;t<n.length;t++){const{magic:o}=n[t];if("b3dm"===o){const{content:o,transferables:i}=this.$(n[t],e);Gn(a,i),r.content.push(o)}else if("i3dm"===o){const{transform:o,rootIdx:i}=e,{content:s,transferables:c}=this.J(n[t],o,i);Gn(a,c),r.content.push(s)}else if("pnts"===o){const{transform:o,rootIdx:i}=e,{content:s,transferables:c}=this.X(n[t],o,i);Gn(a,c),r.content.push(s)}else if("cmpt"===o){const{content:o,transferables:i}=this.Y(n[t],e);Gn(a,i),r.content.push(o)}}return{content:r,transferables:a}}$(t,e){const{gltf:n,transferables:r,featureTable:a}=t;return this.W(n,a,e),delete t.transferables,{content:t,transferables:r}}W(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;if(t.extensions&&t.extensions.KHR_techniques_webgl)return!0;const e="visited";let n=1;const r=[];for(const a in t.meshes){const o=t.meshes[a],{primitives:i}=o;if(i)for(let t=0;t<i.length;t++){const a=i[t].attributes&&i[t].attributes.POSITION;if(!a||!a.array)continue;a.array.buffer[e]||(a.array.buffer[e]=n++);const o=n-1+"-"+(a.byteOffset||0);if(r.indexOf(o)>=0)return!0;r.push(o)}}return!1}(t);this.ot(t);n.service.createNormalIfMissed||this.it(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.st(t,e,n.upAxis,n.transform)):this.ct(t,e,n.upAxis,n.transform)}J(t,e,n){const{featureTable:r}=t,a=t.i3dm,o=r&&r.RTC_CENTER||[0,0,0],i=this.options.projection,s=e&&c(Cn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Rn(a.POSITION.array,3,o,Cn,u);const l=Vn(u);e&&!s&&p(l,l,e);const f=this.ut(l),d=[];je(d,f,i),d[2]=f[2];const b=h([],l),m=[0,0,0],g=[0,0,0],v=[0,0],M=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0];ye(a.POSITION,(t=>{m[0]=t[0]+o[0],m[1]=t[1]+o[1],m[2]=t[2]+o[2],e&&!s&&p(m,m,e),0===w(m)?y(g,0,0,-6378137):Tt(g,m),je(v,g,i),t[0]=v[0]-d[0],t[1]=v[1]-d[1],t[2]=g[2]-d[2],t[0]<M[0]&&(M[0]=t[0]),t[1]<M[1]&&(M[1]=t[1]),t[2]<M[2]&&(M[2]=t[2]),t[0]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2])})),a.POSITION.min=M,a.POSITION.max=T,e&&p(l,l,e),t.rtcCenter=b,t.rtcCoord=f,t.projCenter=d,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}X(t,e,n){const{featureTable:r}=t,a=t.pnts,o=r&&r.RTC_CENTER||[0,0,0],i=this.options.projection,s=e&&c(Cn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Rn(a.POSITION.array,3,o,e,u);const l=Vn(u),f=this.lt(l),d=h([],l),b=[1/0,1/0,1/0],m=[-1/0,-1/0,-1/0];let g=[0,0,0,1];const v=[0,0,0],M=[0,0];ye(a.POSITION,(t=>(g[0]=t[0]+o[0],g[1]=t[1]+o[1],g[2]=t[2]+o[2],e&&!s&&(g=p(g,g,e)),0===w(g)?y(v,0,0,-6378137):Tt(v,g),je(M,v,i),t[0]=M[0]-f[0],t[1]=M[1]-f[1],t[2]=v[2]-f[2],t[0]<b[0]&&(b[0]=t[0]),t[1]<b[1]&&(b[1]=t[1]),t[2]<b[2]&&(b[2]=t[2]),t[0]>m[0]&&(m[0]=t[0]),t[1]>m[1]&&(m[1]=t[1]),t[2]>m[2]&&(m[2]=t[2]),t))),a.POSITION.min=b,a.POSITION.max=m,e&&p(l,l,e);const T=this.ut(l);t.rtcCenter=d,t.projCenter=f,t.rtcCoord=T,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}ot(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],a=n[1],o=n[2],i=n[3];let s=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==a||n[t+2]!==o||n[t+3]!==i){s=!1;break}s&&(e[t].image.color=[r/255,a/255,o/255,i/255],delete e[t].image.array)}}}it(t){const e=t.meshes;for(const n in e){const r=e[n];if(!r)continue;const a=r.primitives;if(a)for(let e=0;e<a.length;e++){if(!a[e])continue;if(!a[e].attributes||a[e].attributes.NORMAL)continue;const n=a[e].material;if(!ht(n)){const e=t.materials[n];if(!e)continue;e.extensions||(e.extensions={}),e.extensions.KHR_materials_unlit={}}}}}abortTileLoading(t,e){const n=this.L[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this.L[t.url],e(null)}ft(t,e,n,r){const a=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let o=kn;"X"===(n=n&&n.toUpperCase())?o=_n:"Z"===n&&(o=Cn),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),a&&(t.extensions.CESIUM_RTC.center=a),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};oe(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=i(Un);t.matrices&&$n(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;s(e,o,e),r&&s(e,r,e),Rn(n,u,a||En,e,c,t.compressUniforms)}));const u=Vn(c);return{rtcCenter:a,modelCenter:u,upAxisTransform:o}}st(t,e,n,r){const{modelCenter:a,upAxisTransform:o,rtcCenter:c}=this.ft(t,e,n),u=this.lt(a);t.extensions.MAPTALKS_RTC.projCenter=u,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ut(a);const l=h([],a);r&&p(a,a,r),t.extensions.CESIUM_RTC.rtcCoord=this.ut(a),c||(oe(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=i(Un);t.matrices&&$n(n,t.matrices),s(n,o,n);const r=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],s=e[5],c=e[6],u=e[7],l=e[8],f=e[9],h=e[10],y=e[11],d=e[12],b=e[13],m=e[14],p=e[15],g=n*s-r*i,v=n*c-a*i,w=n*u-o*i,M=r*c-a*s,T=r*u-o*s,A=a*u-o*c,k=l*b-f*d,_=l*m-h*d,O=l*p-y*d,S=f*m-h*b,x=f*p-y*b,F=h*p-y*m,I=g*F-v*x+w*S+M*O-T*_+A*k;return I?(I=1/I,t[0]=(s*F-c*x+u*S)*I,t[1]=(a*x-r*F-o*S)*I,t[2]=(b*A-m*T+p*M)*I,t[3]=(h*T-f*A-y*M)*I,t[4]=(c*O-i*F-u*_)*I,t[5]=(n*F-a*O+o*_)*I,t[6]=(m*w-d*A-p*v)*I,t[7]=(l*A-h*w+y*v)*I,t[8]=(i*x-s*O+u*k)*I,t[9]=(r*O-n*x-o*k)*I,t[10]=(d*T-b*w+p*g)*I,t[11]=(f*w-l*T-y*g)*I,t[12]=(s*_-i*S-c*k)*I,t[13]=(n*S-r*_+a*k)*I,t[14]=(b*v-d*M-m*g)*I,t[15]=(l*M-f*v+h*g)*I,t):null}(Nn,n),a=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];ye(e,(t=>{p(t,t,n),t[0]=t[0]-l[0],t[1]=t[1]-l[1],t[2]=t[2]-l[2],p(t,t,r),t[0]<a[0]&&(a[0]=t[0]),t[1]<a[1]&&(a[1]=t[1]),t[2]<a[2]&&(a[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=a,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=l)}ct(t,e,n,r){const{modelCenter:a,rtcCenter:o}=this.ft(t,e,n,r),i=this.lt(a);t.extensions.MAPTALKS_RTC.projCenter=i,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ut(a),oe(t,(e=>{if(e.attributes&&e.attributes.POSITION){const a=this.et(e,t);if(a){const t=e.attributes.POSITION.array.length;(!Pn||Pn.length<t)&&(Pn=new Float32Array(t))}e.attributes.NORMAL&&this.ht(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.ht(e.attributes.TANGENT,e.matrices,n);const{newPositions:i}=this.yt(e.attributes.POSITION,e.matrices,o,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,a),{componentType:s}=e.attributes.POSITION;5126!==s&&(e.attributes.POSITION.array=new Float32Array(i))}}));for(const e in t.nodes){t.nodes[e].matrix=Cn}}lt(t){const e=this.options.projection;"identity"===e?h(zn,t):0===w(t)?y(zn,0,0,-6378137):Tt(zn,t),je(Ln,zn,e);const n=zn[2],r=[];return r[0]=Ln[0],r[1]=Ln[1],r[2]=n,r}ht(t,e,n){let r;r="Y"===n?kn:"X"===n?_n:Cn;const a=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],r);if($n(a,e),c(a,Cn))return;const o=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}([],a),i=[];ye(t,(t=>(function(t,e,n){var r=e[0],a=e[1],o=e[2];t[0]=r*n[0]+a*n[3]+o*n[6],t[1]=r*n[1]+a*n[4]+o*n[7],t[2]=r*n[2]+a*n[5]+o*n[8]}(i,t,o),b(i,i),h(t,i),i)))}yt(t,e,n,r,a,o,s,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const l=i([]);$n(l,e);const f=this.options.projection;a=a&&a.toUpperCase();const h=n;let b=null;"Y"===a?b=kn:"X"===a&&(b=_n);let m=[0,0,0,1];const g=[0,0,0],v=[0,0],M=r.projCenter,T=je([],r.rtcCoord,"EPSG:3857"),A=o&&c(Cn,o),k=t.min=t.min||[],_=t.max=t.max||[];y(k,1/0,1/0,1/0),y(_,-1/0,-1/0,-1/0);const O=s||{},{decode_position_min:S,decode_position_normConstant:x}=O;let F=[0,0,0,0],I=1;S&&(F=S),x&&(I=x);const C=[];return ye(t,((e,n)=>{if(m[0]=e[0]*I+F[0],m[1]=e[1]*I+F[1],m[2]=e[2]*I+F[2],m=p(m,m,l),b&&(m=p(m,m,b)),h&&d(m,m,h),o&&!A&&(m=p(m,m,o)),0===w(m)?y(g,0,0,-6378137):Tt(g,m),u){const t=Pn;je(v,g,f),t[3*n]=v[0]-T[0],t[3*n+1]=v[0]-T[1],t[3*n+2]=v[0]-T[2]}if(je(v,g,f),e instanceof Float32Array)e[0]=v[0]-M[0],e[1]=v[1]-M[1],e[2]=g[2]-M[2];else{const n=v[0]-M[0],r=v[1]-M[1],a=g[2]-M[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(a),C.push(e[3]))}return e[0]<k[0]&&(k[0]=e[0]),e[1]<k[1]&&(k[1]=e[1]),e[2]<k[2]&&(k[2]=e[2]),e[0]>_[0]&&(_[0]=e[0]),e[1]>_[1]&&(_[1]=e[1]),e[2]>_[2]&&(_[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:M,newPositions:C}}ut(t){return 0===w(t)?y([],0,0,-6378137):Tt([],t)}onRemove(){}nt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}et(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material],r=n&&n.extensions&&n.extensions.KHR_materials_unlit;return r}(t,e))return!1;return!t.attributes.TANGENT}}const qn=[];function Rn(t,e,n,r,a,o){const i=o||{},{decode_position_min:s,decode_position_normConstant:c}=i;let u=[0,0,0,0],l=1;s&&(u=s),c&&(l=c);for(let o=0,i=t.length;o<i;o+=e){const{xmin:i,ymin:s,xmax:c,ymax:f,hmin:h,hmax:b}=a;y(qn,t[o]*l+u[0],t[o+1]*l+u[1],t[o+2]*l+u[2]),p(qn,qn,r);const m=d(qn,n,qn);m[0]<i&&(a.xmin=m[0]),m[0]>c&&(a.xmax=m[0]),m[1]<s&&(a.ymin=m[1]),m[1]>f&&(a.ymax=m[1]),e>2&&(m[2]<h&&(a.hmin=m[2]),m[2]>b&&(a.hmax=m[2]))}}function Vn(t){const{xmax:e,ymax:n,xmin:r,ymin:a,hmin:o,hmax:i}=t,s=[(r+e)/2,(a+n)/2,(o+i)/2];return e===-1/0&&(s[0]=0),n===-1/0&&(s[1]=0),i===-1/0&&(s[2]=0),isNaN(s[2])&&(s[2]=0),s}function Gn(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function $n(t,e){const n=t;for(let t=e.length-1;t>=0;t--)s(n,e[t],n);return n}function Xn(t,e,n,r,a){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let o,i;if(n&&r&&1===e)o=Math.min(...n),i=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);o=e,i=n}return!function(t,e,n,r){for(let a=0;a<t.length;a++){const o=Hn(Jn(t[a],e,n),e,n);if(Math.abs(o-t[a])>Dn[r])return!1}return!0}(t,o,i,a)&&Dn[a]?null:function(t,e,n){const r=new Int16Array(t.length);for(let a=0;a<t.length;a++)r[a]=Jn(t[a],e,n);return{array:r,range:[e,n]}}(t,o,i)}function Hn(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function Jn(t,e,n){const r=2*(t-e)/(n-e)-1,a=Math.max(-1,Math.min(1,r));return a<0?32768*a:32767*a}function Yn(t){return void 0===t.compressGeometry||t.compressGeometry}let Kn=0;class Qn{constructor(t){this.workerId=t,this.workers={},this.dt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},a){if(this.bt(e,n))return;const o=this.gt(e,n),i=r.options;this.workers[o]=new Bn(n,i,((...e)=>this.send.call(this,t,...e)),a)}removeLayer({mapId:t,layerId:e},n){const r=this.bt(t,e),a=this.gt(t,e);delete this.workers[a],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const a=this.bt(t,e);a&&a.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const a=this.bt(t,e);a&&a.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.dt[e];delete this.dt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,a){const o=a?\`${o}t}-${o}Kn++}\`:null;a&&(this.dt[o]=a),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(o)},r||[])}gt(t,e){return\`${o}t}-${o}e}\`}bt(t,e){const n=this.gt(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Qn(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},((t,n,r)=>{t&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}`
|
|
7
7
|
/*!
|
|
8
8
|
* Contains code from THREE.js
|
|
9
9
|
* MIT License
|
|
10
10
|
* https://github.com/mrdoob/three.js
|
|
11
11
|
*/;for(var c=[],l=0;l<6;l++)c[l]=[];var u=[];function h(t,e,n){M(t);for(var r=0;r<6;r++){var i=c[r];if(u[0]=i[0]>0?e[1][0]:e[0][0],u[1]=i[1]>0?e[1][1]:e[0][1],u[2]=i[2]>0?e[1][2]:e[0][2],O(i,u)<0)return!1}return!0}var f=3,d=4,m=5,y=6,p=7,b=8,g=9,v=10,w=11;function T(t,e){var n=e,r=t,i=e,s=r[0],o=r[1],a=r[2],c=Math.abs(s*i[f]+o*i[d]+a*i[m])+Math.abs(s*i[y]+o*i[p]+a*i[b])+Math.abs(s*i[g]+o*i[v]+a*i[w]),l=O(t,n);return!(l<=-c)}function M(t){var e=t,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],h=e[8],f=e[9],d=e[10],m=e[11],y=e[12],p=e[13],b=e[14],g=e[15];_(c[0],s-n,u-o,m-h,g-y),_(c[1],s+n,u+o,m+h,g+y),_(c[2],s+r,u+a,m+f,g+p),_(c[3],s-r,u-a,m-f,g-p),_(c[4],s-i,u-l,m-d,g-b),_(c[5],s+i,u+l,m+d,g+b)}function _(t,e,n,r,i){var s=1/Math.sqrt(e*e+n*n+r*r);return t[0]=e*s,t[1]=n*s,t[2]=r*s,t[3]=i*s,t}function O(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var x={exports:{}},I={exports:{}},S=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},C=Array.prototype.concat,k=Array.prototype.slice,N=I.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];S(i)?e=C.call(e,k.call(i)):e.push(i)}return e};N.wrap=function(t){return function(){return t(N(arguments))}};var L=I.exports,E={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},R=L,P=Object.hasOwnProperty,U=Object.create(null);for(var B in E)P.call(E,B)&&(U[E[B]]=B);var F=x.exports={to:{},get:{}};function G(t,e,n){return Math.min(Math.max(e,t),n)}function D(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}F.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=F.get.hsl(t),n="hsl";break;case"hwb":e=F.get.hwb(t),n="hwb";break;default:e=F.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},F.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var s=2*n;i[n]=parseInt(e.slice(s,s+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:P.call(E,e[1])?((i=E[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=G(i[n],0,255);return i[3]=G(i[3],0,1),i},F.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,G(parseFloat(e[2]),0,100),G(parseFloat(e[3]),0,100),G(isNaN(n)?1:n,0,1)]}return null},F.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,G(parseFloat(e[2]),0,100),G(parseFloat(e[3]),0,100),G(isNaN(n)?1:n,0,1)]}return null},F.to.hex=function(){var t=R(arguments);return"#"+D(t[0])+D(t[1])+D(t[2])+(t[3]<1?D(Math.round(255*t[3])):"")},F.to.rgb=function(){var t=R(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},F.to.rgb.percent=function(){var t=R(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},F.to.hsl=function(){var t=R(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},F.to.hwb=function(){var t=R(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},F.to.keyword=function(t){return U[t.slice(0,3)]};var j=x.exports,z={exports:{}},H={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},q={};for(var $ in H)H.hasOwnProperty($)&&(q[H[$]]=$);var V=z.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var J in V)if(V.hasOwnProperty(J)){if(!("channels"in V[J]))throw new Error("missing channels property: "+J);if(!("labels"in V[J]))throw new Error("missing channel labels property: "+J);if(V[J].labels.length!==V[J].channels)throw new Error("channel and label counts mismatch: "+J);var Y=V[J].channels,Z=V[J].labels;delete V[J].channels,delete V[J].labels,Object.defineProperty(V[J],"channels",{value:Y}),Object.defineProperty(V[J],"labels",{value:Z})}V.rgb.hsl=function(t){var e,n,r=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(r,i,s),a=Math.max(r,i,s),c=a-o;return a===o?e=0:r===a?e=(i-s)/c:i===a?e=2+(s-r)/c:s===a&&(e=4+(r-i)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},V.rgb.hsv=function(t){var e,n,r,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,l=Math.max(o,a,c),u=l-Math.min(o,a,c),h=function(t){return(l-t)/6/u+.5};return 0===u?i=s=0:(s=u/l,e=h(o),n=h(a),r=h(c),o===l?i=r-n:a===l?i=1/3+e-r:c===l&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*l]},V.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[V.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},V.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-i)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-i-e)/(1-e)||0),100*e]},V.rgb.keyword=function(t){var e=q[t];if(e)return e;var n,r,i,s=1/0;for(var o in H)if(H.hasOwnProperty(o)){var a=H[o],c=(r=t,i=a,Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2)+Math.pow(r[2]-i[2],2));c<s&&(s=c,n=o)}return n},V.keyword.rgb=function(t){return H[t]},V.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},V.rgb.lab=function(t){var e=V.rgb.xyz(t),n=e[0],r=e[1],i=e[2];return r/=100,i/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},V.hsl.rgb=function(t){var e,n,r,i,s,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[s=255*c,s,s];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),i=[0,0,0];for(var l=0;l<3;l++)(r=o+1/3*-(l-1))<0&&r++,r>1&&r--,s=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,i[l]=255*s;return i},V.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,i=n,s=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,i*=s<=1?s:2-s,[e,100*(0===r?2*i/(s+i):2*n/(r+n)),100*((r+n)/2)]},V.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*s),c=255*r*(1-n*(1-s));switch(r*=255,i){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},V.hsv.hsl=function(t){var e,n,r,i=t[0],s=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-s)*o,n=s*a,[i,100*(n=(n/=(e=(2-s)*a)<=1?e:2-e)||0),100*(r/=2)]},V.hwb.rgb=function(t){var e,n,r,i,s,o,a,c=t[0]/360,l=t[1]/100,u=t[2]/100,h=l+u;switch(h>1&&(l/=h,u/=h),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),i=l+r*((n=1-u)-l),e){default:case 6:case 0:s=n,o=i,a=l;break;case 1:s=i,o=n,a=l;break;case 2:s=l,o=n,a=i;break;case 3:s=l,o=i,a=n;break;case 4:s=i,o=l,a=n;break;case 5:s=n,o=l,a=i}return[255*s,255*o,255*a]},V.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},V.xyz.rgb=function(t){var e,n,r,i=t[0]/100,s=t[1]/100,o=t[2]/100;return n=-.9689*i+1.8758*s+.0415*o,r=.0557*i+-.204*s+1.057*o,e=(e=3.2406*i+-1.5372*s+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},V.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},V.lab.xyz=function(t){var e,n,r,i=t[0];e=t[1]/500+(n=(i+16)/116),r=n-t[2]/200;var s=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=s>.008856?s:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},V.lab.lch=function(t){var e,n=t[0],r=t[1],i=t[2];return(e=360*Math.atan2(i,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+i*i),e]},V.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},V.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],i=1 in arguments?arguments[1]:V.rgb.hsv(t)[2];if(0===(i=Math.round(i/50)))return 30;var s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===i&&(s+=60),s},V.hsv.ansi16=function(t){return V.rgb.ansi16(V.hsv.rgb(t),t[2])},V.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},V.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},V.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},V.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},V.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},V.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255,s=Math.max(Math.max(n,r),i),o=Math.min(Math.min(n,r),i),a=s-o;return e=a<=0?0:s===n?(r-i)/a%6:s===r?2+(i-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},V.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,i=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},V.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},V.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var i,s=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0;break;case 1:s[0]=c,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=a;break;case 3:s[0]=0,s[1]=c,s[2]=1;break;case 4:s[0]=a,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=c}return i=(1-n)*r,[255*(n*s[0]+i),255*(n*s[1]+i),255*(n*s[2]+i)]},V.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},V.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},V.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},V.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},V.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},V.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},V.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},V.gray.hsl=V.gray.hsv=function(t){return[0,0,t[0]]},V.gray.hwb=function(t){return[0,100,t[0]]},V.gray.cmyk=function(t){return[0,0,0,t[0]]},V.gray.lab=function(t){return[t[0],0,0]},V.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},V.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var K=z.exports,X=K;function W(t){var e=function(){for(var t={},e=Object.keys(X),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),i=Object.keys(X[r]),s=i.length,o=0;o<s;o++){var a=i[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function Q(t,e){return function(n){return e(t(n))}}function tt(t,e){for(var n=[e[t].parent,t],r=X[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=Q(X[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var et=K,nt=function(t){for(var e=W(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s];null!==e[o].parent&&(n[o]=tt(o,e))}return n},rt={};Object.keys(et).forEach((function(t){rt[t]={},Object.defineProperty(rt[t],"channels",{value:et[t].channels}),Object.defineProperty(rt[t],"labels",{value:et[t].labels});var e=nt(t);Object.keys(e).forEach((function(n){var r=e[n];rt[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,i=0;i<r;i++)n[i]=Math.round(n[i]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),rt[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var it=j,st=rt,ot=[].slice,at=["keyword","gray","hex"],ct={};Object.keys(st).forEach((function(t){ct[ot.call(st[t].labels).sort().join("")]=t}));var lt={};function ut(t,e){if(!(this instanceof ut))return new ut(t,e);if(e&&e in at&&(e=null),e&&!(e in st))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ut)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=it.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=st[this.model].channels,this.color=i.value.slice(0,r),this.valpha="number"==typeof i.value[r]?i.value[r]:1}else if(t.length){this.model=e||"rgb",r=st[this.model].channels;var s=ot.call(t,0,r);this.color=dt(s,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ct))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ct[a];var c=st[this.model].labels,l=[];for(n=0;n<c.length;n++)l.push(t[c[n]]);this.color=dt(l)}if(lt[this.model])for(r=st[this.model].channels,n=0;n<r;n++){var u=lt[this.model][n];u&&(this.color[n]=u(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ht(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(lt[t]||(lt[t]=[]))[e]=n})),t=t[0],function(r){var i;return arguments.length?(n&&(r=n(r)),(i=this[t]()).color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function ft(t){return function(e){return Math.max(0,Math.min(t,e))}}function dt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}ut.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in it.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return it.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return it.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=st[this.model].channels,n=st[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ut(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ut(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ht("rgb",0,ft(255)),green:ht("rgb",1,ft(255)),blue:ht("rgb",2,ft(255)),hue:ht(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ht("hsl",1,ft(100)),lightness:ht("hsl",2,ft(100)),saturationv:ht("hsv",1,ft(100)),value:ht("hsv",2,ft(100)),chroma:ht("hcg",1,ft(100)),gray:ht("hcg",2,ft(100)),white:ht("hwb",1,ft(100)),wblack:ht("hwb",2,ft(100)),cyan:ht("cmyk",0,ft(100)),magenta:ht("cmyk",1,ft(100)),yellow:ht("cmyk",2,ft(100)),black:ht("cmyk",3,ft(100)),x:ht("xyz",0,ft(100)),y:ht("xyz",1,ft(100)),z:ht("xyz",2,ft(100)),l:ht("lab",0,ft(100)),a:ht("lab",1),b:ht("lab",2),keyword:function(t){return arguments.length?new ut(t):st[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ut(t):it.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ut.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),i=void 0===e?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,c=1-a;return ut.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*i+r.alpha()*(1-i))}},Object.keys(st).forEach((function(t){if(-1===at.indexOf(t)){var e=st[t].channels;ut.prototype[t]=function(){if(this.model===t)return new ut(this);if(arguments.length)return new ut(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ut((n=st[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ut[t]=function(n){return"number"==typeof n&&(n=dt(ot.call(arguments),e)),new ut(n,t)}}}));var mt=A(ut);function yt(t){return null==t}function pt(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 bt(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function gt(t){return"object"==typeof t&&!!t}function vt(t){return"number"==typeof t&&!isNaN(t)}function wt(t){return t*Math.PI/180}function Tt(t){return t/Math.PI*180}function Mt(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function _t(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const Ot=[1,1,1,1,2,2,3,0];function At(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=Ot[i>>3&7];if(!(64&i)||!n||r+n>e)return null;for(i&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;i=i<<6|63&e}}n+=String.fromCharCode(i)}return n}function xt(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function It(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function St(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function Ct(t){return 0===t.indexOf("data:")}function kt(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),i=r.length,s=new Uint8Array(i);for(let t=0;t<i;t++)s[t]=r.charCodeAt(t);return s.buffer}function Nt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}const Lt={};function Et(t,e){if(!Array.isArray(e)){const t=e;e=Lt[t]=Lt[t]||mt(e).array().map((t=>t/255))}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Rt=Object.freeze({__proto__:null,base64URLToArrayBuffer:kt,extend:pt,flatArr:It,getAbsoluteURL:Mt,getBatchIdArrayType:St,isBase64:Ct,isFunction:bt,isNil:yt,isNumber:vt,isObject:gt,normalizeColor:Et,pushIn:Nt,setColumn3:xt,sign:_t,stringFromUTF8Array:At,toDegree:Tt,toRadian:wt});function Pt(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Ut(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}const Bt=function(){if("undefined"!=typeof globalThis)return globalThis;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")},Ft=Bt(),Gt=Ft.gl_trans__coders=Ft.gl_trans__coders||{};
|
|
12
12
|
/*!
|
|
13
|
-
* @maptalks/gl v0.
|
|
13
|
+
* @maptalks/gl v0.124.0
|
|
14
14
|
* LICENSE : UNLICENSED
|
|
15
15
|
* (c) 2016-2026 maptalks.com
|
|
16
|
-
*/function Dt(){return Bt().maptalks_gltf_loader}Gt.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=Ft.gl_trans__coders=Ft.gl_trans__coders||{};let s=`${r}\n const _____getGlobal = ${Bt.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\n;");return s+="\n("+Bt().maptalks_gltf_loader_bundle.toString()+")({});\n",s+="\n"+e.substring(r.length),s},Gt.registerTranscoder=function(t,e){Gt[t]=e},Gt.getTranscoder=function(t){return Gt[t]};const jt="undefined"==typeof document?null:document.createElement("canvas");class zt extends i.worker.Actor{constructor(t,e,n){super(t),this.mapId=e,this.i=n}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const i={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(i,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(!jt)return void e(new Error("There is no canvas to draw image!"));const t=this.i?n:function(t){if(Ht(t.width)&&Ht(t.height))return t;let e=t.width,n=t.height;Ht(e)||(e=qt(e));Ht(n)||(n=qt(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const i=t.src,s=i.lastIndexOf("/")+1,o=i.substring(s);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);jt.width=t.width,jt.height=t.height;const r=jt.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),s={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,s,[s.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function Ht(t){return!(t&t-1)&&0!==t}function qt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var $t=1e-6,Vt="undefined"!=typeof Float32Array?Float32Array:Array;function Jt(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],h=e[8],f=e[9],d=e[10],m=e[11],y=e[12],p=e[13],b=e[14],g=e[15],v=n[0],w=n[1],T=n[2],M=n[3];return t[0]=v*r+w*a+T*h+M*y,t[1]=v*i+w*c+T*f+M*p,t[2]=v*s+w*l+T*d+M*b,t[3]=v*o+w*u+T*m+M*g,v=n[4],w=n[5],T=n[6],M=n[7],t[4]=v*r+w*a+T*h+M*y,t[5]=v*i+w*c+T*f+M*p,t[6]=v*s+w*l+T*d+M*b,t[7]=v*o+w*u+T*m+M*g,v=n[8],w=n[9],T=n[10],M=n[11],t[8]=v*r+w*a+T*h+M*y,t[9]=v*i+w*c+T*f+M*p,t[10]=v*s+w*l+T*d+M*b,t[11]=v*o+w*u+T*m+M*g,v=n[12],w=n[13],T=n[14],M=n[15],t[12]=v*r+w*a+T*h+M*y,t[13]=v*i+w*c+T*f+M*p,t[14]=v*s+w*l+T*d+M*b,t[15]=v*o+w*u+T*m+M*g,t}function Yt(){var t=new Vt(3);return Vt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Zt(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function Kt(t,e,n){var r=new Vt(3);return r[0]=t,r[1]=e,r[2]=n,r}function Xt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Wt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function Qt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function te(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function ee(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function ne(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function re(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ie(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[0],a=n[1],c=n[2];return t[0]=i*c-s*a,t[1]=s*o-r*c,t[2]=r*a-i*o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var se=Qt,oe=te,ae=Zt;function ce(){var t=new Vt(4);return Vt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}Yt(),function(){var t,e=(t=new Vt(4),Vt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var le;Yt(),Kt(1,0,0),Kt(0,1,0),ce(),ce(),le=new Vt(9),Vt!=Float32Array&&(le[1]=0,le[2]=0,le[3]=0,le[5]=0,le[6]=0,le[7]=0),le[0]=1,le[4]=1,le[8]=1;const{GLTFLoader:ue}=Dt();function he(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,i=r.length;n<i;n++){const i=[];ge(r[n],i,t,e)}}}const fe=[],de=[],me=[],ye=[0,0,0],pe=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),be=[1,1,1];function ge(t,e,n,r){const i=e.slice(0);if(t.matrix)i.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(fe,t.translation||ye),n=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,l=n*o,u=r*o,h=r*a,f=i*o,d=i*a,m=i*c,y=s*o,p=s*a,b=s*c;return t[0]=1-h-m,t[1]=u+b,t[2]=f-p,t[3]=0,t[4]=u-b,t[5]=1-l-m,t[6]=d+y,t[7]=0,t[8]=f+p,t[9]=d-y,t[10]=1-l-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(de,t.rotation||pe),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(me,t.scale||be);Jt(r,n,r);const s=Jt([],e,r);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)ge(t.children[e],i,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,r(s,e,i,n))}}}}function ve(t,e,n){let{byteOffset:r,byteStride:i}=e;const{componentType:s,itemSize:o}=e,a=e.array.buffer,c=s?ue.getTypedArrayCtor(s):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,i=i||0,!i||i===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}i||(i=o*c.BYTES_PER_ELEMENT);const l=new Uint8Array(a,i*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(l),t}function we(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}var Te="#include <gl2_vert>\nconst float SHIFT_RIGHT_11 = 1.0 / 2048.0;\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\nconst float SHIFT_LEFT_11 = 2048.0;\nconst float SHIFT_LEFT_5 = 32.0;\nconst float NORMALIZE_6 = 1.0 / 64.0;\nconst float NORMALIZE_5 = 1.0 / 32.0;\n#ifdef HAS_POSITION\n attribute vec3 POSITION;\n#endif\n#if defined(HAS_RGB)\n attribute vec3 RGB;\n#elif defined(HAS_RGBA)\n attribute vec4 RGBA;\n#elif defined(HAS_RGB565)\n attribute float RGB565;\n#endif\nuniform vec4 pointColor;\nuniform float pointSize;\nuniform mat4 projViewModelMatrix;\nuniform float pointOpacity;\nvarying vec4 vColor;\n#ifdef HAS_NORMAL\n #ifdef HAS_NORMAL_OCT16P\n attribute vec2 NORMAL_OCT16P;\n float signNotZero(float value) {\n return value >= 0.0 ? 1.0 : -1.0;\n }\n vec2 signNotZero(vec2 value) {\n return vec2(signNotZero(value.x), signNotZero(value.y));\n }\n vec3 octDecode(vec2 encoded, float range) {\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n return vec3(0.0, 0.0, 0.0);\n }\n encoded = encoded / range * 2.0 - 1.0;\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n if (v.z < 0.0) {\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n }\n return normalize(v);\n }\n vec3 octDecode(vec2 encoded) {\n return octDecode(encoded, 255.0);\n }\n #else\n attribute vec3 NORMAL;\n #endif\n uniform vec3 lightDir;\n uniform mat3 modelNormalMatrix;\n uniform mat4 positionMatrix;\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n return max(dot(-lightDir, normal), 0.0);\n }\n#endif\n#ifdef PICKING_MODE\n #include <fbo_picking_vert>\n#endif\n#include <draco_decode_vert>\nvoid main() {\n #ifdef HAS_POSITION\n vec3 localPos = decode_getPosition(POSITION);\n #endif\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n gl_PointSize = pointSize;\n #ifdef PICKING_MODE\n fbo_picking_setData(gl_Position.w, true);\n #else\n #if defined(HAS_RGB)\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n #elif defined(HAS_RGBA)\n vColor = RGBA / 255.0 * pointOpacity;\n #elif defined(HAS_RGB565)\n float compressed = RGB565;\n float r = floor(compressed * SHIFT_RIGHT_11);\n compressed -= r * SHIFT_LEFT_11;\n float g = floor(compressed * SHIFT_RIGHT_5);\n compressed -= g * SHIFT_LEFT_5;\n float b = compressed;\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n vColor = vec4(rgb, 1.0);\n #else\n vColor = pointColor;\n #endif\n #ifdef HAS_NORMAL\n mat3 positionNormalMatrix = mat3(positionMatrix);\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n #ifdef HAS_NORMAL_OCT16P\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n #else\n vec3 localNormal = NORMAL;\n #endif\n vec3 normal = normalize(normalMatrix * localNormal);\n float colorStrength = getLambertDiffuse(lightDir, normal);\n colorStrength = max(colorStrength, 0.5);\n vColor *= colorStrength;\n #endif\n #endif\n}\n";const Me=new Array(3),_e=new Array(3),Oe=[40680631590769,40680631590769,40408299984661.445];function Ae(t,e,n,r){const i=Oe,s=Math.cos(n);Me[0]=s*Math.cos(e),Me[1]=s*Math.sin(e),Me[2]=Math.sin(n),Ue(Me,Me),te(_e,i,Me);const o=Math.sqrt(re(Me,_e));var a,c,l;return c=_e,l=o,(a=_e)[0]=c[0]/l,a[1]=c[1]/l,a[2]=c[2]/l,ee(Me,Me,r),function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}(t,_e,Me)}const xe=[1/6378137,1/6378137,1/6356752.314245179],Ie=[1/40680631590769,1/40680631590769,1/40408299984661.445],Se=new Array(3),Ce=new Array(3),ke=new Array(3);function Ne(t,e){const n=Ie,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],l=n[1],u=n[2],h=s*s*c*c,f=o*o*l*l,d=a*a*u*u,m=h+f+d,y=Math.sqrt(1/m),p=ee(Le,e,y);if(m<i)return isFinite(y)?p:void 0;const b=r[0],g=r[1],v=r[2],w=Ee;w[0]=p[0]*b*2,w[1]=p[1]*g*2,w[2]=p[2]*v*2;let T,M,_,O,A,x,I,S,C,k,N,L=(1-y)*Pe(e)/(.5*Pe(w)),E=0;do{L-=E,_=1/(1+L*b),O=1/(1+L*g),A=1/(1+L*v),x=_*_,I=O*O,S=A*A,C=x*_,k=I*O,N=S*A,T=h*x+f*I+d*S-1,M=h*C*b+f*k*g+d*N*v;E=T/(-2*M)}while(Math.abs(T)>Re);return t[0]=s*_,t[1]=o*O,t[2]=a*A,t}(Se,e,xe,n,.1);let i=oe(Ce,r,n);i=Ue(i,i);const s=se(ke,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=_t(re(s,e))*Pe(s);return t[0]=Tt(o),t[1]=Tt(a),t[2]=c,t}const Le=new Array(3),Ee=new Array(3),Re=1e-12;function Pe(t){return Zt(t)}function Ue(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function Be(t,e){return te(e,t,Ie),ne(e,e)}function Fe(t,e){const n=t[0],r=t[1],i=Math.cos(r),s=i*Math.cos(n),o=i*Math.sin(n),a=Math.sin(r);return e.x=s,e.y=o,e.z=a,ne(e,e)}var Ge=Object.freeze({__proto__:null,cartesian3ToDegree:Ne,geodeticSurfaceNormal:Be,geodeticSurfaceNormalCartographic:Fe,normalizeCartesian:Ue,radianToCartesian3:Ae});function De(t,e,n,r){n=n||0,r=r||n;const i=Math.abs(t-e);return i<=r||i<=n*Math.max(Math.abs(t),Math.abs(e))}function je(t,e){let n="";for(let r=0;r<4;r++){const i=t.getUint8(e+r);n+=String.fromCharCode(i)}return n}const ze="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function He(t,e,n){const r=new Uint8Array(t,e,n);return ze?JSON.parse(ze.decode(r)):JSON.parse(At(r))}function qe(t,e,n){const r=new Uint8Array(t,e,n);return ze?JSON.parse(ze.decode(r)):JSON.parse(At(r))}function $e(t,e,n){return{offset:e,byteLength:n}}function Ve(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=We(s||"UNSIGNED_SHORT"),l=Ke(o);return{byteStride:0,byteOffset:i+n,itemSize:l,count:r*l,componentType:c,array:new a(e,n+i,r*l)}}function Je(t,e,n,r){const i=Ve(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}function Ye(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a}=We(s||"UNSIGNED_SHORT"),c=Ke(o),l=new a(e,i,n*c);return 1===c?l[r]:l.subarray(r*c,r*c+c)}const Ze={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ke(t){return t?Ze[t]:1}const Xe={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function We(t){return Xe[t]}function Qe(t){for(const e in Xe)if(t===Xe[e].ctor)return Xe[e].type;throw new Error("unrecognized ctor:"+t)}function tn(t,e,n,r){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*r[0]+n[0],i[3*t+1]=e[3*t+1]/65535*r[1]+n[1],i[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return i}function en(t,e,n){const r=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,l={},u={},h=null;r>0&&(l=He(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(u=qe(a,e,s),e+=s);const f=$e(0,e,o);return h=a.slice(f.offset,f.offset+f.byteLength),n.push(h),{featureTable:l,featureTableBin:c,batchTable:u,batchTableBin:h}}const nn={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"}},rn={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},sn={},on={east:[],north:[],up:[],west:[],south:[],down:[]};let an=[],cn=[],ln=[];const un=[0,0,0];function hn(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 fn=function(t,e){const n=nn[t][e];let r;const i=t+e;return sn[i]?r=sn[i]:(r=function(r,i,s){if(a=un,c=(o=r)[0],l=o[1],u=o[2],h=a[0],f=a[1],d=a[2],Math.abs(c-h)<=$t*Math.max(1,Math.abs(c),Math.abs(h))&&Math.abs(l-f)<=$t*Math.max(1,Math.abs(l),Math.abs(f))&&Math.abs(u-d)<=$t*Math.max(1,Math.abs(u),Math.abs(d)))Xt(an,rn[t]),Xt(cn,rn[e]),Xt(ln,rn[n]);else if(De(r[0],0,1e-14)&&De(r[1],0,1e-14)){const i=_t(r[2]);Xt(an,rn[t]),Xt(cn,rn[e]),ee(cn,cn,i),Xt(ln,rn[n]),ee(ln,ln,i)}else{Be(r,on.up);const i=on.up,s=on.east;s[0]=-r[1],s[1]=r[0],s[2]=0,ne(on.east,s),ie(on.north,i,s),ee(on.down,on.up,-1),ee(on.west,on.east,-1),ee(on.south,on.north,-1),an=on[t],cn=on[e],ln=on[n]}var o,a,c,l,u,h,f,d;return s[0]=an[0],s[1]=an[1],s[2]=an[2],s[3]=0,s[4]=cn[0],s[5]=cn[1],s[6]=cn[2],s[7]=0,s[8]=ln[0],s[9]=ln[1],s[10]=ln[2],s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s},sn[i]=r),r}("east","north"),dn=[],mn=[],yn=[],pn=[],bn=[],gn=[],vn=[],wn={x:0,y:0},Tn={x:0,y:0},Mn=Math.PI/180;let _n;const On={width:100,height:10};let An=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),An=!0}catch(t){An=!1}function xn(){if(!_n){const{width:t,height:e}=On;An?_n=new OffscreenCanvas(t,e):(_n=document.createElement("canvas"),_n.width=t,_n.height=e)}return _n}class In{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e][0];n=Math.min(i,n),r=Math.max(i,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},On,e),this.o()}getImageData(){return this.imgData}o(){const t=xn(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const i=r.createLinearGradient(0,0,t.width,0),{colors:s,valueOffset:o}=this;for(let t=0,e=s.length;t<e;t++){const[e,n]=s[t],r=(e-this.min)/o;i.addColorStop(r,n)}r.fillStyle=i,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var Sn;function Cn(t){return null==t}function kn(t){return!Cn(t)}function Nn(t){return""===t}function Ln(t,e){var n,r,i;if(zn(t)){var s,o=t.stops&&"object"==typeof t.stops[0][0],a=o||kn(t.property),c=o||!a,l=t.type||e||"exponential";if("exponential"===l)s=Pn;else if("interval"===l)s=Rn;else if("categorical"===l)s=En;else if("identity"===l)s=Fn;else if("color-interpolate"===l)s=Bn;else{if("calculate-expression"!==l)throw new Error('Unknown function type "'+l+'"');s=Gn}if(o){var u={},h=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===u[f[0].zoom]&&(u[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),u[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in u)h.push([u[t].zoom,Ln(u[t])]);n=function(e,n){const r=Pn({stops:h,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,i=!1}else c?(n=function(e){const n=s(t,e);return"function"==typeof n?n(e):n},r=!0,i=!1):(n=function(e,n){const r=s(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,i=!0)}else n=function(){return t},r=!0,i=!0;return n.isZoomConstant=i,n.isFeatureConstant=r,n}function En(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function Rn(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function Pn(t,e){for(var n=kn(t.base)&&!Nn(t.base)?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:Dn(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(Sn=new Map);const Un={width:100,height:1};function Bn(t,e){const n=t.stops;if(n&&n.length>1){let t;if(Sn){const e=JSON.stringify(n);if(!Sn.has(e)){const t=new In(n,Un);Sn.set(e,t)}t=Sn.get(e)}else t=new In(n,Un);const[r,i,s,o]=t.getColor(e);return[r/255,i/255,s/255,o/255]}return n&&1===n.length?n[0][1]:null}function Fn(t,e){return n=e,r=t.default,kn(n)?n:kn(r)?r:kn(i)?i:null;var n,r,i}function Gn(t,e){const n=String(t.property),r=t.expression,i=e;function s(e){return Cn(e)||Nn(e)||isNaN(e)?t.default:e}if(!kn(e)||Nn(e)||isNaN(e)||e<0)return s(t.default);{const e=function t(e,n,r){const i=Number(r),s=String(n);return Array.isArray(e)?e.map((e=>t(e,s,i))):e===s?i:e}(r,n,i);return s(function e(n){if(!Array.isArray(n)){if("number"==typeof n)return n;throw new Error("Invalid expression format")}{const r=n[0];if(!["+","-","*","/"].includes(r))throw new Error(`Unknown operator: ${r}`);const i=n.slice(1).map((t=>e(t)));switch(r){case"+":return i.reduce(((t,e)=>t+e),0);case"-":return i.reduce(((t,e)=>t-e));case"*":return i.reduce(((t,e)=>t*e),1);case"/":return i.some((t=>0===t))?t.default:i.reduce(((t,e)=>t/e));default:throw new Error(`Unsupported operator: ${r}`)}}}(e))}}function Dn(t,e,n,r,i,s){return"function"==typeof i?function(){var o=i.apply(void 0,arguments),a=s.apply(void 0,arguments);return Dn(t,e,n,r,o,a)}:i.length?function(t,e,n,r,i,s){var o=[];for(let a=0;a<i.length;a++)o[a]=jn(t,e,n,r,i[a],s[a]);return o}(t,e,n,r,i,s):jn(t,e,n,r,i,s)}function jn(t,e,n,r,i,s){var o,a=r-n,c=t-n;return i*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+s*o}function zn(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type||t.expression&&"calculate-expression"===t.type)}function Hn(t){return qn(t,"exponential")}function qn(t,e){if(!zn(t))return function(){return t};let n=!0,r=!0;const i=(t=JSON.parse(JSON.stringify(t))).stops;if(i)for(let t=0;t<i.length;t++)if(zn(i[t][1])){const s=qn(i[t][1],e);n=n&&s.isZoomConstant,r=r&&s.isFeatureConstant,i[t]=[i[t][0],s]}const s=Ln(t,e);return s.isZoomConstant=n&&s.isZoomConstant,s.isFeatureConstant=r&&s.isFeatureConstant,s}const{getTextureMagFilter:$n,getTextureMinFilter:Vn,getTextureWrap:Jn,getMaterialType:Yn,getMaterialFormat:Zn,getPrimitive:Kn,getUniqueREGLBuffer:Xn,getArrayType:Wn}=n.reshader.REGLHelper,Qn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],tr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:er,logoutIBLResOnCanvas:nr,getIBLResOnCanvas:rr,getPBRUniforms:ir}=n.reshader.pbr.PBRUtils,sr={factor:0,units:0},or=[1,1,1,1],ar=[0,0,0],cr={specularStrength:0,materialShininess:1},lr=[1,1,1],ur=n.mat4.identity([]),hr=[0,0,0],fr=[0,0],dr=[],mr=t=>t.material instanceof n.reshader.PhongMaterial,yr=t=>t.material instanceof n.reshader.pbr.StandardMaterial,pr=[],br=new i.Coordinate(0,0),gr=new i.Point(0,0),vr=new i.Point(0,0),wr=new i.Point(0,0),Tr=[],Mr=[],_r=[],Or=[],Ar=[],xr=[],Ir=[],Sr=[],Cr=[],kr=[],Nr=[],Lr=[],Er=[],Rr=[],Pr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},Ur=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],Br=function(t,e){const n=2*Math.PI/t,r=[],i=[];for(let i=0;i<=t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=s,r[3*i+2]=o}for(let i=t;i<=2*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=o,r[3*i+1]=t,r[3*i+2]=s}for(let i=2*t;i<=3*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=o,r[3*i+2]=s}const s=r.length/3-1;for(let e=0;e<s;e++)e!==t-1&&e!==2*t-1&&(i[2*e]=e,i[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),i.push(s+1,s+2),i.push(s+1,s+3),i.push(s+1,s+4),{vertices:r,indices:i}}(100,1),Fr=[0,0,0,1],Gr=[1,1,1];class Dr{constructor(t,e){this.u=e,this.h=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.m=t,this.p=new n.reshader.Renderer(t),this.v={},this.T={},this.M={},this._={},this.O={},this.A={},this.I=new n.reshader.Scene,this.S=new n.reshader.Scene,this.C=new n.reshader.Scene,this.k=new n.reshader.Scene,this.N=new n.reshader.ResourceLoader(t.texture(2)),this.L=(...t)=>this.R.call(this,...t),this.P=new n.reshader.KHRTechniquesWebglManager(this.m,this.U(),this.N);const r=this.getMap();this.B=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this._}getPNTSMeshes(){return this.M}getB3DMMeshes(){return this.T}getPaintedMeshes(){return this.F}getMap(){return this.u.getMap()}paint(t,e,r){const i=r&&r.renderTarget,s=r&&r.sceneFilter,o=this.getMap();if(!t.length||!o)return null;const a=this.G(),c=o.projViewMatrix,l=[],u=[],f=[],d=[],m=[];for(let e=0,i=t.length;e<i;e++){const i=t[e].data.node;let s=this.D(i);if(!s)continue;const o=this.u.j(i.H),a=o.debugNodes,y=o.heightOffset||0,p=o.coordOffset||fr;this.O[i.id]&&(s=this.O[i.id],s=It(s));let b=o.polygonOffset||sr;bt(b)&&(b=b()),Array.isArray(s)||(l[0]=s,s=l);for(let l=0,g=s.length;l<g;l++){if(!s[l]||!s[l].isValid||!s[l].isValid())continue;const g=s[l].properties.magic;if(s[l].properties.heightOffset===y&&s[l].properties.coordOffset[0]===p[0]&&s[l].properties.coordOffset[1]===p[1]||(this.q(s[l]),s[l].$=n.mat4.copy([],s[l].localTransform)),s[l].V=i,"b3dm"===g){if(s[l].getBoundingBox&&!h(c,s[l].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=s[l].geometry.properties;if(t&&e){const t=s[l].properties.node.H;this.J&&this.J[t]?n.HighlightUtil.highlightMesh(this.m,s[l],this.J[t],this.Y,e):this.J&&this.J[t]||n.HighlightUtil.highlightMesh(this.m,s[l],null,this.Y,e),n.HighlightUtil.showOnly(this.m,s[l],this.Z&&this.Z[t],this.K,e)}if(a&&a.length&&a.indexOf(s[l].V.id)<0)continue;r&&r.bloom&&s[l].properties.hlBloomMesh&&(s[l].properties.hlBloomMesh.properties.depthFunc="always",f.push(s[l].properties.hlBloomMesh)),f.push(s[l])}else"pnts"===g?d.push(s[l]):"i3dm"===g&&m.push(s[l]);s[l].properties.isLeaf=t[e].leave,s[l].properties.branchRootId=t[e].branchRootId;const v=255-t[e].selectionDepth;s[l].properties.selectionDepth=v,s[l].properties.polygonOffset=b;const w=void 0===o.cullFace||!!o.cullFace;s[l].properties.cullFace=w;const T=s[l].properties.hlBloomMesh;if(T){const n=T.properties;n.branchRootId=t[e].branchRootId,n.selectionDepth=v,n.polygonOffset=b,n.cullFace=w}t[e].leave||u.push(s[l]),this.X(s[l]),this.W(s[l],i)}}let y=0;const p=this.P.getExcludeFilter();n.ContextUtil.setIncludeUniformValues(a,r),y+=this.tt(this.et,a,[s,mr,p],i,u,f,m),y+=this.tt(this.nt,a,[s,yr,p],i,u,f,m),this.P.forEachShader(((t,e,n)=>{const r=this.G(n);y+=this.tt(t,r,[s,e],i,u,f,m)})),this.S.setMeshes(d);const b=this.rt();return y+=this.p.render(this.it,b,this.S,i&&i.fbo),this.F={pntsMeshes:d,i3dmMeshes:m,b3dmMeshes:f},this.k.setMeshes(e),this.p.render(this.st,a,this.k,i&&i.fbo),y}prepareRender(t){this.ot(t)}ot(t){t&&t.states&&t.states.includesChanged&&(this.nt.dispose(),delete this.nt,this.et.dispose(),delete this.et),this.ct(t)}tt(t,e,n,r,i,s,o){t.filter=n.filter((t=>!!t)),e.stencilEnable=!1,e.cullFace="back";const a=r&&r.fbo;let c=0;const l=[],u=[];let h=!1,f=s[0]&&s[0].properties.branchRootId;for(let n=0;n<s.length;n++){const{branchRootId:r}=s[n].properties;r!==f&&(h?(u.length&&(c+=this.lt(t,e,a,!1,u),u.length=0),c+=this.lt(t,e,a,h,l)):Nt(u,l),f=r,h=!1,l.length=0),l.push(s[n]),s[n].properties.selectionDepth<255&&(h=!0),n===s.length-1&&(h||(Nt(u,l),l.length=0),u.length&&(c+=this.lt(t,e,a,!1,u)),c+=this.lt(t,e,a,h,l))}return this.I.setMeshes(s.filter((t=>t.properties.isLeaf))),this.C.setMeshes(o),c+=this.p.render(t,e,this.C,r&&r.fbo),c}lt(t,e,n,r,i){return i.length?(this.I.setMeshes(i),e.stencilEnable=!1,r&&(this.ut(n),e.stencilEnable=!1,e.cullFace="front",this.p.render(t,e,this.I,n),e.cullFace="back",e.stencilEnable=!0),this.p.render(t,e,this.I,n)):0}ut(t){this.m.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.I.getMeshes()}getCurrentI3DMMeshes(){return this.C.getMeshes()}ht(t,e){return e.V.ft-t.V.ft}deleteTile(t){const e=t.node;e.dt&&(e.dt.geometry.dispose(),e.dt.dispose(),delete e.dt);const n=e.id;this.yt(n)}yt(t){const e=this.T[t]||this.M[t]||this._[t]||this.O[t]||this.v[t];this.O[t]?this.bt(t):e&&(this.gt(e),delete this.T[t],delete this.M[t],delete this._[t],delete this.v[t])}bt(t){let e=this.O[t];e=It(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.yt(n)}delete this.O[t]}gt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.gt(t[e]);else{n.HighlightUtil.showOnly(this.m,t),n.HighlightUtil.highlightMesh(this.m,t);const e=t.geometry.properties.url;if(e){const n=this.A[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.A[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.u;nr(t.getRenderer().canvas,t.getMap());for(const t in this.O)this.bt(t);this.O={};for(const t in this.T)this.yt(t);this.T={};for(const t in this.M)this.yt(t);this.M={};for(const t in this._)this.yt(t);this._={};for(const t in this.v)this.yt(t);this.v={},this.et&&(this.et.dispose(),delete this.et),this.nt&&(this.nt.dispose(),delete this.nt),this.it&&(this.it.dispose(),delete this.it),this.st&&(this.st.dispose(),delete this.st),this.P.dispose(),this.picking&&this.picking.dispose()}D(t){return this.T[t.id]||this.M[t.id]||this._[t.id]||this.O[t.id]}has(t){return this.D(t)||this.v[t.id]}q(t){const e=t.properties.magic;"b3dm"===e?this.vt(t):"i3dm"===e?this.wt(t):"pnts"===e&&this.Tt(t)}createPntsMesh(t,e,r,i){if(this.M[e]){const t=this.M[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:s,featureTable:o,rootIdx:a,compressed_int16_params:c}=t,l=o.POINTS_LENGTH;s.BATCH_ID||(s.BATCH_ID=new Uint8Array(l),s.BATCH_ID.fill(0));const u=new n.reshader.Geometry(s,null,l,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.m);const h={};s.POSITION?h.HAS_POSITION=1:s.POSITION_QUANTIZED&&(h.HAS_POSITION_QUANTIZED=1),s.RGB?h.HAS_RGB=1:s.RGBA?h.HAS_RGBA=1:s.RGB565&&(h.HAS_RGB565=1),(s.NORMAL||s.NORMAL_OCT16P)&&(h.HAS_NORMAL=1,s.NORMAL_OCT16P&&(h.HAS_NORMAL_OCT16P=1)),this.Mt(h,c),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:f,rtcCoord:d,projCenter:m}=t,y=this.u.j(a),p=new n.reshader.Mesh(u);p.properties.magic="pnts",p.properties.id=e,p.properties.node=r,p.properties.count=l,p.properties.batchTable=t.batchTable,p.properties.batchTableBin=t.batchTableBin,p.properties.serviceIndex=a,p.properties.rtcCoord=d,p.properties.rtcCenter=f,p.properties.projCenter=m,p.setDefines(h),p.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:y&&y.pointColor||[1,1,1,1]}));const b=this.getMap();let g=null,v=null;p.setFunctionUniform("pointSize",(function(){if(!y)return 2;if(zn(y.pointSize)){const t=JSON.stringify(y.pointSize);t!==g&&(v=Hn(y.pointSize),g=t);return v(b.getZoom())}return y.pointSize||2}));let w=null,T=null;return p.setFunctionUniform("pointOpacity",(function(){if(!y)return 1;if(zn(y.pointOpacity)){const t=JSON.stringify(y.pointOpacity);t!==w&&(T=Hn(y.pointOpacity),w=t);return T(b.getZoom())}return y.pointOpacity||1})),this._t(p,c),this.Tt(p),p.$=n.mat4.copy([],p.localTransform),this.M[e]=p,i(null,{id:e,mesh:[p]}),[p]}Tt(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:i}=t.properties;this.Ot(e,n,i,r.H),t.setLocalTransform(e)}createI3DMMesh(t,e,r,i){if(this._[e]){const t=this._[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.v[e]||i(null,{id:e,mesh:t}),t}const s=this.u.j(r.H),o=this.At(r.xt),{i3dm:a,featureTable:c,gltf:l,batchTable:u,batchTableBin:h,count:f}=t,d=c.INSTANCES_LENGTH,{rtcCenter:m,rtcCoord:y,projCenter:p}=t,b=this.It(Or,r,m,y);hn(b,hr,b);const g=n.mat4.getRotation(Ar,b);n.quat.normalize(g,g);const v=n.mat4.getScaling(xr,b),w=n.mat4.fromScaling(Ir,v),T=this.St(Sr,p,r),M=this.Ct(Nr),_=this.kt(Lr,y),O=n.vec3.div(Er,_,M),A=n.mat4.fromScaling(Rr,O),{POSITION:x,NORMAL_UP:I,NORMAL_RIGHT:S,SCALE:C,SCALE_NON_UNIFORM:k}=a,N=this.getMap().getRenderer().isWebGPU()?Float32Array:Uint16Array,L={"instance_vectorA":new Float32Array(4*d),"instance_vectorB":new Float32Array(4*d),"instance_vectorC":new Float32Array(4*d),"aPickingId":new N(d)};for(let t=0;t<d;t++)L.aPickingId[t]=t;const E=new Float32Array(3),R=new Float32Array(3),P=[],U=new Float32Array(1),B=new Float32Array(3),F=[],G=[],D=[],j=[];!function(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?ue.getTypedArrayCtor(s):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,i=i||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,i*o);for(let r=0;r<i*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const l=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const i=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);l.set(i),e(new c(l.buffer),t),i.set(l)}}(x,((t,e)=>{I?(ve(R,S,e),ve(E,I,e),n.vec3.cross(P,R,E),n.vec3.normalize(P,P),xt(F,R,0),xt(F,E,1),xt(F,P,2),n.quat.fromMat3(G,F),n.quat.normalize(G,G),n.quat.multiply(G,g,G)):n.quat.identity(G),C?(ve(U,C,e),n.vec3.set(D,U[0],U[0],U[0])):k?(ve(B,k,e),n.vec3.set(D,...B)):n.vec3.set(D,1,1,1),n.mat4.fromRotationTranslationScale(j,G,t,D),we(L.instance_vectorA,e,j,0),we(L.instance_vectorB,e,j,1),we(L.instance_vectorC,e,j,2)}));const z={};for(const t in L)z[t]={buffer:this.m.buffer({dimension:L[t].length/d,data:L[t],name:t}),divisor:1};const H=s.shader||"pbr";let q=0,$=!0;const V=[],J=[];return he(l,((t,i,s,a)=>{const l=this.Nt(t,i,s,a,r,!0,H,J),{geometry:g,material:v}=l;v&&!v.isReady()&&($=!1,q++);const M=new n.reshader.InstancedMesh(z,d,g,v);l.refMeshes||(l.refMeshes=new Set,l.refMeshes.add(M.uuid)),M.properties.magic="i3dm",M.properties.id=e,M.properties.count=f,M.properties.batchTable=u,M.properties.batchTableBin=h,M.properties.serviceIndex=r.H,M.properties.rtcCoord=y,M.properties.rtcCenter=m,M.properties.projCenter=p,M.properties.node=r;const _=this.Lt(t,g,v,r.H,a);_.MESH_ENV_EXPO=1,t.compressed_int16_params&&this._t(M,t.compressed_int16_params),this.Et(M,t.attributes);const O=n.mat4.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.mat4.multiply(O,O,t.matrices[e]);n.mat4.multiply(O,o,O),n.mat4.multiply(O,A,O),c.EAST_NORTH_UP||I?n.mat4.multiply(O,w,O):n.mat4.multiply(O,b,O),M.setPositionMatrix(O),this.wt(M,T),M.setDefines(_),M.properties.polygonOffset={offset:0,factor:0},V.push(M),delete t.attributes,M.$=n.mat4.copy([],M.localTransform)})),jr(J),$?(this._[e]=V,i(null,{id:e,mesh:V})):(this.v[e]={meshes:V,count:q},V.Rt=i),V}wt(t,e){const{rtcCoord:r,node:i,projCenter:s}=t.properties;e||(e=this.St(Sr,s,i));const o=this.u.j(i.H),a=t.localTransform||[];if(o.coordOffset){const t=this.Pt(Or,i.H,r);n.mat4.multiply(a,t,e)}else n.mat4.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||fr}St(t,e,r){n.mat4.fromScaling(t,this.Ct(Nr));const i=this.Ut(Mr,e,r.H);return n.mat4.multiply(t,n.mat4.fromTranslation(Cr,i),t),t}createB3DMMesh(t,e,r,s){if(t.gltf&&(t.gltf.transferables=null),this.T[e]||this.v[e]){const t=this.T[e];return console.warn(`mesh with id(${e}) was already created.`),this.v[e]||s(null,{id:e,mesh:t}),t}let o;if(r.maxExtent){const t=new i.Extent(r.maxExtent).convertTo((t=>this._pointToPrj(t)));o=[t.xmin,t.ymin,t.xmax,t.ymax]}const a=t.gltf,{projCenter:c}=a.extensions.MAPTALKS_RTC,{rtcCoord:l,center:u}=a.extensions.CESIUM_RTC,h=a.asset.sharePosition,f=this.At(r.xt),d=this.Bt(Sr,h,l,u,c,r),m=this.u.j(r.H);let y=m.shader||"pbr";if(m.unlit)y="phong";else if(a.materials)for(let t=0;t<a.materials.length;t++)if(a.materials[t]&&a.materials[t].extensions&&a.materials[t].extensions.KHR_materials_unlit){y="phong";break}const p=[],b=[];let g=0,v=!0;return he(a,((i,s,a,w)=>{const T=this.Nt(i,s,a,w,r,!1,y,p),{geometry:M,material:_}=T;_&&!_.isReady()&&(v=!1,g++);const O=new n.reshader.Mesh(M,_);T.refMeshes||(T.refMeshes=new Set,T.refMeshes.add(O.uuid)),O.properties.magic="b3dm",O.properties.id=e,O.properties.node=r,t.batchTable&&(O.properties.batchTable=t.batchTable,O.properties.batchTableBin=t.batchTableBin),O.properties.count=t.featureTable&&t.featureTable.BATCH_LENGTH||0,O.properties.serviceIndex=r.H;const A=this.Lt(i,M,_,r.H,w);O.setDefines(A);const x=i.compressUniforms;if(x)for(const t in x)O.setUniform(t,x[t]);i.compressed_int16_params&&this._t(O,i.compressed_int16_params),this.Et(O,i.attributes),o&&(A.USE_MAX_EXTENT=1,O.setUniform("maxPrjExtent",o)),O.hasFunctionUniform("polygonOpacity")||O.setFunctionUniform("polygonOpacity",(function(){return vt(m.opacity)?m.opacity:1})),O.hasFunctionUniform("polygonFill")||O.setFunctionUniform("polygonFill",(function(){return Et([],m.polygonFill||or)})),O.material.hasFunctionUniform("hsv")||O.material.setFunctionUniform("hsv",(function(){return m.hsv||ar}));const I=n.mat4.identity([]);if(h&&i.matrices&&i.matrices.length)for(let t=0;t<i.matrices.length;t++)n.mat4.multiply(I,I,i.matrices[t]);h&&n.mat4.multiply(I,f,I),O.properties.node=r,O.properties.projCenter=c,O.properties.nodeMatrix=I,O.properties.isSharedPosition=h,O.properties.rtcCoord=l,O.properties.rtcCenter=u,this.vt(O,d),b.push(O),delete i.attributes,O.$=n.mat4.copy([],O.localTransform)})),jr(p),v?(this.T[e]=b,s(null,{id:e,mesh:b})):(this.v[e]={meshes:b,count:g},b.Rt=s),b}Ft(t){const e=this.u.Gt(t.id);if(!e||t.dt)return;let r,i,s,o;if(e.obbox)r=e.boxPosition,i=Ur,s=e.boxCenter,o=Gr;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];r=Br.vertices,i=Br.indices,s=t,o=[n,n,n]}const a=new n.reshader.Geometry({POSITION:r},i,0,{primitive:"lines",positionAttribute:"POSITION"}),c=new n.reshader.Mesh(a,new n.reshader.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),l=[];n.mat4.fromRotationTranslationScale(l,Fr,s,o),c.localTransform=l,c.$=n.mat4.copy([],l),c.properties.node=t,t.dt=c}Dt(t){t.dt&&(t.dt.geometry.dispose(),t.dt.dispose(),delete t.dt)}_t(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}vt(t,e){const{isSharedPosition:r,rtcCoord:i,rtcCenter:s,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this.Bt(e||Sr,r,i,s,o,c));const l=t.localTransform||n.mat4.identity([]);n.mat4.multiply(l,e,a);const u=this.u.j(c.H);if(u.coordOffset){const t=this.Pt(Or,c.H,i);n.mat4.multiply(l,t,l)}t.setLocalTransform(l),t.properties.heightOffset=u.heightOffset||0,t.properties.coordOffset=u.coordOffset&&u.coordOffset.slice(0)||fr}Bt(t,e,r,i,s,o){if(e){const e=this.kt(Lr,r),s=n.mat4.fromScaling(_r,e),a=this.It(Or,o,i,r);n.mat4.multiply(t,a,s)}else this.Ot(t,r,s,o.H);return t}Et(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}It(t,e,r,i){const s=this.getMap(),o=this.u.j(e.H).heightOffset||0,a=e.matrix?n.mat4.copy(t,e.matrix):n.mat4.identity(t);if(r){hn(a,n.vec3.transformMat4(pr,r,a),a)}const c=function(t,e,n,r,i,s,o){e=Xt(dn,e);const a=Ae(dn,e[0]*Mn,e[1]*Mn,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(mn,n),l=r.ellipsoid;let u;u=0===ae(c)?Wt(yn,0,0,-6378137):Ne(yn,c),wn.x=u[0],wn.y=u[1];const h=r.project(wn,Tn);pn[0]=h.x/i,pn[1]=h.y/i,pn[2]=(u[2]+o)*s;const f=fn(a,l,bn),d=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],f=e[10],d=e[11],m=e[12],y=e[13],p=e[14],b=e[15],g=n*a-r*o,v=n*c-i*o,w=n*l-s*o,T=r*c-i*a,M=r*l-s*a,_=i*l-s*c,O=u*y-h*m,A=u*p-f*m,x=u*b-d*m,I=h*p-f*y,S=h*b-d*y,C=f*b-d*p,k=g*C-v*S+w*I+T*x-M*A+_*O;return k?(k=1/k,t[0]=(a*C-c*S+l*I)*k,t[1]=(i*S-r*C-s*I)*k,t[2]=(y*_-p*M+b*T)*k,t[3]=(f*M-h*_-d*T)*k,t[4]=(c*x-o*C-l*A)*k,t[5]=(n*C-i*x+s*A)*k,t[6]=(p*w-m*_-b*v)*k,t[7]=(u*_-f*w+d*v)*k,t[8]=(o*S-a*x+l*O)*k,t[9]=(r*x-n*S-s*O)*k,t[10]=(m*M-y*w+b*g)*k,t[11]=(h*w-u*M-d*g)*k,t[12]=(a*A-o*I-c*O)*k,t[13]=(n*I-r*A+i*O)*k,t[14]=(y*v-m*T-p*g)*k,t[15]=(u*T-h*v+f*g)*k,t):null}(gn,f),m=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}(vn,n);return hn(function(t,e,n){const r=t[0],i=t[1],s=t[2],o=t[4],a=t[5],c=t[6],l=t[8],u=t[9],h=t[10],f=e[0],d=e[1],m=e[2],y=e[3],p=e[4],b=e[5],g=e[6],v=e[7],w=e[8],T=r*f+o*d+l*m,M=i*f+a*d+u*m,_=s*f+c*d+h*m,O=r*y+o*p+l*b,A=i*y+a*p+u*b,x=s*y+c*p+h*b,I=r*g+o*v+l*w,S=i*g+a*v+u*w,C=s*g+c*v+h*w;return n[0]=T,n[1]=M,n[2]=_,n[3]=0,n[4]=O,n[5]=A,n[6]=x,n[7]=0,n[8]=I,n[9]=S,n[10]=C,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(d,m,t),pn,t),t}(a,i,a,s.getProjection(),s.getGLRes(),this.B,o),l=function(t,e){return Wt(t,e[12],e[13],e[14]),t}(Mr,c);let u=this.u.options.offset;if(bt(u)){const t=this.u.Gt(e.id).boxCoord;u=u.call(this.u,t)}return n.vec3.set(Tr,u[0],u[1],0),n.vec3.sub(l,l,Tr),hn(c,l,c),c}Pt(t,e,r){const i=this.u.j(e);if(!i.coordOffset)return null;const s=this.getMap(),o=s.getGLRes();br.set(r[0],r[1]);const a=s.coordToPointAtRes(br,o,vr),c=i.coordOffset,l=br.set(r[0]+c[0],r[1]+c[1]),u=s.coordToPointAtRes(l,o,wr),h=u.x-a.x,f=u.y-a.y,d=this.B,m=n.vec3.set(Tr,h,f,(c[2]||0)*d);return n.mat4.fromTranslation(t,m)}createCMPTMesh(t,e,n,r){if(this.O[e]){const t=this.O[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:i}=t,s=[];for(let t=0;t<i.length;t++){const{magic:r}=i[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"i3dm"===r?this.createI3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"pnts"===r?this.createPntsMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"cmpt"===r&&this.createCMPTMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)}))}return this.O[e]=s,r(null,{id:e,mesh:s}),s}Lt(t,e,n,r,i){const s=("phong"===(this.u.j(r).shader||"pbr")?this.et:this.nt).getGeometryDefines(e);i.asset&&"S3M"===i.asset.generator&&this.jt(s,e),e.data.uvRegion&&(s.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(s.VertexNormal=1),e.data[e.desc.color0Attribute]&&(s.VertexColor=1),e.data[e.desc.uv0Attribute]&&(s.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(s.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(s.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(s.TexCoord2=1),"MESHOPT"===this.u.zt&&(s.MeshOPT_Compress=1),this.hasIBL()&&(s.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(s.HAS_WEB3D_quantized_attributes_TEXCOORD=1),s.HAS_MIN_ALTITUDE=1,this.Mt(s,t.compressed_int16_params);return pt(s,t.compressDefines),s}Mt(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}X(t){const e=this.u.getRenderer();e&&e.updateMaskDefines(t)}jt(t,e){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1)}Nt(t,e,r,i,s,o,a,c){let l=!1;i.asset&&"S3M"===i.asset.generator&&(l=!0,i.extensions=i.extensions||{});const u=i.url+"-"+e+"-"+r;if(this.A[u])return this.A[u];let h,f;c.push(t);const d=i.materials&&i.materials[t.material],m=i.extensions&&i.extensions.KHR_techniques_webgl,y=this.u.j(s.H);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){if(this.getMap().getRenderer().isWebGPU())throw new Error("3dtiles with KHR_techniques_webgl extension is not supported in webgpu");const e=this.Ht(t,i,o,l);h=e.material,f=e.geometry,y.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.qt(t,o,Pr);const e=y.material;h=this.$t(t.material,i,a,e||cr,c,y)}h&&(h.setFunctionUniform("alphaTest",(function(){const t=y.alphaTest;return yt(t)?.1:t})),h.setFunctionUniform("environmentExposure",(()=>{const t=y.ambientLight;let e=y.environmentExposure;const n=this.getMap().getLightManager(),r=n&&n.getAmbientLight();if(t&&(!r||r.color)&&void 0===e){const n=r&&r.color?r.color[0]:.2;e=t[0]/n}return e||1}))),h&&!h.isReady()?h.Vt=s.id:h||(h=new n.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const p={geometry:f,material:h};return f.properties.url=u,this.A[u]=p,p}Ht(t,e,n,r){const{geometry:i,material:s}=this.P.createMesh(t,e,n,r);return{geometry:i,material:s}}qt(t,e,r){const i=this.getMap().getRenderer().isWebGPU(),s=t.attributes,o="COLOR_0";let a=s._BATCHID&&s._BATCHID.array;if(a&&a.byteOffset&&(a=new a.constructor(a),!i||a instanceof Float32Array||(a=new Float32Array(a))),s[o]){const t=s[o].array||s[o];if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);s[o].array?(s[o].array=e,s[o].componentType=5121):s[o]=e}}const c={};let l=0,u=0;for(const t in s){const e=r[t]||t,o=e===r.POSITION;if(o&&(l=s[t].itemSize),i){const e=s[t].array,r=n.reshader.Geometry.padGPUBufferAlignment(e,s[t].count);if(e!==r){const e=r.length/s[t].count;o&&(l=e),s[t].array=r,s[t].byteLength=r.byteLength,s[t].itemSize=e;const n=s[t].type;s[t].type=n.substring(0,n.length-1)+s[t].itemSize}}const a=Xn(this.m,s[t],{dimension:s[t].itemSize,name:t});c[e]=pt({},s[t]),c[e].buffer=a,c[e].type=Wn(c[e].array),delete c[e].array,e===r.POSITION&&(c[e].array=s[t].array,u=s[t].array.length/3)}const h=r._BATCHID;if(!c[h]&&!e){const t=new(i?Float32Array:Uint8Array)(u);c[h]=t}const f=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,d=new n.reshader.Geometry(c,f,0,{positionSize:l,positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":Kn(t.mode)});return a&&f&&(d.properties.batchIdData=a,d.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const i=e[r],s=t[i];let o=n.get(s);o||(o=[],n.set(s,o)),o.push(i)}return n}(a,f)),d.generateBuffers(this.m,{excludeElementsInVAO:e}),d}Ot(t,e,r,i){const s=n.mat4.identity(t),o=this.Ct(lr);return this.Ut(Mr,r,i),n.mat4.translate(s,s,Mr),n.mat4.scale(s,s,o),s}Ut(t,e,r){const i=this.B;br.x=e[0],br.y=e[1];const s=this._prjToPoint(br);let o=this.u.options.offset;bt(o)&&(o=o.call(this.u,br));const a=this.u.j(r).heightOffset||0;return n.vec3.set(t,s.x-o[0],s.y-o[1],i*e[2]+i*a),t}W(t,e){const r=this.u.Jt(kr,e);t.localTransform=n.mat4.multiply(t.localTransform,r,t.$)}kt(t,e){const r=this.getMap();br.x=e[0],br.y=e[1];const i=r.distanceToPointAtRes(100,100,r.getGLRes(),br),s=this.B;return n.vec3.set(t,i.x/100,i.y/100,s),t}ct(t){if(this.nt)return;const e={x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},r=[],i=[];this.it=new n.reshader.MeshShader({vert:Te,frag:"#define SHADER_NAME PNTS\nprecision mediump float;\nuniform float layerOpacity;\nvarying vec4 vColor;\nvoid main() {\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n if (dot(circCoord, circCoord) > 1.0) {\n discard;\n } else {\n gl_FragColor = vColor;\n }\n #ifdef HAS_LAYER_OPACITY\n gl_FragColor *= layerOpacity;\n #endif\n}\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>n.mat4.multiply(i,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>n.mat3.fromMat4(r,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,func:"<"}}});const s={},o=[];n.ContextUtil.fillIncludes(s,o,t);const a=this.U();this.et=new n.reshader.PhongShader({uniforms:o,defines:s,extraCommandProps:a}),this.nt=new n.reshader.pbr.StandardShader({uniforms:o,defines:s,extraCommandProps:a}),this.st=new n.reshader.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const c=this.u;er(c.getRenderer().canvas,this.m,c.getMap()),this.picking=new n.reshader.FBORayPicking(this.p,{vert:"#include <gl2_vert>\n#define SHADER_NAME GEO_3DTILES_PICKING\nattribute vec3 aPosition;\n#if defined(HAS_COLOR)\n attribute vec4 aColor;\n#endif\n#if defined(HAS_COLOR0)\n #if COLOR0_SIZE == 3\n attribute vec3 aColor0;\n varying vec3 vColor0;\n #else\n attribute vec4 aColor0;\n varying vec4 vColor0;\n #endif\n#endif\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projMatrix;\n#include <line_extrusion_vert>\n#include <get_output>\n#include <fbo_picking_vert>\nvoid main() {\n mat4 localPositionMatrix = getPositionMatrix();\n vec4 localVertex = getPosition(aPosition);\n vec4 position = localPositionMatrix * localVertex;\n vec4 viewVertex = modelViewMatrix * position;\n #ifdef HAS_MASK_EXTENT\n gl_Position = projMatrix * getMaskPosition(position, modelMatrix);\n #else\n gl_Position = projMatrix * viewVertex;\n #endif\n float alpha = 1.0;\n #if defined(HAS_COLOR)\n alpha *= aColor.a;\n #endif\n #if defined(HAS_COLOR0) && COLOR0_SIZE == 4\n alpha *= aColor0.a;\n #endif\n fbo_picking_setData(gl_Position.w, alpha != 0.0);\n}\n",wgslVert:n.getWGSLSource("layer_3dtiles_picking_vert"),extraCommandProps:a,uniforms:this.nt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.Yt=new n.reshader.FBORayPicking(this.p,{vert:Te,extraCommandProps:a,uniforms:this.it.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}U(){return{viewport:{x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},cull:{enable:(t,e)=>e.meshProperties.cullFace,face:(t,e)=>e.cullFace||"back"},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:"<=",ref:(t,e)=>e.meshProperties.selectionDepth},op:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,func:(t,e)=>e.meshProperties.depthFunc||"<="},blend:{enable:!0,func:{src:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}rt(t){const e=this.getMap(),r=e.getLightManager(),i=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;let o=this.u.options.opacity;return o=yt(o)?1:o,{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:n.vec3.normalize(dr,i),layerOpacity:o}}G(){const t=this.getMap(),e=this.u,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:i}=rr(n),s=ir(t,r,i),o=this.u.getRenderer().getMaskUniforms();s.minAltitude=e.options.altitude||0;let a=e.options.opacity;return a=yt(a)?1:a,s.layerOpacity=a,pt(s,{czm_lightDirectionEC:s.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),s.ambientColor||(s.ambientColor=[.2,.2,.2]),pt(s,o),s}$t(t,e,r,i,s,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=pt({},i);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Zt(t,s)),c.baseColorFactor=t&&t.image.color||a.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(a.normalTexture){const t=this.Zt(e.textures[a.normalTexture.index],s);if(t){const e=a.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=e}}if(a.occlusionTexture){const t=this.Zt(e.textures[a.occlusionTexture.index],s);if(t){const e=a.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=e}}if(a.emissiveTexture){const t=this.Zt(e.textures[a.emissiveTexture.index],s);t&&(c.emissiveTexture=t)}a.emissiveFactor&&(c.emissiveFactor=a.emissiveFactor);const t=a.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const r=e.textures[t.baseColorTexture.index];if(r&&r.image&&r.image.color)c.baseColorFactor=c.baseColorFactor?n.vec4.multiply(c.baseColorFactor,c.baseColorFactor,r.image.color):r.image.color;else{const t=this.Zt(r,s);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.m))}}if(yt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),yt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.Zt(e.textures[a.metallicRoughnessTexture.index],s);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.reshader.Material(c);if(o.unlit||a.extensions&&a.extensions.KHR_materials_unlit){const t=new n.reshader.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let l=new n.reshader.pbr.StandardMaterial(c);"phong"===r&&(l=n.reshader.PhongMaterial.convertFrom(l));const u=a.pbrMetallicRoughness,h=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return h&&h.KHR_texture_transform&&(l.set("khr_offset",h.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",h.KHR_texture_transform.rotation||0),l.set("khr_scale",h.KHR_texture_transform.scale||[1,1])),l.doubleSided=!(!o.doubleSided&&!a.doubleSided),l.once("complete",this.L),l}Zt(t,e){if(!t)return null;const r={type:t.type?Yn(t.type):"uint8",format:t.format?Zn(t.format):"rgba",flipY:!!t.flipY},i=t.image;if(e.push(i),i.array?r.data=i.array:i.mipmap&&(r.mipmap=i.mipmap),!r.data&&!r.mipmap)return null;if(r.width=i.width,r.height=i.height,r.mipmap&&(r.width<4||r.height<4))return null;const s=t.sampler||t.texture&&t.texture.sampler;return s&&(s.magFilter&&(r.mag=$n(s.magFilter)),s.minFilter&&(r.min=Vn(s.minFilter)),s.wrapS&&(r.wrapS=Jn(s.wrapS)),s.wrapT&&(r.wrapT=Jn(s.wrapT))),new n.reshader.Texture2D(r,this.N)}R({target:t}){const e=t.Vt,n=this.v[e];if(n.count--,!n.count){const t=n.meshes;this.T[e]=t,delete this.v[e];const r=t.Rt;delete t.Rt,r(null,{mesh:n.meshes,id:e})}}Ct(t){const e=1/this.getMap().getGLRes(),n=this.B;return t[0]=t[1]=e,t[2]=n,t}Kt(t){return this.u.Kt(t)}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes(),gr)}At(t){return"Y"===t?Qn:"X"===t?tr:ur}pick(t,e,n=3){const r=this.u;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const i=[],s=this.G(),o=this.Xt(this.picking,s,this.I,t,e,n);o&&i.push(o);const a=this.Xt(this.picking,s,this.C,t,e,n);a&&i.push(a);const c=this.rt(),l=this.Xt(this.Yt,c,this.S,t,e,n);return l&&i.push(l),i}Xt(t,e,n,r,i,s){if(!n.getMeshes().length)return null;const o=this.u,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,i,s,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:l,pickingId:u,point:h,coordinate:f}=c,d=(0===l||l)&&t.getMeshAt(l);if(!d||!d.geometry)return null;const m=d.properties;h&&h.length&&(h[0]=Math.round(1e5*h[0])/1e5,h[1]=Math.round(1e5*h[1])/1e5,h[2]=Math.round(1e5*h[2])/1e5);const y={batchId:u},p=o.options.services,b=p&&p[d.properties.serviceIndex];if(b&&b.debug&&(y.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=u;for(const i in t)void 0!==t[i].byteOffset?y[i]=Ye(t[i],e,n,r):y[i]=t[i][r]}return{service:d.properties.serviceIndex,data:y,point:h,coordinate:f}}highlight(t){this.J=t;const e=this.u.getRenderer();this.Y=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.J=null;const t=this.u.getRenderer();this.Y=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Z=t;const e=this.u.getRenderer();this.K=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Z=null;const t=this.u.getRenderer();this.K=t.getFrameTimestamp(),t.setToRedraw(!0)}Wt(){if(!this.F)return[];const t={},e=[];for(const n in this.F){const r=this.F[n];if(r)for(let n=0;n<r.length;n++){const i=r[n],s=i&&i.geometry;if(!i||!s)continue;const o=i.properties.serviceIndex;t[o]||(t[o]=new Set);const a=s.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}function jr(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}function zr(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}const Hr=[];class qr{constructor(t,e,n,r,i){this.u=r,this.Qt=t,this.H=e,this.te=i,this.ee=n.version,t.indexOf("i3s:tileset:")<0?(this.ee<=1.6?this.ne="root":this.ne=0,n.version=this.ee):(this.ne=t.substring(12),this.ee>1.6&&(this.ne=parseInt(this.ne))),this.Qt=t,this.re=n}load(){const t=this.re,e=t.layerScene.baseUrl;if(this.ee<=1.6)return t[this.ne]&&t[this.ne].lodSelection?(this.ie=t[this.ne],this.se()):new Promise((n=>{let r=e+"/nodes/"+this.ne;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.te(this.H,r,(()=>{this.ie=t[this.ne],n(this.se())}))}));if(this.ee>=1.7){if(t[this.ne])return this.ie=t[this.ne],this.se();const n=Math.floor(this.ne/t.nodesPerPage);return new Promise((r=>{let i=e+"/nodepages/"+n;t.layerScene.eslpk&&(i+=".json"),this.te(this.H,i,(()=>{this.ie=t[this.ne],r(this.se())}))}))}return null}getTileset(){return this.oe}getChildrenURL(){return this.ae}se(){const t=this.re,e=t.layerScene.baseUrl,n=this.ie.children,r=[],i={};if(n)for(let s=0;s<n.length;s++)if(this.ee<=1.6){const o=n[s].id;if(t[o])continue;const a=o;i[a]||(i[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.te(this.H,r,(()=>{n()}))})),r.push(i[a]))}else{const o=n[s];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);i[a]||(i[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.te(this.H,r,(()=>{n()}))})),r.push(i[a]))}return r.length?Promise.all(r).then((()=>this.ce())):this.ce()}ce(){return Promise.resolve(this.le())}ue(t){zr(this.re,t)}le(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.he(this.ie,!0)}}he(t){const e=this.u.getRenderer(),n=this.re.projection,r=!n||n&&4326===n.wkid,i=this.ee,s=this.re,o=t,a=o.obb,c=o.mbs,l={};let u;if(c)u=Wt([],c[0],c[1],c[2]),r||(u=e.fe(u,u)),u=$r([],u[0],u[1],u[2]),l.sphere=[...u,c[3]];else if(a){u=Wt([],a.center[0],a.center[1],a.center[2]),r||(u=e.fe(u,u)),u=$r([],u[0],u[1],u[2]);const t=function(t,e,n){const r=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,l=n*o,u=r*o,h=r*a,f=i*o,d=i*a,m=i*c,y=s*o,p=s*a,b=s*c;return t[0]=1-h-m,t[3]=u-b,t[6]=f+p,t[1]=u+b,t[4]=1-l-m,t[7]=d-y,t[2]=f-p,t[5]=d+y,t[8]=1-l-h,t}([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(u,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],i=t[4]+t[7]+t[10],s=t[5]+t[8]+t[11];Wt(Hr,n,i,s);const o=ae(Hr);l.sphere=[...u,o]}let h=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===s.lodSelectionMetricType){h=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(h=f/o.lodSelection[t].maxError);(h===1/0||isNaN(h))&&(h=1e5);const d=16*h,m=function(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}([]),y=m,p=o.children;let b;if(p){b=[];const t=this.re;for(let e=0;e<p.length;e++){const n=i<=1.6?p[e].id:p[e];if(!t[n]){b=null;break}b.push(this.he(t[n]))}}const g={refine:"REPLACE",boundingVolume:l,transform:y,geometricError:d};return i<=1.6?t.lodSelection?t.geometryData&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}):g.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!b?g.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}),b&&b.length&&(g.children=b),g}getJSON(){return this.ie}}function $r(t,e,n,r){return Ae(t,wt(e),wt(n),r)}const Vr=!!Gt.ktx2,Jr=n.mat4.identity([]),Yr=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function Zr(t){return t.indexOf("i3s:mesh")>=0}const Kr=9;function Xr(t,e,n,r,i){const s=e.layerScene.eslpk,o=function(t,e){const n=e.substring(Kr);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,l=[];let u=!1;const h=Jr;let f,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;s&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let i=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(i){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",s&&(i+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+i,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}l.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions,o=(e.layerScene.store||{}).textureEncoding,h=t[f.definition],{geometryBuffers:m}=h;u=r&&2===m.length;const y=Gt.draco&&u?m[1]:m[0],p=Gt.draco&&u?1:0;let b=c+`/nodes/${f.resource}/geometries/`+p;s&&(b+=".bin");const g={geometry:{url:b,info:y}};if(i&&Yr&&u&&!Gt.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const v=e.layerScene.materialDefinitions,w=e.layerScene.textureSetDefinitions;let T,M=0;if(d&&(M=v[d.definition]),v){T=function(t,e,n,r,i,s,o){const a=JSON.parse(JSON.stringify(e));return Wr(t,a,n,r,i,s,o),a}(o,M,w,c,d.resource,n,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};g.material=T,l.push(g)}return{dracoCompression:u,meshes:l,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:h}}function Wr(t,e,n,r,i,s,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const c=n[e[a].textureSetDefinitionId],l="images/"+c.formats[0].format,u=ti(c.formats,s,t),h={url:r+`/nodes/${i}/textures/${u.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:u.format,mimeType:l};if(o){let t="";switch(u.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=u.format}h.url+="."+t}e[a]=h}else gt(e[a])&&Wr(t,e[a],n,r,i,s,o)}const Qr={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"jpg","image/vnd-ms.dds":"dds","image/ktx":"jpg"};function ti(t,e,n){if(n&&n.length){const e=n[n.length-1],r=Qr[e];if(r)for(let e=0,n=t.length;e<n;e++){if(t[e].format===r)return t[e]}else console.error("i3s not find texture format type from:",Qr,"current textureEncoding:",e)}for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&Vr)return t[n]}return null}const{Ajax:ei}=Dt(),ni=new i.Coordinate(0,0),ri=new i.Coordinate(0,0),ii=new Set,si=[],oi=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.de(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){const t=this.data.keys();let e=t.next();for(;this.currentSize>this.max&&void 0!==e.value;){this.data.get(e.value).current&&i.Util.warnOnce(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`);const n=this.getAndRemove(e.value);n&&this.onRemove(n),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(const r of n)t[e++]=r;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return this.de(t,e),this}de(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(i.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let ai=0;class ci extends(n.MaskRendererMixin(n.CanvasCompatible(i.renderer.LayerAbstractRenderer))){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>oi.max&&oi.setMaxSize(e),this.tileCache=oi,ai++,this.tilesLoading={},this.me={},this.ye=[],this.te=(...t)=>this.pe.call(this,...t)}getAnalysisMeshes(){if(!this.painter)return si;const t=this.painter.getPaintedMeshes();if(!t)return si;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:i}=t;return n.length&&Nt(e,n.filter((t=>!(!t||!t.geometry)))),r.length&&Nt(e,r.filter((t=>!(!t||!t.geometry)))),i.length&&Nt(e,i.filter((t=>!(!t||!t.geometry)))),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.ye.length||super.needToRedraw())}getFrameTimestamp(){return this.be}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.be=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:i}=this.layer.getTiles(),s=i.length;if(!i||!s)return void this.completeRender();this.painter.prepareRender(e),this.ge(),this.ve(e);const{selectedTiles:o,requests:a}=this.we(r,i);a.length&&this.loadTiles(a),this.Te(o,e),this.Me(),a.length||this.completeRender()}we(t,e){let n=[];this._e();let r=0;const i=this.Oe(),s={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const i=e[t],c=i.node;if(s[c.id])continue;s[c.id]=1;let l=!1;const u=this.getCachedTile(c.id);if(this.Ae(c.id)?(r++,l=a=!0,this.tilesLoading[c.id].current=!0):u?(this.getTileOpacity(u)<1&&(l=a=!0),o=!0,i.selected=!0,i.data=u):this.painter.has(c)||(l=a=!0,n.push(c)),!l)continue;if(this.xe(i))o=!0;else{this.Ie(i).length&&(o=!0)}}const c=o?this.Se(t):[];if(n.length>1&&(n.sort(li),i)){const t=i-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c}}Se(t){const e=[];let n,r;const i=[t],s=[];for(;i.length>0||s.length>0;){if(s.length>0){const t=s[s.length-1];if(t.Ce===i.length){s.pop(),t===n&&(t.leave=!0),t.branchRootId=r,e.push(t),0===s.length&&(r=null);continue}}const t=i.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)t.leave=!0,t.selectionDepth=s.length,t.branchRootId=r,e.push(t);else{if(t.selectionDepth=s.length,n=t,0===o.length){t.leave=!0,t.branchRootId=r,e.push(t);continue}0===s.length&&(r=t.node.id),s.push(t),t.Ce=i.length}for(let t=0;t<o.length;t++)i.push(o[t])}return e}xe(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}Ie(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.ke+1,r=[t.node];for(;r.length>0;){const i=r.pop().children;for(let s=0,o=i.length;s<o;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){r.push(i[s]);continue}const o=i[s].id;if(this.tileCache.has(o)){const n=this.layer.Ne(i[s],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else i[s].ke<=n&&r.push(i[s])}}return e}Te(t,e){this.tileCache.markAll(this,!1);const n=[];for(let e=0,r=t.length;e<r;e++){const r=t[e].data;r.current=!0,r.renderer=this,this.tileCache.add(t[e].node.id,r);const i=r.node,s=this.layer.j(i.H);i.dt&&s.debug&&!Array.isArray(s.debug)&&n.push(i.dt)}const r=this.layer.options.services;for(let t=0;t<r.length;t++){const e=r[t],i=Array.isArray(e.debug)&&e.debug;if(i)for(const t of i){const e=this.layer.Gt(t),r=e&&e.node;r&&r.dt&&n.push(r.dt)}}const i={tiles:t};this.onDrawTileStart(i);const s=this.painter.paint(t,n,e);this.layer.fire("drawtiles",{count:s}),this.onDrawTileEnd(i),s&&this.layer.fire("canvasisdirty",{renderCount:s}),this.tileCache.shrink()}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(Ct(e)){const n=kt(e);return this.Le(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.H,r=this.Ee[n];return new qr(e,n,r,this.layer,this.te).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Pt(e)&&!Zr(e)&&(e=t.baseUrl+e),this.Le(e,null,t),null}Le(t,e,r){let i=this.Re;i||(i=n.reshader.Util.getSupportedFormats(this.gl||this.device&&this.device.wgpu),this.Re=i);const s=this.layer.j(r.H);s.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length),r=n.split("/"),i=[];for(let t=0;t<r.length;t++)i.push(encodeURIComponent(r[t]));return e+i.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,this.layer.Pe[r.H]),arraybuffer:e,rootIdx:r.H,upAxis:r.xt,transform:r.matrix,supportedFormats:i};if(Zr(t)){const e=this.Ee[r.H];if(o.projection=e.projection,o.i3sInfo=Xr(t,e,this.regl||this.device,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=pt({},s),s.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:i}=n;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i||"gltf"===i?this.ye.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Ft(t){this.painter&&this.painter.Ft(t)}Dt(t){this.painter&&this.painter.Dt(t)}ve(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.ye.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.ye.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})),n++}}Ue(t,e,n,r){if(this.Be(r),n)this.onTileError(n,e);else{const n=this.Fe(r);e.memorySize=n,this.onTileLoad(t,e)}}Be(t){if(Array.isArray(t)){for(let e=0;e<t.length;e++)if(t[e])if(Array.isArray(t[e]))this.Be(t[e]);else{const n=t[e].defines||{};n.HAS_LAYER_OPACITY=1,t[e].setDefines(n)}}else if(t)if(Array.isArray(t))this.Be(t);else{const e=t.defines||{};e.HAS_LAYER_OPACITY=1,t.setDefines(e)}}Fe(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Fe(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.Ge(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.zt=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.De(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(t,e,n){if(!this.layer)return;const r=n||e.content.url,s=t&&t.message||t;t&&(404===t.status||204===t.status)||ii.has(s)||(console.warn("failed to load 3d tile: "+r),console.warn(t),ii.add(s)),delete this.tilesLoading[e.id],(!this.layer.options.onlyCacheNoContentTileWhenError||t&&!i.Util.isNoContentHttpCode(t.status))&&this.je(e,t),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}getShadowMeshes(){if(!this.painter)return[];const t=[],e=this.painter.getCurrentB3DMMeshes();for(const n in e)e[n]&&e[n].isValid&&e[n].isValid()&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&n[e].isValid&&n[e].isValid()&&t.push(n[e]);return t}je(t,e){const n={loadTime:i.Util.now(),current:!0,error:e,node:t};n.renderer=this,this.tileCache.add(t.id,n)}Ge(t){const e={loadTime:i.Util.now(),current:!0,node:t};e.renderer=this,this.tileCache.add(t.id,e)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.me[e]}_e(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}initContext(){super.initContext();const t=this.layer,{regl:e,reglGL:n,device:r}=this.context;this.regl=e,this.device=r,this.gl=n;const i=e||r;this.prepareWorker(),this.canvas.pickingFBO=this.canvas.pickingFBO||i.framebuffer(this.canvas.width,this.canvas.height),this.pickingFBO=this.canvas.pickingFBO||i.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Dr(i,t),this.layer.ze(),this.layer.fire("contextcreate",{regl:e,device:r})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new zt("@maptalks/3dtiles",t.id,n.reshader.Util.supportNPOT(this.regl||this.device)));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=pt({},r),delete r.offset;const i=t.options.spatialReference;r.projection=i&&i.coordType||i&&i.projection||t.getSpatialReference().getProjection().code;const s=this.layer.getId();e.addLayer(s,r,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),ai--,ai||oi.reset(),this.clear(),delete this.tileCache,delete this.gl,delete this.regl,super.onRemove()}clear(){this.Me(!0),this.tileCache.reset(this),this.tilesLoading={},super.clear()}getTileOpacity(){return 1}getStencilValue(){return 0}Me(t){this.He||(this.He=Date.now());const e=Date.now();if(!t&&e-this.He<this.layer.options.retireInterval)return;this.He=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}Oe(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}qe(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let i=0;i<n.length;++i){try{r=t.getContext(n[i],e)}catch(t){}if(r)break}return r}Ae(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 Ve(t,e,0,n)}ge(){if(!this.$e)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.$e){const i=this.$e[r];if("pending"===i.status)continue;i.status="pending";const s=i.rootIdx,o=Ut(this.layer.j(s).fetchOptions);if(n.push(ei.getJSON(r,o).then((t=>{delete this.$e[r];const e=this.Ee[s];if(e){t.nodes?zr(e,t.nodes):(e[t.id]=t,zr(e,t.children));for(let t=0;t<i.length;t++)i[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}n.length&&Promise.all(n)}pe(t,e,n){this.$e||(this.$e={}),this.$e[e]=this.$e[e]||[],this.$e[e].rootIdx=t,this.$e[e].push(n),this.setToRedraw()}De(t,e,n){this.Ee||(this.Ee=[]);const r=e.H;this.Ee[r]||(this.Ee[r]={});const i=this.Ee[r],s=this.layer.j(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),i.version=+(s.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),t.spatialReference&&4490===t.spatialReference.wkid&&(console.warn("i3s spatialReference is 4490,auto set spatialReference to 4326,This may cause some location issues, please ensure that your service is 4326"),t.spatialReference.wkid=4326),i.projection=t.spatialReference,function(t,e,n,r,i,s,o){if(!s.layerScene){s.layerScene=e,s.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,s.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=i;if(s.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=i.lastIndexOf("/");t=e<0?"./":i.substring(0,e)}s.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new qr(i,n,s,t,o).load()}(this.layer,t,r,0,n,i,this.te).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:i,height:s}=this.canvas;return!this.pickingFBO||r.width===i&&r.height===s||r.resize(i,s),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.J||(this.J=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.J[n];r||(r=this.J[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.J[e];n||(n=this.J[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.J)}cancelHighlight(t,e){if(!this.J)return;const n=this.J[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.J[t]=null),this.painter.highlight(this.J)}}cancelAllHighlight(){delete this.J,this.painter.cancelAllHighlight()}showOnly(t){if(this.Z||(this.Z=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Z[n];r||(r=this.Z[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Z[e];n||(n=this.Z[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Z)}cancelShowOnly(){delete this.Z,this.painter.cancelShowOnly()}Wt(){return this.painter?this.painter.Wt():[]}fe(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.Ve();return ni.set(e[0],e[1]),n.unproject(ni,ri),t[0]=ri.x,t[1]=ri.y,t}return ni.set(e[0],e[1]),n.getProjection().unproject(ni,ri),t[0]=ri.x,t[1]=ri.y,t}Je(t,e){const n=this.Ve();return ni.set(e[0],e[1]),n.project(ni,ri),t[0]=ri.x,t[1]=ri.y,t}Ye(t,e){const n=this.Ve();return ni.set(e[0],e[1]),n.unproject(ni,ri),t[0]=ri.x,t[1]=ri.y,t}Ve(){const t=this.getMap().options.spatialReference.coordType;if(!t)throw new Error("Missing coordType in map spatialReference.");return this.Ze||(this.Ze=i.SpatialReference.getProjectionInstance(t)),this.Ze}}function li(t,e){return t.ft-e.ft}function ui(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function hi(t,e,n){return Math.sqrt(function(t,e,n){const r=Qt(fi,n,t),i=ui(di,e,0),s=ui(mi,e,1),o=ui(yi,e,2),a=ae(i),c=ae(s),l=ae(o);ne(i,i),ne(s,s),ne(o,o);const u=pi;u[0]=re(r,i),u[1]=re(r,s),u[2]=re(r,o);let h,f=0;u[0]<-a?(h=u[0]+a,f+=h*h):u[0]>a&&(h=u[0]-a,f+=h*h);u[1]<-c?(h=u[1]+c,f+=h*h):u[1]>c&&(h=u[1]-c,f+=h*h);u[2]<-l?(h=u[2]+l,f+=h*h):u[2]>l&&(h=u[2]-l,f+=h*h);return f}(t,e,n))}const fi=[],di=[],mi=[],yi=[],pi=[];const bi=2*Math.PI;class gi{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],i=t.west;let s=t.east;return s<i&&(s+=bi,n<0&&(n+=bi)),(n>i||De(n,i,1e-14))&&(n<s||De(n,s,1e-14))&&r>=t.south&&r<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const vi=[0,0,1];function wi(t,e){return Ae(e,t[0],t[1],t[2])}class Ti{constructor(t,e){this.normal=n.vec3.copy([],t),this.distance=e}static fromPointNormal(t,e,r){const i=-n.vec3.dot(e,t);return n.vec3.copy(r.normal,e),r.distance=i,r}}const Mi=[],_i=[],Oi=[],Ai=[],xi=[],Ii=[],Si=[],Ci=[],ki=[],Ni=[],Li=new Ti([1,0,0],0),Ei=[];class Ri{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new gi(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let r=0;if(!gi.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,i=this.northeastCornerCartesian,s=this.westNormal,o=this.southNormal,a=this.eastNormal,c=this.northNormal,l=n.vec3.subtract(Ei,t,e),u=n.vec3.dot(l,s),h=n.vec3.dot(l,o),f=n.vec3.subtract(Ei,t,i),d=n.vec3.dot(f,a),m=n.vec3.dot(f,c);u>0?r+=u*u:d>0&&(r+=d*d),h>0?r+=h*h:m>0&&(r+=m*m)}const i=e[2],s=this.minimumHeight,o=this.maximumHeight;if(i>o){const t=i-o;r+=t*t}else if(i<s){const t=s-i;r+=t*t}return Math.sqrt(r)}computeBox(t){const e=this;wi(gi.southwest(t,_i),e.southwestCornerCartesian),wi(gi.northeast(t,_i),e.northeastCornerCartesian),Mi[0]=t.west,Mi[1]=.5*(t.south+t.north),Mi[2]=0;const r=wi(Mi,Oi),i=n.vec3.cross(xi,r,vi);n.vec3.normalize(e.westNormal,i),Mi[0]=t.east;const s=wi(Mi,Ci),o=n.vec3.cross(xi,vi,s);n.vec3.normalize(e.eastNormal,o);const a=n.vec3.subtract(xi,r,s),c=n.vec3.normalize(Ai,a),l=t.south;let u;if(l>0){Mi[0]=.5*(t.west+t.east),Mi[1]=l;const r=wi(Mi,ki);n.vec3.copy(Ni,c);const i=Ti.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Li);Pi(ki,Ni,i,e.southwestCornerCartesian),u=Be(r,Ii)}else u=Fe(gi.southeast(t,_i),Ii);const h=n.vec3.cross(Si,u,a);n.vec3.normalize(e.southNormal,h);const f=t.north;let d;if(f<0){Mi[0]=.5*(t.west+t.east),Mi[1]=f;const r=wi(Mi,ki);n.vec3.scale(Ni,c,-1);const i=Ti.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Li);Pi(ki,Ni,i,e.northeastCornerCartesian),d=Be(r,Ii)}else d=Fe(gi.northwest(t,_i),Ii);const m=n.vec3.cross(Si,a,d);n.vec3.normalize(e.northNormal,m)}}function Pi(t,e,r,i){const s=t,o=e,a=r.normal,c=n.vec3.dot(a,o);if(Math.abs(c)<1e-15)return;const l=(-r.distance-n.vec3.dot(a,s))/c;return l<0?void 0:(i=n.vec3.scale(i,o,l),n.vec3.add(i,s,i))}function Ui(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const Bi=i.BBOXUtil,Fi={"services":[],"maxGPUMemory":i.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":2,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"onlyCacheNoContentTileWhenError":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"]},Gi=[0,0,0],Di=[0,0,0],ji=[0,0,0],zi=[0,0,0],Hi=[0,0,0],qi=[0,0,0],$i=[0,0,0],Vi=[1,1,1],Ji=[1,1,1],Yi=[0,0,0,0],Zi=[],Ki=new i.Coordinate(0,0),Xi=new i.Point(0,0),Wi=[0,0,0,0,0,0,0,0,0],Qi=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ts=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],es=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ns=new i.Point(0,0),rs=n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),is=[0,0],ss=[0,0,0],os=[1,1,1],as=[0,0,0],cs=[0,0,0],ls=[0,0,0,0],us=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class hs extends(n.MaskLayerMixin(i.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new hs(t.id,t.options):null}static getEnuTransform(t,e=[1,1,1],r=[0,0,0]){const i=Ae([],t[0]*Math.PI/180,t[1]*Math.PI/180,t[2]||0),s=fn(i,null,[]),o=n.quat.fromEuler([0,0,0,0],...r),a=n.mat4.fromRotationTranslationScale([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,[0,0,0],e);return n.mat4.multiply(a,s,a)}constructor(t,e){super(t,e),this.isGeo3DTilesLayer=!0,this.Ke(),this.Xe=new Map}Ke(){const t=this.options.services.map((t=>t.url));this.We=this.We||{},this.Pe=this.Pe||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.We[n];void 0===r&&(r=this.We[n]=this.Pe.length),this.Pe[r]=ms(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Pe.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Qe(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Ke(),this.Qe(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(bs(n[t].coordOffset,e.coordOffset)&&bs(n[t].heightOffset,e.heightOffset)&&bs(n[t].scale,e.scale)&&bs(n[t].rotation,e.rotation)),pt(n[t],e));const i=n[t].url,s=this.We[i],o=this.Pe&&this.Pe[s];return o&&(yt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Qe(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.We[n];this.Pe[r]&&(this.Pe[r]=null),delete this.We[n],e.splice(t,1)}return this.Qe(),this}getTileUrl(t,e){const n=e&&e.service&&e.service.subdomains;if(n&&e.domainKey){const r=n.length;if(r){const i=[...t].reduce(((t,e)=>t+e.charCodeAt(0)),0)%r;return t.replace(e.domainKey,n[i])}}return t}getExtent(t){if(!t&&0!==t){const t=new i.Extent;for(let e=0;e<this.Pe.length;e++){const n=this.Pe[e];if(n&&n.boundingVolume){const e=this.boundingVolumeToExtent(n);t._combine(e)}}return t}const e=this.Pe[t];return e&&e.boundingVolume?this.boundingVolumeToExtent(e):null}boundingVolumeToExtent(t){const e=t.boundingVolume.tn?rs:t.matrix,r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),o=this.getRenderer();if(t.boundingVolume.region){const e=t.boundingVolume.region;return new i.Extent(Tt(e[0]),Tt(e[1]),Tt(e[2]),Tt(e[3]))}if(t.boundingVolume.sphere){const a=t.boundingVolume.sphere,c=Ne([],n.vec3.transformMat4([0,0,0],a,e));s&&o.Je(c,c);const l=a[3],u=r.locate(c,-l,l),h=r.locate(c,l,-l);return new i.Extent(u,h)}if(t.boundingVolume.box){const a=t.boundingVolume.box,c=n.vec3.transformMat4([0,0,0],a,e),l=new i.Coordinate(Ne([],c));s&&o.Je(l,l);const u=a.slice(3);n.mat3.multiply(u,n.mat3.fromMat4([0,0,0,0,0,0,0,0,0],t.matrix),u);const h=n.vec3.length(u.slice(0,3)),f=n.vec3.length(u.slice(3,6)),d=n.vec3.length(u.slice(6,9)),m=Math.max(h,f,d),y=r.locate(l,-m,m),p=r.locate(l,m,-m);return new i.Extent(y,p)}return null}getRootTiles(){return this.Pe}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Qe(),{tiles:Zi};const e=this.getMap(),r=e.cameraPosition,i=e.pointAtResToDistance(r[2],0,e.getGLRes()),s=this.nn(r);this.rn=this.rn||[0,0,0],n.vec3.set(this.rn,wt(s.x),wt(s.y),i),this.sn=Ae(this.sn||[],this.rn[0],this.rn[1],this.rn[2]),this.an=2*Math.tan(.5*wt(e.getFov()));const o=e.projViewMatrix;let a;if(e.getPitch()<=80){const t=e.getExtent(),n=t.getWidth()/2,r=t.getHeight()/2;t.xmin-=n,t.ymin-=r,t.xmax+=n,t.ymax+=r,a=Ui(t)}const c=(this.getMasks()||[]).filter((t=>t&&t instanceof n.ClipOutsideMask));c.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=Ui(e)}catch(t){console.error(t)}}));const l={children:[],level:-1};let u=l;const h=[];for(let e=0;e<this.Pe.length;e++){const n=this.Pe[e];if(!n||!n.visible)continue;const r=n.service,i=[n],s=this.cn(e);for(;i.length>0;){const e=i.pop();for(e.id||this.ln(e);u.level>=e.ke;)u=u.parent;const n=this.un(e,s,o,a,c);if(e.service=r,!(n===gs.VISIBLE||n!==gs.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&ps(e))){let t=u;for(;t&&!t.content;)t=t.parent;n===gs.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.hn(h,t);continue}e.ft<1/0&&this.dn(e);const l=this.Ne(e,u);u.children.push(l);const f=e.children,d=f&&f.length,m=l.content;if(m&&(!d||n===gs.SCREEN_ERROR_TOO_SMALL)&&this.hn(h,l),n!==gs.SCREEN_ERROR_TOO_SMALL&&d){m&&"add"===e.refine&&this.hn(h,l),u=l;const n=f[0].parent;let r=!1;for(let s=0,o=f.length;s<o;s++){if(n){const e=t.getCachedTile(f[s].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,f[s].parent=e,f[s].xt=e.xt,f[s].baseUrl=e.baseUrl;const t=f[s].content&&(f[s].content.url||f[s].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?f[s].baseUrl=e.baseUrl:Pt(t)?f[s].content.url=e.baseUrl+t:f[s].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}i.push(f[s])}!r&&m&&this.hn(h,l)}}}return{root:l,tiles:h}}hn(t,e){const{viewerRequestVolume:n,matrix:r}=e.node;n&&!function(t,e,n,r){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return fs(n,e,r)<=0;if(n.box)return 0===ds(n,e,r)}return!1}(this.rn,this.sn,n,r)||t.push(e)}Ne(t,e){return{id:t.id,node:t,children:[],level:t.ke,parent:e,content:t.content&&t.content.url}}ln(t){const e=this.getId();t.id=e+":"+i.Util.GUID(),t.matrix=t.transform||n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t.mn=this.yn(t),t.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(t)||(t.matrix=n.mat4.multiply(t.matrix,t.parent.matrix,t.matrix)),t.H=t.parent.H,void 0===t.ke&&(t.ke=t.parent.ke+1),t.maxExtent=t.parent.maxExtent),t.refine=t.refine&&t.refine.toLowerCase()||"replace",t.content&&!t.content.url&&t.content.uri&&(t.content.url=t.content.uri)}j(t){return this.Pe[t].service}pn(t){const e=t.boundingVolume;if(!e||e.tn&&!this.bn(t))return;const r=this.j(t.H),i=r.heightOffset||0,s=this.options.offset,o=bt(s)||s[0]||s[1],a=r.coordOffset||is;if(!Array.isArray(a))throw new Error("service.coordOffset must be an array");if(!e.tn&&(!t.boundingVolume||!i&&0!==i&&n.mat4.exactEquals(t.matrix,rs)&&!o&&a===is))return;e.box&&e.region&&delete e.region;const{region:c,box:l,sphere:u}=e;if(e.coordOffset=[a[0],a[1]],e.heightOffset=i,c){e.originalVolume||(e.originalVolume=c.slice(0));const t=e.originalVolume,n=this.gn([Tt(t[0]),Tt(t[1])]);c[0]=wt(n.x+a[0]),c[1]=wt(n.y+a[1]);const r=this.gn([Tt(t[2]),Tt(t[3])]);c[2]=wt(r.x+a[0]),c[3]=wt(r.y+a[1]),c[4]=t[4]+i+(a[2]||0),c[5]=t[5]+i+(a[2]||0)}else if(l||u){e.originalVolume||(e.originalVolume=(l||u).slice(0));const r=l||u,s=e.originalVolume,o=n.vec3.transformMat4(Gi,s,t.matrix),c=Ne(Di,o),h=this.gn([c[0]+a[0],c[1]+a[1]]);c[0]=h.x,c[1]=h.y,c[2]+=i+(a[2]||0),Ae(r,wt(c[0]),wt(c[1]),c[2])}e.tn=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}bn(t){const e=t.boundingVolume,n=this.j(t.H),r=n.heightOffset||0,i=n.coordOffset||is;return e.coordOffset[0]!==i[0]||e.coordOffset[1]!==i[1]||e.heightOffset!==r}yn(t){return void 0===t.geometricError||!t.boundingVolume}dn(t){let e=t.parent;for(;e&&e.mn&&!(e.ft<=t.ft);)e.ft=t.ft,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1),this.Qe()}}onTilesetLoad(t,e,r){if(!t)return void console.warn("invalid tileset at : "+r);const i=(t.asset&&t.asset.gltfUpAxis||e&&e.xt||"Y").toUpperCase();t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const s=r.indexOf("realspace/")>-1;0===e.ke&&t.asset&&t.asset.s3mType&&s&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.xt=i,e){const r=e.boundingVolume,i=e.vn;i&&delete e.vn,pt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",r&&(e.boundingVolume=r);let s=t.root.transform;if(i){const t=this.j(e.H);t.ecefTransform&&(s=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.ecefTransform,s||rs))}s&&(e.parent?o||(e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,s)):e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.matrix,s)),delete e.content,t.root.content&&(e.content=t.root.content),e.mn=this.yn(e);const a=e.content&&(e.content.url||e.content.uri);a&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!o&&a&&!Ct(a)&&Pt(a)&&(e.content.url=e.baseUrl+a),t.root&&!e.parent&&this.wn(e)}this.Qe(),this.fire("loadtileset",{tileset:t,index:e&&e.H,url:r})}Tn(t,e,n){if(!t.extent||!Bi)return!0;const r=t.extent;if(ls[0]=r.xmin,ls[1]=r.ymin,ls[2]=r.xmax,ls[3]=r.ymax,e){if(!Bi.bboxIntersect(ls,e))return!1}if(n.length){for(let t=0,e=n.length;t<e;t++){const e=n[t].maskGeoJSON;if(!e||!e.bbox||Bi.bboxInMask(ls,e))return!0}return!1}return!0}un(t,e,n,r,i){if(!this.Tn(t,r,i))return gs.OUT_OF_FRUSTUM;if(t.ft=1/0,0===t.ke||t.mn)return this.wn(t),gs.VISIBLE;if(this.pn(t),!this.Mn(t,e,n))return gs.OUT_OF_FRUSTUM;if(0===t.geometricError)return gs.VISIBLE;let s=this.j(t.H).maximumScreenSpaceError;null==s&&(s=16);let o=this._n(t);return 0===o&&t.parent&&(o=.5*(t.parent.On||0)),o>=s?gs.VISIBLE:gs.SCREEN_ERROR_TOO_SMALL}Kt(t,e){e||(e=new i.Point(0,0));const n=this.getMap();return n.coordToPointAtRes(t,n.getGLRes(),e)}Mn(t,e,n){const r=t.id;let i=this.Xe.get(r);const{boundingVolume:s}=t,o=s.region,a=s.box,l=s.sphere,u=this.An(t.H),h=this.getRenderer();i&&i.version===u.version||(o?i=this.xn(t):a?i=this.In(t):l&&(i=this.Sn(t)),i&&this.Xe.set(r,i),i.version=u.version,t.dt&&(h.Dt(t.dt),delete t.dt));this.j(t.H).debug&&(this.Xe.get(r).node=t,h.Ft(t));const f=i.obbox;return f?function(t,e,n){M(t);for(var r=0;r<6;r++)if(!T(c[r],e))return!1;return!0}(n,f):!!l&&function(t,e,n){M(t);for(var r=e[0],i=-e[1],s=0;s<6;s++)if(O(c[s],r)<i)return!1;return!0}(n,i.sphereBox)}xn(t){const e=this.getMap(),r=e.getGLRes(),s=t.boundingVolume.region;let{ws:o,en:a}=function(t){const e=t[0],n=t[1],r=t[2],i=t[3],s=t[4],o=t[5],a=Ae([],e,n,s),c=Ae([],r,i,o),l=Ne(a,a),u=Ne(c,c);return{ws:l,en:u}}(s);o=new i.Coordinate(o),a=new i.Coordinate(a);const c=e.coordToPointAtRes(o,r);c.z=e.altitudeToPoint(o.z,r);const l=e.coordToPointAtRes(a,r);l.z=e.altitudeToPoint(a.z,r);const u=[l.x,c.y,l.z,l.x,l.y,l.z,c.x,l.y,l.z,c.x,c.y,l.z,l.x,c.y,c.z,l.x,l.y,c.z,c.x,l.y,c.z,c.x,c.y,c.z],h=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],f=this.An(t.H);t!==f||f.Cn||(f.Cn=h);const d=this.Jt([],t),m=n.mat4.exactEquals(rs,d);if(!m){n.vec3.transformMat4(h,h,d);const t=Gi;for(let e=0;e<u.length;e+=3){let r=n.vec3.set(t,u[e],u[e+1],u[e+2]);m||(r=n.vec3.transformMat4(r,r,d)),u[e]=r[0],u[e+1]=r[1],u[e+2]=r[2]}}const y=e.pointAtResToCoord(new i.Point(h),r);y.z=(o.z+a.z)/2;const p=this.kn(u,h);for(let t=0;t<u.length;t++)u[t]-=h[t%3];return{obbox:p,boxPosition:u,boxCenter:h,boxCoord:y}}In(t){const e=this.getRenderer(),r=this.getMap(),i="identity"===r.getProjection().code.toLowerCase(),s=r.getGLRes(),{boxCenter:o,boxCoord:a}=this.Nn(t),c=t.boundingVolume.box,l=function(t,e,n){return function(t,e,n,r,i,s,o,a,c,l,u,h,f,d,m,y,p){return t[0]=e||0,t[1]=s||0,t[2]=l||0,t[3]=0,t[4]=n||0,t[5]=o||0,t[6]=u||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=h||0,t[11]=0,t[12]=i||0,t[13]=c||0,t[14]=f||0,t[15]=p,t}(t,e[0],e[3],e[6],n[0],e[1],e[4],e[7],n[1],e[2],e[5],e[8],n[2],0,0,0,1)}([],this.Ln(c,t.matrix),c),u=this.Jt([],t),h=n.mat4.exactEquals(rs,u);h||n.vec3.transformMat4(o,o,u);const f=[],d=Gi;for(let t=0;t<us.length;t+=3){d[0]=us[t],d[1]=us[t+1],d[2]=us[t+2],n.vec3.transformMat4(d,d,l),Ne(d,d),i&&e.Je(d,d);const o=Ki.set(d[0],d[1],d[2]);r.coordToPointAtRes(o,s,Xi);let a=n.vec3.set(d,Xi.x,Xi.y,r.altitudeToPoint(o.z,s));h||(a=n.vec3.transformMat4(a,a,u)),f[t]=a[0],f[t+1]=a[1],f[t+2]=a[2]}const m=this.kn(f,o);for(let t=0;t<f.length;t++)f[t]-=o[t%3];return{obbox:m,boxPosition:f,boxCenter:o,boxCoord:a}}Sn(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),s=t.boundingVolume.sphere,o=s;let a=Gi;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:Ne(a,o),r&&n.Je(a,a);const c=new i.Coordinate(a),l=this.Kt(c,Xi).toArray();l[2]=e.altitudeToPoint(c.z,e.getGLRes());const u=this.En(c);return{boxCenter:l,boxCoord:c,sphereBox:[l,s[3]*u[2]]}}kn(t,e){const r=ys(Hi,t,0,1,4,5),i=ys(qi,t,0,3,4,7),s=ys($i,t,0,1,2,3);return[...e,...n.vec3.sub(Gi,r,e),...n.vec3.sub(Di,i,e),...n.vec3.sub(ji,s,e)]}Nn(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),s=e.getGLRes(),o=t.boundingVolume.box.slice(0,3);Ne(o,o),r&&n.Je(o,o);const a=new i.Coordinate(o),c=e.coordToPointAtRes(a,s);return{boxCenter:[c.x,c.y,e.altitudeToPoint(a.z,s)],boxCoord:a}}Jt(t,e){const r=this.An(e.H),i=this.j(e.H),s=r.Cn,o=n.mat4.fromTranslation(Qi,n.vec3.set(Gi,-s[0],-s[1],-s[2])),a=n.mat4.fromTranslation(ts,s),c=i.rotation||ss,l=n.quat.fromEuler(Yi,...c),u=i.scale;let h;h=Array.isArray(u)?n.vec3.set(as,u[0],u[1],u[2]):u&&n.vec3.set(as,u,u,u)||os;const f=n.mat4.fromRotationTranslationScale(es,l,cs,h);return t=n.mat4.multiply(t,f,o),n.mat4.multiply(t,a,t)}wn(t){const e=this.j(t.H);if(!t.boundingVolume||this.Rn(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,i=t.boundingVolume.sphere;let s=null;n?s=this.Pn(t).boxCenter:r?s=this.Un(t).boxCenter:i&&(s=this.Sn(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.Bn=[a[0]||0,a[1]||0],t.Fn=o,t.Cn=s}Rn(t,e){if(!t.Bn)return!1;const n=e.coordOffset||is;return t.Bn[0]===n[0]&&t.Bn[1]===n[1]&&t.Fn===(e.heightOffset||0)}Un(t){return this.pn(t),this.xn(t)}Pn(t){return this.pn(t),this.Nn(t)}Ln(t,e){let r=t.slice(3,12);const i=n.mat3.fromMat4(Wi,e);return r=n.mat3.multiply(r,i,r),r}En(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let i;return i=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:r.y/100,n.vec3.set(Vi,r.x/100*1.01,r.y/100*1.01,i),Vi}gn(t){Array.isArray(t)&&(t=new i.Coordinate(t));let e=this.options.offset;if(bt(e)&&(e=e.call(this,Array.isArray(t)?new i.Coordinate(t):t)),e[0]||e[1]){const n=this.getMap(),r=n.getGLRes(),i=n.coordToPointAtRes(t,r);return Xi.set(e[0],e[1]),i._sub(Xi),n.pointAtResToCoord(i,r)}return t}An(t){return this.Pe[t]}cn(t){const e=this.j(t).maxExtent;if(!e)return null;const n=this.Pe[t];return n.maxExtent||(n.maxExtent=new i.Extent(e).convertTo((t=>this.Kt(t)))),n.maxExtent}_n(t){const e=this.an,r=t.geometricError;if(0===r)return t.On=0,0;const i=this.j(t.H);let s=i.scale||1;if(Array.isArray(s)&&(s=n.vec3.length(s)),i.ecefTransform){const t=n.mat4.getScaling(Ji,i.ecefTransform);s*=n.vec3.len(t)}const o=this.getMap();let a;t.boundingVolume.region?a=function(t,e,n){t.Gn||(t.Gn=new Ri(t.boundingVolume.region));return t.Gn.distanceToCamera(e,n)}(t,this.sn,this.rn):t.boundingVolume.sphere?a=fs(t.boundingVolume,this.sn):t.boundingVolume.box&&(a=ds(t.boundingVolume,this.sn));const c=Math.max(Math.abs(a),1e-7),l=r*s*o.height/(c*e);return t.ft=a,t.On=l,l}Qe(){const t=this.getRenderer();t&&t.setToRedraw()}Gt(t){return this.Xe.get(t)}identify(t,e={}){const n=this.getMap(),r=this.getRenderer();if(!n||!r)return[];Array.isArray(t)&&(t=new i.Coordinate(t));const s=n.coordToContainerPoint(t);return this.identifyAtPoint(s,e)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&Nt(n,r)}const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];const s=r.getDevicePixelRatio();return Nt(n,i.pick(t.x*s,t.y*s,e)),e&&e.filter&&!e.excludeMasks?n.filter((t=>e.filter(t))):n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Wt():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.J||(this.J=[]),this.J.push(t),this)}ze(){if(this.J){for(let t=0;t<this.J.length;t++)this.highlight(this.J[t]);delete this.J}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Z||(this.Z=[]),this.Z.push(t),this)}Dn(){if(this.Z){for(let t=0;t<this.Z.length;t++)this.showOnly(this.Z[t]);delete this.Z}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);return this.getRenderer()?(this.Qe(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Qe(),this):this}nn(t){const e=this.getMap(),n=e.getGLRes();ns.set(t[0],t[1]);const r=e.pointAtResToCoord(ns,n);return"identity"===e.getProjection().code.toLowerCase()?(Di[0]=r.x,Di[1]=r.y,this.getRenderer().Ye(Gi,Di),r.set(Gi[0],Gi[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function fs(t,e,r){let i=t.sphere;r&&(i=n.vec3.transformMat4([0,0,0],i,r));const s=n.vec3.dist(i,e),o=t.sphere[3];return s<o?0:s-o}function ds(t,e,r){const i=t.box;let s=n.vec3.set(Gi,i[0],i[1],i[2]);r&&(s=n.vec3.transformMat4([0,0,0],s,r));return hi(s,n.mat3.set(Wi,i[3],i[4],i[5],i[6],i[7],i[8],i[9],i[10],i[11]),e)}function ms(t,e,r){const i=(t=Mt(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,mn:!0,service:r,visible:!!yt(r.visible)||r.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),H:e,ke:0,vn:!0,domainKey:i}}function ys(t,e,r,i,s,o){const a=n.vec3.set(Gi,e[3*r],e[3*r+1],e[3*r+2]),c=n.vec3.set(Di,e[3*i],e[3*i+1],e[3*i+2]),l=n.vec3.set(ji,e[3*s],e[3*s+1],e[3*s+2]),u=n.vec3.set(zi,e[3*o],e[3*o+1],e[3*o+2]);return t[0]=(a[0]+c[0]+l[0]+u[0])/4,t[1]=(a[1]+c[1]+l[1]+u[1])/4,t[2]=(a[2]+c[2]+l[2]+u[2])/4,t}function ps(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e&&(e.content||e.hasParentContent))return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function bs(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?n.vec2.exactEquals(t,e):n.vec3.exactEquals(t,e):t===e}var gs;hs.mergeOptions(Fi),hs.registerRenderer("gl",ci),hs.registerRenderer("gpu",ci),hs.registerJSONType("Geo3DTilesLayer"),function(t){t[t.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",t[t.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",t[t.VISIBLE=2]="VISIBLE"}(gs||(gs={}));let vs=null;function ws(){return vs||(vs={"image/crn":Gt.crn&&Gt.crn(),"image/ktx2":Gt.ktx2&&Gt.ktx2(),"image/cttf":Gt.ktx2&&Gt.ktx2(),"draco":Gt.draco&&Gt.draco()}),vs}const{Ajax:Ts,GLTFLoader:Ms}=Dt();class _s{constructor(t,e,n){this.jn=t,this.zn=e||Ms,this.Re=n,this.Hn=ws()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.qn(t,e,n,r,i)):Ts.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.qn(t,i,n,r)}))}qn(t,e,n,r,i){const s=i&&i.maxTextureSize,o=this.$n(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.zn(a,o.glb,{transferable:!0,requestImage:this.jn,decoders:this.Hn,supportedFormats:this.Re,maxTextureSize:s})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}$n(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),l=i.getUint32(20,!0),u=i.getUint32(24,!0),h=28+e;l>=570425344?(h-=8,o=a,l=c,u=0,a=0,c=0):u>=570425344&&(h-=4,o=l,l=a,u=c,a=0,c=0);const f=[t];let d,m,y;if(a>0?(d=He(t,h,a),h+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(h+=c),l>0&&(m=qe(t,h,l),h+=l,u>0)){const e=$e(0,h,u);y=t.slice(e.offset,e.offset+e.byteLength),h+=u,f.push(y)}const p=d.BATCH_LENGTH,b={};if(d&&d.BATCH_ID){b.BATCH_ID=Je(d.BATCH_ID,t,undefined.offset,p);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:y,b3dm:b,glb:{buffer:t,byteOffset:h,byteLength:i.byteLength+i.byteOffset-h}}}Vn(){return null}}const{Ajax:Os,GLTFLoader:As}=Dt();class xs{constructor(t,e,n,r){this.jn=t,this.zn=e||As,this.Re=n,this.Hn=ws(),this.Jn=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.qn(t,e,n,r,i)):Os.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.qn(t,i,n,r)}))}qn(t,e,n,r,i){return this.Yn(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.Zn(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}Yn(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.jn,decoders:this.Hn,supportedFormats:this.Re,maxTextureSize:s},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=At(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?Os.getArrayBuffer(r,{}).then((t=>this.Kn(r,{buffer:t.data,byteOffset:0},o))):Os.getJSON(r,{}).then((t=>this.Kn(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Kn(t,r,o)}}Kn(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),i=new this.zn(r,e,n);return i.load({skipAttributeTransform:!0}).then((n=>{let r=0,s=0;return e.buffer&&(r=e.byteOffset||0,s=e.byteLength||0),n.url=`${t}-${r}-${s}`,{transferables:i.transferables,gltf:n}}))}Zn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:u}=en(i,32+e,o),h={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;h.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).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:f,componentType:5126,array:this.Xn(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(h.POSITION.array.buffer)}if(a.BATCH_ID){h.BATCH_ID=Je(a.BATCH_ID,t,c.offset,f);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:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).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:f,componentType:5126,array:this.Wn(new Uint16Array(t,e+c.offset,2*f))},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Wn(new Uint16Array(t,e+c.offset,2*f))},o.push(h.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;h.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).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:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(h.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:l,batchTableBin:u,featureTable:a,i3dm:h,transferables:o}}Wn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)Is(r,t[2*i],t[2*i+1],65535),n[3*i]=r[0],n[3*i+1]=r[1],n[3*i+2]=r[2];return n}Xn(t,e,n){return tn(new Float32Array(t.length),t,e,n)}Vn(){return null}}function Is(t,e,n,r){if(t[0]=Ss(e,r),t[1]=Ss(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]))*Cs(e),t[1]=(1-Math.abs(e))*Cs(t[1])}return ne(t,t)}function Ss(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 Cs(t){return t<0?-1:1}const{Ajax:ks}=Dt();class Ns{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.qn(t,e,n,r)):ks.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.qn(t,i,n,r)}))}qn(t,e,n,r){return this.Qn(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}))}Qn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:u}=en(i,e+28,o),h=a.QUANTIZED_VOLUME_OFFSET,f=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,y={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){y=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,y.byteOffset+c.offset,y.byteLength);const e={attributes:y.properties,useUniqueIDs:!1};return this.tr||(this.tr=ws().draco),this.tr(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.er(t,e.attributes,c.offset,d,o,h,f);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Qe(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?r.BATCH_ID=Je(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Ls(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:l,batchTableBin:u,featureTable:a,pnts:r,transferables:o}}))}const p=this.er(t,a,c.offset,d,o,h,f);if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?p.BATCH_ID=Je(a.BATCH_ID,t,c.offset,d):p.BATCH_ID=Ls(d);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:l,batchTableBin:u,featureTable:a,pnts:p,transferables:o})}er(t,e,n,r,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:l}=e.POSITION_QUANTIZED;c=c||0;const u=l?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Xn(l||new Uint16Array(t,c+u,3*r),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},i.push(o.buffer)}return a}Xn(t,e,n){return tn(new Float32Array(t.length),t,e,n)}Vn(){return null}}function Ls(t){const e=St(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:Qe(e),array:n}}const{Ajax:Es,GLTFLoader:Rs}=Dt();class Ps{constructor(t,e,n,r){this.Re=n,this.jn=t,this.zn=e||Rs,this.Jn=r}load(t,e,n=0,r=0,i){return e?this.qn(t,e,n,r,i):Es.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.qn(t,i,n,r)}))}qn(t,e,n,r,i){r||(r=e.byteLength);const s=this.nr(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new _s(this.jn,this.zn,this.Re);else if("i3dm"===s[n].magic)r=new xs(this.jn,this.zn,this.Re,this.Jn);else if("pnts"===s[n].magic)r=new Ns;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new Ps(this.jn,this.zn,this.Re,this.Jn)}o.push(r.load(t,e,s[n].offset,s[n].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}nr(t,e,n,r){const i=new DataView(t,n,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=je(i,c),r=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(s.transcoders){const t=i.Map.VERSION;if(t.indexOf("1.0.0-beta")>=0||t.indexOf("1.0.0-alpha")>=0){const t=s.transcoders.inject(a);i.registerWorkerAdapter("@maptalks/3dtiles",t)}else i.registerWorkerAdapter("@maptalks/3dtiles",(function(){return s.transcoders.inject(a)}))}else i.registerWorkerAdapter("@maptalks/3dtiles",a);t.B3DMLoader=_s,t.CMPTLoader=Ps,t.Geo3DTilesLayer=hs,t.Geo3DTilesUtil=Rt,t.Geo3DTransform=Ge,"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.123.0")}));
|
|
16
|
+
*/function Dt(){return Bt().maptalks_gltf_loader}Gt.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=Ft.gl_trans__coders=Ft.gl_trans__coders||{};let s=`${r}\n const _____getGlobal = ${Bt.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\n;");return s+="\n("+Bt().maptalks_gltf_loader_bundle.toString()+")({});\n",s+="\n"+e.substring(r.length),s},Gt.registerTranscoder=function(t,e){Gt[t]=e},Gt.getTranscoder=function(t){return Gt[t]};const jt="undefined"==typeof document?null:document.createElement("canvas");class zt extends i.worker.Actor{constructor(t,e,n){super(t),this.mapId=e,this.i=n}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const i={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(i,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(!jt)return void e(new Error("There is no canvas to draw image!"));const t=this.i?n:function(t){if(Ht(t.width)&&Ht(t.height))return t;let e=t.width,n=t.height;Ht(e)||(e=qt(e));Ht(n)||(n=qt(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const i=t.src,s=i.lastIndexOf("/")+1,o=i.substring(s);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);jt.width=t.width,jt.height=t.height;const r=jt.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),s={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,s,[s.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function Ht(t){return!(t&t-1)&&0!==t}function qt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var $t=1e-6,Vt="undefined"!=typeof Float32Array?Float32Array:Array;function Jt(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],h=e[8],f=e[9],d=e[10],m=e[11],y=e[12],p=e[13],b=e[14],g=e[15],v=n[0],w=n[1],T=n[2],M=n[3];return t[0]=v*r+w*a+T*h+M*y,t[1]=v*i+w*c+T*f+M*p,t[2]=v*s+w*l+T*d+M*b,t[3]=v*o+w*u+T*m+M*g,v=n[4],w=n[5],T=n[6],M=n[7],t[4]=v*r+w*a+T*h+M*y,t[5]=v*i+w*c+T*f+M*p,t[6]=v*s+w*l+T*d+M*b,t[7]=v*o+w*u+T*m+M*g,v=n[8],w=n[9],T=n[10],M=n[11],t[8]=v*r+w*a+T*h+M*y,t[9]=v*i+w*c+T*f+M*p,t[10]=v*s+w*l+T*d+M*b,t[11]=v*o+w*u+T*m+M*g,v=n[12],w=n[13],T=n[14],M=n[15],t[12]=v*r+w*a+T*h+M*y,t[13]=v*i+w*c+T*f+M*p,t[14]=v*s+w*l+T*d+M*b,t[15]=v*o+w*u+T*m+M*g,t}function Yt(){var t=new Vt(3);return Vt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Zt(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function Kt(t,e,n){var r=new Vt(3);return r[0]=t,r[1]=e,r[2]=n,r}function Xt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Wt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function Qt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function te(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function ee(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function ne(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function re(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ie(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[0],a=n[1],c=n[2];return t[0]=i*c-s*a,t[1]=s*o-r*c,t[2]=r*a-i*o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var se=Qt,oe=te,ae=Zt;function ce(){var t=new Vt(4);return Vt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}Yt(),function(){var t,e=(t=new Vt(4),Vt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var le;Yt(),Kt(1,0,0),Kt(0,1,0),ce(),ce(),le=new Vt(9),Vt!=Float32Array&&(le[1]=0,le[2]=0,le[3]=0,le[5]=0,le[6]=0,le[7]=0),le[0]=1,le[4]=1,le[8]=1;const{GLTFLoader:ue}=Dt();function he(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,i=r.length;n<i;n++){const i=[];ge(r[n],i,t,e)}}}const fe=[],de=[],me=[],ye=[0,0,0],pe=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),be=[1,1,1];function ge(t,e,n,r){const i=e.slice(0);if(t.matrix)i.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(fe,t.translation||ye),n=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,l=n*o,u=r*o,h=r*a,f=i*o,d=i*a,m=i*c,y=s*o,p=s*a,b=s*c;return t[0]=1-h-m,t[1]=u+b,t[2]=f-p,t[3]=0,t[4]=u-b,t[5]=1-l-m,t[6]=d+y,t[7]=0,t[8]=f+p,t[9]=d-y,t[10]=1-l-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(de,t.rotation||pe),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(me,t.scale||be);Jt(r,n,r);const s=Jt([],e,r);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)ge(t.children[e],i,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,r(s,e,i,n))}}}}function ve(t,e,n){let{byteOffset:r,byteStride:i}=e;const{componentType:s,itemSize:o}=e,a=e.array.buffer,c=s?ue.getTypedArrayCtor(s):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,i=i||0,!i||i===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}i||(i=o*c.BYTES_PER_ELEMENT);const l=new Uint8Array(a,i*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(l),t}function we(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}var Te="#include <gl2_vert>\nconst float SHIFT_RIGHT_11 = 1.0 / 2048.0;\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\nconst float SHIFT_LEFT_11 = 2048.0;\nconst float SHIFT_LEFT_5 = 32.0;\nconst float NORMALIZE_6 = 1.0 / 64.0;\nconst float NORMALIZE_5 = 1.0 / 32.0;\n#ifdef HAS_POSITION\n attribute vec3 POSITION;\n#endif\n#if defined(HAS_RGB)\n attribute vec3 RGB;\n#elif defined(HAS_RGBA)\n attribute vec4 RGBA;\n#elif defined(HAS_RGB565)\n attribute float RGB565;\n#endif\nuniform vec4 pointColor;\nuniform float pointSize;\nuniform mat4 projViewModelMatrix;\nuniform float pointOpacity;\nvarying vec4 vColor;\n#ifdef HAS_NORMAL\n #ifdef HAS_NORMAL_OCT16P\n attribute vec2 NORMAL_OCT16P;\n float signNotZero(float value) {\n return value >= 0.0 ? 1.0 : -1.0;\n }\n vec2 signNotZero(vec2 value) {\n return vec2(signNotZero(value.x), signNotZero(value.y));\n }\n vec3 octDecode(vec2 encoded, float range) {\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n return vec3(0.0, 0.0, 0.0);\n }\n encoded = encoded / range * 2.0 - 1.0;\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n if (v.z < 0.0) {\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n }\n return normalize(v);\n }\n vec3 octDecode(vec2 encoded) {\n return octDecode(encoded, 255.0);\n }\n #else\n attribute vec3 NORMAL;\n #endif\n uniform vec3 lightDir;\n uniform mat3 modelNormalMatrix;\n uniform mat4 positionMatrix;\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n return max(dot(-lightDir, normal), 0.0);\n }\n#endif\n#ifdef PICKING_MODE\n #include <fbo_picking_vert>\n#endif\n#include <draco_decode_vert>\nvoid main() {\n #ifdef HAS_POSITION\n vec3 localPos = decode_getPosition(POSITION);\n #endif\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n gl_PointSize = pointSize;\n #ifdef PICKING_MODE\n fbo_picking_setData(gl_Position.w, true);\n #else\n #if defined(HAS_RGB)\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n #elif defined(HAS_RGBA)\n vColor = RGBA / 255.0 * pointOpacity;\n #elif defined(HAS_RGB565)\n float compressed = RGB565;\n float r = floor(compressed * SHIFT_RIGHT_11);\n compressed -= r * SHIFT_LEFT_11;\n float g = floor(compressed * SHIFT_RIGHT_5);\n compressed -= g * SHIFT_LEFT_5;\n float b = compressed;\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n vColor = vec4(rgb, 1.0);\n #else\n vColor = pointColor;\n #endif\n #ifdef HAS_NORMAL\n mat3 positionNormalMatrix = mat3(positionMatrix);\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n #ifdef HAS_NORMAL_OCT16P\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n #else\n vec3 localNormal = NORMAL;\n #endif\n vec3 normal = normalize(normalMatrix * localNormal);\n float colorStrength = getLambertDiffuse(lightDir, normal);\n colorStrength = max(colorStrength, 0.5);\n vColor *= colorStrength;\n #endif\n #endif\n}\n";const Me=new Array(3),_e=new Array(3),Oe=[40680631590769,40680631590769,40408299984661.445];function Ae(t,e,n,r){const i=Oe,s=Math.cos(n);Me[0]=s*Math.cos(e),Me[1]=s*Math.sin(e),Me[2]=Math.sin(n),Ue(Me,Me),te(_e,i,Me);const o=Math.sqrt(re(Me,_e));var a,c,l;return c=_e,l=o,(a=_e)[0]=c[0]/l,a[1]=c[1]/l,a[2]=c[2]/l,ee(Me,Me,r),function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}(t,_e,Me)}const xe=[1/6378137,1/6378137,1/6356752.314245179],Ie=[1/40680631590769,1/40680631590769,1/40408299984661.445],Se=new Array(3),Ce=new Array(3),ke=new Array(3);function Ne(t,e){const n=Ie,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],l=n[1],u=n[2],h=s*s*c*c,f=o*o*l*l,d=a*a*u*u,m=h+f+d,y=Math.sqrt(1/m),p=ee(Le,e,y);if(m<i)return isFinite(y)?p:void 0;const b=r[0],g=r[1],v=r[2],w=Ee;w[0]=p[0]*b*2,w[1]=p[1]*g*2,w[2]=p[2]*v*2;let T,M,_,O,A,x,I,S,C,k,N,L=(1-y)*Pe(e)/(.5*Pe(w)),E=0;do{L-=E,_=1/(1+L*b),O=1/(1+L*g),A=1/(1+L*v),x=_*_,I=O*O,S=A*A,C=x*_,k=I*O,N=S*A,T=h*x+f*I+d*S-1,M=h*C*b+f*k*g+d*N*v;E=T/(-2*M)}while(Math.abs(T)>Re);return t[0]=s*_,t[1]=o*O,t[2]=a*A,t}(Se,e,xe,n,.1);let i=oe(Ce,r,n);i=Ue(i,i);const s=se(ke,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=_t(re(s,e))*Pe(s);return t[0]=Tt(o),t[1]=Tt(a),t[2]=c,t}const Le=new Array(3),Ee=new Array(3),Re=1e-12;function Pe(t){return Zt(t)}function Ue(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function Be(t,e){return te(e,t,Ie),ne(e,e)}function Fe(t,e){const n=t[0],r=t[1],i=Math.cos(r),s=i*Math.cos(n),o=i*Math.sin(n),a=Math.sin(r);return e.x=s,e.y=o,e.z=a,ne(e,e)}var Ge=Object.freeze({__proto__:null,cartesian3ToDegree:Ne,geodeticSurfaceNormal:Be,geodeticSurfaceNormalCartographic:Fe,normalizeCartesian:Ue,radianToCartesian3:Ae});function De(t,e,n,r){n=n||0,r=r||n;const i=Math.abs(t-e);return i<=r||i<=n*Math.max(Math.abs(t),Math.abs(e))}function je(t,e){let n="";for(let r=0;r<4;r++){const i=t.getUint8(e+r);n+=String.fromCharCode(i)}return n}const ze="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function He(t,e,n){const r=new Uint8Array(t,e,n);return ze?JSON.parse(ze.decode(r)):JSON.parse(At(r))}function qe(t,e,n){const r=new Uint8Array(t,e,n);return ze?JSON.parse(ze.decode(r)):JSON.parse(At(r))}function $e(t,e,n){return{offset:e,byteLength:n}}function Ve(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=We(s||"UNSIGNED_SHORT"),l=Ke(o);return{byteStride:0,byteOffset:i+n,itemSize:l,count:r*l,componentType:c,array:new a(e,n+i,r*l)}}function Je(t,e,n,r){const i=Ve(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}function Ye(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a}=We(s||"UNSIGNED_SHORT"),c=Ke(o),l=new a(e,i,n*c);return 1===c?l[r]:l.subarray(r*c,r*c+c)}const Ze={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ke(t){return t?Ze[t]:1}const Xe={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function We(t){return Xe[t]}function Qe(t){for(const e in Xe)if(t===Xe[e].ctor)return Xe[e].type;throw new Error("unrecognized ctor:"+t)}function tn(t,e,n,r){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*r[0]+n[0],i[3*t+1]=e[3*t+1]/65535*r[1]+n[1],i[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return i}function en(t,e,n){const r=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,l={},u={},h=null;r>0&&(l=He(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(u=qe(a,e,s),e+=s);const f=$e(0,e,o);return h=a.slice(f.offset,f.offset+f.byteLength),n.push(h),{featureTable:l,featureTableBin:c,batchTable:u,batchTableBin:h}}const nn={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"}},rn={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},sn={},on={east:[],north:[],up:[],west:[],south:[],down:[]};let an=[],cn=[],ln=[];const un=[0,0,0];function hn(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 fn=function(t,e){const n=nn[t][e];let r;const i=t+e;return sn[i]?r=sn[i]:(r=function(r,i,s){if(a=un,c=(o=r)[0],l=o[1],u=o[2],h=a[0],f=a[1],d=a[2],Math.abs(c-h)<=$t*Math.max(1,Math.abs(c),Math.abs(h))&&Math.abs(l-f)<=$t*Math.max(1,Math.abs(l),Math.abs(f))&&Math.abs(u-d)<=$t*Math.max(1,Math.abs(u),Math.abs(d)))Xt(an,rn[t]),Xt(cn,rn[e]),Xt(ln,rn[n]);else if(De(r[0],0,1e-14)&&De(r[1],0,1e-14)){const i=_t(r[2]);Xt(an,rn[t]),Xt(cn,rn[e]),ee(cn,cn,i),Xt(ln,rn[n]),ee(ln,ln,i)}else{Be(r,on.up);const i=on.up,s=on.east;s[0]=-r[1],s[1]=r[0],s[2]=0,ne(on.east,s),ie(on.north,i,s),ee(on.down,on.up,-1),ee(on.west,on.east,-1),ee(on.south,on.north,-1),an=on[t],cn=on[e],ln=on[n]}var o,a,c,l,u,h,f,d;return s[0]=an[0],s[1]=an[1],s[2]=an[2],s[3]=0,s[4]=cn[0],s[5]=cn[1],s[6]=cn[2],s[7]=0,s[8]=ln[0],s[9]=ln[1],s[10]=ln[2],s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s},sn[i]=r),r}("east","north"),dn=[],mn=[],yn=[],pn=[],bn=[],gn=[],vn=[],wn={x:0,y:0},Tn={x:0,y:0},Mn=Math.PI/180;let _n;const On={width:100,height:10};let An=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),An=!0}catch(t){An=!1}function xn(){if(!_n){const{width:t,height:e}=On;An?_n=new OffscreenCanvas(t,e):(_n=document.createElement("canvas"),_n.width=t,_n.height=e)}return _n}class In{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e][0];n=Math.min(i,n),r=Math.max(i,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},On,e),this.o()}getImageData(){return this.imgData}o(){const t=xn(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const i=r.createLinearGradient(0,0,t.width,0),{colors:s,valueOffset:o}=this;for(let t=0,e=s.length;t<e;t++){const[e,n]=s[t],r=(e-this.min)/o;i.addColorStop(r,n)}r.fillStyle=i,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var Sn;function Cn(t){return null==t}function kn(t){return!Cn(t)}function Nn(t){return""===t}function Ln(t,e){var n,r,i;if(zn(t)){var s,o=t.stops&&"object"==typeof t.stops[0][0],a=o||kn(t.property),c=o||!a,l=t.type||e||"exponential";if("exponential"===l)s=Pn;else if("interval"===l)s=Rn;else if("categorical"===l)s=En;else if("identity"===l)s=Fn;else if("color-interpolate"===l)s=Bn;else{if("calculate-expression"!==l)throw new Error('Unknown function type "'+l+'"');s=Gn}if(o){var u={},h=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===u[f[0].zoom]&&(u[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),u[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in u)h.push([u[t].zoom,Ln(u[t])]);n=function(e,n){const r=Pn({stops:h,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,i=!1}else c?(n=function(e){const n=s(t,e);return"function"==typeof n?n(e):n},r=!0,i=!1):(n=function(e,n){const r=s(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,i=!0)}else n=function(){return t},r=!0,i=!0;return n.isZoomConstant=i,n.isFeatureConstant=r,n}function En(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function Rn(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function Pn(t,e){for(var n=kn(t.base)&&!Nn(t.base)?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:Dn(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(Sn=new Map);const Un={width:100,height:1};function Bn(t,e){const n=t.stops;if(n&&n.length>1){let t;if(Sn){const e=JSON.stringify(n);if(!Sn.has(e)){const t=new In(n,Un);Sn.set(e,t)}t=Sn.get(e)}else t=new In(n,Un);const[r,i,s,o]=t.getColor(e);return[r/255,i/255,s/255,o/255]}return n&&1===n.length?n[0][1]:null}function Fn(t,e){return n=e,r=t.default,kn(n)?n:kn(r)?r:kn(i)?i:null;var n,r,i}function Gn(t,e){const n=String(t.property),r=t.expression,i=e;function s(e){return Cn(e)||Nn(e)||isNaN(e)?t.default:e}if(!kn(e)||Nn(e)||isNaN(e)||e<0)return s(t.default);{const e=function t(e,n,r){const i=Number(r),s=String(n);return Array.isArray(e)?e.map((e=>t(e,s,i))):e===s?i:e}(r,n,i);return s(function e(n){if(!Array.isArray(n)){if("number"==typeof n)return n;throw new Error("Invalid expression format")}{const r=n[0];if(!["+","-","*","/"].includes(r))throw new Error(`Unknown operator: ${r}`);const i=n.slice(1).map((t=>e(t)));switch(r){case"+":return i.reduce(((t,e)=>t+e),0);case"-":return i.reduce(((t,e)=>t-e));case"*":return i.reduce(((t,e)=>t*e),1);case"/":return i.some((t=>0===t))?t.default:i.reduce(((t,e)=>t/e));default:throw new Error(`Unsupported operator: ${r}`)}}}(e))}}function Dn(t,e,n,r,i,s){return"function"==typeof i?function(){var o=i.apply(void 0,arguments),a=s.apply(void 0,arguments);return Dn(t,e,n,r,o,a)}:i.length?function(t,e,n,r,i,s){var o=[];for(let a=0;a<i.length;a++)o[a]=jn(t,e,n,r,i[a],s[a]);return o}(t,e,n,r,i,s):jn(t,e,n,r,i,s)}function jn(t,e,n,r,i,s){var o,a=r-n,c=t-n;return i*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+s*o}function zn(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type||t.expression&&"calculate-expression"===t.type)}function Hn(t){return qn(t,"exponential")}function qn(t,e){if(!zn(t))return function(){return t};let n=!0,r=!0;const i=(t=JSON.parse(JSON.stringify(t))).stops;if(i)for(let t=0;t<i.length;t++)if(zn(i[t][1])){const s=qn(i[t][1],e);n=n&&s.isZoomConstant,r=r&&s.isFeatureConstant,i[t]=[i[t][0],s]}const s=Ln(t,e);return s.isZoomConstant=n&&s.isZoomConstant,s.isFeatureConstant=r&&s.isFeatureConstant,s}const{getTextureMagFilter:$n,getTextureMinFilter:Vn,getTextureWrap:Jn,getMaterialType:Yn,getMaterialFormat:Zn,getPrimitive:Kn,getUniqueREGLBuffer:Xn,getArrayType:Wn}=n.reshader.REGLHelper,Qn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],tr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:er,logoutIBLResOnCanvas:nr,getIBLResOnCanvas:rr,getPBRUniforms:ir}=n.reshader.pbr.PBRUtils,sr={factor:0,units:0},or=[1,1,1,1],ar=[0,0,0],cr={specularStrength:0,materialShininess:1},lr=[1,1,1],ur=n.mat4.identity([]),hr=[0,0,0],fr=[0,0],dr=[],mr=t=>t.material instanceof n.reshader.PhongMaterial,yr=t=>t.material instanceof n.reshader.pbr.StandardMaterial,pr=[],br=new i.Coordinate(0,0),gr=new i.Point(0,0),vr=new i.Point(0,0),wr=new i.Point(0,0),Tr=[],Mr=[],_r=[],Or=[],Ar=[],xr=[],Ir=[],Sr=[],Cr=[],kr=[],Nr=[],Lr=[],Er=[],Rr=[],Pr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},Ur=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],Br=function(t,e){const n=2*Math.PI/t,r=[],i=[];for(let i=0;i<=t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=s,r[3*i+2]=o}for(let i=t;i<=2*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=o,r[3*i+1]=t,r[3*i+2]=s}for(let i=2*t;i<=3*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=o,r[3*i+2]=s}const s=r.length/3-1;for(let e=0;e<s;e++)e!==t-1&&e!==2*t-1&&(i[2*e]=e,i[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),i.push(s+1,s+2),i.push(s+1,s+3),i.push(s+1,s+4),{vertices:r,indices:i}}(100,1),Fr=[0,0,0,1],Gr=[1,1,1];class Dr{constructor(t,e){this.u=e,this.h=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.m=t,this.p=new n.reshader.Renderer(t),this.v={},this.T={},this.M={},this._={},this.O={},this.A={},this.I=new n.reshader.Scene,this.S=new n.reshader.Scene,this.C=new n.reshader.Scene,this.k=new n.reshader.Scene,this.N=new n.reshader.ResourceLoader(t.texture(2)),this.L=(...t)=>this.R.call(this,...t),this.P=new n.reshader.KHRTechniquesWebglManager(this.m,this.U(),this.N);const r=this.getMap();this.B=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this._}getPNTSMeshes(){return this.M}getB3DMMeshes(){return this.T}getPaintedMeshes(){return this.F}getMap(){return this.u.getMap()}paint(t,e,r){const i=r&&r.renderTarget,s=r&&r.sceneFilter,o=this.getMap();if(!t.length||!o)return null;const a=this.G(),c=o.projViewMatrix,l=[],u=[],f=[],d=[],m=[];for(let e=0,i=t.length;e<i;e++){const i=t[e].data.node;let s=this.D(i);if(!s)continue;const o=this.u.j(i.H),a=o.debugNodes,y=o.heightOffset||0,p=o.coordOffset||fr;this.O[i.id]&&(s=this.O[i.id],s=It(s));let b=o.polygonOffset||sr;bt(b)&&(b=b()),Array.isArray(s)||(l[0]=s,s=l);for(let l=0,g=s.length;l<g;l++){if(!s[l]||!s[l].isValid||!s[l].isValid())continue;const g=s[l].properties.magic;if(s[l].properties.heightOffset===y&&s[l].properties.coordOffset[0]===p[0]&&s[l].properties.coordOffset[1]===p[1]||(this.q(s[l]),s[l].$=n.mat4.copy([],s[l].localTransform)),s[l].V=i,"b3dm"===g){if(s[l].getBoundingBox&&!h(c,s[l].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=s[l].geometry.properties;if(t&&e){const t=s[l].properties.node.H;this.J&&this.J[t]?n.HighlightUtil.highlightMesh(this.m,s[l],this.J[t],this.Y,e):this.J&&this.J[t]||n.HighlightUtil.highlightMesh(this.m,s[l],null,this.Y,e),n.HighlightUtil.showOnly(this.m,s[l],this.Z&&this.Z[t],this.K,e)}if(a&&a.length&&a.indexOf(s[l].V.id)<0)continue;r&&r.bloom&&s[l].properties.hlBloomMesh&&(s[l].properties.hlBloomMesh.properties.depthFunc="always",f.push(s[l].properties.hlBloomMesh)),f.push(s[l])}else"pnts"===g?d.push(s[l]):"i3dm"===g&&m.push(s[l]);s[l].properties.isLeaf=t[e].leave,s[l].properties.branchRootId=t[e].branchRootId;const v=255-t[e].selectionDepth;s[l].properties.selectionDepth=v,s[l].properties.polygonOffset=b;const w=void 0===o.cullFace||!!o.cullFace;s[l].properties.cullFace=w;const T=s[l].properties.hlBloomMesh;if(T){const n=T.properties;n.branchRootId=t[e].branchRootId,n.selectionDepth=v,n.polygonOffset=b,n.cullFace=w}t[e].leave||u.push(s[l]),this.X(s[l]),this.W(s[l],i)}}let y=0;const p=this.P.getExcludeFilter();n.ContextUtil.setIncludeUniformValues(a,r),y+=this.tt(this.et,a,[s,mr,p],i,u,f,m),y+=this.tt(this.nt,a,[s,yr,p],i,u,f,m),this.P.forEachShader(((t,e,n)=>{const r=this.G(n);y+=this.tt(t,r,[s,e],i,u,f,m)})),this.S.setMeshes(d);const b=this.rt();return y+=this.p.render(this.it,b,this.S,i&&i.fbo),this.F={pntsMeshes:d,i3dmMeshes:m,b3dmMeshes:f},this.k.setMeshes(e),this.p.render(this.st,a,this.k,i&&i.fbo),y}prepareRender(t){this.ot(t)}ot(t){t&&t.states&&t.states.includesChanged&&(this.nt.dispose(),delete this.nt,this.et.dispose(),delete this.et),this.ct(t)}tt(t,e,n,r,i,s,o){t.filter=n.filter((t=>!!t)),e.stencilEnable=!1,e.cullFace="back";const a=r&&r.fbo;let c=0;const l=[],u=[];let h=!1,f=s[0]&&s[0].properties.branchRootId;for(let n=0;n<s.length;n++){const{branchRootId:r}=s[n].properties;r!==f&&(h?(u.length&&(c+=this.lt(t,e,a,!1,u),u.length=0),c+=this.lt(t,e,a,h,l)):Nt(u,l),f=r,h=!1,l.length=0),l.push(s[n]),s[n].properties.selectionDepth<255&&(h=!0),n===s.length-1&&(h||(Nt(u,l),l.length=0),u.length&&(c+=this.lt(t,e,a,!1,u)),c+=this.lt(t,e,a,h,l))}return this.I.setMeshes(s.filter((t=>t.properties.isLeaf))),this.C.setMeshes(o),c+=this.p.render(t,e,this.C,r&&r.fbo),c}lt(t,e,n,r,i){return i.length?(this.I.setMeshes(i),e.stencilEnable=!1,r&&(this.ut(n),e.stencilEnable=!1,e.cullFace="front",this.p.render(t,e,this.I,n),e.cullFace="back",e.stencilEnable=!0),this.p.render(t,e,this.I,n)):0}ut(t){this.m.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.I.getMeshes()}getCurrentI3DMMeshes(){return this.C.getMeshes()}ht(t,e){return e.V.ft-t.V.ft}deleteTile(t){const e=t.node;e.dt&&(e.dt.geometry.dispose(),e.dt.dispose(),delete e.dt);const n=e.id;this.yt(n)}yt(t){const e=this.T[t]||this.M[t]||this._[t]||this.O[t]||this.v[t];this.O[t]?this.bt(t):e&&(this.gt(e),delete this.T[t],delete this.M[t],delete this._[t],delete this.v[t])}bt(t){let e=this.O[t];e=It(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.yt(n)}delete this.O[t]}gt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.gt(t[e]);else{n.HighlightUtil.showOnly(this.m,t),n.HighlightUtil.highlightMesh(this.m,t);const e=t.geometry.properties.url;if(e){const n=this.A[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.A[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.u;nr(t.getRenderer().canvas,t.getMap());for(const t in this.O)this.bt(t);this.O={};for(const t in this.T)this.yt(t);this.T={};for(const t in this.M)this.yt(t);this.M={};for(const t in this._)this.yt(t);this._={};for(const t in this.v)this.yt(t);this.v={},this.et&&(this.et.dispose(),delete this.et),this.nt&&(this.nt.dispose(),delete this.nt),this.it&&(this.it.dispose(),delete this.it),this.st&&(this.st.dispose(),delete this.st),this.P.dispose(),this.picking&&this.picking.dispose()}D(t){return this.T[t.id]||this.M[t.id]||this._[t.id]||this.O[t.id]}has(t){return this.D(t)||this.v[t.id]}q(t){const e=t.properties.magic;"b3dm"===e?this.vt(t):"i3dm"===e?this.wt(t):"pnts"===e&&this.Tt(t)}createPntsMesh(t,e,r,i){if(this.M[e]){const t=this.M[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:s,featureTable:o,rootIdx:a,compressed_int16_params:c}=t,l=o.POINTS_LENGTH;s.BATCH_ID||(s.BATCH_ID=new Uint8Array(l),s.BATCH_ID.fill(0));const u=new n.reshader.Geometry(s,null,l,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.m);const h={};s.POSITION?h.HAS_POSITION=1:s.POSITION_QUANTIZED&&(h.HAS_POSITION_QUANTIZED=1),s.RGB?h.HAS_RGB=1:s.RGBA?h.HAS_RGBA=1:s.RGB565&&(h.HAS_RGB565=1),(s.NORMAL||s.NORMAL_OCT16P)&&(h.HAS_NORMAL=1,s.NORMAL_OCT16P&&(h.HAS_NORMAL_OCT16P=1)),this.Mt(h,c),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:f,rtcCoord:d,projCenter:m}=t,y=this.u.j(a),p=new n.reshader.Mesh(u);p.properties.magic="pnts",p.properties.id=e,p.properties.node=r,p.properties.count=l,p.properties.batchTable=t.batchTable,p.properties.batchTableBin=t.batchTableBin,p.properties.serviceIndex=a,p.properties.rtcCoord=d,p.properties.rtcCenter=f,p.properties.projCenter=m,p.setDefines(h),p.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:y&&y.pointColor||[1,1,1,1]}));const b=this.getMap();let g=null,v=null;p.setFunctionUniform("pointSize",(function(){if(!y)return 2;if(zn(y.pointSize)){const t=JSON.stringify(y.pointSize);t!==g&&(v=Hn(y.pointSize),g=t);return v(b.getZoom())}return y.pointSize||2}));let w=null,T=null;return p.setFunctionUniform("pointOpacity",(function(){if(!y)return 1;if(zn(y.pointOpacity)){const t=JSON.stringify(y.pointOpacity);t!==w&&(T=Hn(y.pointOpacity),w=t);return T(b.getZoom())}return y.pointOpacity||1})),this._t(p,c),this.Tt(p),p.$=n.mat4.copy([],p.localTransform),this.M[e]=p,i(null,{id:e,mesh:[p]}),[p]}Tt(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:i}=t.properties;this.Ot(e,n,i,r.H),t.setLocalTransform(e)}createI3DMMesh(t,e,r,i){if(this._[e]){const t=this._[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.v[e]||i(null,{id:e,mesh:t}),t}const s=this.u.j(r.H),o=this.At(r.xt),{i3dm:a,featureTable:c,gltf:l,batchTable:u,batchTableBin:h,count:f}=t,d=c.INSTANCES_LENGTH,{rtcCenter:m,rtcCoord:y,projCenter:p}=t,b=this.It(Or,r,m,y);hn(b,hr,b);const g=n.mat4.getRotation(Ar,b);n.quat.normalize(g,g);const v=n.mat4.getScaling(xr,b),w=n.mat4.fromScaling(Ir,v),T=this.St(Sr,p,r),M=this.Ct(Nr),_=this.kt(Lr,y),O=n.vec3.div(Er,_,M),A=n.mat4.fromScaling(Rr,O),{POSITION:x,NORMAL_UP:I,NORMAL_RIGHT:S,SCALE:C,SCALE_NON_UNIFORM:k}=a,N=this.getMap().getRenderer().isWebGPU()?Float32Array:Uint16Array,L={"instance_vectorA":new Float32Array(4*d),"instance_vectorB":new Float32Array(4*d),"instance_vectorC":new Float32Array(4*d),"aPickingId":new N(d)};for(let t=0;t<d;t++)L.aPickingId[t]=t;const E=new Float32Array(3),R=new Float32Array(3),P=[],U=new Float32Array(1),B=new Float32Array(3),F=[],G=[],D=[],j=[];!function(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?ue.getTypedArrayCtor(s):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,i=i||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,i*o);for(let r=0;r<i*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const l=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const i=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);l.set(i),e(new c(l.buffer),t),i.set(l)}}(x,((t,e)=>{I?(ve(R,S,e),ve(E,I,e),n.vec3.cross(P,R,E),n.vec3.normalize(P,P),xt(F,R,0),xt(F,E,1),xt(F,P,2),n.quat.fromMat3(G,F),n.quat.normalize(G,G),n.quat.multiply(G,g,G)):n.quat.identity(G),C?(ve(U,C,e),n.vec3.set(D,U[0],U[0],U[0])):k?(ve(B,k,e),n.vec3.set(D,...B)):n.vec3.set(D,1,1,1),n.mat4.fromRotationTranslationScale(j,G,t,D),we(L.instance_vectorA,e,j,0),we(L.instance_vectorB,e,j,1),we(L.instance_vectorC,e,j,2)}));const z={};for(const t in L)z[t]={buffer:this.m.buffer({dimension:L[t].length/d,data:L[t],name:t}),divisor:1};const H=s.shader||"pbr";let q=0,$=!0;const V=[],J=[];return he(l,((t,i,s,a)=>{const l=this.Nt(t,i,s,a,r,!0,H,J),{geometry:g,material:v}=l;v&&!v.isReady()&&($=!1,q++);const M=new n.reshader.InstancedMesh(z,d,g,v);l.refMeshes||(l.refMeshes=new Set,l.refMeshes.add(M.uuid)),M.properties.magic="i3dm",M.properties.id=e,M.properties.count=f,M.properties.batchTable=u,M.properties.batchTableBin=h,M.properties.serviceIndex=r.H,M.properties.rtcCoord=y,M.properties.rtcCenter=m,M.properties.projCenter=p,M.properties.node=r;const _=this.Lt(t,g,v,r.H,a);_.MESH_ENV_EXPO=1,t.compressed_int16_params&&this._t(M,t.compressed_int16_params),this.Et(M,t.attributes);const O=n.mat4.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.mat4.multiply(O,O,t.matrices[e]);n.mat4.multiply(O,o,O),n.mat4.multiply(O,A,O),c.EAST_NORTH_UP||I?n.mat4.multiply(O,w,O):n.mat4.multiply(O,b,O),M.setPositionMatrix(O),this.wt(M,T),M.setDefines(_),M.properties.polygonOffset={offset:0,factor:0},V.push(M),delete t.attributes,M.$=n.mat4.copy([],M.localTransform)})),jr(J),$?(this._[e]=V,i(null,{id:e,mesh:V})):(this.v[e]={meshes:V,count:q},V.Rt=i),V}wt(t,e){const{rtcCoord:r,node:i,projCenter:s}=t.properties;e||(e=this.St(Sr,s,i));const o=this.u.j(i.H),a=t.localTransform||[];if(o.coordOffset){const t=this.Pt(Or,i.H,r);n.mat4.multiply(a,t,e)}else n.mat4.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||fr}St(t,e,r){n.mat4.fromScaling(t,this.Ct(Nr));const i=this.Ut(Mr,e,r.H);return n.mat4.multiply(t,n.mat4.fromTranslation(Cr,i),t),t}createB3DMMesh(t,e,r,s){if(t.gltf&&(t.gltf.transferables=null),this.T[e]||this.v[e]){const t=this.T[e];return console.warn(`mesh with id(${e}) was already created.`),this.v[e]||s(null,{id:e,mesh:t}),t}let o;if(r.maxExtent){const t=new i.Extent(r.maxExtent).convertTo((t=>this._pointToPrj(t)));o=[t.xmin,t.ymin,t.xmax,t.ymax]}const a=t.gltf,{projCenter:c}=a.extensions.MAPTALKS_RTC,{rtcCoord:l,center:u}=a.extensions.CESIUM_RTC,h=a.asset.sharePosition,f=this.At(r.xt),d=this.Bt(Sr,h,l,u,c,r),m=this.u.j(r.H);let y=m.shader||"pbr";if(m.unlit)y="phong";else if(a.materials)for(let t=0;t<a.materials.length;t++)if(a.materials[t]&&a.materials[t].extensions&&a.materials[t].extensions.KHR_materials_unlit){y="phong";break}const p=[],b=[];let g=0,v=!0;return he(a,((i,s,a,w)=>{const T=this.Nt(i,s,a,w,r,!1,y,p),{geometry:M,material:_}=T;_&&!_.isReady()&&(v=!1,g++);const O=new n.reshader.Mesh(M,_);T.refMeshes||(T.refMeshes=new Set,T.refMeshes.add(O.uuid)),O.properties.magic="b3dm",O.properties.id=e,O.properties.node=r,t.batchTable&&(O.properties.batchTable=t.batchTable,O.properties.batchTableBin=t.batchTableBin),O.properties.count=t.featureTable&&t.featureTable.BATCH_LENGTH||0,O.properties.serviceIndex=r.H;const A=this.Lt(i,M,_,r.H,w);O.setDefines(A);const x=i.compressUniforms;if(x)for(const t in x)O.setUniform(t,x[t]);i.compressed_int16_params&&this._t(O,i.compressed_int16_params),this.Et(O,i.attributes),o&&(A.USE_MAX_EXTENT=1,O.setUniform("maxPrjExtent",o)),O.hasFunctionUniform("polygonOpacity")||O.setFunctionUniform("polygonOpacity",(function(){return vt(m.opacity)?m.opacity:1})),O.hasFunctionUniform("polygonFill")||O.setFunctionUniform("polygonFill",(function(){return Et([],m.polygonFill||or)})),O.material.hasFunctionUniform("hsv")||O.material.setFunctionUniform("hsv",(function(){return m.hsv||ar}));const I=n.mat4.identity([]);if(h&&i.matrices&&i.matrices.length)for(let t=0;t<i.matrices.length;t++)n.mat4.multiply(I,I,i.matrices[t]);h&&n.mat4.multiply(I,f,I),O.properties.node=r,O.properties.projCenter=c,O.properties.nodeMatrix=I,O.properties.isSharedPosition=h,O.properties.rtcCoord=l,O.properties.rtcCenter=u,this.vt(O,d),b.push(O),delete i.attributes,O.$=n.mat4.copy([],O.localTransform)})),jr(p),v?(this.T[e]=b,s(null,{id:e,mesh:b})):(this.v[e]={meshes:b,count:g},b.Rt=s),b}Ft(t){const e=this.u.Gt(t.id);if(!e||t.dt)return;let r,i,s,o;if(e.obbox)r=e.boxPosition,i=Ur,s=e.boxCenter,o=Gr;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];r=Br.vertices,i=Br.indices,s=t,o=[n,n,n]}const a=new n.reshader.Geometry({POSITION:r},i,0,{primitive:"lines",positionAttribute:"POSITION"}),c=new n.reshader.Mesh(a,new n.reshader.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),l=[];n.mat4.fromRotationTranslationScale(l,Fr,s,o),c.localTransform=l,c.$=n.mat4.copy([],l),c.properties.node=t,t.dt=c}Dt(t){t.dt&&(t.dt.geometry.dispose(),t.dt.dispose(),delete t.dt)}_t(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}vt(t,e){const{isSharedPosition:r,rtcCoord:i,rtcCenter:s,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this.Bt(e||Sr,r,i,s,o,c));const l=t.localTransform||n.mat4.identity([]);n.mat4.multiply(l,e,a);const u=this.u.j(c.H);if(u.coordOffset){const t=this.Pt(Or,c.H,i);n.mat4.multiply(l,t,l)}t.setLocalTransform(l),t.properties.heightOffset=u.heightOffset||0,t.properties.coordOffset=u.coordOffset&&u.coordOffset.slice(0)||fr}Bt(t,e,r,i,s,o){if(e){const e=this.kt(Lr,r),s=n.mat4.fromScaling(_r,e),a=this.It(Or,o,i,r);n.mat4.multiply(t,a,s)}else this.Ot(t,r,s,o.H);return t}Et(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}It(t,e,r,i){const s=this.getMap(),o=this.u.j(e.H).heightOffset||0,a=e.matrix?n.mat4.copy(t,e.matrix):n.mat4.identity(t);if(r){hn(a,n.vec3.transformMat4(pr,r,a),a)}const c=function(t,e,n,r,i,s,o){e=Xt(dn,e);const a=Ae(dn,e[0]*Mn,e[1]*Mn,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(mn,n),l=r.ellipsoid;let u;u=0===ae(c)?Wt(yn,0,0,-6378137):Ne(yn,c),wn.x=u[0],wn.y=u[1];const h=r.project(wn,Tn);pn[0]=h.x/i,pn[1]=h.y/i,pn[2]=(u[2]+o)*s;const f=fn(a,l,bn),d=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],f=e[10],d=e[11],m=e[12],y=e[13],p=e[14],b=e[15],g=n*a-r*o,v=n*c-i*o,w=n*l-s*o,T=r*c-i*a,M=r*l-s*a,_=i*l-s*c,O=u*y-h*m,A=u*p-f*m,x=u*b-d*m,I=h*p-f*y,S=h*b-d*y,C=f*b-d*p,k=g*C-v*S+w*I+T*x-M*A+_*O;return k?(k=1/k,t[0]=(a*C-c*S+l*I)*k,t[1]=(i*S-r*C-s*I)*k,t[2]=(y*_-p*M+b*T)*k,t[3]=(f*M-h*_-d*T)*k,t[4]=(c*x-o*C-l*A)*k,t[5]=(n*C-i*x+s*A)*k,t[6]=(p*w-m*_-b*v)*k,t[7]=(u*_-f*w+d*v)*k,t[8]=(o*S-a*x+l*O)*k,t[9]=(r*x-n*S-s*O)*k,t[10]=(m*M-y*w+b*g)*k,t[11]=(h*w-u*M-d*g)*k,t[12]=(a*A-o*I-c*O)*k,t[13]=(n*I-r*A+i*O)*k,t[14]=(y*v-m*T-p*g)*k,t[15]=(u*T-h*v+f*g)*k,t):null}(gn,f),m=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}(vn,n);return hn(function(t,e,n){const r=t[0],i=t[1],s=t[2],o=t[4],a=t[5],c=t[6],l=t[8],u=t[9],h=t[10],f=e[0],d=e[1],m=e[2],y=e[3],p=e[4],b=e[5],g=e[6],v=e[7],w=e[8],T=r*f+o*d+l*m,M=i*f+a*d+u*m,_=s*f+c*d+h*m,O=r*y+o*p+l*b,A=i*y+a*p+u*b,x=s*y+c*p+h*b,I=r*g+o*v+l*w,S=i*g+a*v+u*w,C=s*g+c*v+h*w;return n[0]=T,n[1]=M,n[2]=_,n[3]=0,n[4]=O,n[5]=A,n[6]=x,n[7]=0,n[8]=I,n[9]=S,n[10]=C,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(d,m,t),pn,t),t}(a,i,a,s.getProjection(),s.getGLRes(),this.B,o),l=function(t,e){return Wt(t,e[12],e[13],e[14]),t}(Mr,c);let u=this.u.options.offset;if(bt(u)){const t=this.u.Gt(e.id).boxCoord;u=u.call(this.u,t)}return n.vec3.set(Tr,u[0],u[1],0),n.vec3.sub(l,l,Tr),hn(c,l,c),c}Pt(t,e,r){const i=this.u.j(e);if(!i.coordOffset)return null;const s=this.getMap(),o=s.getGLRes();br.set(r[0],r[1]);const a=s.coordToPointAtRes(br,o,vr),c=i.coordOffset,l=br.set(r[0]+c[0],r[1]+c[1]),u=s.coordToPointAtRes(l,o,wr),h=u.x-a.x,f=u.y-a.y,d=this.B,m=n.vec3.set(Tr,h,f,(c[2]||0)*d);return n.mat4.fromTranslation(t,m)}createCMPTMesh(t,e,n,r){if(this.O[e]){const t=this.O[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:i}=t,s=[];for(let t=0;t<i.length;t++){const{magic:r}=i[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"i3dm"===r?this.createI3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"pnts"===r?this.createPntsMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"cmpt"===r&&this.createCMPTMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)}))}return this.O[e]=s,r(null,{id:e,mesh:s}),s}Lt(t,e,n,r,i){const s=("phong"===(this.u.j(r).shader||"pbr")?this.et:this.nt).getGeometryDefines(e);i.asset&&"S3M"===i.asset.generator&&this.jt(s,e),e.data.uvRegion&&(s.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(s.VertexNormal=1),e.data[e.desc.color0Attribute]&&(s.VertexColor=1),e.data[e.desc.uv0Attribute]&&(s.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(s.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(s.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(s.TexCoord2=1),"MESHOPT"===this.u.zt&&(s.MeshOPT_Compress=1),this.hasIBL()&&(s.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(s.HAS_WEB3D_quantized_attributes_TEXCOORD=1),s.HAS_MIN_ALTITUDE=1,this.Mt(s,t.compressed_int16_params);return pt(s,t.compressDefines),s}Mt(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}X(t){const e=this.u.getRenderer();e&&e.updateMaskDefines(t)}jt(t,e){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1)}Nt(t,e,r,i,s,o,a,c){let l=!1;i.asset&&"S3M"===i.asset.generator&&(l=!0,i.extensions=i.extensions||{});const u=i.url+"-"+e+"-"+r;if(this.A[u])return this.A[u];let h,f;c.push(t);const d=i.materials&&i.materials[t.material],m=i.extensions&&i.extensions.KHR_techniques_webgl,y=this.u.j(s.H);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){if(this.getMap().getRenderer().isWebGPU())throw new Error("3dtiles with KHR_techniques_webgl extension is not supported in webgpu");const e=this.Ht(t,i,o,l);h=e.material,f=e.geometry,y.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.qt(t,o,Pr);const e=y.material;h=this.$t(t.material,i,a,e||cr,c,y)}h&&(h.setFunctionUniform("alphaTest",(function(){const t=y.alphaTest;return yt(t)?.1:t})),h.setFunctionUniform("environmentExposure",(()=>{const t=y.ambientLight;let e=y.environmentExposure;const n=this.getMap().getLightManager(),r=n&&n.getAmbientLight();if(t&&(!r||r.color)&&void 0===e){const n=r&&r.color?r.color[0]:.2;e=t[0]/n}return e||1}))),h&&!h.isReady()?h.Vt=s.id:h||(h=new n.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const p={geometry:f,material:h};return f.properties.url=u,this.A[u]=p,p}Ht(t,e,n,r){const{geometry:i,material:s}=this.P.createMesh(t,e,n,r);return{geometry:i,material:s}}qt(t,e,r){const i=this.getMap().getRenderer().isWebGPU(),s=t.attributes,o="COLOR_0";let a=s._BATCHID&&s._BATCHID.array;if(a&&a.byteOffset&&(a=new a.constructor(a),!i||a instanceof Float32Array||(a=new Float32Array(a))),s[o]){const t=s[o].array||s[o];if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);s[o].array?(s[o].array=e,s[o].componentType=5121):s[o]=e}}const c={};let l=0,u=0;for(const t in s){const e=r[t]||t,o=e===r.POSITION;i&&n.reshader.Geometry.padGPUGLTFAttribute(s[t]),o&&(l=s[t].itemSize);const a=Xn(this.m,s[t],{dimension:s[t].itemSize,name:t});c[e]=pt({},s[t]),c[e].buffer=a,c[e].type=Wn(c[e].array),delete c[e].array,e===r.POSITION&&(c[e].array=s[t].array,u=s[t].array.length/3)}const h=r._BATCHID;if(!c[h]&&!e){const t=new(i?Float32Array:Uint8Array)(u);c[h]=t}const f=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,d=new n.reshader.Geometry(c,f,0,{positionSize:l,positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":Kn(t.mode)});return a&&f&&(d.properties.batchIdData=a,d.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const i=e[r],s=t[i];let o=n.get(s);o||(o=[],n.set(s,o)),o.push(i)}return n}(a,f)),d.generateBuffers(this.m,{excludeElementsInVAO:e}),d}Ot(t,e,r,i){const s=n.mat4.identity(t),o=this.Ct(lr);return this.Ut(Mr,r,i),n.mat4.translate(s,s,Mr),n.mat4.scale(s,s,o),s}Ut(t,e,r){const i=this.B;br.x=e[0],br.y=e[1];const s=this._prjToPoint(br);let o=this.u.options.offset;bt(o)&&(o=o.call(this.u,br));const a=this.u.j(r).heightOffset||0;return n.vec3.set(t,s.x-o[0],s.y-o[1],i*e[2]+i*a),t}W(t,e){const r=this.u.Jt(kr,e);t.localTransform=n.mat4.multiply(t.localTransform,r,t.$)}kt(t,e){const r=this.getMap();br.x=e[0],br.y=e[1];const i=r.distanceToPointAtRes(100,100,r.getGLRes(),br),s=this.B;return n.vec3.set(t,i.x/100,i.y/100,s),t}ct(t){if(this.nt)return;const e={x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},r=[],i=[];this.it=new n.reshader.MeshShader({vert:Te,frag:"#define SHADER_NAME PNTS\nprecision mediump float;\nuniform float layerOpacity;\nvarying vec4 vColor;\nvoid main() {\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n if (dot(circCoord, circCoord) > 1.0) {\n discard;\n } else {\n gl_FragColor = vColor;\n }\n #ifdef HAS_LAYER_OPACITY\n gl_FragColor *= layerOpacity;\n #endif\n}\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>n.mat4.multiply(i,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>n.mat3.fromMat4(r,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,func:"<"}}});const s={},o=[];n.ContextUtil.fillIncludes(s,o,t);const a=this.U();this.et=new n.reshader.PhongShader({uniforms:o,defines:s,extraCommandProps:a}),this.nt=new n.reshader.pbr.StandardShader({uniforms:o,defines:s,extraCommandProps:a}),this.st=new n.reshader.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const c=this.u;er(c.getRenderer().canvas,this.m,c.getMap()),this.picking=new n.reshader.FBORayPicking(this.p,{vert:"#include <gl2_vert>\n#define SHADER_NAME GEO_3DTILES_PICKING\nattribute vec3 aPosition;\n#if defined(HAS_COLOR)\n attribute vec4 aColor;\n#endif\n#if defined(HAS_COLOR0)\n #if COLOR0_SIZE == 3\n attribute vec3 aColor0;\n varying vec3 vColor0;\n #else\n attribute vec4 aColor0;\n varying vec4 vColor0;\n #endif\n#endif\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projMatrix;\n#include <line_extrusion_vert>\n#include <get_output>\n#include <fbo_picking_vert>\nvoid main() {\n mat4 localPositionMatrix = getPositionMatrix();\n vec4 localVertex = getPosition(aPosition);\n vec4 position = localPositionMatrix * localVertex;\n vec4 viewVertex = modelViewMatrix * position;\n #ifdef HAS_MASK_EXTENT\n gl_Position = projMatrix * getMaskPosition(position, modelMatrix);\n #else\n gl_Position = projMatrix * viewVertex;\n #endif\n float alpha = 1.0;\n #if defined(HAS_COLOR)\n alpha *= aColor.a;\n #endif\n #if defined(HAS_COLOR0) && COLOR0_SIZE == 4\n alpha *= aColor0.a;\n #endif\n fbo_picking_setData(gl_Position.w, alpha != 0.0);\n}\n",wgslVert:n.getWGSLSource("layer_3dtiles_picking_vert"),extraCommandProps:a,uniforms:this.nt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.Yt=new n.reshader.FBORayPicking(this.p,{vert:Te,extraCommandProps:a,uniforms:this.it.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}U(){return{viewport:{x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},cull:{enable:(t,e)=>e.meshProperties.cullFace,face:(t,e)=>e.cullFace||"back"},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:"<=",ref:(t,e)=>e.meshProperties.selectionDepth},op:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,func:(t,e)=>e.meshProperties.depthFunc||"<="},blend:{enable:!0,func:{src:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}rt(t){const e=this.getMap(),r=e.getLightManager(),i=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;let o=this.u.options.opacity;return o=yt(o)?1:o,{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:n.vec3.normalize(dr,i),layerOpacity:o}}G(){const t=this.getMap(),e=this.u,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:i}=rr(n),s=ir(t,r,i),o=this.u.getRenderer().getMaskUniforms();s.minAltitude=e.options.altitude||0;let a=e.options.opacity;return a=yt(a)?1:a,s.layerOpacity=a,pt(s,{czm_lightDirectionEC:s.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),s.ambientColor||(s.ambientColor=[.2,.2,.2]),pt(s,o),s}$t(t,e,r,i,s,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=pt({},i);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Zt(t,s)),c.baseColorFactor=t&&t.image.color||a.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(a.normalTexture){const t=this.Zt(e.textures[a.normalTexture.index],s);if(t){const e=a.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=e}}if(a.occlusionTexture){const t=this.Zt(e.textures[a.occlusionTexture.index],s);if(t){const e=a.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=e}}if(a.emissiveTexture){const t=this.Zt(e.textures[a.emissiveTexture.index],s);t&&(c.emissiveTexture=t)}a.emissiveFactor&&(c.emissiveFactor=a.emissiveFactor);const t=a.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const r=e.textures[t.baseColorTexture.index];if(r&&r.image&&r.image.color)c.baseColorFactor=c.baseColorFactor?n.vec4.multiply(c.baseColorFactor,c.baseColorFactor,r.image.color):r.image.color;else{const t=this.Zt(r,s);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.m))}}if(yt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),yt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.Zt(e.textures[a.metallicRoughnessTexture.index],s);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.reshader.Material(c);if(o.unlit||a.extensions&&a.extensions.KHR_materials_unlit){const t=new n.reshader.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let l=new n.reshader.pbr.StandardMaterial(c);"phong"===r&&(l=n.reshader.PhongMaterial.convertFrom(l));const u=a.pbrMetallicRoughness,h=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return h&&h.KHR_texture_transform&&(l.set("khr_offset",h.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",h.KHR_texture_transform.rotation||0),l.set("khr_scale",h.KHR_texture_transform.scale||[1,1])),l.doubleSided=!(!o.doubleSided&&!a.doubleSided),l.once("complete",this.L),l}Zt(t,e){if(!t)return null;const r={type:t.type?Yn(t.type):"uint8",format:t.format?Zn(t.format):"rgba",flipY:!!t.flipY},i=t.image;if(e.push(i),i.array?r.data=i.array:i.mipmap&&(r.mipmap=i.mipmap),!r.data&&!r.mipmap)return null;if(r.width=i.width,r.height=i.height,r.mipmap&&(r.width<4||r.height<4))return null;const s=t.sampler||t.texture&&t.texture.sampler;return s&&(s.magFilter&&(r.mag=$n(s.magFilter)),s.minFilter&&(r.min=Vn(s.minFilter)),s.wrapS&&(r.wrapS=Jn(s.wrapS)),s.wrapT&&(r.wrapT=Jn(s.wrapT))),new n.reshader.Texture2D(r,this.N)}R({target:t}){const e=t.Vt,n=this.v[e];if(n.count--,!n.count){const t=n.meshes;this.T[e]=t,delete this.v[e];const r=t.Rt;delete t.Rt,r(null,{mesh:n.meshes,id:e})}}Ct(t){const e=1/this.getMap().getGLRes(),n=this.B;return t[0]=t[1]=e,t[2]=n,t}Kt(t){return this.u.Kt(t)}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes(),gr)}At(t){return"Y"===t?Qn:"X"===t?tr:ur}pick(t,e,n=3){const r=this.u;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const i=[],s=this.G(),o=this.Xt(this.picking,s,this.I,t,e,n);o&&i.push(o);const a=this.Xt(this.picking,s,this.C,t,e,n);a&&i.push(a);const c=this.rt(),l=this.Xt(this.Yt,c,this.S,t,e,n);return l&&i.push(l),i}Xt(t,e,n,r,i,s){if(!n.getMeshes().length)return null;const o=this.u,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,i,s,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:l,pickingId:u,point:h,coordinate:f}=c,d=(0===l||l)&&t.getMeshAt(l);if(!d||!d.geometry)return null;const m=d.properties;h&&h.length&&(h[0]=Math.round(1e5*h[0])/1e5,h[1]=Math.round(1e5*h[1])/1e5,h[2]=Math.round(1e5*h[2])/1e5);const y={batchId:u},p=o.options.services,b=p&&p[d.properties.serviceIndex];if(b&&b.debug&&(y.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=u;for(const i in t)void 0!==t[i].byteOffset?y[i]=Ye(t[i],e,n,r):y[i]=t[i][r]}return{service:d.properties.serviceIndex,data:y,point:h,coordinate:f}}highlight(t){this.J=t;const e=this.u.getRenderer();this.Y=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.J=null;const t=this.u.getRenderer();this.Y=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Z=t;const e=this.u.getRenderer();this.K=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Z=null;const t=this.u.getRenderer();this.K=t.getFrameTimestamp(),t.setToRedraw(!0)}Wt(){if(!this.F)return[];const t={},e=[];for(const n in this.F){const r=this.F[n];if(r)for(let n=0;n<r.length;n++){const i=r[n],s=i&&i.geometry;if(!i||!s)continue;const o=i.properties.serviceIndex;t[o]||(t[o]=new Set);const a=s.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}function jr(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}function zr(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}const Hr=[];class qr{constructor(t,e,n,r,i){this.u=r,this.Qt=t,this.H=e,this.te=i,this.ee=n.version,t.indexOf("i3s:tileset:")<0?(this.ee<=1.6?this.ne="root":this.ne=0,n.version=this.ee):(this.ne=t.substring(12),this.ee>1.6&&(this.ne=parseInt(this.ne))),this.Qt=t,this.re=n}load(){const t=this.re,e=t.layerScene.baseUrl;if(this.ee<=1.6)return t[this.ne]&&t[this.ne].lodSelection?(this.ie=t[this.ne],this.se()):new Promise((n=>{let r=e+"/nodes/"+this.ne;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.te(this.H,r,(()=>{this.ie=t[this.ne],n(this.se())}))}));if(this.ee>=1.7){if(t[this.ne])return this.ie=t[this.ne],this.se();const n=Math.floor(this.ne/t.nodesPerPage);return new Promise((r=>{let i=e+"/nodepages/"+n;t.layerScene.eslpk&&(i+=".json"),this.te(this.H,i,(()=>{this.ie=t[this.ne],r(this.se())}))}))}return null}getTileset(){return this.oe}getChildrenURL(){return this.ae}se(){const t=this.re,e=t.layerScene.baseUrl,n=this.ie.children,r=[],i={};if(n)for(let s=0;s<n.length;s++)if(this.ee<=1.6){const o=n[s].id;if(t[o])continue;const a=o;i[a]||(i[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.te(this.H,r,(()=>{n()}))})),r.push(i[a]))}else{const o=n[s];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);i[a]||(i[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.te(this.H,r,(()=>{n()}))})),r.push(i[a]))}return r.length?Promise.all(r).then((()=>this.ce())):this.ce()}ce(){return Promise.resolve(this.le())}ue(t){zr(this.re,t)}le(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.he(this.ie,!0)}}he(t){const e=this.u.getRenderer(),n=this.re.projection,r=!n||n&&4326===n.wkid,i=this.ee,s=this.re,o=t,a=o.obb,c=o.mbs,l={};let u;if(c)u=Wt([],c[0],c[1],c[2]),r||(u=e.fe(u,u)),u=$r([],u[0],u[1],u[2]),l.sphere=[...u,c[3]];else if(a){u=Wt([],a.center[0],a.center[1],a.center[2]),r||(u=e.fe(u,u)),u=$r([],u[0],u[1],u[2]);const t=function(t,e,n){const r=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,l=n*o,u=r*o,h=r*a,f=i*o,d=i*a,m=i*c,y=s*o,p=s*a,b=s*c;return t[0]=1-h-m,t[3]=u-b,t[6]=f+p,t[1]=u+b,t[4]=1-l-m,t[7]=d-y,t[2]=f-p,t[5]=d+y,t[8]=1-l-h,t}([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(u,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],i=t[4]+t[7]+t[10],s=t[5]+t[8]+t[11];Wt(Hr,n,i,s);const o=ae(Hr);l.sphere=[...u,o]}let h=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===s.lodSelectionMetricType){h=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(h=f/o.lodSelection[t].maxError);(h===1/0||isNaN(h))&&(h=1e5);const d=16*h,m=function(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}([]),y=m,p=o.children;let b;if(p){b=[];const t=this.re;for(let e=0;e<p.length;e++){const n=i<=1.6?p[e].id:p[e];if(!t[n]){b=null;break}b.push(this.he(t[n]))}}const g={refine:"REPLACE",boundingVolume:l,transform:y,geometricError:d};return i<=1.6?t.lodSelection?t.geometryData&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}):g.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!b?g.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}),b&&b.length&&(g.children=b),g}getJSON(){return this.ie}}function $r(t,e,n,r){return Ae(t,wt(e),wt(n),r)}const Vr=!!Gt.ktx2,Jr=n.mat4.identity([]),Yr=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function Zr(t){return t.indexOf("i3s:mesh")>=0}const Kr=9;function Xr(t,e,n,r,i){const s=e.layerScene.eslpk,o=function(t,e){const n=e.substring(Kr);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,l=[];let u=!1;const h=Jr;let f,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;s&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let i=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(i){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",s&&(i+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+i,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}l.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions,o=(e.layerScene.store||{}).textureEncoding,h=t[f.definition],{geometryBuffers:m}=h;u=r&&2===m.length;const y=Gt.draco&&u?m[1]:m[0],p=Gt.draco&&u?1:0;let b=c+`/nodes/${f.resource}/geometries/`+p;s&&(b+=".bin");const g={geometry:{url:b,info:y}};if(i&&Yr&&u&&!Gt.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const v=e.layerScene.materialDefinitions,w=e.layerScene.textureSetDefinitions;let T,M=0;if(d&&(M=v[d.definition]),v){T=function(t,e,n,r,i,s,o){const a=JSON.parse(JSON.stringify(e));return Wr(t,a,n,r,i,s,o),a}(o,M,w,c,d.resource,n,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};g.material=T,l.push(g)}return{dracoCompression:u,meshes:l,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:h}}function Wr(t,e,n,r,i,s,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const c=n[e[a].textureSetDefinitionId],l="images/"+c.formats[0].format,u=ti(c.formats,s,t),h={url:r+`/nodes/${i}/textures/${u.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:u.format,mimeType:l};if(o){let t="";switch(u.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=u.format}h.url+="."+t}e[a]=h}else gt(e[a])&&Wr(t,e[a],n,r,i,s,o)}const Qr={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"jpg","image/vnd-ms.dds":"dds","image/ktx":"jpg"};function ti(t,e,n){if(n&&n.length){const e=n[n.length-1],r=Qr[e];if(r)for(let e=0,n=t.length;e<n;e++){if(t[e].format===r)return t[e]}else console.error("i3s not find texture format type from:",Qr,"current textureEncoding:",e)}for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&Vr)return t[n]}return null}const{Ajax:ei}=Dt(),ni=new i.Coordinate(0,0),ri=new i.Coordinate(0,0),ii=new Set,si=[],oi=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.de(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){const t=this.data.keys();let e=t.next();for(;this.currentSize>this.max&&void 0!==e.value;){this.data.get(e.value).current&&i.Util.warnOnce(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`);const n=this.getAndRemove(e.value);n&&this.onRemove(n),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(const r of n)t[e++]=r;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return this.de(t,e),this}de(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(i.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let ai=0;class ci extends(n.MaskRendererMixin(n.CanvasCompatible(i.renderer.LayerAbstractRenderer))){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>oi.max&&oi.setMaxSize(e),this.tileCache=oi,ai++,this.tilesLoading={},this.me={},this.ye=[],this.te=(...t)=>this.pe.call(this,...t)}getAnalysisMeshes(){if(!this.painter)return si;const t=this.painter.getPaintedMeshes();if(!t)return si;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:i}=t;return n.length&&Nt(e,n.filter((t=>!(!t||!t.geometry)))),r.length&&Nt(e,r.filter((t=>!(!t||!t.geometry)))),i.length&&Nt(e,i.filter((t=>!(!t||!t.geometry)))),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.ye.length||super.needToRedraw())}getFrameTimestamp(){return this.be}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.be=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:i}=this.layer.getTiles(),s=i.length;if(!i||!s)return void this.completeRender();this.painter.prepareRender(e),this.ge(),this.ve(e);const{selectedTiles:o,requests:a}=this.we(r,i);a.length&&this.loadTiles(a),this.Te(o,e),this.Me(),a.length||this.completeRender()}we(t,e){let n=[];this._e();let r=0;const i=this.Oe(),s={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const i=e[t],c=i.node;if(s[c.id])continue;s[c.id]=1;let l=!1;const u=this.getCachedTile(c.id);if(this.Ae(c.id)?(r++,l=a=!0,this.tilesLoading[c.id].current=!0):u?(this.getTileOpacity(u)<1&&(l=a=!0),o=!0,i.selected=!0,i.data=u):this.painter.has(c)||(l=a=!0,n.push(c)),!l)continue;if(this.xe(i))o=!0;else{this.Ie(i).length&&(o=!0)}}const c=o?this.Se(t):[];if(n.length>1&&(n.sort(li),i)){const t=i-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c}}Se(t){const e=[];let n,r;const i=[t],s=[];for(;i.length>0||s.length>0;){if(s.length>0){const t=s[s.length-1];if(t.Ce===i.length){s.pop(),t===n&&(t.leave=!0),t.branchRootId=r,e.push(t),0===s.length&&(r=null);continue}}const t=i.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)t.leave=!0,t.selectionDepth=s.length,t.branchRootId=r,e.push(t);else{if(t.selectionDepth=s.length,n=t,0===o.length){t.leave=!0,t.branchRootId=r,e.push(t);continue}0===s.length&&(r=t.node.id),s.push(t),t.Ce=i.length}for(let t=0;t<o.length;t++)i.push(o[t])}return e}xe(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}Ie(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.ke+1,r=[t.node];for(;r.length>0;){const i=r.pop().children;for(let s=0,o=i.length;s<o;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){r.push(i[s]);continue}const o=i[s].id;if(this.tileCache.has(o)){const n=this.layer.Ne(i[s],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else i[s].ke<=n&&r.push(i[s])}}return e}Te(t,e){this.tileCache.markAll(this,!1);const n=[];for(let e=0,r=t.length;e<r;e++){const r=t[e].data;r.current=!0,r.renderer=this,this.tileCache.add(t[e].node.id,r);const i=r.node,s=this.layer.j(i.H);i.dt&&s.debug&&!Array.isArray(s.debug)&&n.push(i.dt)}const r=this.layer.options.services;for(let t=0;t<r.length;t++){const e=r[t],i=Array.isArray(e.debug)&&e.debug;if(i)for(const t of i){const e=this.layer.Gt(t),r=e&&e.node;r&&r.dt&&n.push(r.dt)}}const i={tiles:t};this.onDrawTileStart(i);const s=this.painter.paint(t,n,e);this.layer.fire("drawtiles",{count:s}),this.onDrawTileEnd(i),s&&this.layer.fire("canvasisdirty",{renderCount:s}),this.tileCache.shrink()}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(Ct(e)){const n=kt(e);return this.Le(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.H,r=this.Ee[n];return new qr(e,n,r,this.layer,this.te).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Pt(e)&&!Zr(e)&&(e=t.baseUrl+e),this.Le(e,null,t),null}Le(t,e,r){let i=this.Re;i||(i=n.reshader.Util.getSupportedFormats(this.gl||this.device&&this.device.wgpu),this.Re=i);const s=this.layer.j(r.H);s.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length),r=n.split("/"),i=[];for(let t=0;t<r.length;t++)i.push(encodeURIComponent(r[t]));return e+i.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,this.layer.Pe[r.H]),arraybuffer:e,rootIdx:r.H,upAxis:r.xt,transform:r.matrix,supportedFormats:i};if(Zr(t)){const e=this.Ee[r.H];if(o.projection=e.projection,o.i3sInfo=Xr(t,e,this.regl||this.device,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=pt({},s),s.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:i}=n;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i||"gltf"===i?this.ye.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Ft(t){this.painter&&this.painter.Ft(t)}Dt(t){this.painter&&this.painter.Dt(t)}ve(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.ye.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.ye.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})),n++}}Ue(t,e,n,r){if(this.Be(r),n)this.onTileError(n,e);else{const n=this.Fe(r);e.memorySize=n,this.onTileLoad(t,e)}}Be(t){if(Array.isArray(t)){for(let e=0;e<t.length;e++)if(t[e])if(Array.isArray(t[e]))this.Be(t[e]);else{const n=t[e].defines||{};n.HAS_LAYER_OPACITY=1,t[e].setDefines(n)}}else if(t)if(Array.isArray(t))this.Be(t);else{const e=t.defines||{};e.HAS_LAYER_OPACITY=1,t.setDefines(e)}}Fe(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Fe(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.Ge(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.zt=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.De(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(t,e,n){if(!this.layer)return;const r=n||e.content.url,s=t&&t.message||t;t&&(404===t.status||204===t.status)||ii.has(s)||(console.warn("failed to load 3d tile: "+r),console.warn(t),ii.add(s)),delete this.tilesLoading[e.id],(!this.layer.options.onlyCacheNoContentTileWhenError||t&&!i.Util.isNoContentHttpCode(t.status))&&this.je(e,t),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}getShadowMeshes(){if(!this.painter)return[];const t=[],e=this.painter.getCurrentB3DMMeshes();for(const n in e)e[n]&&e[n].isValid&&e[n].isValid()&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&n[e].isValid&&n[e].isValid()&&t.push(n[e]);return t}je(t,e){const n={loadTime:i.Util.now(),current:!0,error:e,node:t};n.renderer=this,this.tileCache.add(t.id,n)}Ge(t){const e={loadTime:i.Util.now(),current:!0,node:t};e.renderer=this,this.tileCache.add(t.id,e)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.me[e]}_e(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}initContext(){super.initContext();const t=this.layer,{regl:e,reglGL:n,device:r}=this.context;this.regl=e,this.device=r,this.gl=n;const i=e||r;this.prepareWorker(),this.canvas.pickingFBO=this.canvas.pickingFBO||i.framebuffer(this.canvas.width,this.canvas.height),this.pickingFBO=this.canvas.pickingFBO||i.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Dr(i,t),this.layer.ze(),this.layer.fire("contextcreate",{regl:e,device:r})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new zt("@maptalks/3dtiles",t.id,n.reshader.Util.supportNPOT(this.regl||this.device)));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=pt({},r),delete r.offset;const i=t.options.spatialReference;r.projection=i&&i.coordType||i&&i.projection||t.getSpatialReference().getProjection().code;const s=this.layer.getId();e.addLayer(s,r,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),ai--,ai||oi.reset(),this.clear(),delete this.tileCache,delete this.gl,delete this.regl,super.onRemove()}clear(){this.Me(!0),this.tileCache.reset(this),this.tilesLoading={},super.clear()}getTileOpacity(){return 1}getStencilValue(){return 0}Me(t){this.He||(this.He=Date.now());const e=Date.now();if(!t&&e-this.He<this.layer.options.retireInterval)return;this.He=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}Oe(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}qe(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let i=0;i<n.length;++i){try{r=t.getContext(n[i],e)}catch(t){}if(r)break}return r}Ae(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 Ve(t,e,0,n)}ge(){if(!this.$e)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.$e){const i=this.$e[r];if("pending"===i.status)continue;i.status="pending";const s=i.rootIdx,o=Ut(this.layer.j(s).fetchOptions);if(n.push(ei.getJSON(r,o).then((t=>{delete this.$e[r];const e=this.Ee[s];if(e){t.nodes?zr(e,t.nodes):(e[t.id]=t,zr(e,t.children));for(let t=0;t<i.length;t++)i[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}n.length&&Promise.all(n)}pe(t,e,n){this.$e||(this.$e={}),this.$e[e]=this.$e[e]||[],this.$e[e].rootIdx=t,this.$e[e].push(n),this.setToRedraw()}De(t,e,n){this.Ee||(this.Ee=[]);const r=e.H;this.Ee[r]||(this.Ee[r]={});const i=this.Ee[r],s=this.layer.j(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),i.version=+(s.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),t.spatialReference&&4490===t.spatialReference.wkid&&(console.warn("i3s spatialReference is 4490,auto set spatialReference to 4326,This may cause some location issues, please ensure that your service is 4326"),t.spatialReference.wkid=4326),i.projection=t.spatialReference,function(t,e,n,r,i,s,o){if(!s.layerScene){s.layerScene=e,s.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,s.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=i;if(s.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=i.lastIndexOf("/");t=e<0?"./":i.substring(0,e)}s.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new qr(i,n,s,t,o).load()}(this.layer,t,r,0,n,i,this.te).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:i,height:s}=this.canvas;return!this.pickingFBO||r.width===i&&r.height===s||r.resize(i,s),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.J||(this.J=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.J[n];r||(r=this.J[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.J[e];n||(n=this.J[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.J)}cancelHighlight(t,e){if(!this.J)return;const n=this.J[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.J[t]=null),this.painter.highlight(this.J)}}cancelAllHighlight(){delete this.J,this.painter.cancelAllHighlight()}showOnly(t){if(this.Z||(this.Z=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Z[n];r||(r=this.Z[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Z[e];n||(n=this.Z[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Z)}cancelShowOnly(){delete this.Z,this.painter.cancelShowOnly()}Wt(){return this.painter?this.painter.Wt():[]}fe(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.Ve();return ni.set(e[0],e[1]),n.unproject(ni,ri),t[0]=ri.x,t[1]=ri.y,t}return ni.set(e[0],e[1]),n.getProjection().unproject(ni,ri),t[0]=ri.x,t[1]=ri.y,t}Je(t,e){const n=this.Ve();return ni.set(e[0],e[1]),n.project(ni,ri),t[0]=ri.x,t[1]=ri.y,t}Ye(t,e){const n=this.Ve();return ni.set(e[0],e[1]),n.unproject(ni,ri),t[0]=ri.x,t[1]=ri.y,t}Ve(){const t=this.getMap().options.spatialReference.coordType;if(!t)throw new Error("Missing coordType in map spatialReference.");return this.Ze||(this.Ze=i.SpatialReference.getProjectionInstance(t)),this.Ze}}function li(t,e){return t.ft-e.ft}function ui(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function hi(t,e,n){return Math.sqrt(function(t,e,n){const r=Qt(fi,n,t),i=ui(di,e,0),s=ui(mi,e,1),o=ui(yi,e,2),a=ae(i),c=ae(s),l=ae(o);ne(i,i),ne(s,s),ne(o,o);const u=pi;u[0]=re(r,i),u[1]=re(r,s),u[2]=re(r,o);let h,f=0;u[0]<-a?(h=u[0]+a,f+=h*h):u[0]>a&&(h=u[0]-a,f+=h*h);u[1]<-c?(h=u[1]+c,f+=h*h):u[1]>c&&(h=u[1]-c,f+=h*h);u[2]<-l?(h=u[2]+l,f+=h*h):u[2]>l&&(h=u[2]-l,f+=h*h);return f}(t,e,n))}const fi=[],di=[],mi=[],yi=[],pi=[];const bi=2*Math.PI;class gi{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],i=t.west;let s=t.east;return s<i&&(s+=bi,n<0&&(n+=bi)),(n>i||De(n,i,1e-14))&&(n<s||De(n,s,1e-14))&&r>=t.south&&r<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const vi=[0,0,1];function wi(t,e){return Ae(e,t[0],t[1],t[2])}class Ti{constructor(t,e){this.normal=n.vec3.copy([],t),this.distance=e}static fromPointNormal(t,e,r){const i=-n.vec3.dot(e,t);return n.vec3.copy(r.normal,e),r.distance=i,r}}const Mi=[],_i=[],Oi=[],Ai=[],xi=[],Ii=[],Si=[],Ci=[],ki=[],Ni=[],Li=new Ti([1,0,0],0),Ei=[];class Ri{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new gi(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let r=0;if(!gi.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,i=this.northeastCornerCartesian,s=this.westNormal,o=this.southNormal,a=this.eastNormal,c=this.northNormal,l=n.vec3.subtract(Ei,t,e),u=n.vec3.dot(l,s),h=n.vec3.dot(l,o),f=n.vec3.subtract(Ei,t,i),d=n.vec3.dot(f,a),m=n.vec3.dot(f,c);u>0?r+=u*u:d>0&&(r+=d*d),h>0?r+=h*h:m>0&&(r+=m*m)}const i=e[2],s=this.minimumHeight,o=this.maximumHeight;if(i>o){const t=i-o;r+=t*t}else if(i<s){const t=s-i;r+=t*t}return Math.sqrt(r)}computeBox(t){const e=this;wi(gi.southwest(t,_i),e.southwestCornerCartesian),wi(gi.northeast(t,_i),e.northeastCornerCartesian),Mi[0]=t.west,Mi[1]=.5*(t.south+t.north),Mi[2]=0;const r=wi(Mi,Oi),i=n.vec3.cross(xi,r,vi);n.vec3.normalize(e.westNormal,i),Mi[0]=t.east;const s=wi(Mi,Ci),o=n.vec3.cross(xi,vi,s);n.vec3.normalize(e.eastNormal,o);const a=n.vec3.subtract(xi,r,s),c=n.vec3.normalize(Ai,a),l=t.south;let u;if(l>0){Mi[0]=.5*(t.west+t.east),Mi[1]=l;const r=wi(Mi,ki);n.vec3.copy(Ni,c);const i=Ti.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Li);Pi(ki,Ni,i,e.southwestCornerCartesian),u=Be(r,Ii)}else u=Fe(gi.southeast(t,_i),Ii);const h=n.vec3.cross(Si,u,a);n.vec3.normalize(e.southNormal,h);const f=t.north;let d;if(f<0){Mi[0]=.5*(t.west+t.east),Mi[1]=f;const r=wi(Mi,ki);n.vec3.scale(Ni,c,-1);const i=Ti.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Li);Pi(ki,Ni,i,e.northeastCornerCartesian),d=Be(r,Ii)}else d=Fe(gi.northwest(t,_i),Ii);const m=n.vec3.cross(Si,a,d);n.vec3.normalize(e.northNormal,m)}}function Pi(t,e,r,i){const s=t,o=e,a=r.normal,c=n.vec3.dot(a,o);if(Math.abs(c)<1e-15)return;const l=(-r.distance-n.vec3.dot(a,s))/c;return l<0?void 0:(i=n.vec3.scale(i,o,l),n.vec3.add(i,s,i))}function Ui(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const Bi=i.BBOXUtil,Fi={"services":[],"maxGPUMemory":i.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":2,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"onlyCacheNoContentTileWhenError":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"]},Gi=[0,0,0],Di=[0,0,0],ji=[0,0,0],zi=[0,0,0],Hi=[0,0,0],qi=[0,0,0],$i=[0,0,0],Vi=[1,1,1],Ji=[1,1,1],Yi=[0,0,0,0],Zi=[],Ki=new i.Coordinate(0,0),Xi=new i.Point(0,0),Wi=[0,0,0,0,0,0,0,0,0],Qi=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ts=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],es=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ns=new i.Point(0,0),rs=n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),is=[0,0],ss=[0,0,0],os=[1,1,1],as=[0,0,0],cs=[0,0,0],ls=[0,0,0,0],us=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class hs extends(n.MaskLayerMixin(i.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new hs(t.id,t.options):null}static getEnuTransform(t,e=[1,1,1],r=[0,0,0]){const i=Ae([],t[0]*Math.PI/180,t[1]*Math.PI/180,t[2]||0),s=fn(i,null,[]),o=n.quat.fromEuler([0,0,0,0],...r),a=n.mat4.fromRotationTranslationScale([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,[0,0,0],e);return n.mat4.multiply(a,s,a)}constructor(t,e){super(t,e),this.isGeo3DTilesLayer=!0,this.Ke(),this.Xe=new Map}Ke(){const t=this.options.services.map((t=>t.url));this.We=this.We||{},this.Pe=this.Pe||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.We[n];void 0===r&&(r=this.We[n]=this.Pe.length),this.Pe[r]=ms(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Pe.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Qe(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Ke(),this.Qe(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(bs(n[t].coordOffset,e.coordOffset)&&bs(n[t].heightOffset,e.heightOffset)&&bs(n[t].scale,e.scale)&&bs(n[t].rotation,e.rotation)),pt(n[t],e));const i=n[t].url,s=this.We[i],o=this.Pe&&this.Pe[s];return o&&(yt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Qe(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.We[n];this.Pe[r]&&(this.Pe[r]=null),delete this.We[n],e.splice(t,1)}return this.Qe(),this}getTileUrl(t,e){const n=e&&e.service&&e.service.subdomains;if(n&&e.domainKey){const r=n.length;if(r){const i=[...t].reduce(((t,e)=>t+e.charCodeAt(0)),0)%r;return t.replace(e.domainKey,n[i])}}return t}getExtent(t){if(!t&&0!==t){const t=new i.Extent;for(let e=0;e<this.Pe.length;e++){const n=this.Pe[e];if(n&&n.boundingVolume){const e=this.boundingVolumeToExtent(n);t._combine(e)}}return t}const e=this.Pe[t];return e&&e.boundingVolume?this.boundingVolumeToExtent(e):null}boundingVolumeToExtent(t){const e=t.boundingVolume.tn?rs:t.matrix,r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),o=this.getRenderer();if(t.boundingVolume.region){const e=t.boundingVolume.region;return new i.Extent(Tt(e[0]),Tt(e[1]),Tt(e[2]),Tt(e[3]))}if(t.boundingVolume.sphere){const a=t.boundingVolume.sphere,c=Ne([],n.vec3.transformMat4([0,0,0],a,e));s&&o.Je(c,c);const l=a[3],u=r.locate(c,-l,l),h=r.locate(c,l,-l);return new i.Extent(u,h)}if(t.boundingVolume.box){const a=t.boundingVolume.box,c=n.vec3.transformMat4([0,0,0],a,e),l=new i.Coordinate(Ne([],c));s&&o.Je(l,l);const u=a.slice(3);n.mat3.multiply(u,n.mat3.fromMat4([0,0,0,0,0,0,0,0,0],t.matrix),u);const h=n.vec3.length(u.slice(0,3)),f=n.vec3.length(u.slice(3,6)),d=n.vec3.length(u.slice(6,9)),m=Math.max(h,f,d),y=r.locate(l,-m,m),p=r.locate(l,m,-m);return new i.Extent(y,p)}return null}getRootTiles(){return this.Pe}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Qe(),{tiles:Zi};const e=this.getMap(),r=e.cameraPosition,i=e.pointAtResToDistance(r[2],0,e.getGLRes()),s=this.nn(r);this.rn=this.rn||[0,0,0],n.vec3.set(this.rn,wt(s.x),wt(s.y),i),this.sn=Ae(this.sn||[],this.rn[0],this.rn[1],this.rn[2]),this.an=2*Math.tan(.5*wt(e.getFov()));const o=e.projViewMatrix;let a;if(e.getPitch()<=80){const t=e.getExtent(),n=t.getWidth()/2,r=t.getHeight()/2;t.xmin-=n,t.ymin-=r,t.xmax+=n,t.ymax+=r,a=Ui(t)}const c=(this.getMasks()||[]).filter((t=>t&&t instanceof n.ClipOutsideMask));c.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=Ui(e)}catch(t){console.error(t)}}));const l={children:[],level:-1};let u=l;const h=[];for(let e=0;e<this.Pe.length;e++){const n=this.Pe[e];if(!n||!n.visible)continue;const r=n.service,i=[n],s=this.cn(e);for(;i.length>0;){const e=i.pop();for(e.id||this.ln(e);u.level>=e.ke;)u=u.parent;const n=this.un(e,s,o,a,c);if(e.service=r,!(n===gs.VISIBLE||n!==gs.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&ps(e))){let t=u;for(;t&&!t.content;)t=t.parent;n===gs.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.hn(h,t);continue}e.ft<1/0&&this.dn(e);const l=this.Ne(e,u);u.children.push(l);const f=e.children,d=f&&f.length,m=l.content;if(m&&(!d||n===gs.SCREEN_ERROR_TOO_SMALL)&&this.hn(h,l),n!==gs.SCREEN_ERROR_TOO_SMALL&&d){m&&"add"===e.refine&&this.hn(h,l),u=l;const n=f[0].parent;let r=!1;for(let s=0,o=f.length;s<o;s++){if(n){const e=t.getCachedTile(f[s].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,f[s].parent=e,f[s].xt=e.xt,f[s].baseUrl=e.baseUrl;const t=f[s].content&&(f[s].content.url||f[s].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?f[s].baseUrl=e.baseUrl:Pt(t)?f[s].content.url=e.baseUrl+t:f[s].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}i.push(f[s])}!r&&m&&this.hn(h,l)}}}return{root:l,tiles:h}}hn(t,e){const{viewerRequestVolume:n,matrix:r}=e.node;n&&!function(t,e,n,r){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return fs(n,e,r)<=0;if(n.box)return 0===ds(n,e,r)}return!1}(this.rn,this.sn,n,r)||t.push(e)}Ne(t,e){return{id:t.id,node:t,children:[],level:t.ke,parent:e,content:t.content&&t.content.url}}ln(t){const e=this.getId();t.id=e+":"+i.Util.GUID(),t.matrix=t.transform||n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t.mn=this.yn(t),t.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(t)||(t.matrix=n.mat4.multiply(t.matrix,t.parent.matrix,t.matrix)),t.H=t.parent.H,void 0===t.ke&&(t.ke=t.parent.ke+1),t.maxExtent=t.parent.maxExtent),t.refine=t.refine&&t.refine.toLowerCase()||"replace",t.content&&!t.content.url&&t.content.uri&&(t.content.url=t.content.uri)}j(t){return this.Pe[t].service}pn(t){const e=t.boundingVolume;if(!e||e.tn&&!this.bn(t))return;const r=this.j(t.H),i=r.heightOffset||0,s=this.options.offset,o=bt(s)||s[0]||s[1],a=r.coordOffset||is;if(!Array.isArray(a))throw new Error("service.coordOffset must be an array");if(!e.tn&&(!t.boundingVolume||!i&&0!==i&&n.mat4.exactEquals(t.matrix,rs)&&!o&&a===is))return;e.box&&e.region&&delete e.region;const{region:c,box:l,sphere:u}=e;if(e.coordOffset=[a[0],a[1]],e.heightOffset=i,c){e.originalVolume||(e.originalVolume=c.slice(0));const t=e.originalVolume,n=this.gn([Tt(t[0]),Tt(t[1])]);c[0]=wt(n.x+a[0]),c[1]=wt(n.y+a[1]);const r=this.gn([Tt(t[2]),Tt(t[3])]);c[2]=wt(r.x+a[0]),c[3]=wt(r.y+a[1]),c[4]=t[4]+i+(a[2]||0),c[5]=t[5]+i+(a[2]||0)}else if(l||u){e.originalVolume||(e.originalVolume=(l||u).slice(0));const r=l||u,s=e.originalVolume,o=n.vec3.transformMat4(Gi,s,t.matrix),c=Ne(Di,o),h=this.gn([c[0]+a[0],c[1]+a[1]]);c[0]=h.x,c[1]=h.y,c[2]+=i+(a[2]||0),Ae(r,wt(c[0]),wt(c[1]),c[2])}e.tn=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}bn(t){const e=t.boundingVolume,n=this.j(t.H),r=n.heightOffset||0,i=n.coordOffset||is;return e.coordOffset[0]!==i[0]||e.coordOffset[1]!==i[1]||e.heightOffset!==r}yn(t){return void 0===t.geometricError||!t.boundingVolume}dn(t){let e=t.parent;for(;e&&e.mn&&!(e.ft<=t.ft);)e.ft=t.ft,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1),this.Qe()}}onTilesetLoad(t,e,r){if(!t)return void console.warn("invalid tileset at : "+r);const i=(t.asset&&t.asset.gltfUpAxis||e&&e.xt||"Y").toUpperCase();t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const s=r.indexOf("realspace/")>-1;0===e.ke&&t.asset&&t.asset.s3mType&&s&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.xt=i,e){const r=e.boundingVolume,i=e.vn;i&&delete e.vn,pt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",r&&(e.boundingVolume=r);let s=t.root.transform;if(i){const t=this.j(e.H);t.ecefTransform&&(s=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.ecefTransform,s||rs))}s&&(e.parent?o||(e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,s)):e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.matrix,s)),delete e.content,t.root.content&&(e.content=t.root.content),e.mn=this.yn(e);const a=e.content&&(e.content.url||e.content.uri);a&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!o&&a&&!Ct(a)&&Pt(a)&&(e.content.url=e.baseUrl+a),t.root&&!e.parent&&this.wn(e)}this.Qe(),this.fire("loadtileset",{tileset:t,index:e&&e.H,url:r})}Tn(t,e,n){if(!t.extent||!Bi)return!0;const r=t.extent;if(ls[0]=r.xmin,ls[1]=r.ymin,ls[2]=r.xmax,ls[3]=r.ymax,e){if(!Bi.bboxIntersect(ls,e))return!1}if(n.length){for(let t=0,e=n.length;t<e;t++){const e=n[t].maskGeoJSON;if(!e||!e.bbox||Bi.bboxInMask(ls,e))return!0}return!1}return!0}un(t,e,n,r,i){if(!this.Tn(t,r,i))return gs.OUT_OF_FRUSTUM;if(t.ft=1/0,0===t.ke||t.mn)return this.wn(t),gs.VISIBLE;if(this.pn(t),!this.Mn(t,e,n))return gs.OUT_OF_FRUSTUM;if(0===t.geometricError)return gs.VISIBLE;let s=this.j(t.H).maximumScreenSpaceError;null==s&&(s=16);let o=this._n(t);return 0===o&&t.parent&&(o=.5*(t.parent.On||0)),o>=s?gs.VISIBLE:gs.SCREEN_ERROR_TOO_SMALL}Kt(t,e){e||(e=new i.Point(0,0));const n=this.getMap();return n.coordToPointAtRes(t,n.getGLRes(),e)}Mn(t,e,n){const r=t.id;let i=this.Xe.get(r);const{boundingVolume:s}=t,o=s.region,a=s.box,l=s.sphere,u=this.An(t.H),h=this.getRenderer();i&&i.version===u.version||(o?i=this.xn(t):a?i=this.In(t):l&&(i=this.Sn(t)),i&&this.Xe.set(r,i),i.version=u.version,t.dt&&(h.Dt(t.dt),delete t.dt));this.j(t.H).debug&&(this.Xe.get(r).node=t,h.Ft(t));const f=i.obbox;return f?function(t,e,n){M(t);for(var r=0;r<6;r++)if(!T(c[r],e))return!1;return!0}(n,f):!!l&&function(t,e,n){M(t);for(var r=e[0],i=-e[1],s=0;s<6;s++)if(O(c[s],r)<i)return!1;return!0}(n,i.sphereBox)}xn(t){const e=this.getMap(),r=e.getGLRes(),s=t.boundingVolume.region;let{ws:o,en:a}=function(t){const e=t[0],n=t[1],r=t[2],i=t[3],s=t[4],o=t[5],a=Ae([],e,n,s),c=Ae([],r,i,o),l=Ne(a,a),u=Ne(c,c);return{ws:l,en:u}}(s);o=new i.Coordinate(o),a=new i.Coordinate(a);const c=e.coordToPointAtRes(o,r);c.z=e.altitudeToPoint(o.z,r);const l=e.coordToPointAtRes(a,r);l.z=e.altitudeToPoint(a.z,r);const u=[l.x,c.y,l.z,l.x,l.y,l.z,c.x,l.y,l.z,c.x,c.y,l.z,l.x,c.y,c.z,l.x,l.y,c.z,c.x,l.y,c.z,c.x,c.y,c.z],h=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],f=this.An(t.H);t!==f||f.Cn||(f.Cn=h);const d=this.Jt([],t),m=n.mat4.exactEquals(rs,d);if(!m){n.vec3.transformMat4(h,h,d);const t=Gi;for(let e=0;e<u.length;e+=3){let r=n.vec3.set(t,u[e],u[e+1],u[e+2]);m||(r=n.vec3.transformMat4(r,r,d)),u[e]=r[0],u[e+1]=r[1],u[e+2]=r[2]}}const y=e.pointAtResToCoord(new i.Point(h),r);y.z=(o.z+a.z)/2;const p=this.kn(u,h);for(let t=0;t<u.length;t++)u[t]-=h[t%3];return{obbox:p,boxPosition:u,boxCenter:h,boxCoord:y}}In(t){const e=this.getRenderer(),r=this.getMap(),i="identity"===r.getProjection().code.toLowerCase(),s=r.getGLRes(),{boxCenter:o,boxCoord:a}=this.Nn(t),c=t.boundingVolume.box,l=function(t,e,n){return function(t,e,n,r,i,s,o,a,c,l,u,h,f,d,m,y,p){return t[0]=e||0,t[1]=s||0,t[2]=l||0,t[3]=0,t[4]=n||0,t[5]=o||0,t[6]=u||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=h||0,t[11]=0,t[12]=i||0,t[13]=c||0,t[14]=f||0,t[15]=p,t}(t,e[0],e[3],e[6],n[0],e[1],e[4],e[7],n[1],e[2],e[5],e[8],n[2],0,0,0,1)}([],this.Ln(c,t.matrix),c),u=this.Jt([],t),h=n.mat4.exactEquals(rs,u);h||n.vec3.transformMat4(o,o,u);const f=[],d=Gi;for(let t=0;t<us.length;t+=3){d[0]=us[t],d[1]=us[t+1],d[2]=us[t+2],n.vec3.transformMat4(d,d,l),Ne(d,d),i&&e.Je(d,d);const o=Ki.set(d[0],d[1],d[2]);r.coordToPointAtRes(o,s,Xi);let a=n.vec3.set(d,Xi.x,Xi.y,r.altitudeToPoint(o.z,s));h||(a=n.vec3.transformMat4(a,a,u)),f[t]=a[0],f[t+1]=a[1],f[t+2]=a[2]}const m=this.kn(f,o);for(let t=0;t<f.length;t++)f[t]-=o[t%3];return{obbox:m,boxPosition:f,boxCenter:o,boxCoord:a}}Sn(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),s=t.boundingVolume.sphere,o=s;let a=Gi;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:Ne(a,o),r&&n.Je(a,a);const c=new i.Coordinate(a),l=this.Kt(c,Xi).toArray();l[2]=e.altitudeToPoint(c.z,e.getGLRes());const u=this.En(c);return{boxCenter:l,boxCoord:c,sphereBox:[l,s[3]*u[2]]}}kn(t,e){const r=ys(Hi,t,0,1,4,5),i=ys(qi,t,0,3,4,7),s=ys($i,t,0,1,2,3);return[...e,...n.vec3.sub(Gi,r,e),...n.vec3.sub(Di,i,e),...n.vec3.sub(ji,s,e)]}Nn(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),s=e.getGLRes(),o=t.boundingVolume.box.slice(0,3);Ne(o,o),r&&n.Je(o,o);const a=new i.Coordinate(o),c=e.coordToPointAtRes(a,s);return{boxCenter:[c.x,c.y,e.altitudeToPoint(a.z,s)],boxCoord:a}}Jt(t,e){const r=this.An(e.H),i=this.j(e.H),s=r.Cn,o=n.mat4.fromTranslation(Qi,n.vec3.set(Gi,-s[0],-s[1],-s[2])),a=n.mat4.fromTranslation(ts,s),c=i.rotation||ss,l=n.quat.fromEuler(Yi,...c),u=i.scale;let h;h=Array.isArray(u)?n.vec3.set(as,u[0],u[1],u[2]):u&&n.vec3.set(as,u,u,u)||os;const f=n.mat4.fromRotationTranslationScale(es,l,cs,h);return t=n.mat4.multiply(t,f,o),n.mat4.multiply(t,a,t)}wn(t){const e=this.j(t.H);if(!t.boundingVolume||this.Rn(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,i=t.boundingVolume.sphere;let s=null;n?s=this.Pn(t).boxCenter:r?s=this.Un(t).boxCenter:i&&(s=this.Sn(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.Bn=[a[0]||0,a[1]||0],t.Fn=o,t.Cn=s}Rn(t,e){if(!t.Bn)return!1;const n=e.coordOffset||is;return t.Bn[0]===n[0]&&t.Bn[1]===n[1]&&t.Fn===(e.heightOffset||0)}Un(t){return this.pn(t),this.xn(t)}Pn(t){return this.pn(t),this.Nn(t)}Ln(t,e){let r=t.slice(3,12);const i=n.mat3.fromMat4(Wi,e);return r=n.mat3.multiply(r,i,r),r}En(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let i;return i=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:r.y/100,n.vec3.set(Vi,r.x/100*1.01,r.y/100*1.01,i),Vi}gn(t){Array.isArray(t)&&(t=new i.Coordinate(t));let e=this.options.offset;if(bt(e)&&(e=e.call(this,Array.isArray(t)?new i.Coordinate(t):t)),e[0]||e[1]){const n=this.getMap(),r=n.getGLRes(),i=n.coordToPointAtRes(t,r);return Xi.set(e[0],e[1]),i._sub(Xi),n.pointAtResToCoord(i,r)}return t}An(t){return this.Pe[t]}cn(t){const e=this.j(t).maxExtent;if(!e)return null;const n=this.Pe[t];return n.maxExtent||(n.maxExtent=new i.Extent(e).convertTo((t=>this.Kt(t)))),n.maxExtent}_n(t){const e=this.an,r=t.geometricError;if(0===r)return t.On=0,0;const i=this.j(t.H);let s=i.scale||1;if(Array.isArray(s)&&(s=n.vec3.length(s)),i.ecefTransform){const t=n.mat4.getScaling(Ji,i.ecefTransform);s*=n.vec3.len(t)}const o=this.getMap();let a;t.boundingVolume.region?a=function(t,e,n){t.Gn||(t.Gn=new Ri(t.boundingVolume.region));return t.Gn.distanceToCamera(e,n)}(t,this.sn,this.rn):t.boundingVolume.sphere?a=fs(t.boundingVolume,this.sn):t.boundingVolume.box&&(a=ds(t.boundingVolume,this.sn));const c=Math.max(Math.abs(a),1e-7),l=r*s*o.height/(c*e);return t.ft=a,t.On=l,l}Qe(){const t=this.getRenderer();t&&t.setToRedraw()}Gt(t){return this.Xe.get(t)}identify(t,e={}){const n=this.getMap(),r=this.getRenderer();if(!n||!r)return[];Array.isArray(t)&&(t=new i.Coordinate(t));const s=n.coordToContainerPoint(t);return this.identifyAtPoint(s,e)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&Nt(n,r)}const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];const s=r.getDevicePixelRatio();return Nt(n,i.pick(t.x*s,t.y*s,e)),e&&e.filter&&!e.excludeMasks?n.filter((t=>e.filter(t))):n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Wt():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.J||(this.J=[]),this.J.push(t),this)}ze(){if(this.J){for(let t=0;t<this.J.length;t++)this.highlight(this.J[t]);delete this.J}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Z||(this.Z=[]),this.Z.push(t),this)}Dn(){if(this.Z){for(let t=0;t<this.Z.length;t++)this.showOnly(this.Z[t]);delete this.Z}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);return this.getRenderer()?(this.Qe(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Qe(),this):this}nn(t){const e=this.getMap(),n=e.getGLRes();ns.set(t[0],t[1]);const r=e.pointAtResToCoord(ns,n);return"identity"===e.getProjection().code.toLowerCase()?(Di[0]=r.x,Di[1]=r.y,this.getRenderer().Ye(Gi,Di),r.set(Gi[0],Gi[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function fs(t,e,r){let i=t.sphere;r&&(i=n.vec3.transformMat4([0,0,0],i,r));const s=n.vec3.dist(i,e),o=t.sphere[3];return s<o?0:s-o}function ds(t,e,r){const i=t.box;let s=n.vec3.set(Gi,i[0],i[1],i[2]);r&&(s=n.vec3.transformMat4([0,0,0],s,r));return hi(s,n.mat3.set(Wi,i[3],i[4],i[5],i[6],i[7],i[8],i[9],i[10],i[11]),e)}function ms(t,e,r){const i=(t=Mt(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,mn:!0,service:r,visible:!!yt(r.visible)||r.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),H:e,ke:0,vn:!0,domainKey:i}}function ys(t,e,r,i,s,o){const a=n.vec3.set(Gi,e[3*r],e[3*r+1],e[3*r+2]),c=n.vec3.set(Di,e[3*i],e[3*i+1],e[3*i+2]),l=n.vec3.set(ji,e[3*s],e[3*s+1],e[3*s+2]),u=n.vec3.set(zi,e[3*o],e[3*o+1],e[3*o+2]);return t[0]=(a[0]+c[0]+l[0]+u[0])/4,t[1]=(a[1]+c[1]+l[1]+u[1])/4,t[2]=(a[2]+c[2]+l[2]+u[2])/4,t}function ps(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e&&(e.content||e.hasParentContent))return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function bs(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?n.vec2.exactEquals(t,e):n.vec3.exactEquals(t,e):t===e}var gs;hs.mergeOptions(Fi),hs.registerRenderer("gl",ci),hs.registerRenderer("gpu",ci),hs.registerJSONType("Geo3DTilesLayer"),function(t){t[t.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",t[t.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",t[t.VISIBLE=2]="VISIBLE"}(gs||(gs={}));let vs=null;function ws(){return vs||(vs={"image/crn":Gt.crn&&Gt.crn(),"image/ktx2":Gt.ktx2&&Gt.ktx2(),"image/cttf":Gt.ktx2&&Gt.ktx2(),"draco":Gt.draco&&Gt.draco()}),vs}const{Ajax:Ts,GLTFLoader:Ms}=Dt();class _s{constructor(t,e,n){this.jn=t,this.zn=e||Ms,this.Re=n,this.Hn=ws()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.qn(t,e,n,r,i)):Ts.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.qn(t,i,n,r)}))}qn(t,e,n,r,i){const s=i&&i.maxTextureSize,o=this.$n(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.zn(a,o.glb,{transferable:!0,requestImage:this.jn,decoders:this.Hn,supportedFormats:this.Re,maxTextureSize:s})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}$n(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),l=i.getUint32(20,!0),u=i.getUint32(24,!0),h=28+e;l>=570425344?(h-=8,o=a,l=c,u=0,a=0,c=0):u>=570425344&&(h-=4,o=l,l=a,u=c,a=0,c=0);const f=[t];let d,m,y;if(a>0?(d=He(t,h,a),h+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(h+=c),l>0&&(m=qe(t,h,l),h+=l,u>0)){const e=$e(0,h,u);y=t.slice(e.offset,e.offset+e.byteLength),h+=u,f.push(y)}const p=d.BATCH_LENGTH,b={};if(d&&d.BATCH_ID){b.BATCH_ID=Je(d.BATCH_ID,t,undefined.offset,p);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:y,b3dm:b,glb:{buffer:t,byteOffset:h,byteLength:i.byteLength+i.byteOffset-h}}}Vn(){return null}}const{Ajax:Os,GLTFLoader:As}=Dt();class xs{constructor(t,e,n,r){this.jn=t,this.zn=e||As,this.Re=n,this.Hn=ws(),this.Jn=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.qn(t,e,n,r,i)):Os.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.qn(t,i,n,r)}))}qn(t,e,n,r,i){return this.Yn(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.Zn(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}Yn(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.jn,decoders:this.Hn,supportedFormats:this.Re,maxTextureSize:s},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=At(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?Os.getArrayBuffer(r,{}).then((t=>this.Kn(r,{buffer:t.data,byteOffset:0},o))):Os.getJSON(r,{}).then((t=>this.Kn(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Kn(t,r,o)}}Kn(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),i=new this.zn(r,e,n);return i.load({skipAttributeTransform:!0}).then((n=>{let r=0,s=0;return e.buffer&&(r=e.byteOffset||0,s=e.byteLength||0),n.url=`${t}-${r}-${s}`,{transferables:i.transferables,gltf:n}}))}Zn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:u}=en(i,32+e,o),h={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;h.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).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:f,componentType:5126,array:this.Xn(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(h.POSITION.array.buffer)}if(a.BATCH_ID){h.BATCH_ID=Je(a.BATCH_ID,t,c.offset,f);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:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).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:f,componentType:5126,array:this.Wn(new Uint16Array(t,e+c.offset,2*f))},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Wn(new Uint16Array(t,e+c.offset,2*f))},o.push(h.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;h.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).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:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(h.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:l,batchTableBin:u,featureTable:a,i3dm:h,transferables:o}}Wn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)Is(r,t[2*i],t[2*i+1],65535),n[3*i]=r[0],n[3*i+1]=r[1],n[3*i+2]=r[2];return n}Xn(t,e,n){return tn(new Float32Array(t.length),t,e,n)}Vn(){return null}}function Is(t,e,n,r){if(t[0]=Ss(e,r),t[1]=Ss(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]))*Cs(e),t[1]=(1-Math.abs(e))*Cs(t[1])}return ne(t,t)}function Ss(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 Cs(t){return t<0?-1:1}const{Ajax:ks}=Dt();class Ns{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.qn(t,e,n,r)):ks.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.qn(t,i,n,r)}))}qn(t,e,n,r){return this.Qn(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}))}Qn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:u}=en(i,e+28,o),h=a.QUANTIZED_VOLUME_OFFSET,f=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,y={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){y=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,y.byteOffset+c.offset,y.byteLength);const e={attributes:y.properties,useUniqueIDs:!1};return this.tr||(this.tr=ws().draco),this.tr(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.er(t,e.attributes,c.offset,d,o,h,f);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Qe(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?r.BATCH_ID=Je(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Ls(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:l,batchTableBin:u,featureTable:a,pnts:r,transferables:o}}))}const p=this.er(t,a,c.offset,d,o,h,f);if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?p.BATCH_ID=Je(a.BATCH_ID,t,c.offset,d):p.BATCH_ID=Ls(d);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:l,batchTableBin:u,featureTable:a,pnts:p,transferables:o})}er(t,e,n,r,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:l}=e.POSITION_QUANTIZED;c=c||0;const u=l?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Xn(l||new Uint16Array(t,c+u,3*r),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},i.push(o.buffer)}return a}Xn(t,e,n){return tn(new Float32Array(t.length),t,e,n)}Vn(){return null}}function Ls(t){const e=St(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:Qe(e),array:n}}const{Ajax:Es,GLTFLoader:Rs}=Dt();class Ps{constructor(t,e,n,r){this.Re=n,this.jn=t,this.zn=e||Rs,this.Jn=r}load(t,e,n=0,r=0,i){return e?this.qn(t,e,n,r,i):Es.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.qn(t,i,n,r)}))}qn(t,e,n,r,i){r||(r=e.byteLength);const s=this.nr(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new _s(this.jn,this.zn,this.Re);else if("i3dm"===s[n].magic)r=new xs(this.jn,this.zn,this.Re,this.Jn);else if("pnts"===s[n].magic)r=new Ns;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new Ps(this.jn,this.zn,this.Re,this.Jn)}o.push(r.load(t,e,s[n].offset,s[n].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}nr(t,e,n,r){const i=new DataView(t,n,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=je(i,c),r=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(s.transcoders){const t=i.Map.VERSION;if(t.indexOf("1.0.0-beta")>=0||t.indexOf("1.0.0-alpha")>=0){const t=s.transcoders.inject(a);i.registerWorkerAdapter("@maptalks/3dtiles",t)}else i.registerWorkerAdapter("@maptalks/3dtiles",(function(){return s.transcoders.inject(a)}))}else i.registerWorkerAdapter("@maptalks/3dtiles",a);t.B3DMLoader=_s,t.CMPTLoader=Ps,t.Geo3DTilesLayer=hs,t.Geo3DTilesUtil=Rt,t.Geo3DTransform=Ge,"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.124.0")}));
|
|
17
17
|
//# sourceMappingURL=maptalks.3dtiles.js.map
|