(function(qe,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(qe=typeof globalThis<"u"?globalThis:qe||self,m((qe.cesium=qe.cesium||{},qe.cesium.draw={})))})(this,function(qe){"use strict";var Sx=Object.defineProperty;var Ox=(qe,m,h)=>m in qe?Sx(qe,m,{enumerable:!0,configurable:!0,writable:!0,value:h}):qe[m]=h;var ge=(qe,m,h)=>(Ox(qe,typeof m!="symbol"?m+"":m,h),h);function m(e,t){return e??t}m.EMPTY_OBJECT=Object.freeze({});function h(e){return e!=null}function T(e){this.name="DeveloperError",this.message=e;let t;try{throw new Error}catch(n){t=n.stack}this.stack=t}h(Object.create)&&(T.prototype=Object.create(Error.prototype),T.prototype.constructor=T),T.prototype.toString=function(){let e=`${this.name}: ${this.message}`;return h(this.stack)&&(e+=` ${this.stack.toString()}`),e},T.throwInstantiationError=function(){throw new T("This function defines an interface and should not be called directly.")};const ft={};ft.typeOf={};function i_(e){return`${e} is required, actual value was undefined`}function to(e,t,n){return`Expected ${n} to be typeof ${t}, actual typeof was ${e}`}ft.defined=function(e,t){if(!h(t))throw new T(i_(e))},ft.typeOf.func=function(e,t){if(typeof t!="function")throw new T(to(typeof t,"function",e))},ft.typeOf.string=function(e,t){if(typeof t!="string")throw new T(to(typeof t,"string",e))},ft.typeOf.number=function(e,t){if(typeof t!="number")throw new T(to(typeof t,"number",e))},ft.typeOf.number.lessThan=function(e,t,n){if(ft.typeOf.number(e,t),t>=n)throw new T(`Expected ${e} to be less than ${n}, actual value was ${t}`)},ft.typeOf.number.lessThanOrEquals=function(e,t,n){if(ft.typeOf.number(e,t),t>n)throw new T(`Expected ${e} to be less than or equal to ${n}, actual value was ${t}`)},ft.typeOf.number.greaterThan=function(e,t,n){if(ft.typeOf.number(e,t),t<=n)throw new T(`Expected ${e} to be greater than ${n}, actual value was ${t}`)},ft.typeOf.number.greaterThanOrEquals=function(e,t,n){if(ft.typeOf.number(e,t),t0){for(o.sort(o_),e=0;e0&&(this._hash={},e.length=0)};var no=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Un=function(e){e==null&&(e=new Date().getTime()),this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,e.constructor==Array?this.init_by_array(e,e.length):this.init_seed(e)};Un.prototype.init_seed=function(e){for(this.mt[0]=e>>>0,this.mti=1;this.mti>>30;this.mt[this.mti]=(((e&4294901760)>>>16)*1812433253<<16)+(e&65535)*1812433253+this.mti,this.mt[this.mti]>>>=0}},Un.prototype.init_by_array=function(e,t){var n,i,o;for(this.init_seed(19650218),n=1,i=0,o=this.N>t?this.N:t;o;o--){var r=this.mt[n-1]^this.mt[n-1]>>>30;this.mt[n]=(this.mt[n]^(((r&4294901760)>>>16)*1664525<<16)+(r&65535)*1664525)+e[i]+i,this.mt[n]>>>=0,n++,i++,n>=this.N&&(this.mt[0]=this.mt[this.N-1],n=1),i>=t&&(i=0)}for(o=this.N-1;o;o--){var r=this.mt[n-1]^this.mt[n-1]>>>30;this.mt[n]=(this.mt[n]^(((r&4294901760)>>>16)*1566083941<<16)+(r&65535)*1566083941)-n,this.mt[n]>>>=0,n++,n>=this.N&&(this.mt[0]=this.mt[this.N-1],n=1)}this.mt[0]=2147483648},Un.prototype.random_int=function(){var e,t=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var n;for(this.mti==this.N+1&&this.init_seed(5489),n=0;n>>1^t[e&1];for(;n>>1^t[e&1];e=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^e>>>1^t[e&1],this.mti=0}return e=this.mt[this.mti++],e^=e>>>11,e^=e<<7&2636928640,e^=e<<15&4022730752,e^=e>>>18,e>>>0},Un.prototype.random_int31=function(){return this.random_int()>>>1},Un.prototype.random_incl=function(){return this.random_int()*(1/4294967295)},Un.prototype.random=function(){return this.random_int()*(1/4294967296)},Un.prototype.random_excl=function(){return(this.random_int()+.5)*(1/4294967296)},Un.prototype.random_long=function(){var e=this.random_int()>>>5,t=this.random_int()>>>6;return(e*67108864+t)*(1/9007199254740992)};var a_=Un;const Kl=Xl(a_),ne={};ne.EPSILON1=.1,ne.EPSILON2=.01,ne.EPSILON3=.001,ne.EPSILON4=1e-4,ne.EPSILON5=1e-5,ne.EPSILON6=1e-6,ne.EPSILON7=1e-7,ne.EPSILON8=1e-8,ne.EPSILON9=1e-9,ne.EPSILON10=1e-10,ne.EPSILON11=1e-11,ne.EPSILON12=1e-12,ne.EPSILON13=1e-13,ne.EPSILON14=1e-14,ne.EPSILON15=1e-15,ne.EPSILON16=1e-16,ne.EPSILON17=1e-17,ne.EPSILON18=1e-18,ne.EPSILON19=1e-19,ne.EPSILON20=1e-20,ne.EPSILON21=1e-21,ne.GRAVITATIONALPARAMETER=3986004418e5,ne.SOLAR_RADIUS=6955e5,ne.LUNAR_RADIUS=1737400,ne.SIXTY_FOUR_KILOBYTES=64*1024,ne.FOUR_GIGABYTES=4*1024*1024*1024,ne.sign=m(Math.sign,function(t){return t=+t,t===0||t!==t?t:t>0?1:-1}),ne.signNotZero=function(e){return e<0?-1:1},ne.toSNorm=function(e,t){return t=m(t,255),Math.round((ne.clamp(e,-1,1)*.5+.5)*t)},ne.fromSNorm=function(e,t){return t=m(t,255),ne.clamp(e,0,t)/t*2-1},ne.normalize=function(e,t,n){return n=Math.max(n-t,0),n===0?0:ne.clamp((e-t)/n,0,1)},ne.sinh=m(Math.sinh,function(t){return(Math.exp(t)-Math.exp(-t))/2}),ne.cosh=m(Math.cosh,function(t){return(Math.exp(t)+Math.exp(-t))/2}),ne.lerp=function(e,t,n){return(1-n)*e+n*t},ne.PI=Math.PI,ne.ONE_OVER_PI=1/Math.PI,ne.PI_OVER_TWO=Math.PI/2,ne.PI_OVER_THREE=Math.PI/3,ne.PI_OVER_FOUR=Math.PI/4,ne.PI_OVER_SIX=Math.PI/6,ne.THREE_PI_OVER_TWO=3*Math.PI/2,ne.TWO_PI=2*Math.PI,ne.ONE_OVER_TWO_PI=1/(2*Math.PI),ne.RADIANS_PER_DEGREE=Math.PI/180,ne.DEGREES_PER_RADIAN=180/Math.PI,ne.RADIANS_PER_ARCSECOND=ne.RADIANS_PER_DEGREE/3600,ne.toRadians=function(e){if(!h(e))throw new T("degrees is required.");return e*ne.RADIANS_PER_DEGREE},ne.toDegrees=function(e){if(!h(e))throw new T("radians is required.");return e*ne.DEGREES_PER_RADIAN},ne.convertLongitudeRange=function(e){if(!h(e))throw new T("angle is required.");const t=ne.TWO_PI,n=e-Math.floor(e/t)*t;return n<-Math.PI?n+t:n>=Math.PI?n-t:n},ne.clampToLatitudeRange=function(e){if(!h(e))throw new T("angle is required.");return ne.clamp(e,-1*ne.PI_OVER_TWO,ne.PI_OVER_TWO)},ne.negativePiToPi=function(e){if(!h(e))throw new T("angle is required.");return e>=-ne.PI&&e<=ne.PI?e:ne.zeroToTwoPi(e+ne.PI)-ne.PI},ne.zeroToTwoPi=function(e){if(!h(e))throw new T("angle is required.");if(e>=0&&e<=ne.TWO_PI)return e;const t=ne.mod(e,ne.TWO_PI);return Math.abs(t)ne.EPSILON14?ne.TWO_PI:t},ne.mod=function(e,t){if(!h(e))throw new T("m is required.");if(!h(t))throw new T("n is required.");if(t===0)throw new T("divisor cannot be 0.");return ne.sign(e)===ne.sign(t)&&Math.abs(e)n},ne.greaterThanOrEquals=function(e,t,n){if(!h(e))throw new T("first is required.");if(!h(t))throw new T("second is required.");if(!h(n))throw new T("absoluteEpsilon is required.");return e-t>-n};const Hr=[1];ne.factorial=function(e){if(typeof e!="number"||e<0)throw new T("A number greater than or equal to 0 is required.");const t=Hr.length;if(e>=t){let n=Hr[t-1];for(let i=t;i<=e;i++){const o=n*i;Hr.push(o),n=o}}return Hr[e]},ne.incrementWrap=function(e,t,n){if(n=m(n,0),!h(e))throw new T("n is required.");if(t<=n)throw new T("maximumValue must be greater than minimumValue.");return++e,e>t&&(e=n),e},ne.isPowerOfTwo=function(e){if(typeof e!="number"||e<0||e>4294967295)throw new T("A number between 0 and (2^32)-1 is required.");return e!==0&&(e&e-1)===0},ne.nextPowerOfTwo=function(e){if(typeof e!="number"||e<0||e>2147483648)throw new T("A number between 0 and 2^31 is required.");return--e,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e,e},ne.previousPowerOfTwo=function(e){if(typeof e!="number"||e<0||e>4294967295)throw new T("A number between 0 and (2^32)-1 is required.");return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e=(e>>>0)-(e>>>1),e},ne.clamp=function(e,t,n){return d.typeOf.number("value",e),d.typeOf.number("min",t),d.typeOf.number("max",n),en?n:e};let Zl=new Kl;ne.setRandomNumberSeed=function(e){if(!h(e))throw new T("seed is required.");Zl=new Kl(e)},ne.nextRandomNumber=function(){return Zl.random()},ne.randomBetween=function(e,t){return ne.nextRandomNumber()*(t-e)+e},ne.acosClamped=function(e){if(!h(e))throw new T("value is required.");return Math.acos(ne.clamp(e,-1,1))},ne.asinClamped=function(e){if(!h(e))throw new T("value is required.");return Math.asin(ne.clamp(e,-1,1))},ne.chordLength=function(e,t){if(!h(e))throw new T("angle is required.");if(!h(t))throw new T("radius is required.");return 2*t*Math.sin(e*.5)},ne.logBase=function(e,t){if(!h(e))throw new T("number is required.");if(!h(t))throw new T("base is required.");return Math.log(e)/Math.log(t)},ne.cbrt=m(Math.cbrt,function(t){const n=Math.pow(Math.abs(t),.3333333333333333);return t<0?-n:n}),ne.log2=m(Math.log2,function(t){return Math.log(t)*Math.LOG2E}),ne.fog=function(e,t){const n=e*t;return 1-Math.exp(-(n*n))},ne.fastApproximateAtan=function(e){return d.typeOf.number("x",e),e*(-.1784*Math.abs(e)-.0663*e*e+1.0301)},ne.fastApproximateAtan2=function(e,t){d.typeOf.number("x",e),d.typeOf.number("y",t);let n,i=Math.abs(e);n=Math.abs(t);const o=Math.max(i,n);n=Math.min(i,n);const r=n/o;if(isNaN(r))throw new T("either x or y must be nonzero");return i=ne.fastApproximateAtan(r),i=Math.abs(t)>Math.abs(e)?ne.PI_OVER_TWO-i:i,i=e<0?ne.PI-i:i,i=t<0?-i:i,i};const P=ne;function L(e,t){this.x=m(e,0),this.y=m(t,0)}L.fromElements=function(e,t,n){return h(n)?(n.x=e,n.y=t,n):new L(e,t)},L.clone=function(e,t){if(h(e))return h(t)?(t.x=e.x,t.y=e.y,t):new L(e.x,e.y)},L.fromCartesian3=L.clone,L.fromCartesian4=L.clone,L.packedLength=2,L.pack=function(e,t,n){return d.typeOf.object("value",e),d.defined("array",t),n=m(n,0),t[n++]=e.x,t[n]=e.y,t},L.unpack=function(e,t,n){return d.defined("array",e),t=m(t,0),h(n)||(n=new L),n.x=e[t++],n.y=e[t],n},L.packArray=function(e,t){d.defined("array",e);const n=e.length,i=n*2;if(!h(t))t=new Array(i);else{if(!Array.isArray(t)&&t.length!==i)throw new T("If result is a typed array, it must have exactly array.length * 2 elements");t.length!==i&&(t.length=i)}for(let o=0;oP.EPSILON12);return h(o)?(o.x=r*j,o.y=s*B,o.z=a*H,o):new l(r*j,s*B,a*H)}function J(e,t,n){this.longitude=m(e,0),this.latitude=m(t,0),this.height=m(n,0)}J.fromRadians=function(e,t,n,i){return d.typeOf.number("longitude",e),d.typeOf.number("latitude",t),n=m(n,0),h(i)?(i.longitude=e,i.latitude=t,i.height=n,i):new J(e,t,n)},J.fromDegrees=function(e,t,n,i){return d.typeOf.number("longitude",e),d.typeOf.number("latitude",t),e=P.toRadians(e),t=P.toRadians(t),J.fromRadians(e,t,n,i)};const d_=new l,p_=new l,m_=new l,__=new l(1/6378137,1/6378137,1/6356752314245179e-9),g_=new l(1/(6378137*6378137),1/(6378137*6378137),1/(6356752314245179e-9*6356752314245179e-9)),y_=P.EPSILON1;J.fromCartesian=function(e,t,n){const i=h(t)?t.oneOverRadii:__,o=h(t)?t.oneOverRadiiSquared:g_,r=h(t)?t._centerToleranceSquared:y_,s=nh(e,i,o,r,p_);if(!h(s))return;let a=l.multiplyComponents(s,o,d_);a=l.normalize(a,a);const c=l.subtract(e,s,m_),u=Math.atan2(a.y,a.x),f=Math.asin(a.z),p=P.sign(l.dot(c,e))*l.magnitude(c);return h(n)?(n.longitude=u,n.latitude=f,n.height=p,n):new J(u,f,p)},J.toCartesian=function(e,t,n){return d.defined("cartographic",e),l.fromRadians(e.longitude,e.latitude,e.height,t,n)},J.clone=function(e,t){if(h(e))return h(t)?(t.longitude=e.longitude,t.latitude=e.latitude,t.height=e.height,t):new J(e.longitude,e.latitude,e.height)},J.equals=function(e,t){return e===t||h(e)&&h(t)&&e.longitude===t.longitude&&e.latitude===t.latitude&&e.height===t.height},J.equalsEpsilon=function(e,t,n){return n=m(n,0),e===t||h(e)&&h(t)&&Math.abs(e.longitude-t.longitude)<=n&&Math.abs(e.latitude-t.latitude)<=n&&Math.abs(e.height-t.height)<=n},J.ZERO=Object.freeze(new J(0,0,0)),J.prototype.clone=function(e){return J.clone(this,e)},J.prototype.equals=function(e){return J.equals(this,e)},J.prototype.equalsEpsilon=function(e,t){return J.equalsEpsilon(this,e,t)},J.prototype.toString=function(){return`(${this.longitude}, ${this.latitude}, ${this.height})`};function ih(e,t,n,i){t=m(t,0),n=m(n,0),i=m(i,0),d.typeOf.number.greaterThanOrEquals("x",t,0),d.typeOf.number.greaterThanOrEquals("y",n,0),d.typeOf.number.greaterThanOrEquals("z",i,0),e._radii=new l(t,n,i),e._radiiSquared=new l(t*t,n*n,i*i),e._radiiToTheFourth=new l(t*t*t*t,n*n*n*n,i*i*i*i),e._oneOverRadii=new l(t===0?0:1/t,n===0?0:1/n,i===0?0:1/i),e._oneOverRadiiSquared=new l(t===0?0:1/(t*t),n===0?0:1/(n*n),i===0?0:1/(i*i)),e._minimumRadius=Math.min(t,n,i),e._maximumRadius=Math.max(t,n,i),e._centerToleranceSquared=P.EPSILON1,e._radiiSquared.z!==0&&(e._squaredXOverSquaredZ=e._radiiSquared.x/e._radiiSquared.z)}function pe(e,t,n){this._radii=void 0,this._radiiSquared=void 0,this._radiiToTheFourth=void 0,this._oneOverRadii=void 0,this._oneOverRadiiSquared=void 0,this._minimumRadius=void 0,this._maximumRadius=void 0,this._centerToleranceSquared=void 0,this._squaredXOverSquaredZ=void 0,ih(this,e,t,n)}Object.defineProperties(pe.prototype,{radii:{get:function(){return this._radii}},radiiSquared:{get:function(){return this._radiiSquared}},radiiToTheFourth:{get:function(){return this._radiiToTheFourth}},oneOverRadii:{get:function(){return this._oneOverRadii}},oneOverRadiiSquared:{get:function(){return this._oneOverRadiiSquared}},minimumRadius:{get:function(){return this._minimumRadius}},maximumRadius:{get:function(){return this._maximumRadius}}}),pe.clone=function(e,t){if(!h(e))return;const n=e._radii;return h(t)?(l.clone(n,t._radii),l.clone(e._radiiSquared,t._radiiSquared),l.clone(e._radiiToTheFourth,t._radiiToTheFourth),l.clone(e._oneOverRadii,t._oneOverRadii),l.clone(e._oneOverRadiiSquared,t._oneOverRadiiSquared),t._minimumRadius=e._minimumRadius,t._maximumRadius=e._maximumRadius,t._centerToleranceSquared=e._centerToleranceSquared,t):new pe(n.x,n.y,n.z)},pe.fromCartesian3=function(e,t){return h(t)||(t=new pe),h(e)&&ih(t,e.x,e.y,e.z),t},pe.WGS84=Object.freeze(new pe(6378137,6378137,6356752314245179e-9)),pe.UNIT_SPHERE=Object.freeze(new pe(1,1,1)),pe.MOON=Object.freeze(new pe(P.LUNAR_RADIUS,P.LUNAR_RADIUS,P.LUNAR_RADIUS)),pe.prototype.clone=function(e){return pe.clone(this,e)},pe.packedLength=l.packedLength,pe.pack=function(e,t,n){return d.typeOf.object("value",e),d.defined("array",t),n=m(n,0),l.pack(e._radii,t,n),t},pe.unpack=function(e,t,n){d.defined("array",e),t=m(t,0);const i=l.unpack(e,t);return pe.fromCartesian3(i,n)},pe.prototype.geocentricSurfaceNormal=l.normalize,pe.prototype.geodeticSurfaceNormalCartographic=function(e,t){d.typeOf.object("cartographic",e);const n=e.longitude,i=e.latitude,o=Math.cos(i),r=o*Math.cos(n),s=o*Math.sin(n),a=Math.sin(i);return h(t)||(t=new l),t.x=r,t.y=s,t.z=a,l.normalize(t,t)},pe.prototype.geodeticSurfaceNormal=function(e,t){if(!l.equalsEpsilon(e,l.ZERO,P.EPSILON14))return h(t)||(t=new l),t=l.multiplyComponents(e,this._oneOverRadiiSquared,t),l.normalize(t,t)};const w_=new l,b_=new l;pe.prototype.cartographicToCartesian=function(e,t){const n=w_,i=b_;this.geodeticSurfaceNormalCartographic(e,n),l.multiplyComponents(this._radiiSquared,n,i);const o=Math.sqrt(l.dot(n,i));return l.divideByScalar(i,o,i),l.multiplyByScalar(n,e.height,n),h(t)||(t=new l),l.add(i,n,t)},pe.prototype.cartographicArrayToCartesianArray=function(e,t){d.defined("cartographics",e);const n=e.length;h(t)?t.length=n:t=new Array(n);for(let i=0;i=this._radii.z-t))return n};const S_=[.14887433898163,.43339539412925,.67940956829902,.86506336668898,.97390652851717,0],O_=[.29552422471475,.26926671930999,.21908636251598,.14945134915058,.066671344308684,0];function oh(e,t,n){d.typeOf.number("a",e),d.typeOf.number("b",t),d.typeOf.func("func",n);const i=.5*(t+e),o=.5*(t-e);let r=0;for(let s=0;s<5;s++){const a=o*S_[s];r+=O_[s]*(n(i+a)+n(i-a))}return r*=o,r}pe.prototype.surfaceArea=function(e){d.typeOf.object("rectangle",e);const t=e.west;let n=e.east;const i=e.south,o=e.north;for(;n=0?f.longitude:f.longitude+P.TWO_PI;o=Math.min(o,p),r=Math.max(r,p)}return i-n>r-o&&(n=o,i=r,i>P.PI&&(i=i-P.TWO_PI),n>P.PI&&(n=n-P.TWO_PI)),h(t)?(t.west=n,t.south=s,t.east=i,t.north=a,t):new he(n,s,i,a)},he.fromCartesianArray=function(e,t,n){d.defined("cartesians",e),t=m(t,pe.WGS84);let i=Number.MAX_VALUE,o=-Number.MAX_VALUE,r=Number.MAX_VALUE,s=-Number.MAX_VALUE,a=Number.MAX_VALUE,c=-Number.MAX_VALUE;for(let u=0,f=e.length;u=0?p.longitude:p.longitude+P.TWO_PI;r=Math.min(r,_),s=Math.max(s,_)}return o-i>s-r&&(i=r,o=s,o>P.PI&&(o=o-P.TWO_PI),i>P.PI&&(i=i-P.TWO_PI)),h(n)?(n.west=i,n.south=a,n.east=o,n.north=c,n):new he(i,a,o,c)},he.clone=function(e,t){if(h(e))return h(t)?(t.west=e.west,t.south=e.south,t.east=e.east,t.north=e.north,t):new he(e.west,e.south,e.east,e.north)},he.equalsEpsilon=function(e,t,n){return n=m(n,0),e===t||h(e)&&h(t)&&Math.abs(e.west-t.west)<=n&&Math.abs(e.south-t.south)<=n&&Math.abs(e.east-t.east)<=n&&Math.abs(e.north-t.north)<=n},he.prototype.clone=function(e){return he.clone(this,e)},he.prototype.equals=function(e){return he.equals(this,e)},he.equals=function(e,t){return e===t||h(e)&&h(t)&&e.west===t.west&&e.south===t.south&&e.east===t.east&&e.north===t.north},he.prototype.equalsEpsilon=function(e,t){return he.equalsEpsilon(this,e,t)},he.validate=function(e){d.typeOf.object("rectangle",e);const t=e.north;d.typeOf.number.greaterThanOrEquals("north",t,-P.PI_OVER_TWO),d.typeOf.number.lessThanOrEquals("north",t,P.PI_OVER_TWO);const n=e.south;d.typeOf.number.greaterThanOrEquals("south",n,-P.PI_OVER_TWO),d.typeOf.number.lessThanOrEquals("south",n,P.PI_OVER_TWO);const i=e.west;d.typeOf.number.greaterThanOrEquals("west",i,-Math.PI),d.typeOf.number.lessThanOrEquals("west",i,Math.PI);const o=e.east;d.typeOf.number.greaterThanOrEquals("east",o,-Math.PI),d.typeOf.number.lessThanOrEquals("east",o,Math.PI)},he.southwest=function(e,t){return d.typeOf.object("rectangle",e),h(t)?(t.longitude=e.west,t.latitude=e.south,t.height=0,t):new J(e.west,e.south)},he.northwest=function(e,t){return d.typeOf.object("rectangle",e),h(t)?(t.longitude=e.west,t.latitude=e.north,t.height=0,t):new J(e.west,e.north)},he.northeast=function(e,t){return d.typeOf.object("rectangle",e),h(t)?(t.longitude=e.east,t.latitude=e.north,t.height=0,t):new J(e.east,e.north)},he.southeast=function(e,t){return d.typeOf.object("rectangle",e),h(t)?(t.longitude=e.east,t.latitude=e.south,t.height=0,t):new J(e.east,e.south)},he.center=function(e,t){d.typeOf.object("rectangle",e);let n=e.east;const i=e.west;n0?i+=P.TWO_PI:r0&&(r+=P.TWO_PI),i=f))return h(n)?(n.west=a,n.south=u,n.east=c,n.north=f,n):new he(a,u,c,f)},he.simpleIntersection=function(e,t,n){d.typeOf.object("rectangle",e),d.typeOf.object("otherRectangle",t);const i=Math.max(e.west,t.west),o=Math.max(e.south,t.south),r=Math.min(e.east,t.east),s=Math.min(e.north,t.north);if(!(o>=s||i>=r))return h(n)?(n.west=i,n.south=o,n.east=r,n.north=s,n):new he(i,o,r,s)},he.union=function(e,t,n){d.typeOf.object("rectangle",e),d.typeOf.object("otherRectangle",t),h(n)||(n=new he);let i=e.east,o=e.west,r=t.east,s=t.west;i0?i+=P.TWO_PI:r0&&(r+=P.TWO_PI),io||P.equalsEpsilon(n,o,P.EPSILON14))&&(n=e.south&&i<=e.north};const A_=new J;he.subsample=function(e,t,n,i){d.typeOf.object("rectangle",e),t=m(t,pe.WGS84),n=m(n,0),h(i)||(i=[]);let o=0;const r=e.north,s=e.south,a=e.east,c=e.west,u=A_;u.height=n,u.longitude=c,u.latitude=r,i[o]=t.cartographicToCartesian(u,i[o]),o++,u.longitude=a,i[o]=t.cartographicToCartesian(u,i[o]),o++,u.latitude=s,i[o]=t.cartographicToCartesian(u,i[o]),o++,u.longitude=c,i[o]=t.cartographicToCartesian(u,i[o]),o++,r<0?u.latitude=r:s>0?u.latitude=s:u.latitude=0;for(let f=1;f<8;++f)u.longitude=-Math.PI+f*P.PI_OVER_TWO,he.contains(e,u)&&(i[o]=t.cartographicToCartesian(u,i[o]),o++);return u.latitude===0&&(u.longitude=c,i[o]=t.cartographicToCartesian(u,i[o]),o++,u.longitude=a,i[o]=t.cartographicToCartesian(u,i[o]),o++),i.length=o,i},he.subsection=function(e,t,n,i,o,r){if(d.typeOf.object("rectangle",e),d.typeOf.number.greaterThanOrEquals("westLerp",t,0),d.typeOf.number.lessThanOrEquals("westLerp",t,1),d.typeOf.number.greaterThanOrEquals("southLerp",n,0),d.typeOf.number.lessThanOrEquals("southLerp",n,1),d.typeOf.number.greaterThanOrEquals("eastLerp",i,0),d.typeOf.number.lessThanOrEquals("eastLerp",i,1),d.typeOf.number.greaterThanOrEquals("northLerp",o,0),d.typeOf.number.lessThanOrEquals("northLerp",o,1),d.typeOf.number.lessThanOrEquals("westLerp",t,i),d.typeOf.number.lessThanOrEquals("southLerp",n,o),h(r)||(r=new he),e.west<=e.east){const a=e.east-e.west;r.west=e.west+t*a,r.east=e.west+i*a}else{const a=P.TWO_PI+e.east-e.west;r.west=P.negativePiToPi(e.west+t*a),r.east=P.negativePiToPi(e.west+i*a)}const s=e.north-e.south;return r.south=e.south+n*s,r.north=e.south+o*s,t===1&&(r.west=e.east),i===1&&(r.east=e.east),n===1&&(r.south=e.north),o===1&&(r.north=e.north),r},he.MAX_VALUE=Object.freeze(new he(-Math.PI,-P.PI_OVER_TWO,Math.PI,P.PI_OVER_TWO));function je(e,t,n,i){this.x=m(e,0),this.y=m(t,0),this.width=m(n,0),this.height=m(i,0)}je.packedLength=4,je.pack=function(e,t,n){return d.typeOf.object("value",e),d.defined("array",t),n=m(n,0),t[n++]=e.x,t[n++]=e.y,t[n++]=e.width,t[n]=e.height,t},je.unpack=function(e,t,n){return d.defined("array",e),t=m(t,0),h(n)||(n=new je),n.x=e[t++],n.y=e[t++],n.width=e[t++],n.height=e[t],n},je.fromPoints=function(e,t){if(h(t)||(t=new je),!h(e)||e.length===0)return t.x=0,t.y=0,t.width=0,t.height=0,t;const n=e.length;let i=e[0].x,o=e[0].y,r=e[0].x,s=e[0].y;for(let a=1;an.width?n.width=i:i<0&&(n.width-=i,n.x=t.x),o>n.height?n.height=o:o<0&&(n.height-=o,n.y=t.y),n},je.intersect=function(e,t){d.typeOf.object("left",e),d.typeOf.object("right",t);const n=e.x,i=e.y,o=t.x,r=t.y;return n>o+t.width||n+e.widthr+t.height?nn.OUTSIDE:nn.INTERSECTING},je.equals=function(e,t){return e===t||h(e)&&h(t)&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height},je.prototype.clone=function(e){return je.clone(this,e)},je.prototype.intersect=function(e){return je.intersect(this,e)},je.prototype.equals=function(e){return je.equals(this,e)};let ui;const ot={requestFullscreen:void 0,exitFullscreen:void 0,fullscreenEnabled:void 0,fullscreenElement:void 0,fullscreenchange:void 0,fullscreenerror:void 0},$t={};Object.defineProperties($t,{element:{get:function(){if($t.supportsFullscreen())return document[ot.fullscreenElement]}},changeEventName:{get:function(){if($t.supportsFullscreen())return ot.fullscreenchange}},errorEventName:{get:function(){if($t.supportsFullscreen())return ot.fullscreenerror}},enabled:{get:function(){if($t.supportsFullscreen())return document[ot.fullscreenEnabled]}},fullscreen:{get:function(){if($t.supportsFullscreen())return $t.element!==null}}}),$t.supportsFullscreen=function(){if(h(ui))return ui;ui=!1;const e=document.body;if(typeof e.requestFullscreen=="function")return ot.requestFullscreen="requestFullscreen",ot.exitFullscreen="exitFullscreen",ot.fullscreenEnabled="fullscreenEnabled",ot.fullscreenElement="fullscreenElement",ot.fullscreenchange="fullscreenchange",ot.fullscreenerror="fullscreenerror",ui=!0,ui;const t=["webkit","moz","o","ms","khtml"];let n;for(let i=0,o=t.length;i{const t=new Image;t.onload=function(){Dt._result=t.width>0&&t.height>0,e(Dt._result)},t.onerror=function(){Dt._result=!1,e(Dt._result)},t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA"})),Dt._promise},Object.defineProperties(Dt,{initialized:{get:function(){return h(Dt._result)}}});const oo=[];typeof ArrayBuffer<"u"&&(oo.push(Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array),typeof Uint8ClampedArray<"u"&&oo.push(Uint8ClampedArray),typeof Uint8ClampedArray<"u"&&oo.push(Uint8ClampedArray),typeof BigInt64Array<"u"&&oo.push(BigInt64Array),typeof BigUint64Array<"u"&&oo.push(BigUint64Array));const yn={isChrome:ma,chromeVersion:I_,isSafari:ah,safariVersion:z_,isWebkit:ch,webkitVersion:D_,isInternetExplorer:lh,internetExplorerVersion:M_,isEdge:Qr,edgeVersion:N_,isFirefox:ya,firefoxVersion:B_,isWindows:L_,isIPadOrIOS:F_,hardwareConcurrency:m(zt.hardwareConcurrency,3),supportsPointerEvents:U_,supportsImageRenderingPixelated:dh,supportsWebP:Dt,imageRenderingValue:k_,typedArrayTypes:oo};yn.supportsBasis=function(e){return yn.supportsWebAssembly()&&e.context.supportsBasis},yn.supportsFullscreen=function(){return R_.supportsFullscreen()},yn.supportsTypedArrays=function(){return typeof ArrayBuffer<"u"},yn.supportsBigInt64Array=function(){return typeof BigInt64Array<"u"},yn.supportsBigUint64Array=function(){return typeof BigUint64Array<"u"},yn.supportsBigInt=function(){return typeof BigInt<"u"},yn.supportsWebWorkers=function(){return typeof Worker<"u"},yn.supportsWebAssembly=function(){return typeof WebAssembly<"u"},yn.supportsWebgl2=function(e){return d.defined("scene",e),e.context.webgl2};const wn=yn;function Ea(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n*6<1?e+(t-e)*6*n:n*2<1?t:n*3<2?e+(t-e)*(2/3-n)*6:e}function S(e,t,n,i){this.red=m(e,1),this.green=m(t,1),this.blue=m(n,1),this.alpha=m(i,1)}S.fromCartesian4=function(e,t){return d.typeOf.object("cartesian",e),h(t)?(t.red=e.x,t.green=e.y,t.blue=e.z,t.alpha=e.w,t):new S(e.x,e.y,e.z,e.w)},S.fromBytes=function(e,t,n,i,o){return e=S.byteToFloat(m(e,255)),t=S.byteToFloat(m(t,255)),n=S.byteToFloat(m(n,255)),i=S.byteToFloat(m(i,255)),h(o)?(o.red=e,o.green=t,o.blue=n,o.alpha=i,o):new S(e,t,n,i)},S.fromAlpha=function(e,t,n){return d.typeOf.object("color",e),d.typeOf.number("alpha",t),h(n)?(n.red=e.red,n.green=e.green,n.blue=e.blue,n.alpha=t,n):new S(e.red,e.green,e.blue,t)};let Ca,Sa,kn;wn.supportsTypedArrays()&&(Ca=new ArrayBuffer(4),Sa=new Uint32Array(Ca),kn=new Uint8Array(Ca)),S.fromRgba=function(e,t){return Sa[0]=e,S.fromBytes(kn[0],kn[1],kn[2],kn[3],t)},S.fromHsl=function(e,t,n,i,o){e=m(e,0)%1,t=m(t,0),n=m(n,0),i=m(i,1);let r=n,s=n,a=n;if(t!==0){let c;n<.5?c=n*(1+t):c=n+t-n*t;const u=2*n-c;r=Ea(u,c,e+1/3),s=Ea(u,c,e),a=Ea(u,c,e-1/3)}return h(o)?(o.red=r,o.green=s,o.blue=a,o.alpha=i,o):new S(r,s,a,i)},S.fromRandom=function(e,t){e=m(e,m.EMPTY_OBJECT);let n=e.red;if(!h(n)){const s=m(e.minimumRed,0),a=m(e.maximumRed,1);d.typeOf.number.lessThanOrEquals("minimumRed",s,a),n=s+P.nextRandomNumber()*(a-s)}let i=e.green;if(!h(i)){const s=m(e.minimumGreen,0),a=m(e.maximumGreen,1);d.typeOf.number.lessThanOrEquals("minimumGreen",s,a),i=s+P.nextRandomNumber()*(a-s)}let o=e.blue;if(!h(o)){const s=m(e.minimumBlue,0),a=m(e.maximumBlue,1);d.typeOf.number.lessThanOrEquals("minimumBlue",s,a),o=s+P.nextRandomNumber()*(a-s)}let r=e.alpha;if(!h(r)){const s=m(e.minimumAlpha,0),a=m(e.maximumAlpha,1);d.typeOf.number.lessThanOrEquals("minumumAlpha",s,a),r=s+P.nextRandomNumber()*(a-s)}return h(t)?(t.red=n,t.green=i,t.blue=o,t.alpha=r,t):new S(n,i,o,r)};const j_=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i,G_=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i,V_=/^rgba?\s*\(\s*([0-9.]+%?)\s*[,\s]+\s*([0-9.]+%?)\s*[,\s]+\s*([0-9.]+%?)(?:\s*[,\s/]+\s*([0-9.]+))?\s*\)$/i,H_=/^hsla?\s*\(\s*([0-9.]+)\s*[,\s]+\s*([0-9.]+%)\s*[,\s]+\s*([0-9.]+%)(?:\s*[,\s/]+\s*([0-9.]+))?\s*\)$/i;S.fromCssColorString=function(e,t){d.typeOf.string("color",e),h(t)||(t=new S),e=e.trim();const n=S[e.toUpperCase()];if(h(n))return S.clone(n,t),t;let i=j_.exec(e);return i!==null?(t.red=parseInt(i[1],16)/15,t.green=parseInt(i[2],16)/15,t.blue=parseInt(i[3],16)/15,t.alpha=parseInt(m(i[4],"f"),16)/15,t):(i=G_.exec(e),i!==null?(t.red=parseInt(i[1],16)/255,t.green=parseInt(i[2],16)/255,t.blue=parseInt(i[3],16)/255,t.alpha=parseInt(m(i[4],"ff"),16)/255,t):(i=V_.exec(e),i!==null?(t.red=parseFloat(i[1])/(i[1].substr(-1)==="%"?100:255),t.green=parseFloat(i[2])/(i[2].substr(-1)==="%"?100:255),t.blue=parseFloat(i[3])/(i[3].substr(-1)==="%"?100:255),t.alpha=parseFloat(m(i[4],"1.0")),t):(i=H_.exec(e),i!==null?S.fromHsl(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,parseFloat(m(i[4],"1.0")),t):(t=void 0,t))))},S.packedLength=4,S.pack=function(e,t,n){return d.typeOf.object("value",e),d.defined("array",t),n=m(n,0),t[n++]=e.red,t[n++]=e.green,t[n++]=e.blue,t[n]=e.alpha,t},S.unpack=function(e,t,n){return d.defined("array",e),t=m(t,0),h(n)||(n=new S),n.red=e[t++],n.green=e[t++],n.blue=e[t++],n.alpha=e[t],n},S.byteToFloat=function(e){return e/255},S.floatToByte=function(e){return e===1?255:e*256|0},S.clone=function(e,t){if(h(e))return h(t)?(t.red=e.red,t.green=e.green,t.blue=e.blue,t.alpha=e.alpha,t):new S(e.red,e.green,e.blue,e.alpha)},S.equals=function(e,t){return e===t||h(e)&&h(t)&&e.red===t.red&&e.green===t.green&&e.blue===t.blue&&e.alpha===t.alpha},S.equalsArray=function(e,t,n){return e.red===t[n]&&e.green===t[n+1]&&e.blue===t[n+2]&&e.alpha===t[n+3]},S.prototype.clone=function(e){return S.clone(this,e)},S.prototype.equals=function(e){return S.equals(this,e)},S.prototype.equalsEpsilon=function(e,t){return this===e||h(e)&&Math.abs(this.red-e.red)<=t&&Math.abs(this.green-e.green)<=t&&Math.abs(this.blue-e.blue)<=t&&Math.abs(this.alpha-e.alpha)<=t},S.prototype.toString=function(){return`(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`},S.prototype.toCssColorString=function(){const e=S.floatToByte(this.red),t=S.floatToByte(this.green),n=S.floatToByte(this.blue);return this.alpha===1?`rgb(${e},${t},${n})`:`rgba(${e},${t},${n},${this.alpha})`},S.prototype.toCssHexString=function(){let e=S.floatToByte(this.red).toString(16);e.length<2&&(e=`0${e}`);let t=S.floatToByte(this.green).toString(16);t.length<2&&(t=`0${t}`);let n=S.floatToByte(this.blue).toString(16);if(n.length<2&&(n=`0${n}`),this.alpha<1){let i=S.floatToByte(this.alpha).toString(16);return i.length<2&&(i=`0${i}`),`#${e}${t}${n}${i}`}return`#${e}${t}${n}`},S.prototype.toBytes=function(e){const t=S.floatToByte(this.red),n=S.floatToByte(this.green),i=S.floatToByte(this.blue),o=S.floatToByte(this.alpha);return h(e)?(e[0]=t,e[1]=n,e[2]=i,e[3]=o,e):[t,n,i,o]},S.prototype.toRgba=function(){return kn[0]=S.floatToByte(this.red),kn[1]=S.floatToByte(this.green),kn[2]=S.floatToByte(this.blue),kn[3]=S.floatToByte(this.alpha),Sa[0]},S.prototype.brighten=function(e,t){return d.typeOf.number("magnitude",e),d.typeOf.number.greaterThanOrEquals("magnitude",e,0),d.typeOf.object("result",t),e=1-e,t.red=1-(1-this.red)*e,t.green=1-(1-this.green)*e,t.blue=1-(1-this.blue)*e,t.alpha=this.alpha,t},S.prototype.darken=function(e,t){return d.typeOf.number("magnitude",e),d.typeOf.number.greaterThanOrEquals("magnitude",e,0),d.typeOf.object("result",t),e=1-e,t.red=this.red*e,t.green=this.green*e,t.blue=this.blue*e,t.alpha=this.alpha,t},S.prototype.withAlpha=function(e,t){return S.fromAlpha(this,e,t)},S.add=function(e,t,n){return d.typeOf.object("left",e),d.typeOf.object("right",t),d.typeOf.object("result",n),n.red=e.red+t.red,n.green=e.green+t.green,n.blue=e.blue+t.blue,n.alpha=e.alpha+t.alpha,n},S.subtract=function(e,t,n){return d.typeOf.object("left",e),d.typeOf.object("right",t),d.typeOf.object("result",n),n.red=e.red-t.red,n.green=e.green-t.green,n.blue=e.blue-t.blue,n.alpha=e.alpha-t.alpha,n},S.multiply=function(e,t,n){return d.typeOf.object("left",e),d.typeOf.object("right",t),d.typeOf.object("result",n),n.red=e.red*t.red,n.green=e.green*t.green,n.blue=e.blue*t.blue,n.alpha=e.alpha*t.alpha,n},S.divide=function(e,t,n){return d.typeOf.object("left",e),d.typeOf.object("right",t),d.typeOf.object("result",n),n.red=e.red/t.red,n.green=e.green/t.green,n.blue=e.blue/t.blue,n.alpha=e.alpha/t.alpha,n},S.mod=function(e,t,n){return d.typeOf.object("left",e),d.typeOf.object("right",t),d.typeOf.object("result",n),n.red=e.red%t.red,n.green=e.green%t.green,n.blue=e.blue%t.blue,n.alpha=e.alpha%t.alpha,n},S.lerp=function(e,t,n,i){return d.typeOf.object("start",e),d.typeOf.object("end",t),d.typeOf.number("t",n),d.typeOf.object("result",i),i.red=P.lerp(e.red,t.red,n),i.green=P.lerp(e.green,t.green,n),i.blue=P.lerp(e.blue,t.blue,n),i.alpha=P.lerp(e.alpha,t.alpha,n),i},S.multiplyByScalar=function(e,t,n){return d.typeOf.object("color",e),d.typeOf.number("scalar",t),d.typeOf.object("result",n),n.red=e.red*t,n.green=e.green*t,n.blue=e.blue*t,n.alpha=e.alpha*t,n},S.divideByScalar=function(e,t,n){return d.typeOf.object("color",e),d.typeOf.number("scalar",t),d.typeOf.object("result",n),n.red=e.red/t,n.green=e.green/t,n.blue=e.blue/t,n.alpha=e.alpha/t,n},S.ALICEBLUE=Object.freeze(S.fromCssColorString("#F0F8FF")),S.ANTIQUEWHITE=Object.freeze(S.fromCssColorString("#FAEBD7")),S.AQUA=Object.freeze(S.fromCssColorString("#00FFFF")),S.AQUAMARINE=Object.freeze(S.fromCssColorString("#7FFFD4")),S.AZURE=Object.freeze(S.fromCssColorString("#F0FFFF")),S.BEIGE=Object.freeze(S.fromCssColorString("#F5F5DC")),S.BISQUE=Object.freeze(S.fromCssColorString("#FFE4C4")),S.BLACK=Object.freeze(S.fromCssColorString("#000000")),S.BLANCHEDALMOND=Object.freeze(S.fromCssColorString("#FFEBCD")),S.BLUE=Object.freeze(S.fromCssColorString("#0000FF")),S.BLUEVIOLET=Object.freeze(S.fromCssColorString("#8A2BE2")),S.BROWN=Object.freeze(S.fromCssColorString("#A52A2A")),S.BURLYWOOD=Object.freeze(S.fromCssColorString("#DEB887")),S.CADETBLUE=Object.freeze(S.fromCssColorString("#5F9EA0")),S.CHARTREUSE=Object.freeze(S.fromCssColorString("#7FFF00")),S.CHOCOLATE=Object.freeze(S.fromCssColorString("#D2691E")),S.CORAL=Object.freeze(S.fromCssColorString("#FF7F50")),S.CORNFLOWERBLUE=Object.freeze(S.fromCssColorString("#6495ED")),S.CORNSILK=Object.freeze(S.fromCssColorString("#FFF8DC")),S.CRIMSON=Object.freeze(S.fromCssColorString("#DC143C")),S.CYAN=Object.freeze(S.fromCssColorString("#00FFFF")),S.DARKBLUE=Object.freeze(S.fromCssColorString("#00008B")),S.DARKCYAN=Object.freeze(S.fromCssColorString("#008B8B")),S.DARKGOLDENROD=Object.freeze(S.fromCssColorString("#B8860B")),S.DARKGRAY=Object.freeze(S.fromCssColorString("#A9A9A9")),S.DARKGREEN=Object.freeze(S.fromCssColorString("#006400")),S.DARKGREY=S.DARKGRAY,S.DARKKHAKI=Object.freeze(S.fromCssColorString("#BDB76B")),S.DARKMAGENTA=Object.freeze(S.fromCssColorString("#8B008B")),S.DARKOLIVEGREEN=Object.freeze(S.fromCssColorString("#556B2F")),S.DARKORANGE=Object.freeze(S.fromCssColorString("#FF8C00")),S.DARKORCHID=Object.freeze(S.fromCssColorString("#9932CC")),S.DARKRED=Object.freeze(S.fromCssColorString("#8B0000")),S.DARKSALMON=Object.freeze(S.fromCssColorString("#E9967A")),S.DARKSEAGREEN=Object.freeze(S.fromCssColorString("#8FBC8F")),S.DARKSLATEBLUE=Object.freeze(S.fromCssColorString("#483D8B")),S.DARKSLATEGRAY=Object.freeze(S.fromCssColorString("#2F4F4F")),S.DARKSLATEGREY=S.DARKSLATEGRAY,S.DARKTURQUOISE=Object.freeze(S.fromCssColorString("#00CED1")),S.DARKVIOLET=Object.freeze(S.fromCssColorString("#9400D3")),S.DEEPPINK=Object.freeze(S.fromCssColorString("#FF1493")),S.DEEPSKYBLUE=Object.freeze(S.fromCssColorString("#00BFFF")),S.DIMGRAY=Object.freeze(S.fromCssColorString("#696969")),S.DIMGREY=S.DIMGRAY,S.DODGERBLUE=Object.freeze(S.fromCssColorString("#1E90FF")),S.FIREBRICK=Object.freeze(S.fromCssColorString("#B22222")),S.FLORALWHITE=Object.freeze(S.fromCssColorString("#FFFAF0")),S.FORESTGREEN=Object.freeze(S.fromCssColorString("#228B22")),S.FUCHSIA=Object.freeze(S.fromCssColorString("#FF00FF")),S.GAINSBORO=Object.freeze(S.fromCssColorString("#DCDCDC")),S.GHOSTWHITE=Object.freeze(S.fromCssColorString("#F8F8FF")),S.GOLD=Object.freeze(S.fromCssColorString("#FFD700")),S.GOLDENROD=Object.freeze(S.fromCssColorString("#DAA520")),S.GRAY=Object.freeze(S.fromCssColorString("#808080")),S.GREEN=Object.freeze(S.fromCssColorString("#008000")),S.GREENYELLOW=Object.freeze(S.fromCssColorString("#ADFF2F")),S.GREY=S.GRAY,S.HONEYDEW=Object.freeze(S.fromCssColorString("#F0FFF0")),S.HOTPINK=Object.freeze(S.fromCssColorString("#FF69B4")),S.INDIANRED=Object.freeze(S.fromCssColorString("#CD5C5C")),S.INDIGO=Object.freeze(S.fromCssColorString("#4B0082")),S.IVORY=Object.freeze(S.fromCssColorString("#FFFFF0")),S.KHAKI=Object.freeze(S.fromCssColorString("#F0E68C")),S.LAVENDER=Object.freeze(S.fromCssColorString("#E6E6FA")),S.LAVENDAR_BLUSH=Object.freeze(S.fromCssColorString("#FFF0F5")),S.LAWNGREEN=Object.freeze(S.fromCssColorString("#7CFC00")),S.LEMONCHIFFON=Object.freeze(S.fromCssColorString("#FFFACD")),S.LIGHTBLUE=Object.freeze(S.fromCssColorString("#ADD8E6")),S.LIGHTCORAL=Object.freeze(S.fromCssColorString("#F08080")),S.LIGHTCYAN=Object.freeze(S.fromCssColorString("#E0FFFF")),S.LIGHTGOLDENRODYELLOW=Object.freeze(S.fromCssColorString("#FAFAD2")),S.LIGHTGRAY=Object.freeze(S.fromCssColorString("#D3D3D3")),S.LIGHTGREEN=Object.freeze(S.fromCssColorString("#90EE90")),S.LIGHTGREY=S.LIGHTGRAY,S.LIGHTPINK=Object.freeze(S.fromCssColorString("#FFB6C1")),S.LIGHTSEAGREEN=Object.freeze(S.fromCssColorString("#20B2AA")),S.LIGHTSKYBLUE=Object.freeze(S.fromCssColorString("#87CEFA")),S.LIGHTSLATEGRAY=Object.freeze(S.fromCssColorString("#778899")),S.LIGHTSLATEGREY=S.LIGHTSLATEGRAY,S.LIGHTSTEELBLUE=Object.freeze(S.fromCssColorString("#B0C4DE")),S.LIGHTYELLOW=Object.freeze(S.fromCssColorString("#FFFFE0")),S.LIME=Object.freeze(S.fromCssColorString("#00FF00")),S.LIMEGREEN=Object.freeze(S.fromCssColorString("#32CD32")),S.LINEN=Object.freeze(S.fromCssColorString("#FAF0E6")),S.MAGENTA=Object.freeze(S.fromCssColorString("#FF00FF")),S.MAROON=Object.freeze(S.fromCssColorString("#800000")),S.MEDIUMAQUAMARINE=Object.freeze(S.fromCssColorString("#66CDAA")),S.MEDIUMBLUE=Object.freeze(S.fromCssColorString("#0000CD")),S.MEDIUMORCHID=Object.freeze(S.fromCssColorString("#BA55D3")),S.MEDIUMPURPLE=Object.freeze(S.fromCssColorString("#9370DB")),S.MEDIUMSEAGREEN=Object.freeze(S.fromCssColorString("#3CB371")),S.MEDIUMSLATEBLUE=Object.freeze(S.fromCssColorString("#7B68EE")),S.MEDIUMSPRINGGREEN=Object.freeze(S.fromCssColorString("#00FA9A")),S.MEDIUMTURQUOISE=Object.freeze(S.fromCssColorString("#48D1CC")),S.MEDIUMVIOLETRED=Object.freeze(S.fromCssColorString("#C71585")),S.MIDNIGHTBLUE=Object.freeze(S.fromCssColorString("#191970")),S.MINTCREAM=Object.freeze(S.fromCssColorString("#F5FFFA")),S.MISTYROSE=Object.freeze(S.fromCssColorString("#FFE4E1")),S.MOCCASIN=Object.freeze(S.fromCssColorString("#FFE4B5")),S.NAVAJOWHITE=Object.freeze(S.fromCssColorString("#FFDEAD")),S.NAVY=Object.freeze(S.fromCssColorString("#000080")),S.OLDLACE=Object.freeze(S.fromCssColorString("#FDF5E6")),S.OLIVE=Object.freeze(S.fromCssColorString("#808000")),S.OLIVEDRAB=Object.freeze(S.fromCssColorString("#6B8E23")),S.ORANGE=Object.freeze(S.fromCssColorString("#FFA500")),S.ORANGERED=Object.freeze(S.fromCssColorString("#FF4500")),S.ORCHID=Object.freeze(S.fromCssColorString("#DA70D6")),S.PALEGOLDENROD=Object.freeze(S.fromCssColorString("#EEE8AA")),S.PALEGREEN=Object.freeze(S.fromCssColorString("#98FB98")),S.PALETURQUOISE=Object.freeze(S.fromCssColorString("#AFEEEE")),S.PALEVIOLETRED=Object.freeze(S.fromCssColorString("#DB7093")),S.PAPAYAWHIP=Object.freeze(S.fromCssColorString("#FFEFD5")),S.PEACHPUFF=Object.freeze(S.fromCssColorString("#FFDAB9")),S.PERU=Object.freeze(S.fromCssColorString("#CD853F")),S.PINK=Object.freeze(S.fromCssColorString("#FFC0CB")),S.PLUM=Object.freeze(S.fromCssColorString("#DDA0DD")),S.POWDERBLUE=Object.freeze(S.fromCssColorString("#B0E0E6")),S.PURPLE=Object.freeze(S.fromCssColorString("#800080")),S.RED=Object.freeze(S.fromCssColorString("#FF0000")),S.ROSYBROWN=Object.freeze(S.fromCssColorString("#BC8F8F")),S.ROYALBLUE=Object.freeze(S.fromCssColorString("#4169E1")),S.SADDLEBROWN=Object.freeze(S.fromCssColorString("#8B4513")),S.SALMON=Object.freeze(S.fromCssColorString("#FA8072")),S.SANDYBROWN=Object.freeze(S.fromCssColorString("#F4A460")),S.SEAGREEN=Object.freeze(S.fromCssColorString("#2E8B57")),S.SEASHELL=Object.freeze(S.fromCssColorString("#FFF5EE")),S.SIENNA=Object.freeze(S.fromCssColorString("#A0522D")),S.SILVER=Object.freeze(S.fromCssColorString("#C0C0C0")),S.SKYBLUE=Object.freeze(S.fromCssColorString("#87CEEB")),S.SLATEBLUE=Object.freeze(S.fromCssColorString("#6A5ACD")),S.SLATEGRAY=Object.freeze(S.fromCssColorString("#708090")),S.SLATEGREY=S.SLATEGRAY,S.SNOW=Object.freeze(S.fromCssColorString("#FFFAFA")),S.SPRINGGREEN=Object.freeze(S.fromCssColorString("#00FF7F")),S.STEELBLUE=Object.freeze(S.fromCssColorString("#4682B4")),S.TAN=Object.freeze(S.fromCssColorString("#D2B48C")),S.TEAL=Object.freeze(S.fromCssColorString("#008080")),S.THISTLE=Object.freeze(S.fromCssColorString("#D8BFD8")),S.TOMATO=Object.freeze(S.fromCssColorString("#FF6347")),S.TURQUOISE=Object.freeze(S.fromCssColorString("#40E0D0")),S.VIOLET=Object.freeze(S.fromCssColorString("#EE82EE")),S.WHEAT=Object.freeze(S.fromCssColorString("#F5DEB3")),S.WHITE=Object.freeze(S.fromCssColorString("#FFFFFF")),S.WHITESMOKE=Object.freeze(S.fromCssColorString("#F5F5F5")),S.YELLOW=Object.freeze(S.fromCssColorString("#FFFF00")),S.YELLOWGREEN=Object.freeze(S.fromCssColorString("#9ACD32")),S.TRANSPARENT=Object.freeze(new S(0,0,0,0));function q_(){return!0}function gt(e,t){t=m(t,"This object was destroyed, i.e., destroy() was called.");function n(){throw new T(t)}for(const i in e)typeof e[i]=="function"&&(e[i]=n);e.isDestroyed=q_}const Vo=Object.freeze({NONE:0,CLAMP_TO_GROUND:1,RELATIVE_TO_GROUND:2});function fe(){T.throwInstantiationError()}Object.defineProperties(fe.prototype,{isConstant:{get:T.throwInstantiationError},definitionChanged:{get:T.throwInstantiationError}}),fe.prototype.getValue=T.throwInstantiationError,fe.prototype.equals=T.throwInstantiationError,fe.equals=function(e,t){return e===t||h(e)&&e.equals(t)},fe.arrayEquals=function(e,t){if(e===t)return!0;if(!h(e)||!h(t)||e.length!==t.length)return!1;const n=e.length;for(let i=0;ii&&(o=u,i=f)}let r=1,s=0;const a=Aa[o],c=va[o];if(Math.abs(e[M.getElementIndex(c,a)])>n){const u=e[M.getElementIndex(c,c)],f=e[M.getElementIndex(a,a)],p=e[M.getElementIndex(c,a)],_=(u-f)/2/p;let g;_<0?g=-1/(-_+Math.sqrt(1+_*_)):g=1/(_+Math.sqrt(1+_*_)),r=1/Math.sqrt(1+g*g),s=g*r}return t=M.clone(M.IDENTITY,t),t[M.getElementIndex(a,a)]=t[M.getElementIndex(c,c)]=r,t[M.getElementIndex(c,a)]=s,t[M.getElementIndex(a,c)]=-s,t}const ts=new M,mh=new M;M.computeEigenDecomposition=function(e,t){d.typeOf.object("matrix",e);const n=P.EPSILON20,i=10;let o=0,r=0;h(t)||(t={});const s=t.unitary=M.clone(M.IDENTITY,t.unitary),a=t.diagonal=M.clone(e,t.diagonal),c=n*K_(a);for(;rc;)Q_(a,ts),M.transpose(ts,mh),M.multiply(a,ts,a),M.multiply(mh,a,a),M.multiply(s,ts,s),++o>2&&(++r,o=0);return t},M.abs=function(e,t){return d.typeOf.object("matrix",e),d.typeOf.object("result",t),t[0]=Math.abs(e[0]),t[1]=Math.abs(e[1]),t[2]=Math.abs(e[2]),t[3]=Math.abs(e[3]),t[4]=Math.abs(e[4]),t[5]=Math.abs(e[5]),t[6]=Math.abs(e[6]),t[7]=Math.abs(e[7]),t[8]=Math.abs(e[8]),t},M.determinant=function(e){d.typeOf.object("matrix",e);const t=e[0],n=e[3],i=e[6],o=e[1],r=e[4],s=e[7],a=e[2],c=e[5],u=e[8];return t*(r*u-c*s)+o*(c*i-n*u)+a*(n*s-r*i)},M.inverse=function(e,t){d.typeOf.object("matrix",e),d.typeOf.object("result",t);const n=e[0],i=e[1],o=e[2],r=e[3],s=e[4],a=e[5],c=e[6],u=e[7],f=e[8],p=M.determinant(e);if(Math.abs(p)<=P.EPSILON15)throw new T("matrix is not invertible");t[0]=s*f-u*a,t[1]=u*o-i*f,t[2]=i*a-s*o,t[3]=c*a-r*f,t[4]=n*f-c*o,t[5]=r*o-n*a,t[6]=r*u-c*s,t[7]=c*i-n*u,t[8]=n*s-r*i;const _=1/p;return M.multiplyByScalar(t,_,t)};const J_=new M;M.inverseTranspose=function(e,t){return d.typeOf.object("matrix",e),d.typeOf.object("result",t),M.inverse(M.transpose(e,J_),t)},M.equals=function(e,t){return e===t||h(e)&&h(t)&&e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]},M.equalsEpsilon=function(e,t,n){return n=m(n,0),e===t||h(e)&&h(t)&&Math.abs(e[0]-t[0])<=n&&Math.abs(e[1]-t[1])<=n&&Math.abs(e[2]-t[2])<=n&&Math.abs(e[3]-t[3])<=n&&Math.abs(e[4]-t[4])<=n&&Math.abs(e[5]-t[5])<=n&&Math.abs(e[6]-t[6])<=n&&Math.abs(e[7]-t[7])<=n&&Math.abs(e[8]-t[8])<=n},M.IDENTITY=Object.freeze(new M(1,0,0,0,1,0,0,0,1)),M.ZERO=Object.freeze(new M(0,0,0,0,0,0,0,0,0)),M.COLUMN0ROW0=0,M.COLUMN0ROW1=1,M.COLUMN0ROW2=2,M.COLUMN1ROW0=3,M.COLUMN1ROW1=4,M.COLUMN1ROW2=5,M.COLUMN2ROW0=6,M.COLUMN2ROW1=7,M.COLUMN2ROW2=8,Object.defineProperties(M.prototype,{length:{get:function(){return M.packedLength}}}),M.prototype.clone=function(e){return M.clone(this,e)},M.prototype.equals=function(e){return M.equals(this,e)},M.equalsArray=function(e,t,n){return e[0]===t[n]&&e[1]===t[n+1]&&e[2]===t[n+2]&&e[3]===t[n+3]&&e[4]===t[n+4]&&e[5]===t[n+5]&&e[6]===t[n+6]&&e[7]===t[n+7]&&e[8]===t[n+8]},M.prototype.equalsEpsilon=function(e,t){return M.equalsEpsilon(this,e,t)},M.prototype.toString=function(){return`(${this[0]}, ${this[3]}, ${this[6]}) (${this[1]}, ${this[4]}, ${this[7]}) (${this[2]}, ${this[5]}, ${this[8]})`};function q(e,t,n,i){this.x=m(e,0),this.y=m(t,0),this.z=m(n,0),this.w=m(i,0)}q.fromElements=function(e,t,n,i,o){return h(o)?(o.x=e,o.y=t,o.z=n,o.w=i,o):new q(e,t,n,i)},q.fromColor=function(e,t){return d.typeOf.object("color",e),h(t)?(t.x=e.red,t.y=e.green,t.z=e.blue,t.w=e.alpha,t):new q(e.red,e.green,e.blue,e.alpha)},q.clone=function(e,t){if(h(e))return h(t)?(t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t):new q(e.x,e.y,e.z,e.w)},q.packedLength=4,q.pack=function(e,t,n){return d.typeOf.object("value",e),d.defined("array",t),n=m(n,0),t[n++]=e.x,t[n++]=e.y,t[n++]=e.z,t[n]=e.w,t},q.unpack=function(e,t,n){return d.defined("array",e),t=m(t,0),h(n)||(n=new q),n.x=e[t++],n.y=e[t++],n.z=e[t++],n.w=e[t],n},q.packArray=function(e,t){d.defined("array",e);const n=e.length,i=n*4;if(!h(t))t=new Array(i);else{if(!Array.isArray(t)&&t.length!==i)throw new T("If result is a typed array, it must have exactly array.length * 4 elements");t.length!==i&&(t.length=i)}for(let o=0;os.x&&l.clone(n,s),ja.y&&l.clone(n,a),Bc.z&&l.clone(n,c)}const p=l.magnitudeSquared(l.subtract(s,i,bt)),_=l.magnitudeSquared(l.subtract(a,o,bt)),g=l.magnitudeSquared(l.subtract(c,r,bt));let y=i,b=s,E=p;_>E&&(E=_,y=o,b=a),g>E&&(E=g,y=r,b=c);const O=Fa;O.x=(y.x+b.x)*.5,O.y=(y.y+b.y)*.5,O.z=(y.z+b.z)*.5;let v=l.magnitudeSquared(l.subtract(b,O,bt)),A=Math.sqrt(v);const R=Ba;R.x=i.x,R.y=o.y,R.z=r.z;const z=Ua;z.x=s.x,z.y=a.y,z.z=c.z;const U=l.midpoint(R,z,ka);let G=0;for(f=0;fG&&(G=k);const j=l.magnitudeSquared(l.subtract(n,O,bt));if(j>v){const B=Math.sqrt(j);A=(A+B)*.5,v=A*A;const H=B-A;O.x=(A*O.x+H*n.x)/B,O.y=(A*O.y+H*n.y)/B,O.z=(A*O.z+H*n.z)/B}}return Ac.x&&l.clone(o,c),Hu.y&&l.clone(o,u),Wf.z&&l.clone(o,f)}const g=l.magnitudeSquared(l.subtract(c,r,bt)),y=l.magnitudeSquared(l.subtract(u,s,bt)),b=l.magnitudeSquared(l.subtract(f,a,bt));let E=r,O=c,v=g;y>v&&(v=y,E=s,O=u),b>v&&(v=b,E=a,O=f);const A=Fa;A.x=(E.x+O.x)*.5,A.y=(E.y+O.y)*.5,A.z=(E.z+O.z)*.5;let R=l.magnitudeSquared(l.subtract(O,A,bt)),z=Math.sqrt(R);const U=Ba;U.x=r.x,U.y=s.y,U.z=a.z;const G=Ua;G.x=c.x,G.y=u.y,G.z=f.z;const k=l.midpoint(U,G,ka);let j=0;for(_=0;_j&&(j=B);const H=l.magnitudeSquared(l.subtract(o,A,bt));if(H>R){const W=Math.sqrt(H);z=(z+W)*.5,R=z*z;const w=W-z;A.x=(z*A.x+w*o.x)/W,A.y=(z*A.y+w*o.y)/W,A.z=(z*A.z+w*o.z)/W}}return za.x&&l.clone(i,a),Bc.y&&l.clone(i,c),Hu.z&&l.clone(i,u)}const _=l.magnitudeSquared(l.subtract(a,o,bt)),g=l.magnitudeSquared(l.subtract(c,r,bt)),y=l.magnitudeSquared(l.subtract(u,s,bt));let b=o,E=a,O=_;g>O&&(O=g,b=r,E=c),y>O&&(O=y,b=s,E=u);const v=Fa;v.x=(b.x+E.x)*.5,v.y=(b.y+E.y)*.5,v.z=(b.z+E.z)*.5;let A=l.magnitudeSquared(l.subtract(E,v,bt)),R=Math.sqrt(A);const z=Ba;z.x=o.x,z.y=r.y,z.z=s.z;const U=Ua;U.x=a.x,U.y=c.y,U.z=u.z;const G=l.midpoint(z,U,ka);let k=0;for(p=0;pk&&(k=j);const B=l.magnitudeSquared(l.subtract(i,v,bt));if(B>A){const H=Math.sqrt(B);R=(R+H)*.5,A=R*R;const W=H-R;v.x=(R*v.x+W*i.x)/H,v.y=(R*v.y+W*i.y)/H,v.z=(R*v.z+W*i.z)/H}}return R=c+s)return e.clone(n),n;if(s>=c+o)return t.clone(n),n;const u=(o+c+s)*.5,f=l.multiplyByScalar(a,(-o+u)/c,C0);return l.add(f,i,f),l.clone(f,n.center),n.radius=u,n};const S0=new l;Q.expand=function(e,t,n){d.typeOf.object("sphere",e),d.typeOf.object("point",t),n=Q.clone(e,n);const i=l.magnitude(l.subtract(t,n.center,S0));return i>n.radius&&(n.radius=i),n},Q.intersectPlane=function(e,t){d.typeOf.object("sphere",e),d.typeOf.object("plane",t);const n=e.center,i=e.radius,o=t.normal,r=l.dot(o,n)+t.distance;return r<-i?nn.OUTSIDE:r0)n=Math.sqrt(f+1),s=.5*n,n=.5/n,i=(e[M.COLUMN1ROW2]-e[M.COLUMN2ROW1])*n,o=(e[M.COLUMN2ROW0]-e[M.COLUMN0ROW2])*n,r=(e[M.COLUMN0ROW1]-e[M.COLUMN1ROW0])*n;else{const p=F0;let _=0;c>a&&(_=1),u>a&&u>c&&(_=2);const g=p[_],y=p[g];n=Math.sqrt(e[M.getElementIndex(_,_)]-e[M.getElementIndex(g,g)]-e[M.getElementIndex(y,y)]+1);const b=B0;b[_]=.5*n,n=.5/n,s=(e[M.getElementIndex(y,g)]-e[M.getElementIndex(g,y)])*n,b[g]=(e[M.getElementIndex(g,_)]+e[M.getElementIndex(_,g)])*n,b[y]=(e[M.getElementIndex(y,_)]+e[M.getElementIndex(_,y)])*n,i=-b[0],o=-b[1],r=-b[2]}return h(t)?(t.x=i,t.y=o,t.z=r,t.w=s,t):new K(i,o,r,s)};const Ch=new K;let Sh=new K,Va=new K,Oh=new K;K.fromHeadingPitchRoll=function(e,t){return d.typeOf.object("headingPitchRoll",e),Oh=K.fromAxisAngle(l.UNIT_X,e.roll,Ch),Va=K.fromAxisAngle(l.UNIT_Y,-e.pitch,t),t=K.multiply(Va,Oh,Va),Sh=K.fromAxisAngle(l.UNIT_Z,-e.heading,Ch),K.multiply(Sh,t,t)};const is=new l,Ha=new l,bn=new K,Ah=new K,os=new K;K.packedLength=4,K.pack=function(e,t,n){return d.typeOf.object("value",e),d.defined("array",t),n=m(n,0),t[n++]=e.x,t[n++]=e.y,t[n++]=e.z,t[n]=e.w,t},K.unpack=function(e,t,n){return d.defined("array",e),t=m(t,0),h(n)||(n=new K),n.x=e[t],n.y=e[t+1],n.z=e[t+2],n.w=e[t+3],n},K.packedInterpolationLength=3,K.convertPackedArrayForInterpolation=function(e,t,n,i){K.unpack(e,n*4,os),K.conjugate(os,os);for(let o=0,r=n-t+1;o=0?r=1:(r=-1,o=-o);const s=o-1,a=1-n,c=n*n,u=a*a;for(let g=7;g>=0;--g)jn[g]=(rs[g]*c-ss[g])*s,Gn[g]=(rs[g]*u-ss[g])*s;const f=r*n*(1+jn[0]*(1+jn[1]*(1+jn[2]*(1+jn[3]*(1+jn[4]*(1+jn[5]*(1+jn[6]*(1+jn[7])))))))),p=a*(1+Gn[0]*(1+Gn[1]*(1+Gn[2]*(1+Gn[3]*(1+Gn[4]*(1+Gn[5]*(1+Gn[6]*(1+Gn[7])))))))),_=K.multiplyByScalar(e,p,j0);return K.multiplyByScalar(t,f,i),K.add(_,i,i)},K.fastSquad=function(e,t,n,i,o,r){d.typeOf.object("q0",e),d.typeOf.object("q1",t),d.typeOf.object("s0",n),d.typeOf.object("s1",i),d.typeOf.number("t",o),d.typeOf.object("result",r);const s=K.fastSlerp(e,t,o,Yo),a=K.fastSlerp(n,i,o,ao);return K.fastSlerp(s,a,2*o*(1-o),r)},K.equals=function(e,t){return e===t||h(e)&&h(t)&&e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w},K.equalsEpsilon=function(e,t,n){return n=m(n,0),e===t||h(e)&&h(t)&&Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n&&Math.abs(e.z-t.z)<=n&&Math.abs(e.w-t.w)<=n},K.ZERO=Object.freeze(new K(0,0,0,0)),K.IDENTITY=Object.freeze(new K(0,0,0,1)),K.prototype.clone=function(e){return K.clone(this,e)},K.prototype.equals=function(e){return K.equals(this,e)},K.prototype.equalsEpsilon=function(e,t){return K.equalsEpsilon(this,e,t)},K.prototype.toString=function(){return`(${this.x}, ${this.y}, ${this.z}, ${this.w})`};function $o(e,t,n){d.defined("array",e),d.defined("itemToFind",t),d.defined("comparator",n);let i=0,o=e.length-1,r,s;for(;i<=o;){if(r=~~((i+o)/2),s=n(e[r],t),s<0){i=r+1;continue}if(s>0){o=r-1;continue}return r}return~(o+1)}function $a(e,t,n,i,o){this.xPoleWander=e,this.yPoleWander=t,this.xPoleOffset=n,this.yPoleOffset=i,this.ut1MinusUtc=o}function Xa(e,t,n,i,o,r,s,a){this.year=e,this.month=t,this.day=n,this.hour=i,this.minute=o,this.second=r,this.millisecond=s,this.isLeapSecond=a}function Ph(e){if(e===null||isNaN(e))throw new T("year is required and must be a number.");return e%4===0&&e%100!==0||e%400===0}function Ne(e,t){this.julianDate=e,this.offset=t}const Qe=Object.freeze({SECONDS_PER_MILLISECOND:.001,SECONDS_PER_MINUTE:60,MINUTES_PER_HOUR:60,HOURS_PER_DAY:24,SECONDS_PER_HOUR:3600,MINUTES_PER_DAY:1440,SECONDS_PER_DAY:86400,DAYS_PER_JULIAN_CENTURY:36525,PICOSECOND:1e-9,MODIFIED_JULIAN_DATE_DIFFERENCE:24000005e-1}),Ce=Object.freeze({UTC:0,TAI:1}),Rh=new Xa,as=[31,28,31,30,31,30,31,31,30,31,30,31],cs=29;function Ka(e,t){return oe.compare(e.julianDate,t.julianDate)}const co=new Ne;function ls(e){co.julianDate=e;const t=oe.leapSeconds;let n=$o(t,co,Ka);n<0&&(n=~n),n>=t.length&&(n=t.length-1);let i=t[n].offset;n>0&&oe.secondsDifference(t[n].julianDate,e)>i&&(n--,i=t[n].offset),oe.addSeconds(e,i,e)}function Ih(e,t){co.julianDate=e;const n=oe.leapSeconds;let i=$o(n,co,Ka);if(i<0&&(i=~i),i===0)return oe.addSeconds(e,-n[0].offset,t);if(i>=n.length)return oe.addSeconds(e,-n[i-1].offset,t);const o=oe.secondsDifference(n[i].julianDate,e);if(o===0)return oe.addSeconds(e,-n[i].offset,t);if(!(o<=1))return oe.addSeconds(e,-n[--i].offset,t)}function fi(e,t,n){const i=t/Qe.SECONDS_PER_DAY|0;return e+=i,t-=Qe.SECONDS_PER_DAY*i,t<0&&(e--,t+=Qe.SECONDS_PER_DAY),n.dayNumber=e,n.secondsOfDay=t,n}function Za(e,t,n,i,o,r,s){const a=(t-14)/12|0,c=e+4800+a;let u=(1461*c/4|0)+(367*(t-2-12*a)/12|0)-(3*((c+100)/100|0)/4|0)+n-32075;i=i-12,i<0&&(i+=24);const f=r+(i*Qe.SECONDS_PER_HOUR+o*Qe.SECONDS_PER_MINUTE+s*Qe.SECONDS_PER_MILLISECOND);return f>=43200&&(u-=1),[u,f]}const G0=/^(\d{4})$/,V0=/^(\d{4})-(\d{2})$/,H0=/^(\d{4})-?(\d{3})$/,q0=/^(\d{4})-?W(\d{2})-?(\d{1})?$/,W0=/^(\d{4})-?(\d{2})-?(\d{2})$/,Qa=/([Z+\-])?(\d{2})?:?(\d{2})?$/,Y0=/^(\d{2})(\.\d+)?/.source+Qa.source,$0=/^(\d{2}):?(\d{2})(\.\d+)?/.source+Qa.source,X0=/^(\d{2}):?(\d{2}):?(\d{2})(\.\d+)?/.source+Qa.source,Tn="Invalid ISO 8601 date.";function oe(e,t,n){this.dayNumber=void 0,this.secondsOfDay=void 0,e=m(e,0),t=m(t,0),n=m(n,Ce.UTC);const i=e|0;t=t+(e-i)*Qe.SECONDS_PER_DAY,fi(i,t,this),n===Ce.UTC&&ls(this)}oe.fromGregorianDate=function(e,t){if(!(e instanceof Xa))throw new T("date must be a valid GregorianDate.");const n=Za(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond);return h(t)?(fi(n[0],n[1],t),ls(t),t):new oe(n[0],n[1],Ce.UTC)},oe.fromDate=function(e,t){if(!(e instanceof Date)||isNaN(e.getTime()))throw new T("date must be a valid JavaScript Date.");const n=Za(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds());return h(t)?(fi(n[0],n[1],t),ls(t),t):new oe(n[0],n[1],Ce.UTC)},oe.fromIso8601=function(e,t){if(typeof e!="string")throw new T(Tn);e=e.replace(",",".");let n=e.split("T"),i,o=1,r=1,s=0,a=0,c=0,u=0;const f=n[0],p=n[1];let _,g;if(!h(f))throw new T(Tn);let y;if(n=f.match(W0),n!==null){if(y=f.split("-").length-1,y>0&&y!==2)throw new T(Tn);i=+n[1],o=+n[2],r=+n[3]}else if(n=f.match(V0),n!==null)i=+n[1],o=+n[2];else if(n=f.match(G0),n!==null)i=+n[1];else{let v;if(n=f.match(H0),n!==null){if(i=+n[1],v=+n[2],g=Ph(i),v<1||g&&v>366||!g&&v>365)throw new T(Tn)}else if(n=f.match(q0),n!==null){i=+n[1];const A=+n[2],R=+n[3]||0;if(y=f.split("-").length-1,y>0&&(!h(n[3])&&y!==1||h(n[3])&&y!==2))throw new T(Tn);const z=new Date(Date.UTC(i,0,4));v=A*7+R-z.getUTCDay()-3}else throw new T(Tn);_=new Date(Date.UTC(i,0,1)),_.setUTCDate(v),o=_.getUTCMonth()+1,r=_.getUTCDate()}if(g=Ph(i),o<1||o>12||r<1||(o!==2||!g)&&r>as[o-1]||g&&o===2&&r>cs)throw new T(Tn);let b;if(h(p)){if(n=p.match(X0),n!==null){if(y=p.split(":").length-1,y>0&&y!==2&&y!==3)throw new T(Tn);s=+n[1],a=+n[2],c=+n[3],u=+(n[4]||0)*1e3,b=5}else if(n=p.match($0),n!==null){if(y=p.split(":").length-1,y>2)throw new T(Tn);s=+n[1],a=+n[2],c=+(n[3]||0)*60,b=4}else if(n=p.match(Y0),n!==null)s=+n[1],a=+(n[2]||0)*60,b=3;else throw new T(Tn);if(a>=60||c>=61||s>24||s===24&&(a>0||c>0||u>0))throw new T(Tn);const v=n[b],A=+n[b+1],R=+(n[b+2]||0);switch(v){case"+":s=s-A,a=a-R;break;case"-":s=s+A,a=a+R;break;case"Z":break;default:a=a+new Date(Date.UTC(i,o-1,r,s,a)).getTimezoneOffset();break}}const E=c===60;for(E&&c--;a>=60;)a-=60,s++;for(;s>=24;)s-=24,r++;for(_=g&&o===2?cs:as[o-1];r>_;)r-=_,o++,o>12&&(o-=12,i++),_=g&&o===2?cs:as[o-1];for(;a<0;)a+=60,s--;for(;s<0;)s+=24,r--;for(;r<1;)o--,o<1&&(o+=12,i--),_=g&&o===2?cs:as[o-1],r+=_;const O=Za(i,o,r,s,a,c,u);return h(t)?(fi(O[0],O[1],t),ls(t)):t=new oe(O[0],O[1],Ce.UTC),E&&oe.addSeconds(t,1,t),t},oe.now=function(e){return oe.fromDate(new Date,e)};const hs=new oe(0,0,Ce.TAI);oe.toGregorianDate=function(e,t){if(!h(e))throw new T("julianDate is required.");let n=!1,i=Ih(e,hs);h(i)||(oe.addSeconds(e,-1,hs),i=Ih(hs,hs),n=!0);let o=i.dayNumber;const r=i.secondsOfDay;r>=43200&&(o+=1);let s=o+68569|0;const a=4*s/146097|0;s=s-((146097*a+3)/4|0)|0;const c=4e3*(s+1)/1461001|0;s=s-(1461*c/4|0)+31|0;const u=80*s/2447|0,f=s-(2447*u/80|0)|0;s=u/11|0;const p=u+2-12*s|0,_=100*(a-49)+c+s|0;let g=r/Qe.SECONDS_PER_HOUR|0,y=r-g*Qe.SECONDS_PER_HOUR;const b=y/Qe.SECONDS_PER_MINUTE|0;y=y-b*Qe.SECONDS_PER_MINUTE;let E=y|0;const O=(y-E)/Qe.SECONDS_PER_MILLISECOND;return g+=12,g>23&&(g-=24),n&&(E+=1),h(t)?(t.year=_,t.month=p,t.day=f,t.hour=g,t.minute=b,t.second=E,t.millisecond=O,t.isLeapSecond=n,t):new Xa(_,p,f,g,b,E,O,n)},oe.toDate=function(e){if(!h(e))throw new T("julianDate is required.");const t=oe.toGregorianDate(e,Rh);let n=t.second;return t.isLeapSecond&&(n-=1),new Date(Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,n,t.millisecond))},oe.toIso8601=function(e,t){if(!h(e))throw new T("julianDate is required.");const n=oe.toGregorianDate(e,Rh);let i=n.year,o=n.month,r=n.day,s=n.hour;const a=n.minute,c=n.second,u=n.millisecond;i===1e4&&o===1&&r===1&&s===0&&a===0&&c===0&&u===0&&(i=9999,o=12,r=31,s=24);let f;return!h(t)&&u!==0?(f=(u*.01).toString().replace(".",""),`${i.toString().padStart(4,"0")}-${o.toString().padStart(2,"0")}-${r.toString().padStart(2,"0")}T${s.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}.${f}Z`):!h(t)||t===0?`${i.toString().padStart(4,"0")}-${o.toString().padStart(2,"0")}-${r.toString().padStart(2,"0")}T${s.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}Z`:(f=(u*.01).toFixed(t).replace(".","").slice(0,t),`${i.toString().padStart(4,"0")}-${o.toString().padStart(2,"0")}-${r.toString().padStart(2,"0")}T${s.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}.${f}Z`)},oe.clone=function(e,t){if(h(e))return h(t)?(t.dayNumber=e.dayNumber,t.secondsOfDay=e.secondsOfDay,t):new oe(e.dayNumber,e.secondsOfDay,Ce.TAI)},oe.compare=function(e,t){if(!h(e))throw new T("left is required.");if(!h(t))throw new T("right is required.");const n=e.dayNumber-t.dayNumber;return n!==0?n:e.secondsOfDay-t.secondsOfDay},oe.equals=function(e,t){return e===t||h(e)&&h(t)&&e.dayNumber===t.dayNumber&&e.secondsOfDay===t.secondsOfDay},oe.equalsEpsilon=function(e,t,n){return n=m(n,0),e===t||h(e)&&h(t)&&Math.abs(oe.secondsDifference(e,t))<=n},oe.totalDays=function(e){if(!h(e))throw new T("julianDate is required.");return e.dayNumber+e.secondsOfDay/Qe.SECONDS_PER_DAY},oe.secondsDifference=function(e,t){if(!h(e))throw new T("left is required.");if(!h(t))throw new T("right is required.");return(e.dayNumber-t.dayNumber)*Qe.SECONDS_PER_DAY+(e.secondsOfDay-t.secondsOfDay)},oe.daysDifference=function(e,t){if(!h(e))throw new T("left is required.");if(!h(t))throw new T("right is required.");const n=e.dayNumber-t.dayNumber,i=(e.secondsOfDay-t.secondsOfDay)/Qe.SECONDS_PER_DAY;return n+i},oe.computeTaiMinusUtc=function(e){co.julianDate=e;const t=oe.leapSeconds;let n=$o(t,co,Ka);return n<0&&(n=~n,--n,n<0&&(n=0)),t[n].offset},oe.addSeconds=function(e,t,n){if(!h(e))throw new T("julianDate is required.");if(!h(t))throw new T("seconds is required.");if(!h(n))throw new T("result is required.");return fi(e.dayNumber,e.secondsOfDay+t,n)},oe.addMinutes=function(e,t,n){if(!h(e))throw new T("julianDate is required.");if(!h(t))throw new T("minutes is required.");if(!h(n))throw new T("result is required.");const i=e.secondsOfDay+t*Qe.SECONDS_PER_MINUTE;return fi(e.dayNumber,i,n)},oe.addHours=function(e,t,n){if(!h(e))throw new T("julianDate is required.");if(!h(t))throw new T("hours is required.");if(!h(n))throw new T("result is required.");const i=e.secondsOfDay+t*Qe.SECONDS_PER_HOUR;return fi(e.dayNumber,i,n)},oe.addDays=function(e,t,n){if(!h(e))throw new T("julianDate is required.");if(!h(t))throw new T("days is required.");if(!h(n))throw new T("result is required.");const i=e.dayNumber+t;return fi(i,e.secondsOfDay,n)},oe.lessThan=function(e,t){return oe.compare(e,t)<0},oe.lessThanOrEquals=function(e,t){return oe.compare(e,t)<=0},oe.greaterThan=function(e,t){return oe.compare(e,t)>0},oe.greaterThanOrEquals=function(e,t){return oe.compare(e,t)>=0},oe.prototype.clone=function(e){return oe.clone(this,e)},oe.prototype.equals=function(e){return oe.equals(this,e)},oe.prototype.equalsEpsilon=function(e,t){return oe.equalsEpsilon(this,e,t)},oe.prototype.toString=function(){return oe.toIso8601(this)},oe.leapSeconds=[new Ne(new oe(2441317,43210,Ce.TAI),10),new Ne(new oe(2441499,43211,Ce.TAI),11),new Ne(new oe(2441683,43212,Ce.TAI),12),new Ne(new oe(2442048,43213,Ce.TAI),13),new Ne(new oe(2442413,43214,Ce.TAI),14),new Ne(new oe(2442778,43215,Ce.TAI),15),new Ne(new oe(2443144,43216,Ce.TAI),16),new Ne(new oe(2443509,43217,Ce.TAI),17),new Ne(new oe(2443874,43218,Ce.TAI),18),new Ne(new oe(2444239,43219,Ce.TAI),19),new Ne(new oe(2444786,43220,Ce.TAI),20),new Ne(new oe(2445151,43221,Ce.TAI),21),new Ne(new oe(2445516,43222,Ce.TAI),22),new Ne(new oe(2446247,43223,Ce.TAI),23),new Ne(new oe(2447161,43224,Ce.TAI),24),new Ne(new oe(2447892,43225,Ce.TAI),25),new Ne(new oe(2448257,43226,Ce.TAI),26),new Ne(new oe(2448804,43227,Ce.TAI),27),new Ne(new oe(2449169,43228,Ce.TAI),28),new Ne(new oe(2449534,43229,Ce.TAI),29),new Ne(new oe(2450083,43230,Ce.TAI),30),new Ne(new oe(2450630,43231,Ce.TAI),31),new Ne(new oe(2451179,43232,Ce.TAI),32),new Ne(new oe(2453736,43233,Ce.TAI),33),new Ne(new oe(2454832,43234,Ce.TAI),34),new Ne(new oe(2456109,43235,Ce.TAI),35),new Ne(new oe(2457204,43236,Ce.TAI),36),new Ne(new oe(2457754,43237,Ce.TAI),37)];var zh={exports:{}},Xo={exports:{}};/*! https://mths.be/punycode v1.4.0 by @mathias */Xo.exports;var Dh;function K0(){return Dh||(Dh=1,function(e,t){(function(n){var i=t&&!t.nodeType&&t,o=e&&!e.nodeType&&e,r=typeof no=="object"&&no;(r.global===r||r.window===r||r.self===r)&&(n=r);var s,a=2147483647,c=36,u=1,f=26,p=38,_=700,g=72,y=128,b="-",E=/^xn--/,O=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,A={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},R=c-u,z=Math.floor,U=String.fromCharCode,G;function k($){throw new RangeError(A[$])}function j($,re){for(var le=$.length,we=[];le--;)we[le]=re($[le]);return we}function B($,re){var le=$.split("@"),we="";le.length>1&&(we=le[0]+"@",$=le[1]),$=$.replace(v,".");var Te=$.split("."),be=j(Te,re).join(".");return we+be}function H($){for(var re=[],le=0,we=$.length,Te,be;le=55296&&Te<=56319&&le65535&&(re-=65536,le+=U(re>>>10&1023|55296),re=56320|re&1023),le+=U(re),le}).join("")}function w($){return $-48<10?$-22:$-65<26?$-65:$-97<26?$-97:c}function C($,re){return $+22+75*($<26)-((re!=0)<<5)}function x($,re,le){var we=0;for($=le?z($/_):$>>1,$+=z($/re);$>R*f>>1;we+=c)$=z($/R);return z(we+(R+1)*$/($+p))}function N($){var re=[],le=$.length,we,Te=0,be=y,Pe=g,Be,Ze,at,Re,ht,_t,ut,en,tn;for(Be=$.lastIndexOf(b),Be<0&&(Be=0),Ze=0;Ze=128&&k("not-basic"),re.push($.charCodeAt(Ze));for(at=Be>0?Be+1:0;at=le&&k("invalid-input"),ut=w($.charCodeAt(at++)),(ut>=c||ut>z((a-Te)/ht))&&k("overflow"),Te+=ut*ht,en=_t<=Pe?u:_t>=Pe+f?f:_t-Pe,!(utz(a/tn)&&k("overflow"),ht*=tn;we=re.length+1,Pe=x(Te-Re,we,Re==0),z(Te/we)>a-be&&k("overflow"),be+=z(Te/we),Te%=we,re.splice(Te++,0,be)}return W(re)}function V($){var re,le,we,Te,be,Pe,Be,Ze,at,Re,ht,_t=[],ut,en,tn,An;for($=H($),ut=$.length,re=y,le=0,be=g,Pe=0;Pe=re&&htz((a-le)/en)&&k("overflow"),le+=(Be-re)*en,re=Be,Pe=0;Pea&&k("overflow"),ht==re){for(Ze=le,at=c;Re=at<=be?u:at>=be+f?f:at-be,!(Ze1);g++)p.splice(0,1);a[_]=p.join("")}var y=-1,b=0,E=0,O=-1,v=!1;for(_=0;_b&&(y=O,b=E)):a[_]==="0"&&(v=!0,O=_,E=1);E>b&&(y=O,b=E),b>1&&a.splice(y,b,""),c=a.length;var A="";for(a[0]===""&&(A=":"),_=0;_=o.length-1)return!1;var s=o.lastIndexOf(".",r-1);if(s<=0||s>=r-1)return!1;var a=i.list[o.slice(r+1)];return a?a.indexOf(" "+o.slice(s+1,r)+" ")>=0:!1},is:function(o){var r=o.lastIndexOf(".");if(r<=0||r>=o.length-1)return!1;var s=o.lastIndexOf(".",r-1);if(s>=0)return!1;var a=i.list[o.slice(r+1)];return a?a.indexOf(" "+o.slice(0,r)+" ")>=0:!1},get:function(o){var r=o.lastIndexOf(".");if(r<=0||r>=o.length-1)return null;var s=o.lastIndexOf(".",r-1);if(s<=0||s>=r-1)return null;var a=i.list[o.slice(r+1)];return!a||a.indexOf(" "+o.slice(s+1,r)+" ")<0?null:o.slice(s+1)},noConflict:function(){return t.SecondLevelDomains===this&&(t.SecondLevelDomains=n),this}};return i})}(ec)),ec.exports}/*! * URI.js - Mutating URLs * * Version: 1.19.11 * * Author: Rodney Rehm * Web: http://medialize.github.io/URI.js/ * * Licensed under * MIT License http://www.opensource.org/licenses/mit-license * */(function(e){(function(t,n){e.exports?e.exports=n(K0(),Z0(),Q0()):t.URI=n(t.punycode,t.IPv6,t.SecondLevelDomains,t)})(no,function(t,n,i,o){var r=o&&o.URI;function s(w,C){var x=arguments.length>=1,N=arguments.length>=2;if(!(this instanceof s))return x?N?new s(w,C):new s(w):new s;if(w===void 0){if(x)throw new TypeError("undefined is not a valid argument for URI");typeof location<"u"?w=location.href+"":w=""}if(w===null&&x)throw new TypeError("null is not a valid argument for URI");return this.href(w),C!==void 0?this.absoluteTo(C):this}function a(w){return/^[0-9]+$/.test(w)}s.version="1.19.11";var c=s.prototype,u=Object.prototype.hasOwnProperty;function f(w){return w.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function p(w){return w===void 0?"Undefined":String(Object.prototype.toString.call(w)).slice(8,-1)}function _(w){return p(w)==="Array"}function g(w,C){var x={},N,V;if(p(C)==="RegExp")x=null;else if(_(C))for(N=0,V=C.length;N]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig,s.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},s.leading_whitespace_expression=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,s.ascii_tab_whitespace=/[\u0009\u000A\u000D]+/g,s.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},s.hostProtocols=["http","https"],s.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,s.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},s.getDomAttribute=function(w){if(!(!w||!w.nodeName)){var C=w.nodeName.toLowerCase();if(!(C==="input"&&w.type!=="image"))return s.domAttributes[C]}};function O(w){return escape(w)}function v(w){return encodeURIComponent(w).replace(/[!'()*]/g,O).replace(/\*/g,"%2A")}s.encode=v,s.decode=decodeURIComponent,s.iso8859=function(){s.encode=escape,s.decode=unescape},s.unicode=function(){s.encode=v,s.decode=decodeURIComponent},s.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},s.encodeQuery=function(w,C){var x=s.encode(w+"");return C===void 0&&(C=s.escapeQuerySpace),C?x.replace(/%20/g,"+"):x},s.decodeQuery=function(w,C){w+="",C===void 0&&(C=s.escapeQuerySpace);try{return s.decode(C?w.replace(/\+/g,"%20"):w)}catch{return w}};var A={encode:"encode",decode:"decode"},R,z=function(w,C){return function(x){try{return s[C](x+"").replace(s.characters[w][C].expression,function(N){return s.characters[w][C].map[N]})}catch{return x}}};for(R in A)s[R+"PathSegment"]=z("pathname",A[R]),s[R+"UrnPathSegment"]=z("urnpath",A[R]);var U=function(w,C,x){return function(N){var V;x?V=function(re){return s[C](s[x](re))}:V=s[C];for(var Y=(N+"").split(w),Z=0,$=Y.length;Z<$;Z++)Y[Z]=V(Y[Z]);return Y.join(w)}};s.decodePath=U("/","decodePathSegment"),s.decodeUrnPath=U(":","decodeUrnPathSegment"),s.recodePath=U("/","encodePathSegment","decode"),s.recodeUrnPath=U(":","encodeUrnPathSegment","decode"),s.encodeReserved=z("reserved","encode"),s.parse=function(w,C){var x;return C||(C={preventInvalidHostname:s.preventInvalidHostname}),w=w.replace(s.leading_whitespace_expression,""),w=w.replace(s.ascii_tab_whitespace,""),x=w.indexOf("#"),x>-1&&(C.fragment=w.substring(x+1)||null,w=w.substring(0,x)),x=w.indexOf("?"),x>-1&&(C.query=w.substring(x+1)||null,w=w.substring(0,x)),w=w.replace(/^(https?|ftp|wss?)?:+[/\\]*/i,"$1://"),w=w.replace(/^[/\\]{2,}/i,"//"),w.substring(0,2)==="//"?(C.protocol=null,w=w.substring(2),w=s.parseAuthority(w,C)):(x=w.indexOf(":"),x>-1&&(C.protocol=w.substring(0,x)||null,C.protocol&&!C.protocol.match(s.protocol_expression)?C.protocol=void 0:w.substring(x+1,x+3).replace(/\\/g,"/")==="//"?(w=w.substring(x+3),w=s.parseAuthority(w,C)):(w=w.substring(x+1),C.urn=!0))),C.path=w,C},s.parseHost=function(w,C){w||(w=""),w=w.replace(/\\/g,"/");var x=w.indexOf("/"),N,V;if(x===-1&&(x=w.length),w.charAt(0)==="[")N=w.indexOf("]"),C.hostname=w.substring(1,N)||null,C.port=w.substring(N+2,x)||null,C.port==="/"&&(C.port=null);else{var Y=w.indexOf(":"),Z=w.indexOf("/"),$=w.indexOf(":",Y+1);$!==-1&&(Z===-1||$-1?V:w.length-1),Z;return Y>-1&&(V===-1||Y-1?be=be.slice(0,Pe)+be.slice(Pe).replace(Y,""):be=be.replace(Y,""),!(be.length<=re[0].length)&&!(x.ignore&&x.ignore.test(be))){Te=le+be.length;var at=C(be,le,Te,w);if(at===void 0){N.lastIndex=Te;continue}at=String(at),w=w.slice(0,le)+at+w.slice(Te),N.lastIndex=le+at.length}}return N.lastIndex=0,w},s.ensureValidHostname=function(w,C){var x=!!w,N=!!C,V=!1;if(N&&(V=y(s.hostProtocols,C)),V&&!x)throw new TypeError("Hostname cannot be empty, if protocol is "+C);if(w&&w.match(s.invalid_hostname_characters)){if(!t)throw new TypeError('Hostname "'+w+'" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');if(t.toASCII(w).match(s.invalid_hostname_characters))throw new TypeError('Hostname "'+w+'" contains characters other than [A-Z0-9.-:_]')}},s.ensureValidPort=function(w){if(w){var C=Number(w);if(!(a(C)&&C>0&&C<65536))throw new TypeError('Port "'+w+'" is not a valid port')}},s.noConflict=function(w){if(w){var C={URI:this.noConflict()};return o.URITemplate&&typeof o.URITemplate.noConflict=="function"&&(C.URITemplate=o.URITemplate.noConflict()),o.IPv6&&typeof o.IPv6.noConflict=="function"&&(C.IPv6=o.IPv6.noConflict()),o.SecondLevelDomains&&typeof o.SecondLevelDomains.noConflict=="function"&&(C.SecondLevelDomains=o.SecondLevelDomains.noConflict()),C}else o.URI===this&&(o.URI=r);return this},c.build=function(w){return w===!0?this._deferred_build=!0:(w===void 0||this._deferred_build)&&(this._string=s.build(this._parts),this._deferred_build=!1),this},c.clone=function(){return new s(this)},c.valueOf=c.toString=function(){return this.build(!1)._string};function G(w){return function(C,x){return C===void 0?this._parts[w]||"":(this._parts[w]=C||null,this.build(!x),this)}}function k(w,C){return function(x,N){return x===void 0?this._parts[w]||"":(x!==null&&(x=x+"",x.charAt(0)===C&&(x=x.substring(1))),this._parts[w]=x,this.build(!N),this)}}c.protocol=G("protocol"),c.username=G("username"),c.password=G("password"),c.hostname=G("hostname"),c.port=G("port"),c.query=k("query","?"),c.fragment=k("fragment","#"),c.search=function(w,C){var x=this.query(w,C);return typeof x=="string"&&x.length?"?"+x:x},c.hash=function(w,C){var x=this.fragment(w,C);return typeof x=="string"&&x.length?"#"+x:x},c.pathname=function(w,C){if(w===void 0||w===!0){var x=this._parts.path||(this._parts.hostname?"/":"");return w?(this._parts.urn?s.decodeUrnPath:s.decodePath)(x):x}else return this._parts.urn?this._parts.path=w?s.recodeUrnPath(w):"":this._parts.path=w?s.recodePath(w):"/",this.build(!C),this},c.path=c.pathname,c.href=function(w,C){var x;if(w===void 0)return this.toString();this._string="",this._parts=s._parts();var N=w instanceof s,V=typeof w=="object"&&(w.hostname||w.path||w.pathname);if(w.nodeName){var Y=s.getDomAttribute(w);w=w[Y]||"",V=!1}if(!N&&V&&w.pathname!==void 0&&(w=w.toString()),typeof w=="string"||w instanceof String)this._parts=s.parse(String(w),this._parts);else if(N||V){var Z=N?w._parts:w;for(x in Z)x!=="query"&&u.call(this._parts,x)&&(this._parts[x]=Z[x]);Z.query&&this.query(Z.query,!1)}else throw new TypeError("invalid input");return this.build(!C),this},c.is=function(w){var C=!1,x=!1,N=!1,V=!1,Y=!1,Z=!1,$=!1,re=!this._parts.urn;switch(this._parts.hostname&&(re=!1,x=s.ip4_expression.test(this._parts.hostname),N=s.ip6_expression.test(this._parts.hostname),C=x||N,V=!C,Y=V&&i&&i.has(this._parts.hostname),Z=V&&s.idn_expression.test(this._parts.hostname),$=V&&s.punycode_expression.test(this._parts.hostname)),w.toLowerCase()){case"relative":return re;case"absolute":return!re;case"domain":case"name":return V;case"sld":return Y;case"ip":return C;case"ip4":case"ipv4":case"inet4":return x;case"ip6":case"ipv6":case"inet6":return N;case"idn":return Z;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return $}return null};var j=c.protocol,B=c.port,H=c.hostname;c.protocol=function(w,C){if(w&&(w=w.replace(/:(\/\/)?$/,""),!w.match(s.protocol_expression)))throw new TypeError('Protocol "'+w+`" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]`);return j.call(this,w,C)},c.scheme=c.protocol,c.port=function(w,C){return this._parts.urn?w===void 0?"":this:(w!==void 0&&(w===0&&(w=null),w&&(w+="",w.charAt(0)===":"&&(w=w.substring(1)),s.ensureValidPort(w))),B.call(this,w,C))},c.hostname=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(w!==void 0){var x={preventInvalidHostname:this._parts.preventInvalidHostname},N=s.parseHost(w,x);if(N!=="/")throw new TypeError('Hostname "'+w+'" contains characters other than [A-Z0-9.-]');w=x.hostname,this._parts.preventInvalidHostname&&s.ensureValidHostname(w,this._parts.protocol)}return H.call(this,w,C)},c.origin=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(w===void 0){var x=this.protocol(),N=this.authority();return N?(x?x+"://":"")+this.authority():""}else{var V=s(w);return this.protocol(V.protocol()).authority(V.authority()).build(!C),this}},c.host=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(w===void 0)return this._parts.hostname?s.buildHost(this._parts):"";var x=s.parseHost(w,this._parts);if(x!=="/")throw new TypeError('Hostname "'+w+'" contains characters other than [A-Z0-9.-]');return this.build(!C),this},c.authority=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(w===void 0)return this._parts.hostname?s.buildAuthority(this._parts):"";var x=s.parseAuthority(w,this._parts);if(x!=="/")throw new TypeError('Hostname "'+w+'" contains characters other than [A-Z0-9.-]');return this.build(!C),this},c.userinfo=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(w===void 0){var x=s.buildUserinfo(this._parts);return x&&x.substring(0,x.length-1)}else return w[w.length-1]!=="@"&&(w+="@"),s.parseUserinfo(w,this._parts),this.build(!C),this},c.resource=function(w,C){var x;return w===void 0?this.path()+this.search()+this.hash():(x=s.parse(w),this._parts.path=x.path,this._parts.query=x.query,this._parts.fragment=x.fragment,this.build(!C),this)},c.subdomain=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(w===void 0){if(!this._parts.hostname||this.is("IP"))return"";var x=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,x)||""}else{var N=this._parts.hostname.length-this.domain().length,V=this._parts.hostname.substring(0,N),Y=new RegExp("^"+f(V));if(w&&w.charAt(w.length-1)!=="."&&(w+="."),w.indexOf(":")!==-1)throw new TypeError("Domains cannot contain colons");return w&&s.ensureValidHostname(w,this._parts.protocol),this._parts.hostname=this._parts.hostname.replace(Y,w),this.build(!C),this}},c.domain=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(typeof w=="boolean"&&(C=w,w=void 0),w===void 0){if(!this._parts.hostname||this.is("IP"))return"";var x=this._parts.hostname.match(/\./g);if(x&&x.length<2)return this._parts.hostname;var N=this._parts.hostname.length-this.tld(C).length-1;return N=this._parts.hostname.lastIndexOf(".",N-1)+1,this._parts.hostname.substring(N)||""}else{if(!w)throw new TypeError("cannot set domain empty");if(w.indexOf(":")!==-1)throw new TypeError("Domains cannot contain colons");if(s.ensureValidHostname(w,this._parts.protocol),!this._parts.hostname||this.is("IP"))this._parts.hostname=w;else{var V=new RegExp(f(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(V,w)}return this.build(!C),this}},c.tld=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(typeof w=="boolean"&&(C=w,w=void 0),w===void 0){if(!this._parts.hostname||this.is("IP"))return"";var x=this._parts.hostname.lastIndexOf("."),N=this._parts.hostname.substring(x+1);return C!==!0&&i&&i.list[N.toLowerCase()]&&i.get(this._parts.hostname)||N}else{var V;if(w)if(w.match(/[^a-zA-Z0-9-]/))if(i&&i.is(w))V=new RegExp(f(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(V,w);else throw new TypeError('TLD "'+w+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");V=new RegExp(f(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(V,w)}else throw new TypeError("cannot set TLD empty");return this.build(!C),this}},c.directory=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(w===void 0||w===!0){if(!this._parts.path&&!this._parts.hostname)return"";if(this._parts.path==="/")return"/";var x=this._parts.path.length-this.filename().length-1,N=this._parts.path.substring(0,x)||(this._parts.hostname?"/":"");return w?s.decodePath(N):N}else{var V=this._parts.path.length-this.filename().length,Y=this._parts.path.substring(0,V),Z=new RegExp("^"+f(Y));return this.is("relative")||(w||(w="/"),w.charAt(0)!=="/"&&(w="/"+w)),w&&w.charAt(w.length-1)!=="/"&&(w+="/"),w=s.recodePath(w),this._parts.path=this._parts.path.replace(Z,w),this.build(!C),this}},c.filename=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(typeof w!="string"){if(!this._parts.path||this._parts.path==="/")return"";var x=this._parts.path.lastIndexOf("/"),N=this._parts.path.substring(x+1);return w?s.decodePathSegment(N):N}else{var V=!1;w.charAt(0)==="/"&&(w=w.substring(1)),w.match(/\.?\//)&&(V=!0);var Y=new RegExp(f(this.filename())+"$");return w=s.recodePath(w),this._parts.path=this._parts.path.replace(Y,w),V?this.normalizePath(C):this.build(!C),this}},c.suffix=function(w,C){if(this._parts.urn)return w===void 0?"":this;if(w===void 0||w===!0){if(!this._parts.path||this._parts.path==="/")return"";var x=this.filename(),N=x.lastIndexOf("."),V,Y;return N===-1?"":(V=x.substring(N+1),Y=/^[a-z0-9%]+$/i.test(V)?V:"",w?s.decodePathSegment(Y):Y)}else{w.charAt(0)==="."&&(w=w.substring(1));var Z=this.suffix(),$;if(Z)w?$=new RegExp(f(Z)+"$"):$=new RegExp(f("."+Z)+"$");else{if(!w)return this;this._parts.path+="."+s.recodePath(w)}return $&&(w=s.recodePath(w),this._parts.path=this._parts.path.replace($,w)),this.build(!C),this}},c.segment=function(w,C,x){var N=this._parts.urn?":":"/",V=this.path(),Y=V.substring(0,1)==="/",Z=V.split(N);if(w!==void 0&&typeof w!="number"&&(x=C,C=w,w=void 0),w!==void 0&&typeof w!="number")throw new Error('Bad segment "'+w+'", must be 0-based integer');if(Y&&Z.shift(),w<0&&(w=Math.max(Z.length+w,0)),C===void 0)return w===void 0?Z:Z[w];if(w===null||Z[w]===void 0)if(_(C)){Z=[];for(var $=0,re=C.length;$"u")return e;t=m(n.baseURI,n.location.href)}const i=new Vn(e);return i.scheme()!==""?i.toString():i.absoluteTo(t).toString()};function tg(e,t){if(!h(e))throw new T("uri is required.");let n="";const i=e.lastIndexOf("/");return i!==-1&&(n=e.substring(0,i+1)),t&&(e=new Vn(e),e.query().length!==0&&(n+=`?${e.query()}`),e.fragment().length!==0&&(n+=`#${e.fragment()}`)),n}function ng(e){if(!h(e))throw new T("uri is required.");const t=new Vn(e);t.normalize();let n=t.path(),i=n.lastIndexOf("/");return i!==-1&&(n=n.substr(i+1)),i=n.lastIndexOf("."),i===-1?n="":n=n.substr(i+1),n}const Lh={};function Fh(e,t,n){h(t)||(t=e.width),h(n)||(n=e.height);let i=Lh[t];h(i)||(i={},Lh[t]=i);let o=i[n];if(!h(o)){const r=document.createElement("canvas");r.width=t,r.height=n,o=r.getContext("2d",{willReadFrequently:!0}),o.globalCompositeOperation="copy",i[n]=o}return o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n).data}const ig=/^blob:/i;function Bh(e){return d.typeOf.string("uri",e),ig.test(e)}let vn;function Uh(e){h(vn)||(vn=document.createElement("a")),vn.href=window.location.href;const t=vn.host,n=vn.protocol;return vn.href=e,vn.href=vn.href,n!==vn.protocol||t!==vn.host}const og=/^data:/i;function kh(e){return d.typeOf.string("uri",e),og.test(e)}function rg(e){const t=document.createElement("script");return t.async=!0,t.src=e,new Promise((n,i)=>{window.crossOriginIsolated&&t.setAttribute("crossorigin","anonymous");const o=document.getElementsByTagName("head")[0];t.onload=function(){t.onload=void 0,o.removeChild(t),n()},t.onerror=function(r){i(r)},o.appendChild(t)})}function sg(e){if(!h(e))throw new T("obj is required.");let t="";for(const n in e)if(e.hasOwnProperty(n)){const i=e[n],o=`${encodeURIComponent(n)}=`;if(Array.isArray(i))for(let r=0,s=i.length;r0){const s=o.substring(0,r),a=o.substring(r+2);t[s]=a}}return t}function Ko(e,t,n){this.statusCode=e,this.response=t,this.responseHeaders=n,typeof this.responseHeaders=="string"&&(this.responseHeaders=lg(this.responseHeaders))}Ko.prototype.toString=function(){let e="Request has failed.";return h(this.statusCode)&&(e+=` Status Code: ${this.statusCode}`),e};function Mi(e){d.typeOf.object("options",e),d.defined("options.comparator",e.comparator),this._comparator=e.comparator,this._array=[],this._length=0,this._maximumLength=void 0}Object.defineProperties(Mi.prototype,{length:{get:function(){return this._length}},internalArray:{get:function(){return this._array}},maximumLength:{get:function(){return this._maximumLength},set:function(e){d.typeOf.number.greaterThanOrEquals("maximumLength",e,0);const t=this._length;if(e=0;--t)this.heapify(t)},Mi.prototype.insert=function(e){d.defined("element",e);const t=this._array,n=this._comparator,i=this._maximumLength;let o=this._length++;for(oi&&(r=t[i],this._length=i),r},Mi.prototype.pop=function(e){if(e=m(e,0),this._length===0)return;d.typeOf.number.lessThan("index",e,this._length);const t=this._array,n=t[e];return tc(t,e,--this._length),this.heapify(e),t[this._length]=void 0,n};function hg(e,t){return e.priority-t.priority}const De={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0};let lo=20;const Nt=new Mi({comparator:hg});Nt.maximumLength=lo,Nt.reserve(lo);const xn=[];let Hn={};const ug=typeof document<"u"?new Vn(document.location.href):new Vn,ds=new ze;function ke(){}ke.maximumRequests=50,ke.maximumRequestsPerServer=6,ke.requestsByServer={"api.cesium.com:443":18,"assets.ion.cesium.com:443":18,"ibasemaps-api.arcgis.com:443":18,"tile.googleapis.com:443":18},ke.throttleRequests=!0,ke.debugShowStatistics=!1,ke.requestCompletedEvent=ds,Object.defineProperties(ke,{statistics:{get:function(){return De}},priorityHeapLength:{get:function(){return lo},set:function(e){if(ee;){const t=Nt.pop();Ni(t)}lo=e,Nt.maximumLength=e,Nt.reserve(e)}}});function jh(e){h(e.priorityFunction)&&(e.priority=e.priorityFunction())}ke.serverHasOpenSlots=function(e,t){t=m(t,1);const n=m(ke.requestsByServer[e],ke.maximumRequestsPerServer);return Hn[e]+t<=n},ke.heapHasOpenSlots=function(e){return Nt.length+e<=lo};function Gh(e){return e.state===lt.UNISSUED&&(e.state=lt.ISSUED,e.deferred=di()),e.deferred.promise}function fg(e){return function(t){if(e.state===lt.CANCELLED)return;const n=e.deferred;--De.numberOfActiveRequests,--Hn[e.serverKey],ds.raiseEvent(),e.state=lt.RECEIVED,e.deferred=void 0,n.resolve(t)}}function dg(e){return function(t){e.state!==lt.CANCELLED&&(++De.numberOfFailedRequests,--De.numberOfActiveRequests,--Hn[e.serverKey],ds.raiseEvent(t),e.state=lt.FAILED,e.deferred.reject(t))}}function Vh(e){const t=Gh(e);return e.state=lt.ACTIVE,xn.push(e),++De.numberOfActiveRequests,++De.numberOfActiveRequestsEver,++Hn[e.serverKey],e.requestFunction().then(fg(e)).catch(dg(e)),t}function Ni(e){const t=e.state===lt.ACTIVE;if(e.state=lt.CANCELLED,++De.numberOfCancelledRequests,h(e.deferred)){const n=e.deferred;e.deferred=void 0,n.reject()}t&&(--De.numberOfActiveRequests,--Hn[e.serverKey],++De.numberOfCancelledActiveRequests),h(e.cancelFunction)&&e.cancelFunction()}ke.update=function(){let e,t,n=0;const i=xn.length;for(e=0;e0&&(xn[e-n]=t)}xn.length-=n;const o=Nt.internalArray,r=Nt.length;for(e=0;e0;){if(t=Nt.pop(),t.cancelled){Ni(t);continue}if(t.throttleByServer&&!ke.serverHasOpenSlots(t.serverKey)){Ni(t);continue}Vh(t),++a}pg()},ke.getServerKey=function(e){d.typeOf.string("url",e);let t=new Vn(e);t.scheme()===""&&(t=t.absoluteTo(ug),t.normalize());let n=t.authority();/:/.test(n)||(n=`${n}:${t.scheme()==="https"?"443":"80"}`);const i=Hn[n];return h(i)||(Hn[n]=0),n},ke.request=function(e){if(d.typeOf.object("request",e),d.typeOf.string("request.url",e.url),d.typeOf.func("request.requestFunction",e.requestFunction),kh(e.url)||Bh(e.url))return ds.raiseEvent(),e.state=lt.RECEIVED,e.requestFunction();if(++De.numberOfAttemptedRequests,h(e.serverKey)||(e.serverKey=ke.getServerKey(e.url)),ke.throttleRequests&&e.throttleByServer&&!ke.serverHasOpenSlots(e.serverKey))return;if(!ke.throttleRequests||!e.throttle)return Vh(e);if(xn.length>=ke.maximumRequests)return;jh(e);const t=Nt.insert(e);if(h(t)){if(t===e)return;Ni(t)}return Gh(e)};function pg(){ke.debugShowStatistics&&(De.numberOfActiveRequests===0&&De.lastNumberOfActiveRequests>0&&(De.numberOfAttemptedRequests>0&&(console.log(`Number of attempted requests: ${De.numberOfAttemptedRequests}`),De.numberOfAttemptedRequests=0),De.numberOfCancelledRequests>0&&(console.log(`Number of cancelled requests: ${De.numberOfCancelledRequests}`),De.numberOfCancelledRequests=0),De.numberOfCancelledActiveRequests>0&&(console.log(`Number of cancelled active requests: ${De.numberOfCancelledActiveRequests}`),De.numberOfCancelledActiveRequests=0),De.numberOfFailedRequests>0&&(console.log(`Number of failed requests: ${De.numberOfFailedRequests}`),De.numberOfFailedRequests=0)),De.lastNumberOfActiveRequests=De.numberOfActiveRequests)}ke.clearForSpecs=function(){for(;Nt.length>0;){const t=Nt.pop();Ni(t)}const e=xn.length;for(let t=0;t0}},credits:{get:function(){return this._credits}}}),ie.prototype.toString=function(){return this.getUrlComponent(!0,!0)},ie.prototype.parseUrl=function(e,t,n,i){let o=new Vn(e);const r=_g(o.query());this._queryParameters=t?ps(r,this.queryParameters,n):r,o.search(""),o.fragment(""),h(i)&&o.scheme()===""&&(o=o.absoluteTo(us(i))),this._url=o.toString()};function _g(e){return e.length===0?{}:e.indexOf("=")===-1?{[e]:void 0}:ag(e)}function ps(e,t,n){if(!n)return Kt(e,t);const i=Xt(e,!0);for(const o in t)if(t.hasOwnProperty(o)){let r=i[o];const s=t[o];h(r)?(Array.isArray(r)||(r=i[o]=[r]),i[o]=r.concat(s)):i[o]=Array.isArray(s)?s.slice():s}return i}ie.prototype.getUrlComponent=function(e,t){if(this.isDataUri)return this._url;let n=this._url;e&&(n=`${n}${gg(this.queryParameters)}`),n=n.replace(/%7B/g,"{").replace(/%7D/g,"}");const i=this._templateValues;return Object.keys(i).length>0&&(n=n.replace(/{(.*?)}/g,function(o,r){const s=i[r];return h(s)?encodeURIComponent(s):o})),t&&h(this.proxy)&&(n=this.proxy.getURL(n)),n};function gg(e){const t=Object.keys(e);return t.length===0?"":t.length===1&&!h(e[t[0]])?`?${t[0]}`:`?${sg(e)}`}ie.prototype.setQueryParameters=function(e,t){t?this._queryParameters=ps(this._queryParameters,e,!1):this._queryParameters=ps(e,this._queryParameters,!1)},ie.prototype.appendQueryParameters=function(e){this._queryParameters=ps(e,this._queryParameters,!0)},ie.prototype.setTemplateValues=function(e,t){t?this._templateValues=Kt(this._templateValues,e):this._templateValues=Kt(e,this._templateValues)},ie.prototype.getDerivedResource=function(e){const t=this.clone();if(t._retryCount=0,h(e.url)){const n=m(e.preserveQueryParameters,!1);t.parseUrl(e.url,!0,n,this._url)}return h(e.queryParameters)&&(t._queryParameters=Kt(e.queryParameters,t.queryParameters)),h(e.templateValues)&&(t._templateValues=Kt(e.templateValues,t.templateValues)),h(e.headers)&&(t.headers=Kt(e.headers,t.headers)),h(e.proxy)&&(t.proxy=e.proxy),h(e.request)&&(t.request=e.request),h(e.retryCallback)&&(t.retryCallback=e.retryCallback),h(e.retryAttempts)&&(t.retryAttempts=e.retryAttempts),t},ie.prototype.retryOnError=function(e){const t=this.retryCallback;if(typeof t!="function"||this._retryCount>=this.retryAttempts)return Promise.resolve(!1);const n=this;return Promise.resolve(t(this,e)).then(function(i){return++n._retryCount,i})},ie.prototype.clone=function(e){return h(e)?(e._url=this._url,e._queryParameters=Xt(this._queryParameters),e._templateValues=Xt(this._templateValues),e.headers=Xt(this.headers),e.proxy=this.proxy,e.retryCallback=this.retryCallback,e.retryAttempts=this.retryAttempts,e._retryCount=0,e.request=this.request.clone(),e):new ie({url:this._url,queryParameters:this.queryParameters,templateValues:this.templateValues,headers:this.headers,proxy:this.proxy,retryCallback:this.retryCallback,retryAttempts:this.retryAttempts,request:this.request.clone(),parseUrl:!1,credits:h(this.credits)?this.credits.slice():void 0})},ie.prototype.getBaseUri=function(e){return tg(this.getUrlComponent(e),e)},ie.prototype.appendForwardSlash=function(){this._url=eg(this._url)},ie.prototype.fetchArrayBuffer=function(){return this.fetch({responseType:"arraybuffer"})},ie.fetchArrayBuffer=function(e){return new ie(e).fetchArrayBuffer()},ie.prototype.fetchBlob=function(){return this.fetch({responseType:"blob"})},ie.fetchBlob=function(e){return new ie(e).fetchBlob()},ie.prototype.fetchImage=function(e){e=m(e,m.EMPTY_OBJECT);const t=m(e.preferImageBitmap,!1),n=m(e.preferBlob,!1),i=m(e.flipY,!1),o=m(e.skipColorSpaceConversion,!1);if(ic(this.request),!qh||this.isDataUri||this.isBlobUri||!this.hasHeaders&&!n)return nc({resource:this,flipY:i,skipColorSpaceConversion:o,preferImageBitmap:t});const r=this.fetchBlob();if(!h(r))return;let s,a,c,u;return ie.supportsImageBitmapOptions().then(function(f){return s=f,a=s&&t,r}).then(function(f){if(!h(f))return;if(u=f,a)return ie.createImageBitmapFromBlob(f,{flipY:i,premultiplyAlpha:!1,skipColorSpaceConversion:o});const p=window.URL.createObjectURL(f);return c=new ie({url:p}),nc({resource:c,flipY:i,skipColorSpaceConversion:o,preferImageBitmap:!1})}).then(function(f){if(h(f))return f.blob=u,a||window.URL.revokeObjectURL(c.url),f}).catch(function(f){return h(c)&&window.URL.revokeObjectURL(c.url),f.blob=u,Promise.reject(f)})};function nc(e){const t=e.resource,n=e.flipY,i=e.skipColorSpaceConversion,o=e.preferImageBitmap,r=t.request;r.url=t.url,r.requestFunction=function(){let a=!1;!t.isDataUri&&!t.isBlobUri&&(a=t.isCrossOriginUrl);const c=di();return ie._Implementations.createImage(r,a,c,n,i,o),c.promise};const s=ke.request(r);if(h(s))return s.catch(function(a){return r.state!==lt.FAILED?Promise.reject(a):t.retryOnError(a).then(function(c){return c?(r.state=lt.UNISSUED,r.deferred=void 0,nc({resource:t,flipY:n,skipColorSpaceConversion:i,preferImageBitmap:o})):Promise.reject(a)})})}ie.fetchImage=function(e){return new ie(e).fetchImage({flipY:e.flipY,skipColorSpaceConversion:e.skipColorSpaceConversion,preferBlob:e.preferBlob,preferImageBitmap:e.preferImageBitmap})},ie.prototype.fetchText=function(){return this.fetch({responseType:"text"})},ie.fetchText=function(e){return new ie(e).fetchText()},ie.prototype.fetchJson=function(){const e=this.fetch({responseType:"text",headers:{Accept:"application/json,*/*;q=0.01"}});if(h(e))return e.then(function(t){if(h(t))return JSON.parse(t)})},ie.fetchJson=function(e){return new ie(e).fetchJson()},ie.prototype.fetchXML=function(){return this.fetch({responseType:"document",overrideMimeType:"text/xml"})},ie.fetchXML=function(e){return new ie(e).fetchXML()},ie.prototype.fetchJsonp=function(e){e=m(e,"callback"),ic(this.request);let t;do t=`loadJsonp${P.nextRandomNumber().toString().substring(2,8)}`;while(h(window[t]));return Wh(this,e,t)};function Wh(e,t,n){const i={};i[t]=n,e.setQueryParameters(i);const o=e.request,r=e.url;o.url=r,o.requestFunction=function(){const a=di();return window[n]=function(c){a.resolve(c);try{delete window[n]}catch{window[n]=void 0}},ie._Implementations.loadAndExecuteScript(r,n,a),a.promise};const s=ke.request(o);if(h(s))return s.catch(function(a){return o.state!==lt.FAILED?Promise.reject(a):e.retryOnError(a).then(function(c){return c?(o.state=lt.UNISSUED,o.deferred=void 0,Wh(e,t,n)):Promise.reject(a)})})}ie.fetchJsonp=function(e){return new ie(e).fetchJsonp(e.callbackParameterName)},ie.prototype._makeRequest=function(e){const t=this;ic(t.request);const n=t.request,i=t.url;n.url=i,n.requestFunction=function(){const r=e.responseType,s=Kt(e.headers,t.headers),a=e.overrideMimeType,c=e.method,u=e.data,f=di(),p=ie._Implementations.loadWithXhr(i,r,c,u,s,f,a);return h(p)&&h(p.abort)&&(n.cancelFunction=function(){p.abort()}),f.promise};const o=ke.request(n);if(h(o))return o.then(function(r){return n.cancelFunction=void 0,r}).catch(function(r){return n.cancelFunction=void 0,n.state!==lt.FAILED?Promise.reject(r):t.retryOnError(r).then(function(s){return s?(n.state=lt.UNISSUED,n.deferred=void 0,t.fetch(e)):Promise.reject(r)})})};function ic(e){if(e.state===lt.ISSUED||e.state===lt.ACTIVE)throw new dt("The Resource is already being fetched.");e.state=lt.UNISSUED,e.deferred=void 0}const yg=/^data:(.*?)(;base64)?,(.*)$/;function ms(e,t){const n=decodeURIComponent(t);return e?atob(n):n}function Yh(e,t){const n=ms(e,t),i=new ArrayBuffer(n.length),o=new Uint8Array(i);for(let r=0;raa),Promise.resolve().then(()=>aa)]).then(([u,f])=>(a=u.parse(e),c=f,a.protocol==="https:"?Promise.resolve().then(()=>aa):Promise.resolve().then(()=>aa))).then(u=>{const f={protocol:a.protocol,hostname:a.hostname,port:a.port,path:a.path,query:a.query,method:n,headers:o};u.request(f).on("response",function(p){if(p.statusCode<200||p.statusCode>=300){r.reject(new Ko(p.statusCode,p,p.headers));return}const _=[];p.on("data",function(g){_.push(g)}),p.on("end",function(){const g=Buffer.concat(_);p.headers["content-encoding"]==="gzip"?c.gunzip(g,function(y,b){y?r.reject(new dt("Error decompressing response.")):r.resolve($h(b,t))}):r.resolve($h(g,t))})}).on("error",function(p){r.reject(new Ko)}).end()})}const Tg=typeof XMLHttpRequest>"u";ie._Implementations.loadWithXhr=function(e,t,n,i,o,r,s){const a=yg.exec(e);if(a!==null){r.resolve(wg(a,t));return}if(Tg){bg(e,t,n,i,o,r);return}const c=new XMLHttpRequest;if(Hh.contains(e)&&(c.withCredentials=!0),c.open(n,e,!0),h(s)&&h(c.overrideMimeType)&&c.overrideMimeType(s),h(o))for(const f in o)o.hasOwnProperty(f)&&c.setRequestHeader(f,o[f]);h(t)&&(c.responseType=t);let u=!1;return typeof e=="string"&&(u=e.indexOf("file://")===0||typeof window<"u"&&window.location.origin==="file://"),c.onload=function(){if((c.status<200||c.status>=300)&&!(u&&c.status===0)){r.reject(new Ko(c.status,c.response,c.getAllResponseHeaders()));return}const f=c.response,p=c.responseType;if(n==="HEAD"||n==="OPTIONS"){const g=c.getAllResponseHeaders().trim().split(/[\r\n]+/),y={};g.forEach(function(b){const E=b.split(": "),O=E.shift();y[O]=E.join(": ")}),r.resolve(y);return}if(c.status===204)r.resolve();else if(h(f)&&(!h(t)||p===t))r.resolve(f);else if(t==="json"&&typeof f=="string")try{r.resolve(JSON.parse(f))}catch(_){r.reject(_)}else(p===""||p==="document")&&h(c.responseXML)&&c.responseXML.hasChildNodes()?r.resolve(c.responseXML):(p===""||p==="text")&&h(c.responseText)?r.resolve(c.responseText):r.reject(new dt("Invalid XMLHttpRequest response type."))},c.onerror=function(f){r.reject(new Ko)},c.send(i),c},ie._Implementations.loadAndExecuteScript=function(e,t,n){return rg(e).catch(function(i){n.reject(i)})},ie._DefaultImplementations={},ie._DefaultImplementations.createImage=ie._Implementations.createImage,ie._DefaultImplementations.loadWithXhr=ie._Implementations.loadWithXhr,ie._DefaultImplementations.loadAndExecuteScript=ie._Implementations.loadAndExecuteScript,ie.DEFAULT=Object.freeze(new ie({url:typeof document>"u"?"":document.location.href.split("?")[0]}));function Qo(e){e=m(e,m.EMPTY_OBJECT),this._dates=void 0,this._samples=void 0,this._dateColumn=-1,this._xPoleWanderRadiansColumn=-1,this._yPoleWanderRadiansColumn=-1,this._ut1MinusUtcSecondsColumn=-1,this._xCelestialPoleOffsetRadiansColumn=-1,this._yCelestialPoleOffsetRadiansColumn=-1,this._taiMinusUtcSecondsColumn=-1,this._columnCount=0,this._lastIndex=-1,this._addNewLeapSeconds=m(e.addNewLeapSeconds,!0),h(e.data)?Xh(this,e.data):Xh(this,{columnNames:["dateIso8601","modifiedJulianDateUtc","xPoleWanderRadians","yPoleWanderRadians","ut1MinusUtcSeconds","lengthOfDayCorrectionSeconds","xCelestialPoleOffsetRadians","yCelestialPoleOffsetRadians","taiMinusUtcSeconds"],samples:[]})}Qo.fromUrl=async function(e,t){d.defined("url",e),t=m(t,m.EMPTY_OBJECT);const n=ie.createIfNeeded(e);let i;try{i=await n.fetchJson()}catch{throw new dt(`An error occurred while retrieving the EOP data from the URL ${n.url}.`)}return new Qo({addNewLeapSeconds:t.addNewLeapSeconds,data:i})},Qo.NONE=Object.freeze({compute:function(e,t){return h(t)?(t.xPoleWander=0,t.yPoleWander=0,t.xPoleOffset=0,t.yPoleOffset=0,t.ut1MinusUtc=0):t=new $a(0,0,0,0,0),t}}),Qo.prototype.compute=function(e,t){if(!h(this._samples))return;if(h(t)||(t=new $a(0,0,0,0,0)),this._samples.length===0)return t.xPoleWander=0,t.yPoleWander=0,t.xPoleOffset=0,t.yPoleOffset=0,t.ut1MinusUtc=0,t;const n=this._dates,i=this._lastIndex;let o=0,r=0;if(h(i)){const a=n[i],c=n[i+1],u=oe.lessThanOrEquals(a,e),f=!h(c),p=f||oe.greaterThanOrEquals(c,e);if(u&&p)return o=i,!f&&c.equals(e)&&++o,r=o+1,Zh(this,n,this._samples,e,o,r,t),t}let s=$o(n,e,oe.compare,this._dateColumn);return s>=0?(st.length-1)return s.xPoleWander=0,s.yPoleWander=0,s.xPoleOffset=0,s.yPoleOffset=0,s.ut1MinusUtc=0,s;const c=t[o],u=t[r];if(c.equals(u)||i.equals(c))return Kh(e,n,o,a,s),s;if(i.equals(u))return Kh(e,n,r,a,s),s;const f=oe.secondsDifference(i,c)/oe.secondsDifference(u,c),p=o*a,_=r*a;let g=n[p+e._ut1MinusUtcSecondsColumn],y=n[_+e._ut1MinusUtcSecondsColumn];const b=y-g;if(b>.5||b<-.5){const E=n[p+e._taiMinusUtcSecondsColumn],O=n[_+e._taiMinusUtcSecondsColumn];E!==O&&(u.equals(i)?g=y:y-=O-E)}return s.xPoleWander=Jo(f,n[p+e._xPoleWanderRadiansColumn],n[_+e._xPoleWanderRadiansColumn]),s.yPoleWander=Jo(f,n[p+e._yPoleWanderRadiansColumn],n[_+e._yPoleWanderRadiansColumn]),s.xPoleOffset=Jo(f,n[p+e._xCelestialPoleOffsetRadiansColumn],n[_+e._xCelestialPoleOffsetRadiansColumn]),s.yPoleOffset=Jo(f,n[p+e._yCelestialPoleOffsetRadiansColumn],n[_+e._yCelestialPoleOffsetRadiansColumn]),s.ut1MinusUtc=Jo(f,g,y),s}function At(e,t,n){this.heading=m(e,0),this.pitch=m(t,0),this.roll=m(n,0)}At.fromQuaternion=function(e,t){if(!h(e))throw new T("quaternion is required");h(t)||(t=new At);const n=2*(e.w*e.y-e.z*e.x),i=1-2*(e.x*e.x+e.y*e.y),o=2*(e.w*e.x+e.y*e.z),r=1-2*(e.y*e.y+e.z*e.z),s=2*(e.w*e.z+e.x*e.y);return t.heading=-Math.atan2(s,r),t.roll=Math.atan2(o,i),t.pitch=-P.asinClamped(n),t},At.fromDegrees=function(e,t,n,i){if(!h(e))throw new T("heading is required");if(!h(t))throw new T("pitch is required");if(!h(n))throw new T("roll is required");return h(i)||(i=new At),i.heading=e*P.RADIANS_PER_DEGREE,i.pitch=t*P.RADIANS_PER_DEGREE,i.roll=n*P.RADIANS_PER_DEGREE,i},At.clone=function(e,t){if(h(e))return h(t)?(t.heading=e.heading,t.pitch=e.pitch,t.roll=e.roll,t):new At(e.heading,e.pitch,e.roll)},At.equals=function(e,t){return e===t||h(e)&&h(t)&&e.heading===t.heading&&e.pitch===t.pitch&&e.roll===t.roll},At.equalsEpsilon=function(e,t,n,i){return e===t||h(e)&&h(t)&&P.equalsEpsilon(e.heading,t.heading,n,i)&&P.equalsEpsilon(e.pitch,t.pitch,n,i)&&P.equalsEpsilon(e.roll,t.roll,n,i)},At.prototype.clone=function(e){return At.clone(this,e)},At.prototype.equals=function(e){return At.equals(this,e)},At.prototype.equalsEpsilon=function(e,t,n){return At.equalsEpsilon(this,e,t,n)},At.prototype.toString=function(){return`(${this.heading}, ${this.pitch}, ${this.roll})`};const Qh=/((?:.*\/)|^)Cesium\.js(?:\?|\#|$)/;function Cg(){const e=document.getElementsByTagName("script");for(let t=0,n=e.length;t"u"?e:(h(fo)||(fo=document.createElement("a")),fo.href=e,fo.href=fo.href,fo.href)}let Li;function eu(){if(h(Li))return Li;let e;if(typeof CESIUM_BASE_URL<"u"?e=CESIUM_BASE_URL:typeof define=="object"&&h(define.amd)&&!define.amd.toUrlUndefined&&h(require.toUrl)?e=us("..",Zt("Core/buildModuleUrl.js")):e=Cg(),!h(e))throw new T("Unable to determine Cesium base URL automatically, try defining a global variable called CESIUM_BASE_URL.");return Li=new ie({url:Jh(e)}),Li.appendForwardSlash(),Li}function Sg(e){return Jh(require.toUrl(`../${e}`))}function tu(e){return eu().getDerivedResource({url:e}).url}let _s;function Zt(e){return h(_s)||(typeof define=="object"&&h(define.amd)&&!define.amd.toUrlUndefined&&h(require.toUrl)?_s=Sg:_s=tu),_s(e)}Zt._cesiumScriptRegex=Qh,Zt._buildModuleUrlFromBaseUrl=tu,Zt._clearBaseResource=function(){Li=void 0},Zt.setBaseUrl=function(e){Li=ie.DEFAULT.getDerivedResource({url:e})},Zt.getCesiumBaseUrl=eu;function nu(e,t,n){this.x=e,this.y=t,this.s=n}function oc(e){e=m(e,m.EMPTY_OBJECT),this._xysFileUrlTemplate=ie.createIfNeeded(e.xysFileUrlTemplate),this._interpolationOrder=m(e.interpolationOrder,9),this._sampleZeroJulianEphemerisDate=m(e.sampleZeroJulianEphemerisDate,24423965e-1),this._sampleZeroDateTT=new oe(this._sampleZeroJulianEphemerisDate,0,Ce.TAI),this._stepSizeDays=m(e.stepSizeDays,1),this._samplesPerXysFile=m(e.samplesPerXysFile,1e3),this._totalSamples=m(e.totalSamples,27426),this._samples=new Array(this._totalSamples*3),this._chunkDownloadsInProgress=[];const t=this._interpolationOrder,n=this._denominators=new Array(t+1),i=this._xTable=new Array(t+1),o=Math.pow(this._stepSizeDays,t);for(let r=0;r<=t;++r){n[r]=o,i[r]=r*this._stepSizeDays;for(let s=0;s<=t;++s)s!==r&&(n[r]*=r-s);n[r]=1/n[r]}this._work=new Array(t+1),this._coef=new Array(t+1)}const Og=new oe(0,0,Ce.TAI);function rc(e,t,n){const i=Og;return i.dayNumber=t,i.secondsOfDay=n,oe.daysDifference(i,e._sampleZeroDateTT)}oc.prototype.preload=function(e,t,n,i){const o=rc(this,e,t),r=rc(this,n,i);let s=o/this._stepSizeDays-this._interpolationOrder/2|0;s<0&&(s=0);let a=r/this._stepSizeDays-this._interpolationOrder/2|0+this._interpolationOrder;a>=this._totalSamples&&(a=this._totalSamples-1);const c=s/this._samplesPerXysFile|0,u=a/this._samplesPerXysFile|0,f=[];for(let p=c;p<=u;++p)f.push(sc(this,p));return Promise.all(f)},oc.prototype.computeXysRadians=function(e,t,n){const i=rc(this,e,t);if(i<0)return;const o=i/this._stepSizeDays|0;if(o>=this._totalSamples)return;const r=this._interpolationOrder;let s=o-(r/2|0);s<0&&(s=0);let a=s+r;a>=this._totalSamples&&(a=this._totalSamples-1,s=a-r,s<0&&(s=0));let c=!1;const u=this._samples;if(h(u[s*3])||(sc(this,s/this._samplesPerXysFile|0),c=!0),h(u[a*3])||(sc(this,a/this._samplesPerXysFile|0),c=!0),c)return;h(n)?(n.x=0,n.y=0,n.s=0):n=new nu(0,0,0);const f=i-s*this._stepSizeDays,p=this._work,_=this._denominators,g=this._coef,y=this._xTable;let b,E;for(b=0;b<=r;++b)p[b]=f-y[b];for(b=0;b<=r;++b){for(g[b]=1,E=0;E<=r;++E)E!==b&&(g[b]*=p[E]);g[b]*=_[b];let O=(s+b)*3;n.x+=g[b]*u[O++],n.y+=g[b]*u[O++],n.s+=g[b]*u[O]}return n};function sc(e,t){if(e._chunkDownloadsInProgress[t])return e._chunkDownloadsInProgress[t];let n;const i=e._xysFileUrlTemplate;h(i)?n=i.getDerivedResource({templateValues:{0:t}}):n=new ie({url:Zt(`Assets/IAU2006_XYS/IAU2006_XYS_${t}.json`)});const o=n.fetchJson().then(function(r){e._chunkDownloadsInProgress[t]=!1;const s=e._samples,a=r.samples,c=t*e._samplesPerXysFile*3;for(let u=0,f=a.length;u=43200?o=(r+.5)/Qe.DAYS_PER_JULIAN_CENTURY:o=(r-.5)/Qe.DAYS_PER_JULIAN_CENTURY;const a=(Lg+o*(Fg+o*(Bg+o*Ug)))*Gg%P.TWO_PI,c=jg+kg*(n-24515455e-1),u=(i+Qe.SECONDS_PER_DAY*.5)%Qe.SECONDS_PER_DAY,f=a+c*u,p=Math.cos(f),_=Math.sin(f);return h(t)?(t[0]=p,t[1]=-_,t[2]=0,t[3]=_,t[4]=p,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t):new M(p,_,0,-_,p,0,0,0,1)},Ie.iau2006XysData=new oc,Ie.earthOrientationParameters=Qo.NONE;const lc=32.184,Vg=2451545;Ie.preloadIcrfFixed=function(e){const t=e.start.dayNumber,n=e.start.secondsOfDay+lc,i=e.stop.dayNumber,o=e.stop.secondsOfDay+lc;return Ie.iau2006XysData.preload(t,n,i,o)},Ie.computeIcrfToFixedMatrix=function(e,t){if(!h(e))throw new T("date is required.");h(t)||(t=new M);const n=Ie.computeFixedToIcrfMatrix(e,t);if(h(n))return M.transpose(n,t)};const Hg=new nu(0,0,0),qg=new $a(0,0,0,0,0),hc=new M,uc=new M;Ie.computeFixedToIcrfMatrix=function(e,t){if(!h(e))throw new T("date is required.");h(t)||(t=new M);const n=Ie.earthOrientationParameters.compute(e,qg);if(!h(n))return;const i=e.dayNumber,o=e.secondsOfDay+lc,r=Ie.iau2006XysData.computeXysRadians(i,o,Hg);if(!h(r))return;const s=r.x+n.xPoleOffset,a=r.y+n.yPoleOffset,c=1/(1+Math.sqrt(1-s*s-a*a)),u=hc;u[0]=1-c*s*s,u[3]=-c*s*a,u[6]=s,u[1]=-c*s*a,u[4]=1-c*a*a,u[7]=a,u[2]=-s,u[5]=-a,u[8]=1-c*(s*s+a*a);const f=M.fromRotationZ(-r.s,uc),p=M.multiply(u,f,hc),_=e.dayNumber,g=e.secondsOfDay-oe.computeTaiMinusUtc(e)+n.ut1MinusUtc,y=_-2451545,b=g/Qe.SECONDS_PER_DAY;let E=.779057273264+b+.00273781191135448*(y+b);E=E%1*P.TWO_PI;const O=M.fromRotationZ(E,uc),v=M.multiply(p,O,hc),A=Math.cos(n.xPoleWander),R=Math.cos(n.yPoleWander),z=Math.sin(n.xPoleWander),U=Math.sin(n.yPoleWander);let G=i-Vg+o/Qe.SECONDS_PER_DAY;G/=36525;const k=-47e-6*G*P.RADIANS_PER_DEGREE/3600,j=Math.cos(k),B=Math.sin(k),H=uc;return H[0]=A*j,H[1]=A*B,H[2]=z,H[3]=-R*B+U*z*j,H[4]=R*j+U*z*B,H[5]=-U*A,H[6]=-U*B-R*z*j,H[7]=U*j-R*z*B,H[8]=R*A,M.multiply(v,H,t)};const Wg=new q;Ie.pointToWindowCoordinates=function(e,t,n,i){return i=Ie.pointToGLWindowCoordinates(e,t,n,i),i.y=2*t[5]-i.y,i},Ie.pointToGLWindowCoordinates=function(e,t,n,i){if(!h(e))throw new T("modelViewProjectionMatrix is required.");if(!h(t))throw new T("viewportTransformation is required.");if(!h(n))throw new T("point is required.");h(i)||(i=new L);const o=Wg;return F.multiplyByVector(e,q.fromElements(n.x,n.y,n.z,1,o),o),q.multiplyByScalar(o,1/o.w,o),F.multiplyByVector(t,o,o),L.fromCartesian4(o,i)};const Yg=new l,$g=new l,Xg=new l;Ie.rotationMatrixFromPositionVelocity=function(e,t,n,i){if(!h(e))throw new T("position is required.");if(!h(t))throw new T("velocity is required.");const o=m(n,pe.WGS84).geodeticSurfaceNormal(e,Yg);let r=l.cross(t,o,$g);l.equalsEpsilon(r,l.ZERO,P.EPSILON6)&&(r=l.clone(l.UNIT_X,r));const s=l.cross(r,t,Xg);return l.normalize(s,s),l.cross(t,s,r),l.negate(r,r),l.normalize(r,r),h(i)||(i=new M),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=r.x,i[4]=r.y,i[5]=r.z,i[6]=s.x,i[7]=s.y,i[8]=s.z,i};const ou=new F(0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,1),ru=new J,su=new l,Kg=new l,Zg=new M,fc=new F,au=new F;Ie.basisTo2D=function(e,t,n){if(!h(e))throw new T("projection is required.");if(!h(t))throw new T("matrix is required.");if(!h(n))throw new T("result is required.");const i=F.getTranslation(t,Kg),o=e.ellipsoid,r=o.cartesianToCartographic(i,ru),s=e.project(r,su);l.fromElements(s.z,s.x,s.y,s);const a=Ie.eastNorthUpToFixedFrame(i,o,fc),c=F.inverseTransformation(a,au),u=F.getMatrix3(t,Zg),f=F.multiplyByMatrix3(c,u,n);return F.multiply(ou,f,n),F.setTranslation(n,s,n),n},Ie.wgs84To2DModelMatrix=function(e,t,n){if(!h(e))throw new T("projection is required.");if(!h(t))throw new T("center is required.");if(!h(n))throw new T("result is required.");const i=e.ellipsoid,o=Ie.eastNorthUpToFixedFrame(t,i,fc),r=F.inverseTransformation(o,au),s=i.cartesianToCartographic(t,ru),a=e.project(s,su);l.fromElements(a.z,a.x,a.y,a);const c=F.fromTranslation(a,fc);return F.multiply(ou,r,n),F.multiply(c,n,n),n};const Fi=Ie;function rt(e){e=m(e,m.EMPTY_OBJECT),d.typeOf.object("options.attributes",e.attributes),this.attributes=e.attributes,this.indices=e.indices,this.primitiveType=m(e.primitiveType,Ue.TRIANGLES),this.boundingSphere=e.boundingSphere,this.geometryType=m(e.geometryType,qo.NONE),this.boundingSphereCV=e.boundingSphereCV,this.offsetAttribute=e.offsetAttribute}rt.computeNumberOfVertices=function(e){d.typeOf.object("geometry",e);let t=-1;for(const n in e.attributes)if(e.attributes.hasOwnProperty(n)&&h(e.attributes[n])&&h(e.attributes[n].values)){const i=e.attributes[n],o=i.values.length/i.componentsPerAttribute;if(t!==o&&t!==-1)throw new T("All attribute lists must have the same number of attributes.");t=o}return t};const Qg=new J,Jg=new l,cu=new F,ey=[new J,new J,new J],ty=[new L,new L,new L],ny=[new L,new L,new L],iy=new l,oy=new K,ry=new F,sy=new se;rt._textureCoordinateRotationPoints=function(e,t,n,i){let o;const r=he.center(i,Qg),s=J.toCartesian(r,n,Jg),a=Fi.eastNorthUpToFixedFrame(s,n,cu),c=F.inverse(a,cu),u=ty,f=ey;f[0].longitude=i.west,f[0].latitude=i.south,f[1].longitude=i.west,f[1].latitude=i.north,f[2].longitude=i.east,f[2].latitude=i.south;let p=iy;for(o=0;o<3;o++)J.toCartesian(f[o],n,p),p=F.multiplyByPointAsVector(c,p,p),u[o].x=p.x,u[o].y=p.y;const _=K.fromAxisAngle(l.UNIT_Z,-t,oy),g=M.fromQuaternion(_,ry),y=e.length;let b=Number.POSITIVE_INFINITY,E=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY,v=Number.NEGATIVE_INFINITY;for(o=0;o4)throw new T("options.componentsPerAttribute must be between 1 and 4.");if(!h(e.values))throw new T("options.values is required.");this.componentDatatype=e.componentDatatype,this.componentsPerAttribute=e.componentsPerAttribute,this.normalize=m(e.normalize,!1),this.values=e.values}function lu(e){e=m(e,m.EMPTY_OBJECT),this.position=e.position,this.normal=e.normal,this.st=e.st,this.bitangent=e.bitangent,this.tangent=e.tangent,this.color=e.color}const hu=Object.freeze({NONE:0,TOP:1,ALL:2});function Je(e){e=m(e,m.EMPTY_OBJECT),this.position=m(e.position,!1),this.normal=m(e.normal,!1),this.st=m(e.st,!1),this.bitangent=m(e.bitangent,!1),this.tangent=m(e.tangent,!1),this.color=m(e.color,!1)}Je.POSITION_ONLY=Object.freeze(new Je({position:!0})),Je.POSITION_AND_NORMAL=Object.freeze(new Je({position:!0,normal:!0})),Je.POSITION_NORMAL_AND_ST=Object.freeze(new Je({position:!0,normal:!0,st:!0})),Je.POSITION_AND_ST=Object.freeze(new Je({position:!0,st:!0})),Je.POSITION_AND_COLOR=Object.freeze(new Je({position:!0,color:!0})),Je.ALL=Object.freeze(new Je({position:!0,normal:!0,st:!0,tangent:!0,bitangent:!0})),Je.DEFAULT=Je.POSITION_NORMAL_AND_ST,Je.packedLength=6,Je.pack=function(e,t,n){if(!h(e))throw new T("value is required");if(!h(t))throw new T("array is required");return n=m(n,0),t[n++]=e.position?1:0,t[n++]=e.normal?1:0,t[n++]=e.st?1:0,t[n++]=e.tangent?1:0,t[n++]=e.bitangent?1:0,t[n]=e.color?1:0,t},Je.unpack=function(e,t,n){if(!h(e))throw new T("array is required");return t=m(t,0),h(n)||(n=new Je),n.position=e[t++]===1,n.normal=e[t++]===1,n.st=e[t++]===1,n.tangent=e[t++]===1,n.bitangent=e[t++]===1,n.color=e[t]===1,n},Je.clone=function(e,t){if(h(e))return h(t)||(t=new Je),t.position=e.position,t.normal=e.normal,t.st=e.st,t.tangent=e.tangent,t.bitangent=e.bitangent,t.color=e.color,t};function mo(e,t,n,i){e=m(e,1),t=m(t,1),n=m(n,1),i=m(i,1),this.value=new Uint8Array([S.floatToByte(e),S.floatToByte(t),S.floatToByte(n),S.floatToByte(i)])}Object.defineProperties(mo.prototype,{componentDatatype:{get:function(){return ue.UNSIGNED_BYTE}},componentsPerAttribute:{get:function(){return 4}},normalize:{get:function(){return!0}}}),mo.fromColor=function(e){if(!h(e))throw new T("color is required.");return new mo(e.red,e.green,e.blue,e.alpha)},mo.toValue=function(e,t){if(!h(e))throw new T("color is required.");return h(t)?e.toBytes(t):new Uint8Array(e.toBytes())},mo.equals=function(e,t){return e===t||h(e)&&h(t)&&e.value[0]===t.value[0]&&e.value[1]===t.value[1]&&e.value[2]===t.value[2]&&e.value[3]===t.value[3]};function ys(e){if(e=m(e,m.EMPTY_OBJECT),!h(e.geometry))throw new T("options.geometry is required.");this.geometry=e.geometry,this.modelMatrix=F.clone(m(e.modelMatrix,F.IDENTITY)),this.id=e.id,this.pickPrimitive=e.pickPrimitive,this.attributes=m(e.attributes,{}),this.westHemisphereGeometry=void 0,this.eastHemisphereGeometry=void 0}function er(e,t,n){e=m(e,0),t=m(t,0),n=m(n,0),this.value=new Float32Array([e,t,n])}Object.defineProperties(er.prototype,{componentDatatype:{get:function(){return ue.FLOAT}},componentsPerAttribute:{get:function(){return 3}},normalize:{get:function(){return!1}}}),er.fromCartesian3=function(e){return d.defined("offset",e),new er(e.x,e.y,e.z)},er.toValue=function(e,t){return d.defined("offset",e),h(t)||(t=new Float32Array([e.x,e.y,e.z])),t[0]=e.x,t[1]=e.y,t[2]=e.z,t};const ay={ADD:I.FUNC_ADD,SUBTRACT:I.FUNC_SUBTRACT,REVERSE_SUBTRACT:I.FUNC_REVERSE_SUBTRACT,MIN:I.MIN,MAX:I.MAX},_o=Object.freeze(ay),cy={ZERO:I.ZERO,ONE:I.ONE,SOURCE_COLOR:I.SRC_COLOR,ONE_MINUS_SOURCE_COLOR:I.ONE_MINUS_SRC_COLOR,DESTINATION_COLOR:I.DST_COLOR,ONE_MINUS_DESTINATION_COLOR:I.ONE_MINUS_DST_COLOR,SOURCE_ALPHA:I.SRC_ALPHA,ONE_MINUS_SOURCE_ALPHA:I.ONE_MINUS_SRC_ALPHA,DESTINATION_ALPHA:I.DST_ALPHA,ONE_MINUS_DESTINATION_ALPHA:I.ONE_MINUS_DST_ALPHA,CONSTANT_COLOR:I.CONSTANT_COLOR,ONE_MINUS_CONSTANT_COLOR:I.ONE_MINUS_CONSTANT_COLOR,CONSTANT_ALPHA:I.CONSTANT_ALPHA,ONE_MINUS_CONSTANT_ALPHA:I.ONE_MINUS_CONSTANT_ALPHA,SOURCE_ALPHA_SATURATE:I.SRC_ALPHA_SATURATE},fn=Object.freeze(cy),ly={DISABLED:Object.freeze({enabled:!1}),ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:_o.ADD,equationAlpha:_o.ADD,functionSourceRgb:fn.SOURCE_ALPHA,functionSourceAlpha:fn.ONE,functionDestinationRgb:fn.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:fn.ONE_MINUS_SOURCE_ALPHA}),PRE_MULTIPLIED_ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:_o.ADD,equationAlpha:_o.ADD,functionSourceRgb:fn.ONE,functionSourceAlpha:fn.ONE,functionDestinationRgb:fn.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:fn.ONE_MINUS_SOURCE_ALPHA}),ADDITIVE_BLEND:Object.freeze({enabled:!0,equationRgb:_o.ADD,equationAlpha:_o.ADD,functionSourceRgb:fn.SOURCE_ALPHA,functionSourceAlpha:fn.ONE,functionDestinationRgb:fn.ONE,functionDestinationAlpha:fn.ONE})},tr=Object.freeze(ly),hy={FRONT:I.FRONT,BACK:I.BACK,FRONT_AND_BACK:I.FRONT_AND_BACK},go=Object.freeze(hy);function vt(e){e=m(e,m.EMPTY_OBJECT),this.material=e.material,this.translucent=m(e.translucent,!0),this._vertexShaderSource=e.vertexShaderSource,this._fragmentShaderSource=e.fragmentShaderSource,this._renderState=e.renderState,this._closed=m(e.closed,!1)}Object.defineProperties(vt.prototype,{vertexShaderSource:{get:function(){return this._vertexShaderSource}},fragmentShaderSource:{get:function(){return this._fragmentShaderSource}},renderState:{get:function(){return this._renderState}},closed:{get:function(){return this._closed}}}),vt.prototype.getFragmentShaderSource=function(){const e=[];return this.flat&&e.push("#define FLAT"),this.faceForward&&e.push("#define FACE_FORWARD"),h(this.material)&&e.push(this.material.shaderSource),e.push(this.fragmentShaderSource),e.join(` `)},vt.prototype.isTranslucent=function(){return h(this.material)&&this.material.isTranslucent()||!h(this.material)&&this.translucent},vt.prototype.getRenderState=function(){const e=this.isTranslucent(),t=Xt(this.renderState,!1);return e?(t.depthMask=!1,t.blending=tr.ALPHA_BLEND):t.depthMask=!0,t},vt.getDefaultRenderState=function(e,t,n){let i={depthTest:{enabled:!0}};return e&&(i.depthMask=!1,i.blending=tr.ALPHA_BLEND),t&&(i.cull={enabled:!0,face:go.BACK}),h(n)&&(i=Kt(n,i,!0)),i};function ws(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function yo(e,t,n,i,o){this._format=e,this._datatype=t,this._width=n,this._height=i,this._buffer=o}Object.defineProperties(yo.prototype,{internalFormat:{get:function(){return this._format}},pixelDatatype:{get:function(){return this._datatype}},width:{get:function(){return this._width}},height:{get:function(){return this._height}},bufferView:{get:function(){return this._buffer}}}),yo.clone=function(e){if(h(e))return new yo(e._format,e._datatype,e._width,e._height,e._buffer)},yo.prototype.clone=function(){return yo.clone(this)};function uu(){if(!h(yt._canTransferArrayBuffer)){const e=new Worker(du("Workers/transferTypedArrayTest.js"));e.postMessage=m(e.webkitPostMessage,e.postMessage);const t=99,n=new Int8Array([t]);try{e.postMessage({array:n},[n.buffer])}catch{return yt._canTransferArrayBuffer=!1,yt._canTransferArrayBuffer}const i=di();e.onmessage=function(o){const r=o.data.array,s=h(r)&&r[0]===t;i.resolve(s),e.terminate(),yt._canTransferArrayBuffer=s},yt._canTransferArrayBuffer=i.promise}return yt._canTransferArrayBuffer}const dc=new ze;function fu(e,t){--e._activeTasks;const n=t.id;if(!h(n))return;const i=e._deferreds,o=i[n];if(h(t.error)){let r=t.error;r.name==="RuntimeError"?(r=new dt(t.error.message),r.stack=t.error.stack):r.name==="DeveloperError"&&(r=new T(t.error.message),r.stack=t.error.stack),dc.raiseEvent(r),o.reject(r)}else dc.raiseEvent(),o.resolve(t.result);delete i[n]}function du(e){let t=Zt(e);if(Uh(t)){const n=`importScripts("${t}");`;let i;try{i=new Blob([n],{type:"application/javascript"})}catch{const s=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,a=new s;a.append(n),i=a.getBlob("application/javascript")}t=(window.URL||window.webkitURL).createObjectURL(i)}return t}let pc;function uy(){return h(pc)||(pc=du("Workers/cesiumWorkerBootstrapper.js")),pc}function pu(e){const t=new Worker(uy());t.postMessage=m(t.webkitPostMessage,t.postMessage);const n={loaderConfig:{paths:{Workers:Zt("Workers")},baseUrl:Zt.getCesiumBaseUrl().url},workerModule:e._workerPath};return t.postMessage(n),t.onmessage=function(i){fu(e,i.data)},t}function fy(e,t){const n={modulePath:void 0,wasmBinaryFile:void 0,wasmBinary:void 0};if(!wn.supportsWebAssembly()){if(!h(t.fallbackModulePath))throw new dt(`This browser does not support Web Assembly, and no backup module was provided for ${e._workerPath}`);return n.modulePath=Zt(t.fallbackModulePath),Promise.resolve(n)}return n.modulePath=Zt(t.modulePath),n.wasmBinaryFile=Zt(t.wasmBinaryFile),ie.fetchArrayBuffer({url:n.wasmBinaryFile}).then(function(i){return n.wasmBinary=i,n})}function yt(e,t){const n=new Vn(e);this._workerPath=n.scheme().length!==0&&n.fragment().length===0?e:yt._workerModulePrefix+e,this._maximumActiveTasks=m(t,Number.POSITIVE_INFINITY),this._activeTasks=0,this._deferreds={},this._nextID=0}const dy=[];yt.prototype.scheduleTask=function(e,t){if(h(this._worker)||(this._worker=pu(this)),this._activeTasks>=this._maximumActiveTasks)return;++this._activeTasks;const n=this;return Promise.resolve(uu()).then(function(i){h(t)?i||(t.length=0):t=dy;const o=n._nextID++,r=di();return n._deferreds[o]=r,n._worker.postMessage({id:o,parameters:e,canTransferArrayBuffer:i},t),r.promise})},yt.prototype.initWebAssemblyModule=function(e){h(this._worker)||(this._worker=pu(this));const t=di(),n=this,i=this._worker;return fy(this,e).then(function(o){return Promise.resolve(uu()).then(function(r){let s;const a=o.wasmBinary;h(a)&&r&&(s=[a]),i.onmessage=function(c){i.onmessage=function(u){fu(n,u.data)},t.resolve(c.data)},i.postMessage({webAssemblyConfig:o},s)})}),t.promise},yt.prototype.isDestroyed=function(){return!1},yt.prototype.destroy=function(){return h(this._worker)&&this._worker.terminate(),gt(this)},yt.taskCompletedEvent=dc,yt._defaultWorkerModulePrefix="Workers/",yt._workerModulePrefix=yt._defaultWorkerModulePrefix,yt._canTransferArrayBuffer=void 0;function qn(){}qn._transcodeTaskProcessor=new yt("transcodeKTX2",Number.POSITIVE_INFINITY),qn._readyPromise=void 0;function py(){const e=qn._transcodeTaskProcessor.initWebAssemblyModule({modulePath:"ThirdParty/Workers/basis_transcoder.js",wasmBinaryFile:"ThirdParty/basis_transcoder.wasm"}).then(function(){return qn._transcodeTaskProcessor});qn._readyPromise=e}qn.transcode=function(e,t){return d.defined("supportedTargetFormats",t),h(qn._readyPromise)||py(),qn._readyPromise.then(function(n){let i;if(e instanceof ArrayBuffer){const o=new Uint8Array(e);return i={supportedTargetFormats:t,ktx2Buffer:o},n.scheduleTask(i,[e])}return i={supportedTargetFormats:t,ktx2Buffer:e},n.scheduleTask(i,[e.buffer])}).then(function(n){const i=n.length,o=Object.keys(n[0]),r=o.length;let s;for(s=0;sthis._size)throw new T("xOffset + options.source.width must be less than or equal to width.");if(n+e.source.height>this._size)throw new T("yOffset + options.source.height must be less than or equal to height.");const i=e.source,o=this._context._gl,r=this._textureTarget,s=this._targetFace;o.activeTexture(o.TEXTURE0),o.bindTexture(r,this._texture);const a=i.width,c=i.height;let u=i.arrayBufferView;const f=this._size,p=this._pixelFormat,_=this._internalFormat,g=this._pixelDatatype,y=this._preMultiplyAlpha,b=this._flipY,E=m(e.skipColorSpaceConversion,!1);let O=4;h(u)&&(O=ye.alignmentInBytes(p,g,a)),o.pixelStorei(o.UNPACK_ALIGNMENT,O),E?o.pixelStorei(o.UNPACK_COLORSPACE_CONVERSION_WEBGL,o.NONE):o.pixelStorei(o.UNPACK_COLORSPACE_CONVERSION_WEBGL,o.BROWSER_DEFAULT_WEBGL);let v=!1;if(!this._initialized){if(t===0&&n===0&&a===f&&c===f)h(u)?(o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,!1),b&&(u=ye.flipY(u,p,g,f,f)),o.texImage2D(s,0,_,f,f,0,p,de.toWebGLConstant(g,this._context),u)):(o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,b),o.texImage2D(s,0,_,p,de.toWebGLConstant(g,this._context),i)),v=!0;else{o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,!1);const A=ye.createTypedArray(p,g,f,f);o.texImage2D(s,0,_,f,f,0,p,de.toWebGLConstant(g,this._context),A)}this._initialized=!0}v||(h(u)?(o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,!1),b&&(u=ye.flipY(u,p,g,a,c)),o.texSubImage2D(s,0,t,n,a,c,p,de.toWebGLConstant(g,this._context),u)):(o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,b),o.texSubImage2D(s,0,t,n,p,de.toWebGLConstant(g,this._context),i))),o.bindTexture(r,null)},Wn.prototype.copyFromFramebuffer=function(e,t,n,i,o,r){if(e=m(e,0),t=m(t,0),n=m(n,0),i=m(i,0),o=m(o,this._size),r=m(r,this._size),d.typeOf.number.greaterThanOrEquals("xOffset",e,0),d.typeOf.number.greaterThanOrEquals("yOffset",t,0),d.typeOf.number.greaterThanOrEquals("framebufferXOffset",n,0),d.typeOf.number.greaterThanOrEquals("framebufferYOffset",i,0),e+o>this._size)throw new T("xOffset + source.width must be less than or equal to width.");if(t+r>this._size)throw new T("yOffset + source.height must be less than or equal to height.");if(this._pixelDatatype===de.FLOAT)throw new T("Cannot call copyFromFramebuffer when the texture pixel data type is FLOAT.");if(this._pixelDatatype===de.HALF_FLOAT)throw new T("Cannot call copyFromFramebuffer when the texture pixel data type is HALF_FLOAT.");const s=this._context._gl,a=this._textureTarget;s.activeTexture(s.TEXTURE0),s.bindTexture(a,this._texture),s.copyTexSubImage2D(this._targetFace,0,e,t,n,i,o,r),s.bindTexture(a,null),this._initialized=!0};const bs={DONT_CARE:I.DONT_CARE,FASTEST:I.FASTEST,NICEST:I.NICEST,validate:function(e){return e===bs.DONT_CARE||e===bs.FASTEST||e===bs.NICEST}},Ts=Object.freeze(bs),Es={NEAREST:I.NEAREST,LINEAR:I.LINEAR};Es.validate=function(e){return e===Es.NEAREST||e===Es.LINEAR};const Bi=Object.freeze(Es),gi={NEAREST:I.NEAREST,LINEAR:I.LINEAR,NEAREST_MIPMAP_NEAREST:I.NEAREST_MIPMAP_NEAREST,LINEAR_MIPMAP_NEAREST:I.LINEAR_MIPMAP_NEAREST,NEAREST_MIPMAP_LINEAR:I.NEAREST_MIPMAP_LINEAR,LINEAR_MIPMAP_LINEAR:I.LINEAR_MIPMAP_LINEAR};gi.validate=function(e){return e===gi.NEAREST||e===gi.LINEAR||e===gi.NEAREST_MIPMAP_NEAREST||e===gi.LINEAR_MIPMAP_NEAREST||e===gi.NEAREST_MIPMAP_LINEAR||e===gi.LINEAR_MIPMAP_LINEAR};const Pt=Object.freeze(gi),Cs={CLAMP_TO_EDGE:I.CLAMP_TO_EDGE,REPEAT:I.REPEAT,MIRRORED_REPEAT:I.MIRRORED_REPEAT,validate:function(e){return e===Cs.CLAMP_TO_EDGE||e===Cs.REPEAT||e===Cs.MIRRORED_REPEAT}},wo=Object.freeze(Cs);function Rn(e){e=m(e,m.EMPTY_OBJECT);const t=m(e.wrapS,wo.CLAMP_TO_EDGE),n=m(e.wrapT,wo.CLAMP_TO_EDGE),i=m(e.minificationFilter,Pt.LINEAR),o=m(e.magnificationFilter,Bi.LINEAR),r=h(e.maximumAnisotropy)?e.maximumAnisotropy:1;if(!wo.validate(t))throw new T("Invalid sampler.wrapS.");if(!wo.validate(n))throw new T("Invalid sampler.wrapT.");if(!Pt.validate(i))throw new T("Invalid sampler.minificationFilter.");if(!Bi.validate(o))throw new T("Invalid sampler.magnificationFilter.");d.typeOf.number.greaterThanOrEquals("maximumAnisotropy",r,1),this._wrapS=t,this._wrapT=n,this._minificationFilter=i,this._magnificationFilter=o,this._maximumAnisotropy=r}Object.defineProperties(Rn.prototype,{wrapS:{get:function(){return this._wrapS}},wrapT:{get:function(){return this._wrapT}},minificationFilter:{get:function(){return this._minificationFilter}},magnificationFilter:{get:function(){return this._magnificationFilter}},maximumAnisotropy:{get:function(){return this._maximumAnisotropy}}}),Rn.equals=function(e,t){return e===t||h(e)&&h(t)&&e._wrapS===t._wrapS&&e._wrapT===t._wrapT&&e._minificationFilter===t._minificationFilter&&e._magnificationFilter===t._magnificationFilter&&e._maximumAnisotropy===t._maximumAnisotropy},Rn.NEAREST=Object.freeze(new Rn({wrapS:wo.CLAMP_TO_EDGE,wrapT:wo.CLAMP_TO_EDGE,minificationFilter:Pt.NEAREST,magnificationFilter:Bi.NEAREST}));function bo(e){e=m(e,m.EMPTY_OBJECT),d.defined("options.context",e.context);const t=e.context,n=e.source;let i,o;if(h(n)){const v=[n.positiveX,n.negativeX,n.positiveY,n.negativeY,n.positiveZ,n.negativeZ];if(!v[0]||!v[1]||!v[2]||!v[3]||!v[4]||!v[5])throw new T("options.source requires positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ faces.");i=v[0].width,o=v[0].height;for(let A=1;A<6;++A)if(Number(v[A].width)!==i||Number(v[A].height)!==o)throw new T("Each face in options.source must have the same width and height.")}else i=e.width,o=e.height;const r=i,s=m(e.pixelDatatype,de.UNSIGNED_BYTE),a=m(e.pixelFormat,ye.RGBA),c=ye.toInternalFormat(a,s,t);if(!h(i)||!h(o))throw new T("options requires a source field to create an initialized cube map or width and height fields to create a blank cube map.");if(i!==o)throw new T("Width must equal height.");if(r<=0)throw new T("Width and height must be greater than zero.");if(r>xt.maximumCubeMapSize)throw new T(`Width and height must be less than or equal to the maximum cube map size (${xt.maximumCubeMapSize}). Check maximumCubeMapSize.`);if(!ye.validate(a))throw new T("Invalid options.pixelFormat.");if(ye.isDepthFormat(a))throw new T("options.pixelFormat cannot be DEPTH_COMPONENT or DEPTH_STENCIL.");if(!de.validate(s))throw new T("Invalid options.pixelDatatype.");if(s===de.FLOAT&&!t.floatingPointTexture)throw new T("When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension.");if(s===de.HALF_FLOAT&&!t.halfFloatingPointTexture)throw new T("When options.pixelDatatype is HALF_FLOAT, this WebGL implementation must support the OES_texture_half_float extension.");const u=ye.textureSizeInBytes(a,s,r,r)*6,f=e.preMultiplyAlpha||a===ye.RGB||a===ye.LUMINANCE,p=m(e.flipY,!0),_=m(e.skipColorSpaceConversion,!1),g=t._gl,y=g.TEXTURE_CUBE_MAP,b=g.createTexture();g.activeTexture(g.TEXTURE0),g.bindTexture(y,b);function E(v,A,R,z,U){let G=A.arrayBufferView;h(G)||(G=A.bufferView);let k=4;h(G)&&(k=ye.alignmentInBytes(a,s,i)),g.pixelStorei(g.UNPACK_ALIGNMENT,k),U?g.pixelStorei(g.UNPACK_COLORSPACE_CONVERSION_WEBGL,g.NONE):g.pixelStorei(g.UNPACK_COLORSPACE_CONVERSION_WEBGL,g.BROWSER_DEFAULT_WEBGL),h(G)?(g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,!1),z&&(G=ye.flipY(G,a,s,r,r)),g.texImage2D(v,0,c,r,r,0,a,de.toWebGLConstant(s,t),G)):(g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R),g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,z),g.texImage2D(v,0,c,a,de.toWebGLConstant(s,t),A))}h(n)?(E(g.TEXTURE_CUBE_MAP_POSITIVE_X,n.positiveX,f,p,_),E(g.TEXTURE_CUBE_MAP_NEGATIVE_X,n.negativeX,f,p,_),E(g.TEXTURE_CUBE_MAP_POSITIVE_Y,n.positiveY,f,p,_),E(g.TEXTURE_CUBE_MAP_NEGATIVE_Y,n.negativeY,f,p,_),E(g.TEXTURE_CUBE_MAP_POSITIVE_Z,n.positiveZ,f,p,_),E(g.TEXTURE_CUBE_MAP_NEGATIVE_Z,n.negativeZ,f,p,_)):(g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X,0,c,r,r,0,a,de.toWebGLConstant(s,t),null),g.texImage2D(g.TEXTURE_CUBE_MAP_NEGATIVE_X,0,c,r,r,0,a,de.toWebGLConstant(s,t),null),g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_Y,0,c,r,r,0,a,de.toWebGLConstant(s,t),null),g.texImage2D(g.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,c,r,r,0,a,de.toWebGLConstant(s,t),null),g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_Z,0,c,r,r,0,a,de.toWebGLConstant(s,t),null),g.texImage2D(g.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,c,r,r,0,a,de.toWebGLConstant(s,t),null)),g.bindTexture(y,null),this._context=t,this._textureFilterAnisotropic=t._textureFilterAnisotropic,this._textureTarget=y,this._texture=b,this._pixelFormat=a,this._pixelDatatype=s,this._size=r,this._hasMipmap=!1,this._sizeInBytes=u,this._preMultiplyAlpha=f,this._flipY=p,this._sampler=void 0;const O=h(n);this._positiveX=new Wn(t,b,y,g.TEXTURE_CUBE_MAP_POSITIVE_X,c,a,s,r,f,p,O),this._negativeX=new Wn(t,b,y,g.TEXTURE_CUBE_MAP_NEGATIVE_X,c,a,s,r,f,p,O),this._positiveY=new Wn(t,b,y,g.TEXTURE_CUBE_MAP_POSITIVE_Y,c,a,s,r,f,p,O),this._negativeY=new Wn(t,b,y,g.TEXTURE_CUBE_MAP_NEGATIVE_Y,c,a,s,r,f,p,O),this._positiveZ=new Wn(t,b,y,g.TEXTURE_CUBE_MAP_POSITIVE_Z,c,a,s,r,f,p,O),this._negativeZ=new Wn(t,b,y,g.TEXTURE_CUBE_MAP_NEGATIVE_Z,c,a,s,r,f,p,O),this.sampler=h(e.sampler)?e.sampler:new Rn}Object.defineProperties(bo.prototype,{positiveX:{get:function(){return this._positiveX}},negativeX:{get:function(){return this._negativeX}},positiveY:{get:function(){return this._positiveY}},negativeY:{get:function(){return this._negativeY}},positiveZ:{get:function(){return this._positiveZ}},negativeZ:{get:function(){return this._negativeZ}},sampler:{get:function(){return this._sampler},set:function(e){let t=e.minificationFilter,n=e.magnificationFilter;const i=t===Pt.NEAREST_MIPMAP_NEAREST||t===Pt.NEAREST_MIPMAP_LINEAR||t===Pt.LINEAR_MIPMAP_NEAREST||t===Pt.LINEAR_MIPMAP_LINEAR,o=this._context,r=this._pixelDatatype;(r===de.FLOAT&&!o.textureFloatLinear||r===de.HALF_FLOAT&&!o.textureHalfFloatLinear)&&(t=i?Pt.NEAREST_MIPMAP_NEAREST:Pt.NEAREST,n=Bi.NEAREST);const s=o._gl,a=this._textureTarget;s.activeTexture(s.TEXTURE0),s.bindTexture(a,this._texture),s.texParameteri(a,s.TEXTURE_MIN_FILTER,t),s.texParameteri(a,s.TEXTURE_MAG_FILTER,n),s.texParameteri(a,s.TEXTURE_WRAP_S,e.wrapS),s.texParameteri(a,s.TEXTURE_WRAP_T,e.wrapT),h(this._textureFilterAnisotropic)&&s.texParameteri(a,this._textureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.maximumAnisotropy),s.bindTexture(a,null),this._sampler=e}},pixelFormat:{get:function(){return this._pixelFormat}},pixelDatatype:{get:function(){return this._pixelDatatype}},width:{get:function(){return this._size}},height:{get:function(){return this._size}},sizeInBytes:{get:function(){return this._hasMipmap?Math.floor(this._sizeInBytes*4/3):this._sizeInBytes}},preMultiplyAlpha:{get:function(){return this._preMultiplyAlpha}},flipY:{get:function(){return this._flipY}},_target:{get:function(){return this._textureTarget}}}),bo.prototype.generateMipmap=function(e){if(e=m(e,Ts.DONT_CARE),this._size>1&&!P.isPowerOfTwo(this._size))throw new T("width and height must be a power of two to call generateMipmap().");if(!Ts.validate(e))throw new T("hint is invalid.");this._hasMipmap=!0;const t=this._context._gl,n=this._textureTarget;t.hint(t.GENERATE_MIPMAP_HINT,e),t.activeTexture(t.TEXTURE0),t.bindTexture(n,this._texture),t.generateMipmap(n),t.bindTexture(n,null)},bo.prototype.isDestroyed=function(){return!1},bo.prototype.destroy=function(){return this._context._gl.deleteTexture(this._texture),this._positiveX=gt(this._positiveX),this._negativeX=gt(this._negativeX),this._positiveY=gt(this._positiveY),this._negativeY=gt(this._negativeY),this._positiveZ=gt(this._positiveZ),this._negativeZ=gt(this._negativeZ),gt(this)};function jt(e){e=m(e,m.EMPTY_OBJECT),d.defined("options.context",e.context);const t=e.context;let n=e.width,i=e.height;const o=e.source;h(o)&&(h(n)||(n=m(o.videoWidth,o.width)),h(i)||(i=m(o.videoHeight,o.height)));const r=m(e.pixelFormat,ye.RGBA),s=m(e.pixelDatatype,de.UNSIGNED_BYTE),a=ye.toInternalFormat(r,s,t),c=ye.isCompressedFormat(a);if(!h(n)||!h(i))throw new T("options requires a source field to create an initialized texture or width and height fields to create a blank texture.");if(d.typeOf.number.greaterThan("width",n,0),n>xt.maximumTextureSize)throw new T(`Width must be less than or equal to the maximum texture size (${xt.maximumTextureSize}). Check maximumTextureSize.`);if(d.typeOf.number.greaterThan("height",i,0),i>xt.maximumTextureSize)throw new T(`Height must be less than or equal to the maximum texture size (${xt.maximumTextureSize}). Check maximumTextureSize.`);if(!ye.validate(r))throw new T("Invalid options.pixelFormat.");if(!c&&!de.validate(s))throw new T("Invalid options.pixelDatatype.");if(r===ye.DEPTH_COMPONENT&&s!==de.UNSIGNED_SHORT&&s!==de.UNSIGNED_INT)throw new T("When options.pixelFormat is DEPTH_COMPONENT, options.pixelDatatype must be UNSIGNED_SHORT or UNSIGNED_INT.");if(r===ye.DEPTH_STENCIL&&s!==de.UNSIGNED_INT_24_8)throw new T("When options.pixelFormat is DEPTH_STENCIL, options.pixelDatatype must be UNSIGNED_INT_24_8.");if(s===de.FLOAT&&!t.floatingPointTexture)throw new T("When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension. Check context.floatingPointTexture.");if(s===de.HALF_FLOAT&&!t.halfFloatingPointTexture)throw new T("When options.pixelDatatype is HALF_FLOAT, this WebGL implementation must support the OES_texture_half_float extension. Check context.halfFloatingPointTexture.");if(ye.isDepthFormat(r)){if(h(o))throw new T("When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, source cannot be provided.");if(!t.depthTexture)throw new T("When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, this WebGL implementation must support WEBGL_depth_texture. Check context.depthTexture.")}if(c){if(!h(o)||!h(o.arrayBufferView))throw new T("When options.pixelFormat is compressed, options.source.arrayBufferView must be defined.");if(ye.isDXTFormat(a)&&!t.s3tc)throw new T("When options.pixelFormat is S3TC compressed, this WebGL implementation must support the WEBGL_compressed_texture_s3tc extension. Check context.s3tc.");if(ye.isPVRTCFormat(a)&&!t.pvrtc)throw new T("When options.pixelFormat is PVRTC compressed, this WebGL implementation must support the WEBGL_compressed_texture_pvrtc extension. Check context.pvrtc.");if(ye.isASTCFormat(a)&&!t.astc)throw new T("When options.pixelFormat is ASTC compressed, this WebGL implementation must support the WEBGL_compressed_texture_astc extension. Check context.astc.");if(ye.isETC2Format(a)&&!t.etc)throw new T("When options.pixelFormat is ETC2 compressed, this WebGL implementation must support the WEBGL_compressed_texture_etc extension. Check context.etc.");if(ye.isETC1Format(a)&&!t.etc1)throw new T("When options.pixelFormat is ETC1 compressed, this WebGL implementation must support the WEBGL_compressed_texture_etc1 extension. Check context.etc1.");if(ye.isBC7Format(a)&&!t.bc7)throw new T("When options.pixelFormat is BC7 compressed, this WebGL implementation must support the EXT_texture_compression_bptc extension. Check context.bc7.");if(ye.compressedTextureSizeInBytes(a,n,i)!==o.arrayBufferView.byteLength)throw new T("The byte length of the array buffer is invalid for the compressed texture with the given width and height.")}const u=e.preMultiplyAlpha||r===ye.RGB||r===ye.LUMINANCE,f=m(e.flipY,!0),p=m(e.skipColorSpaceConversion,!1);let _=!0;const g=t._gl,y=g.TEXTURE_2D,b=g.createTexture();g.activeTexture(g.TEXTURE0),g.bindTexture(y,b);let E=4;if(h(o)&&h(o.arrayBufferView)&&!c&&(E=ye.alignmentInBytes(r,s,n)),g.pixelStorei(g.UNPACK_ALIGNMENT,E),p?g.pixelStorei(g.UNPACK_COLORSPACE_CONVERSION_WEBGL,g.NONE):g.pixelStorei(g.UNPACK_COLORSPACE_CONVERSION_WEBGL,g.BROWSER_DEFAULT_WEBGL),h(o))if(h(o.arrayBufferView)){g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,!1);let v=o.arrayBufferView,A,R,z;if(c){if(g.compressedTexImage2D(y,0,a,n,i,0,v),h(o.mipLevels))for(R=n,z=i,A=0;An.drawingBufferWidth)throw new T("framebufferXOffset + width must be less than or equal to drawingBufferWidth");if(r+a>n.drawingBufferHeight)throw new T("framebufferYOffset + height must be less than or equal to drawingBufferHeight.");return new jt({context:t,width:s,height:a,pixelFormat:i,source:{framebuffer:h(c)?c:t.defaultFramebuffer,xOffset:o,yOffset:r,width:s,height:a}})},Object.defineProperties(jt.prototype,{id:{get:function(){return this._id}},sampler:{get:function(){return this._sampler},set:function(e){let t=e.minificationFilter,n=e.magnificationFilter;const i=this._context,o=this._pixelFormat,r=this._pixelDatatype,s=t===Pt.NEAREST_MIPMAP_NEAREST||t===Pt.NEAREST_MIPMAP_LINEAR||t===Pt.LINEAR_MIPMAP_NEAREST||t===Pt.LINEAR_MIPMAP_LINEAR;(r===de.FLOAT&&!i.textureFloatLinear||r===de.HALF_FLOAT&&!i.textureHalfFloatLinear)&&(t=s?Pt.NEAREST_MIPMAP_NEAREST:Pt.NEAREST,n=Bi.NEAREST),i.webgl2&&ye.isDepthFormat(o)&&(t=Pt.NEAREST,n=Bi.NEAREST);const a=i._gl,c=this._textureTarget;a.activeTexture(a.TEXTURE0),a.bindTexture(c,this._texture),a.texParameteri(c,a.TEXTURE_MIN_FILTER,t),a.texParameteri(c,a.TEXTURE_MAG_FILTER,n),a.texParameteri(c,a.TEXTURE_WRAP_S,e.wrapS),a.texParameteri(c,a.TEXTURE_WRAP_T,e.wrapT),h(this._textureFilterAnisotropic)&&a.texParameteri(c,this._textureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.maximumAnisotropy),a.bindTexture(c,null),this._sampler=e}},pixelFormat:{get:function(){return this._pixelFormat}},pixelDatatype:{get:function(){return this._pixelDatatype}},dimensions:{get:function(){return this._dimensions}},preMultiplyAlpha:{get:function(){return this._preMultiplyAlpha}},flipY:{get:function(){return this._flipY}},width:{get:function(){return this._width}},height:{get:function(){return this._height}},sizeInBytes:{get:function(){return this._hasMipmap?Math.floor(this._sizeInBytes*4/3):this._sizeInBytes}},_target:{get:function(){return this._textureTarget}}}),jt.prototype.copyFrom=function(e){d.defined("options",e);const t=m(e.xOffset,0),n=m(e.yOffset,0);if(d.defined("options.source",e.source),ye.isDepthFormat(this._pixelFormat))throw new T("Cannot call copyFrom when the texture pixel format is DEPTH_COMPONENT or DEPTH_STENCIL.");if(ye.isCompressedFormat(this._pixelFormat))throw new T("Cannot call copyFrom with a compressed texture pixel format.");d.typeOf.number.greaterThanOrEquals("xOffset",t,0),d.typeOf.number.greaterThanOrEquals("yOffset",n,0),d.typeOf.number.lessThanOrEquals("xOffset + options.source.width",t+e.source.width,this._width),d.typeOf.number.lessThanOrEquals("yOffset + options.source.height",n+e.source.height,this._height);const i=e.source,o=this._context,r=o._gl,s=this._textureTarget;r.activeTexture(r.TEXTURE0),r.bindTexture(s,this._texture);const a=i.width,c=i.height;let u=i.arrayBufferView;const f=this._width,p=this._height,_=this._internalFormat,g=this._pixelFormat,y=this._pixelDatatype,b=this._preMultiplyAlpha,E=this._flipY,O=m(e.skipColorSpaceConversion,!1);let v=4;h(u)&&(v=ye.alignmentInBytes(g,y,a)),r.pixelStorei(r.UNPACK_ALIGNMENT,v),O?r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE):r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.BROWSER_DEFAULT_WEBGL);let A=!1;if(!this._initialized){if(t===0&&n===0&&a===f&&c===p)h(u)?(r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),E&&(u=ye.flipY(u,g,y,f,p)),r.texImage2D(s,0,_,f,p,0,g,de.toWebGLConstant(y,o),u)):(r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E),r.texImage2D(s,0,_,g,de.toWebGLConstant(y,o),i)),A=!0;else{r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);const R=ye.createTypedArray(g,y,f,p);r.texImage2D(s,0,_,f,p,0,g,de.toWebGLConstant(y,o),R)}this._initialized=!0}A||(h(u)?(r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),E&&(u=ye.flipY(u,g,y,a,c)),r.texSubImage2D(s,0,t,n,a,c,g,de.toWebGLConstant(y,o),u)):(r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E),r.texSubImage2D(s,0,t,n,g,de.toWebGLConstant(y,o),i))),r.bindTexture(s,null)},jt.prototype.copyFromFramebuffer=function(e,t,n,i,o,r){if(e=m(e,0),t=m(t,0),n=m(n,0),i=m(i,0),o=m(o,this._width),r=m(r,this._height),ye.isDepthFormat(this._pixelFormat))throw new T("Cannot call copyFromFramebuffer when the texture pixel format is DEPTH_COMPONENT or DEPTH_STENCIL.");if(this._pixelDatatype===de.FLOAT)throw new T("Cannot call copyFromFramebuffer when the texture pixel data type is FLOAT.");if(this._pixelDatatype===de.HALF_FLOAT)throw new T("Cannot call copyFromFramebuffer when the texture pixel data type is HALF_FLOAT.");if(ye.isCompressedFormat(this._pixelFormat))throw new T("Cannot call copyFrom with a compressed texture pixel format.");d.typeOf.number.greaterThanOrEquals("xOffset",e,0),d.typeOf.number.greaterThanOrEquals("yOffset",t,0),d.typeOf.number.greaterThanOrEquals("framebufferXOffset",n,0),d.typeOf.number.greaterThanOrEquals("framebufferYOffset",i,0),d.typeOf.number.lessThanOrEquals("xOffset + width",e+o,this._width),d.typeOf.number.lessThanOrEquals("yOffset + height",t+r,this._height);const s=this._context._gl,a=this._textureTarget;s.activeTexture(s.TEXTURE0),s.bindTexture(a,this._texture),s.copyTexSubImage2D(a,0,e,t,n,i,o,r),s.bindTexture(a,null),this._initialized=!0},jt.prototype.generateMipmap=function(e){if(e=m(e,Ts.DONT_CARE),ye.isDepthFormat(this._pixelFormat))throw new T("Cannot call generateMipmap when the texture pixel format is DEPTH_COMPONENT or DEPTH_STENCIL.");if(ye.isCompressedFormat(this._pixelFormat))throw new T("Cannot call generateMipmap with a compressed pixel format.");if(!this._context.webgl2){if(this._width>1&&!P.isPowerOfTwo(this._width))throw new T("width must be a power of two to call generateMipmap() in a WebGL1 context.");if(this._height>1&&!P.isPowerOfTwo(this._height))throw new T("height must be a power of two to call generateMipmap() in a WebGL1 context.")}if(!Ts.validate(e))throw new T("hint is invalid.");this._hasMipmap=!0;const t=this._context._gl,n=this._textureTarget;t.hint(t.GENERATE_MIPMAP_HINT,e),t.activeTexture(t.TEXTURE0),t.bindTexture(n,this._texture),t.generateMipmap(n),t.bindTexture(n,null)},jt.prototype.isDestroyed=function(){return!1},jt.prototype.destroy=function(){return this._context._gl.deleteTexture(this._texture),gt(this)};const my=`uniform sampler2D image; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec4 rampColor = texture(image, vec2(materialInput.aspect / (2.0 * czm_pi), 0.5)); rampColor = czm_gammaCorrect(rampColor); material.diffuse = rampColor.rgb; material.alpha = rampColor.a; return material; } `,_y=`uniform sampler2D image; uniform float strength; uniform vec2 repeat; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; vec2 centerPixel = fract(repeat * st); float centerBump = texture(image, centerPixel).channel; float imageWidth = float(imageDimensions.x); vec2 rightPixel = fract(repeat * (st + vec2(1.0 / imageWidth, 0.0))); float rightBump = texture(image, rightPixel).channel; float imageHeight = float(imageDimensions.y); vec2 leftPixel = fract(repeat * (st + vec2(0.0, 1.0 / imageHeight))); float topBump = texture(image, leftPixel).channel; vec3 normalTangentSpace = normalize(vec3(centerBump - rightBump, centerBump - topBump, clamp(1.0 - strength, 0.1, 1.0))); vec3 normalEC = materialInput.tangentToEyeMatrix * normalTangentSpace; material.normal = normalEC; material.diffuse = vec3(0.01); return material; } `,gy=`uniform vec4 lightColor; uniform vec4 darkColor; uniform vec2 repeat; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; // From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights float b = mod(floor(repeat.s * st.s) + floor(repeat.t * st.t), 2.0); // 0.0 or 1.0 // Find the distance from the closest separator (region between two colors) float scaledWidth = fract(repeat.s * st.s); scaledWidth = abs(scaledWidth - floor(scaledWidth + 0.5)); float scaledHeight = fract(repeat.t * st.t); scaledHeight = abs(scaledHeight - floor(scaledHeight + 0.5)); float value = min(scaledWidth, scaledHeight); vec4 currentColor = mix(lightColor, darkColor, b); vec4 color = czm_antialias(lightColor, darkColor, currentColor, value, 0.03); color = czm_gammaCorrect(color); material.diffuse = color.rgb; material.alpha = color.a; return material; } `,yy=`uniform vec4 lightColor; uniform vec4 darkColor; uniform vec2 repeat; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); // From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights float b = smoothstep(0.3, 0.32, length(fract(repeat * materialInput.st) - 0.5)); // 0.0 or 1.0 vec4 color = mix(lightColor, darkColor, b); color = czm_gammaCorrect(color); material.diffuse = color.rgb; material.alpha = color.a; return material; } `,wy=`uniform sampler2D heights; uniform sampler2D colors; // This material expects heights to be sorted from lowest to highest. float getHeight(int idx, float invTexSize) { vec2 uv = vec2((float(idx) + 0.5) * invTexSize, 0.5); #ifdef OES_texture_float return texture(heights, uv).x; #else return czm_unpackFloat(texture(heights, uv)); #endif } czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); float height = materialInput.height; float invTexSize = 1.0 / float(heightsDimensions.x); float minHeight = getHeight(0, invTexSize); float maxHeight = getHeight(heightsDimensions.x - 1, invTexSize); // early-out when outside the height range if (height < minHeight || height > maxHeight) { material.diffuse = vec3(0.0); material.alpha = 0.0; return material; } // Binary search to find heights above and below. int idxBelow = 0; int idxAbove = heightsDimensions.x; float heightBelow = minHeight; float heightAbove = maxHeight; // while loop not allowed, so use for loop with max iterations. // maxIterations of 16 supports a texture size up to 65536 (2^16). const int maxIterations = 16; for (int i = 0; i < maxIterations; i++) { if (idxBelow >= idxAbove - 1) { break; } int idxMid = (idxBelow + idxAbove) / 2; float heightTex = getHeight(idxMid, invTexSize); if (height > heightTex) { idxBelow = idxMid; heightBelow = heightTex; } else { idxAbove = idxMid; heightAbove = heightTex; } } float lerper = heightBelow == heightAbove ? 1.0 : (height - heightBelow) / (heightAbove - heightBelow); vec2 colorUv = vec2(invTexSize * (float(idxBelow) + 0.5 + lerper), 0.5); vec4 color = texture(colors, colorUv); // undo preumultiplied alpha if (color.a > 0.0) { color.rgb /= color.a; } color.rgb = czm_gammaCorrect(color.rgb); material.diffuse = color.rgb; material.alpha = color.a; return material; } `,by=`uniform vec4 color; uniform float spacing; uniform float width; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); float distanceToContour = mod(materialInput.height, spacing); #if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives)) float dxc = abs(dFdx(materialInput.height)); float dyc = abs(dFdy(materialInput.height)); float dF = max(dxc, dyc) * czm_pixelRatio * width; float alpha = (distanceToContour < dF) ? 1.0 : 0.0; #else // If no derivatives available (IE 10?), use pixel ratio float alpha = (distanceToContour < (czm_pixelRatio * width)) ? 1.0 : 0.0; #endif vec4 outColor = czm_gammaCorrect(vec4(color.rgb, alpha * color.a)); material.diffuse = outColor.rgb; material.alpha = outColor.a; return material; } `,Ty=`uniform sampler2D image; uniform float minimumHeight; uniform float maximumHeight; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); float scaledHeight = clamp((materialInput.height - minimumHeight) / (maximumHeight - minimumHeight), 0.0, 1.0); vec4 rampColor = texture(image, vec2(scaledHeight, 0.5)); rampColor = czm_gammaCorrect(rampColor); material.diffuse = rampColor.rgb; material.alpha = rampColor.a; return material; } `,Ey=`uniform vec4 fadeInColor; uniform vec4 fadeOutColor; uniform float maximumDistance; uniform bool repeat; uniform vec2 fadeDirection; uniform vec2 time; float getTime(float t, float coord) { float scalar = 1.0 / maximumDistance; float q = distance(t, coord) * scalar; if (repeat) { float r = distance(t, coord + 1.0) * scalar; float s = distance(t, coord - 1.0) * scalar; q = min(min(r, s), q); } return clamp(q, 0.0, 1.0); } czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; float s = getTime(time.x, st.s) * fadeDirection.s; float t = getTime(time.y, st.t) * fadeDirection.t; float u = length(vec2(s, t)); vec4 color = mix(fadeInColor, fadeOutColor, u); color = czm_gammaCorrect(color); material.emission = color.rgb; material.alpha = color.a; return material; } `,Cy=`uniform vec4 color; uniform float cellAlpha; uniform vec2 lineCount; uniform vec2 lineThickness; uniform vec2 lineOffset; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; float scaledWidth = fract(lineCount.s * st.s - lineOffset.s); scaledWidth = abs(scaledWidth - floor(scaledWidth + 0.5)); float scaledHeight = fract(lineCount.t * st.t - lineOffset.t); scaledHeight = abs(scaledHeight - floor(scaledHeight + 0.5)); float value; // Fuzz Factor - Controls blurriness of lines #if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives)) const float fuzz = 1.2; vec2 thickness = (lineThickness * czm_pixelRatio) - 1.0; // From "3D Engine Design for Virtual Globes" by Cozzi and Ring, Listing 4.13. vec2 dx = abs(dFdx(st)); vec2 dy = abs(dFdy(st)); vec2 dF = vec2(max(dx.s, dy.s), max(dx.t, dy.t)) * lineCount; value = min( smoothstep(dF.s * thickness.s, dF.s * (fuzz + thickness.s), scaledWidth), smoothstep(dF.t * thickness.t, dF.t * (fuzz + thickness.t), scaledHeight)); #else // If no derivatives available (IE 10?), revert to view-dependent fuzz const float fuzz = 0.05; vec2 range = 0.5 - (lineThickness * 0.05); value = min( 1.0 - smoothstep(range.s, range.s + fuzz, scaledWidth), 1.0 - smoothstep(range.t, range.t + fuzz, scaledHeight)); #endif // Edges taken from RimLightingMaterial.glsl // See http://www.fundza.com/rman_shaders/surface/fake_rim/fake_rim1.html float dRim = 1.0 - abs(dot(materialInput.normalEC, normalize(materialInput.positionToEyeEC))); float sRim = smoothstep(0.8, 1.0, dRim); value *= (1.0 - sRim); vec4 halfColor; halfColor.rgb = color.rgb * 0.5; halfColor.a = color.a * (1.0 - ((1.0 - cellAlpha) * value)); halfColor = czm_gammaCorrect(halfColor); material.diffuse = halfColor.rgb; material.emission = halfColor.rgb; material.alpha = halfColor.a; return material; } `,Sy=`uniform sampler2D image; uniform float strength; uniform vec2 repeat; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec4 textureValue = texture(image, fract(repeat * materialInput.st)); vec3 normalTangentSpace = textureValue.channels; normalTangentSpace.xy = normalTangentSpace.xy * 2.0 - 1.0; normalTangentSpace.z = clamp(1.0 - strength, 0.1, 1.0); normalTangentSpace = normalize(normalTangentSpace); vec3 normalEC = materialInput.tangentToEyeMatrix * normalTangentSpace; material.normal = normalEC; return material; } `,Oy=`uniform vec4 color; float getPointOnLine(vec2 p0, vec2 p1, float x) { float slope = (p0.y - p1.y) / (p0.x - p1.x); return slope * (x - p0.x) + p0.y; } czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; #if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives)) float base = 1.0 - abs(fwidth(st.s)) * 10.0 * czm_pixelRatio; #else // If no derivatives available (IE 10?), 2.5% of the line will be the arrow head float base = 0.975; #endif vec2 center = vec2(1.0, 0.5); float ptOnUpperLine = getPointOnLine(vec2(base, 1.0), center, st.s); float ptOnLowerLine = getPointOnLine(vec2(base, 0.0), center, st.s); float halfWidth = 0.15; float s = step(0.5 - halfWidth, st.t); s *= 1.0 - step(0.5 + halfWidth, st.t); s *= 1.0 - step(base, st.s); float t = step(base, materialInput.st.s); t *= 1.0 - step(ptOnUpperLine, st.t); t *= step(ptOnLowerLine, st.t); // Find the distance from the closest separator (region between two colors) float dist; if (st.s < base) { float d1 = abs(st.t - (0.5 - halfWidth)); float d2 = abs(st.t - (0.5 + halfWidth)); dist = min(d1, d2); } else { float d1 = czm_infinity; if (st.t < 0.5 - halfWidth && st.t > 0.5 + halfWidth) { d1 = abs(st.s - base); } float d2 = abs(st.t - ptOnUpperLine); float d3 = abs(st.t - ptOnLowerLine); dist = min(min(d1, d2), d3); } vec4 outsideColor = vec4(0.0); vec4 currentColor = mix(outsideColor, color, clamp(s + t, 0.0, 1.0)); vec4 outColor = czm_antialias(outsideColor, color, currentColor, dist); outColor = czm_gammaCorrect(outColor); material.diffuse = outColor.rgb; material.alpha = outColor.a; return material; } `,Ay=`uniform vec4 color; uniform vec4 gapColor; uniform float dashLength; uniform float dashPattern; in float v_polylineAngle; const float maskLength = 16.0; mat2 rotate(float rad) { float c = cos(rad); float s = sin(rad); return mat2( c, s, -s, c ); } czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 pos = rotate(v_polylineAngle) * gl_FragCoord.xy; // Get the relative position within the dash from 0 to 1 float dashPosition = fract(pos.x / (dashLength * czm_pixelRatio)); // Figure out the mask index. float maskIndex = floor(dashPosition * maskLength); // Test the bit mask. float maskTest = floor(dashPattern / pow(2.0, maskIndex)); vec4 fragColor = (mod(maskTest, 2.0) < 1.0) ? gapColor : color; if (fragColor.a < 0.005) { // matches 0/255 and 1/255 discard; } fragColor = czm_gammaCorrect(fragColor); material.emission = fragColor.rgb; material.alpha = fragColor.a; return material; } `,vy=`uniform vec4 color; uniform float glowPower; uniform float taperPower; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; float glow = glowPower / abs(st.t - 0.5) - (glowPower / 0.5); if (taperPower <= 0.99999) { glow *= min(1.0, taperPower / (0.5 - st.s * 0.5) - (taperPower / 0.5)); } vec4 fragColor; fragColor.rgb = max(vec3(glow - 1.0 + color.rgb), color.rgb); fragColor.a = clamp(0.0, 1.0, glow) * color.a; fragColor = czm_gammaCorrect(fragColor); material.emission = fragColor.rgb; material.alpha = fragColor.a; return material; } `,xy=`uniform vec4 color; uniform vec4 outlineColor; uniform float outlineWidth; in float v_width; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; float halfInteriorWidth = 0.5 * (v_width - outlineWidth) / v_width; float b = step(0.5 - halfInteriorWidth, st.t); b *= 1.0 - step(0.5 + halfInteriorWidth, st.t); // Find the distance from the closest separator (region between two colors) float d1 = abs(st.t - (0.5 - halfInteriorWidth)); float d2 = abs(st.t - (0.5 + halfInteriorWidth)); float dist = min(d1, d2); vec4 currentColor = mix(outlineColor, color, b); vec4 outColor = czm_antialias(outlineColor, color, currentColor, dist); outColor = czm_gammaCorrect(outColor); material.diffuse = outColor.rgb; material.alpha = outColor.a; return material; } `,Py=`uniform vec4 color; uniform vec4 rimColor; uniform float width; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); // See http://www.fundza.com/rman_shaders/surface/fake_rim/fake_rim1.html float d = 1.0 - dot(materialInput.normalEC, normalize(materialInput.positionToEyeEC)); float s = smoothstep(1.0 - width, 1.0, d); vec4 outColor = czm_gammaCorrect(color); vec4 outRimColor = czm_gammaCorrect(rimColor); material.diffuse = outColor.rgb; material.emission = outRimColor.rgb * s; material.alpha = mix(outColor.a, outRimColor.a, s); return material; } `,Ry=`uniform sampler2D image; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec4 rampColor = texture(image, vec2(materialInput.slope / (czm_pi / 2.0), 0.5)); rampColor = czm_gammaCorrect(rampColor); material.diffuse = rampColor.rgb; material.alpha = rampColor.a; return material; } `,Iy=`uniform vec4 evenColor; uniform vec4 oddColor; uniform float offset; uniform float repeat; uniform bool horizontal; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); // Based on the Stripes Fragment Shader in the Orange Book (11.1.2) float coord = mix(materialInput.st.s, materialInput.st.t, float(horizontal)); float value = fract((coord - offset) * (repeat * 0.5)); float dist = min(value, min(abs(value - 0.5), 1.0 - value)); vec4 currentColor = mix(evenColor, oddColor, step(0.5, value)); vec4 color = czm_antialias(evenColor, oddColor, currentColor, dist); color = czm_gammaCorrect(color); material.diffuse = color.rgb; material.alpha = color.a; return material; } `,zy=`// Thanks for the contribution Jonas // http://29a.ch/2012/7/19/webgl-terrain-rendering-water-fog uniform sampler2D specularMap; uniform sampler2D normalMap; uniform vec4 baseWaterColor; uniform vec4 blendColor; uniform float frequency; uniform float animationSpeed; uniform float amplitude; uniform float specularIntensity; uniform float fadeFactor; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); float time = czm_frameNumber * animationSpeed; // fade is a function of the distance from the fragment and the frequency of the waves float fade = max(1.0, (length(materialInput.positionToEyeEC) / 10000000000.0) * frequency * fadeFactor); float specularMapValue = texture(specularMap, materialInput.st).r; // note: not using directional motion at this time, just set the angle to 0.0; vec4 noise = czm_getWaterNoise(normalMap, materialInput.st * frequency, time, 0.0); vec3 normalTangentSpace = noise.xyz * vec3(1.0, 1.0, (1.0 / amplitude)); // fade out the normal perturbation as we move further from the water surface normalTangentSpace.xy /= fade; // attempt to fade out the normal perturbation as we approach non water areas (low specular map value) normalTangentSpace = mix(vec3(0.0, 0.0, 50.0), normalTangentSpace, specularMapValue); normalTangentSpace = normalize(normalTangentSpace); // get ratios for alignment of the new normal vector with a vector perpendicular to the tangent plane float tsPerturbationRatio = clamp(dot(normalTangentSpace, vec3(0.0, 0.0, 1.0)), 0.0, 1.0); // fade out water effect as specular map value decreases material.alpha = mix(blendColor.a, baseWaterColor.a, specularMapValue) * specularMapValue; // base color is a blend of the water and non-water color based on the value from the specular map // may need a uniform blend factor to better control this material.diffuse = mix(blendColor.rgb, baseWaterColor.rgb, specularMapValue); // diffuse highlights are based on how perturbed the normal is material.diffuse += (0.1 * tsPerturbationRatio); material.diffuse = material.diffuse; material.normal = normalize(materialInput.tangentToEyeMatrix * normalTangentSpace); material.specular = specularIntensity; material.shininess = 10.0; return material; } `;function X(e){this.type=void 0,this.shaderSource=void 0,this.materials=void 0,this.uniforms=void 0,this._uniforms=void 0,this.translucent=void 0,this._minificationFilter=m(e.minificationFilter,Pt.LINEAR),this._magnificationFilter=m(e.magnificationFilter,Bi.LINEAR),this._strict=void 0,this._template=void 0,this._count=void 0,this._texturePaths={},this._loadedImages=[],this._loadedCubeMaps=[],this._textures={},this._updateFunctions=[],this._defaultTexture=void 0,Dy(e,this),Object.defineProperties(this,{type:{value:this.type,writable:!1}}),h(X._uniformList[this.type])||(X._uniformList[this.type]=Object.keys(this._uniforms))}X._uniformList={},X.fromType=function(e,t){if(!h(X._materialCache.getMaterial(e)))throw new T(`material with type '${e}' does not exist.`);const n=new X({fabric:{type:e}});if(h(t))for(const i in t)t.hasOwnProperty(i)&&(n.uniforms[i]=t[i]);return n},X.prototype.isTranslucent=function(){if(h(this.translucent))return typeof this.translucent=="function"?this.translucent():this.translucent;let e=!0;const t=this._translucentFunctions,n=t.length;for(let i=0;i-1)return!0;return!1}function Uy(e){const t=e._template.components,n=e._template.source;if(h(n))e.shaderSource+=`${n} `;else{if(e.shaderSource+=`czm_material czm_getMaterial(czm_materialInput materialInput) { `,e.shaderSource+=`czm_material material = czm_getDefaultMaterial(materialInput); `,h(t)){const i=Object.keys(e._template.materials).length>0;for(const o in t)if(t.hasOwnProperty(o))if(o==="diffuse"||o==="emission"){const s=i&&By(t[o],e)?t[o]:`czm_gammaCorrect(${t[o]})`;e.shaderSource+=`material.${o} = ${s}; `}else o==="alpha"?e.shaderSource+=`material.alpha = ${t.alpha}; `:e.shaderSource+=`material.${o} = ${t[o]}; `}e.shaderSource+=`return material; } `}}const yu={mat2:se,mat3:M,mat4:F},ky=/\.ktx2$/i;function jy(e){let t;return function(n,i){const o=n.uniforms,r=o[e],s=t!==r,a=!h(r)||r===X.DefaultImageId;t=r;let c=n._textures[e],u,f;if(r instanceof HTMLVideoElement){if(r.readyState>=2){if(s&&h(c)&&(c!==i.defaultTexture&&c.destroy(),c=void 0),!h(c)||c===i.defaultTexture){const _=new Rn({minificationFilter:n._minificationFilter,magnificationFilter:n._magnificationFilter});c=new jt({context:i,source:r,sampler:_}),n._textures[e]=c;return}c.copyFrom({source:r})}else h(c)||(n._textures[e]=i.defaultTexture);return}if(r instanceof jt&&r!==c){n._texturePaths[e]=void 0;const _=n._textures[e];h(_)&&_!==n._defaultTexture&&_.destroy(),n._textures[e]=r,u=`${e}Dimensions`,o.hasOwnProperty(u)&&(f=o[u],f.x=r._width,f.y=r._height);return}if(s&&h(c)&&a&&(c!==n._defaultTexture&&c.destroy(),c=void 0),h(c)||(n._texturePaths[e]=void 0,c=n._textures[e]=n._defaultTexture,u=`${e}Dimensions`,o.hasOwnProperty(u)&&(f=o[u],f.x=c._width,f.y=c._height)),a)return;const p=r instanceof ie;if(!h(n._texturePaths[e])||p&&r.url!==n._texturePaths[e].url||!p&&r!==n._texturePaths[e]){if(typeof r=="string"||p){const _=p?r:ie.createIfNeeded(r);let g;ky.test(_.url)?g=_u(_.url):g=_.fetchImage(),Promise.resolve(g).then(function(y){n._loadedImages.push({id:e,image:y})}).catch(function(){h(c)&&c!==n._defaultTexture&&c.destroy(),n._textures[e]=n._defaultTexture})}else(r instanceof HTMLCanvasElement||r instanceof HTMLImageElement)&&n._loadedImages.push({id:e,image:r});n._texturePaths[e]=r}}}function Gy(e){return function(t,n){const i=t.uniforms[e];if(i instanceof bo){const r=t._textures[e];r!==t._defaultTexture&&r.destroy(),t._texturePaths[e]=void 0,t._textures[e]=i;return}if(h(t._textures[e])||(t._texturePaths[e]=void 0,t._textures[e]=n.defaultCubeMap),i===X.DefaultCubeMapId)return;const o=i.positiveX+i.negativeX+i.positiveY+i.negativeY+i.positiveZ+i.negativeZ;if(o!==t._texturePaths[e]){const r=[ie.createIfNeeded(i.positiveX).fetchImage(),ie.createIfNeeded(i.negativeX).fetchImage(),ie.createIfNeeded(i.positiveY).fetchImage(),ie.createIfNeeded(i.negativeY).fetchImage(),ie.createIfNeeded(i.positiveZ).fetchImage(),ie.createIfNeeded(i.negativeZ).fetchImage()];Promise.all(r).then(function(s){t._loadedCubeMaps.push({id:e,images:s})}),t._texturePaths[e]=o}}}function Vy(e){const t=e._template.uniforms;for(const n in t)t.hasOwnProperty(n)&&wu(e,n)}function wu(e,t){const n=e._strict,i=e._template.uniforms,o=i[t],r=Hy(o);if(!h(r))throw new T(`fabric: uniform '${t}' has invalid type.`);let s;if(r==="channels"){if(s=nr(e,t,o,!1),s===0&&n)throw new T(`strict: shader source does not use channels '${t}'.`)}else{if(r==="sampler2D"){const u=`${t}Dimensions`;Wy(e,u)>0&&(i[u]={type:"ivec3",x:1,y:1},wu(e,u))}if(!new RegExp(`uniform\\s+${r}\\s+${t}\\s*;`).test(e.shaderSource)){const u=`uniform ${r} ${t};`;e.shaderSource=u+e.shaderSource}const c=`${t}_${e._count++}`;if(s=nr(e,t,c),s===1&&n)throw new T(`strict: shader source does not use uniform '${t}'.`);if(e.uniforms[t]=o,r==="sampler2D")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(jy(t));else if(r==="samplerCube")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(Gy(t));else if(r.indexOf("mat")!==-1){const u=new yu[r];e._uniforms[c]=function(){return yu[r].fromColumnMajorArray(e.uniforms[t],u)}}else e._uniforms[c]=function(){return e.uniforms[t]}}}function Hy(e){let t=e.type;if(!h(t)){const n=typeof e;if(n==="number")t="float";else if(n==="boolean")t="bool";else if(n==="string"||e instanceof ie||e instanceof HTMLCanvasElement||e instanceof HTMLImageElement)/^([rgba]){1,4}$/i.test(e)?t="channels":e===X.DefaultCubeMapId?t="samplerCube":t="sampler2D";else if(n==="object")if(Array.isArray(e))(e.length===4||e.length===9||e.length===16)&&(t=`mat${Math.sqrt(e.length)}`);else{let i=0;for(const o in e)e.hasOwnProperty(o)&&(i+=1);i>=2&&i<=4?t=`vec${i}`:i===6&&(t="samplerCube")}}return t}function qy(e){const t=e._strict,n=e._template.materials;for(const i in n)if(n.hasOwnProperty(i)){const o=new X({strict:t,fabric:n[i],count:e._count});e._count=o._count,e._uniforms=Kt(e._uniforms,o._uniforms,!0),e.materials[i]=o,e._translucentFunctions=e._translucentFunctions.concat(o._translucentFunctions);const r="czm_getMaterial",s=`${r}_${e._count++}`;nr(o,r,s),e.shaderSource=o.shaderSource+e.shaderSource;const a=`${s}(materialInput)`;if(nr(e,i,a)===0&&t)throw new T(`strict: shader source does not use material '${i}'.`)}}function nr(e,t,n,i){i=m(i,!0);let o=0;const r="([\\w])?",s=`([\\w${i?".":""}])?`,a=new RegExp(s+t+r,"g");return e.shaderSource=e.shaderSource.replace(a,function(c,u,f){return u||f?c:(o+=1,n)}),o}function Wy(e,t,n){return nr(e,t,t,n)}X._materialCache={_materials:{},addMaterial:function(e,t){this._materials[e]=t},getMaterial:function(e){return this._materials[e]}},X.DefaultImageId="czm_defaultImage",X.DefaultCubeMapId="czm_defaultCubeMap",X.ColorType="Color",X._materialCache.addMaterial(X.ColorType,{fabric:{type:X.ColorType,uniforms:{color:new S(1,0,0,.5)},components:{diffuse:"color.rgb",alpha:"color.a"}},translucent:function(e){return e.uniforms.color.alpha<1}}),X.ImageType="Image",X._materialCache.addMaterial(X.ImageType,{fabric:{type:X.ImageType,uniforms:{image:X.DefaultImageId,repeat:new L(1,1),color:new S(1,1,1,1)},components:{diffuse:"texture(image, fract(repeat * materialInput.st)).rgb * color.rgb",alpha:"texture(image, fract(repeat * materialInput.st)).a * color.a"}},translucent:function(e){return e.uniforms.color.alpha<1}}),X.DiffuseMapType="DiffuseMap",X._materialCache.addMaterial(X.DiffuseMapType,{fabric:{type:X.DiffuseMapType,uniforms:{image:X.DefaultImageId,channels:"rgb",repeat:new L(1,1)},components:{diffuse:"texture(image, fract(repeat * materialInput.st)).channels"}},translucent:!1}),X.AlphaMapType="AlphaMap",X._materialCache.addMaterial(X.AlphaMapType,{fabric:{type:X.AlphaMapType,uniforms:{image:X.DefaultImageId,channel:"a",repeat:new L(1,1)},components:{alpha:"texture(image, fract(repeat * materialInput.st)).channel"}},translucent:!0}),X.SpecularMapType="SpecularMap",X._materialCache.addMaterial(X.SpecularMapType,{fabric:{type:X.SpecularMapType,uniforms:{image:X.DefaultImageId,channel:"r",repeat:new L(1,1)},components:{specular:"texture(image, fract(repeat * materialInput.st)).channel"}},translucent:!1}),X.EmissionMapType="EmissionMap",X._materialCache.addMaterial(X.EmissionMapType,{fabric:{type:X.EmissionMapType,uniforms:{image:X.DefaultImageId,channels:"rgb",repeat:new L(1,1)},components:{emission:"texture(image, fract(repeat * materialInput.st)).channels"}},translucent:!1}),X.BumpMapType="BumpMap",X._materialCache.addMaterial(X.BumpMapType,{fabric:{type:X.BumpMapType,uniforms:{image:X.DefaultImageId,channel:"r",strength:.8,repeat:new L(1,1)},source:_y},translucent:!1}),X.NormalMapType="NormalMap",X._materialCache.addMaterial(X.NormalMapType,{fabric:{type:X.NormalMapType,uniforms:{image:X.DefaultImageId,channels:"rgb",strength:.8,repeat:new L(1,1)},source:Sy},translucent:!1}),X.GridType="Grid",X._materialCache.addMaterial(X.GridType,{fabric:{type:X.GridType,uniforms:{color:new S(0,1,0,1),cellAlpha:.1,lineCount:new L(8,8),lineThickness:new L(1,1),lineOffset:new L(0,0)},source:Cy},translucent:function(e){const t=e.uniforms;return t.color.alpha<1||t.cellAlpha<1}}),X.StripeType="Stripe",X._materialCache.addMaterial(X.StripeType,{fabric:{type:X.StripeType,uniforms:{horizontal:!0,evenColor:new S(1,1,1,.5),oddColor:new S(0,0,1,.5),offset:0,repeat:5},source:Iy},translucent:function(e){const t=e.uniforms;return t.evenColor.alpha<1||t.oddColor.alpha<1}}),X.CheckerboardType="Checkerboard",X._materialCache.addMaterial(X.CheckerboardType,{fabric:{type:X.CheckerboardType,uniforms:{lightColor:new S(1,1,1,.5),darkColor:new S(0,0,0,.5),repeat:new L(5,5)},source:gy},translucent:function(e){const t=e.uniforms;return t.lightColor.alpha<1||t.darkColor.alpha<1}}),X.DotType="Dot",X._materialCache.addMaterial(X.DotType,{fabric:{type:X.DotType,uniforms:{lightColor:new S(1,1,0,.75),darkColor:new S(0,1,1,.75),repeat:new L(5,5)},source:yy},translucent:function(e){const t=e.uniforms;return t.lightColor.alpha<1||t.darkColor.alpha<1}}),X.WaterType="Water",X._materialCache.addMaterial(X.WaterType,{fabric:{type:X.WaterType,uniforms:{baseWaterColor:new S(.2,.3,.6,1),blendColor:new S(0,1,.699,1),specularMap:X.DefaultImageId,normalMap:X.DefaultImageId,frequency:10,animationSpeed:.01,amplitude:1,specularIntensity:.5,fadeFactor:1},source:zy},translucent:function(e){const t=e.uniforms;return t.baseWaterColor.alpha<1||t.blendColor.alpha<1}}),X.RimLightingType="RimLighting",X._materialCache.addMaterial(X.RimLightingType,{fabric:{type:X.RimLightingType,uniforms:{color:new S(1,0,0,.7),rimColor:new S(1,1,1,.4),width:.3},source:Py},translucent:function(e){const t=e.uniforms;return t.color.alpha<1||t.rimColor.alpha<1}}),X.FadeType="Fade",X._materialCache.addMaterial(X.FadeType,{fabric:{type:X.FadeType,uniforms:{fadeInColor:new S(1,0,0,1),fadeOutColor:new S(0,0,0,0),maximumDistance:.5,repeat:!0,fadeDirection:{x:!0,y:!0},time:new L(.5,.5)},source:Ey},translucent:function(e){const t=e.uniforms;return t.fadeInColor.alpha<1||t.fadeOutColor.alpha<1}}),X.PolylineArrowType="PolylineArrow",X._materialCache.addMaterial(X.PolylineArrowType,{fabric:{type:X.PolylineArrowType,uniforms:{color:new S(1,1,1,1)},source:Oy},translucent:!0}),X.PolylineDashType="PolylineDash",X._materialCache.addMaterial(X.PolylineDashType,{fabric:{type:X.PolylineDashType,uniforms:{color:new S(1,0,1,1),gapColor:new S(0,0,0,0),dashLength:16,dashPattern:255},source:Ay},translucent:!0}),X.PolylineGlowType="PolylineGlow",X._materialCache.addMaterial(X.PolylineGlowType,{fabric:{type:X.PolylineGlowType,uniforms:{color:new S(0,.5,1,1),glowPower:.25,taperPower:1},source:vy},translucent:!0}),X.PolylineOutlineType="PolylineOutline",X._materialCache.addMaterial(X.PolylineOutlineType,{fabric:{type:X.PolylineOutlineType,uniforms:{color:new S(1,1,1,1),outlineColor:new S(1,0,0,1),outlineWidth:1},source:xy},translucent:function(e){const t=e.uniforms;return t.color.alpha<1||t.outlineColor.alpha<1}}),X.ElevationContourType="ElevationContour",X._materialCache.addMaterial(X.ElevationContourType,{fabric:{type:X.ElevationContourType,uniforms:{spacing:100,color:new S(1,0,0,1),width:1},source:by},translucent:!1}),X.ElevationRampType="ElevationRamp",X._materialCache.addMaterial(X.ElevationRampType,{fabric:{type:X.ElevationRampType,uniforms:{image:X.DefaultImageId,minimumHeight:0,maximumHeight:1e4},source:Ty},translucent:!1}),X.SlopeRampMaterialType="SlopeRamp",X._materialCache.addMaterial(X.SlopeRampMaterialType,{fabric:{type:X.SlopeRampMaterialType,uniforms:{image:X.DefaultImageId},source:Ry},translucent:!1}),X.AspectRampMaterialType="AspectRamp",X._materialCache.addMaterial(X.AspectRampMaterialType,{fabric:{type:X.AspectRampMaterialType,uniforms:{image:X.DefaultImageId},source:my},translucent:!1}),X.ElevationBandType="ElevationBand",X._materialCache.addMaterial(X.ElevationBandType,{fabric:{type:X.ElevationBandType,uniforms:{heights:X.DefaultImageId,colors:X.DefaultImageId},source:wy},translucent:!0});const Yy=`in vec3 v_positionEC; in vec3 v_normalEC; in vec4 v_color; void main() { vec3 positionToEyeEC = -v_positionEC; vec3 normalEC = normalize(v_normalEC); #ifdef FACE_FORWARD normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC); #endif vec4 color = czm_gammaCorrect(v_color); czm_materialInput materialInput; materialInput.normalEC = normalEC; materialInput.positionToEyeEC = positionToEyeEC; czm_material material = czm_getDefaultMaterial(materialInput); material.diffuse = color.rgb; material.alpha = color.a; out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC); } `,$y=`in vec3 position3DHigh; in vec3 position3DLow; in vec3 normal; in vec4 color; in float batchId; out vec3 v_positionEC; out vec3 v_normalEC; out vec4 v_color; void main() { vec4 p = czm_computePosition(); v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates v_normalEC = czm_normal * normal; // normal in eye coordinates v_color = color; gl_Position = czm_modelViewProjectionRelativeToEye * p; } `,bu=`in vec4 v_color; void main() { out_FragColor = czm_gammaCorrect(v_color); } `,Xy=`in vec3 position3DHigh; in vec3 position3DLow; in vec4 color; in float batchId; out vec4 v_color; void main() { vec4 p = czm_computePosition(); v_color = color; gl_Position = czm_modelViewProjectionRelativeToEye * p; } `;function Lt(e){e=m(e,m.EMPTY_OBJECT);const t=m(e.translucent,!0),n=m(e.closed,!1),i=m(e.flat,!1),o=i?Xy:$y,r=i?bu:Yy,s=i?Lt.FLAT_VERTEX_FORMAT:Lt.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=m(e.vertexShaderSource,o),this._fragmentShaderSource=m(e.fragmentShaderSource,r),this._renderState=vt.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=s,this._flat=i,this._faceForward=m(e.faceForward,!n)}Object.defineProperties(Lt.prototype,{vertexShaderSource:{get:function(){return this._vertexShaderSource}},fragmentShaderSource:{get:function(){return this._fragmentShaderSource}},renderState:{get:function(){return this._renderState}},closed:{get:function(){return this._closed}},vertexFormat:{get:function(){return this._vertexFormat}},flat:{get:function(){return this._flat}},faceForward:{get:function(){return this._faceForward}}}),Lt.VERTEX_FORMAT=Je.POSITION_AND_NORMAL,Lt.FLAT_VERTEX_FORMAT=Je.POSITION_ONLY,Lt.prototype.getFragmentShaderSource=vt.prototype.getFragmentShaderSource,Lt.prototype.isTranslucent=vt.prototype.isTranslucent,Lt.prototype.getRenderState=vt.prototype.getRenderState;function To(e){this._definitionChanged=new ze,this._color=void 0,this._colorSubscription=void 0,this.color=e}Object.defineProperties(To.prototype,{isConstant:{get:function(){return fe.isConstant(this._color)}},definitionChanged:{get:function(){return this._definitionChanged}},color:D("color")}),To.prototype.getType=function(e){return"Color"},To.prototype.getValue=function(e,t){return h(t)||(t={}),t.color=fe.getValueOrClonedDefault(this._color,e,S.WHITE,t.color),t},To.prototype.equals=function(e){return this===e||e instanceof To&&fe.equals(this._color,e._color)};function yi(e){e=m(e,m.EMPTY_OBJECT),this._ellipsoid=m(e.ellipsoid,pe.WGS84),this._rectangle=m(e.rectangle,he.MAX_VALUE),this._projection=new gn(this._ellipsoid),this._numberOfLevelZeroTilesX=m(e.numberOfLevelZeroTilesX,2),this._numberOfLevelZeroTilesY=m(e.numberOfLevelZeroTilesY,1)}Object.defineProperties(yi.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}}),yi.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<=o&&(u=o-1);let f=(i.north-e.latitude)/a|0;return f>=r&&(f=r-1),h(n)?(n.x=u,n.y=f,n):new L(u,f)};const Tu=new l,Eu=new l,Cu=new J,_c=new l,Ky=new l,Su=new Q,Zy=new yi,ir=[new J,new J,new J,new J],or=new L,tt={};tt.initialize=function(){let e=tt._initPromise;return h(e)||(e=ie.fetchJson(Zt("Assets/approximateTerrainHeights.json")).then(function(t){tt._terrainHeights=t}),tt._initPromise=e),e},tt.getMinimumMaximumHeights=function(e,t){if(d.defined("rectangle",e),!h(tt._terrainHeights))throw new T("You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function");t=m(t,pe.WGS84);const n=Ou(e);let i=tt._defaultMinTerrainHeight,o=tt._defaultMaxTerrainHeight;if(h(n)){const r=`${n.level}-${n.x}-${n.y}`,s=tt._terrainHeights[r];h(s)&&(i=s[0],o=s[1]),t.cartographicToCartesian(he.northeast(e,Cu),Tu),t.cartographicToCartesian(he.southwest(e,Cu),Eu),l.midpoint(Eu,Tu,_c);const a=t.scaleToGeodeticSurface(_c,Ky);if(h(a)){const c=l.distance(_c,a);i=Math.min(i,-c)}else i=tt._defaultMinTerrainHeight}return i=Math.max(tt._defaultMinTerrainHeight,i),{minimumTerrainHeight:i,maximumTerrainHeight:o}},tt.getBoundingSphere=function(e,t){if(d.defined("rectangle",e),!h(tt._terrainHeights))throw new T("You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function");t=m(t,pe.WGS84);const n=Ou(e);let i=tt._defaultMaxTerrainHeight;if(h(n)){const r=`${n.level}-${n.x}-${n.y}`,s=tt._terrainHeights[r];h(s)&&(i=s[1])}const o=Q.fromRectangle3D(e,t,0);return Q.fromRectangle3D(e,t,i,Su),Q.union(o,Su,o)};function Ou(e){J.fromRadians(e.east,e.north,0,ir[0]),J.fromRadians(e.west,e.north,0,ir[1]),J.fromRadians(e.east,e.south,0,ir[2]),J.fromRadians(e.west,e.south,0,ir[3]);let t=0,n=0,i=0,o=0;const r=tt._terrainHeightsMaxLevel;let s;for(s=0;s<=r;++s){let a=!1;for(let c=0;c<4;++c){const u=ir[c];if(Zy.positionToTileXY(u,s,or),c===0)i=or.x,o=or.y;else if(i!==or.x||o!==or.y){a=!0;break}}if(a)break;t=i,n=o}if(s!==0)return{x:t,y:n,level:s>r?r:s-1}}tt._terrainHeightsMaxLevel=6,tt._defaultMaxTerrainHeight=9e3,tt._defaultMinTerrainHeight=-1e5,tt._terrainHeights=void 0,tt._initPromise=void 0,Object.defineProperties(tt,{initialized:{get:function(){return h(tt._terrainHeights)}}});const In=tt;function Ft(e,t,n){this.minimum=l.clone(m(e,l.ZERO)),this.maximum=l.clone(m(t,l.ZERO)),h(n)?n=l.clone(n):n=l.midpoint(this.minimum,this.maximum,new l),this.center=n}Ft.fromCorners=function(e,t,n){return d.defined("minimum",e),d.defined("maximum",t),h(n)||(n=new Ft),n.minimum=l.clone(e,n.minimum),n.maximum=l.clone(t,n.maximum),n.center=l.midpoint(e,t,n.center),n},Ft.fromPoints=function(e,t){if(h(t)||(t=new Ft),!h(e)||e.length===0)return t.minimum=l.clone(l.ZERO,t.minimum),t.maximum=l.clone(l.ZERO,t.maximum),t.center=l.clone(l.ZERO,t.center),t;let n=e[0].x,i=e[0].y,o=e[0].z,r=e[0].x,s=e[0].y,a=e[0].z;const c=e.length;for(let p=1;p0?nn.INSIDE:r+o<0?nn.OUTSIDE:nn.INTERSECTING},Ft.prototype.clone=function(e){return Ft.clone(this,e)},Ft.prototype.intersectPlane=function(e){return Ft.intersectPlane(this,e)},Ft.prototype.equals=function(e){return Ft.equals(this,e)};const gc={};gc.computeDiscriminant=function(e,t,n){if(typeof e!="number")throw new T("a is a required number.");if(typeof t!="number")throw new T("b is a required number.");if(typeof n!="number")throw new T("c is a required number.");return t*t-4*e*n};function Au(e,t,n){const i=e+t;return P.sign(e)!==P.sign(t)&&Math.abs(i/Math.max(Math.abs(e),Math.abs(t)))u&&u/c0?[a/e,n/a]:[n/a,a/e]};const Yn=gc,yc={};yc.computeDiscriminant=function(e,t,n,i){if(typeof e!="number")throw new T("a is a required number.");if(typeof t!="number")throw new T("b is a required number.");if(typeof n!="number")throw new T("c is a required number.");if(typeof i!="number")throw new T("d is a required number.");const o=e*e,r=t*t,s=n*n,a=i*i;return 18*e*t*n*i+r*s-27*o*a-4*(e*s*n+r*t*i)};function wc(e,t,n,i){const o=e,r=t/3,s=n/3,a=i,c=o*s,u=r*a,f=r*r,p=s*s,_=o*s-f,g=o*a-r*s,y=r*a-p,b=4*_*y-g*g;let E,O;if(b<0){let re,le,we;f*u>=c*p?(re=o,le=_,we=-2*r*_+o*g):(re=a,le=y,we=-a*g+2*s*y);const be=-(we<0?-1:1)*Math.abs(re)*Math.sqrt(-b);O=-we+be;const Pe=O/2,Be=Pe<0?-Math.pow(-Pe,1/3):Math.pow(Pe,1/3),Ze=O===be?-Be:-le/Be;return E=le<=0?Be+Ze:-we/(Be*Be+Ze*Ze+le),f*u>=c*p?[(E-r)/o]:[-a/(E+s)]}const v=_,A=-2*r*_+o*g,R=y,z=-a*g+2*s*y,U=Math.sqrt(b),G=Math.sqrt(3)/2;let k=Math.abs(Math.atan2(o*U,-A)/3);E=2*Math.sqrt(-v);let j=Math.cos(k);O=E*j;let B=E*(-j/2-G*Math.sin(k));const H=O+B>2*r?O-r:B-r,W=o,w=H/W;k=Math.abs(Math.atan2(a*U,-z)/3),E=2*Math.sqrt(-R),j=Math.cos(k),O=E*j,B=E*(-j/2-G*Math.sin(k));const C=-a,x=O+B<2*s?O+s:B+s,N=C/x,V=W*x,Y=-H*x-W*C,Z=H*C,$=(s*Y-r*Z)/(-r*Y+s*V);return w<=$?w<=N?$<=N?[w,$,N]:[w,N,$]:[N,w,$]:w<=N?[$,w,N]:$<=N?[$,N,w]:[N,$,w]}yc.computeRealRoots=function(e,t,n,i){if(typeof e!="number")throw new T("a is a required number.");if(typeof t!="number")throw new T("b is a required number.");if(typeof n!="number")throw new T("c is a required number.");if(typeof i!="number")throw new T("d is a required number.");let o,r;if(e===0)return Yn.computeRealRoots(t,n,i);if(t===0){if(n===0){if(i===0)return[0,0,0];r=-i/e;const s=r<0?-Math.pow(-r,1/3):Math.pow(r,1/3);return[s,s,s]}else if(i===0)return o=Yn.computeRealRoots(e,0,n),o.Length===0?[0]:[o[0],0,o[1]];return wc(e,0,n,i)}else{if(n===0)return i===0?(r=-t/e,r<0?[r,0,0]:[0,0,r]):wc(e,t,0,i);if(i===0)return o=Yn.computeRealRoots(e,t,n),o.length===0?[0]:o[1]<=0?[o[0],o[1],0]:o[0]>=0?[0,o[0],o[1]]:[o[0],0,o[1]]}return wc(e,t,n,i)};const bc=yc,Tc={};Tc.computeDiscriminant=function(e,t,n,i,o){if(typeof e!="number")throw new T("a is a required number.");if(typeof t!="number")throw new T("b is a required number.");if(typeof n!="number")throw new T("c is a required number.");if(typeof i!="number")throw new T("d is a required number.");if(typeof o!="number")throw new T("e is a required number.");const r=e*e,s=r*e,a=t*t,c=a*t,u=n*n,f=u*n,p=i*i,_=p*i,g=o*o,y=g*o;return a*u*p-4*c*_-4*e*f*p+18*e*t*n*_-27*r*p*p+256*s*y+o*(18*c*n*i-4*a*f+16*e*u*u-80*e*t*u*i-6*e*a*p+144*r*n*p)+g*(144*e*a*n-27*a*a-128*r*u-192*r*t*i)};function En(e,t,n,i){const o=e*e,r=t-3*o/8,s=n-t*e/2+o*e/8,a=i-n*e/4+t*o/16-3*o*o/256,c=bc.computeRealRoots(1,2*r,r*r-4*a,-s*s);if(c.length>0){const u=-e/4,f=c[c.length-1];if(Math.abs(f)=0&&g>=0){const b=Math.sqrt(_),E=Math.sqrt(g);return[u-E,u-b,u+b,u+E]}else{if(_>=0&&g<0)return y=Math.sqrt(_),[u-y,u+y];if(_<0&&g>=0)return y=Math.sqrt(g),[u-y,u+y]}}return[]}else if(f>0){const p=Math.sqrt(f),_=(r+f-s/p)/2,g=(r+f+s/p)/2,y=Yn.computeRealRoots(1,p,_),b=Yn.computeRealRoots(1,-p,g);return y.length!==0?(y[0]+=u,y[1]+=u,b.length!==0?(b[0]+=u,b[1]+=u,y[1]<=b[0]?[y[0],y[1],b[0],b[1]]:b[1]<=y[0]?[b[0],b[1],y[0],y[1]]:y[0]>=b[0]&&y[1]<=b[1]?[b[0],y[0],y[1],b[1]]:b[0]>=y[0]&&b[1]<=y[1]?[y[0],b[0],b[1],y[1]]:y[0]>b[0]&&y[0]0){const p=f[0],_=t-p,g=_*_,y=e/2,b=_/2,E=g-4*i,O=g+4*Math.abs(i),v=s-4*p,A=s+4*Math.abs(p);let R,z;if(p<0||E*A=H[0]&&B[1]<=H[1]?[H[0],B[0],B[1],H[1]]:H[0]>=B[0]&&H[1]<=B[1]?[B[0],H[0],H[1],B[1]]:B[0]>H[0]&&B[0]f)||(_=l.cross(p,a,Pu),y=l.dot(s,_),y<0||g+y>f))return;b=l.dot(c,_)/f}else{if(Math.abs(f)1||(_=l.cross(p,a,Pu),y=l.dot(s,_)*E,y<0||g+y>1))return;b=l.dot(c,_)*E}return b},$e.rayTriangle=function(e,t,n,i,o,r){const s=$e.rayTriangleParametric(e,t,n,i,o);if(!(!h(s)||s<0))return h(r)||(r=new l),l.multiplyByScalar(e.direction,s,r),l.add(e.origin,r,r)};const tw=new Eo;$e.lineSegmentTriangle=function(e,t,n,i,o,r,s){if(!h(e))throw new T("v0 is required.");if(!h(t))throw new T("v1 is required.");if(!h(n))throw new T("p0 is required.");if(!h(i))throw new T("p1 is required.");if(!h(o))throw new T("p2 is required.");const a=tw;l.clone(e,a.origin),l.subtract(t,e,a.direction),l.normalize(a.direction,a.direction);const c=$e.rayTriangleParametric(a,n,i,o,r);if(!(!h(c)||c<0||c>l.distance(e,t)))return h(s)||(s=new l),l.multiplyByScalar(a.direction,c,s),l.add(a.origin,s,s)};function nw(e,t,n,i){const o=t*t-4*e*n;if(o<0)return;if(o>0){const s=1/(2*e),a=Math.sqrt(o),c=(-t+a)*s,u=(-t-a)*s;return cs))return i.start=Math.max(i.start,0),i.stop=Math.min(i.stop,s),i};const rw=new l,sw=new l;$e.rayEllipsoid=function(e,t){if(!h(e))throw new T("ray is required.");if(!h(t))throw new T("ellipsoid is required.");const n=t.oneOverRadii,i=l.multiplyComponents(n,e.origin,rw),o=l.multiplyComponents(n,e.direction,sw),r=l.magnitudeSquared(i),s=l.dot(i,o);let a,c,u,f,p;if(r>1){if(s>=0)return;const _=s*s;if(a=r-1,c=l.magnitudeSquared(o),u=c*a,_u){f=s*s-u,p=-s+Math.sqrt(f);const y=p/c,b=a/p;return y0?g.push(new l(i,o*j,o*-W)):W!==0?(g.push(new l(i,o*j,o*-W)),g.push(new l(i,o*j,o*W)),++k):g.push(new l(i,o*j,o*W))}return g}const Ec=new l,Iu=new l,zu=new l,Os=new l,cw=new l,lw=new M,hw=new M,uw=new M,fw=new M,dw=new M,Du=new M,Mu=new M,Nu=new l,pw=new l,mw=new J;$e.grazingAltitudeLocation=function(e,t){if(!h(e))throw new T("ray is required.");if(!h(t))throw new T("ellipsoid is required.");const n=e.origin,i=e.direction;if(!l.equals(n,l.ZERO)){const U=t.geodeticSurfaceNormal(n,Ec);if(l.dot(i,U)>=0)return n}const o=h(this.rayEllipsoid(e,t)),r=t.transformPositionToScaledSpace(i,Ec),s=l.normalize(r,r),a=l.mostOrthogonalAxis(r,Os),c=l.normalize(l.cross(a,s,Iu),Iu),u=l.normalize(l.cross(s,c,zu),zu),f=lw;f[0]=s.x,f[1]=s.y,f[2]=s.z,f[3]=c.x,f[4]=c.y,f[5]=c.z,f[6]=u.x,f[7]=u.y,f[8]=u.z;const p=M.transpose(f,hw),_=M.fromScale(t.radii,uw),g=M.fromScale(t.oneOverRadii,fw),y=dw;y[0]=0,y[1]=-i.z,y[2]=i.y,y[3]=i.z,y[4]=0,y[5]=-i.x,y[6]=-i.y,y[7]=i.x,y[8]=0;const b=M.multiply(M.multiply(p,g,Du),y,Du),E=M.multiply(M.multiply(b,_,Mu),f,Mu),O=M.multiplyByVector(b,n,cw),v=aw(E,l.negate(O,Ec),0,0,1);let A,R;const z=v.length;if(z>0){let U=l.clone(l.ZERO,pw),G=Number.NEGATIVE_INFINITY;for(let j=0;jG&&(G=H,U=l.clone(A,U))}const k=t.cartesianToCartographic(U,mw);return G=P.clamp(G,0,1),R=l.magnitude(l.subtract(U,n,Os))*Math.sqrt(1-G*G),R=o?-R:R,k.height=R,t.cartographicToCartesian(k,new l)}};const _w=new l;$e.lineSegmentPlane=function(e,t,n,i){if(!h(e))throw new T("endPoint0 is required.");if(!h(t))throw new T("endPoint1 is required.");if(!h(n))throw new T("plane is required.");h(i)||(i=new l);const o=l.subtract(t,e,_w),r=n.normal,s=l.dot(r,o);if(Math.abs(s)1))return l.multiplyByScalar(o,c,i),l.add(e,i,i),i},$e.trianglePlaneIntersection=function(e,t,n,i){if(!h(e)||!h(t)||!h(n)||!h(i))throw new T("p0, p1, p2, and plane are required.");const o=i.normal,r=i.distance,s=l.dot(o,e)+r<0,a=l.dot(o,t)+r<0,c=l.dot(o,n)+r<0;let u=0;u+=s?1:0,u+=a?1:0,u+=c?1:0;let f,p;if((u===1||u===2)&&(f=new l,p=new l),u===1){if(s)return $e.lineSegmentPlane(e,t,i,f),$e.lineSegmentPlane(e,n,i,p),{positions:[e,t,n,f,p],indices:[0,3,4,1,2,4,1,4,3]};if(a)return $e.lineSegmentPlane(t,n,i,f),$e.lineSegmentPlane(t,e,i,p),{positions:[e,t,n,f,p],indices:[1,3,4,2,0,4,2,4,3]};if(c)return $e.lineSegmentPlane(n,e,i,f),$e.lineSegmentPlane(n,t,i,p),{positions:[e,t,n,f,p],indices:[2,3,4,0,1,4,0,4,3]}}else if(u===2)if(s)if(a){if(!c)return $e.lineSegmentPlane(e,n,i,f),$e.lineSegmentPlane(t,n,i,p),{positions:[e,t,n,f,p],indices:[0,1,4,0,4,3,2,3,4]}}else return $e.lineSegmentPlane(n,t,i,f),$e.lineSegmentPlane(e,t,i,p),{positions:[e,t,n,f,p],indices:[2,0,4,2,4,3,1,3,4]};else return $e.lineSegmentPlane(t,e,i,f),$e.lineSegmentPlane(n,e,i,p),{positions:[e,t,n,f,p],indices:[1,2,4,1,4,3,0,3,4]}};const $n=$e;function Se(e,t){if(d.typeOf.object("normal",e),!P.equalsEpsilon(l.magnitude(e),1,P.EPSILON6))throw new T("normal must be normalized.");d.typeOf.number("distance",t),this.normal=l.clone(e),this.distance=t}Se.fromPointNormal=function(e,t,n){if(d.typeOf.object("point",e),d.typeOf.object("normal",t),!P.equalsEpsilon(l.magnitude(t),1,P.EPSILON6))throw new T("normal must be normalized.");const i=-l.dot(t,e);return h(n)?(l.clone(t,n.normal),n.distance=i,n):new Se(t,i)};const gw=new l;Se.fromCartesian4=function(e,t){d.typeOf.object("coefficients",e);const n=l.fromCartesian4(e,gw),i=e.w;if(!P.equalsEpsilon(l.magnitude(n),1,P.EPSILON6))throw new T("normal must be normalized.");return h(t)?(l.clone(n,t.normal),t.distance=i,t):new Se(n,i)},Se.getPointDistance=function(e,t){return d.typeOf.object("plane",e),d.typeOf.object("point",t),l.dot(e.normal,t)+e.distance};const yw=new l;Se.projectPointOntoPlane=function(e,t,n){d.typeOf.object("plane",e),d.typeOf.object("point",t),h(n)||(n=new l);const i=Se.getPointDistance(e,t),o=l.multiplyByScalar(e.normal,i,yw);return l.subtract(t,o,n)};const ww=new F,bw=new q,Tw=new l;Se.transform=function(e,t,n){d.typeOf.object("plane",e),d.typeOf.object("transform",t);const i=e.normal,o=e.distance,r=F.inverseTranspose(t,ww);let s=q.fromElements(i.x,i.y,i.z,o,bw);s=F.multiplyByVector(r,s,s);const a=l.fromCartesian4(s,Tw);return s=q.divideByScalar(s,l.magnitude(a),s),Se.fromCartesian4(s,n)},Se.clone=function(e,t){return d.typeOf.object("plane",e),h(t)?(l.clone(e.normal,t.normal),t.distance=e.distance,t):new Se(e.normal,e.distance)},Se.equals=function(e,t){return d.typeOf.object("left",e),d.typeOf.object("right",t),e.distance===t.distance&&l.equals(e.normal,t.normal)},Se.ORIGIN_XY_PLANE=Object.freeze(new Se(l.UNIT_Z,0)),Se.ORIGIN_YZ_PLANE=Object.freeze(new Se(l.UNIT_X,0)),Se.ORIGIN_ZX_PLANE=Object.freeze(new Se(l.UNIT_Y,0));const Cc=new q;function zn(e,t){if(d.defined("origin",e),t=m(t,pe.WGS84),e=t.scaleToGeodeticSurface(e),!h(e))throw new T("origin must not be at the center of the ellipsoid.");const n=Fi.eastNorthUpToFixedFrame(e,t);this._ellipsoid=t,this._origin=e,this._xAxis=l.fromCartesian4(F.getColumn(n,0,Cc)),this._yAxis=l.fromCartesian4(F.getColumn(n,1,Cc));const i=l.fromCartesian4(F.getColumn(n,2,Cc));this._plane=Se.fromPointNormal(e,i)}Object.defineProperties(zn.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},origin:{get:function(){return this._origin}},plane:{get:function(){return this._plane}},xAxis:{get:function(){return this._xAxis}},yAxis:{get:function(){return this._yAxis}},zAxis:{get:function(){return this._plane.normal}}});const Ew=new Ft;zn.fromPoints=function(e,t){d.defined("cartesians",e);const n=Ft.fromPoints(e,Ew);return new zn(n.center,t)};const Lu=new Eo,As=new l;zn.prototype.projectPointOntoPlane=function(e,t){d.defined("cartesian",e);const n=Lu;n.origin=e,l.normalize(e,n.direction);let i=$n.rayPlane(n,this._plane,As);if(h(i)||(l.negate(n.direction,n.direction),i=$n.rayPlane(n,this._plane,As)),h(i)){const o=l.subtract(i,this._origin,i),r=l.dot(this._xAxis,o),s=l.dot(this._yAxis,o);return h(t)?(t.x=r,t.y=s,t):new L(r,s)}},zn.prototype.projectPointsOntoPlane=function(e,t){d.defined("cartesians",e),h(t)||(t=[]);let n=0;const i=e.length;for(let o=0;oP.TWO_PI)throw new T("Rectangle width must be between 0 and 2 * pi");if(e.height<0||e.height>P.PI)throw new T("Rectangle height must be between 0 and pi");if(h(i)&&!P.equalsEpsilon(i.radii.x,i.radii.y,P.EPSILON15))throw new T("Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)");t=m(t,0),n=m(n,0),i=m(i,pe.WGS84);let r,s,a,c,u,f,p;if(e.width<=P.PI){const G=he.center(e,Uu),k=i.cartographicToCartesian(G,Dw),j=new zn(k,i);p=j.plane;const B=G.longitude,H=e.south<0&&e.north>0?0:G.latitude,W=J.fromRadians(B,e.north,n,Mw),w=J.fromRadians(e.west,e.north,n,Nw),C=J.fromRadians(e.west,H,n,Lw),x=J.fromRadians(e.west,e.south,n,Fw),N=J.fromRadians(B,e.south,n,Bw),V=i.cartographicToCartesian(W,Uw);let Y=i.cartographicToCartesian(w,ku);const Z=i.cartographicToCartesian(C,kw);let $=i.cartographicToCartesian(x,ju);const re=i.cartographicToCartesian(N,jw),le=j.projectPointToNearestOnPlane(V,Gw),we=j.projectPointToNearestOnPlane(Y,Vw),Te=j.projectPointToNearestOnPlane(Z,Hw),be=j.projectPointToNearestOnPlane($,qw),Pe=j.projectPointToNearestOnPlane(re,Ww);return r=Math.min(we.x,Te.x,be.x),s=-r,c=Math.max(we.y,le.y),a=Math.min(be.y,Pe.y),w.height=x.height=t,Y=i.cartographicToCartesian(w,ku),$=i.cartographicToCartesian(x,ju),u=Math.min(Se.getPointDistance(p,Y),Se.getPointDistance(p,$)),f=n,Bu(j.origin,j.xAxis,j.yAxis,j.zAxis,r,s,a,c,u,f,o)}const _=e.south>0,g=e.north<0,y=_?e.south:g?e.north:0,b=he.center(e,Uu).longitude,E=l.fromRadians(b,y,n,i,Yw);E.z=0;const v=Math.abs(E.x)=c?nn.INSIDE:nn.INTERSECTING};const Gu=new l,Vu=new l,Hu=new l,nb=new l,qu=new l,ib=new l;xe.distanceSquaredTo=function(e,t){if(!h(e))throw new T("box is required.");if(!h(t))throw new T("cartesian is required.");const n=l.subtract(t,e.center,Fu),i=e.halfAxes;let o=M.getColumn(i,0,Gu),r=M.getColumn(i,1,Vu),s=M.getColumn(i,2,Hu);const a=l.magnitude(o),c=l.magnitude(r),u=l.magnitude(s);let f=!0,p=!0,_=!0;a>0?l.divideByScalar(o,a,o):f=!1,c>0?l.divideByScalar(r,c,r):p=!1,u>0?l.divideByScalar(s,u,s):_=!1;const g=!f+!p+!_;let y,b,E;if(g===1){let R=o;y=r,b=s,p?_||(R=s,b=o):(R=r,y=o),E=l.cross(y,b,qu),R===o?o=E:R===r?r=E:R===s&&(s=E)}else if(g===2){y=o,p?y=r:_&&(y=s);let R=l.UNIT_Y;R.equalsEpsilon(y,P.EPSILON3)&&(R=l.UNIT_X),b=l.cross(y,R,nb),l.normalize(b,b),E=l.cross(y,b,qu),l.normalize(E,E),y===o?(r=b,s=E):y===r?(s=b,o=E):y===s&&(o=b,r=E)}else g===3&&(o=l.UNIT_X,r=l.UNIT_Y,s=l.UNIT_Z);const O=ib;O.x=l.dot(n,o),O.y=l.dot(n,r),O.z=l.dot(n,s);let v=0,A;return O.x<-a?(A=O.x+a,v+=A*A):O.x>a&&(A=O.x-a,v+=A*A),O.y<-c?(A=O.y+c,v+=A*A):O.y>c&&(A=O.y-c,v+=A*A),O.z<-u?(A=O.z+u,v+=A*A):O.z>u&&(A=O.z-u,v+=A*A),v};const ob=new l,rb=new l;xe.computePlaneDistances=function(e,t,n,i){if(!h(e))throw new T("box is required.");if(!h(t))throw new T("position is required.");if(!h(n))throw new T("direction is required.");h(i)||(i=new Di);let o=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;const s=e.center,a=e.halfAxes,c=M.getColumn(a,0,Gu),u=M.getColumn(a,1,Vu),f=M.getColumn(a,2,Hu),p=l.add(c,u,ob);l.add(p,f,p),l.add(p,s,p);const _=l.subtract(p,t,rb);let g=l.dot(n,_);return o=Math.min(g,o),r=Math.max(g,r),l.add(s,c,p),l.add(p,u,p),l.subtract(p,f,p),l.subtract(p,t,_),g=l.dot(n,_),o=Math.min(g,o),r=Math.max(g,r),l.add(s,c,p),l.subtract(p,u,p),l.add(p,f,p),l.subtract(p,t,_),g=l.dot(n,_),o=Math.min(g,o),r=Math.max(g,r),l.add(s,c,p),l.subtract(p,u,p),l.subtract(p,f,p),l.subtract(p,t,_),g=l.dot(n,_),o=Math.min(g,o),r=Math.max(g,r),l.subtract(s,c,p),l.add(p,u,p),l.add(p,f,p),l.subtract(p,t,_),g=l.dot(n,_),o=Math.min(g,o),r=Math.max(g,r),l.subtract(s,c,p),l.add(p,u,p),l.subtract(p,f,p),l.subtract(p,t,_),g=l.dot(n,_),o=Math.min(g,o),r=Math.max(g,r),l.subtract(s,c,p),l.subtract(p,u,p),l.add(p,f,p),l.subtract(p,t,_),g=l.dot(n,_),o=Math.min(g,o),r=Math.max(g,r),l.subtract(s,c,p),l.subtract(p,u,p),l.subtract(p,f,p),l.subtract(p,t,_),g=l.dot(n,_),o=Math.min(g,o),r=Math.max(g,r),i.start=o,i.stop=r,i};const sb=new l,ab=new l,cb=new l;xe.computeCorners=function(e,t){d.typeOf.object("box",e),h(t)||(t=[new l,new l,new l,new l,new l,new l,new l,new l]);const n=e.center,i=e.halfAxes,o=M.getColumn(i,0,sb),r=M.getColumn(i,1,ab),s=M.getColumn(i,2,cb);return l.clone(n,t[0]),l.subtract(t[0],o,t[0]),l.subtract(t[0],r,t[0]),l.subtract(t[0],s,t[0]),l.clone(n,t[1]),l.subtract(t[1],o,t[1]),l.subtract(t[1],r,t[1]),l.add(t[1],s,t[1]),l.clone(n,t[2]),l.subtract(t[2],o,t[2]),l.add(t[2],r,t[2]),l.subtract(t[2],s,t[2]),l.clone(n,t[3]),l.subtract(t[3],o,t[3]),l.add(t[3],r,t[3]),l.add(t[3],s,t[3]),l.clone(n,t[4]),l.add(t[4],o,t[4]),l.subtract(t[4],r,t[4]),l.subtract(t[4],s,t[4]),l.clone(n,t[5]),l.add(t[5],o,t[5]),l.subtract(t[5],r,t[5]),l.add(t[5],s,t[5]),l.clone(n,t[6]),l.add(t[6],o,t[6]),l.add(t[6],r,t[6]),l.subtract(t[6],s,t[6]),l.clone(n,t[7]),l.add(t[7],o,t[7]),l.add(t[7],r,t[7]),l.add(t[7],s,t[7]),t};const lb=new M;xe.computeTransformation=function(e,t){d.typeOf.object("box",e),h(t)||(t=new F);const n=e.center,i=M.multiplyByUniformScale(e.halfAxes,2,lb);return F.fromRotationTranslation(i,n,t)};const hb=new Q;xe.isOccluded=function(e,t){if(!h(e))throw new T("box is required.");if(!h(t))throw new T("occluder is required.");const n=Q.fromOrientedBoundingBox(e,hb);return!t.isBoundingSphereVisible(n)},xe.prototype.intersectPlane=function(e){return xe.intersectPlane(this,e)},xe.prototype.distanceSquaredTo=function(e){return xe.distanceSquaredTo(this,e)},xe.prototype.computePlaneDistances=function(e,t,n){return xe.computePlaneDistances(this,e,t,n)},xe.prototype.computeCorners=function(e){return xe.computeCorners(this,e)},xe.prototype.computeTransformation=function(e){return xe.computeTransformation(this,e)},xe.prototype.isOccluded=function(e){return xe.isOccluded(this,e)},xe.equals=function(e,t){return e===t||h(e)&&h(t)&&l.equals(e.center,t.center)&&M.equals(e.halfAxes,t.halfAxes)},xe.prototype.clone=function(e){return xe.clone(this,e)},xe.prototype.equals=function(e){return xe.equals(this,e)};const vs={};vs.getHeight=function(e,t,n){return(e-n)*t+n};const ub=new l;vs.getPosition=function(e,t,n,i,o){const r=t.cartesianToCartographic(e,ub),s=vs.getHeight(r.height,n,i);return l.fromRadians(r.longitude,r.latitude,s,t,o)};const Wu=vs,nt={CULL:1,OCCLUDE:2,EXECUTE_IN_CLOSEST_FRUSTUM:4,DEBUG_SHOW_BOUNDING_VOLUME:8,CAST_SHADOWS:16,RECEIVE_SHADOWS:32,PICK_ONLY:64,DEPTH_FOR_TRANSLUCENT_CLASSIFICATION:128};function We(e){e=m(e,m.EMPTY_OBJECT),this._boundingVolume=e.boundingVolume,this._orientedBoundingBox=e.orientedBoundingBox,this._modelMatrix=e.modelMatrix,this._primitiveType=m(e.primitiveType,Ue.TRIANGLES),this._vertexArray=e.vertexArray,this._count=e.count,this._offset=m(e.offset,0),this._instanceCount=m(e.instanceCount,0),this._shaderProgram=e.shaderProgram,this._uniformMap=e.uniformMap,this._renderState=e.renderState,this._framebuffer=e.framebuffer,this._pass=e.pass,this._owner=e.owner,this._debugOverlappingFrustums=0,this._pickId=e.pickId,this._flags=0,this.cull=m(e.cull,!0),this.occlude=m(e.occlude,!0),this.executeInClosestFrustum=m(e.executeInClosestFrustum,!1),this.debugShowBoundingVolume=m(e.debugShowBoundingVolume,!1),this.castShadows=m(e.castShadows,!1),this.receiveShadows=m(e.receiveShadows,!1),this.pickOnly=m(e.pickOnly,!1),this.depthForTranslucentClassification=m(e.depthForTranslucentClassification,!1),this.dirty=!0,this.lastDirtyTime=0,this.derivedCommands={}}function Bt(e,t){return(e._flags&t)===t}function wi(e,t,n){n?e._flags|=t:e._flags&=~t}Object.defineProperties(We.prototype,{boundingVolume:{get:function(){return this._boundingVolume},set:function(e){this._boundingVolume!==e&&(this._boundingVolume=e,this.dirty=!0)}},orientedBoundingBox:{get:function(){return this._orientedBoundingBox},set:function(e){this._orientedBoundingBox!==e&&(this._orientedBoundingBox=e,this.dirty=!0)}},cull:{get:function(){return Bt(this,nt.CULL)},set:function(e){Bt(this,nt.CULL)!==e&&(wi(this,nt.CULL,e),this.dirty=!0)}},occlude:{get:function(){return Bt(this,nt.OCCLUDE)},set:function(e){Bt(this,nt.OCCLUDE)!==e&&(wi(this,nt.OCCLUDE,e),this.dirty=!0)}},modelMatrix:{get:function(){return this._modelMatrix},set:function(e){this._modelMatrix!==e&&(this._modelMatrix=e,this.dirty=!0)}},primitiveType:{get:function(){return this._primitiveType},set:function(e){this._primitiveType!==e&&(this._primitiveType=e,this.dirty=!0)}},vertexArray:{get:function(){return this._vertexArray},set:function(e){this._vertexArray!==e&&(this._vertexArray=e,this.dirty=!0)}},count:{get:function(){return this._count},set:function(e){this._count!==e&&(this._count=e,this.dirty=!0)}},offset:{get:function(){return this._offset},set:function(e){this._offset!==e&&(this._offset=e,this.dirty=!0)}},instanceCount:{get:function(){return this._instanceCount},set:function(e){this._instanceCount!==e&&(this._instanceCount=e,this.dirty=!0)}},shaderProgram:{get:function(){return this._shaderProgram},set:function(e){this._shaderProgram!==e&&(this._shaderProgram=e,this.dirty=!0)}},castShadows:{get:function(){return Bt(this,nt.CAST_SHADOWS)},set:function(e){Bt(this,nt.CAST_SHADOWS)!==e&&(wi(this,nt.CAST_SHADOWS,e),this.dirty=!0)}},receiveShadows:{get:function(){return Bt(this,nt.RECEIVE_SHADOWS)},set:function(e){Bt(this,nt.RECEIVE_SHADOWS)!==e&&(wi(this,nt.RECEIVE_SHADOWS,e),this.dirty=!0)}},uniformMap:{get:function(){return this._uniformMap},set:function(e){this._uniformMap!==e&&(this._uniformMap=e,this.dirty=!0)}},renderState:{get:function(){return this._renderState},set:function(e){this._renderState!==e&&(this._renderState=e,this.dirty=!0)}},framebuffer:{get:function(){return this._framebuffer},set:function(e){this._framebuffer!==e&&(this._framebuffer=e,this.dirty=!0)}},pass:{get:function(){return this._pass},set:function(e){this._pass!==e&&(this._pass=e,this.dirty=!0)}},executeInClosestFrustum:{get:function(){return Bt(this,nt.EXECUTE_IN_CLOSEST_FRUSTUM)},set:function(e){Bt(this,nt.EXECUTE_IN_CLOSEST_FRUSTUM)!==e&&(wi(this,nt.EXECUTE_IN_CLOSEST_FRUSTUM,e),this.dirty=!0)}},owner:{get:function(){return this._owner},set:function(e){this._owner!==e&&(this._owner=e,this.dirty=!0)}},debugShowBoundingVolume:{get:function(){return Bt(this,nt.DEBUG_SHOW_BOUNDING_VOLUME)},set:function(e){Bt(this,nt.DEBUG_SHOW_BOUNDING_VOLUME)!==e&&(wi(this,nt.DEBUG_SHOW_BOUNDING_VOLUME,e),this.dirty=!0)}},debugOverlappingFrustums:{get:function(){return this._debugOverlappingFrustums},set:function(e){this._debugOverlappingFrustums!==e&&(this._debugOverlappingFrustums=e,this.dirty=!0)}},pickId:{get:function(){return this._pickId},set:function(e){this._pickId!==e&&(this._pickId=e,this.dirty=!0)}},pickOnly:{get:function(){return Bt(this,nt.PICK_ONLY)},set:function(e){Bt(this,nt.PICK_ONLY)!==e&&(wi(this,nt.PICK_ONLY,e),this.dirty=!0)}},depthForTranslucentClassification:{get:function(){return Bt(this,nt.DEPTH_FOR_TRANSLUCENT_CLASSIFICATION)},set:function(e){Bt(this,nt.DEPTH_FOR_TRANSLUCENT_CLASSIFICATION)!==e&&(wi(this,nt.DEPTH_FOR_TRANSLUCENT_CLASSIFICATION,e),this.dirty=!0)}}}),We.shallowClone=function(e,t){if(h(e))return h(t)||(t=new We),t._boundingVolume=e._boundingVolume,t._orientedBoundingBox=e._orientedBoundingBox,t._modelMatrix=e._modelMatrix,t._primitiveType=e._primitiveType,t._vertexArray=e._vertexArray,t._count=e._count,t._offset=e._offset,t._instanceCount=e._instanceCount,t._shaderProgram=e._shaderProgram,t._uniformMap=e._uniformMap,t._renderState=e._renderState,t._framebuffer=e._framebuffer,t._pass=e._pass,t._owner=e._owner,t._debugOverlappingFrustums=e._debugOverlappingFrustums,t._pickId=e._pickId,t._flags=e._flags,t.dirty=!0,t.lastDirtyTime=0,t},We.prototype.execute=function(e,t){e.draw(this,t)};const on=Object.freeze({ENVIRONMENT:0,COMPUTE:1,GLOBE:2,TERRAIN_CLASSIFICATION:3,CESIUM_3D_TILE:4,CESIUM_3D_TILE_CLASSIFICATION:5,CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW:6,OPAQUE:7,TRANSLUCENT:8,VOXELS:9,OVERLAY:10,NUMBER_OF_PASSES:11}),xs={CLOCKWISE:I.CW,COUNTER_CLOCKWISE:I.CCW};xs.validate=function(e){return e===xs.CLOCKWISE||e===xs.COUNTER_CLOCKWISE};const Yu=Object.freeze(xs);function $u(e){if(typeof e!="object"||e===null)return e;let t;const n=Object.keys(e);for(let i=0;ixt.maximumAliasedLineWidth)throw new T("renderState.lineWidth is out of range. Check minimumAliasedLineWidth and maximumAliasedLineWidth.");if(!Yu.validate(this.frontFace))throw new T("Invalid renderState.frontFace.");if(!fb(this.cull.face))throw new T("Invalid renderState.cull.face.");if(this.scissorTest.rectangle.width<0||this.scissorTest.rectangle.height<0)throw new T("renderState.scissorTest.rectangle.width and renderState.scissorTest.rectangle.height must be greater than or equal to zero.");if(this.depthRange.near>this.depthRange.far)throw new T("renderState.depthRange.near can not be greater than renderState.depthRange.far.");if(this.depthRange.near<0)throw new T("renderState.depthRange.near must be greater than or equal to zero.");if(this.depthRange.far>1)throw new T("renderState.depthRange.far must be less than or equal to one.");if(!db(this.depthTest.func))throw new T("Invalid renderState.depthTest.func.");if(this.blending.color.red<0||this.blending.color.red>1||this.blending.color.green<0||this.blending.color.green>1||this.blending.color.blue<0||this.blending.color.blue>1||this.blending.color.alpha<0||this.blending.color.alpha>1)throw new T("renderState.blending.color components must be greater than or equal to zero and less than or equal to one.");if(!Xu(this.blending.equationRgb))throw new T("Invalid renderState.blending.equationRgb.");if(!Xu(this.blending.equationAlpha))throw new T("Invalid renderState.blending.equationAlpha.");if(!Ps(this.blending.functionSourceRgb))throw new T("Invalid renderState.blending.functionSourceRgb.");if(!Ps(this.blending.functionSourceAlpha))throw new T("Invalid renderState.blending.functionSourceAlpha.");if(!Ps(this.blending.functionDestinationRgb))throw new T("Invalid renderState.blending.functionDestinationRgb.");if(!Ps(this.blending.functionDestinationAlpha))throw new T("Invalid renderState.blending.functionDestinationAlpha.");if(!Ku(this.stencilTest.frontFunction))throw new T("Invalid renderState.stencilTest.frontFunction.");if(!Ku(this.stencilTest.backFunction))throw new T("Invalid renderState.stencilTest.backFunction.");if(!Co(this.stencilTest.frontOperation.fail))throw new T("Invalid renderState.stencilTest.frontOperation.fail.");if(!Co(this.stencilTest.frontOperation.zFail))throw new T("Invalid renderState.stencilTest.frontOperation.zFail.");if(!Co(this.stencilTest.frontOperation.zPass))throw new T("Invalid renderState.stencilTest.frontOperation.zPass.");if(!Co(this.stencilTest.backOperation.fail))throw new T("Invalid renderState.stencilTest.backOperation.fail.");if(!Co(this.stencilTest.backOperation.zFail))throw new T("Invalid renderState.stencilTest.backOperation.zFail.");if(!Co(this.stencilTest.backOperation.zPass))throw new T("Invalid renderState.stencilTest.backOperation.zPass.");if(h(this.viewport)){if(this.viewport.width<0)throw new T("renderState.viewport.width must be greater than or equal to zero.");if(this.viewport.height<0)throw new T("renderState.viewport.height must be greater than or equal to zero.");if(this.viewport.width>xt.maximumViewportWidth)throw new T(`renderState.viewport.width must be less than or equal to the maximum viewport width (${xt.maximumViewportWidth.toString()}). Check maximumViewportWidth.`);if(this.viewport.height>xt.maximumViewportHeight)throw new T(`renderState.viewport.height must be less than or equal to the maximum viewport height (${xt.maximumViewportHeight.toString()}). Check maximumViewportHeight.`)}this.id=0,this._applyFunctions=[]}let pb=0,Dn={};Ge.fromCache=function(e){const t=JSON.stringify(e);let n=Dn[t];if(h(n))return++n.referenceCount,n.state;let i=new Ge(e);const o=JSON.stringify(i);return n=Dn[o],h(n)||(i.id=pb++,i=$u(i),n={referenceCount:0,state:i},Dn[o]=n),++n.referenceCount,Dn[t]={referenceCount:1,state:n.state},n.state},Ge.removeFromCache=function(e){const t=new Ge(e),n=JSON.stringify(t),i=Dn[n],o=JSON.stringify(e),r=Dn[o];h(r)&&(--r.referenceCount,r.referenceCount===0&&(delete Dn[o],h(i)&&--i.referenceCount)),h(i)&&i.referenceCount===0&&delete Dn[n]},Ge.getCache=function(){return Dn},Ge.clearCache=function(){Dn={}};function ki(e,t,n){n?e.enable(t):e.disable(t)}function Zu(e,t){e.frontFace(t.frontFace)}function Qu(e,t){const n=t.cull,i=n.enabled;ki(e,e.CULL_FACE,i),i&&e.cullFace(n.face)}function Ju(e,t){e.lineWidth(t.lineWidth)}function ef(e,t){const n=t.polygonOffset,i=n.enabled;ki(e,e.POLYGON_OFFSET_FILL,i),i&&e.polygonOffset(n.factor,n.units)}function tf(e,t,n){const i=t.scissorTest,o=h(n.scissorTest)?n.scissorTest.enabled:i.enabled;if(ki(e,e.SCISSOR_TEST,o),o){const r=h(n.scissorTest)?n.scissorTest.rectangle:i.rectangle;e.scissor(r.x,r.y,r.width,r.height)}}function nf(e,t){const n=t.depthRange;e.depthRange(n.near,n.far)}function of(e,t){const n=t.depthTest,i=n.enabled;ki(e,e.DEPTH_TEST,i),i&&e.depthFunc(n.func)}function rf(e,t){const n=t.colorMask;e.colorMask(n.red,n.green,n.blue,n.alpha)}function sf(e,t){e.depthMask(t.depthMask)}function af(e,t){e.stencilMask(t.stencilMask)}function mb(e,t){e.blendColor(t.red,t.green,t.blue,t.alpha)}function cf(e,t,n){const i=t.blending,o=h(n.blendingEnabled)?n.blendingEnabled:i.enabled;ki(e,e.BLEND,o),o&&(mb(e,i.color),e.blendEquationSeparate(i.equationRgb,i.equationAlpha),e.blendFuncSeparate(i.functionSourceRgb,i.functionDestinationRgb,i.functionSourceAlpha,i.functionDestinationAlpha))}function lf(e,t){const n=t.stencilTest,i=n.enabled;if(ki(e,e.STENCIL_TEST,i),i){const o=n.frontFunction,r=n.backFunction,s=n.reference,a=n.mask;e.stencilFunc(o,s,a),e.stencilFuncSeparate(e.BACK,r,s,a),e.stencilFuncSeparate(e.FRONT,o,s,a);const c=n.frontOperation,u=c.fail,f=c.zFail,p=c.zPass;e.stencilOpSeparate(e.FRONT,u,f,p);const _=n.backOperation,g=_.fail,y=_.zFail,b=_.zPass;e.stencilOpSeparate(e.BACK,g,y,b)}}function hf(e,t){const n=t.sampleCoverage,i=n.enabled;ki(e,e.SAMPLE_COVERAGE,i),i&&e.sampleCoverage(n.value,n.invert)}const _b=new je;function uf(e,t,n){let i=m(t.viewport,n.viewport);h(i)||(i=_b,i.width=n.context.drawingBufferWidth,i.height=n.context.drawingBufferHeight),n.context.uniformState.viewport=i,e.viewport(i.x,i.y,i.width,i.height)}Ge.apply=function(e,t,n){Zu(e,t),Qu(e,t),Ju(e,t),ef(e,t),nf(e,t),of(e,t),rf(e,t),sf(e,t),af(e,t),lf(e,t),hf(e,t),tf(e,t,n),cf(e,t,n),uf(e,t,n)};function gb(e,t){const n=[];return e.frontFace!==t.frontFace&&n.push(Zu),(e.cull.enabled!==t.cull.enabled||e.cull.face!==t.cull.face)&&n.push(Qu),e.lineWidth!==t.lineWidth&&n.push(Ju),(e.polygonOffset.enabled!==t.polygonOffset.enabled||e.polygonOffset.factor!==t.polygonOffset.factor||e.polygonOffset.units!==t.polygonOffset.units)&&n.push(ef),(e.depthRange.near!==t.depthRange.near||e.depthRange.far!==t.depthRange.far)&&n.push(nf),(e.depthTest.enabled!==t.depthTest.enabled||e.depthTest.func!==t.depthTest.func)&&n.push(of),(e.colorMask.red!==t.colorMask.red||e.colorMask.green!==t.colorMask.green||e.colorMask.blue!==t.colorMask.blue||e.colorMask.alpha!==t.colorMask.alpha)&&n.push(rf),e.depthMask!==t.depthMask&&n.push(sf),e.stencilMask!==t.stencilMask&&n.push(af),(e.stencilTest.enabled!==t.stencilTest.enabled||e.stencilTest.frontFunction!==t.stencilTest.frontFunction||e.stencilTest.backFunction!==t.stencilTest.backFunction||e.stencilTest.reference!==t.stencilTest.reference||e.stencilTest.mask!==t.stencilTest.mask||e.stencilTest.frontOperation.fail!==t.stencilTest.frontOperation.fail||e.stencilTest.frontOperation.zFail!==t.stencilTest.frontOperation.zFail||e.stencilTest.backOperation.fail!==t.stencilTest.backOperation.fail||e.stencilTest.backOperation.zFail!==t.stencilTest.backOperation.zFail||e.stencilTest.backOperation.zPass!==t.stencilTest.backOperation.zPass)&&n.push(lf),(e.sampleCoverage.enabled!==t.sampleCoverage.enabled||e.sampleCoverage.value!==t.sampleCoverage.value||e.sampleCoverage.invert!==t.sampleCoverage.invert)&&n.push(hf),n}Ge.partialApply=function(e,t,n,i,o,r){if(t!==n){let f=n._applyFunctions[t.id];h(f)||(f=gb(t,n),n._applyFunctions[t.id]=f);const p=f.length;for(let _=0;_0&&console.log(`${Mn}Vertex shader compile log: ${c}`),c=e.getShaderInfoLog(r),h(c)&&c.length>0&&console.log(`${Mn}Fragment shader compile log: ${c}`),c=e.getProgramInfoLog(s),h(c)&&c.length>0&&console.log(`${Mn}Shader program link log: ${c}`)),e.deleteShader(o),e.deleteShader(r),s;let u;const f=t._debugShaders;throw e.getShaderParameter(r,e.COMPILE_STATUS)?e.getShaderParameter(o,e.COMPILE_STATUS)?(c=e.getProgramInfoLog(s),console.error(`${Mn}Shader program link log: ${c}`),p(o,"vertex"),p(r,"fragment"),u=`Program failed to link. Link log: ${c}`):(c=e.getShaderInfoLog(o),console.error(`${Mn}Vertex shader compile log: ${c}`),console.error(`${Mn} Vertex shader source: ${n}`),u=`Vertex shader failed to compile. Compile log: ${c}`):(c=e.getShaderInfoLog(r),console.error(`${Mn}Fragment shader compile log: ${c}`),console.error(`${Mn} Fragment shader source: ${i}`),u=`Fragment shader failed to compile. Compile log: ${c}`),e.deleteShader(o),e.deleteShader(r),e.deleteProgram(s),new dt(u);function p(_,g){if(!h(f))return;const y=f.getTranslatedShaderSource(_);if(y===""){console.error(`${Mn}${g} shader translation failed.`);return}console.error(`${Mn}Translated ${g} shaderSource: ${y}`)}}function vb(e,t,n){const i={};for(let o=0;o=0){if(f=n[u.slice(0,y)],!h(f))continue;p=f._locations,p.length<=1&&(_=f.value,g=e.getUniformLocation(t,u),g!==null&&(p.push(g),_.push(e.getUniform(t,g))))}else{p=[];for(let b=0;b abs(x), czm_piOverTwo - t, t); t = czm_branchFreeTernary(x < 0.0, czm_pi - t, t); t = czm_branchFreeTernary(y < 0.0, -t, t); return t; } `,czm_fog:`/** * Gets the color with fog at a distance from the camera. * * @name czm_fog * @glslFunction * * @param {float} distanceToCamera The distance to the camera in meters. * @param {vec3} color The original color. * @param {vec3} fogColor The color of the fog. * * @returns {vec3} The color adjusted for fog at the distance from the camera. */ vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor) { float scalar = distanceToCamera * czm_fogDensity; float fog = 1.0 - exp(-(scalar * scalar)); return mix(color, fogColor, fog); } /** * Gets the color with fog at a distance from the camera. * * @name czm_fog * @glslFunction * * @param {float} distanceToCamera The distance to the camera in meters. * @param {vec3} color The original color. * @param {vec3} fogColor The color of the fog. * @param {float} fogModifierConstant A constant to modify the appearance of fog. * * @returns {vec3} The color adjusted for fog at the distance from the camera. */ vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor, float fogModifierConstant) { float scalar = distanceToCamera * czm_fogDensity; float fog = 1.0 - exp(-((fogModifierConstant * scalar + fogModifierConstant) * (scalar * (1.0 + fogModifierConstant)))); return mix(color, fogColor, fog); } `,czm_gammaCorrect:`/** * Converts a color from RGB space to linear space. * * @name czm_gammaCorrect * @glslFunction * * @param {vec3} color The color in RGB space. * @returns {vec3} The color in linear space. */ vec3 czm_gammaCorrect(vec3 color) { #ifdef HDR color = pow(color, vec3(czm_gamma)); #endif return color; } vec4 czm_gammaCorrect(vec4 color) { #ifdef HDR color.rgb = pow(color.rgb, vec3(czm_gamma)); #endif return color; } `,czm_geodeticSurfaceNormal:`/** * DOC_TBA * * @name czm_geodeticSurfaceNormal * @glslFunction * * @param {vec3} positionOnEllipsoid DOC_TBA * @param {vec3} ellipsoidCenter DOC_TBA * @param {vec3} oneOverEllipsoidRadiiSquared DOC_TBA * * @returns {vec3} DOC_TBA. */ vec3 czm_geodeticSurfaceNormal(vec3 positionOnEllipsoid, vec3 ellipsoidCenter, vec3 oneOverEllipsoidRadiiSquared) { return normalize((positionOnEllipsoid - ellipsoidCenter) * oneOverEllipsoidRadiiSquared); } `,czm_getDefaultMaterial:`/** * An czm_material with default values. Every material's czm_getMaterial * should use this default material as a base for the material it returns. * The default normal value is given by materialInput.normalEC. * * @name czm_getDefaultMaterial * @glslFunction * * @param {czm_materialInput} input The input used to construct the default material. * * @returns {czm_material} The default material. * * @see czm_materialInput * @see czm_material * @see czm_getMaterial */ czm_material czm_getDefaultMaterial(czm_materialInput materialInput) { czm_material material; material.diffuse = vec3(0.0); material.specular = 0.0; material.shininess = 1.0; material.normal = materialInput.normalEC; material.emission = vec3(0.0); material.alpha = 1.0; return material; } `,czm_getLambertDiffuse:`/** * Calculates the intensity of diffusely reflected light. * * @name czm_getLambertDiffuse * @glslFunction * * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates. * @param {vec3} normalEC The surface normal in eye coordinates. * * @returns {float} The intensity of the diffuse reflection. * * @see czm_phong * * @example * float diffuseIntensity = czm_getLambertDiffuse(lightDirectionEC, normalEC); * float specularIntensity = czm_getSpecular(lightDirectionEC, toEyeEC, normalEC, 200); * vec3 color = (diffuseColor * diffuseIntensity) + (specularColor * specularIntensity); */ float czm_getLambertDiffuse(vec3 lightDirectionEC, vec3 normalEC) { return max(dot(lightDirectionEC, normalEC), 0.0); } `,czm_getSpecular:`/** * Calculates the specular intensity of reflected light. * * @name czm_getSpecular * @glslFunction * * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates. * @param {vec3} toEyeEC Unit vector pointing to the eye position in eye coordinates. * @param {vec3} normalEC The surface normal in eye coordinates. * @param {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight. * * @returns {float} The intensity of the specular highlight. * * @see czm_phong * * @example * float diffuseIntensity = czm_getLambertDiffuse(lightDirectionEC, normalEC); * float specularIntensity = czm_getSpecular(lightDirectionEC, toEyeEC, normalEC, 200); * vec3 color = (diffuseColor * diffuseIntensity) + (specularColor * specularIntensity); */ float czm_getSpecular(vec3 lightDirectionEC, vec3 toEyeEC, vec3 normalEC, float shininess) { vec3 toReflectedLight = reflect(-lightDirectionEC, normalEC); float specular = max(dot(toReflectedLight, toEyeEC), 0.0); // pow has undefined behavior if both parameters <= 0. // Prevent this by making sure shininess is at least czm_epsilon2. return pow(specular, max(shininess, czm_epsilon2)); } `,czm_getWaterNoise:`/** * @private */ vec4 czm_getWaterNoise(sampler2D normalMap, vec2 uv, float time, float angleInRadians) { float cosAngle = cos(angleInRadians); float sinAngle = sin(angleInRadians); // time dependent sampling directions vec2 s0 = vec2(1.0/17.0, 0.0); vec2 s1 = vec2(-1.0/29.0, 0.0); vec2 s2 = vec2(1.0/101.0, 1.0/59.0); vec2 s3 = vec2(-1.0/109.0, -1.0/57.0); // rotate sampling direction by specified angle s0 = vec2((cosAngle * s0.x) - (sinAngle * s0.y), (sinAngle * s0.x) + (cosAngle * s0.y)); s1 = vec2((cosAngle * s1.x) - (sinAngle * s1.y), (sinAngle * s1.x) + (cosAngle * s1.y)); s2 = vec2((cosAngle * s2.x) - (sinAngle * s2.y), (sinAngle * s2.x) + (cosAngle * s2.y)); s3 = vec2((cosAngle * s3.x) - (sinAngle * s3.y), (sinAngle * s3.x) + (cosAngle * s3.y)); vec2 uv0 = (uv/103.0) + (time * s0); vec2 uv1 = uv/107.0 + (time * s1) + vec2(0.23); vec2 uv2 = uv/vec2(897.0, 983.0) + (time * s2) + vec2(0.51); vec2 uv3 = uv/vec2(991.0, 877.0) + (time * s3) + vec2(0.71); uv0 = fract(uv0); uv1 = fract(uv1); uv2 = fract(uv2); uv3 = fract(uv3); vec4 noise = (texture(normalMap, uv0)) + (texture(normalMap, uv1)) + (texture(normalMap, uv2)) + (texture(normalMap, uv3)); // average and scale to between -1 and 1 return ((noise / 4.0) - 0.5) * 2.0; } `,czm_hue:`/** * Adjusts the hue of a color. * * @name czm_hue * @glslFunction * * @param {vec3} rgb The color. * @param {float} adjustment The amount to adjust the hue of the color in radians. * * @returns {float} The color with the hue adjusted. * * @example * vec3 adjustHue = czm_hue(color, czm_pi); // The same as czm_hue(color, -czm_pi) */ vec3 czm_hue(vec3 rgb, float adjustment) { const mat3 toYIQ = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135); const mat3 toRGB = mat3(1.0, 0.9563, 0.6210, 1.0, -0.2721, -0.6474, 1.0, -1.107, 1.7046); vec3 yiq = toYIQ * rgb; float hue = atan(yiq.z, yiq.y) + adjustment; float chroma = sqrt(yiq.z * yiq.z + yiq.y * yiq.y); vec3 color = vec3(yiq.x, chroma * cos(hue), chroma * sin(hue)); return toRGB * color; } `,czm_inverseGamma:`/** * Converts a color in linear space to RGB space. * * @name czm_inverseGamma * @glslFunction * * @param {vec3} color The color in linear space. * @returns {vec3} The color in RGB space. */ vec3 czm_inverseGamma(vec3 color) { return pow(color, vec3(1.0 / czm_gamma)); } `,czm_isEmpty:`/** * Determines if a time interval is empty. * * @name czm_isEmpty * @glslFunction * * @param {czm_raySegment} interval The interval to test. * * @returns {bool} true if the time interval is empty; otherwise, false. * * @example * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0. */ bool czm_isEmpty(czm_raySegment interval) { return (interval.stop < 0.0); } `,czm_isFull:`/** * Determines if a time interval is empty. * * @name czm_isFull * @glslFunction * * @param {czm_raySegment} interval The interval to test. * * @returns {bool} true if the time interval is empty; otherwise, false. * * @example * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0. */ bool czm_isFull(czm_raySegment interval) { return (interval.start == 0.0 && interval.stop == czm_infinity); } `,czm_latitudeToWebMercatorFraction:`/** * Computes the fraction of a Web Wercator rectangle at which a given geodetic latitude is located. * * @name czm_latitudeToWebMercatorFraction * @glslFunction * * @param {float} latitude The geodetic latitude, in radians. * @param {float} southMercatorY The Web Mercator coordinate of the southern boundary of the rectangle. * @param {float} oneOverMercatorHeight The total height of the rectangle in Web Mercator coordinates. * * @returns {float} The fraction of the rectangle at which the latitude occurs. If the latitude is the southern * boundary of the rectangle, the return value will be zero. If it is the northern boundary, the return * value will be 1.0. Latitudes in between are mapped according to the Web Mercator projection. */ float czm_latitudeToWebMercatorFraction(float latitude, float southMercatorY, float oneOverMercatorHeight) { float sinLatitude = sin(latitude); float mercatorY = 0.5 * log((1.0 + sinLatitude) / (1.0 - sinLatitude)); return (mercatorY - southMercatorY) * oneOverMercatorHeight; } `,czm_lineDistance:`/** * Computes distance from an point in 2D to a line in 2D. * * @name czm_lineDistance * @glslFunction * * param {vec2} point1 A point along the line. * param {vec2} point2 A point along the line. * param {vec2} point A point that may or may not be on the line. * returns {float} The distance from the point to the line. */ float czm_lineDistance(vec2 point1, vec2 point2, vec2 point) { return abs((point2.y - point1.y) * point.x - (point2.x - point1.x) * point.y + point2.x * point1.y - point2.y * point1.x) / distance(point2, point1); } `,czm_linearToSrgb:`/** * Converts a linear RGB color to an sRGB color. * * @param {vec3|vec4} linearIn The color in linear color space. * @returns {vec3|vec4} The color in sRGB color space. The vector type matches the input. */ vec3 czm_linearToSrgb(vec3 linearIn) { return pow(linearIn, vec3(1.0/2.2)); } vec4 czm_linearToSrgb(vec4 linearIn) { vec3 srgbOut = pow(linearIn.rgb, vec3(1.0/2.2)); return vec4(srgbOut, linearIn.a); } `,czm_luminance:`/** * Computes the luminance of a color. * * @name czm_luminance * @glslFunction * * @param {vec3} rgb The color. * * @returns {float} The luminance. * * @example * float light = czm_luminance(vec3(0.0)); // 0.0 * float dark = czm_luminance(vec3(1.0)); // ~1.0 */ float czm_luminance(vec3 rgb) { // Algorithm from Chapter 10 of Graphics Shaders. const vec3 W = vec3(0.2125, 0.7154, 0.0721); return dot(rgb, W); } `,czm_metersPerPixel:`/** * Computes the size of a pixel in meters at a distance from the eye. *

* Use this version when passing in a custom pixel ratio. For example, passing in 1.0 will return meters per native device pixel. *

* @name czm_metersPerPixel * @glslFunction * * @param {vec3} positionEC The position to get the meters per pixel in eye coordinates. * @param {float} pixelRatio The scaling factor from pixel space to coordinate space * * @returns {float} The meters per pixel at positionEC. */ float czm_metersPerPixel(vec4 positionEC, float pixelRatio) { float width = czm_viewport.z; float height = czm_viewport.w; float pixelWidth; float pixelHeight; float top = czm_frustumPlanes.x; float bottom = czm_frustumPlanes.y; float left = czm_frustumPlanes.z; float right = czm_frustumPlanes.w; if (czm_sceneMode == czm_sceneMode2D || czm_orthographicIn3D == 1.0) { float frustumWidth = right - left; float frustumHeight = top - bottom; pixelWidth = frustumWidth / width; pixelHeight = frustumHeight / height; } else { float distanceToPixel = -positionEC.z; float inverseNear = 1.0 / czm_currentFrustum.x; float tanTheta = top * inverseNear; pixelHeight = 2.0 * distanceToPixel * tanTheta / height; tanTheta = right * inverseNear; pixelWidth = 2.0 * distanceToPixel * tanTheta / width; } return max(pixelWidth, pixelHeight) * pixelRatio; } /** * Computes the size of a pixel in meters at a distance from the eye. *

* Use this version when scaling by pixel ratio. *

* @name czm_metersPerPixel * @glslFunction * * @param {vec3} positionEC The position to get the meters per pixel in eye coordinates. * * @returns {float} The meters per pixel at positionEC. */ float czm_metersPerPixel(vec4 positionEC) { return czm_metersPerPixel(positionEC, czm_pixelRatio); } `,czm_modelToWindowCoordinates:`/** * Transforms a position from model to window coordinates. The transformation * from model to clip coordinates is done using {@link czm_modelViewProjection}. * The transform from normalized device coordinates to window coordinates is * done using {@link czm_viewportTransformation}, which assumes a depth range * of near = 0 and far = 1. *

* This transform is useful when there is a need to manipulate window coordinates * in a vertex shader as done by {@link BillboardCollection}. *

* This function should not be confused with {@link czm_viewportOrthographic}, * which is an orthographic projection matrix that transforms from window * coordinates to clip coordinates. * * @name czm_modelToWindowCoordinates * @glslFunction * * @param {vec4} position The position in model coordinates to transform. * * @returns {vec4} The transformed position in window coordinates. * * @see czm_eyeToWindowCoordinates * @see czm_modelViewProjection * @see czm_viewportTransformation * @see czm_viewportOrthographic * @see BillboardCollection * * @example * vec4 positionWC = czm_modelToWindowCoordinates(positionMC); */ vec4 czm_modelToWindowCoordinates(vec4 position) { vec4 q = czm_modelViewProjection * position; // clip coordinates q.xyz /= q.w; // normalized device coordinates q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates return q; } `,czm_multiplyWithColorBalance:`/** * DOC_TBA * * @name czm_multiplyWithColorBalance * @glslFunction */ vec3 czm_multiplyWithColorBalance(vec3 left, vec3 right) { // Algorithm from Chapter 10 of Graphics Shaders. const vec3 W = vec3(0.2125, 0.7154, 0.0721); vec3 target = left * right; float leftLuminance = dot(left, W); float rightLuminance = dot(right, W); float targetLuminance = dot(target, W); return ((leftLuminance + rightLuminance) / (2.0 * targetLuminance)) * target; } `,czm_nearFarScalar:`/** * Computes a value that scales with distance. The scaling is clamped at the near and * far distances, and does not extrapolate. This function works with the * {@link NearFarScalar} JavaScript class. * * @name czm_nearFarScalar * @glslFunction * * @param {vec4} nearFarScalar A vector with 4 components: Near distance (x), Near value (y), Far distance (z), Far value (w). * @param {float} cameraDistSq The square of the current distance from the camera. * * @returns {float} The value at this distance. */ float czm_nearFarScalar(vec4 nearFarScalar, float cameraDistSq) { float valueAtMin = nearFarScalar.y; float valueAtMax = nearFarScalar.w; float nearDistanceSq = nearFarScalar.x * nearFarScalar.x; float farDistanceSq = nearFarScalar.z * nearFarScalar.z; float t = (cameraDistSq - nearDistanceSq) / (farDistanceSq - nearDistanceSq); t = pow(clamp(t, 0.0, 1.0), 0.2); return mix(valueAtMin, valueAtMax, t); } `,czm_octDecode:` /** * Decodes a unit-length vector in 'oct' encoding to a normalized 3-component Cartesian vector. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors", * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/ * * @name czm_octDecode * @param {vec2} encoded The oct-encoded, unit-length vector * @param {float} range The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits. * @returns {vec3} The decoded and normalized vector */ vec3 czm_octDecode(vec2 encoded, float range) { if (encoded.x == 0.0 && encoded.y == 0.0) { return vec3(0.0, 0.0, 0.0); } encoded = encoded / range * 2.0 - 1.0; vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y)); if (v.z < 0.0) { v.xy = (1.0 - abs(v.yx)) * czm_signNotZero(v.xy); } return normalize(v); } /** * Decodes a unit-length vector in 'oct' encoding to a normalized 3-component Cartesian vector. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors", * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/ * * @name czm_octDecode * @param {vec2} encoded The oct-encoded, unit-length vector * @returns {vec3} The decoded and normalized vector */ vec3 czm_octDecode(vec2 encoded) { return czm_octDecode(encoded, 255.0); } /** * Decodes a unit-length vector in 'oct' encoding packed into a floating-point number to a normalized 3-component Cartesian vector. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors", * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/ * * @name czm_octDecode * @param {float} encoded The oct-encoded, unit-length vector * @returns {vec3} The decoded and normalized vector */ vec3 czm_octDecode(float encoded) { float temp = encoded / 256.0; float x = floor(temp); float y = (temp - x) * 256.0; return czm_octDecode(vec2(x, y)); } /** * Decodes three unit-length vectors in 'oct' encoding packed into two floating-point numbers to normalized 3-component Cartesian vectors. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors", * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/ * * @name czm_octDecode * @param {vec2} encoded The packed oct-encoded, unit-length vectors. * @param {vec3} vector1 One decoded and normalized vector. * @param {vec3} vector2 One decoded and normalized vector. * @param {vec3} vector3 One decoded and normalized vector. */ void czm_octDecode(vec2 encoded, out vec3 vector1, out vec3 vector2, out vec3 vector3) { float temp = encoded.x / 65536.0; float x = floor(temp); float encodedFloat1 = (temp - x) * 65536.0; temp = encoded.y / 65536.0; float y = floor(temp); float encodedFloat2 = (temp - y) * 65536.0; vector1 = czm_octDecode(encodedFloat1); vector2 = czm_octDecode(encodedFloat2); vector3 = czm_octDecode(vec2(x, y)); } `,czm_packDepth:`/** * Packs a depth value into a vec3 that can be represented by unsigned bytes. * * @name czm_packDepth * @glslFunction * * @param {float} depth The floating-point depth. * @returns {vec3} The packed depth. */ vec4 czm_packDepth(float depth) { // See Aras Pranckevičius' post Encoding Floats to RGBA // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/ vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth; enc = fract(enc); enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0); return enc; } `,czm_pbrLighting:`vec3 lambertianDiffuse(vec3 diffuseColor) { return diffuseColor / czm_pi; } vec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH) { return f0 + (f90 - f0) * pow(clamp(1.0 - VdotH, 0.0, 1.0), 5.0); } float smithVisibilityG1(float NdotV, float roughness) { // this is the k value for direct lighting. // for image based lighting it will be roughness^2 / 2 float k = (roughness + 1.0) * (roughness + 1.0) / 8.0; return NdotV / (NdotV * (1.0 - k) + k); } float smithVisibilityGGX(float roughness, float NdotL, float NdotV) { return ( smithVisibilityG1(NdotL, roughness) * smithVisibilityG1(NdotV, roughness) ); } float GGX(float roughness, float NdotH) { float roughnessSquared = roughness * roughness; float f = (NdotH * roughnessSquared - NdotH) * NdotH + 1.0; return roughnessSquared / (czm_pi * f * f); } /** * Compute the diffuse and specular contributions using physically based * rendering. This function only handles direct lighting. *

* This function only handles the lighting calculations. Metallic/roughness * and specular/glossy must be handled separately. See {@czm_pbrMetallicRoughnessMaterial}, {@czm_pbrSpecularGlossinessMaterial} and {@czm_defaultPbrMaterial} *

* * @name czm_pbrlighting * @glslFunction * * @param {vec3} positionEC The position of the fragment in eye coordinates * @param {vec3} normalEC The surface normal in eye coordinates * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates. * @param {vec3} lightColorHdr radiance of the light source. This is a HDR value. * @param {czm_pbrParameters} The computed PBR parameters. * @return {vec3} The computed HDR color * * @example * czm_pbrParameters pbrParameters = czm_pbrMetallicRoughnessMaterial( * baseColor, * metallic, * roughness * ); * vec3 color = czm_pbrlighting( * positionEC, * normalEC, * lightDirectionEC, * lightColorHdr, * pbrParameters); */ vec3 czm_pbrLighting( vec3 positionEC, vec3 normalEC, vec3 lightDirectionEC, vec3 lightColorHdr, czm_pbrParameters pbrParameters ) { vec3 v = -normalize(positionEC); vec3 l = normalize(lightDirectionEC); vec3 h = normalize(v + l); vec3 n = normalEC; float NdotL = clamp(dot(n, l), 0.001, 1.0); float NdotV = abs(dot(n, v)) + 0.001; float NdotH = clamp(dot(n, h), 0.0, 1.0); float LdotH = clamp(dot(l, h), 0.0, 1.0); float VdotH = clamp(dot(v, h), 0.0, 1.0); vec3 f0 = pbrParameters.f0; float reflectance = max(max(f0.r, f0.g), f0.b); vec3 f90 = vec3(clamp(reflectance * 25.0, 0.0, 1.0)); vec3 F = fresnelSchlick2(f0, f90, VdotH); float alpha = pbrParameters.roughness; float G = smithVisibilityGGX(alpha, NdotL, NdotV); float D = GGX(alpha, NdotH); vec3 specularContribution = F * G * D / (4.0 * NdotL * NdotV); vec3 diffuseColor = pbrParameters.diffuseColor; // F here represents the specular contribution vec3 diffuseContribution = (1.0 - F) * lambertianDiffuse(diffuseColor); // Lo = (diffuse + specular) * Li * NdotL return (diffuseContribution + specularContribution) * NdotL * lightColorHdr; } `,czm_pbrMetallicRoughnessMaterial:`/** * Compute parameters for physically based rendering using the * metallic/roughness workflow. All inputs are linear; sRGB texture values must * be decoded beforehand * * @name czm_pbrMetallicRoughnessMaterial * @glslFunction * * @param {vec3} baseColor For dielectrics, this is the base color. For metals, this is the f0 value (reflectance at normal incidence) * @param {float} metallic 0.0 indicates dielectric. 1.0 indicates metal. Values in between are allowed (e.g. to model rust or dirt); * @param {float} roughness A value between 0.0 and 1.0 * @return {czm_pbrParameters} parameters to pass into {@link czm_pbrLighting} */ czm_pbrParameters czm_pbrMetallicRoughnessMaterial( vec3 baseColor, float metallic, float roughness ) { czm_pbrParameters results; // roughness is authored as perceptual roughness // square it to get material roughness roughness = clamp(roughness, 0.0, 1.0); results.roughness = roughness * roughness; // dielectrics use f0 = 0.04, metals use albedo as f0 metallic = clamp(metallic, 0.0, 1.0); const vec3 REFLECTANCE_DIELECTRIC = vec3(0.04); vec3 f0 = mix(REFLECTANCE_DIELECTRIC, baseColor, metallic); results.f0 = f0; // diffuse only applies to dielectrics. results.diffuseColor = baseColor * (1.0 - f0) * (1.0 - metallic); return results; } `,czm_pbrSpecularGlossinessMaterial:`/** * Compute parameters for physically based rendering using the * specular/glossy workflow. All inputs are linear; sRGB texture values must * be decoded beforehand * * @name czm_pbrSpecularGlossinessMaterial * @glslFunction * * @param {vec3} diffuse The diffuse color for dielectrics (non-metals) * @param {vec3} specular The reflectance at normal incidence (f0) * @param {float} glossiness A number from 0.0 to 1.0 indicating how smooth the surface is. * @return {czm_pbrParameters} parameters to pass into {@link czm_pbrLighting} */ czm_pbrParameters czm_pbrSpecularGlossinessMaterial( vec3 diffuse, vec3 specular, float glossiness ) { czm_pbrParameters results; // glossiness is the opposite of roughness, but easier for artists to use. float roughness = 1.0 - glossiness; results.roughness = roughness * roughness; results.diffuseColor = diffuse * (1.0 - max(max(specular.r, specular.g), specular.b)); results.f0 = specular; return results; } `,czm_phong:`float czm_private_getLambertDiffuseOfMaterial(vec3 lightDirectionEC, czm_material material) { return czm_getLambertDiffuse(lightDirectionEC, material.normal); } float czm_private_getSpecularOfMaterial(vec3 lightDirectionEC, vec3 toEyeEC, czm_material material) { return czm_getSpecular(lightDirectionEC, toEyeEC, material.normal, material.shininess); } /** * Computes a color using the Phong lighting model. * * @name czm_phong * @glslFunction * * @param {vec3} toEye A normalized vector from the fragment to the eye in eye coordinates. * @param {czm_material} material The fragment's material. * * @returns {vec4} The computed color. * * @example * vec3 positionToEyeEC = // ... * czm_material material = // ... * vec3 lightDirectionEC = // ... * out_FragColor = czm_phong(normalize(positionToEyeEC), material, lightDirectionEC); * * @see czm_getMaterial */ vec4 czm_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC) { // Diffuse from directional light sources at eye (for top-down) float diffuse = czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 0.0, 1.0), material); if (czm_sceneMode == czm_sceneMode3D) { // (and horizon views in 3D) diffuse += czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 1.0, 0.0), material); } float specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material); // Temporary workaround for adding ambient. vec3 materialDiffuse = material.diffuse * 0.5; vec3 ambient = materialDiffuse; vec3 color = ambient + material.emission; color += materialDiffuse * diffuse * czm_lightColor; color += material.specular * specular * czm_lightColor; return vec4(color, material.alpha); } vec4 czm_private_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC) { float diffuse = czm_private_getLambertDiffuseOfMaterial(lightDirectionEC, material); float specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material); vec3 ambient = vec3(0.0); vec3 color = ambient + material.emission; color += material.diffuse * diffuse * czm_lightColor; color += material.specular * specular * czm_lightColor; return vec4(color, material.alpha); } `,czm_planeDistance:`/** * Computes distance from a point to a plane. * * @name czm_planeDistance * @glslFunction * * param {vec4} plane A Plane in Hessian Normal Form. See Plane.js * param {vec3} point A point in the same space as the plane. * returns {float} The distance from the point to the plane. */ float czm_planeDistance(vec4 plane, vec3 point) { return (dot(plane.xyz, point) + plane.w); } /** * Computes distance from a point to a plane. * * @name czm_planeDistance * @glslFunction * * param {vec3} planeNormal Normal for a plane in Hessian Normal Form. See Plane.js * param {float} planeDistance Distance for a plane in Hessian Normal form. See Plane.js * param {vec3} point A point in the same space as the plane. * returns {float} The distance from the point to the plane. */ float czm_planeDistance(vec3 planeNormal, float planeDistance, vec3 point) { return (dot(planeNormal, point) + planeDistance); } `,czm_pointAlongRay:`/** * Computes the point along a ray at the given time. time can be positive, negative, or zero. * * @name czm_pointAlongRay * @glslFunction * * @param {czm_ray} ray The ray to compute the point along. * @param {float} time The time along the ray. * * @returns {vec3} The point along the ray at the given time. * * @example * czm_ray ray = czm_ray(vec3(0.0), vec3(1.0, 0.0, 0.0)); // origin, direction * vec3 v = czm_pointAlongRay(ray, 2.0); // (2.0, 0.0, 0.0) */ vec3 czm_pointAlongRay(czm_ray ray, float time) { return ray.origin + (time * ray.direction); } `,czm_rayEllipsoidIntersectionInterval:`/** * DOC_TBA * * @name czm_rayEllipsoidIntersectionInterval * @glslFunction */ czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_center, vec3 ellipsoid_inverseRadii) { // ray and ellipsoid center in eye coordinates. radii in model coordinates. vec3 q = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz; vec3 w = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz; q = q - ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ellipsoid_center, 1.0)).xyz; float q2 = dot(q, q); float qw = dot(q, w); if (q2 > 1.0) // Outside ellipsoid. { if (qw >= 0.0) // Looking outward or tangent (0 intersections). { return czm_emptyRaySegment; } else // qw < 0.0. { float qw2 = qw * qw; float difference = q2 - 1.0; // Positively valued. float w2 = dot(w, w); float product = w2 * difference; if (qw2 < product) // Imaginary roots (0 intersections). { return czm_emptyRaySegment; } else if (qw2 > product) // Distinct roots (2 intersections). { float discriminant = qw * qw - product; float temp = -qw + sqrt(discriminant); // Avoid cancellation. float root0 = temp / w2; float root1 = difference / temp; if (root0 < root1) { czm_raySegment i = czm_raySegment(root0, root1); return i; } else { czm_raySegment i = czm_raySegment(root1, root0); return i; } } else // qw2 == product. Repeated roots (2 intersections). { float root = sqrt(difference / w2); czm_raySegment i = czm_raySegment(root, root); return i; } } } else if (q2 < 1.0) // Inside ellipsoid (2 intersections). { float difference = q2 - 1.0; // Negatively valued. float w2 = dot(w, w); float product = w2 * difference; // Negatively valued. float discriminant = qw * qw - product; float temp = -qw + sqrt(discriminant); // Positively valued. czm_raySegment i = czm_raySegment(0.0, temp / w2); return i; } else // q2 == 1.0. On ellipsoid. { if (qw < 0.0) // Looking inward. { float w2 = dot(w, w); czm_raySegment i = czm_raySegment(0.0, -qw / w2); return i; } else // qw >= 0.0. Looking outward or tangent. { return czm_emptyRaySegment; } } } `,czm_raySphereIntersectionInterval:`/** * Compute the intersection interval of a ray with a sphere. * * @name czm_raySphereIntersectionInterval * @glslFunction * * @param {czm_ray} ray The ray. * @param {vec3} center The center of the sphere. * @param {float} radius The radius of the sphere. * @return {czm_raySegment} The intersection interval of the ray with the sphere. */ czm_raySegment czm_raySphereIntersectionInterval(czm_ray ray, vec3 center, float radius) { vec3 o = ray.origin; vec3 d = ray.direction; vec3 oc = o - center; float a = dot(d, d); float b = 2.0 * dot(d, oc); float c = dot(oc, oc) - (radius * radius); float det = (b * b) - (4.0 * a * c); if (det < 0.0) { return czm_emptyRaySegment; } float sqrtDet = sqrt(det); float t0 = (-b - sqrtDet) / (2.0 * a); float t1 = (-b + sqrtDet) / (2.0 * a); czm_raySegment result = czm_raySegment(t0, t1); return result; } `,czm_readDepth:`float czm_readDepth(sampler2D depthTexture, vec2 texCoords) { return czm_reverseLogDepth(texture(depthTexture, texCoords).r); } `,czm_readNonPerspective:`/** * Reads a value previously transformed with {@link czm_writeNonPerspective} * by dividing it by \`w\`, the value used in the perspective divide. * This function is intended to be called in a fragment shader to access a * \`varying\` that should not be subject to perspective interpolation. * For example, screen-space texture coordinates. The value should have been * previously written in the vertex shader with a call to * {@link czm_writeNonPerspective}. * * @name czm_readNonPerspective * @glslFunction * * @param {float|vec2|vec3|vec4} value The non-perspective value to be read. * @param {float} oneOverW One over the perspective divide value, \`w\`. Usually this is simply \`gl_FragCoord.w\`. * @returns {float|vec2|vec3|vec4} The usable value. */ float czm_readNonPerspective(float value, float oneOverW) { return value * oneOverW; } vec2 czm_readNonPerspective(vec2 value, float oneOverW) { return value * oneOverW; } vec3 czm_readNonPerspective(vec3 value, float oneOverW) { return value * oneOverW; } vec4 czm_readNonPerspective(vec4 value, float oneOverW) { return value * oneOverW; } `,czm_reverseLogDepth:`float czm_reverseLogDepth(float logZ) { #ifdef LOG_DEPTH float near = czm_currentFrustum.x; float far = czm_currentFrustum.y; float log2Depth = logZ * czm_log2FarDepthFromNearPlusOne; float depthFromNear = pow(2.0, log2Depth) - 1.0; return far * (1.0 - near / (depthFromNear + near)) / (far - near); #endif return logZ; } `,czm_round:`/** * Round a floating point value. This function exists because round() doesn't * exist in GLSL 1.00. * * @param {float|vec2|vec3|vec4} value The value to round * @param {float|vec2|vec3|vec3} The rounded value. The type matches the input. */ float czm_round(float value) { return floor(value + 0.5); } vec2 czm_round(vec2 value) { return floor(value + 0.5); } vec3 czm_round(vec3 value) { return floor(value + 0.5); } vec4 czm_round(vec4 value) { return floor(value + 0.5); } `,czm_sampleOctahedralProjection:`/** * Samples the 4 neighboring pixels and return the weighted average. * * @private */ vec3 czm_sampleOctahedralProjectionWithFiltering(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod) { direction /= dot(vec3(1.0), abs(direction)); vec2 rev = abs(direction.zx) - vec2(1.0); vec2 neg = vec2(direction.x < 0.0 ? rev.x : -rev.x, direction.z < 0.0 ? rev.y : -rev.y); vec2 uv = direction.y < 0.0 ? neg : direction.xz; vec2 coord = 0.5 * uv + vec2(0.5); vec2 pixel = 1.0 / textureSize; if (lod > 0.0) { // Each subseqeuent mip level is half the size float scale = 1.0 / pow(2.0, lod); float offset = ((textureSize.y + 1.0) / textureSize.x); coord.x *= offset; coord *= scale; coord.x += offset + pixel.x; coord.y += (1.0 - (1.0 / pow(2.0, lod - 1.0))) + pixel.y * (lod - 1.0) * 2.0; } else { coord.x *= (textureSize.y / textureSize.x); } // Do bilinear filtering #ifndef OES_texture_float_linear vec3 color1 = texture(projectedMap, coord + vec2(0.0, pixel.y)).rgb; vec3 color2 = texture(projectedMap, coord + vec2(pixel.x, 0.0)).rgb; vec3 color3 = texture(projectedMap, coord + pixel).rgb; vec3 color4 = texture(projectedMap, coord).rgb; vec2 texturePosition = coord * textureSize; float fu = fract(texturePosition.x); float fv = fract(texturePosition.y); vec3 average1 = mix(color4, color2, fu); vec3 average2 = mix(color1, color3, fu); vec3 color = mix(average1, average2, fv); #else vec3 color = texture(projectedMap, coord).rgb; #endif return color; } /** * Samples from a cube map that has been projected using an octahedral projection from the given direction. * * @name czm_sampleOctahedralProjection * @glslFunction * * @param {sampler2D} projectedMap The texture with the octahedral projected cube map. * @param {vec2} textureSize The width and height dimensions in pixels of the projected map. * @param {vec3} direction The normalized direction used to sample the cube map. * @param {float} lod The level of detail to sample. * @param {float} maxLod The maximum level of detail. * @returns {vec3} The color of the cube map at the direction. */ vec3 czm_sampleOctahedralProjection(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod, float maxLod) { float currentLod = floor(lod + 0.5); float nextLod = min(currentLod + 1.0, maxLod); vec3 colorCurrentLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, currentLod); vec3 colorNextLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, nextLod); return mix(colorNextLod, colorCurrentLod, nextLod - lod); } `,czm_saturation:`/** * Adjusts the saturation of a color. * * @name czm_saturation * @glslFunction * * @param {vec3} rgb The color. * @param {float} adjustment The amount to adjust the saturation of the color. * * @returns {float} The color with the saturation adjusted. * * @example * vec3 greyScale = czm_saturation(color, 0.0); * vec3 doubleSaturation = czm_saturation(color, 2.0); */ vec3 czm_saturation(vec3 rgb, float adjustment) { // Algorithm from Chapter 16 of OpenGL Shading Language const vec3 W = vec3(0.2125, 0.7154, 0.0721); vec3 intensity = vec3(dot(rgb, W)); return mix(intensity, rgb, adjustment); } `,czm_shadowDepthCompare:` float czm_sampleShadowMap(highp samplerCube shadowMap, vec3 d) { return czm_unpackDepth(czm_textureCube(shadowMap, d)); } float czm_sampleShadowMap(highp sampler2D shadowMap, vec2 uv) { #ifdef USE_SHADOW_DEPTH_TEXTURE return texture(shadowMap, uv).r; #else return czm_unpackDepth(texture(shadowMap, uv)); #endif } float czm_shadowDepthCompare(samplerCube shadowMap, vec3 uv, float depth) { return step(depth, czm_sampleShadowMap(shadowMap, uv)); } float czm_shadowDepthCompare(sampler2D shadowMap, vec2 uv, float depth) { return step(depth, czm_sampleShadowMap(shadowMap, uv)); } `,czm_shadowVisibility:` float czm_private_shadowVisibility(float visibility, float nDotL, float normalShadingSmooth, float darkness) { #ifdef USE_NORMAL_SHADING #ifdef USE_NORMAL_SHADING_SMOOTH float strength = clamp(nDotL / normalShadingSmooth, 0.0, 1.0); #else float strength = step(0.0, nDotL); #endif visibility *= strength; #endif visibility = max(visibility, darkness); return visibility; } #ifdef USE_CUBE_MAP_SHADOW float czm_shadowVisibility(samplerCube shadowMap, czm_shadowParameters shadowParameters) { float depthBias = shadowParameters.depthBias; float depth = shadowParameters.depth; float nDotL = shadowParameters.nDotL; float normalShadingSmooth = shadowParameters.normalShadingSmooth; float darkness = shadowParameters.darkness; vec3 uvw = shadowParameters.texCoords; depth -= depthBias; float visibility = czm_shadowDepthCompare(shadowMap, uvw, depth); return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness); } #else float czm_shadowVisibility(sampler2D shadowMap, czm_shadowParameters shadowParameters) { float depthBias = shadowParameters.depthBias; float depth = shadowParameters.depth; float nDotL = shadowParameters.nDotL; float normalShadingSmooth = shadowParameters.normalShadingSmooth; float darkness = shadowParameters.darkness; vec2 uv = shadowParameters.texCoords; depth -= depthBias; #ifdef USE_SOFT_SHADOWS vec2 texelStepSize = shadowParameters.texelStepSize; float radius = 1.0; float dx0 = -texelStepSize.x * radius; float dy0 = -texelStepSize.y * radius; float dx1 = texelStepSize.x * radius; float dy1 = texelStepSize.y * radius; float visibility = ( czm_shadowDepthCompare(shadowMap, uv, depth) + czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy0), depth) + czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy0), depth) + czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy0), depth) + czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, 0.0), depth) + czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, 0.0), depth) + czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy1), depth) + czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy1), depth) + czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy1), depth) ) * (1.0 / 9.0); #else float visibility = czm_shadowDepthCompare(shadowMap, uv, depth); #endif return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness); } #endif `,czm_signNotZero:`/** * Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative. This is similar to the GLSL * built-in function sign except that returns 1.0 instead of 0.0 when the input value is 0.0. * * @name czm_signNotZero * @glslFunction * * @param {} value The value for which to determine the sign. * @returns {} 1.0 if the value is positive or zero, -1.0 if the value is negative. */ float czm_signNotZero(float value) { return value >= 0.0 ? 1.0 : -1.0; } vec2 czm_signNotZero(vec2 value) { return vec2(czm_signNotZero(value.x), czm_signNotZero(value.y)); } vec3 czm_signNotZero(vec3 value) { return vec3(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z)); } vec4 czm_signNotZero(vec4 value) { return vec4(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z), czm_signNotZero(value.w)); } `,czm_sphericalHarmonics:`/** * Computes a color from the third order spherical harmonic coefficients and a normalized direction vector. *

* The order of the coefficients is [L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22]. *

* * @name czm_sphericalHarmonics * @glslFunction * * @param {vec3} normal The normalized direction. * @param {vec3[9]} coefficients The third order spherical harmonic coefficients. * @returns {vec3} The color at the direction. * * @see https://graphics.stanford.edu/papers/envmap/envmap.pdf */ vec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9]) { vec3 L00 = coefficients[0]; vec3 L1_1 = coefficients[1]; vec3 L10 = coefficients[2]; vec3 L11 = coefficients[3]; vec3 L2_2 = coefficients[4]; vec3 L2_1 = coefficients[5]; vec3 L20 = coefficients[6]; vec3 L21 = coefficients[7]; vec3 L22 = coefficients[8]; float x = normal.x; float y = normal.y; float z = normal.z; return L00 + L1_1 * y + L10 * z + L11 * x + L2_2 * (y * x) + L2_1 * (y * z) + L20 * (3.0 * z * z - 1.0) + L21 * (z * x) + L22 * (x * x - y * y); } `,czm_srgbToLinear:`/** * Converts an sRGB color to a linear RGB color. * * @param {vec3|vec4} srgbIn The color in sRGB space * @returns {vec3|vec4} The color in linear color space. The vector type matches the input. */ vec3 czm_srgbToLinear(vec3 srgbIn) { return pow(srgbIn, vec3(2.2)); } vec4 czm_srgbToLinear(vec4 srgbIn) { vec3 linearOut = pow(srgbIn.rgb, vec3(2.2)); return vec4(linearOut, srgbIn.a); } `,czm_tangentToEyeSpaceMatrix:`/** * Creates a matrix that transforms vectors from tangent space to eye space. * * @name czm_tangentToEyeSpaceMatrix * @glslFunction * * @param {vec3} normalEC The normal vector in eye coordinates. * @param {vec3} tangentEC The tangent vector in eye coordinates. * @param {vec3} bitangentEC The bitangent vector in eye coordinates. * * @returns {mat3} The matrix that transforms from tangent space to eye space. * * @example * mat3 tangentToEye = czm_tangentToEyeSpaceMatrix(normalEC, tangentEC, bitangentEC); * vec3 normal = tangentToEye * texture(normalMap, st).xyz; */ mat3 czm_tangentToEyeSpaceMatrix(vec3 normalEC, vec3 tangentEC, vec3 bitangentEC) { vec3 normal = normalize(normalEC); vec3 tangent = normalize(tangentEC); vec3 bitangent = normalize(bitangentEC); return mat3(tangent.x , tangent.y , tangent.z, bitangent.x, bitangent.y, bitangent.z, normal.x , normal.y , normal.z); } `,czm_textureCube:`/** * A wrapper around the texture (WebGL2) / textureCube (WebGL1) * function to allow for WebGL 1 support. * * @name czm_textureCube * @glslFunction * * @param {samplerCube} sampler The sampler. * @param {vec3} p The coordinates to sample the texture at. */ vec4 czm_textureCube(samplerCube sampler, vec3 p) { #if __VERSION__ == 300 return texture(sampler, p); #else return textureCube(sampler, p); #endif }`,czm_transformPlane:`/** * Transforms a plane. * * @name czm_transformPlane * @glslFunction * * @param {vec4} plane The plane in Hessian Normal Form. * @param {mat4} transform The inverse-transpose of a transformation matrix. */ vec4 czm_transformPlane(vec4 plane, mat4 transform) { vec4 transformedPlane = transform * plane; // Convert the transformed plane to Hessian Normal Form float normalMagnitude = length(transformedPlane.xyz); return transformedPlane / normalMagnitude; } `,czm_translateRelativeToEye:`/** * Translates a position (or any vec3) that was encoded with {@link EncodedCartesian3}, * and then provided to the shader as separate high and low bits to * be relative to the eye. As shown in the example, the position can then be transformed in eye * or clip coordinates using {@link czm_modelViewRelativeToEye} or {@link czm_modelViewProjectionRelativeToEye}, * respectively. *

* This technique, called GPU RTE, eliminates jittering artifacts when using large coordinates as * described in {@link http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}. *

* * @name czm_translateRelativeToEye * @glslFunction * * @param {vec3} high The position's high bits. * @param {vec3} low The position's low bits. * @returns {vec3} The position translated to be relative to the camera's position. * * @example * in vec3 positionHigh; * in vec3 positionLow; * * void main() * { * vec4 p = czm_translateRelativeToEye(positionHigh, positionLow); * gl_Position = czm_modelViewProjectionRelativeToEye * p; * } * * @see czm_modelViewRelativeToEye * @see czm_modelViewProjectionRelativeToEye * @see czm_computePosition * @see EncodedCartesian3 */ vec4 czm_translateRelativeToEye(vec3 high, vec3 low) { vec3 highDifference = high - czm_encodedCameraPositionMCHigh; vec3 lowDifference = low - czm_encodedCameraPositionMCLow; return vec4(highDifference + lowDifference, 1.0); } `,czm_translucentPhong:`/** * @private */ vec4 czm_translucentPhong(vec3 toEye, czm_material material, vec3 lightDirectionEC) { // Diffuse from directional light sources at eye (for top-down and horizon views) float diffuse = czm_getLambertDiffuse(vec3(0.0, 0.0, 1.0), material.normal); if (czm_sceneMode == czm_sceneMode3D) { // (and horizon views in 3D) diffuse += czm_getLambertDiffuse(vec3(0.0, 1.0, 0.0), material.normal); } diffuse = clamp(diffuse, 0.0, 1.0); float specular = czm_getSpecular(lightDirectionEC, toEye, material.normal, material.shininess); // Temporary workaround for adding ambient. vec3 materialDiffuse = material.diffuse * 0.5; vec3 ambient = materialDiffuse; vec3 color = ambient + material.emission; color += materialDiffuse * diffuse * czm_lightColor; color += material.specular * specular * czm_lightColor; return vec4(color, material.alpha); } `,czm_transpose:`/** * Returns the transpose of the matrix. The input matrix can be * a mat2, mat3, or mat4. * * @name czm_transpose * @glslFunction * * @param {} matrix The matrix to transpose. * * @returns {} The transposed matrix. * * @example * // GLSL declarations * mat2 czm_transpose(mat2 matrix); * mat3 czm_transpose(mat3 matrix); * mat4 czm_transpose(mat4 matrix); * * // Transpose a 3x3 rotation matrix to find its inverse. * mat3 eastNorthUpToEye = czm_eastNorthUpToEyeCoordinates( * positionMC, normalEC); * mat3 eyeToEastNorthUp = czm_transpose(eastNorthUpToEye); */ mat2 czm_transpose(mat2 matrix) { return mat2( matrix[0][0], matrix[1][0], matrix[0][1], matrix[1][1]); } mat3 czm_transpose(mat3 matrix) { return mat3( matrix[0][0], matrix[1][0], matrix[2][0], matrix[0][1], matrix[1][1], matrix[2][1], matrix[0][2], matrix[1][2], matrix[2][2]); } mat4 czm_transpose(mat4 matrix) { return mat4( matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0], matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1], matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2], matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]); } `,czm_unpackDepth:`/** * Unpacks a vec4 depth value to a float in [0, 1) range. * * @name czm_unpackDepth * @glslFunction * * @param {vec4} packedDepth The packed depth. * * @returns {float} The floating-point depth in [0, 1) range. */ float czm_unpackDepth(vec4 packedDepth) { // See Aras Pranckevičius' post Encoding Floats to RGBA // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/ return dot(packedDepth, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)); } `,czm_unpackFloat:`/** * Unpack an IEEE 754 single-precision float that is packed as a little-endian unsigned normalized vec4. * * @name czm_unpackFloat * @glslFunction * * @param {vec4} packedFloat The packed float. * * @returns {float} The floating-point depth in arbitrary range. */ float czm_unpackFloat(vec4 packedFloat) { // Convert to [0.0, 255.0] and round to integer packedFloat = floor(packedFloat * 255.0 + 0.5); float sign = 1.0 - step(128.0, packedFloat[3]) * 2.0; float exponent = 2.0 * mod(packedFloat[3], 128.0) + step(128.0, packedFloat[2]) - 127.0; if (exponent == -127.0) { return 0.0; } float mantissa = mod(packedFloat[2], 128.0) * 65536.0 + packedFloat[1] * 256.0 + packedFloat[0] + float(0x800000); float result = sign * exp2(exponent - 23.0) * mantissa; return result; } `,czm_unpackUint:`/** * Unpack unsigned integers of 1-4 bytes. in WebGL 1, there is no uint type, * so the return value is an int. *

* There are also precision limitations in WebGL 1. highp int is still limited * to 24 bits. Above the value of 2^24 = 16777216, precision loss may occur. *

* * @param {float|vec2|vec3|vec4} packed The packed value. For vectors, the components are listed in little-endian order. * * @return {int} The unpacked value. */ int czm_unpackUint(float packedValue) { float rounded = czm_round(packedValue * 255.0); return int(rounded); } int czm_unpackUint(vec2 packedValue) { vec2 rounded = czm_round(packedValue * 255.0); return int(dot(rounded, vec2(1.0, 256.0))); } int czm_unpackUint(vec3 packedValue) { vec3 rounded = czm_round(packedValue * 255.0); return int(dot(rounded, vec3(1.0, 256.0, 65536.0))); } int czm_unpackUint(vec4 packedValue) { vec4 rounded = czm_round(packedValue * 255.0); return int(dot(rounded, vec4(1.0, 256.0, 65536.0, 16777216.0))); } `,czm_valueTransform:`/** * Transform metadata values following the EXT_structural_metadata spec * by multiplying by scale and adding the offset. Operations are always * performed component-wise, even for matrices. * * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} offset The offset to add * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} scale The scale factor to multiply * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} value The original value. * * @return {float|vec2|vec3|vec4|mat2|mat3|mat4} The transformed value of the same scalar/vector/matrix type as the input. */ float czm_valueTransform(float offset, float scale, float value) { return scale * value + offset; } vec2 czm_valueTransform(vec2 offset, vec2 scale, vec2 value) { return scale * value + offset; } vec3 czm_valueTransform(vec3 offset, vec3 scale, vec3 value) { return scale * value + offset; } vec4 czm_valueTransform(vec4 offset, vec4 scale, vec4 value) { return scale * value + offset; } mat2 czm_valueTransform(mat2 offset, mat2 scale, mat2 value) { return matrixCompMult(scale, value) + offset; } mat3 czm_valueTransform(mat3 offset, mat3 scale, mat3 value) { return matrixCompMult(scale, value) + offset; } mat4 czm_valueTransform(mat4 offset, mat4 scale, mat4 value) { return matrixCompMult(scale, value) + offset; } `,czm_vertexLogDepth:`#ifdef LOG_DEPTH // 1.0 at the near plane, increasing linearly from there. out float v_depthFromNearPlusOne; #ifdef SHADOW_MAP out vec3 v_logPositionEC; #endif #endif vec4 czm_updatePositionDepth(vec4 coords) { #if defined(LOG_DEPTH) #ifdef SHADOW_MAP vec3 logPositionEC = (czm_inverseProjection * coords).xyz; v_logPositionEC = logPositionEC; #endif // With the very high far/near ratios used with the logarithmic depth // buffer, floating point rounding errors can cause linear depth values // to end up on the wrong side of the far plane, even for vertices that // are really nowhere near it. Since we always write a correct logarithmic // depth value in the fragment shader anyway, we just need to make sure // such errors don't cause the primitive to be clipped entirely before // we even get to the fragment shader. coords.z = clamp(coords.z / coords.w, -1.0, 1.0) * coords.w; #endif return coords; } /** * Writes the logarithmic depth to gl_Position using the already computed gl_Position. * * @name czm_vertexLogDepth * @glslFunction */ void czm_vertexLogDepth() { #ifdef LOG_DEPTH v_depthFromNearPlusOne = (gl_Position.w - czm_currentFrustum.x) + 1.0; gl_Position = czm_updatePositionDepth(gl_Position); #endif } /** * Writes the logarithmic depth to gl_Position using the provided clip coordinates. *

* An example use case for this function would be moving the vertex in window coordinates * before converting back to clip coordinates. Use the original vertex clip coordinates. *

* @name czm_vertexLogDepth * @glslFunction * * @param {vec4} clipCoords The vertex in clip coordinates. * * @example * czm_vertexLogDepth(czm_projection * vec4(positionEyeCoordinates, 1.0)); */ void czm_vertexLogDepth(vec4 clipCoords) { #ifdef LOG_DEPTH v_depthFromNearPlusOne = (clipCoords.w - czm_currentFrustum.x) + 1.0; czm_updatePositionDepth(clipCoords); #endif } `,czm_windowToEyeCoordinates:`vec4 czm_screenToEyeCoordinates(vec4 screenCoordinate) { // Reconstruct NDC coordinates float x = 2.0 * screenCoordinate.x - 1.0; float y = 2.0 * screenCoordinate.y - 1.0; float z = (screenCoordinate.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2]; vec4 q = vec4(x, y, z, 1.0); // Reverse the perspective division to obtain clip coordinates. q /= screenCoordinate.w; // Reverse the projection transformation to obtain eye coordinates. if (!(czm_inverseProjection == mat4(0.0))) // IE and Edge sometimes do something weird with != between mat4s { q = czm_inverseProjection * q; } else { float top = czm_frustumPlanes.x; float bottom = czm_frustumPlanes.y; float left = czm_frustumPlanes.z; float right = czm_frustumPlanes.w; float near = czm_currentFrustum.x; float far = czm_currentFrustum.y; q.x = (q.x * (right - left) + left + right) * 0.5; q.y = (q.y * (top - bottom) + bottom + top) * 0.5; q.z = (q.z * (near - far) - near - far) * 0.5; q.w = 1.0; } return q; } /** * Transforms a position from window to eye coordinates. * The transform from window to normalized device coordinates is done using components * of (@link czm_viewport} and {@link czm_viewportTransformation} instead of calculating * the inverse of czm_viewportTransformation. The transformation from * normalized device coordinates to clip coordinates is done using fragmentCoordinate.w, * which is expected to be the scalar used in the perspective divide. The transformation * from clip to eye coordinates is done using {@link czm_inverseProjection}. * * @name czm_windowToEyeCoordinates * @glslFunction * * @param {vec4} fragmentCoordinate The position in window coordinates to transform. * * @returns {vec4} The transformed position in eye coordinates. * * @see czm_modelToWindowCoordinates * @see czm_eyeToWindowCoordinates * @see czm_inverseProjection * @see czm_viewport * @see czm_viewportTransformation * * @example * vec4 positionEC = czm_windowToEyeCoordinates(gl_FragCoord); */ vec4 czm_windowToEyeCoordinates(vec4 fragmentCoordinate) { vec2 screenCoordXY = (fragmentCoordinate.xy - czm_viewport.xy) / czm_viewport.zw; return czm_screenToEyeCoordinates(vec4(screenCoordXY, fragmentCoordinate.zw)); } vec4 czm_screenToEyeCoordinates(vec2 screenCoordinateXY, float depthOrLogDepth) { // See reverseLogDepth.glsl. This is separate to re-use the pow. #if defined(LOG_DEPTH) || defined(LOG_DEPTH_READ_ONLY) float near = czm_currentFrustum.x; float far = czm_currentFrustum.y; float log2Depth = depthOrLogDepth * czm_log2FarDepthFromNearPlusOne; float depthFromNear = pow(2.0, log2Depth) - 1.0; float depthFromCamera = depthFromNear + near; vec4 screenCoord = vec4(screenCoordinateXY, far * (1.0 - near / depthFromCamera) / (far - near), 1.0); vec4 eyeCoordinate = czm_screenToEyeCoordinates(screenCoord); eyeCoordinate.w = 1.0 / depthFromCamera; // Better precision return eyeCoordinate; #else vec4 screenCoord = vec4(screenCoordinateXY, depthOrLogDepth, 1.0); vec4 eyeCoordinate = czm_screenToEyeCoordinates(screenCoord); #endif return eyeCoordinate; } /** * Transforms a position given as window x/y and a depth or a log depth from window to eye coordinates. * This function produces more accurate results for window positions with log depth than * conventionally unpacking the log depth using czm_reverseLogDepth and using the standard version * of czm_windowToEyeCoordinates. * * @name czm_windowToEyeCoordinates * @glslFunction * * @param {vec2} fragmentCoordinateXY The XY position in window coordinates to transform. * @param {float} depthOrLogDepth A depth or log depth for the fragment. * * @see czm_modelToWindowCoordinates * @see czm_eyeToWindowCoordinates * @see czm_inverseProjection * @see czm_viewport * @see czm_viewportTransformation * * @returns {vec4} The transformed position in eye coordinates. */ vec4 czm_windowToEyeCoordinates(vec2 fragmentCoordinateXY, float depthOrLogDepth) { vec2 screenCoordXY = (fragmentCoordinateXY.xy - czm_viewport.xy) / czm_viewport.zw; return czm_screenToEyeCoordinates(screenCoordXY, depthOrLogDepth); } `,czm_writeDepthClamp:`// emulated noperspective #if !defined(LOG_DEPTH) in float v_WindowZ; #endif /** * Emulates GL_DEPTH_CLAMP. Clamps a fragment to the near and far plane * by writing the fragment's depth. See czm_depthClamp for more details. * * @name czm_writeDepthClamp * @glslFunction * * @example * out_FragColor = color; * czm_writeDepthClamp(); * * @see czm_depthClamp */ void czm_writeDepthClamp() { #if (!defined(LOG_DEPTH) && (__VERSION__ == 300 || defined(GL_EXT_frag_depth))) gl_FragDepth = clamp(v_WindowZ * gl_FragCoord.w, 0.0, 1.0); #endif } `,czm_writeLogDepth:`#ifdef LOG_DEPTH in float v_depthFromNearPlusOne; #ifdef POLYGON_OFFSET uniform vec2 u_polygonOffset; #endif #endif /** * Writes the fragment depth to the logarithmic depth buffer. *

* Use this when the vertex shader does not call {@link czm_vertexlogDepth}, for example, when * ray-casting geometry using a full screen quad. *

* @name czm_writeLogDepth * @glslFunction * * @param {float} depth The depth coordinate, where 1.0 is on the near plane and * depth increases in eye-space units from there * * @example * czm_writeLogDepth((czm_projection * v_positionEyeCoordinates).w + 1.0); */ void czm_writeLogDepth(float depth) { #if (defined(LOG_DEPTH) && (__VERSION__ == 300 || defined(GL_EXT_frag_depth))) // Discard the vertex if it's not between the near and far planes. // We allow a bit of epsilon on the near plane comparison because a 1.0 // from the vertex shader (indicating the vertex should be _on_ the near // plane) will not necessarily come here as exactly 1.0. if (depth <= 0.9999999 || depth > czm_farDepthFromNearPlusOne) { discard; } #ifdef POLYGON_OFFSET // Polygon offset: m * factor + r * units float factor = u_polygonOffset[0]; float units = u_polygonOffset[1]; #if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives)) // This factor doesn't work in IE 10 if (factor != 0.0) { // m = sqrt(dZdX^2 + dZdY^2); float x = dFdx(depth); float y = dFdy(depth); float m = sqrt(x * x + y * y); // Apply the factor before computing the log depth. depth += m * factor; } #endif #endif gl_FragDepth = log2(depth) * czm_oneOverLog2FarDepthFromNearPlusOne; #ifdef POLYGON_OFFSET // Apply the units after the log depth. gl_FragDepth += czm_epsilon7 * units; #endif #endif } /** * Writes the fragment depth to the logarithmic depth buffer. *

* Use this when the vertex shader calls {@link czm_vertexlogDepth}. *

* * @name czm_writeLogDepth * @glslFunction */ void czm_writeLogDepth() { #ifdef LOG_DEPTH czm_writeLogDepth(v_depthFromNearPlusOne); #endif } `,czm_writeNonPerspective:`/** * Transforms a value for non-perspective interpolation by multiplying * it by w, the value used in the perspective divide. This function is * intended to be called in a vertex shader to compute the value of a * \`varying\` that should not be subject to perspective interpolation. * For example, screen-space texture coordinates. The fragment shader * must call {@link czm_readNonPerspective} to retrieve the final * non-perspective value. * * @name czm_writeNonPerspective * @glslFunction * * @param {float|vec2|vec3|vec4} value The value to be interpolated without accounting for perspective. * @param {float} w The perspective divide value. Usually this is the computed \`gl_Position.w\`. * @returns {float|vec2|vec3|vec4} The transformed value, intended to be stored in a \`varying\` and read in the * fragment shader with {@link czm_readNonPerspective}. */ float czm_writeNonPerspective(float value, float w) { return value * w; } vec2 czm_writeNonPerspective(vec2 value, float w) { return value * w; } vec3 czm_writeNonPerspective(vec3 value, float w) { return value * w; } vec4 czm_writeNonPerspective(vec4 value, float w) { return value * w; } `};function Ib(e,t){let n=e;return n=n.replaceAll("version 300 es",""),n=n.replaceAll(/(texture\()/g,"texture2D("),t?(n=n.replaceAll(/(in)\s+(vec\d|mat\d|float)/g,"varying $2"),/out_FragData_(\d+)/.test(n)&&(n=`#extension GL_EXT_draw_buffers : enable ${n}`,n=n.replaceAll(/layout\s+\(location\s*=\s*\d+\)\s*out\s+vec4\s+out_FragData_\d+;/g,""),n=n.replaceAll(/out_FragData_(\d+)/g,"gl_FragData[$1]")),n=n.replaceAll(/layout\s+\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor;/g,""),n=n.replaceAll(/out_FragColor/g,"gl_FragColor"),n=n.replaceAll(/out_FragColor\[(\d+)\]/g,"gl_FragColor[$1]"),/gl_FragDepth/.test(n)&&(n=`#extension GL_EXT_frag_depth : enable ${n}`,n=n.replaceAll(/gl_FragDepth/g,"gl_FragDepthEXT")),n=`#ifdef GL_OES_standard_derivatives #extension GL_OES_standard_derivatives : enable #endif ${n}`):(n=n.replaceAll(/(in)\s+(vec\d|mat\d|float)/g,"attribute $2"),n=n.replaceAll(/(out)\s+(vec\d|mat\d|float)\s+([\w]+);/g,"varying $2 $3;")),n=`#version 100 ${n}`,n}function Lf(e){return e=e.replace(/\/\/.*/g,""),e.replace(/\/\*\*[\s\S]*?\*\//gm,function(t){const n=t.match(/\n/gm).length;let i="";for(let o=0;o0;){const o=e.pop();n.push(o),o.requiredBy.length===0&&t.push(o)}for(;t.length>0;){const o=t.shift();e.push(o);for(let r=0;r=0;--o)i=`${i+t[o].glslSource} `;return i.replace(n.glslSource,"")}function Uf(e,t,n){let i,o,r="";const s=e.sources;if(h(s))for(i=0,o=s.length;i planes2D_high.w): // - If this vertex is on the east side of the IDL (position3DLow.y > 0.0, comparison with position3DHigh may produce artifacts) // - existing "east" is on the wrong side of the world, far away (planes2D_high/low.w) // - so set "east" as beyond the eastmost extent of the projection (idlSplitNewPlaneHiLow) vec2 idlSplitNewPlaneHiLow = vec2(EAST_MOST_X_HIGH - (WEST_MOST_X_HIGH - planes2D_high.w), EAST_MOST_X_LOW - (WEST_MOST_X_LOW - planes2D_low.w)); bool idlSplit = planes2D_high.x > planes2D_high.w && position3DLow.y > 0.0; planes2D_high.w = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.x, planes2D_high.w); planes2D_low.w = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.y, planes2D_low.w); // - else, if this vertex is on the west side of the IDL (position3DLow.y < 0.0) // - existing "west" is on the wrong side of the world, far away (planes2D_high/low.x) // - so set "west" as beyond the westmost extent of the projection (idlSplitNewPlaneHiLow) idlSplit = planes2D_high.x > planes2D_high.w && position3DLow.y < 0.0; idlSplitNewPlaneHiLow = vec2(WEST_MOST_X_HIGH - (EAST_MOST_X_HIGH - planes2D_high.x), WEST_MOST_X_LOW - (EAST_MOST_X_LOW - planes2D_low.x)); planes2D_high.x = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.x, planes2D_high.x); planes2D_low.x = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.y, planes2D_low.x); vec3 southWestCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, planes2D_high.xy), vec3(0.0, planes2D_low.xy))).xyz; vec3 northWestCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, planes2D_high.x, planes2D_high.z), vec3(0.0, planes2D_low.x, planes2D_low.z))).xyz; vec3 southEastCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, planes2D_high.w, planes2D_high.y), vec3(0.0, planes2D_low.w, planes2D_low.y))).xyz; #else // COLUMBUS_VIEW_2D // 3D case has smaller "plane extents," so planes encoded as a 64 bit position and 2 vec3s for distances/direction vec3 southWestCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(czm_batchTable_southWest_HIGH(batchId), czm_batchTable_southWest_LOW(batchId))).xyz; vec3 northWestCorner = czm_normal * czm_batchTable_northward(batchId) + southWestCorner; vec3 southEastCorner = czm_normal * czm_batchTable_eastward(batchId) + southWestCorner; #endif // COLUMBUS_VIEW_2D vec3 eastWard = southEastCorner - southWestCorner; float eastExtent = length(eastWard); eastWard /= eastExtent; vec3 northWard = northWestCorner - southWestCorner; float northExtent = length(northWard); northWard /= northExtent; v_westPlane = vec4(eastWard, -dot(eastWard, southWestCorner)); v_southPlane = vec4(northWard, -dot(northWard, southWestCorner)); v_inversePlaneExtents = vec2(1.0 / eastExtent, 1.0 / northExtent); #endif // SPHERICAL vec4 uvMinAndExtents = czm_batchTable_uvMinAndExtents(batchId); vec4 uMaxVmax = czm_batchTable_uMaxVmax(batchId); v_uMaxAndInverseDistance = vec3(uMaxVmax.xy, uvMinAndExtents.z); v_vMaxAndInverseDistance = vec3(uMaxVmax.zw, uvMinAndExtents.w); v_uvMinAndSphericalLongitudeRotation.xy = uvMinAndExtents.xy; #endif // TEXTURE_COORDINATES #ifdef PER_INSTANCE_COLOR v_color = czm_batchTable_color(batchId); #endif gl_Position = czm_depthClamp(czm_modelViewProjectionRelativeToEye * position); } `,Bb=`#ifdef VECTOR_TILE uniform vec4 u_highlightColor; #endif void main(void) { #ifdef VECTOR_TILE out_FragColor = czm_gammaCorrect(u_highlightColor); #else out_FragColor = vec4(1.0); #endif czm_writeDepthClamp(); } `,Gf={TERRAIN:0,CESIUM_3D_TILE:1,BOTH:2};Gf.NUMBER_OF_CLASSIFICATION_TYPES=3;const Xn=Object.freeze(Gf),Ub={NEVER:I.NEVER,LESS:I.LESS,EQUAL:I.EQUAL,LESS_OR_EQUAL:I.LEQUAL,GREATER:I.GREATER,NOT_EQUAL:I.NOTEQUAL,GREATER_OR_EQUAL:I.GEQUAL,ALWAYS:I.ALWAYS},Vf=Object.freeze(Ub);function Xe(){this.high=l.clone(l.ZERO),this.low=l.clone(l.ZERO)}Xe.encode=function(e,t){d.typeOf.number("value",e),h(t)||(t={high:0,low:0});let n;return e>=0?(n=Math.floor(e/65536)*65536,t.high=n,t.low=e-n):(n=Math.floor(-e/65536)*65536,t.high=-n,t.low=e+n),t};const Kn={high:0,low:0};Xe.fromCartesian=function(e,t){d.typeOf.object("cartesian",e),h(t)||(t=new Xe);const n=t.high,i=t.low;return Xe.encode(e.x,Kn),n.x=Kn.high,i.x=Kn.low,Xe.encode(e.y,Kn),n.y=Kn.high,i.y=Kn.low,Xe.encode(e.z,Kn),n.z=Kn.high,i.z=Kn.low,t};const vc=new Xe;Xe.writeElements=function(e,t,n){d.defined("cartesianArray",t),d.typeOf.number("index",n),d.typeOf.number.greaterThanOrEquals("index",n,0),Xe.fromCartesian(e,vc);const i=vc.high,o=vc.low;t[n]=i.x,t[n+1]=i.y,t[n+2]=i.z,t[n+3]=o.x,t[n+4]=o.y,t[n+5]=o.z};function kb(e,t){if(!h(e))throw new T("array is required.");if(!h(t)||t<1)throw new T("numberOfArrays must be greater than 0.");const n=[],i=e.length;let o=0;for(;o=P.SIXTY_FOUR_KILOBYTES?new Uint32Array(t):new Uint16Array(t)},wt.createTypedArrayFromArrayBuffer=function(e,t,n,i){if(!h(e))throw new T("numberOfVertices is required.");if(!h(t))throw new T("sourceArray is required.");if(!h(n))throw new T("byteOffset is required.");return e>=P.SIXTY_FOUR_KILOBYTES?new Uint32Array(t,n,i):new Uint16Array(t,n,i)},wt.fromTypedArray=function(e){if(e instanceof Uint8Array)return wt.UNSIGNED_BYTE;if(e instanceof Uint16Array)return wt.UNSIGNED_SHORT;if(e instanceof Uint32Array)return wt.UNSIGNED_INT;throw new T("array must be a Uint8Array, Uint16Array, or Uint32Array.")};const Ct=Object.freeze(wt);function Gt(e){if(e=m(e,m.EMPTY_OBJECT),d.defined("options.context",e.context),!h(e.typedArray)&&!h(e.sizeInBytes))throw new T("Either options.sizeInBytes or options.typedArray is required.");if(h(e.typedArray)&&h(e.sizeInBytes))throw new T("Cannot pass in both options.sizeInBytes and options.typedArray.");if(h(e.typedArray)&&(d.typeOf.object("options.typedArray",e.typedArray),d.typeOf.number("options.typedArray.byteLength",e.typedArray.byteLength)),!xc.validate(e.usage))throw new T("usage is invalid.");const t=e.context._gl,n=e.bufferTarget,i=e.typedArray;let o=e.sizeInBytes;const r=e.usage,s=h(i);s&&(o=i.byteLength),d.typeOf.number.greaterThan("sizeInBytes",o,0);const a=t.createBuffer();t.bindBuffer(n,a),t.bufferData(n,s?i:o,r),t.bindBuffer(n,null),this._id=ws(),this._gl=t,this._webgl2=e.context._webgl2,this._bufferTarget=n,this._sizeInBytes=o,this._usage=r,this._buffer=a,this.vertexArrayDestroyable=!0}Gt.createVertexBuffer=function(e){return d.defined("options.context",e.context),new Gt({context:e.context,bufferTarget:I.ARRAY_BUFFER,typedArray:e.typedArray,sizeInBytes:e.sizeInBytes,usage:e.usage})},Gt.createIndexBuffer=function(e){if(d.defined("options.context",e.context),!Ct.validate(e.indexDatatype))throw new T("Invalid indexDatatype.");if(e.indexDatatype===Ct.UNSIGNED_INT&&!e.context.elementIndexUint)throw new T("IndexDatatype.UNSIGNED_INT requires OES_element_index_uint, which is not supported on this system. Check context.elementIndexUint.");const t=e.context,n=e.indexDatatype,i=Ct.getSizeInBytes(n),o=new Gt({context:t,bufferTarget:I.ELEMENT_ARRAY_BUFFER,typedArray:e.typedArray,sizeInBytes:e.sizeInBytes,usage:e.usage}),r=o.sizeInBytes/i;return Object.defineProperties(o,{indexDatatype:{get:function(){return n}},bytesPerIndex:{get:function(){return i}},numberOfIndices:{get:function(){return r}}}),o},Object.defineProperties(Gt.prototype,{sizeInBytes:{get:function(){return this._sizeInBytes}},usage:{get:function(){return this._usage}}}),Gt.prototype._getBuffer=function(){return this._buffer},Gt.prototype.copyFromArrayView=function(e,t){t=m(t,0),d.defined("arrayView",e),d.typeOf.number.lessThanOrEquals("offsetInBytes + arrayView.byteLength",t+e.byteLength,this._sizeInBytes);const n=this._gl,i=this._bufferTarget;n.bindBuffer(i,this._buffer),n.bufferSubData(i,t,e),n.bindBuffer(i,null)},Gt.prototype.copyFromBuffer=function(e,t,n,i){if(!this._webgl2)throw new T("A WebGL 2 context is required.");if(!h(e))throw new T("readBuffer must be defined.");if(!h(i)||i<=0)throw new T("sizeInBytes must be defined and be greater than zero.");if(!h(t)||t<0||t+i>e._sizeInBytes)throw new T("readOffset must be greater than or equal to zero and readOffset + sizeInBytes must be less than of equal to readBuffer.sizeInBytes.");if(!h(n)||n<0||n+i>this._sizeInBytes)throw new T("writeOffset must be greater than or equal to zero and writeOffset + sizeInBytes must be less than of equal to this.sizeInBytes.");if(this._buffer===e._buffer&&(n>=t&&nn&&ts)throw new T("destinationOffset must be greater than zero and less than the arrayView length.");if(n+o>s)throw new T("destinationOffset + length must be less than or equal to the arrayViewLength.");if(t<0||t>this._sizeInBytes)throw new T("sourceOffset must be greater than zero and less than the buffers size.");if(t+o*r>this._sizeInBytes)throw new T("sourceOffset + length must be less than the buffers size.");const a=this._gl,c=I.COPY_READ_BUFFER;a.bindBuffer(c,this._buffer),a.getBufferSubData(c,t,e,n,i),a.bindBuffer(c,null)},Gt.prototype.isDestroyed=function(){return!1},Gt.prototype.destroy=function(){return this._gl.deleteBuffer(this._buffer),gt(this)};function jb(e,t,n,i){const o=h(t.vertexBuffer),r=h(t.value),s=t.value?t.value.length:t.componentsPerAttribute;if(!o&&!r)throw new T("attribute must have a vertexBuffer or a value.");if(o&&r)throw new T("attribute cannot have both a vertexBuffer and a value. It must have either a vertexBuffer property defining per-vertex data or a value property defining data for all vertices.");if(s!==1&&s!==2&&s!==3&&s!==4)throw r?new T("attribute.value.length must be in the range [1, 4]."):new T("attribute.componentsPerAttribute must be in the range [1, 4].");if(h(t.componentDatatype)&&!ue.validate(t.componentDatatype))throw new T("attribute must have a valid componentDatatype or not specify it.");if(h(t.strideInBytes)&&t.strideInBytes>255)throw new T("attribute must have a strideInBytes less than or equal to 255 or not specify it.");if(h(t.instanceDivisor)&&t.instanceDivisor>0&&!i.instancedArrays)throw new T("instanced arrays is not supported");if(h(t.instanceDivisor)&&t.instanceDivisor<0)throw new T("attribute must have an instanceDivisor greater than or equal to zero");if(h(t.instanceDivisor)&&r)throw new T("attribute cannot have have an instanceDivisor if it is not backed by a buffer");if(h(t.instanceDivisor)&&t.instanceDivisor>0&&t.index===0)throw new T("attribute zero cannot have an instanceDivisor greater than 0");const a={index:m(t.index,n),enabled:m(t.enabled,!0),vertexBuffer:t.vertexBuffer,value:r?t.value.slice(0):void 0,componentsPerAttribute:s,componentDatatype:m(t.componentDatatype,ue.FLOAT),normalize:m(t.normalize,!1),offsetInBytes:m(t.offsetInBytes,0),strideInBytes:m(t.strideInBytes,0),instanceDivisor:m(t.instanceDivisor,0)};if(o)a.vertexAttrib=function(c){const u=this.index;c.bindBuffer(c.ARRAY_BUFFER,this.vertexBuffer._getBuffer()),c.vertexAttribPointer(u,this.componentsPerAttribute,this.componentDatatype,this.normalize,this.strideInBytes,this.offsetInBytes),c.enableVertexAttribArray(u),this.instanceDivisor>0&&(i.glVertexAttribDivisor(u,this.instanceDivisor),i._vertexAttribDivisors[u]=this.instanceDivisor,i._previousDrawInstanced=!0)},a.disableVertexAttribArray=function(c){c.disableVertexAttribArray(this.index),this.instanceDivisor>0&&i.glVertexAttribDivisor(n,0)};else{switch(a.componentsPerAttribute){case 1:a.vertexAttrib=function(c){c.vertexAttrib1fv(this.index,this.value)};break;case 2:a.vertexAttrib=function(c){c.vertexAttrib2fv(this.index,this.value)};break;case 3:a.vertexAttrib=function(c){c.vertexAttrib3fv(this.index,this.value)};break;case 4:a.vertexAttrib=function(c){c.vertexAttrib4fv(this.index,this.value)};break}a.disableVertexAttribArray=function(c){}}e.push(a)}function Hf(e,t,n){for(let i=0;i0&&(c=!0),h(s[r].value)&&(u=!0);const p={};for(r=0;r0)for(r=qf(e[o[0]]),t=1;t0){const u=ue.getSizeInBytes(e[o[0]].componentDatatype),f=a%u;f!==0&&(a+=u-f);const p=r*a,_=new ArrayBuffer(p),g={};for(t=0;t=P.SIXTY_FOUR_KILOBYTES&&t.elementIndexUint?_=Gt.createIndexBuffer({context:t,typedArray:new Uint32Array(g),usage:i,indexDatatype:Ct.UNSIGNED_INT}):_=Gt.createIndexBuffer({context:t,typedArray:new Uint16Array(g),usage:i,indexDatatype:Ct.UNSIGNED_SHORT})),new Zn({context:t,attributes:f,indexBuffer:_})},Object.defineProperties(Zn.prototype,{numberOfAttributes:{get:function(){return this._attributes.length}},numberOfVertices:{get:function(){return this._numberOfVertices}},indexBuffer:{get:function(){return this._indexBuffer}}}),Zn.prototype.getAttribute=function(e){return d.defined("index",e),this._attributes[e]};function Hb(e){const t=e._context,n=e._hasInstancedAttributes;if(!n&&!t._previousDrawInstanced)return;t._previousDrawInstanced=n;const i=t._vertexAttribDivisors,o=e._attributes,r=xt.maximumVertexAttributes;let s;if(n){const a=o.length;for(s=0;s0&&(t.glVertexAttribDivisor(s,0),i[s]=0)}function qb(e,t){const n=e._attributes,i=n.length;for(let o=0;o=this._numberOfInstances)throw new T("instanceIndex is out of range.");if(t<0||t>=this._attributes.length)throw new T("attributeIndex is out of range");const i=this._attributes,o=this._offsets[t],s=4*this._stride*e+4*o;let a;this._packFloats&&i[t].componentDatatype!==de.UNSIGNED_BYTE?a=Xb(this._batchValues,s,Yf):a=q.unpack(this._batchValues,s,Yf);const c=Wf(i,t);return h(c.fromCartesian4)?c.fromCartesian4(a,n):h(c.clone)?c.clone(a,n):a.x};const Zb=[void 0,void 0,new L,new l,new q],Qb=new q;Qn.prototype.setBatchedAttribute=function(e,t,n){if(e<0||e>=this._numberOfInstances)throw new T("instanceIndex is out of range.");if(t<0||t>=this._attributes.length)throw new T("attributeIndex is out of range");if(!h(n))throw new T("value is required.");const i=this._attributes,o=Zb[i[t].componentsPerAttribute],r=this.getBatchedAttribute(e,t,o),s=Wf(this._attributes,t);if(h(s.equals)?s.equals(r,n):r===n)return;const c=Qb;c.x=h(n.x)?n.x:n,c.y=h(n.y)?n.y:0,c.z=h(n.z)?n.z:0,c.w=h(n.w)?n.w:0;const u=this._offsets[t],p=4*this._stride*e+4*u;this._packFloats&&i[t].componentDatatype!==de.UNSIGNED_BYTE?Kb(c,this._batchValues,p):q.pack(c,this._batchValues,p),this._batchValuesDirty=!0};function Jb(e,t){const n=e._textureDimensions;e._texture=new jt({context:t,pixelFormat:ye.RGBA,pixelDatatype:e._pixelDatatype,width:n.x,height:n.y,sampler:Rn.NEAREST,flipY:!1})}function eT(e){const t=e._textureDimensions;e._texture.copyFrom({source:{width:t.x,height:t.y,arrayBufferView:e._batchValues}})}Qn.prototype.update=function(e){h(this._texture)&&!this._batchValuesDirty||this._attributes.length===0||(this._batchValuesDirty=!1,h(this._texture)||Jb(this,e.context),eT(this))},Qn.prototype.getUniformMapCallback=function(){const e=this;return function(t){return e._attributes.length===0?t:Kt(t,{batchTexture:function(){return e._texture},batchTextureDimensions:function(){return e._textureDimensions},batchTextureStep:function(){return e._textureStep}})}};function tT(e){const t=e._stride;return e._textureDimensions.y===1?`uniform vec4 batchTextureStep; vec2 computeSt(float batchId) { float stepX = batchTextureStep.x; float centerX = batchTextureStep.y; float numberOfAttributes = float(${t}); return vec2(centerX + (batchId * numberOfAttributes * stepX), 0.5); } `:`uniform vec4 batchTextureStep; uniform vec2 batchTextureDimensions; vec2 computeSt(float batchId) { float stepX = batchTextureStep.x; float centerX = batchTextureStep.y; float stepY = batchTextureStep.z; float centerY = batchTextureStep.w; float numberOfAttributes = float(${t}); float xId = mod(batchId * numberOfAttributes, batchTextureDimensions.x); float yId = floor(batchId * numberOfAttributes / batchTextureDimensions.x); return vec2(centerX + (xId * stepX), centerY + (yId * stepY)); } `}function nT(e){return e===1?"float":`vec${e}`}function iT(e){return e===1?".x":e===2?".xy":e===3?".xyz":""}function oT(e,t){const i=e._attributes[t],o=i.componentsPerAttribute,r=i.functionName,s=nT(o),a=iT(o),c=e._offsets[t];let u=`${s} ${r}(float batchId) { vec2 st = computeSt(batchId); st.x += batchTextureStep.x * float(${c}); `;return e._packFloats&&i.componentDatatype!==de.UNSIGNED_BYTE?u+=`vec4 textureValue; textureValue.x = czm_unpackFloat(texture(batchTexture, st)); textureValue.y = czm_unpackFloat(texture(batchTexture, st + vec2(batchTextureStep.x, 0.0))); textureValue.z = czm_unpackFloat(texture(batchTexture, st + vec2(batchTextureStep.x * 2.0, 0.0))); textureValue.w = czm_unpackFloat(texture(batchTexture, st + vec2(batchTextureStep.x * 3.0, 0.0))); `:u+=` vec4 textureValue = texture(batchTexture, st); `,u+=` ${s} value = textureValue${a}; `,e._pixelDatatype===de.UNSIGNED_BYTE&&i.componentDatatype===ue.UNSIGNED_BYTE&&!i.normalize?u+=`value *= 255.0; `:e._pixelDatatype===de.FLOAT&&i.componentDatatype===ue.UNSIGNED_BYTE&&i.normalize&&(u+=`value /= 255.0; `),u+=` return value; } `,u}Qn.prototype.getVertexShaderCallback=function(){const e=this._attributes;if(e.length===0)return function(i){return i};let t=`uniform highp sampler2D batchTexture; `;t+=`${tT(this)} `;const n=e.length;for(let i=0;iP.EPSILON6)throw new T("vector must be normalized.");if(n.x=e.x/(Math.abs(e.x)+Math.abs(e.y)+Math.abs(e.z)),n.y=e.y/(Math.abs(e.x)+Math.abs(e.y)+Math.abs(e.z)),e.z<0){const o=n.x,r=n.y;n.x=(1-Math.abs(r))*P.signNotZero(o),n.y=(1-Math.abs(o))*P.signNotZero(r)}return n.x=P.toSNorm(n.x,t),n.y=P.toSNorm(n.y,t),n},Le.octEncode=function(e,t){return Le.octEncodeInRange(e,255,t)};const ar=new L,Kf=new Uint8Array(1);function Ds(e){return Kf[0]=e,Kf[0]}Le.octEncodeToCartesian4=function(e,t){return Le.octEncodeInRange(e,65535,ar),t.x=Ds(ar.x*$f),t.y=Ds(ar.x),t.z=Ds(ar.y*$f),t.w=Ds(ar.y),t},Le.octDecodeInRange=function(e,t,n,i){if(d.defined("result",i),e<0||e>n||t<0||t>n)throw new T(`x and y must be unsigned normalized integers between 0 and ${n}`);if(i.x=P.fromSNorm(e,n),i.y=P.fromSNorm(t,n),i.z=1-(Math.abs(i.x)+Math.abs(i.y)),i.z<0){const o=i.x;i.x=(1-Math.abs(i.y))*P.signNotZero(o),i.y=(1-Math.abs(o))*P.signNotZero(i.y)}return l.normalize(i,i)},Le.octDecode=function(e,t,n){return Le.octDecodeInRange(e,t,255,n)},Le.octDecodeFromCartesian4=function(e,t){d.typeOf.object("encoded",e),d.typeOf.object("result",t);const n=e.x,i=e.y,o=e.z,r=e.w;if(n<0||n>255||i<0||i>255||o<0||o>255||r<0||r>255)throw new T("x, y, z, and w must be unsigned normalized integers between 0 and 255");const s=n*Xf+i,a=o*Xf+r;return Le.octDecodeInRange(s,a,65535,t)},Le.octPackFloat=function(e){return d.defined("encoded",e),256*e.x+e.y};const Pc=new L;Le.octEncodeFloat=function(e){return Le.octEncode(e,Pc),Le.octPackFloat(Pc)},Le.octDecodeFloat=function(e,t){d.defined("value",e);const n=e/256,i=Math.floor(n),o=(n-i)*256;return Le.octDecode(i,o,t)},Le.octPack=function(e,t,n,i){d.defined("v1",e),d.defined("v2",t),d.defined("v3",n),d.defined("result",i);const o=Le.octEncodeFloat(e),r=Le.octEncodeFloat(t),s=Le.octEncode(n,Pc);return i.x=65536*s.x+o,i.y=65536*s.y+r,i},Le.octUnpack=function(e,t,n,i){d.defined("packed",e),d.defined("v1",t),d.defined("v2",n),d.defined("v3",i);let o=e.x/65536;const r=Math.floor(o),s=(o-r)*65536;o=e.y/65536;const a=Math.floor(o),c=(o-a)*65536;Le.octDecodeFloat(s,t),Le.octDecodeFloat(c,n),Le.octDecode(r,a,i)},Le.compressTextureCoordinates=function(e){d.defined("textureCoordinates",e);const t=e.x*4095|0,n=e.y*4095|0;return 4096*t+n},Le.decompressTextureCoordinates=function(e,t){d.defined("compressed",e),d.defined("result",t);const n=e/4096,i=Math.floor(n);return t.x=i/4095,t.y=(e-i*4096)/4095,t};function Rc(e){return e>>1^-(e&1)}Le.zigZagDeltaDecode=function(e,t,n){d.defined("uBuffer",e),d.defined("vBuffer",t),d.typeOf.number.equals("uBuffer.length","vBuffer.length",e.length,t.length),h(n)&&d.typeOf.number.equals("uBuffer.length","heightBuffer.length",e.length,n.length);const i=e.length;let o=0,r=0,s=0;for(let a=0;a>11,p=u>>5&r,_=u&o,g=3*c;t[g]=f*s,t[g+1]=p*a,t[g+2]=_*s}return t};const So=Le,Zf=new l,Qf=new l,Jf=new l;function sT(e,t,n,i,o){d.defined("point",e),d.defined("p0",t),d.defined("p1",n),d.defined("p2",i),h(o)||(o=new l);let r,s,a,c,u,f,p,_;if(h(t.z)){if(l.equalsEpsilon(e,t,P.EPSILON14))return l.clone(l.UNIT_X,o);if(l.equalsEpsilon(e,n,P.EPSILON14))return l.clone(l.UNIT_Y,o);if(l.equalsEpsilon(e,i,P.EPSILON14))return l.clone(l.UNIT_Z,o);r=l.subtract(n,t,Zf),s=l.subtract(i,t,Qf),a=l.subtract(e,t,Jf),c=l.dot(r,r),u=l.dot(r,s),f=l.dot(r,a),p=l.dot(s,s),_=l.dot(s,a)}else{if(L.equalsEpsilon(e,t,P.EPSILON14))return l.clone(l.UNIT_X,o);if(L.equalsEpsilon(e,n,P.EPSILON14))return l.clone(l.UNIT_Y,o);if(L.equalsEpsilon(e,i,P.EPSILON14))return l.clone(l.UNIT_Z,o);r=L.subtract(n,t,Zf),s=L.subtract(i,t,Qf),a=L.subtract(e,t,Jf),c=L.dot(r,r),u=L.dot(r,s),f=L.dot(r,a),p=L.dot(s,s),_=L.dot(s,a)}o.y=p*f-u*_,o.z=c*_-u*f;const g=c*p-u*u;if(g!==0)return o.y/=g,o.z/=g,o.x=1-o.y-o.z,o}const Ic={};Ic.calculateACMR=function(e){e=m(e,m.EMPTY_OBJECT);const t=e.indices;let n=e.maximumIndex;const i=m(e.cacheSize,24);if(!h(t))throw new T("indices is required.");const o=t.length;if(o<3||o%3!==0)throw new T("indices length must be a multiple of three.");if(n<=0)throw new T("maximumIndex must be greater than zero.");if(i<3)throw new T("cacheSize must be greater than two.");if(!h(n)){n=0;let a=0,c=t[a];for(;an&&(n=c),++a,c=t[a]}const r=[];for(let a=0;ai&&(r[t[a]]=s,++s);return(s-i+1)/(o/3)},Ic.tipsify=function(e){e=m(e,m.EMPTY_OBJECT);const t=e.indices,n=e.maximumIndex,i=m(e.cacheSize,24);let o;function r(H,W,w,C){for(;W.length>=1;){const x=W[W.length-1];if(W.splice(W.length-1,1),H[x].numLiveTriangles>0)return x}for(;o0)return++o,o-1;++o}return-1}function s(H,W,w,C,x,N,V){let Y=-1,Z,$=-1,re=0;for(;re$||$===-1)&&($=Z,Y=le)),++re}return Y===-1?r(C,N,H,V):Y}if(!h(t))throw new T("indices is required.");const a=t.length;if(a<3||a%3!==0)throw new T("indices length must be a multiple of three.");if(n<=0)throw new T("maximumIndex must be greater than zero.");if(i<3)throw new T("cacheSize must be greater than two.");let c=0,u=0,f=t[u];const p=a;if(h(n))c=n+1;else{for(;uc&&(c=f),++u,f=t[u];if(c===-1)return 0;++c}const _=[];let g;for(g=0;gi&&(A.timeStamp=E,++E),++u}b=s(t,i,O,_,E,v,c)}return U};const aT=Ic,Vt={};function Ms(e,t,n,i,o){e[t++]=n,e[t++]=i,e[t++]=i,e[t++]=o,e[t++]=o,e[t]=n}function cT(e){const t=e.length,n=t/3*6,i=Ct.createTypedArray(t,n);let o=0;for(let r=0;r=3){const n=(t-2)*6,i=Ct.createTypedArray(t,n);Ms(i,0,e[0],e[1],e[2]);let o=6;for(let r=3;r0){const t=e.length-1,n=(t-1)*6,i=Ct.createTypedArray(t,n),o=e[0];let r=0;for(let s=1;so&&(o=n[r]);e.indices=aT.tipsify({indices:n,maximumIndex:o,cacheSize:t})}return e};function ed(e){const t={};for(const n in e)if(e.hasOwnProperty(n)&&h(e[n])&&h(e[n].values)){const i=e[n];t[n]=new Tt({componentDatatype:i.componentDatatype,componentsPerAttribute:i.componentsPerAttribute,normalize:i.normalize,values:[]})}return t}function uT(e,t,n){for(const i in t)if(t.hasOwnProperty(i)&&h(t[i])&&h(t[i].values)){const o=t[i];for(let r=0;r=P.SIXTY_FOUR_KILOBYTES){let i=[],o=[],r=0,s=ed(e.attributes);const a=e.indices,c=a.length;let u;e.primitiveType===Ue.TRIANGLES?u=3:e.primitiveType===Ue.LINES?u=2:e.primitiveType===Ue.POINTS&&(u=1);for(let f=0;f=P.SIXTY_FOUR_KILOBYTES&&(t.push(new rt({attributes:s,indices:o,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV})),i=[],o=[],r=0,s=ed(e.attributes))}o.length!==0&&t.push(new rt({attributes:s,indices:o,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV}))}else t.push(e);return t};const td=new l,fT=new J;Vt.projectTo2D=function(e,t,n,i,o){if(!h(e))throw new T("geometry is required.");if(!h(t))throw new T("attributeName is required.");if(!h(n))throw new T("attributeName3D is required.");if(!h(i))throw new T("attributeName2D is required.");if(!h(e.attributes[t]))throw new T(`geometry must have attribute matching the attributeName argument: ${t}.`);if(e.attributes[t].componentDatatype!==ue.DOUBLE)throw new T("The attribute componentDatatype must be ComponentDatatype.DOUBLE.");const r=e.attributes[t];o=h(o)?o:new gn;const s=o.ellipsoid,a=r.values,c=new Float64Array(a.length);let u=0;for(let f=0;fE&&(E=v)}return new rt({attributes:f,indices:y,primitiveType:u,boundingSphere:h(b)?new Q(b,E):void 0})}Vt.combineInstances=function(e){if(!h(e)||e.length<1)throw new T("instances is required and must have length greater than zero.");const t=[],n=[],i=e.length;for(let r=0;r0&&o.push(Nc(t,"geometry")),n.length>0&&(o.push(Nc(n,"westHemisphereGeometry")),o.push(Nc(n,"eastHemisphereGeometry"))),o};const dn=new l,cr=new l,Oo=new l,Ao=new l;Vt.computeNormal=function(e){if(!h(e))throw new T("geometry is required.");if(!h(e.attributes.position)||!h(e.attributes.position.values))throw new T("geometry.attributes.position.values is required.");if(!h(e.indices))throw new T("geometry.indices is required.");if(e.indices.length<2||e.indices.length%3!==0)throw new T("geometry.indices length must be greater than 0 and be a multiple of 3.");if(e.primitiveType!==Ue.TRIANGLES)throw new T("geometry.primitiveType must be PrimitiveType.TRIANGLES.");const t=e.indices,n=e.attributes,i=n.position.values,o=n.position.values.length/3,r=t.length,s=new Array(o),a=new Array(r/3),c=new Array(r);let u;for(u=0;u0){for(f=0;f<_.count;f++)l.add(dn,a[c[_.indexOffset+f]],dn);l.equalsEpsilon(l.ZERO,dn,P.EPSILON10)&&l.clone(a[c[_.indexOffset]],dn)}l.equalsEpsilon(l.ZERO,dn,P.EPSILON10)&&(dn.z=1),l.normalize(dn,dn),g[y]=dn.x,g[y+1]=dn.y,g[y+2]=dn.z}return e.attributes.normal=new Tt({componentDatatype:ue.FLOAT,componentsPerAttribute:3,values:g}),e};const mT=new l,nd=new l,_T=new l;Vt.computeTangentAndBitangent=function(e){if(!h(e))throw new T("geometry is required.");const t=e.attributes,n=e.indices;if(!h(t.position)||!h(t.position.values))throw new T("geometry.attributes.position.values is required.");if(!h(t.normal)||!h(t.normal.values))throw new T("geometry.attributes.normal.values is required.");if(!h(t.st)||!h(t.st.values))throw new T("geometry.attributes.st.values is required.");if(!h(n))throw new T("geometry.indices is required.");if(n.length<2||n.length%3!==0)throw new T("geometry.indices length must be greater than 0 and be a multiple of 3.");if(e.primitiveType!==Ue.TRIANGLES)throw new T("geometry.primitiveType must be PrimitiveType.TRIANGLES.");const i=e.attributes.position.values,o=e.attributes.normal.values,r=e.attributes.st.values,s=e.attributes.position.values.length/3,a=n.length,c=new Array(s*3);let u;for(u=0;u3&&(n[3]=0,n[4]=2,n[5]=3);let i=6;for(let o=3;oo?i>r?s=P.sign(e.y):s=P.sign(n.y):o>r?s=P.sign(t.y):s=P.sign(n.y);const a=s<0;bi(e,a),bi(t,a),bi(n,a)}const rd=new l;function pn(e,t,n,i){l.add(e,l.multiplyByScalar(l.subtract(t,e,rd),e.y/(e.y-t.y),rd),n),l.clone(n,i),bi(n,!0),bi(i,!1)}const ji=new l,Gi=new l,Vi=new l,Hi=new l,Lc={positions:new Array(7),indices:new Array(3*3)};function OT(e,t,n){if(e.x>=0||t.x>=0||n.x>=0)return;ST(e,t,n);const i=e.y<0,o=t.y<0,r=n.y<0;let s=0;s+=i?1:0,s+=o?1:0,s+=r?1:0;const a=Lc.indices;s===1?(a[1]=3,a[2]=4,a[5]=6,a[7]=6,a[8]=5,i?(pn(e,t,ji,Vi),pn(e,n,Gi,Hi),a[0]=0,a[3]=1,a[4]=2,a[6]=1):o?(pn(t,n,ji,Vi),pn(t,e,Gi,Hi),a[0]=1,a[3]=2,a[4]=0,a[6]=2):r&&(pn(n,e,ji,Vi),pn(n,t,Gi,Hi),a[0]=2,a[3]=0,a[4]=1,a[6]=0)):s===2&&(a[2]=4,a[4]=4,a[5]=3,a[7]=5,a[8]=6,i?o?r||(pn(n,e,ji,Vi),pn(n,t,Gi,Hi),a[0]=0,a[1]=1,a[3]=0,a[6]=2):(pn(t,n,ji,Vi),pn(t,e,Gi,Hi),a[0]=2,a[1]=0,a[3]=2,a[6]=1):(pn(e,t,ji,Vi),pn(e,n,Gi,Hi),a[0]=1,a[1]=2,a[3]=1,a[6]=0));const c=Lc.positions;return c[0]=e,c[1]=t,c[2]=n,c.length=3,(s===1||s===2)&&(c[3]=ji,c[4]=Gi,c[5]=Vi,c[6]=Hi,c.length=7),Lc}function sd(e,t){const n=e.attributes;if(n.position.values.length===0)return;for(const o in n)if(n.hasOwnProperty(o)&&h(n[o])&&h(n[o].values)){const r=n[o];r.values=ue.createTypedArray(r.componentDatatype,r.values)}const i=rt.computeNumberOfVertices(e);return e.indices=Ct.createTypedArray(i,e.indices),t&&(e.boundingSphere=Q.fromVertices(n.position.values)),e}function vo(e){const t=e.attributes,n={};for(const i in t)if(t.hasOwnProperty(i)&&h(t[i])&&h(t[i].values)){const o=t[i];n[i]=new Tt({componentDatatype:o.componentDatatype,componentsPerAttribute:o.componentsPerAttribute,normalize:o.normalize,values:[]})}return new rt({attributes:n,indices:[],primitiveType:e.primitiveType})}function Fc(e,t,n){const i=h(e.geometry.boundingSphere);t=sd(t,i),n=sd(n,i),h(n)&&!h(t)?e.geometry=n:!h(n)&&h(t)?e.geometry=t:(e.westHemisphereGeometry=t,e.eastHemisphereGeometry=n,e.geometry=void 0)}function Bc(e,t){const n=new e,i=new e,o=new e;return function(r,s,a,c,u,f,p,_){const g=e.fromArray(u,r*t,n),y=e.fromArray(u,s*t,i),b=e.fromArray(u,a*t,o);e.multiplyByScalar(g,c.x,g),e.multiplyByScalar(y,c.y,y),e.multiplyByScalar(b,c.z,b);const E=e.add(g,y,g);e.add(E,b,E),_&&e.normalize(E,E),e.pack(E,f,p*t)}}const AT=Bc(q,4),Bs=Bc(l,3),ad=Bc(L,2),vT=function(e,t,n,i,o,r,s){const a=o[e]*i.x,c=o[t]*i.y,u=o[n]*i.z;r[s]=a+c+u>P.EPSILON6?1:0},hr=new l,Uc=new l,kc=new l,xT=new l;function Us(e,t,n,i,o,r,s,a,c,u,f,p,_,g,y,b){if(!h(r)&&!h(s)&&!h(a)&&!h(c)&&!h(u)&&g===0)return;const E=l.fromArray(o,e*3,hr),O=l.fromArray(o,t*3,Uc),v=l.fromArray(o,n*3,kc),A=sT(i,E,O,v,xT);if(h(A)){if(h(r)&&Bs(e,t,n,A,r,p.normal.values,b,!0),h(u)){const R=l.fromArray(u,e*3,hr),z=l.fromArray(u,t*3,Uc),U=l.fromArray(u,n*3,kc);l.multiplyByScalar(R,A.x,R),l.multiplyByScalar(z,A.y,z),l.multiplyByScalar(U,A.z,U);let G;!l.equals(R,l.ZERO)||!l.equals(z,l.ZERO)||!l.equals(U,l.ZERO)?(G=l.add(R,z,R),l.add(G,U,G),l.normalize(G,G)):(G=hr,G.x=0,G.y=0,G.z=0),l.pack(G,p.extrudeDirection.values,b*3)}if(h(f)&&vT(e,t,n,A,f,p.applyOffset.values,b),h(s)&&Bs(e,t,n,A,s,p.tangent.values,b,!0),h(a)&&Bs(e,t,n,A,a,p.bitangent.values,b,!0),h(c)&&ad(e,t,n,A,c,p.st.values,b),g>0)for(let R=0;R3){const C=w.positions,x=w.indices,N=x.length;for(let V=0;V0)continue;const c=l.unpack(i,s,dd);(a.y<0&&c.y>0||a.y>0&&c.y<0)&&(s-3>0?(i[s]=n[s-3],i[s+1]=n[s-2],i[s+2]=n[s-1]):l.pack(a,i,s));const u=l.unpack(o,s,jc);(a.y<0&&u.y>0||a.y>0&&u.y<0)&&(s+30||Q.intersectPlane(n,Se.ORIGIN_ZX_PLANE)!==nn.INTERSECTING))return e;if(t.geometryType!==qo.NONE)switch(t.geometryType){case qo.POLYLINES:BT(e);break;case qo.TRIANGLES:cd(e);break;case qo.LINES:hd(e);break}else CT(t),t.primitiveType===Ue.TRIANGLES?cd(e):t.primitiveType===Ue.LINES&&hd(e);return e};const kt=Vt;function Ht(e){this._ellipsoid=m(e,pe.WGS84),this._semimajorAxis=this._ellipsoid.maximumRadius,this._oneOverSemimajorAxis=1/this._semimajorAxis}Object.defineProperties(Ht.prototype,{ellipsoid:{get:function(){return this._ellipsoid}}}),Ht.mercatorAngleToGeodeticLatitude=function(e){return P.PI_OVER_TWO-2*Math.atan(Math.exp(-e))},Ht.geodeticLatitudeToMercatorAngle=function(e){e>Ht.MaximumLatitude?e=Ht.MaximumLatitude:e<-Ht.MaximumLatitude&&(e=-Ht.MaximumLatitude);const t=Math.sin(e);return .5*Math.log((1+t)/(1-t))},Ht.MaximumLatitude=Ht.mercatorAngleToGeodeticLatitude(Math.PI),Ht.prototype.project=function(e,t){const n=this._semimajorAxis,i=e.longitude*n,o=Ht.geodeticLatitudeToMercatorAngle(e.latitude)*n,r=e.height;return h(t)?(t.x=i,t.y=o,t.z=r,t):new l(i,o,r)},Ht.prototype.unproject=function(e,t){if(!h(e))throw new T("cartesian is required");const n=this._oneOverSemimajorAxis,i=e.x*n,o=Ht.mercatorAngleToGeodeticLatitude(e.y*n),r=e.z;return h(t)?(t.longitude=i,t.latitude=o,t.height=r,t):new J(i,o,r)};function UT(e,t,n){let i=!n;const o=e.length;let r;if(!i&&o>1){const s=e[0].modelMatrix;for(r=1;r=0){const u=i[a];o=u.offset+u.count,s=u.index,r=n[s].indices.length}else o=0,s=0,r=n[s].indices.length;const c=e.length;for(let u=0;ur&&(o=0,r=n[++s].indices.length),i.push({index:s,offset:o,count:_}),o+=_}}function GT(e,t){const n=[];return Vc(e,"geometry",t,n),Vc(e,"westHemisphereGeometry",t,n),Vc(e,"eastHemisphereGeometry",t,n),n}const Jn={};Jn.combineGeometry=function(e){let t,n;const i=e.instances,o=i.length;let r,s,a=!1;o>0&&(t=jT(e),t.length>0&&(n=kt.createAttributeLocations(t[0]),e.createPickOffsets&&(r=GT(i,t))),h(i[0].attributes)&&h(i[0].attributes.offset)&&(s=new Array(o),a=!0));const c=new Array(o),u=new Array(o);for(let f=0;f0&&(n.set(c.indices,s),s+=y)}return t.push(n.buffer),{stringTable:i,packedData:n}},Jn.unpackCreateGeometryResults=function(e){const t=e.stringTable,n=e.packedData;let i;const o=new Array(n[0]);let r=0,s=1;for(;s0){const z=E.length/O;for(R=Ct.createTypedArray(z,b),i=0;i= nearSq && distanceSq <= farSq) ? 1.0 : 0.0; gl_Position *= show; }`,`${i} ${o}`};function Ed(e,t){if(!e.compressVertices)return t;const n=t.search(/in\s+vec3\s+normal;/g)!==-1,i=t.search(/in\s+vec2\s+st;/g)!==-1;if(!n&&!i)return t;const o=t.search(/in\s+vec3\s+tangent;/g)!==-1,r=t.search(/in\s+vec3\s+bitangent;/g)!==-1;let s=i&&n?2:1;s+=o||r?1:0;const a=s>1?`vec${s}`:"float",c="compressedAttributes",u=`in ${a} ${c};`;let f="",p="";if(i){f+=`vec2 st; `;const y=s>1?`${c}.x`:c;p+=` st = czm_decompressTextureCoordinates(${y}); `}n&&o&&r?(f+=`vec3 normal; vec3 tangent; vec3 bitangent; `,p+=` czm_octDecode(${c}.${i?"yz":"xy"}, normal, tangent, bitangent); `):(n&&(f+=`vec3 normal; `,p+=` normal = czm_octDecode(${c}${s>1?`.${i?"y":"x"}`:""}); `),o&&(f+=`vec3 tangent; `,p+=` tangent = czm_octDecode(${c}.${i&&n?"z":"y"}); `),r&&(f+=`vec3 bitangent; `,p+=` bitangent = czm_octDecode(${c}.${i&&n?"z":"y"}); `));let _=t;_=_.replace(/in\s+vec3\s+normal;/g,""),_=_.replace(/in\s+vec2\s+st;/g,""),_=_.replace(/in\s+vec3\s+tangent;/g,""),_=_.replace(/in\s+vec3\s+bitangent;/g,""),_=Ae.replaceMain(_,"czm_non_compressed_main");const g=`void main() { ${p} czm_non_compressed_main(); }`;return[u,f,_,g].join(` `)}function nE(e){let t=Ae.replaceMain(e,"czm_non_depth_clamp_main");return t+=`void main() { czm_non_depth_clamp_main(); gl_Position = czm_depthClamp(gl_Position);} `,t}function iE(e){let t=Ae.replaceMain(e,"czm_non_depth_clamp_main");return t+=`void main() { czm_non_depth_clamp_main(); #if defined(LOG_DEPTH) czm_writeLogDepth(); #else czm_writeDepthClamp(); #endif } `,t}function Cd(e,t){const n=e.vertexAttributes;for(const i in n)if(n.hasOwnProperty(i)&&!h(t[i]))throw new T(`Appearance/Geometry mismatch. The appearance requires vertex shader attribute input '${i}', which was not computed as part of the Geometry. Use the appearance's vertexFormat property when constructing the geometry.`)}function oE(e,t){return function(){return e[t]}}const Wc=Math.max(wn.hardwareConcurrency-1,1);let Gs;const rE=new yt("combineGeometry");function sE(e,t){let n,i,o,r;const s=e._instanceIds;if(e._state===pt.READY){n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];const a=e._numberOfInstances=n.length,c=[];let u=[];for(o=0;o0){const b=new Float64Array(p);for(y=[b.buffer],r=0;r0?(e._recomputeBoundingSpheres=!0,e._state=pt.COMBINED):fr(e,t,pt.FAILED,void 0)}).catch(function(p){fr(e,t,pt.FAILED,p)})}}function aE(e,t){const n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances],i=e._numberOfInstances=n.length,o=new Array(i),r=e._instanceIds;let s,a,c=0;for(a=0;a0?(e._recomputeBoundingSpheres=!0,e._state=pt.COMBINED):fr(e,t,pt.FAILED,void 0)}function cE(e,t){const n=e._batchTableAttributeIndices.offset;if(!e._recomputeBoundingSpheres||!h(n)){e._recomputeBoundingSpheres=!1;return}let i;const o=e._offsetInstanceExtend,r=e._instanceBoundingSpheres,s=r.length;let a=e._tempBoundingSpheres;if(!h(a)){for(a=new Array(s),i=0;i0||Q.intersectPlane(b,Se.ORIGIN_ZX_PLANE)!==nn.INTERSECTING?c.push(b):(u.push(b),f.push(b))}let p=c[0],_=f[0],g=u[0];for(i=1;i0){if(xt.maximumVertexTextureImageUnits===0)throw new dt("Vertex texture fetch support is required to render primitives with per-instance attributes. The maximum number of vertex texture image units must be greater than zero.");this._batchTable.update(e)}if(this._state!==pt.COMPLETE&&this._state!==pt.COMBINED&&(this.asynchronous?sE(this,e):aE(this,e)),this._state===pt.COMBINED&&(lE(this,e),xd(this,e),uE(this,e)),!this.show||this._state!==pt.COMPLETE)return;this._batchTableOffsetsUpdated||xd(this,e),this._recomputeBoundingSpheres&&cE(this,e);const n=this.appearance,i=n.material;let o=!1,r=!1;this._appearance!==n?(this._appearance=n,this._material=i,o=!0,r=!0):this._material!==i&&(this._material=i,r=!0);const s=this.depthFailAppearance,a=h(s)?s.material:void 0;this._depthFailAppearance!==s?(this._depthFailAppearance=s,this._depthFailMaterial=a,o=!0,r=!0):this._depthFailMaterial!==a&&(this._depthFailMaterial=a,r=!0);const c=this._appearance.isTranslucent();this._translucent!==c&&(this._translucent=c,o=!0),h(this._material)&&this._material.update(t);const u=n.closed&&c;o&&m(this._createRenderStatesFunction,fE)(this,t,n,u),r&&m(this._createShaderProgramFunction,dE)(this,e,n),(o||r)&&m(this._createCommandsFunction,pE)(this,n,i,c,u,this._colorCommands,this._pickCommands,e),m(this._updateAndQueueCommandsFunction,mE)(this,e,this._colorCommands,this._pickCommands,this.modelMatrix,this.cull,this.debugShowBoundingVolume,u)};const _E=new Q,gE=new Q;function Id(e,t,n){if(n===hu.TOP){const i=Q.clone(e,_E),o=Q.clone(e,gE);o.center=l.add(o.center,t,o.center),e=Q.union(i,o,e)}else n===hu.ALL&&(e.center=l.add(e.center,t,e.center));return e}function yE(e,t,n){return function(){const i=e.getBatchedAttribute(t,n),o=e.attributes[n],r=o.componentsPerAttribute,s=ue.createTypedArray(o.componentDatatype,r);return h(i.constructor.pack)?i.constructor.pack(i,s,0):s[0]=i,s}}function wE(e,t,n,i,o){return function(r){if(!h(r)||!h(r.length)||r.length<1||r.length>4)throw new T("value must be and array with length between 1 and 4.");const s=wd(r);e.setBatchedAttribute(t,n,s),o==="offset"&&(i._recomputeBoundingSpheres=!0,i._batchTableOffsetsUpdated=!1)}}const bE=new l;function TE(e,t,n){t.boundingSphere={get:function(){let i=e._instanceBoundingSpheres[n];if(h(i)){i=i.clone();const o=e.modelMatrix,r=t.offset;h(r)&&Id(i,l.fromArray(r.get(),0,bE),e._offsetInstanceExtend[n]),h(o)&&(i=Q.transform(i,o))}return i}},t.boundingSphereCV={get:function(){return e._instanceBoundingSpheresCV[n]}}}function EE(e,t,n){t.pickId={get:function(){return e._pickIds[n]}}}Ee.prototype.getGeometryInstanceAttributes=function(e){if(!h(e))throw new T("id is required");if(!h(this._batchTable))throw new T("must call update before calling getGeometryInstanceAttributes");let t=this._perInstanceAttributeCache.get(e);if(h(t))return t;let n=-1;const i=this._lastPerInstanceAttributeIndex,o=this._instanceIds,r=o.length;for(let u=0;u4)throw new T("options.componentsPerAttribute must be between 1 and 4.");if(!h(e.value))throw new T("options.value is required.");this.componentDatatype=e.componentDatatype,this.componentsPerAttribute=e.componentsPerAttribute,this.normalize=m(e.normalize,!1),this.value=e.value}const zd=`#ifdef TEXTURE_COORDINATES #ifdef SPHERICAL in vec4 v_sphericalExtents; #else // SPHERICAL in vec2 v_inversePlaneExtents; in vec4 v_westPlane; in vec4 v_southPlane; #endif // SPHERICAL in vec3 v_uvMinAndSphericalLongitudeRotation; in vec3 v_uMaxAndInverseDistance; in vec3 v_vMaxAndInverseDistance; #endif // TEXTURE_COORDINATES #ifdef PER_INSTANCE_COLOR in vec4 v_color; #endif #ifdef NORMAL_EC vec3 getEyeCoordinate3FromWindowCoordinate(vec2 fragCoord, float logDepthOrDepth) { vec4 eyeCoordinate = czm_windowToEyeCoordinates(fragCoord, logDepthOrDepth); return eyeCoordinate.xyz / eyeCoordinate.w; } vec3 vectorFromOffset(vec4 eyeCoordinate, vec2 positiveOffset) { vec2 glFragCoordXY = gl_FragCoord.xy; // Sample depths at both offset and negative offset float upOrRightLogDepth = czm_unpackDepth(texture(czm_globeDepthTexture, (glFragCoordXY + positiveOffset) / czm_viewport.zw)); float downOrLeftLogDepth = czm_unpackDepth(texture(czm_globeDepthTexture, (glFragCoordXY - positiveOffset) / czm_viewport.zw)); // Explicitly evaluate both paths // Necessary for multifrustum and for edges of the screen bvec2 upOrRightInBounds = lessThan(glFragCoordXY + positiveOffset, czm_viewport.zw); float useUpOrRight = float(upOrRightLogDepth > 0.0 && upOrRightInBounds.x && upOrRightInBounds.y); float useDownOrLeft = float(useUpOrRight == 0.0); vec3 upOrRightEC = getEyeCoordinate3FromWindowCoordinate(glFragCoordXY + positiveOffset, upOrRightLogDepth); vec3 downOrLeftEC = getEyeCoordinate3FromWindowCoordinate(glFragCoordXY - positiveOffset, downOrLeftLogDepth); return (upOrRightEC - (eyeCoordinate.xyz / eyeCoordinate.w)) * useUpOrRight + ((eyeCoordinate.xyz / eyeCoordinate.w) - downOrLeftEC) * useDownOrLeft; } #endif // NORMAL_EC void main(void) { #ifdef REQUIRES_EC float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, gl_FragCoord.xy / czm_viewport.zw)); vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth); #endif #ifdef REQUIRES_WC vec4 worldCoordinate4 = czm_inverseView * eyeCoordinate; vec3 worldCoordinate = worldCoordinate4.xyz / worldCoordinate4.w; #endif #ifdef TEXTURE_COORDINATES vec2 uv; #ifdef SPHERICAL // Treat world coords as a sphere normal for spherical coordinates vec2 sphericalLatLong = czm_approximateSphericalCoordinates(worldCoordinate); sphericalLatLong.y += v_uvMinAndSphericalLongitudeRotation.z; sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi); uv.x = (sphericalLatLong.y - v_sphericalExtents.y) * v_sphericalExtents.w; uv.y = (sphericalLatLong.x - v_sphericalExtents.x) * v_sphericalExtents.z; #else // SPHERICAL // Unpack planes and transform to eye space uv.x = czm_planeDistance(v_westPlane, eyeCoordinate.xyz / eyeCoordinate.w) * v_inversePlaneExtents.x; uv.y = czm_planeDistance(v_southPlane, eyeCoordinate.xyz / eyeCoordinate.w) * v_inversePlaneExtents.y; #endif // SPHERICAL #endif // TEXTURE_COORDINATES #ifdef PICK #ifdef CULL_FRAGMENTS // When classifying translucent geometry, logDepthOrDepth == 0.0 // indicates a region that should not be classified, possibly due to there // being opaque pixels there in another buffer. // Check for logDepthOrDepth != 0.0 to make sure this should be classified. if (0.0 <= uv.x && uv.x <= 1.0 && 0.0 <= uv.y && uv.y <= 1.0 || logDepthOrDepth != 0.0) { out_FragColor.a = 1.0; // 0.0 alpha leads to discard from ShaderSource.createPickFragmentShaderSource czm_writeDepthClamp(); } #else // CULL_FRAGMENTS out_FragColor.a = 1.0; #endif // CULL_FRAGMENTS #else // PICK #ifdef CULL_FRAGMENTS // When classifying translucent geometry, logDepthOrDepth == 0.0 // indicates a region that should not be classified, possibly due to there // being opaque pixels there in another buffer. if (uv.x <= 0.0 || 1.0 <= uv.x || uv.y <= 0.0 || 1.0 <= uv.y || logDepthOrDepth == 0.0) { discard; } #endif #ifdef NORMAL_EC // Compute normal by sampling adjacent pixels in 2x2 block in screen space vec3 downUp = vectorFromOffset(eyeCoordinate, vec2(0.0, 1.0)); vec3 leftRight = vectorFromOffset(eyeCoordinate, vec2(1.0, 0.0)); vec3 normalEC = normalize(cross(leftRight, downUp)); #endif #ifdef PER_INSTANCE_COLOR vec4 color = czm_gammaCorrect(v_color); #ifdef FLAT out_FragColor = color; #else // FLAT czm_materialInput materialInput; materialInput.normalEC = normalEC; materialInput.positionToEyeEC = -eyeCoordinate.xyz; czm_material material = czm_getDefaultMaterial(materialInput); material.diffuse = color.rgb; material.alpha = color.a; out_FragColor = czm_phong(normalize(-eyeCoordinate.xyz), material, czm_lightDirectionEC); #endif // FLAT // Premultiply alpha. Required for classification primitives on translucent globe. out_FragColor.rgb *= out_FragColor.a; #else // PER_INSTANCE_COLOR // Material support. // USES_ is distinct from REQUIRES_, because some things are dependencies of each other or // dependencies for culling but might not actually be used by the material. czm_materialInput materialInput; #ifdef USES_NORMAL_EC materialInput.normalEC = normalEC; #endif #ifdef USES_POSITION_TO_EYE_EC materialInput.positionToEyeEC = -eyeCoordinate.xyz; #endif #ifdef USES_TANGENT_TO_EYE materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(worldCoordinate, normalEC); #endif #ifdef USES_ST // Remap texture coordinates from computed (approximately aligned with cartographic space) to the desired // texture coordinate system, which typically forms a tight oriented bounding box around the geometry. // Shader is provided a set of reference points for remapping. materialInput.st.x = czm_lineDistance(v_uvMinAndSphericalLongitudeRotation.xy, v_uMaxAndInverseDistance.xy, uv) * v_uMaxAndInverseDistance.z; materialInput.st.y = czm_lineDistance(v_uvMinAndSphericalLongitudeRotation.xy, v_vMaxAndInverseDistance.xy, uv) * v_vMaxAndInverseDistance.z; #endif czm_material material = czm_getMaterial(materialInput); #ifdef FLAT out_FragColor = vec4(material.diffuse + material.emission, material.alpha); #else // FLAT out_FragColor = czm_phong(normalize(-eyeCoordinate.xyz), material, czm_lightDirectionEC); #endif // FLAT // Premultiply alpha. Required for classification primitives on translucent globe. out_FragColor.rgb *= out_FragColor.a; #endif // PER_INSTANCE_COLOR czm_writeDepthClamp(); #endif // PICK } `;function It(e,t,n){d.typeOf.bool("extentsCulling",e),d.typeOf.bool("planarExtents",t),d.typeOf.object("appearance",n),this._projectionExtentDefines={eastMostYhighDefine:"",eastMostYlowDefine:"",westMostYhighDefine:"",westMostYlowDefine:""};const i=new $c;i.requiresTextureCoordinates=e,i.requiresEC=!n.flat;const o=new $c;if(o.requiresTextureCoordinates=e,n instanceof Lt)i.requiresNormalEC=!n.flat;else{const r=`${n.material.shaderSource} ${n.fragmentShaderSource}`;i.normalEC=r.indexOf("materialInput.normalEC")!==-1||r.indexOf("czm_getDefaultMaterial")!==-1,i.positionToEyeEC=r.indexOf("materialInput.positionToEyeEC")!==-1,i.tangentToEyeMatrix=r.indexOf("materialInput.tangentToEyeMatrix")!==-1,i.st=r.indexOf("materialInput.st")!==-1}this._colorShaderDependencies=i,this._pickShaderDependencies=o,this._appearance=n,this._extentsCulling=e,this._planarExtents=t}It.prototype.createFragmentShader=function(e){d.typeOf.bool("columbusView2D",e);const t=this._appearance,n=this._colorShaderDependencies,i=[];!e&&!this._planarExtents&&i.push("SPHERICAL"),n.requiresEC&&i.push("REQUIRES_EC"),n.requiresWC&&i.push("REQUIRES_WC"),n.requiresTextureCoordinates&&i.push("TEXTURE_COORDINATES"),this._extentsCulling&&i.push("CULL_FRAGMENTS"),n.requiresNormalEC&&i.push("NORMAL_EC"),t instanceof Lt&&i.push("PER_INSTANCE_COLOR"),n.normalEC&&i.push("USES_NORMAL_EC"),n.positionToEyeEC&&i.push("USES_POSITION_TO_EYE_EC"),n.tangentToEyeMatrix&&i.push("USES_TANGENT_TO_EYE"),n.st&&i.push("USES_ST"),t.flat&&i.push("FLAT");let o="";return t instanceof Lt||(o=t.material.shaderSource),new Ae({defines:i,sources:[o,zd]})},It.prototype.createPickFragmentShader=function(e){d.typeOf.bool("columbusView2D",e);const t=this._pickShaderDependencies,n=["PICK"];return!e&&!this._planarExtents&&n.push("SPHERICAL"),t.requiresEC&&n.push("REQUIRES_EC"),t.requiresWC&&n.push("REQUIRES_WC"),t.requiresTextureCoordinates&&n.push("TEXTURE_COORDINATES"),this._extentsCulling&&n.push("CULL_FRAGMENTS"),new Ae({defines:n,sources:[zd],pickColorQualifier:"in"})},It.prototype.createVertexShader=function(e,t,n,i){return d.defined("defines",e),d.typeOf.string("vertexShaderSource",t),d.typeOf.bool("columbusView2D",n),d.defined("mapProjection",i),Ld(this._colorShaderDependencies,this._planarExtents,n,e,t,this._appearance,i,this._projectionExtentDefines)},It.prototype.createPickVertexShader=function(e,t,n,i){return d.defined("defines",e),d.typeOf.string("vertexShaderSource",t),d.typeOf.bool("columbusView2D",n),d.defined("mapProjection",i),Ld(this._pickShaderDependencies,this._planarExtents,n,e,t,void 0,i,this._projectionExtentDefines)};const Dd=new l,Md=new J,Nd={high:0,low:0};function Ld(e,t,n,i,o,r,s,a){const c=i.slice();if(a.eastMostYhighDefine===""){const u=Md;u.longitude=P.PI,u.latitude=0,u.height=0;const f=s.project(u,Dd);let p=Xe.encode(f.x,Nd);a.eastMostYhighDefine=`EAST_MOST_X_HIGH ${p.high.toFixed(`${p.high}`.length+1)}`,a.eastMostYlowDefine=`EAST_MOST_X_LOW ${p.low.toFixed(`${p.low}`.length+1)}`;const _=Md;_.longitude=-P.PI,_.latitude=0,_.height=0;const g=s.project(_,Dd);p=Xe.encode(g.x,Nd),a.westMostYhighDefine=`WEST_MOST_X_HIGH ${p.high.toFixed(`${p.high}`.length+1)}`,a.westMostYlowDefine=`WEST_MOST_X_LOW ${p.low.toFixed(`${p.low}`.length+1)}`}return n&&(c.push(a.eastMostYhighDefine),c.push(a.eastMostYlowDefine),c.push(a.westMostYhighDefine),c.push(a.westMostYlowDefine)),h(r)&&r instanceof Lt&&c.push("PER_INSTANCE_COLOR"),e.requiresTextureCoordinates&&(c.push("TEXTURE_COORDINATES"),t||n||c.push("SPHERICAL"),n&&c.push("COLUMBUS_VIEW_2D")),new Ae({defines:c,sources:[o]})}function $c(){this._requiresEC=!1,this._requiresWC=!1,this._requiresNormalEC=!1,this._requiresTextureCoordinates=!1,this._usesNormalEC=!1,this._usesPositionToEyeEC=!1,this._usesTangentToEyeMat=!1,this._usesSt=!1}Object.defineProperties($c.prototype,{requiresEC:{get:function(){return this._requiresEC},set:function(e){this._requiresEC=e||this._requiresEC}},requiresWC:{get:function(){return this._requiresWC},set:function(e){this._requiresWC=e||this._requiresWC,this.requiresEC=this._requiresWC}},requiresNormalEC:{get:function(){return this._requiresNormalEC},set:function(e){this._requiresNormalEC=e||this._requiresNormalEC,this.requiresEC=this._requiresNormalEC}},requiresTextureCoordinates:{get:function(){return this._requiresTextureCoordinates},set:function(e){this._requiresTextureCoordinates=e||this._requiresTextureCoordinates,this.requiresWC=this._requiresTextureCoordinates}},normalEC:{set:function(e){this.requiresNormalEC=e,this._usesNormalEC=e},get:function(){return this._usesNormalEC}},tangentToEyeMatrix:{set:function(e){this.requiresWC=e,this.requiresNormalEC=e,this._usesTangentToEyeMat=e},get:function(){return this._usesTangentToEyeMat}},positionToEyeEC:{set:function(e){this.requiresEC=e,this._usesPositionToEyeEC=e},get:function(){return this._usesPositionToEyeEC}},st:{set:function(e){this.requiresTextureCoordinates=e,this._usesSt=e},get:function(){return this._usesSt}}});function Fd(e,t,n){return Math.abs((t.y-e.y)*n.x-(t.x-e.x)*n.y+t.x*e.y-t.y*e.x)/L.distance(t,e)}const CE=[new L,new L,new L,new L];function Bd(e,t){const n=CE,i=L.unpack(t,0,n[0]),o=L.unpack(t,2,n[1]),r=L.unpack(t,4,n[2]);e.uMaxVmax=new On({componentDatatype:ue.FLOAT,componentsPerAttribute:4,normalize:!1,value:[o.x,o.y,r.x,r.y]});const s=1/Fd(i,o,r),a=1/Fd(i,r,o);e.uvMinAndExtents=new On({componentDatatype:ue.FLOAT,componentsPerAttribute:4,normalize:!1,value:[i.x,i.y,s,a]})}const Ud=new J,kd=new l,SE=new l,OE=new l,Vs={high:0,low:0};function jd(e,t,n){const i=Ud;i.height=0,i.longitude=e.west,i.latitude=e.south;const o=t.project(i,kd);i.latitude=e.north;const r=t.project(i,SE);i.longitude=e.east,i.latitude=e.south;const s=t.project(i,OE),a=[0,0,0,0],c=[0,0,0,0];let u=Xe.encode(o.x,Vs);a[0]=u.high,c[0]=u.low,u=Xe.encode(o.y,Vs),a[1]=u.high,c[1]=u.low,u=Xe.encode(r.y,Vs),a[2]=u.high,c[2]=u.low,u=Xe.encode(s.x,Vs),a[3]=u.high,c[3]=u.low,n.planes2D_HIGH=new On({componentDatatype:ue.FLOAT,componentsPerAttribute:4,normalize:!1,value:a}),n.planes2D_LOW=new On({componentDatatype:ue.FLOAT,componentsPerAttribute:4,normalize:!1,value:c})}const AE=new F,vE=new F,Gd=new l,xE=new J,PE=[new J,new J,new J,new J,new J,new J,new J,new J];function RE(e,t,n,i,o,r){const s=he.center(e,xE);s.height=n;const a=J.toCartesian(s,t,Gd),c=Fi.eastNorthUpToFixedFrame(a,t,AE),u=F.inverse(c,vE),f=e.west,p=e.east,_=e.north,g=e.south,y=PE;y[0].latitude=g,y[0].longitude=f,y[1].latitude=_,y[1].longitude=f,y[2].latitude=_,y[2].longitude=p,y[3].latitude=g,y[3].longitude=p;const b=(f+p)*.5,E=(_+g)*.5;y[4].latitude=g,y[4].longitude=b,y[5].latitude=_,y[5].longitude=b,y[6].latitude=E,y[6].longitude=f,y[7].latitude=E,y[7].longitude=p;let O=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY,R=Number.NEGATIVE_INFINITY;for(let k=0;k<8;k++){y[k].height=n;const j=J.toCartesian(y[k],t,Gd);F.multiplyByPoint(u,j,j),j.z=0,O=Math.min(O,j.x),v=Math.max(v,j.x),A=Math.min(A,j.y),R=Math.max(R,j.y)}const z=i;z.x=O,z.y=A,z.z=0,F.multiplyByPoint(c,z,z);const U=o;U.x=v,U.y=A,U.z=0,F.multiplyByPoint(c,U,U),l.subtract(U,z,o);const G=r;G.x=O,G.y=R,G.z=0,F.multiplyByPoint(c,G,G),l.subtract(G,z,r)}const IE=new l,zE=new l,DE=new Xe;It.getPlanarTextureCoordinateAttributes=function(e,t,n,i,o){d.typeOf.object("boundingRectangle",e),d.defined("textureCoordinateRotationPoints",t),d.typeOf.object("ellipsoid",n),d.typeOf.object("projection",i);const r=kd,s=IE,a=zE;RE(e,n,m(o,0),r,s,a);const c={};Bd(c,t);const u=Xe.fromCartesian(r,DE);return c.southWest_HIGH=new On({componentDatatype:ue.FLOAT,componentsPerAttribute:3,normalize:!1,value:l.pack(u.high,[0,0,0])}),c.southWest_LOW=new On({componentDatatype:ue.FLOAT,componentsPerAttribute:3,normalize:!1,value:l.pack(u.low,[0,0,0])}),c.eastward=new On({componentDatatype:ue.FLOAT,componentsPerAttribute:3,normalize:!1,value:l.pack(s,[0,0,0])}),c.northward=new On({componentDatatype:ue.FLOAT,componentsPerAttribute:3,normalize:!1,value:l.pack(a,[0,0,0])}),jd(e,i,c),c};const ME=new l;function Vd(e,t,n,i){const o=Ud;o.latitude=e,o.longitude=t,o.height=0;const r=J.toCartesian(o,n,ME),s=Math.sqrt(r.x*r.x+r.y*r.y),a=P.fastApproximateAtan2(s,r.z),c=P.fastApproximateAtan2(r.x,r.y);return i.x=a,i.y=c,i}const Hd=new L;It.getSphericalExtentGeometryInstanceAttributes=function(e,t,n,i){d.typeOf.object("boundingRectangle",e),d.defined("textureCoordinateRotationPoints",t),d.typeOf.object("ellipsoid",n),d.typeOf.object("projection",i);const o=Vd(e.south,e.west,n,Hd);let r=o.x,s=o.y;const a=Vd(e.north,e.east,n,Hd);let c=a.x,u=a.y,f=0;s>u&&(f=P.PI-s,s=-P.PI,u+=f),r-=P.EPSILON5,s-=P.EPSILON5,c+=P.EPSILON5,u+=P.EPSILON5;const p=1/(u-s),_=1/(c-r),g={sphericalExtents:new On({componentDatatype:ue.FLOAT,componentsPerAttribute:4,normalize:!1,value:[r,s,_,p]}),longitudeRotation:new On({componentDatatype:ue.FLOAT,componentsPerAttribute:1,normalize:!1,value:[f]})};return Bd(g,t),jd(e,i,g),g},It.hasAttributesForTextureCoordinatePlanes=function(e){return h(e.southWest_HIGH)&&h(e.southWest_LOW)&&h(e.northward)&&h(e.eastward)&&h(e.planes2D_HIGH)&&h(e.planes2D_LOW)&&h(e.uMaxVmax)&&h(e.uvMinAndExtents)},It.hasAttributesForSphericalExtents=function(e){return h(e.sphericalExtents)&&h(e.longitudeRotation)&&h(e.planes2D_HIGH)&&h(e.planes2D_LOW)&&h(e.uMaxVmax)&&h(e.uvMinAndExtents)};function NE(e){return Math.max(e.width,e.height)>It.MAX_WIDTH_FOR_PLANAR_EXTENTS}It.shouldUseSphericalCoordinates=function(e){return d.typeOf.object("rectangle",e),NE(e)},It.MAX_WIDTH_FOR_PLANAR_EXTENTS=P.toRadians(1);const LE={NEVER:I.NEVER,LESS:I.LESS,EQUAL:I.EQUAL,LESS_OR_EQUAL:I.LEQUAL,GREATER:I.GREATER,NOT_EQUAL:I.NOTEQUAL,GREATER_OR_EQUAL:I.GEQUAL,ALWAYS:I.ALWAYS},Ln=Object.freeze(LE),FE={ZERO:I.ZERO,KEEP:I.KEEP,REPLACE:I.REPLACE,INCREMENT:I.INCR,DECREMENT:I.DECR,INVERT:I.INVERT,INCREMENT_WRAP:I.INCR_WRAP,DECREMENT_WRAP:I.DECR_WRAP},Fe=Object.freeze(FE),Hs={CESIUM_3D_TILE_MASK:128,SKIP_LOD_MASK:112,SKIP_LOD_BIT_SHIFT:4,CLASSIFICATION_MASK:15};Hs.setCesium3DTileBit=function(){return{enabled:!0,frontFunction:Ln.ALWAYS,frontOperation:{fail:Fe.KEEP,zFail:Fe.KEEP,zPass:Fe.REPLACE},backFunction:Ln.ALWAYS,backOperation:{fail:Fe.KEEP,zFail:Fe.KEEP,zPass:Fe.REPLACE},reference:Hs.CESIUM_3D_TILE_MASK,mask:Hs.CESIUM_3D_TILE_MASK}};const ei=Object.freeze(Hs);function Ti(e){e=m(e,m.EMPTY_OBJECT);const t=e.geometryInstances;this.geometryInstances=t,this.show=m(e.show,!0),this.classificationType=m(e.classificationType,Xn.BOTH),this.debugShowBoundingVolume=m(e.debugShowBoundingVolume,!1),this.debugShowShadowVolume=m(e.debugShowShadowVolume,!1),this._debugShowShadowVolume=!1,this._extruded=m(e._extruded,!1),this._uniformMap=e._uniformMap,this._sp=void 0,this._spStencil=void 0,this._spPick=void 0,this._spColor=void 0,this._spPick2D=void 0,this._spColor2D=void 0,this._rsStencilDepthPass=void 0,this._rsStencilDepthPass3DTiles=void 0,this._rsColorPass=void 0,this._rsPickPass=void 0,this._commandsIgnoreShow=[],this._ready=!1,this._primitive=void 0,this._pickPrimitive=e._pickPrimitive,this._hasSphericalExtentsAttribute=!1,this._hasPlanarExtentsAttributes=!1,this._hasPerColorAttribute=!1,this.appearance=e.appearance,this._createBoundingVolumeFunction=e._createBoundingVolumeFunction,this._updateAndQueueCommandsFunction=e._updateAndQueueCommandsFunction,this._usePickOffsets=!1,this._primitiveOptions={geometryInstances:void 0,appearance:void 0,vertexCacheOptimize:m(e.vertexCacheOptimize,!1),interleave:m(e.interleave,!1),releaseGeometryInstances:m(e.releaseGeometryInstances,!0),allowPicking:m(e.allowPicking,!0),asynchronous:m(e.asynchronous,!0),compressVertices:m(e.compressVertices,!0),_createBoundingVolumeFunction:void 0,_createRenderStatesFunction:void 0,_createShaderProgramFunction:void 0,_createCommandsFunction:void 0,_updateAndQueueCommandsFunction:void 0,_createPickOffsets:!0}}Object.defineProperties(Ti.prototype,{vertexCacheOptimize:{get:function(){return this._primitiveOptions.vertexCacheOptimize}},interleave:{get:function(){return this._primitiveOptions.interleave}},releaseGeometryInstances:{get:function(){return this._primitiveOptions.releaseGeometryInstances}},allowPicking:{get:function(){return this._primitiveOptions.allowPicking}},asynchronous:{get:function(){return this._primitiveOptions.asynchronous}},compressVertices:{get:function(){return this._primitiveOptions.compressVertices}},ready:{get:function(){return this._ready}},_needs2DShader:{get:function(){return this._hasPlanarExtentsAttributes||this._hasSphericalExtentsAttribute}}}),Ti.isSupported=function(e){return e.context.stencilBuffer};function Po(e,t){const n=t?Ln.EQUAL:Ln.ALWAYS;return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:e,frontFunction:n,frontOperation:{fail:Fe.KEEP,zFail:Fe.DECREMENT_WRAP,zPass:Fe.KEEP},backFunction:n,backOperation:{fail:Fe.KEEP,zFail:Fe.INCREMENT_WRAP,zPass:Fe.KEEP},reference:ei.CESIUM_3D_TILE_MASK,mask:ei.CESIUM_3D_TILE_MASK},stencilMask:ei.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:Vf.LESS_OR_EQUAL},depthMask:!1}}function Xc(e){return{stencilTest:{enabled:e,frontFunction:Ln.NOT_EQUAL,frontOperation:{fail:Fe.ZERO,zFail:Fe.ZERO,zPass:Fe.ZERO},backFunction:Ln.NOT_EQUAL,backOperation:{fail:Fe.ZERO,zFail:Fe.ZERO,zPass:Fe.ZERO},reference:0,mask:ei.CLASSIFICATION_MASK},stencilMask:ei.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:tr.PRE_MULTIPLIED_ALPHA_BLEND}}const BE={stencilTest:{enabled:!0,frontFunction:Ln.NOT_EQUAL,frontOperation:{fail:Fe.ZERO,zFail:Fe.ZERO,zPass:Fe.ZERO},backFunction:Ln.NOT_EQUAL,backOperation:{fail:Fe.ZERO,zFail:Fe.ZERO,zPass:Fe.ZERO},reference:0,mask:ei.CLASSIFICATION_MASK},stencilMask:ei.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1};function UE(e,t,n,i){if(h(e._rsStencilDepthPass))return;const o=!e.debugShowShadowVolume;e._rsStencilDepthPass=Ge.fromCache(Po(o,!1)),e._rsStencilDepthPass3DTiles=Ge.fromCache(Po(o,!0)),e._rsColorPass=Ge.fromCache(Xc(o)),e._rsPickPass=Ge.fromCache(BE)}function kE(e,t){if(!e.compressVertices)return t;if(t.search(/in\s+vec3\s+extrudeDirection;/g)!==-1){const n="compressedAttributes",i=`in vec2 ${n};`,o=`vec3 extrudeDirection; `,r=` extrudeDirection = czm_octDecode(${n}, 65535.0); `;let s=t;s=s.replace(/in\s+vec3\s+extrudeDirection;/g,""),s=Ae.replaceMain(s,"czm_non_compressed_main");const a=`void main() { ${r} czm_non_compressed_main(); }`;return[i,o,s,a].join(` `)}}function jE(e,t){const n=t.context,i=e._primitive;let o=Fb;o=e._primitive._batchTable.getVertexShaderCallback()(o),o=Ee._appendDistanceDisplayConditionToShader(i,o),o=Ee._modifyShaderPosition(e,o,t.scene3DOnly),o=Ee._updateColorAttribute(i,o);const r=e._hasPlanarExtentsAttributes,s=r||e._hasSphericalExtentsAttribute;e._extruded&&(o=kE(i,o));const a=e._extruded?"EXTRUDED_GEOMETRY":"";let c=new Ae({defines:[a],sources:[o]});const u=new Ae({sources:[Bb]}),f=e._primitive._attributeLocations,p=new It(s,r,e.appearance);if(e._spStencil=Ut.replaceCache({context:n,shaderProgram:e._spStencil,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f}),e._primitive.allowPicking){let y=Ae.createPickVertexShaderSource(o);y=Ee._appendShowToShader(i,y),y=Ee._updatePickColorAttribute(y);const b=p.createPickFragmentShader(!1),E=p.createPickVertexShader([a],y,!1,t.mapProjection);if(e._spPick=Ut.replaceCache({context:n,shaderProgram:e._spPick,vertexShaderSource:E,fragmentShaderSource:b,attributeLocations:f}),s){let O=n.shaderCache.getDerivedShaderProgram(e._spPick,"2dPick");if(!h(O)){const v=p.createPickFragmentShader(!0),A=p.createPickVertexShader([a],y,!0,t.mapProjection);O=n.shaderCache.createDerivedShaderProgram(e._spPick,"2dPick",{vertexShaderSource:A,fragmentShaderSource:v,attributeLocations:f})}e._spPick2D=O}}else e._spPick=Ut.fromCache({context:n,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f});o=Ee._appendShowToShader(i,o),c=new Ae({defines:[a],sources:[o]}),e._sp=Ut.replaceCache({context:n,shaderProgram:e._sp,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f});const _=p.createFragmentShader(!1),g=p.createVertexShader([a],o,!1,t.mapProjection);if(e._spColor=Ut.replaceCache({context:n,shaderProgram:e._spColor,vertexShaderSource:g,fragmentShaderSource:_,attributeLocations:f}),s){let y=n.shaderCache.getDerivedShaderProgram(e._spColor,"2dColor");if(!h(y)){const b=p.createFragmentShader(!0),E=p.createVertexShader([a],o,!0,t.mapProjection);y=n.shaderCache.createDerivedShaderProgram(e._spColor,"2dColor",{vertexShaderSource:E,fragmentShaderSource:b,attributeLocations:f})}e._spColor2D=y}}function GE(e,t){const n=e._primitive;let i=n._va.length*2;t.length=i;let o,r,s,a=0,c=n._batchTable.getUniformMapCallback()(e._uniformMap);const u=e._needs2DShader;for(o=0;o0&&(c=o[0].attributes,_=It.hasAttributesForSphericalExtents(c),g=It.hasAttributesForTextureCoordinatePlanes(c),p=c.color),s=0;s{h(this._primitive)&&this._primitive.ready&&(this._ready=!0,this.releaseGeometryInstances&&(this.geometryInstances=void 0))})},Ti.prototype.getGeometryInstanceAttributes=function(e){if(!h(this._primitive))throw new T("must call update before calling getGeometryInstanceAttributes");return this._primitive.getGeometryInstanceAttributes(e)},Ti.prototype.isDestroyed=function(){return!1},Ti.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),this._sp=this._sp&&this._sp.destroy(),this._spPick=this._spPick&&this._spPick.destroy(),this._spColor=this._spColor&&this._spColor.destroy(),this._spPick2D=void 0,this._spColor2D=void 0,gt(this)};const WE={u_globeMinimumAltitude:function(){return 55e3}};function Jt(e){e=m(e,m.EMPTY_OBJECT);let t=e.appearance;const n=e.geometryInstances;if(!h(t)&&h(n)){const o=Array.isArray(n)?n:[n],r=o.length;for(let s=0;s{!this._ready&&h(this._primitive)&&this._primitive.ready&&(this._ready=!0,this.releaseGeometryInstances&&(this.geometryInstances=void 0))})},Jt.prototype.getBoundingSphere=function(e){const t=this._boundingSpheresKeys.indexOf(e);if(t!==-1)return this._boundingSpheres[t]},Jt.prototype.getGeometryInstanceAttributes=function(e){if(!h(this._primitive))throw new T("must call update before calling getGeometryInstanceAttributes");return this._primitive.getGeometryInstanceAttributes(e)},Jt.prototype.isDestroyed=function(){return!1},Jt.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),gt(this)},Jt._supportsMaterials=function(e){return e.depthTexture},Jt.supportsMaterials=function(e){return d.typeOf.object("scene",e),Jt._supportsMaterials(e.frameState.context)};const ti=Object.freeze({NONE:0,GEODESIC:1,RHUMB:2}),Kd=P.EPSILON10;function tC(e,t,n,i){if(d.defined("equalsEpsilon",t),!h(e))return;n=m(n,!1);const o=h(i),r=e.length;if(r<2)return e;let s,a=e[0],c,u,f=0,p=-1;for(s=1;sP.EPSILON12);const W=B*(t*t-n*n)/(n*n),w=1+W*(4096+W*(W*(320-175*W)-768))/16384,C=W*(256+W*(W*(74-47*W)-128))/1024,x=H*H,N=C*j*(H+C*(k*(2*x-1)-C*H*(4*j*j-3)*(4*x-3)/6)/4),V=n*w*(G-N),Y=Math.atan2(g*U,E-v*z),Z=Math.atan2(p*U,E*z-v);e._distance=V,e._startHeading=Y,e._endHeading=Z,e._uSquared=W}const rC=new l,Jc=new l;function Qd(e,t,n,i){const o=l.normalize(i.cartographicToCartesian(t,Jc),rC),r=l.normalize(i.cartographicToCartesian(n,Jc),Jc);d.typeOf.number.greaterThanOrEquals("value",Math.abs(Math.abs(l.angleBetween(o,r))-Math.PI),.0125),oC(e,i.maximumRadius,i.minimumRadius,t.longitude,t.latitude,n.longitude,n.latitude),e._start=J.clone(t,e._start),e._end=J.clone(n,e._end),e._start.height=0,e._end.height=0,nC(e)}function qi(e,t,n){const i=m(n,pe.WGS84);this._ellipsoid=i,this._start=new J,this._end=new J,this._constants={},this._startHeading=void 0,this._endHeading=void 0,this._distance=void 0,this._uSquared=void 0,h(e)&&h(t)&&Qd(this,e,t,i)}Object.defineProperties(qi.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},surfaceDistance:{get:function(){return d.defined("distance",this._distance),this._distance}},start:{get:function(){return this._start}},end:{get:function(){return this._end}},startHeading:{get:function(){return d.defined("distance",this._distance),this._startHeading}},endHeading:{get:function(){return d.defined("distance",this._distance),this._endHeading}}}),qi.prototype.setEndPoints=function(e,t){d.defined("start",e),d.defined("end",t),Qd(this,e,t,this._ellipsoid)},qi.prototype.interpolateUsingFraction=function(e,t){return this.interpolateUsingSurfaceDistance(this._distance*e,t)},qi.prototype.interpolateUsingSurfaceDistance=function(e,t){d.defined("distance",this._distance);const n=this._constants,i=n.distanceRatio+e/n.b,o=Math.cos(2*i),r=Math.cos(4*i),s=Math.cos(6*i),a=Math.sin(2*i),c=Math.sin(4*i),u=Math.sin(6*i),f=Math.sin(8*i),p=i*i,_=i*p,g=n.u8Over256,y=n.u2Over4,b=n.u6Over64,E=n.u4Over16;let O=2*_*g*o/3+i*(1-y+7*E/4-15*b/4+579*g/64-(E-15*b/4+187*g/16)*o-(5*b/4-115*g/16)*r-29*g*s/16)+(y/2-E+71*b/32-85*g/16)*a+(5*E/16-5*b/4+383*g/96)*c-p*((b-11*g/2)*a+5*g*c/2)+(29*b/96-29*g/16)*u+539*g*f/1536;const v=Math.asin(Math.sin(O)*n.cosineAlpha),A=Math.atan(n.a/n.b*Math.tan(v));O=O-n.sigma;const R=Math.cos(2*n.sigma+O),z=Math.sin(O),U=Math.cos(O),G=n.cosineU*U,k=n.sineU*z,B=Math.atan2(z*n.sineHeading,G-k*n.cosineHeading)-Zd(n.f,n.sineAlpha,n.cosineSquaredAlpha,O,z,U,R);return h(t)?(t.longitude=this._start.longitude+B,t.latitude=A,t.height=0,t):new J(this._start.longitude+B,A,0)};function el(e,t,n){if(e===0)return t*n;const i=e*e,o=i*i,r=o*i,s=r*i,a=s*i,c=a*i,u=n,f=Math.sin(2*u),p=Math.sin(4*u),_=Math.sin(6*u),g=Math.sin(8*u),y=Math.sin(10*u),b=Math.sin(12*u);return t*((1-i/4-3*o/64-5*r/256-175*s/16384-441*a/65536-4851*c/1048576)*u-(3*i/8+3*o/32+45*r/1024+105*s/4096+2205*a/131072+6237*c/524288)*f+(15*o/256+45*r/1024+525*s/16384+1575*a/65536+155925*c/8388608)*p-(35*r/3072+175*s/12288+3675*a/262144+13475*c/1048576)*_+(315*s/131072+2205*a/524288+43659*c/8388608)*g-(693*a/1310720+6237*c/5242880)*y+1001*c/8388608*b)}function sC(e,t,n){const i=e/n;if(t===0)return i;const o=i*i,r=o*i,s=r*i,a=t,c=a*a,u=c*c,f=u*c,p=f*c,_=p*c,g=_*c,y=Math.sin(2*i),b=Math.cos(2*i),E=Math.sin(4*i),O=Math.cos(4*i),v=Math.sin(6*i),A=Math.cos(6*i),R=Math.sin(8*i),z=Math.cos(8*i),U=Math.sin(10*i),G=Math.cos(10*i),k=Math.sin(12*i);return i+i*c/4+7*i*u/64+15*i*f/256+579*i*p/16384+1515*i*_/65536+16837*i*g/1048576+(3*i*u/16+45*i*f/256-i*(32*o-561)*p/4096-i*(232*o-1677)*_/16384+i*(399985-90560*o+512*s)*g/5242880)*b+(21*i*f/256+483*i*p/4096-i*(224*o-1969)*_/16384-i*(33152*o-112599)*g/1048576)*O+(151*i*p/4096+4681*i*_/65536+1479*i*g/16384-453*r*g/32768)*A+(1097*i*_/65536+42783*i*g/1048576)*z+8011*i*g/1048576*G+(3*c/8+3*u/16+213*f/2048-3*o*f/64+255*p/4096-33*o*p/512+20861*_/524288-33*o*_/512+s*_/1024+28273*g/1048576-471*o*g/8192+9*s*g/4096)*y+(21*u/256+21*f/256+533*p/8192-21*o*p/512+197*_/4096-315*o*_/4096+584039*g/16777216-12517*o*g/131072+7*s*g/2048)*E+(151*f/6144+151*p/4096+5019*_/131072-453*o*_/16384+26965*g/786432-8607*o*g/131072)*v+(1097*p/131072+1097*_/65536+225797*g/10485760-1097*o*g/65536)*R+(8011*_/2621440+8011*g/1048576)*U+293393*g/251658240*k}function Ro(e,t){if(e===0)return Math.log(Math.tan(.5*(P.PI_OVER_TWO+t)));const n=e*Math.sin(t);return Math.log(Math.tan(.5*(P.PI_OVER_TWO+t)))-e/2*Math.log((1+n)/(1-n))}function aC(e,t,n,i,o){const r=Ro(e._ellipticity,n),s=Ro(e._ellipticity,o);return Math.atan2(P.negativePiToPi(i-t),s-r)}function cC(e,t,n,i,o,r,s){const a=e._heading,c=r-i;let u=0;if(P.equalsEpsilon(Math.abs(a),P.PI_OVER_TWO,P.EPSILON8))if(t===n)u=t*Math.cos(o)*P.negativePiToPi(c);else{const f=Math.sin(o);u=t*Math.cos(o)*P.negativePiToPi(c)/Math.sqrt(1-e._ellipticitySquared*f*f)}else{const f=el(e._ellipticity,t,o);u=(el(e._ellipticity,t,s)-f)/Math.cos(a)}return Math.abs(u)}const lC=new l,tl=new l;function Jd(e,t,n,i){const o=l.normalize(i.cartographicToCartesian(t,tl),lC),r=l.normalize(i.cartographicToCartesian(n,tl),tl);d.typeOf.number.greaterThanOrEquals("value",Math.abs(Math.abs(l.angleBetween(o,r))-Math.PI),.0125);const s=i.maximumRadius,a=i.minimumRadius,c=s*s,u=a*a;e._ellipticitySquared=(c-u)/c,e._ellipticity=Math.sqrt(e._ellipticitySquared),e._start=J.clone(t,e._start),e._start.height=0,e._end=J.clone(n,e._end),e._end.height=0,e._heading=aC(e,t.longitude,t.latitude,n.longitude,n.latitude),e._distance=cC(e,i.maximumRadius,i.minimumRadius,t.longitude,t.latitude,n.longitude,n.latitude)}function ep(e,t,n,i,o,r){if(n===0)return J.clone(e,r);const s=o*o;let a,c,u;if(Math.abs(P.PI_OVER_TWO-Math.abs(t))>P.EPSILON8){const f=el(o,i,e.latitude),p=n*Math.cos(t),_=f+p;c=sC(_,o,i);const g=Ro(o,e.latitude),y=Ro(o,c);u=Math.tan(t)*(y-g),a=P.negativePiToPi(e.longitude+u)}else{c=e.latitude;let f;if(o===0)f=i*Math.cos(e.latitude);else{const p=Math.sin(e.latitude);f=i*Math.cos(e.latitude)/Math.sqrt(1-s*p*p)}u=n/f,t>0?a=P.negativePiToPi(e.longitude+u):a=P.negativePiToPi(e.longitude-u)}return h(r)?(r.longitude=a,r.latitude=c,r.height=0,r):new J(a,c,0)}function mn(e,t,n){const i=m(n,pe.WGS84);this._ellipsoid=i,this._start=new J,this._end=new J,this._heading=void 0,this._distance=void 0,this._ellipticity=void 0,this._ellipticitySquared=void 0,h(e)&&h(t)&&Jd(this,e,t,i)}Object.defineProperties(mn.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},surfaceDistance:{get:function(){return d.defined("distance",this._distance),this._distance}},start:{get:function(){return this._start}},end:{get:function(){return this._end}},heading:{get:function(){return d.defined("distance",this._distance),this._heading}}}),mn.fromStartHeadingDistance=function(e,t,n,i,o){d.defined("start",e),d.defined("heading",t),d.defined("distance",n),d.typeOf.number.greaterThan("distance",n,0);const r=m(i,pe.WGS84),s=r.maximumRadius,a=r.minimumRadius,c=s*s,u=a*a,f=Math.sqrt((c-u)/c);t=P.negativePiToPi(t);const p=ep(e,t,n,r.maximumRadius,f);return!h(o)||h(i)&&!i.equals(o.ellipsoid)?new mn(e,p,r):(o.setEndPoints(e,p),o)},mn.prototype.setEndPoints=function(e,t){d.defined("start",e),d.defined("end",t),Jd(this,e,t,this._ellipsoid)},mn.prototype.interpolateUsingFraction=function(e,t){return this.interpolateUsingSurfaceDistance(e*this._distance,t)},mn.prototype.interpolateUsingSurfaceDistance=function(e,t){if(d.typeOf.number("distance",e),!h(this._distance)||this._distance===0)throw new T("EllipsoidRhumbLine must have distinct start and end set.");return ep(this._start,this._heading,e,this._ellipsoid.maximumRadius,this._ellipticity,t)},mn.prototype.findIntersectionWithLongitude=function(e,t){if(d.typeOf.number("intersectionLongitude",e),!h(this._distance)||this._distance===0)throw new T("EllipsoidRhumbLine must have distinct start and end set.");const n=this._ellipticity,i=this._heading,o=Math.abs(i),r=this._start;if(e=P.negativePiToPi(e),P.equalsEpsilon(Math.abs(e),Math.PI,P.EPSILON14)&&(e=P.sign(r.longitude)*Math.PI),h(t)||(t=new J),Math.abs(P.PI_OVER_TWO-o)<=P.EPSILON8)return t.longitude=e,t.latitude=r.latitude,t.height=0,t;if(P.equalsEpsilon(Math.abs(P.PI_OVER_TWO-o),P.PI_OVER_TWO,P.EPSILON8))return P.equalsEpsilon(e,r.longitude,P.EPSILON12)?void 0:(t.longitude=e,t.latitude=P.PI_OVER_TWO*P.sign(P.PI_OVER_TWO-i),t.height=0,t);const s=r.latitude,a=n*Math.sin(s),c=Math.tan(.5*(P.PI_OVER_TWO+s))*Math.exp((e-r.longitude)/Math.tan(i)),u=(1+a)/(1-a);let f=r.latitude,p;do{p=f;const _=n*Math.sin(p),g=(1+_)/(1-_);f=2*Math.atan(c*Math.pow(g/u,n/2))-P.PI_OVER_TWO}while(!P.equalsEpsilon(f,p,P.EPSILON12));return t.longitude=e,t.latitude=f,t.height=0,t},mn.prototype.findIntersectionWithLatitude=function(e,t){if(d.typeOf.number("intersectionLatitude",e),!h(this._distance)||this._distance===0)throw new T("EllipsoidRhumbLine must have distinct start and end set.");const n=this._ellipticity,i=this._heading,o=this._start;if(P.equalsEpsilon(Math.abs(i),P.PI_OVER_TWO,P.EPSILON8))return;const r=Ro(n,o.latitude),s=Ro(n,e),a=Math.tan(i)*(s-r),c=P.negativePiToPi(o.longitude+a);return h(t)?(t.longitude=c,t.latitude=e,t.height=0,t):new J(c,e,0)};const nl=[gn,Ht],hC=nl.length,tp=Math.cos(P.toRadians(30)),np=Math.cos(P.toRadians(150)),ip=0,op=1e3;function Ei(e){e=m(e,m.EMPTY_OBJECT);const t=e.positions;if(!h(t)||t.length<2)throw new T("At least two positions are required.");if(h(e.arcType)&&e.arcType!==ti.GEODESIC&&e.arcType!==ti.RHUMB)throw new T("Valid options for arcType are ArcType.GEODESIC and ArcType.RHUMB.");this.width=m(e.width,1),this._positions=t,this.granularity=m(e.granularity,9999),this.loop=m(e.loop,!1),this.arcType=m(e.arcType,ti.GEODESIC),this._ellipsoid=pe.WGS84,this._projectionIndex=0,this._workerName="createGroundPolylineGeometry",this._scene3DOnly=!1}Object.defineProperties(Ei.prototype,{packedLength:{get:function(){return 1+this._positions.length*3+1+1+1+pe.packedLength+1+1}}}),Ei.setProjectionAndEllipsoid=function(e,t){let n=0;for(let i=0;itp||rP.PI_OVER_TWO&&(a=!0,s=l.subtract(r,n,dp),u=c.cartesianToCartographic(s,fp)),u.height=0;const f=e.project(u,o);return o=l.subtract(f,i,o),o.z=0,o=l.normalize(o,o),a&&l.negate(o,o),o}const RC=new l,pp=new l;function mp(e,t,n,i,o,r){const s=l.subtract(t,e,RC);l.normalize(s,s);const a=n-ip;let c=l.multiplyByScalar(s,a,pp);l.add(e,c,o);const u=i-op;c=l.multiplyByScalar(s,u,pp),l.add(t,c,r)}const IC=new l;function Xs(e,t){const n=Se.getPointDistance(Ws,e),i=Se.getPointDistance(Ws,t);let o=IC;P.equalsEpsilon(n,0,P.EPSILON2)?(o=ni(t,e,o),l.multiplyByScalar(o,P.EPSILON2,o),l.add(e,o,e)):P.equalsEpsilon(i,0,P.EPSILON2)&&(o=ni(e,t,o),l.multiplyByScalar(o,P.EPSILON2,o),l.add(t,o,t))}function zC(e,t){const n=Math.abs(e.longitude),i=Math.abs(t.longitude);if(P.equalsEpsilon(n,P.PI,P.EPSILON11)){const o=P.sign(t.longitude);return e.longitude=o*(n-P.EPSILON11),1}else if(P.equalsEpsilon(i,P.PI,P.EPSILON11)){const o=P.sign(e.longitude);return t.longitude=o*(i-P.EPSILON11),2}return 0}const _p=new J,gp=new J,yp=new l,al=new l,wp=new l,bp=new l,DC=new l,Tp=new l,MC=[_p,gp],NC=new he,LC=new l,FC=new l,BC=new l,UC=new l,kC=new l,jC=new l,cl=new l,ll=new l,GC=new l,VC=new l,HC=new l,Ep=new l,qC=new l,WC=new l,YC=new Xe,$C=new Xe,Cp=new l,XC=new l,Sp=new l,KC=[new Q,new Q],Op=[0,2,1,0,3,2,0,7,3,0,4,7,0,5,4,0,1,5,5,7,4,5,6,7,5,2,6,5,1,2,3,6,2,3,7,6],Ap=Op.length;function ZC(e,t,n,i,o,r,s){let a,c;const u=t._ellipsoid,f=n.length/3-1,p=f*8,_=p*4,g=f*36,y=p>65535?new Uint32Array(g):new Uint16Array(g),b=new Float64Array(p*3),E=new Float32Array(_),O=new Float32Array(_),v=new Float32Array(_),A=new Float32Array(_),R=new Float32Array(_);let z,U,G,k;s&&(z=new Float32Array(_),U=new Float32Array(_),G=new Float32Array(_),k=new Float32Array(p*2));const j=r.length/2;let B=0;const H=_p;H.height=0;const W=gp;W.height=0;let w=yp,C=al;if(s)for(c=0,a=1;atp?(Ri=dr(t,H,tn,An,cl),Ii=dr(t,W,be,Bo,ll)):ct===1?(Ii=dr(t,W,be,Bo,ll),Ri.x=0,Ri.y=P.sign(H.longitude-Math.abs(W.longitude)),Ri.z=0):(Ri=dr(t,H,tn,An,cl),Ii.x=0,Ii.y=P.sign(H.longitude-W.longitude),Ii.z=0)}const Zm=l.distance(en,Te),Qm=Xe.fromCartesian(ut,YC),ca=l.subtract(we,ut,GC),bx=l.normalize(ca,Ep);let jr=l.subtract(en,ut,VC);jr=l.normalize(jr,jr);let Uo=l.cross(bx,jr,Ep);Uo=l.normalize(Uo,Uo);let la=l.cross(jr,tn,qC);la=l.normalize(la,la);let ha=l.subtract(Te,we,HC);ha=l.normalize(ha,ha);let ua=l.cross(be,ha,WC);ua=l.normalize(ua,ua);const Tx=Zm/N,Ex=Pe/N;let Wl=0,Gr,fa,Ji,Jm=0,e_=0;if(s){Wl=l.distance(An,Bo),Gr=Xe.fromCartesian(An,$C),fa=l.subtract(Bo,An,Cp),Ji=l.normalize(fa,XC);const ct=Ji.x;Ji.x=Ji.y,Ji.y=-ct,Jm=Wl/B,e_=Be/B}for(V=0;V<8;V++){const ct=re+V*4,ko=Z+V*2,Vr=ct+3,n_=V<4?1:-1,da=V===2||V===3||V===6||V===7?1:-1;l.pack(Qm.high,E,ct),E[Vr]=ca.x,l.pack(Qm.low,O,ct),O[Vr]=ca.y,l.pack(la,v,ct),v[Vr]=ca.z,l.pack(ua,A,ct),A[Vr]=Tx*n_,l.pack(Uo,R,ct);let eo=Ex*da;eo===0&&da<0&&(eo=9),R[Vr]=eo,s&&(z[ct]=Gr.high.x,z[ct+1]=Gr.high.y,z[ct+2]=Gr.low.x,z[ct+3]=Gr.low.y,G[ct]=-Ri.y,G[ct+1]=Ri.x,G[ct+2]=Ii.y,G[ct+3]=-Ii.x,U[ct]=fa.x,U[ct+1]=fa.y,U[ct+2]=Ji.x,U[ct+3]=Ji.y,k[ko]=Jm*n_,eo=e_*da,eo===0&&da<0&&(eo=9),k[ko+1]=eo)}const ri=BC,si=UC,ai=LC,ci=FC,Cx=he.fromCartographicArray(MC,NC),t_=In.getMinimumMaximumHeights(Cx,u),Yl=t_.minimumTerrainHeight,$l=t_.maximumTerrainHeight;Ze+=Yl,Ze+=$l,mp(ut,en,Yl,$l,ri,ai),mp(we,Te,Yl,$l,si,ci);let li=l.multiplyByScalar(Uo,P.EPSILON5,Sp);l.add(ri,li,ri),l.add(si,li,si),l.add(ai,li,ai),l.add(ci,li,ci),Xs(ri,si),Xs(ai,ci),l.pack(ri,b,$),l.pack(si,b,$+3),l.pack(ci,b,$+6),l.pack(ai,b,$+9),li=l.multiplyByScalar(Uo,-2*P.EPSILON5,Sp),l.add(ri,li,ri),l.add(si,li,si),l.add(ai,li,ai),l.add(ci,li,ci),Xs(ri,si),Xs(ai,ci),l.pack(ri,b,$+12),l.pack(si,b,$+15),l.pack(ci,b,$+18),l.pack(ai,b,$+21),Y+=2,c+=3,Z+=16,$+=24,re+=32,Pe+=Zm,Be+=Wl}c=0;let at=0;for(a=0;a halfMaxWidth || distanceFromStart < 0.0 || distanceFromEnd < 0.0) { #ifdef DEBUG_SHOW_VOLUME out_FragColor = vec4(1.0, 0.0, 0.0, 0.5); return; #else // DEBUG_SHOW_VOLUME discard; #endif // DEBUG_SHOW_VOLUME } // Check distance of the eye coordinate against start and end planes with normals in the right plane. // For computing unskewed lengthwise texture coordinate. // Can also be used for clipping extremely pointy miters, but in practice unnecessary because of miter breaking. // aligned plane: cross the right plane normal with miter plane normal, then cross the result with right again to point it more "forward" vec3 alignedPlaneNormal; // start aligned plane alignedPlaneNormal = cross(v_rightPlaneEC.xyz, v_startPlaneNormalEcAndHalfWidth.xyz); alignedPlaneNormal = normalize(cross(alignedPlaneNormal, v_rightPlaneEC.xyz)); distanceFromStart = czm_planeDistance(alignedPlaneNormal, -dot(alignedPlaneNormal, ecStart), eyeCoordinate.xyz); // end aligned plane alignedPlaneNormal = cross(v_rightPlaneEC.xyz, v_endPlaneNormalEcAndBatchId.xyz); alignedPlaneNormal = normalize(cross(alignedPlaneNormal, v_rightPlaneEC.xyz)); distanceFromEnd = czm_planeDistance(alignedPlaneNormal, -dot(alignedPlaneNormal, v_endEcAndStartEcX.xyz), eyeCoordinate.xyz); #ifdef PER_INSTANCE_COLOR out_FragColor = czm_gammaCorrect(v_color); #else // PER_INSTANCE_COLOR // Clamp - distance to aligned planes may be negative due to mitering, // so fragment texture coordinate might be out-of-bounds. float s = clamp(distanceFromStart / (distanceFromStart + distanceFromEnd), 0.0, 1.0); s = (s * v_texcoordNormalizationAndStartEcYZ.x) + v_texcoordNormalizationAndStartEcYZ.y; float t = (widthwiseDistance + halfMaxWidth) / (2.0 * halfMaxWidth); czm_materialInput materialInput; materialInput.s = s; materialInput.st = vec2(s, t); materialInput.str = vec3(s, t, 0.0); czm_material material = czm_getMaterial(materialInput); out_FragColor = vec4(material.diffuse + material.emission, material.alpha); #endif // PER_INSTANCE_COLOR // Premultiply alpha. Required for classification primitives on translucent globe. out_FragColor.rgb *= out_FragColor.a; czm_writeDepthClamp(); } `,JC=`in vec3 v_forwardDirectionEC; in vec3 v_texcoordNormalizationAndHalfWidth; in float v_batchId; #ifdef PER_INSTANCE_COLOR in vec4 v_color; #else in vec2 v_alignedPlaneDistances; in float v_texcoordT; #endif float rayPlaneDistanceUnsafe(vec3 origin, vec3 direction, vec3 planeNormal, float planeDistance) { // We don't expect the ray to ever be parallel to the plane return (-planeDistance - dot(planeNormal, origin)) / dot(planeNormal, direction); } void main(void) { vec4 eyeCoordinate = gl_FragCoord; eyeCoordinate /= eyeCoordinate.w; #ifdef PER_INSTANCE_COLOR out_FragColor = czm_gammaCorrect(v_color); #else // PER_INSTANCE_COLOR // Use distances for planes aligned with segment to prevent skew in dashing float distanceFromStart = rayPlaneDistanceUnsafe(eyeCoordinate.xyz, -v_forwardDirectionEC, v_forwardDirectionEC.xyz, v_alignedPlaneDistances.x); float distanceFromEnd = rayPlaneDistanceUnsafe(eyeCoordinate.xyz, v_forwardDirectionEC, -v_forwardDirectionEC.xyz, v_alignedPlaneDistances.y); // Clamp - distance to aligned planes may be negative due to mitering distanceFromStart = max(0.0, distanceFromStart); distanceFromEnd = max(0.0, distanceFromEnd); float s = distanceFromStart / (distanceFromStart + distanceFromEnd); s = (s * v_texcoordNormalizationAndHalfWidth.x) + v_texcoordNormalizationAndHalfWidth.y; czm_materialInput materialInput; materialInput.s = s; materialInput.st = vec2(s, v_texcoordT); materialInput.str = vec3(s, v_texcoordT, 0.0); czm_material material = czm_getMaterial(materialInput); out_FragColor = vec4(material.diffuse + material.emission, material.alpha); #endif // PER_INSTANCE_COLOR } `,eS=`in vec3 position3DHigh; in vec3 position3DLow; in vec4 startHiAndForwardOffsetX; in vec4 startLoAndForwardOffsetY; in vec4 startNormalAndForwardOffsetZ; in vec4 endNormalAndTextureCoordinateNormalizationX; in vec4 rightNormalAndTextureCoordinateNormalizationY; in vec4 startHiLo2D; in vec4 offsetAndRight2D; in vec4 startEndNormals2D; in vec2 texcoordNormalization2D; in float batchId; out vec3 v_forwardDirectionEC; out vec3 v_texcoordNormalizationAndHalfWidth; out float v_batchId; // For materials #ifdef WIDTH_VARYING out float v_width; #endif #ifdef ANGLE_VARYING out float v_polylineAngle; #endif #ifdef PER_INSTANCE_COLOR out vec4 v_color; #else out vec2 v_alignedPlaneDistances; out float v_texcoordT; #endif // Morphing planes using SLERP or NLERP doesn't seem to work, so instead draw the material directly on the shadow volume. // Morph views are from very far away and aren't meant to be used precisely, so this should be sufficient. void main() { v_batchId = batchId; // Start position vec4 posRelativeToEye2D = czm_translateRelativeToEye(vec3(0.0, startHiLo2D.xy), vec3(0.0, startHiLo2D.zw)); vec4 posRelativeToEye3D = czm_translateRelativeToEye(startHiAndForwardOffsetX.xyz, startLoAndForwardOffsetY.xyz); vec4 posRelativeToEye = czm_columbusViewMorph(posRelativeToEye2D, posRelativeToEye3D, czm_morphTime); vec3 posEc2D = (czm_modelViewRelativeToEye * posRelativeToEye2D).xyz; vec3 posEc3D = (czm_modelViewRelativeToEye * posRelativeToEye3D).xyz; vec3 startEC = (czm_modelViewRelativeToEye * posRelativeToEye).xyz; // Start plane vec4 startPlane2D; vec4 startPlane3D; startPlane2D.xyz = czm_normal * vec3(0.0, startEndNormals2D.xy); startPlane3D.xyz = czm_normal * startNormalAndForwardOffsetZ.xyz; startPlane2D.w = -dot(startPlane2D.xyz, posEc2D); startPlane3D.w = -dot(startPlane3D.xyz, posEc3D); // Right plane vec4 rightPlane2D; vec4 rightPlane3D; rightPlane2D.xyz = czm_normal * vec3(0.0, offsetAndRight2D.zw); rightPlane3D.xyz = czm_normal * rightNormalAndTextureCoordinateNormalizationY.xyz; rightPlane2D.w = -dot(rightPlane2D.xyz, posEc2D); rightPlane3D.w = -dot(rightPlane3D.xyz, posEc3D); // End position posRelativeToEye2D = posRelativeToEye2D + vec4(0.0, offsetAndRight2D.xy, 0.0); posRelativeToEye3D = posRelativeToEye3D + vec4(startHiAndForwardOffsetX.w, startLoAndForwardOffsetY.w, startNormalAndForwardOffsetZ.w, 0.0); posRelativeToEye = czm_columbusViewMorph(posRelativeToEye2D, posRelativeToEye3D, czm_morphTime); posEc2D = (czm_modelViewRelativeToEye * posRelativeToEye2D).xyz; posEc3D = (czm_modelViewRelativeToEye * posRelativeToEye3D).xyz; vec3 endEC = (czm_modelViewRelativeToEye * posRelativeToEye).xyz; vec3 forwardEc3D = czm_normal * normalize(vec3(startHiAndForwardOffsetX.w, startLoAndForwardOffsetY.w, startNormalAndForwardOffsetZ.w)); vec3 forwardEc2D = czm_normal * normalize(vec3(0.0, offsetAndRight2D.xy)); // End plane vec4 endPlane2D; vec4 endPlane3D; endPlane2D.xyz = czm_normal * vec3(0.0, startEndNormals2D.zw); endPlane3D.xyz = czm_normal * endNormalAndTextureCoordinateNormalizationX.xyz; endPlane2D.w = -dot(endPlane2D.xyz, posEc2D); endPlane3D.w = -dot(endPlane3D.xyz, posEc3D); // Forward direction v_forwardDirectionEC = normalize(endEC - startEC); vec2 cleanTexcoordNormalization2D; cleanTexcoordNormalization2D.x = abs(texcoordNormalization2D.x); cleanTexcoordNormalization2D.y = czm_branchFreeTernary(texcoordNormalization2D.y > 1.0, 0.0, abs(texcoordNormalization2D.y)); vec2 cleanTexcoordNormalization3D; cleanTexcoordNormalization3D.x = abs(endNormalAndTextureCoordinateNormalizationX.w); cleanTexcoordNormalization3D.y = rightNormalAndTextureCoordinateNormalizationY.w; cleanTexcoordNormalization3D.y = czm_branchFreeTernary(cleanTexcoordNormalization3D.y > 1.0, 0.0, abs(cleanTexcoordNormalization3D.y)); v_texcoordNormalizationAndHalfWidth.xy = mix(cleanTexcoordNormalization2D, cleanTexcoordNormalization3D, czm_morphTime); #ifdef PER_INSTANCE_COLOR v_color = czm_batchTable_color(batchId); #else // PER_INSTANCE_COLOR // For computing texture coordinates v_alignedPlaneDistances.x = -dot(v_forwardDirectionEC, startEC); v_alignedPlaneDistances.y = -dot(-v_forwardDirectionEC, endEC); #endif // PER_INSTANCE_COLOR #ifdef WIDTH_VARYING float width = czm_batchTable_width(batchId); float halfWidth = width * 0.5; v_width = width; v_texcoordNormalizationAndHalfWidth.z = halfWidth; #else float halfWidth = 0.5 * czm_batchTable_width(batchId); v_texcoordNormalizationAndHalfWidth.z = halfWidth; #endif // Compute a normal along which to "push" the position out, extending the miter depending on view distance. // Position has already been "pushed" by unit length along miter normal, and miter normals are encoded in the planes. // Decode the normal to use at this specific vertex, push the position back, and then push to where it needs to be. // Since this is morphing, compute both 3D and 2D positions and then blend. // ****** 3D ****** // Check distance to the end plane and start plane, pick the plane that is closer vec4 positionEc3D = czm_modelViewRelativeToEye * czm_translateRelativeToEye(position3DHigh, position3DLow); // w = 1.0, see czm_computePosition float absStartPlaneDistance = abs(czm_planeDistance(startPlane3D, positionEc3D.xyz)); float absEndPlaneDistance = abs(czm_planeDistance(endPlane3D, positionEc3D.xyz)); vec3 planeDirection = czm_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, startPlane3D.xyz, endPlane3D.xyz); vec3 upOrDown = normalize(cross(rightPlane3D.xyz, planeDirection)); // Points "up" for start plane, "down" at end plane. vec3 normalEC = normalize(cross(planeDirection, upOrDown)); // In practice, the opposite seems to work too. // Nudge the top vertex upwards to prevent flickering vec3 geodeticSurfaceNormal = normalize(cross(normalEC, forwardEc3D)); geodeticSurfaceNormal *= float(0.0 <= rightNormalAndTextureCoordinateNormalizationY.w && rightNormalAndTextureCoordinateNormalizationY.w <= 1.0); geodeticSurfaceNormal *= MAX_TERRAIN_HEIGHT; positionEc3D.xyz += geodeticSurfaceNormal; // Determine if this vertex is on the "left" or "right" normalEC *= sign(endNormalAndTextureCoordinateNormalizationX.w); // A "perfect" implementation would push along normals according to the angle against forward. // In practice, just pushing the normal out by halfWidth is sufficient for morph views. positionEc3D.xyz += halfWidth * max(0.0, czm_metersPerPixel(positionEc3D)) * normalEC; // prevent artifacts when czm_metersPerPixel is negative (behind camera) // ****** 2D ****** // Check distance to the end plane and start plane, pick the plane that is closer vec4 positionEc2D = czm_modelViewRelativeToEye * czm_translateRelativeToEye(position2DHigh.zxy, position2DLow.zxy); // w = 1.0, see czm_computePosition absStartPlaneDistance = abs(czm_planeDistance(startPlane2D, positionEc2D.xyz)); absEndPlaneDistance = abs(czm_planeDistance(endPlane2D, positionEc2D.xyz)); planeDirection = czm_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, startPlane2D.xyz, endPlane2D.xyz); upOrDown = normalize(cross(rightPlane2D.xyz, planeDirection)); // Points "up" for start plane, "down" at end plane. normalEC = normalize(cross(planeDirection, upOrDown)); // In practice, the opposite seems to work too. // Nudge the top vertex upwards to prevent flickering geodeticSurfaceNormal = normalize(cross(normalEC, forwardEc2D)); geodeticSurfaceNormal *= float(0.0 <= texcoordNormalization2D.y && texcoordNormalization2D.y <= 1.0); geodeticSurfaceNormal *= MAX_TERRAIN_HEIGHT; positionEc2D.xyz += geodeticSurfaceNormal; // Determine if this vertex is on the "left" or "right" normalEC *= sign(texcoordNormalization2D.x); #ifndef PER_INSTANCE_COLOR // Use vertex's sidedness to compute its texture coordinate. v_texcoordT = clamp(sign(texcoordNormalization2D.x), 0.0, 1.0); #endif // A "perfect" implementation would push along normals according to the angle against forward. // In practice, just pushing the normal out by halfWidth is sufficient for morph views. positionEc2D.xyz += halfWidth * max(0.0, czm_metersPerPixel(positionEc2D)) * normalEC; // prevent artifacts when czm_metersPerPixel is negative (behind camera) // Blend for actual position gl_Position = czm_projection * mix(positionEc2D, positionEc3D, czm_morphTime); #ifdef ANGLE_VARYING // Approximate relative screen space direction of the line. vec2 approxLineDirection = normalize(vec2(v_forwardDirectionEC.x, -v_forwardDirectionEC.y)); approxLineDirection.y = czm_branchFreeTernary(approxLineDirection.x == 0.0 && approxLineDirection.y == 0.0, -1.0, approxLineDirection.y); v_polylineAngle = czm_fastApproximateAtan(approxLineDirection.x, approxLineDirection.y); #endif } `,tS=`in vec3 position3DHigh; in vec3 position3DLow; // In 2D and in 3D, texture coordinate normalization component signs encodes: // * X sign - sidedness relative to right plane // * Y sign - is negative OR magnitude is greater than 1.0 if vertex is on bottom of volume #ifndef COLUMBUS_VIEW_2D in vec4 startHiAndForwardOffsetX; in vec4 startLoAndForwardOffsetY; in vec4 startNormalAndForwardOffsetZ; in vec4 endNormalAndTextureCoordinateNormalizationX; in vec4 rightNormalAndTextureCoordinateNormalizationY; #else in vec4 startHiLo2D; in vec4 offsetAndRight2D; in vec4 startEndNormals2D; in vec2 texcoordNormalization2D; #endif in float batchId; out vec4 v_startPlaneNormalEcAndHalfWidth; out vec4 v_endPlaneNormalEcAndBatchId; out vec4 v_rightPlaneEC; out vec4 v_endEcAndStartEcX; out vec4 v_texcoordNormalizationAndStartEcYZ; // For materials #ifdef WIDTH_VARYING out float v_width; #endif #ifdef ANGLE_VARYING out float v_polylineAngle; #endif #ifdef PER_INSTANCE_COLOR out vec4 v_color; #endif void main() { #ifdef COLUMBUS_VIEW_2D vec3 ecStart = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, startHiLo2D.xy), vec3(0.0, startHiLo2D.zw))).xyz; vec3 forwardDirectionEC = czm_normal * vec3(0.0, offsetAndRight2D.xy); vec3 ecEnd = forwardDirectionEC + ecStart; forwardDirectionEC = normalize(forwardDirectionEC); // Right plane v_rightPlaneEC.xyz = czm_normal * vec3(0.0, offsetAndRight2D.zw); v_rightPlaneEC.w = -dot(v_rightPlaneEC.xyz, ecStart); // start plane vec4 startPlaneEC; startPlaneEC.xyz = czm_normal * vec3(0.0, startEndNormals2D.xy); startPlaneEC.w = -dot(startPlaneEC.xyz, ecStart); // end plane vec4 endPlaneEC; endPlaneEC.xyz = czm_normal * vec3(0.0, startEndNormals2D.zw); endPlaneEC.w = -dot(endPlaneEC.xyz, ecEnd); v_texcoordNormalizationAndStartEcYZ.x = abs(texcoordNormalization2D.x); v_texcoordNormalizationAndStartEcYZ.y = texcoordNormalization2D.y; #else // COLUMBUS_VIEW_2D vec3 ecStart = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(startHiAndForwardOffsetX.xyz, startLoAndForwardOffsetY.xyz)).xyz; vec3 offset = czm_normal * vec3(startHiAndForwardOffsetX.w, startLoAndForwardOffsetY.w, startNormalAndForwardOffsetZ.w); vec3 ecEnd = ecStart + offset; vec3 forwardDirectionEC = normalize(offset); // start plane vec4 startPlaneEC; startPlaneEC.xyz = czm_normal * startNormalAndForwardOffsetZ.xyz; startPlaneEC.w = -dot(startPlaneEC.xyz, ecStart); // end plane vec4 endPlaneEC; endPlaneEC.xyz = czm_normal * endNormalAndTextureCoordinateNormalizationX.xyz; endPlaneEC.w = -dot(endPlaneEC.xyz, ecEnd); // Right plane v_rightPlaneEC.xyz = czm_normal * rightNormalAndTextureCoordinateNormalizationY.xyz; v_rightPlaneEC.w = -dot(v_rightPlaneEC.xyz, ecStart); v_texcoordNormalizationAndStartEcYZ.x = abs(endNormalAndTextureCoordinateNormalizationX.w); v_texcoordNormalizationAndStartEcYZ.y = rightNormalAndTextureCoordinateNormalizationY.w; #endif // COLUMBUS_VIEW_2D v_endEcAndStartEcX.xyz = ecEnd; v_endEcAndStartEcX.w = ecStart.x; v_texcoordNormalizationAndStartEcYZ.zw = ecStart.yz; #ifdef PER_INSTANCE_COLOR v_color = czm_batchTable_color(batchId); #endif // PER_INSTANCE_COLOR // Compute a normal along which to "push" the position out, extending the miter depending on view distance. // Position has already been "pushed" by unit length along miter normal, and miter normals are encoded in the planes. // Decode the normal to use at this specific vertex, push the position back, and then push to where it needs to be. vec4 positionRelativeToEye = czm_computePosition(); // Check distance to the end plane and start plane, pick the plane that is closer vec4 positionEC = czm_modelViewRelativeToEye * positionRelativeToEye; // w = 1.0, see czm_computePosition float absStartPlaneDistance = abs(czm_planeDistance(startPlaneEC, positionEC.xyz)); float absEndPlaneDistance = abs(czm_planeDistance(endPlaneEC, positionEC.xyz)); vec3 planeDirection = czm_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, startPlaneEC.xyz, endPlaneEC.xyz); vec3 upOrDown = normalize(cross(v_rightPlaneEC.xyz, planeDirection)); // Points "up" for start plane, "down" at end plane. vec3 normalEC = normalize(cross(planeDirection, upOrDown)); // In practice, the opposite seems to work too. // Extrude bottom vertices downward for far view distances, like for GroundPrimitives upOrDown = cross(forwardDirectionEC, normalEC); upOrDown = float(czm_sceneMode == czm_sceneMode3D) * upOrDown; upOrDown = float(v_texcoordNormalizationAndStartEcYZ.y > 1.0 || v_texcoordNormalizationAndStartEcYZ.y < 0.0) * upOrDown; upOrDown = min(GLOBE_MINIMUM_ALTITUDE, czm_geometricToleranceOverMeter * length(positionRelativeToEye.xyz)) * upOrDown; positionEC.xyz += upOrDown; v_texcoordNormalizationAndStartEcYZ.y = czm_branchFreeTernary(v_texcoordNormalizationAndStartEcYZ.y > 1.0, 0.0, abs(v_texcoordNormalizationAndStartEcYZ.y)); // Determine distance along normalEC to push for a volume of appropriate width. // Make volumes about double pixel width for a conservative fit - in practice the // extra cost here is minimal compared to the loose volume heights. // // N = normalEC (guaranteed "right-facing") // R = rightEC // p = angle between N and R // w = distance to push along R if R == N // d = distance to push along N // // N R // { p| } * cos(p) = dot(N, R) = w / d // d | |w * d = w / dot(N, R) // { | } // o---------- polyline segment ----> // float width = czm_batchTable_width(batchId); #ifdef WIDTH_VARYING v_width = width; #endif v_startPlaneNormalEcAndHalfWidth.xyz = startPlaneEC.xyz; v_startPlaneNormalEcAndHalfWidth.w = width * 0.5; v_endPlaneNormalEcAndBatchId.xyz = endPlaneEC.xyz; v_endPlaneNormalEcAndBatchId.w = batchId; width = width * max(0.0, czm_metersPerPixel(positionEC)); // width = distance to push along R width = width / dot(normalEC, v_rightPlaneEC.xyz); // width = distance to push along N // Determine if this vertex is on the "left" or "right" #ifdef COLUMBUS_VIEW_2D normalEC *= sign(texcoordNormalization2D.x); #else normalEC *= sign(endNormalAndTextureCoordinateNormalizationX.w); #endif positionEC.xyz += width * normalEC; gl_Position = czm_depthClamp(czm_projection * positionEC); #ifdef ANGLE_VARYING // Approximate relative screen space direction of the line. vec2 approxLineDirection = normalize(vec2(forwardDirectionEC.x, -forwardDirectionEC.y)); approxLineDirection.y = czm_branchFreeTernary(approxLineDirection.x == 0.0 && approxLineDirection.y == 0.0, -1.0, approxLineDirection.y); v_polylineAngle = czm_fastApproximateAtan(approxLineDirection.x, approxLineDirection.y); #endif } `,nS=`in vec3 position3DHigh; in vec3 position3DLow; in vec3 prevPosition3DHigh; in vec3 prevPosition3DLow; in vec3 nextPosition3DHigh; in vec3 nextPosition3DLow; in vec2 expandAndWidth; in vec4 color; in float batchId; out vec4 v_color; void main() { float expandDir = expandAndWidth.x; float width = abs(expandAndWidth.y) + 0.5; bool usePrev = expandAndWidth.y < 0.0; vec4 p = czm_computePosition(); vec4 prev = czm_computePrevPosition(); vec4 next = czm_computeNextPosition(); float angle; vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, angle); gl_Position = czm_viewportOrthographic * positionWC; v_color = color; } `,vp=`void clipLineSegmentToNearPlane( vec3 p0, vec3 p1, out vec4 positionWC, out bool clipped, out bool culledByNearPlane, out vec4 clippedPositionEC) { culledByNearPlane = false; clipped = false; vec3 p0ToP1 = p1 - p0; float magnitude = length(p0ToP1); vec3 direction = normalize(p0ToP1); // Distance that p0 is behind the near plane. Negative means p0 is // in front of the near plane. float endPoint0Distance = czm_currentFrustum.x + p0.z; // Camera looks down -Z. // When moving a point along +Z: LESS VISIBLE // * Points in front of the camera move closer to the camera. // * Points behind the camrea move farther away from the camera. // When moving a point along -Z: MORE VISIBLE // * Points in front of the camera move farther away from the camera. // * Points behind the camera move closer to the camera. // Positive denominator: -Z, becoming more visible // Negative denominator: +Z, becoming less visible // Nearly zero: parallel to near plane float denominator = -direction.z; if (endPoint0Distance > 0.0 && abs(denominator) < czm_epsilon7) { // p0 is behind the near plane and the line to p1 is nearly parallel to // the near plane, so cull the segment completely. culledByNearPlane = true; } else if (endPoint0Distance > 0.0) { // p0 is behind the near plane, and the line to p1 is moving distinctly // toward or away from it. // t = (-plane distance - dot(plane normal, ray origin)) / dot(plane normal, ray direction) float t = endPoint0Distance / denominator; if (t < 0.0 || t > magnitude) { // Near plane intersection is not between the two points. // We already confirmed p0 is behind the naer plane, so now // we know the entire segment is behind it. culledByNearPlane = true; } else { // Segment crosses the near plane, update p0 to lie exactly on it. p0 = p0 + t * direction; // Numerical noise might put us a bit on the wrong side of the near plane. // Don't let that happen. p0.z = min(p0.z, -czm_currentFrustum.x); clipped = true; } } clippedPositionEC = vec4(p0, 1.0); positionWC = czm_eyeToWindowCoordinates(clippedPositionEC); } vec4 getPolylineWindowCoordinatesEC(vec4 positionEC, vec4 prevEC, vec4 nextEC, float expandDirection, float width, bool usePrevious, out float angle) { // expandDirection +1 is to the _left_ when looking from positionEC toward nextEC. #ifdef POLYLINE_DASH // Compute the window coordinates of the points. vec4 positionWindow = czm_eyeToWindowCoordinates(positionEC); vec4 previousWindow = czm_eyeToWindowCoordinates(prevEC); vec4 nextWindow = czm_eyeToWindowCoordinates(nextEC); // Determine the relative screen space direction of the line. vec2 lineDir; if (usePrevious) { lineDir = normalize(positionWindow.xy - previousWindow.xy); } else { lineDir = normalize(nextWindow.xy - positionWindow.xy); } angle = atan(lineDir.x, lineDir.y) - 1.570796327; // precomputed atan(1,0) // Quantize the angle so it doesn't change rapidly between segments. angle = floor(angle / czm_piOverFour + 0.5) * czm_piOverFour; #endif vec4 clippedPrevWC, clippedPrevEC; bool prevSegmentClipped, prevSegmentCulled; clipLineSegmentToNearPlane(prevEC.xyz, positionEC.xyz, clippedPrevWC, prevSegmentClipped, prevSegmentCulled, clippedPrevEC); vec4 clippedNextWC, clippedNextEC; bool nextSegmentClipped, nextSegmentCulled; clipLineSegmentToNearPlane(nextEC.xyz, positionEC.xyz, clippedNextWC, nextSegmentClipped, nextSegmentCulled, clippedNextEC); bool segmentClipped, segmentCulled; vec4 clippedPositionWC, clippedPositionEC; clipLineSegmentToNearPlane(positionEC.xyz, usePrevious ? prevEC.xyz : nextEC.xyz, clippedPositionWC, segmentClipped, segmentCulled, clippedPositionEC); if (segmentCulled) { return vec4(0.0, 0.0, 0.0, 1.0); } vec2 directionToPrevWC = normalize(clippedPrevWC.xy - clippedPositionWC.xy); vec2 directionToNextWC = normalize(clippedNextWC.xy - clippedPositionWC.xy); // If a segment was culled, we can't use the corresponding direction // computed above. We should never see both of these be true without // \`segmentCulled\` above also being true. if (prevSegmentCulled) { directionToPrevWC = -directionToNextWC; } else if (nextSegmentCulled) { directionToNextWC = -directionToPrevWC; } vec2 thisSegmentForwardWC, otherSegmentForwardWC; if (usePrevious) { thisSegmentForwardWC = -directionToPrevWC; otherSegmentForwardWC = directionToNextWC; } else { thisSegmentForwardWC = directionToNextWC; otherSegmentForwardWC = -directionToPrevWC; } vec2 thisSegmentLeftWC = vec2(-thisSegmentForwardWC.y, thisSegmentForwardWC.x); vec2 leftWC = thisSegmentLeftWC; float expandWidth = width * 0.5; // When lines are split at the anti-meridian, the position may be at the // same location as the next or previous position, and we need to handle // that to avoid producing NaNs. if (!czm_equalsEpsilon(prevEC.xyz - positionEC.xyz, vec3(0.0), czm_epsilon1) && !czm_equalsEpsilon(nextEC.xyz - positionEC.xyz, vec3(0.0), czm_epsilon1)) { vec2 otherSegmentLeftWC = vec2(-otherSegmentForwardWC.y, otherSegmentForwardWC.x); vec2 leftSumWC = thisSegmentLeftWC + otherSegmentLeftWC; float leftSumLength = length(leftSumWC); leftWC = leftSumLength < czm_epsilon6 ? thisSegmentLeftWC : (leftSumWC / leftSumLength); // The sine of the angle between the two vectors is given by the formula // |a x b| = |a||b|sin(theta) // which is // float sinAngle = length(cross(vec3(leftWC, 0.0), vec3(-thisSegmentForwardWC, 0.0))); // Because the z components of both vectors are zero, the x and y coordinate will be zero. // Therefore, the sine of the angle is just the z component of the cross product. vec2 u = -thisSegmentForwardWC; vec2 v = leftWC; float sinAngle = abs(u.x * v.y - u.y * v.x); expandWidth = clamp(expandWidth / sinAngle, 0.0, width * 2.0); } vec2 offset = leftWC * expandDirection * expandWidth * czm_pixelRatio; return vec4(clippedPositionWC.xy + offset, -clippedPositionWC.z, 1.0) * (czm_projection * clippedPositionEC).w; } vec4 getPolylineWindowCoordinates(vec4 position, vec4 previous, vec4 next, float expandDirection, float width, bool usePrevious, out float angle) { vec4 positionEC = czm_modelViewRelativeToEye * position; vec4 prevEC = czm_modelViewRelativeToEye * previous; vec4 nextEC = czm_modelViewRelativeToEye * next; return getPolylineWindowCoordinatesEC(positionEC, prevEC, nextEC, expandDirection, width, usePrevious, angle); } `;let hl=`${vp} ${nS}`;const iS=bu;wn.isInternetExplorer()||(hl=`#define CLIP_POLYLINE ${hl}`);function Si(e){e=m(e,m.EMPTY_OBJECT);const t=m(e.translucent,!0),n=!1,i=Si.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=m(e.vertexShaderSource,hl),this._fragmentShaderSource=m(e.fragmentShaderSource,iS),this._renderState=vt.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(Si.prototype,{vertexShaderSource:{get:function(){return this._vertexShaderSource}},fragmentShaderSource:{get:function(){return this._fragmentShaderSource}},renderState:{get:function(){return this._renderState}},closed:{get:function(){return this._closed}},vertexFormat:{get:function(){return this._vertexFormat}}}),Si.VERTEX_FORMAT=Je.POSITION_ONLY,Si.prototype.getFragmentShaderSource=vt.prototype.getFragmentShaderSource,Si.prototype.isTranslucent=vt.prototype.isTranslucent,Si.prototype.getRenderState=vt.prototype.getRenderState;const oS=`in vec3 position3DHigh; in vec3 position3DLow; in vec3 prevPosition3DHigh; in vec3 prevPosition3DLow; in vec3 nextPosition3DHigh; in vec3 nextPosition3DLow; in vec2 expandAndWidth; in vec2 st; in float batchId; out float v_width; out vec2 v_st; out float v_polylineAngle; void main() { float expandDir = expandAndWidth.x; float width = abs(expandAndWidth.y) + 0.5; bool usePrev = expandAndWidth.y < 0.0; vec4 p = czm_computePosition(); vec4 prev = czm_computePrevPosition(); vec4 next = czm_computeNextPosition(); float angle; vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, angle); gl_Position = czm_viewportOrthographic * positionWC; v_width = width; v_st.s = st.s; v_st.t = czm_writeNonPerspective(st.t, gl_Position.w); v_polylineAngle = angle; } `,rS=`#ifdef VECTOR_TILE uniform vec4 u_highlightColor; #endif in vec2 v_st; void main() { czm_materialInput materialInput; vec2 st = v_st; st.t = czm_readNonPerspective(st.t, gl_FragCoord.w); materialInput.s = st.s; materialInput.st = st; materialInput.str = vec3(st, 0.0); czm_material material = czm_getMaterial(materialInput); out_FragColor = vec4(material.diffuse + material.emission, material.alpha); #ifdef VECTOR_TILE out_FragColor *= u_highlightColor; #endif czm_writeLogDepth(); } `;let ul=`${vp} ${oS}`;const sS=rS;wn.isInternetExplorer()||(ul=`#define CLIP_POLYLINE ${ul}`);function Wi(e){e=m(e,m.EMPTY_OBJECT);const t=m(e.translucent,!0),n=!1,i=Wi.VERTEX_FORMAT;this.material=h(e.material)?e.material:X.fromType(X.ColorType),this.translucent=t,this._vertexShaderSource=m(e.vertexShaderSource,ul),this._fragmentShaderSource=m(e.fragmentShaderSource,sS),this._renderState=vt.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(Wi.prototype,{vertexShaderSource:{get:function(){let e=this._vertexShaderSource;return this.material.shaderSource.search(/in\s+float\s+v_polylineAngle;/g)!==-1&&(e=`#define POLYLINE_DASH ${e}`),e}},fragmentShaderSource:{get:function(){return this._fragmentShaderSource}},renderState:{get:function(){return this._renderState}},closed:{get:function(){return this._closed}},vertexFormat:{get:function(){return this._vertexFormat}}}),Wi.VERTEX_FORMAT=Je.POSITION_AND_ST,Wi.prototype.getFragmentShaderSource=vt.prototype.getFragmentShaderSource,Wi.prototype.isTranslucent=vt.prototype.isTranslucent,Wi.prototype.getRenderState=vt.prototype.getRenderState;function ii(e){e=m(e,m.EMPTY_OBJECT),this.geometryInstances=e.geometryInstances,this._hasPerInstanceColors=!0;let t=e.appearance;h(t)||(t=new Wi),this.appearance=t,this.show=m(e.show,!0),this.classificationType=m(e.classificationType,Xn.BOTH),this.debugShowBoundingVolume=m(e.debugShowBoundingVolume,!1),this._debugShowShadowVolume=m(e.debugShowShadowVolume,!1),this._primitiveOptions={geometryInstances:void 0,appearance:void 0,vertexCacheOptimize:!1,interleave:m(e.interleave,!1),releaseGeometryInstances:m(e.releaseGeometryInstances,!0),allowPicking:m(e.allowPicking,!0),asynchronous:m(e.asynchronous,!0),compressVertices:!1,_createShaderProgramFunction:void 0,_createCommandsFunction:void 0,_updateAndQueueCommandsFunction:void 0},this._zIndex=void 0,this._ready=!1,this._primitive=void 0,this._sp=void 0,this._sp2D=void 0,this._spMorph=void 0,this._renderState=xp(!1),this._renderState3DTiles=xp(!0),this._renderStateMorph=Ge.fromCache({cull:{enabled:!0,face:go.FRONT},depthTest:{enabled:!0},blending:tr.PRE_MULTIPLIED_ALPHA_BLEND,depthMask:!1})}Object.defineProperties(ii.prototype,{interleave:{get:function(){return this._primitiveOptions.interleave}},releaseGeometryInstances:{get:function(){return this._primitiveOptions.releaseGeometryInstances}},allowPicking:{get:function(){return this._primitiveOptions.allowPicking}},asynchronous:{get:function(){return this._primitiveOptions.asynchronous}},ready:{get:function(){return this._ready}},debugShowShadowVolume:{get:function(){return this._debugShowShadowVolume}}}),ii.initializeTerrainHeights=function(){return In.initialize()};function aS(e,t,n){const i=t.context,o=e._primitive,r=o._attributeLocations;let s=o._batchTable.getVertexShaderCallback()(tS);s=Ee._appendShowToShader(o,s),s=Ee._appendDistanceDisplayConditionToShader(o,s),s=Ee._modifyShaderPosition(e,s,t.scene3DOnly);let a=o._batchTable.getVertexShaderCallback()(eS);a=Ee._appendShowToShader(o,a),a=Ee._appendDistanceDisplayConditionToShader(o,a),a=Ee._modifyShaderPosition(e,a,t.scene3DOnly);let c=o._batchTable.getVertexShaderCallback()(QC);const u=[`GLOBE_MINIMUM_ALTITUDE ${t.mapProjection.ellipsoid.minimumRadius.toFixed(1)}`];let f="",p="";h(n.material)?(p=h(n.material)?n.material.shaderSource:"",p.search(/in\s+float\s+v_polylineAngle;/g)!==-1&&u.push("ANGLE_VARYING"),p.search(/in\s+float\s+v_width;/g)!==-1&&u.push("WIDTH_VARYING")):f="PER_INSTANCE_COLOR",u.push(f);const _=e.debugShowShadowVolume?["DEBUG_SHOW_VOLUME",f]:[f],g=new Ae({defines:u,sources:[s]}),y=new Ae({defines:_,sources:[p,c]});e._sp=Ut.replaceCache({context:i,shaderProgram:o._sp,vertexShaderSource:g,fragmentShaderSource:y,attributeLocations:r});let b=i.shaderCache.getDerivedShaderProgram(e._sp,"2dColor");if(!h(b)){const O=new Ae({defines:u.concat(["COLUMBUS_VIEW_2D"]),sources:[s]});b=i.shaderCache.createDerivedShaderProgram(e._sp,"2dColor",{context:i,shaderProgram:e._sp2D,vertexShaderSource:O,fragmentShaderSource:y,attributeLocations:r})}e._sp2D=b;let E=i.shaderCache.getDerivedShaderProgram(e._sp,"MorphColor");if(!h(E)){const O=new Ae({defines:u.concat([`MAX_TERRAIN_HEIGHT ${In._defaultMaxTerrainHeight.toFixed(1)}`]),sources:[a]});c=o._batchTable.getVertexShaderCallback()(JC);const v=new Ae({defines:_,sources:[p,c]});E=i.shaderCache.createDerivedShaderProgram(e._sp,"MorphColor",{context:i,shaderProgram:e._spMorph,vertexShaderSource:O,fragmentShaderSource:v,attributeLocations:r})}e._spMorph=E}function xp(e){return Ge.fromCache({cull:{enabled:!0},blending:tr.PRE_MULTIPLIED_ALPHA_BLEND,depthMask:!1,stencilTest:{enabled:e,frontFunction:Ln.EQUAL,frontOperation:{fail:Fe.KEEP,zFail:Fe.KEEP,zPass:Fe.KEEP},backFunction:Ln.EQUAL,backOperation:{fail:Fe.KEEP,zFail:Fe.KEEP,zPass:Fe.KEEP},reference:ei.CESIUM_3D_TILE_MASK,mask:ei.CESIUM_3D_TILE_MASK}})}function cS(e,t,n,i,o,r){const s=e._primitive,a=s._va.length;o.length=a,r.length=a;const u=t instanceof Si?{}:n._uniforms,f=s._batchTable.getUniformMapCallback()(u);for(let p=0;p{!this._ready&&h(this._primitive)&&this._primitive.ready&&(this._ready=!0,this.releaseGeometryInstances&&(this.geometryInstances=void 0))})},ii.prototype.getGeometryInstanceAttributes=function(e){if(!h(this._primitive))throw new T("must call update before calling getGeometryInstanceAttributes");return this._primitive.getGeometryInstanceAttributes(e)},ii.isSupported=function(e){return e.frameState.context.depthTexture},ii.prototype.isDestroyed=function(){return!1},ii.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),this._sp=this._sp&&this._sp.destroy(),this._sp2D=void 0,this._spMorph=void 0,gt(this)};const hS=new L(1,1),uS=!1,fS=S.WHITE;function Io(e){e=m(e,m.EMPTY_OBJECT),this._definitionChanged=new ze,this._image=void 0,this._imageSubscription=void 0,this._repeat=void 0,this._repeatSubscription=void 0,this._color=void 0,this._colorSubscription=void 0,this._transparent=void 0,this._transparentSubscription=void 0,this.image=e.image,this.repeat=e.repeat,this.color=e.color,this.transparent=e.transparent}Object.defineProperties(Io.prototype,{isConstant:{get:function(){return fe.isConstant(this._image)&&fe.isConstant(this._repeat)}},definitionChanged:{get:function(){return this._definitionChanged}},image:D("image"),repeat:D("repeat"),color:D("color"),transparent:D("transparent")}),Io.prototype.getType=function(e){return"Image"},Io.prototype.getValue=function(e,t){return h(t)||(t={}),t.image=fe.getValueOrUndefined(this._image,e),t.repeat=fe.getValueOrClonedDefault(this._repeat,e,hS,t.repeat),t.color=fe.getValueOrClonedDefault(this._color,e,fS,t.color),fe.getValueOrDefault(this._transparent,e,uS)&&(t.color.alpha=Math.min(.99,t.color.alpha)),t},Io.prototype.equals=function(e){return this===e||e instanceof Io&&fe.equals(this._image,e._image)&&fe.equals(this._repeat,e._repeat)&&fe.equals(this._color,e._color)&&fe.equals(this._transparent,e._transparent)};function dS(e){if(e instanceof S)return new To(e);if(typeof e=="string"||e instanceof ie||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement){const t=new Io;return t.image=e,t}throw new T(`Unable to infer material type: ${e}`)}function sn(e,t){return D(e,t,dS)}function pr(e){this._definitionChanged=new ze,this._show=void 0,this._showSubscription=void 0,this._dimensions=void 0,this._dimensionsSubscription=void 0,this._heightReference=void 0,this._heightReferenceSubscription=void 0,this._fill=void 0,this._fillSubscription=void 0,this._material=void 0,this._materialSubscription=void 0,this._outline=void 0,this._outlineSubscription=void 0,this._outlineColor=void 0,this._outlineColorSubscription=void 0,this._outlineWidth=void 0,this._outlineWidthSubscription=void 0,this._shadows=void 0,this._shadowsSubscription=void 0,this._distanceDisplayCondition=void 0,this._distanceDisplayConditionSubscription=void 0,this.merge(m(e,m.EMPTY_OBJECT))}Object.defineProperties(pr.prototype,{definitionChanged:{get:function(){return this._definitionChanged}},show:D("show"),dimensions:D("dimensions"),heightReference:D("heightReference"),fill:D("fill"),material:sn("material"),outline:D("outline"),outlineColor:D("outlineColor"),outlineWidth:D("outlineWidth"),shadows:D("shadows"),distanceDisplayCondition:D("distanceDisplayCondition")}),pr.prototype.clone=function(e){return h(e)?(e.show=this.show,e.dimensions=this.dimensions,e.heightReference=this.heightReference,e.fill=this.fill,e.material=this.material,e.outline=this.outline,e.outlineColor=this.outlineColor,e.outlineWidth=this.outlineWidth,e.shadows=this.shadows,e.distanceDisplayCondition=this.distanceDisplayCondition,e):new pr(this)},pr.prototype.merge=function(e){if(!h(e))throw new T("source is required.");this.show=m(this.show,e.show),this.dimensions=m(this.dimensions,e.dimensions),this.heightReference=m(this.heightReference,e.heightReference),this.fill=m(this.fill,e.fill),this.material=m(this.material,e.material),this.outline=m(this.outline,e.outline),this.outlineColor=m(this.outlineColor,e.outlineColor),this.outlineWidth=m(this.outlineWidth,e.outlineWidth),this.shadows=m(this.shadows,e.shadows),this.distanceDisplayCondition=m(this.distanceDisplayCondition,e.distanceDisplayCondition)};const mr=Object.freeze({FIXED:0,INERTIAL:1});function zo(){T.throwInstantiationError()}Object.defineProperties(zo.prototype,{isConstant:{get:T.throwInstantiationError},definitionChanged:{get:T.throwInstantiationError},referenceFrame:{get:T.throwInstantiationError}}),zo.prototype.getValue=T.throwInstantiationError,zo.prototype.getValueInReferenceFrame=T.throwInstantiationError,zo.prototype.equals=T.throwInstantiationError;const fl=new M;zo.convertToReferenceFrame=function(e,t,n,i,o){if(!h(t))return t;if(h(o)||(o=new l),n===i)return l.clone(t,o);let r=Fi.computeIcrfToFixedMatrix(e,fl);if(h(r)||(r=Fi.computeTemeToPseudoFixedMatrix(e,fl)),n===mr.INERTIAL)return M.multiplyByVector(r,t,o);if(n===mr.FIXED)return M.multiplyByVector(M.transpose(r,fl),t,o)};function Yi(e,t){this._definitionChanged=new ze,this._value=l.clone(e),this._referenceFrame=m(t,mr.FIXED)}Object.defineProperties(Yi.prototype,{isConstant:{get:function(){return!h(this._value)||this._referenceFrame===mr.FIXED}},definitionChanged:{get:function(){return this._definitionChanged}},referenceFrame:{get:function(){return this._referenceFrame}}}),Yi.prototype.getValue=function(e,t){return this.getValueInReferenceFrame(e,mr.FIXED,t)},Yi.prototype.setValue=function(e,t){let n=!1;l.equals(this._value,e)||(n=!0,this._value=l.clone(e)),h(t)&&this._referenceFrame!==t&&(n=!0,this._referenceFrame=t),n&&this._definitionChanged.raiseEvent(this)},Yi.prototype.getValueInReferenceFrame=function(e,t,n){if(!h(e))throw new T("time is required.");if(!h(t))throw new T("referenceFrame is required.");return zo.convertToReferenceFrame(e,this._value,this._referenceFrame,t,n)},Yi.prototype.equals=function(e){return this===e||e instanceof Yi&&l.equals(this._value,e._value)&&this._referenceFrame===e._referenceFrame};function _r(e){this._definitionChanged=new ze,this._show=void 0,this._showSubscription=void 0,this._positions=void 0,this._positionsSubscription=void 0,this._width=void 0,this._widthSubscription=void 0,this._height=void 0,this._heightSubscription=void 0,this._heightReference=void 0,this._heightReferenceSubscription=void 0,this._extrudedHeight=void 0,this._extrudedHeightSubscription=void 0,this._extrudedHeightReference=void 0,this._extrudedHeightReferenceSubscription=void 0,this._cornerType=void 0,this._cornerTypeSubscription=void 0,this._granularity=void 0,this._granularitySubscription=void 0,this._fill=void 0,this._fillSubscription=void 0,this._material=void 0,this._materialSubscription=void 0,this._outline=void 0,this._outlineSubscription=void 0,this._outlineColor=void 0,this._outlineColorSubscription=void 0,this._outlineWidth=void 0,this._outlineWidthSubscription=void 0,this._shadows=void 0,this._shadowsSubscription=void 0,this._distanceDisplayCondition=void 0,this._distanceDisplayConditionSubscription=void 0,this._classificationType=void 0,this._classificationTypeSubscription=void 0,this._zIndex=void 0,this._zIndexSubscription=void 0,this.merge(m(e,m.EMPTY_OBJECT))}Object.defineProperties(_r.prototype,{definitionChanged:{get:function(){return this._definitionChanged}},show:D("show"),positions:D("positions"),width:D("width"),height:D("height"),heightReference:D("heightReference"),extrudedHeight:D("extrudedHeight"),extrudedHeightReference:D("extrudedHeightReference"),cornerType:D("cornerType"),granularity:D("granularity"),fill:D("fill"),material:sn("material"),outline:D("outline"),outlineColor:D("outlineColor"),outlineWidth:D("outlineWidth"),shadows:D("shadows"),distanceDisplayCondition:D("distanceDisplayCondition"),classificationType:D("classificationType"),zIndex:D("zIndex")}),_r.prototype.clone=function(e){return h(e)?(e.show=this.show,e.positions=this.positions,e.width=this.width,e.height=this.height,e.heightReference=this.heightReference,e.extrudedHeight=this.extrudedHeight,e.extrudedHeightReference=this.extrudedHeightReference,e.cornerType=this.cornerType,e.granularity=this.granularity,e.fill=this.fill,e.material=this.material,e.outline=this.outline,e.outlineColor=this.outlineColor,e.outlineWidth=this.outlineWidth,e.shadows=this.shadows,e.distanceDisplayCondition=this.distanceDisplayCondition,e.classificationType=this.classificationType,e.zIndex=this.zIndex,e):new _r(this)},_r.prototype.merge=function(e){if(!h(e))throw new T("source is required.");this.show=m(this.show,e.show),this.positions=m(this.positions,e.positions),this.width=m(this.width,e.width),this.height=m(this.height,e.height),this.heightReference=m(this.heightReference,e.heightReference),this.extrudedHeight=m(this.extrudedHeight,e.extrudedHeight),this.extrudedHeightReference=m(this.extrudedHeightReference,e.extrudedHeightReference),this.cornerType=m(this.cornerType,e.cornerType),this.granularity=m(this.granularity,e.granularity),this.fill=m(this.fill,e.fill),this.material=m(this.material,e.material),this.outline=m(this.outline,e.outline),this.outlineColor=m(this.outlineColor,e.outlineColor),this.outlineWidth=m(this.outlineWidth,e.outlineWidth),this.shadows=m(this.shadows,e.shadows),this.distanceDisplayCondition=m(this.distanceDisplayCondition,e.distanceDisplayCondition),this.classificationType=m(this.classificationType,e.classificationType),this.zIndex=m(this.zIndex,e.zIndex)};function pS(e){return e}function dl(e,t){return D(e,t,pS)}function gr(e){this._definitionChanged=new ze,this._show=void 0,this._showSubscription=void 0,this._length=void 0,this._lengthSubscription=void 0,this._topRadius=void 0,this._topRadiusSubscription=void 0,this._bottomRadius=void 0,this._bottomRadiusSubscription=void 0,this._heightReference=void 0,this._heightReferenceSubscription=void 0,this._fill=void 0,this._fillSubscription=void 0,this._material=void 0,this._materialSubscription=void 0,this._outline=void 0,this._outlineSubscription=void 0,this._outlineColor=void 0,this._outlineColorSubscription=void 0,this._outlineWidth=void 0,this._outlineWidthSubscription=void 0,this._numberOfVerticalLines=void 0,this._numberOfVerticalLinesSubscription=void 0,this._slices=void 0,this._slicesSubscription=void 0,this._shadows=void 0,this._shadowsSubscription=void 0,this._distanceDisplayCondition=void 0,this._distanceDisplayConditionSubscription=void 0,this.merge(m(e,m.EMPTY_OBJECT))}Object.defineProperties(gr.prototype,{definitionChanged:{get:function(){return this._definitionChanged}},show:D("show"),length:D("length"),topRadius:D("topRadius"),bottomRadius:D("bottomRadius"),heightReference:D("heightReference"),fill:D("fill"),material:sn("material"),outline:D("outline"),outlineColor:D("outlineColor"),outlineWidth:D("outlineWidth"),numberOfVerticalLines:D("numberOfVerticalLines"),slices:D("slices"),shadows:D("shadows"),distanceDisplayCondition:D("distanceDisplayCondition")}),gr.prototype.clone=function(e){return h(e)?(e.show=this.show,e.length=this.length,e.topRadius=this.topRadius,e.bottomRadius=this.bottomRadius,e.heightReference=this.heightReference,e.fill=this.fill,e.material=this.material,e.outline=this.outline,e.outlineColor=this.outlineColor,e.outlineWidth=this.outlineWidth,e.numberOfVerticalLines=this.numberOfVerticalLines,e.slices=this.slices,e.shadows=this.shadows,e.distanceDisplayCondition=this.distanceDisplayCondition,e):new gr(this)},gr.prototype.merge=function(e){if(!h(e))throw new T("source is required.");this.show=m(this.show,e.show),this.length=m(this.length,e.length),this.topRadius=m(this.topRadius,e.topRadius),this.bottomRadius=m(this.bottomRadius,e.bottomRadius),this.heightReference=m(this.heightReference,e.heightReference),this.fill=m(this.fill,e.fill),this.material=m(this.material,e.material),this.outline=m(this.outline,e.outline),this.outlineColor=m(this.outlineColor,e.outlineColor),this.outlineWidth=m(this.outlineWidth,e.outlineWidth),this.numberOfVerticalLines=m(this.numberOfVerticalLines,e.numberOfVerticalLines),this.slices=m(this.slices,e.slices),this.shadows=m(this.shadows,e.shadows),this.distanceDisplayCondition=m(this.distanceDisplayCondition,e.distanceDisplayCondition)};function yr(e){this._definitionChanged=new ze,this._show=void 0,this._showSubscription=void 0,this._semiMajorAxis=void 0,this._semiMajorAxisSubscription=void 0,this._semiMinorAxis=void 0,this._semiMinorAxisSubscription=void 0,this._height=void 0,this._heightSubscription=void 0,this._heightReference=void 0,this._heightReferenceSubscription=void 0,this._extrudedHeight=void 0,this._extrudedHeightSubscription=void 0,this._extrudedHeightReference=void 0,this._extrudedHeightReferenceSubscription=void 0,this._rotation=void 0,this._rotationSubscription=void 0,this._stRotation=void 0,this._stRotationSubscription=void 0,this._granularity=void 0,this._granularitySubscription=void 0,this._fill=void 0,this._fillSubscription=void 0,this._material=void 0,this._materialSubscription=void 0,this._outline=void 0,this._outlineSubscription=void 0,this._outlineColor=void 0,this._outlineColorSubscription=void 0,this._outlineWidth=void 0,this._outlineWidthSubscription=void 0,this._numberOfVerticalLines=void 0,this._numberOfVerticalLinesSubscription=void 0,this._shadows=void 0,this._shadowsSubscription=void 0,this._distanceDisplayCondition=void 0,this._distanceDisplayConditionSubscription=void 0,this._classificationType=void 0,this._classificationTypeSubscription=void 0,this._zIndex=void 0,this._zIndexSubscription=void 0,this.merge(m(e,m.EMPTY_OBJECT))}Object.defineProperties(yr.prototype,{definitionChanged:{get:function(){return this._definitionChanged}},show:D("show"),semiMajorAxis:D("semiMajorAxis"),semiMinorAxis:D("semiMinorAxis"),height:D("height"),heightReference:D("heightReference"),extrudedHeight:D("extrudedHeight"),extrudedHeightReference:D("extrudedHeightReference"),rotation:D("rotation"),stRotation:D("stRotation"),granularity:D("granularity"),fill:D("fill"),material:sn("material"),outline:D("outline"),outlineColor:D("outlineColor"),outlineWidth:D("outlineWidth"),numberOfVerticalLines:D("numberOfVerticalLines"),shadows:D("shadows"),distanceDisplayCondition:D("distanceDisplayCondition"),classificationType:D("classificationType"),zIndex:D("zIndex")}),yr.prototype.clone=function(e){return h(e)?(e.show=this.show,e.semiMajorAxis=this.semiMajorAxis,e.semiMinorAxis=this.semiMinorAxis,e.height=this.height,e.heightReference=this.heightReference,e.extrudedHeight=this.extrudedHeight,e.extrudedHeightReference=this.extrudedHeightReference,e.rotation=this.rotation,e.stRotation=this.stRotation,e.granularity=this.granularity,e.fill=this.fill,e.material=this.material,e.outline=this.outline,e.outlineColor=this.outlineColor,e.outlineWidth=this.outlineWidth,e.numberOfVerticalLines=this.numberOfVerticalLines,e.shadows=this.shadows,e.distanceDisplayCondition=this.distanceDisplayCondition,e.classificationType=this.classificationType,e.zIndex=this.zIndex,e):new yr(this)},yr.prototype.merge=function(e){if(!h(e))throw new T("source is required.");this.show=m(this.show,e.show),this.semiMajorAxis=m(this.semiMajorAxis,e.semiMajorAxis),this.semiMinorAxis=m(this.semiMinorAxis,e.semiMinorAxis),this.height=m(this.height,e.height),this.heightReference=m(this.heightReference,e.heightReference),this.extrudedHeight=m(this.extrudedHeight,e.extrudedHeight),this.extrudedHeightReference=m(this.extrudedHeightReference,e.extrudedHeightReference),this.rotation=m(this.rotation,e.rotation),this.stRotation=m(this.stRotation,e.stRotation),this.granularity=m(this.granularity,e.granularity),this.fill=m(this.fill,e.fill),this.material=m(this.material,e.material),this.outline=m(this.outline,e.outline),this.outlineColor=m(this.outlineColor,e.outlineColor),this.outlineWidth=m(this.outlineWidth,e.outlineWidth),this.numberOfVerticalLines=m(this.numberOfVerticalLines,e.numberOfVerticalLines),this.shadows=m(this.shadows,e.shadows),this.distanceDisplayCondition=m(this.distanceDisplayCondition,e.distanceDisplayCondition),this.classificationType=m(this.classificationType,e.classificationType),this.zIndex=m(this.zIndex,e.zIndex)};function wr(e){this._definitionChanged=new ze,this._show=void 0,this._showSubscription=void 0,this._radii=void 0,this._radiiSubscription=void 0,this._innerRadii=void 0,this._innerRadiiSubscription=void 0,this._minimumClock=void 0,this._minimumClockSubscription=void 0,this._maximumClock=void 0,this._maximumClockSubscription=void 0,this._minimumCone=void 0,this._minimumConeSubscription=void 0,this._maximumCone=void 0,this._maximumConeSubscription=void 0,this._heightReference=void 0,this._heightReferenceSubscription=void 0,this._fill=void 0,this._fillSubscription=void 0,this._material=void 0,this._materialSubscription=void 0,this._outline=void 0,this._outlineSubscription=void 0,this._outlineColor=void 0,this._outlineColorSubscription=void 0,this._outlineWidth=void 0,this._outlineWidthSubscription=void 0,this._stackPartitions=void 0,this._stackPartitionsSubscription=void 0,this._slicePartitions=void 0,this._slicePartitionsSubscription=void 0,this._subdivisions=void 0,this._subdivisionsSubscription=void 0,this._shadows=void 0,this._shadowsSubscription=void 0,this._distanceDisplayCondition=void 0,this._distanceDisplayConditionSubscription=void 0,this.merge(m(e,m.EMPTY_OBJECT))}Object.defineProperties(wr.prototype,{definitionChanged:{get:function(){return this._definitionChanged}},show:D("show"),radii:D("radii"),innerRadii:D("innerRadii"),minimumClock:D("minimumClock"),maximumClock:D("maximumClock"),minimumCone:D("minimumCone"),maximumCone:D("maximumCone"),heightReference:D("heightReference"),fill:D("fill"),material:sn("material"),outline:D("outline"),outlineColor:D("outlineColor"),outlineWidth:D("outlineWidth"),stackPartitions:D("stackPartitions"),slicePartitions:D("slicePartitions"),subdivisions:D("subdivisions"),shadows:D("shadows"),distanceDisplayCondition:D("distanceDisplayCondition")}),wr.prototype.clone=function(e){return h(e)?(e.show=this.show,e.radii=this.radii,e.innerRadii=this.innerRadii,e.minimumClock=this.minimumClock,e.maximumClock=this.maximumClock,e.minimumCone=this.minimumCone,e.maximumCone=this.maximumCone,e.heightReference=this.heightReference,e.fill=this.fill,e.material=this.material,e.outline=this.outline,e.outlineColor=this.outlineColor,e.outlineWidth=this.outlineWidth,e.stackPartitions=this.stackPartitions,e.slicePartitions=this.slicePartitions,e.subdivisions=this.subdivisions,e.shadows=this.shadows,e.distanceDisplayCondition=this.distanceDisplayCondition,e):new wr(this)},wr.prototype.merge=function(e){if(!h(e))throw new T("source is required.");this.show=m(this.show,e.show),this.radii=m(this.radii,e.radii),this.innerRadii=m(this.innerRadii,e.innerRadii),this.minimumClock=m(this.minimumClock,e.minimumClock),this.maximumClock=m(this.maximumClock,e.maximumClock),this.minimumCone=m(this.minimumCone,e.minimumCone),this.maximumCone=m(this.maximumCone,e.maximumCone),this.heightReference=m(this.heightReference,e.heightReference),this.fill=m(this.fill,e.fill),this.material=m(this.material,e.material),this.outline=m(this.outline,e.outline),this.outlineColor=m(this.outlineColor,e.outlineColor),this.outlineWidth=m(this.outlineWidth,e.outlineWidth),this.stackPartitions=m(this.stackPartitions,e.stackPartitions),this.slicePartitions=m(this.slicePartitions,e.slicePartitions),this.subdivisions=m(this.subdivisions,e.subdivisions),this.shadows=m(this.shadows,e.shadows),this.distanceDisplayCondition=m(this.distanceDisplayCondition,e.distanceDisplayCondition)};function br(e){this._definitionChanged=new ze,this._show=void 0,this._showSubscription=void 0,this._text=void 0,this._textSubscription=void 0,this._font=void 0,this._fontSubscription=void 0,this._style=void 0,this._styleSubscription=void 0,this._scale=void 0,this._scaleSubscription=void 0,this._showBackground=void 0,this._showBackgroundSubscription=void 0,this._backgroundColor=void 0,this._backgroundColorSubscription=void 0,this._backgroundPadding=void 0,this._backgroundPaddingSubscription=void 0,this._pixelOffset=void 0,this._pixelOffsetSubscription=void 0,this._eyeOffset=void 0,this._eyeOffsetSubscription=void 0,this._horizontalOrigin=void 0,this._horizontalOriginSubscription=void 0,this._verticalOrigin=void 0,this._verticalOriginSubscription=void 0,this._heightReference=void 0,this._heightReferenceSubscription=void 0,this._fillColor=void 0,this._fillColorSubscription=void 0,this._outlineColor=void 0,this._outlineColorSubscription=void 0,this._outlineWidth=void 0,this._outlineWidthSubscription=void 0,this._translucencyByDistance=void 0,this._translucencyByDistanceSubscription=void 0,this._pixelOffsetScaleByDistance=void 0,this._pixelOffsetScaleByDistanceSubscription=void 0,this._scaleByDistance=void 0,this._scaleByDistanceSubscription=void 0,this._distanceDisplayCondition=void 0,this._distanceDisplayConditionSubscription=void 0,this._disableDepthTestDistance=void 0,this._disableDepthTestDistanceSubscription=void 0,this.merge(m(e,m.EMPTY_OBJECT))}Object.defineProperties(br.prototype,{definitionChanged:{get:function(){return this._definitionChanged}},show:D("show"),text:D("text"),font:D("font"),style:D("style"),scale:D("scale"),showBackground:D("showBackground"),backgroundColor:D("backgroundColor"),backgroundPadding:D("backgroundPadding"),pixelOffset:D("pixelOffset"),eyeOffset:D("eyeOffset"),horizontalOrigin:D("horizontalOrigin"),verticalOrigin:D("verticalOrigin"),heightReference:D("heightReference"),fillColor:D("fillColor"),outlineColor:D("outlineColor"),outlineWidth:D("outlineWidth"),translucencyByDistance:D("translucencyByDistance"),pixelOffsetScaleByDistance:D("pixelOffsetScaleByDistance"),scaleByDistance:D("scaleByDistance"),distanceDisplayCondition:D("distanceDisplayCondition"),disableDepthTestDistance:D("disableDepthTestDistance")}),br.prototype.clone=function(e){return h(e)?(e.show=this.show,e.text=this.text,e.font=this.font,e.style=this.style,e.scale=this.scale,e.showBackground=this.showBackground,e.backgroundColor=this.backgroundColor,e.backgroundPadding=this.backgroundPadding,e.pixelOffset=this.pixelOffset,e.eyeOffset=this.eyeOffset,e.horizontalOrigin=this.horizontalOrigin,e.verticalOrigin=this.verticalOrigin,e.heightReference=this.heightReference,e.fillColor=this.fillColor,e.outlineColor=this.outlineColor,e.outlineWidth=this.outlineWidth,e.translucencyByDistance=this.translucencyByDistance,e.pixelOffsetScaleByDistance=this.pixelOffsetScaleByDistance,e.scaleByDistance=this.scaleByDistance,e.distanceDisplayCondition=this.distanceDisplayCondition,e.disableDepthTestDistance=this.disableDepthTestDistance,e):new br(this)},br.prototype.merge=function(e){if(!h(e))throw new T("source is required.");this.show=m(this.show,e.show),this.text=m(this.text,e.text),this.font=m(this.font,e.font),this.style=m(this.style,e.style),this.scale=m(this.scale,e.scale),this.showBackground=m(this.showBackground,e.showBackground),this.backgroundColor=m(this.backgroundColor,e.backgroundColor),this.backgroundPadding=m(this.backgroundPadding,e.backgroundPadding),this.pixelOffset=m(this.pixelOffset,e.pixelOffset),this.eyeOffset=m(this.eyeOffset,e.eyeOffset),this.horizontalOrigin=m(this.horizontalOrigin,e.horizontalOrigin),this.verticalOrigin=m(this.verticalOrigin,e.verticalOrigin),this.heightReference=m(this.heightReference,e.heightReference),this.fillColor=m(this.fillColor,e.fillColor),this.outlineColor=m(this.outlineColor,e.outlineColor),this.outlineWidth=m(this.outlineWidth,e.outlineWidth),this.translucencyByDistance=m(this.translucencyByDistance,e.translucencyByDistance),this.pixelOffsetScaleByDistance=m(this.pixelOffsetScaleByDistance,e.pixelOffsetScaleByDistance),this.scaleByDistance=m(this.scaleByDistance,e.scaleByDistance),this.distanceDisplayCondition=m(this.distanceDisplayCondition,e.distanceDisplayCondition),this.disableDepthTestDistance=m(this.disableDepthTestDistance,e.disableDepthTestDistance)};const mS=new l(1,1,1),_S=l.ZERO,gS=K.IDENTITY;function pl(e,t,n){this.translation=l.clone(m(e,_S)),this.rotation=K.clone(m(t,gS)),this.scale=l.clone(m(n,mS))}pl.prototype.equals=function(e){return this===e||h(e)&&l.equals(this.translation,e.translation)&&K.equals(this.rotation,e.rotation)&&l.equals(this.scale,e.scale)};const ml=new pl;function Tr(e){e=m(e,m.EMPTY_OBJECT),this._definitionChanged=new ze,this._translation=void 0,this._translationSubscription=void 0,this._rotation=void 0,this._rotationSubscription=void 0,this._scale=void 0,this._scaleSubscription=void 0,this.translation=e.translation,this.rotation=e.rotation,this.scale=e.scale}Object.defineProperties(Tr.prototype,{isConstant:{get:function(){return fe.isConstant(this._translation)&&fe.isConstant(this._rotation)&&fe.isConstant(this._scale)}},definitionChanged:{get:function(){return this._definitionChanged}},translation:D("translation"),rotation:D("rotation"),scale:D("scale")}),Tr.prototype.getValue=function(e,t){return h(t)||(t=new pl),t.translation=fe.getValueOrClonedDefault(this._translation,e,ml.translation,t.translation),t.rotation=fe.getValueOrClonedDefault(this._rotation,e,ml.rotation,t.rotation),t.scale=fe.getValueOrClonedDefault(this._scale,e,ml.scale,t.scale),t},Tr.prototype.equals=function(e){return this===e||e instanceof Tr&&fe.equals(this._translation,e._translation)&&fe.equals(this._rotation,e._rotation)&&fe.equals(this._scale,e._scale)};function an(e,t){this._propertyNames=[],this._definitionChanged=new ze,h(e)&&this.merge(e,t)}Object.defineProperties(an.prototype,{propertyNames:{get:function(){return this._propertyNames}},isConstant:{get:function(){const e=this._propertyNames;for(let t=0,n=e.length;t0){t=m(t,F.IDENTITY);const o=F.inverseTransformation(t,vS),r=F.multiplyByPoint(o,l.ZERO,xS),s=l.normalize(F.multiplyByPointAsVector(o,l.UNIT_Y,Np),Np),a=Se.fromPointNormal(r,s,PS),c=l.normalize(F.multiplyByPointAsVector(o,l.UNIT_X,Lp),Lp),u=Se.fromPointNormal(r,c,RS);let f=1;n.push(l.clone(e[0]));let p=n[0];const _=e.length;for(let g=1;g<_;++g){const y=e[g];if(Se.getPointDistance(u,p)<0||Se.getPointDistance(u,y)<0){const b=$n.lineSegmentPlane(p,y,a,IS);if(h(b)){const E=l.multiplyByScalar(s,5e-9,zS);Se.getPointDistance(a,p)<0&&l.negate(E,E),n.push(l.add(b,E,new l)),i.push(f+1),l.negate(E,E),n.push(l.add(b,E,new l)),f=1}}n.push(l.clone(e[g])),f++,p=y}i.push(f)}return{positions:n,lengths:i}},Wt.generateArc=function(e){h(e)||(e={});const t=e.positions;if(!h(t))throw new T("options.positions is required.");const n=t.length,i=m(e.ellipsoid,pe.WGS84);let o=m(e.height,0);const r=Array.isArray(o);if(n<1)return[];if(n===1){const b=i.scaleToGeodeticSurface(t[0],yl);if(o=r?o[0]:o,o!==0){const E=i.geodeticSurfaceNormal(b,Ai);l.multiplyByScalar(E,o,E),l.add(b,E,b)}return[b.x,b.y,b.z]}let s=e.minDistance;if(!h(s)){const b=m(e.granularity,P.RADIANS_PER_DEGREE);s=P.chordLength(b,i.maximumRadius)}let a=0,c;for(c=0;c1;--H){if(O=P.PI_OVER_TWO-(H-1)*E,z=Do(-O,r,y,g,c,f,u,p,_,z),U=Do(O+Math.PI,r,y,g,c,f,u,p,_,U),t){for(A[R++]=z.x,A[R++]=z.y,A[R++]=z.z,w=2*(H-1)+2,W=1;Wve.mouseEmulationIgnoreMilliseconds}function vl(e,t,n){const i=e.x-t.x,o=e.y-t.y;return Math.sqrt(i*i+o*o)0?n=t.detail*-120:n=t.wheelDelta;if(!h(n))return;const i=$i(t),o=e.getInputAction(ae.WHEEL,i);h(o)&&(o(n),t.preventDefault())}function eO(e,t){Ol(e);const n=t.changedTouches;let i;const o=n.length;let r,s;const a=e._positions;for(i=0;i=e[1]&&t[0]>=e[0]?n=i+Math.PI:t[1]>=e[1]&&t[0]=e[0]&&(n=Math.PI-i),n},getAngleOfThreePoints(e,t,n){const i=this.getAzimuth(t,e)-this.getAzimuth(t,n);return i<0?i+te.Constants.TWO_PI:i},isClockWise(e,t,n){return(n[1]-e[1])*(t[0]-e[0])>(t[1]-e[1])*(n[0]-e[0])},getPointOnLine(e,t,n){const i=t[0]+e*(n[0]-t[0]),o=t[1]+e*(n[1]-t[1]);return[i,o]},getCubicValue(e,t,n,i,o){e=Math.max(Math.min(e,1),0);const r=1-e,s=e*e,a=s*e,c=r*r,u=c*r,f=u*t[0]+3*c*e*n[0]+3*r*s*i[0]+a*o[0],p=u*t[1]+3*c*e*n[1]+3*r*s*i[1]+a*o[1];return[f,p]},getThirdPoint(e,t,n,i,o){const r=this.getAzimuth(e,t),s=o?r+n:r-n,a=i*Math.cos(s),c=i*Math.sin(s);return[t[0]+a,t[1]+c]},getArcPoints(e,t,n,i){let o,r;const s=[];let a=i-n;a=a<0?a+te.Constants.TWO_PI:a;for(let c=0;c<=te.Constants.FITTING_COUNT;c++){const u=n+a*c/te.Constants.FITTING_COUNT;o=e[0]+t*Math.cos(u),r=e[1]+t*Math.sin(u),s.push([o,r])}return s},getBisectorNormals(e,t,n,i){const o=this.getNormal(t,n,i),r=Math.sqrt(o[0]*o[0]+o[1]*o[1]),s=o[0]/r,a=o[1]/r,c=this.distance(t,n),u=this.distance(n,i);let f,p,_,g,y;if(r>te.Constants.ZERO_TOLERANCE)if(this.isClockWise(t,n,i)){let b=e*c,E=n[0]-b*a,O=n[1]+b*s;f=[E,O],b=e*u,E=n[0]+b*a,O=n[1]-b*s,p=[E,O]}else _=e*c,y=n[0]+_*a,g=n[1]-_*s,f=[y,g],_=e*u,y=n[0]-_*a,g=n[1]+_*s,p=[y,g];else y=n[0]+e*(t[0]-n[0]),g=n[1]+e*(t[1]-n[1]),f=[y,g],y=n[0]+e*(i[0]-n[0]),g=n[1]+e*(i[1]-n[1]),p=[y,g];return[f,p]},getNormal(e,t,n){let i=e[0]-t[0],o=e[1]-t[1];const r=Math.sqrt(i*i+o*o);i/=r,o/=r;let s=n[0]-t[0],a=n[1]-t[1];const c=Math.sqrt(s*s+a*a);s/=c,a/=c;const u=i+s,f=o+a;return[u,f]},getCurvePoints(e,t){let i=[this.getLeftMostControlPoint(t)],o,r;for(let c=0;cte.Constants.ZERO_TOLERANCE){const p=this.mid(n,i),_=n[0]-p[0],g=n[1]-p[1],b=2/this.distance(n,i),E=-b*g,O=b*_,v=E*E-O*O,A=2*E*O,R=O*O-E*E,z=s[0]-p[0],U=s[1]-p[1];u=p[0]+v*z+A*U,f=p[1]+A*z+R*U}else u=n[0]+1*(i[0]-n[0]),f=n[1]+1*(i[1]-n[1]);return[u,f]},getRightMostControlPoint(e){const n=e.length,i=e[n-3],o=e[n-2],r=e[n-1],a=this.getBisectorNormals(0,i,o,r)[1],c=this.getNormal(i,o,r),u=Math.sqrt(c[0]*c[0]+c[1]*c[1]);let f,p;if(u>te.Constants.ZERO_TOLERANCE){const _=this.mid(o,r),g=r[0]-_[0],y=r[1]-_[1],E=2/this.distance(o,r),O=-E*y,v=E*g,A=O*O-v*v,R=2*O*v,z=v*v-O*O,U=a[0]-_[0],G=a[1]-_[1];p=_[0]+A*U+R*G,f=_[1]+R*U+z*G}else p=r[0]+1*(o[0]-r[0]),f=r[1]+1*(o[1]-r[1]);return[p,f]},getBezierPoints(e){if(e.length<=2)return e;const t=[],n=e.length-1;for(let i=0;i<=1;i+=.01){let o=0,r=0;for(let s=0;n>=s;s++){const a=this.getBinomialFactor(n,s),c=i**s,u=(1-i)**(n-s);o+=a*c*u*e[s][0],r+=a*c*u*e[s][1]}t.push([o,r])}return t.push(e[n]),t},getBinomialFactor(e,t){return this.getFactorial(e)/(this.getFactorial(t)*this.getFactorial(e-t))},getFactorial(e){if(e<=1)return 1;if(e===2)return 2;if(e===3)return 6;if(e===4)return 24;if(e===5)return 120;let t=1;for(let n=1;e>=n;n++)t*=n;return t},getQBSplinePoints(e){if(e.length<=2)return e;const t=2,n=[],i=e.length-t-1;n.push(e[0]);for(let o=0;i>=o;o++)for(let r=0;r<=1;r+=.05){let s=0,a=0;for(let c=0;t>=c;c++){const u=this.getQuadricBSplineFactor(c,r);s+=u*e[o+c][0],a+=u*e[o+c][1]}n.push([s,a])}return n.push(e[e.length-1]),n},getQuadricBSplineFactor(e,t){return e===0?(t-1)**2/2:e===1?(-2*t**2+2*t+1)/2:e===2?t**2/2:0}}},Pi={type:"doublearrow",headHeightFactor:.25,headWidthFactor:.3,neckHeightFactor:.85,fixPointCount:4,neckWidthFactor:.15},ea={headHeightFactor:.18,headWidthFactor:.3,neckHeightFactor:.85,neckWidthFactor:.15,tailWidthFactor:.1,headTailFactor:.8,swallowTailFactor:1,swallowTailPnt:[]},Dr={tailWidthFactor:.15,neckWidthFactor:.2,headWidthFactor:.25,headAngle:Math.PI/8.5,neckAngle:Math.PI/13},He={version:"1.0.0",createTime:"2018.6.19",author:"xupinhui",algorithm:{doubleArrow:e=>{let t,n;const i=e,o={controlPoint:void 0,polygonalPoint:void 0},r=e.length;if(!(r<2)){if(r===2)return e;const s=i[0],a=i[1],c=i[2];r===3?n=He.algorithm.getTempPoint4(s,a,c):n=i[3],r===3||r===4?t=te.PlotUtils.mid(s,a):t=i[4];let u,f;te.PlotUtils.isClockWise(s,a,c)?(u=He.algorithm.getArrowPoints(s,t,n,!1),f=He.algorithm.getArrowPoints(t,a,c,!0)):(u=He.algorithm.getArrowPoints(a,t,c,!1),f=He.algorithm.getArrowPoints(t,s,n,!0));const p=u.length,_=(p-5)/2,g=u.slice(0,_),y=u.slice(_,_+5);let b=u.slice(_+5,p),E=f.slice(0,_);const O=f.slice(_,_+5),v=f.slice(_+5,p);E=te.PlotUtils.getBezierPoints(E);const A=te.PlotUtils.getBezierPoints(v.concat(g.slice(1)));b=te.PlotUtils.getBezierPoints(b);const R=E.concat(O,A,y,b),z=He.algorithm.array2Dto1D(R);o.controlPoint=[s,a,c,n,t],o.polygonalPoint=l.fromDegreesArray(z)}return o},threeArrow(e){let t,n,i;const o=e,r={controlPoint:void 0,polygonalPoint:void 0};let s=e.length;if(s>=2){if(s===2)return e;const a=o[0],c=o[1],u=o[2];s=e.length,s===3?(n=He.algorithm.getTempPoint4(a,c,u),i=te.PlotUtils.mid(u,n)):(n=o[3],i=o[4]),s<6?t=te.PlotUtils.mid(a,c):t=o[5];let f,p;te.PlotUtils.isClockWise(a,c,u)?(f=He.algorithm.getArrowPoints(a,t,n,!1),p=He.algorithm.getArrowPoints(t,c,u,!0)):(f=He.algorithm.getArrowPoints(c,t,u,!1),p=He.algorithm.getArrowPoints(t,a,n,!0));const _=f.length,g=(_-5)/2,y=f.slice(0,g),b=f.slice(g,g+5);let E=f.slice(g+5,_),O=p.slice(0,g);const v=p.slice(g,g+5),A=p.slice(g+5,_);O=te.PlotUtils.getBezierPoints(O);const R=te.PlotUtils.getBezierPoints(A.concat(y.slice(1)));E=te.PlotUtils.getBezierPoints(E);const z=O.concat(v,R,b,E),U=He.algorithm.array2Dto1D(z);r.controlPoint=[a,c,u,n,i,t],r.polygonalPoint=l.fromDegreesArray(U)}return r},array2Dto1D(e){const t=[];return e.forEach(n=>{t.push(n[0]),t.push(n[1])}),t},getArrowPoints(e,t,n,i){const o=Pi.headHeightFactor,r=Pi.headWidthFactor,s=Pi.neckHeightFactor,a=Pi.neckWidthFactor,c=te.PlotUtils.mid(e,t),u=te.PlotUtils.distance(c,n);let f=te.PlotUtils.getThirdPoint(n,c,0,.3*u,!0),p=te.PlotUtils.getThirdPoint(n,c,0,.5*u,!0);f=te.PlotUtils.getThirdPoint(c,f,te.Constants.HALF_PI,u/5,i),p=te.PlotUtils.getThirdPoint(c,p,te.Constants.HALF_PI,u/4,i);const _=[c,f,p,n],g=He.algorithm.getArrowHeadPoints(_,o,r,s,a),y=g[0],b=g[4],E=te.PlotUtils.distance(e,t)/te.PlotUtils.getBaseLength(_)/2,O=He.algorithm.getArrowBodyPoints(_,y,b,E),v=O.length;let A=O.slice(0,v/2),R=O.slice(v/2,v);return A.push(y),R.push(b),A=A.reverse(),A.push(t),R=R.reverse(),R.push(e),A.reverse().concat(g,R)},getArrowHeadPoints(e,t,n){const i=Pi.headHeightFactor,o=Pi.headWidthFactor,r=Pi.neckHeightFactor,s=Pi.neckWidthFactor,c=te.PlotUtils.getBaseLength(e)*i,u=e[e.length-1],f=(te.PlotUtils.distance(t,n),c*o),p=c*s,_=c*r,g=te.PlotUtils.getThirdPoint(e[e.length-2],u,0,c,!0),y=te.PlotUtils.getThirdPoint(e[e.length-2],u,0,_,!0),b=te.PlotUtils.getThirdPoint(u,g,te.Constants.HALF_PI,f,!1),E=te.PlotUtils.getThirdPoint(u,g,te.Constants.HALF_PI,f,!0),O=te.PlotUtils.getThirdPoint(u,y,te.Constants.HALF_PI,p,!1),v=te.PlotUtils.getThirdPoint(u,y,te.Constants.HALF_PI,p,!0);return[O,b,u,E,v]},getArrowBodyPoints(e,t,n,i){const o=[],r=[];for(let s=te.PlotUtils.wholeDistance(e),a=te.PlotUtils.getBaseLength(e),c=a*i,u=te.PlotUtils.distance(t,n),f=(c-u)/2,p=0,_=[],g=[],y=1;y=te.Constants.HALF_PI&&u=Math.PI&&u<1.5*Math.PI?(o=c*Math.sin(u-Math.PI),r=c*Math.cos(u-Math.PI),s=te.PlotUtils.getThirdPoint(e,a,te.Constants.HALF_PI,o,!0),i=te.PlotUtils.getThirdPoint(a,s,te.Constants.HALF_PI,r,!0)):(o=c*Math.sin(2*Math.PI-u),r=c*Math.cos(2*Math.PI-u),s=te.PlotUtils.getThirdPoint(e,a,te.Constants.HALF_PI,o,!0),i=te.PlotUtils.getThirdPoint(a,s,te.Constants.HALF_PI,r,!1)),i},tailedAttackArrow(e){e=He.algorithm.dereplication(e);const t=ea.tailWidthFactor,n=ea.swallowTailFactor;let i=ea.swallowTailPnt;const o={controlPoint:void 0,polygonalPoint:void 0};o.controlPoint=e;let r=e.length;if(!(r<2)){if(e.length===2)return o.polygonalPoint=e,o;const s=e;let a=s[0],c=s[1];te.PlotUtils.isClockWise(s[0],s[1],s[2])&&(a=s[1],c=s[0]);const f=[te.PlotUtils.mid(a,c)].concat(s.slice(2)),p=He.algorithm.getAttackArrowHeadPoints(f,a,c,ea),_=p[0],g=p[4],y=te.PlotUtils.distance(a,c),b=te.PlotUtils.getBaseLength(f),E=b*t*n;i=te.PlotUtils.getThirdPoint(f[1],f[0],0,E,!0);const O=y/b,v=He.algorithm.getAttackArrowBodyPoints(f,_,g,O);r=v.length;let A=[a].concat(v.slice(0,r/2));A.push(_);let R=[c].concat(v.slice(r/2,r)),z=[];R.push(g),A=te.PlotUtils.getQBSplinePoints(A),R=te.PlotUtils.getQBSplinePoints(R),z=He.algorithm.array2Dto1D(A.concat(p,R.reverse(),[i,A[0]])),o.polygonalPoint=l.fromDegreesArray(z)}return o},getAttackArrowHeadPoints(e,t,n,i){const o=i.headHeightFactor,r=i.headTailFactor,s=i.headWidthFactor,a=i.neckWidthFactor,c=i.neckHeightFactor;let u=te.PlotUtils.getBaseLength(e),f=u*o;const p=e[e.length-1];u=te.PlotUtils.distance(p,e[e.length-2]);const _=te.PlotUtils.distance(t,n);f>_*r&&(f=_*r);const g=f*s,y=f*a;f=f>u?u:f;const b=f*c,E=te.PlotUtils.getThirdPoint(e[e.length-2],p,0,f,!0),O=te.PlotUtils.getThirdPoint(e[e.length-2],p,0,b,!0),v=te.PlotUtils.getThirdPoint(p,E,te.Constants.HALF_PI,g,!1),A=te.PlotUtils.getThirdPoint(p,E,te.Constants.HALF_PI,g,!0),R=te.PlotUtils.getThirdPoint(p,O,te.Constants.HALF_PI,y,!1),z=te.PlotUtils.getThirdPoint(p,O,te.Constants.HALF_PI,y,!0);return[R,v,p,A,z]},getAttackArrowBodyPoints(e,t,n,i){const o=[],r=[];for(let s=te.PlotUtils.wholeDistance(e),a=te.PlotUtils.getBaseLength(e),c=a*i,u=te.PlotUtils.distance(t,n),f=(c-u)/2,p=0,_=1;_o[0]!==t[0]&&o[1]!==t[1]?o:(n=!0,!1)),n&&i.push(t),i},fineArrow(e,t){if(e.length<2||t.length<2)return;const n=Dr.tailWidthFactor,i=Dr.neckWidthFactor,o=Dr.headWidthFactor,r=Dr.headAngle,s=Dr.neckAngle,a=[];a[0]=e,a[1]=t;const c=a[0],u=a[1],f=te.PlotUtils.getBaseLength(a),p=f*n,_=f*i,g=f*o,y=te.PlotUtils.getThirdPoint(u,c,te.Constants.HALF_PI,p,!0),b=te.PlotUtils.getThirdPoint(u,c,te.Constants.HALF_PI,p,!1),E=te.PlotUtils.getThirdPoint(c,u,r,g,!1),O=te.PlotUtils.getThirdPoint(c,u,r,g,!0),v=te.PlotUtils.getThirdPoint(c,u,s,_,!1),A=te.PlotUtils.getThirdPoint(c,u,s,_,!0),R=[];return R.push(y[0],y[1],v[0],v[1],E[0],E[1],u[0],u[1],O[0],O[1],A[0],A[1],b[0],b[1],c[0],c[1]),l.fromDegreesArray(R)}}};var oO=typeof global=="object"&&global&&global.Object===Object&&global;const rm=oO;var rO=typeof self=="object"&&self&&self.Object===Object&&self,sO=rm||rO||Function("return this")();const Bn=sO;var aO=Bn.Symbol;const Mo=aO;var sm=Object.prototype,cO=sm.hasOwnProperty,lO=sm.toString,Mr=Mo?Mo.toStringTag:void 0;function hO(e){var t=cO.call(e,Mr),n=e[Mr];try{e[Mr]=void 0;var i=!0}catch{}var o=lO.call(e);return i&&(t?e[Mr]=n:delete e[Mr]),o}var uO=Object.prototype,fO=uO.toString;function dO(e){return fO.call(e)}var pO="[object Null]",mO="[object Undefined]",am=Mo?Mo.toStringTag:void 0;function Nr(e){return e==null?e===void 0?mO:pO:am&&am in Object(e)?hO(e):dO(e)}function Lr(e){return e!=null&&typeof e=="object"}var _O=Array.isArray;const zl=_O;function Fr(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var gO="[object AsyncFunction]",yO="[object Function]",wO="[object GeneratorFunction]",bO="[object Proxy]";function cm(e){if(!Fr(e))return!1;var t=Nr(e);return t==yO||t==wO||t==gO||t==bO}var TO=Bn["__core-js_shared__"];const Dl=TO;var lm=function(){var e=/[^.]+$/.exec(Dl&&Dl.keys&&Dl.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function EO(e){return!!lm&&lm in e}var CO=Function.prototype,SO=CO.toString;function Xi(e){if(e!=null){try{return SO.call(e)}catch{}try{return e+""}catch{}}return""}var OO=/[\\^$.*+?()[\]{}|]/g,AO=/^\[object .+?Constructor\]$/,vO=Function.prototype,xO=Object.prototype,PO=vO.toString,RO=xO.hasOwnProperty,IO=RegExp("^"+PO.call(RO).replace(OO,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function zO(e){if(!Fr(e)||EO(e))return!1;var t=cm(e)?IO:AO;return t.test(Xi(e))}function DO(e,t){return e==null?void 0:e[t]}function Ki(e,t){var n=DO(e,t);return zO(n)?n:void 0}var MO=Ki(Bn,"WeakMap");const Ml=MO;var hm=Object.create,NO=function(){function e(){}return function(t){if(!Fr(t))return{};if(hm)return hm(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();const LO=NO;function FO(e,t){var n=-1,i=e.length;for(t||(t=Array(i));++n-1&&e%1==0&&e-1&&e%1==0&&e<=qO}function _m(e){return e!=null&&mm(e.length)&&!cm(e)}var WO=Object.prototype;function Nl(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||WO;return e===n}function YO(e,t){for(var n=-1,i=Array(e);++n-1}function aA(e,t){var n=this.__data__,i=na(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}function oi(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{if(t&&n){this.tooltip.setVisible(!0),this.tooltip.text!==n&&(this.tooltip.dom.innerHTML=n,this.tooltip.text=n);const i=this.tooltip.dom.clientWidth,o=this.tooltip.dom.clientHeight+24;this.tooltip.dom.style.left=`${(t.x-i/2).toFixed(0)}px`,this.tooltip.dom.style.top=`${(t.y-o).toFixed(0)}px`}},setVisible:t=>{this.tooltip.dom.style.opacity=t?"1":"0",this.tooltip.dom.style.zIndex=t?"100":"-1"}});setTimeout(()=>{const t=document.getElementById("mouse-tooltip");t&&(this.tooltip.dom=t)},0)}}const it={layerId:"globeDrawerLayer",dragIconLight:"/src/assets/images/circle_point_icon.svg",dragIcon:"/src/assets/images/point_icon.svg",fill:!0,outline:!0,outlineWidth:2,outlineColor:S.YELLOW,extrudedHeight:0,polylineWidth:8,radius:1,line:!0,lineWidth:2};class ln extends rx{constructor(n,i={}){super();ge(this,"viewer");ge(this,"drawHandler");ge(this,"modifyHandler");ge(this,"okHandler");ge(this,"cancelHandler");ge(this,"drawType","");ge(this,"objId",new Date().getTime());ge(this,"layerDom",document.getElementById("drawPopConfirmLayer"));ge(this,"entity");ge(this,"outlineEntity");ge(this,"position");ge(this,"oldPosition");ge(this,"positions",[]);ge(this,"oldPositions",[]);ge(this,"tempPositions",[]);ge(this,"markers",{});ge(this,"saveMarkers",{});ge(this,"material");ge(this,"outlineMaterial");ge(this,"radiusLineMaterial");ge(this,"lineMaterial");ge(this,"dragIconLight",it.dragIconLight);ge(this,"dragIcon",it.dragIcon);ge(this,"layerId",it.layerId);ge(this,"fill",it.fill);ge(this,"outline",it.outline);ge(this,"outlineWidth",it.outlineWidth);ge(this,"outlineColor",it.outlineColor);ge(this,"extrudedHeight",it.extrudedHeight);ge(this,"polylineWidth",it.polylineWidth);ge(this,"radius",it.radius);ge(this,"line",it.line);ge(this,"lineWidth",it.lineWidth);ge(this,"drawConfig",{material:void 0,outlineMaterial:void 0,radiusLineMaterial:void 0,lineMaterial:void 0,dragIconLight:it.dragIconLight,dragIcon:it.dragIcon,layerId:it.layerId,fill:it.fill,outline:it.outline,outlineWidth:it.outlineWidth,outlineColor:it.outlineColor,extrudedHeight:it.extrudedHeight,polylineWidth:it.polylineWidth,radius:it.radius,line:it.line,lineWidth:it.lineWidth});ge(this,"dialogVisible",()=>{});this.viewer=n,this.objId=new Date().getTime(),Object.keys(i).forEach(o=>{this.drawConfig[o]=i[o]}),setTimeout(()=>{this.init()},0)}init(){const n=document.getElementById("drawPopConfirmLayer");n&&(this.layerDom=n)}createPoint(n,i){const o=this.viewer.entities.add({position:n,label:i.label||{},billboard:{image:i.image||this.drawConfig.dragIconLight,eyeOffset:new hn(new l(0,0,-500)),heightReference:Vo.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}});return o.oid=i.oid,o.layerId=this.drawConfig.layerId,o.flag=i.flag||_e.ANCHOR,o.objId=this.objId,o.drawType=this.drawType,i.needSave?this.saveMarkers[i.oid]=o:this.markers[i.oid]=o,o.flag===_e.ANCHOR&&(o.sid=n==null?void 0:n.sid),o}reCreateAllPoint(){const n=this.tempPositions;for(let i=0;i{const s=this.checkPosition(r.position);if(!s)return;const a=this.positions.length;a===0&&(this.positions.push(s),n=this.createPoint(s,{oid:-1}),this.showRegion2Map()),this.positions.push(s);const c=this.positions.length-2;this.createPoint(s,{oid:c}),a>1&&(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.startModify())},ae.LEFT_CLICK),(o=this.drawHandler)==null||o.setInputAction(r=>{if(this.positions.length<1){this.tooltip.showAt(r.position,"选择起点");return}this.tooltip.showAt(r.position,"选择终点");const s=this.checkPosition(r.endPosition);s&&(n.position=s,this.positions.pop(),this.positions.push(s))},ae.MOUSE_MOVE)}startModify(){let n=!1,i;this.clearDrawHandler(),this.layerShowOrHide(!0),this.modifyHandler=new ve(this.viewer.scene.canvas),this.modifyHandler.setInputAction(o=>{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.positions[s]=r,this.tooltip.setVisible(!1))}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR)return;i=a,n=!0,this.tooltip.showAt(o.position,"移动控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.position,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.positions[s]=r)},ae.MOUSE_MOVE)}showRegion2Map(n){n&&(this.positions=this.cloneDeep(this.oldPositions)),this.drawConfig.material||(this.drawConfig.material=S.fromCssColorString("#ff0").withAlpha(.5)),this.drawConfig.outlineMaterial||(this.drawConfig.outlineMaterial=new Yt({dashLength:16,color:S.fromCssColorString("#f00").withAlpha(.7)}));const i=new Ve(()=>{if(this.positions.length>1){const s=this.positions[0],a=this.positions[1];if(this.isSimpleXYZ(s,a))return;const c=this.getLonLat(s),u=this.getLonLat(a),f=He.algorithm.fineArrow([c.lon,c.lat],[u.lon,u.lat]);return new Oi(f)}else return},!1),o=new Ve(()=>{if(this.positions.length<2)return;const s=this.positions[0],a=this.positions[1];if(this.isSimpleXYZ(s,a))return;const c=this.getLonLat(s),u=this.getLonLat(a),f=He.algorithm.fineArrow([c.lon,c.lat],[u.lon,u.lat]);return f.push(f[0]),f},!1),r={polygon:new _n({hierarchy:i,material:this.drawConfig.material,show:this.drawConfig.fill}),polyline:{positions:o,clampToGround:!0,width:this.drawConfig.outlineWidth,material:this.drawConfig.outlineMaterial,show:this.drawConfig.outline}};this.entity=this.viewer.entities.add(r),this.setPublicParams()}showModifyRegion2Map(){this.startModify(),this._computeTempPositions(),this.showRegion2Map(!0);const n=this.positions;for(let i=0;i{const o=this.checkPosition(i.position);if(!o)return;this.positions.length===0&&(this.positions.push(o),n=this.createPoint(o,{oid:-1}),this.showRegion2Map()),this.positions.push(o);const s=this.positions.length-2;this.createPoint(o,{oid:s})},ae.LEFT_CLICK),this.drawHandler.setInputAction(i=>{if(this.positions.length<1){this.tooltip.showAt(i.position,"选择起点");return}const o=this.positions.length;let r="点击添加下一个点";o>2&&(r+="右键结束绘制"),this.tooltip.showAt(i.position,r);const s=this.checkPosition(i.endPosition);s&&(n.position=s,this.positions.pop(),this.positions.push(s))},ae.MOUSE_MOVE),this.drawHandler.setInputAction(()=>{this.positions.length<3||(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.dialogVisible(!0))},ae.RIGHT_CLICK)}startModify(){let n=!1,i;this.clearDrawHandler(),this.layerShowOrHide(!0),this.modifyHandler=new ve(this.viewer.scene.canvas),this.modifyHandler.setInputAction(o=>{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.tempPositions[s]=r,this.tooltip.setVisible(!1),i.flag===_e.MID_ANCHOR&&this.updateModifyAnchors(s))}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!=="anchor"&&a.flag!=="mid_anchor")return;i=a,n=!0,a.flag===_e.ANCHOR&&this.tooltip.showAt(o.position,"移动控制点"),a.flag===_e.MID_ANCHOR&&this.tooltip.showAt(o.position,"移动创建新的控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.position,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;typeof s=="number"&&s>=0&&(i.flag===_e.ANCHOR?(i.position=r,this.tempPositions[s]=r,this.updateNewMidAnchors(s)):i.flag===_e.MID_ANCHOR&&(i.position=r,this.tempPositions[s]=r))},ae.MOUSE_MOVE)}showRegion2Map(){this.drawConfig.lineMaterial||(this.drawConfig.lineMaterial=new Yt({dashLength:16,color:S.fromCssColorString("#00f").withAlpha(.7)}));const i={polyline:{positions:new Ve(()=>this.positions,!1),clampToGround:!0,width:this.drawConfig.lineWidth,material:this.drawConfig.lineMaterial}};this.entity=this.viewer.entities.add(i),this.setPublicParams()}showModifyRegion2MapCreateEntity(n){n&&(this.tempPositions=this.cloneDeep(this.positions)),this.drawConfig.material||(this.drawConfig.material=S.fromCssColorString("#ff0").withAlpha(.5)),this.drawConfig.lineMaterial||(this.drawConfig.lineMaterial=new Yt({dashLength:16,color:S.fromCssColorString("#00f").withAlpha(.7)}));const i=new Ve(()=>this.tempPositions,!1),o=new Ve(()=>{const s=this.computeBufferLine(this.tempPositions,(this.drawConfig.radius||1)*1e3)||void 0;return new Oi(s)},!1),r={polygon:new _n({hierarchy:o,material:this.drawConfig.material,show:this.drawConfig.fill}),polyline:{positions:i,clampToGround:!0,width:this.drawConfig.lineWidth||2,material:this.drawConfig.lineMaterial,show:this.drawConfig.line}};this.entity=this.viewer.entities.add(r),this.setPublicParams()}showModifyRegion2Map(){this.startModify(),this.computeTempPositions(),this.showModifyRegion2MapCreateEntity(),this.reCreateAllPoint()}computeBufferLine(n,i){const o=[],r=n[0],s=n.length;for(let _=0;_{const s=this.checkPosition(r.position);if(!s)return;const a=this.positions.length;a===0&&(this.positions.push(s),n=this.createPoint(s,{oid:-1}),this.showRegion2Map()),this.positions.push(s);const c=this.positions.length-2;this.createPoint(s,{oid:c}),a>1&&(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.startModify())},ae.LEFT_CLICK),(o=this.drawHandler)==null||o.setInputAction(r=>{if(this.positions.length<1){this.tooltip.showAt(r.position,"选择起点");return}this.tooltip.showAt(r.position,"选择终点");const s=this.checkPosition(r.endPosition);s&&(n.position=s,this.positions.pop(),this.positions.push(s))},ae.MOUSE_MOVE)}startModify(){let n=!1,i;this.clearDrawHandler(),this.layerShowOrHide(!0),this.modifyHandler=new ve(this.viewer.scene.canvas),this.modifyHandler.setInputAction(o=>{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.positions[s]=r,this.tooltip.setVisible(!1))}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR)return;i=a,n=!0,this.tooltip.showAt(o.position,"移动控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.position,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.positions[s]=r)},ae.MOUSE_MOVE)}showRegion2Map(n){n&&(this.positions=this.cloneDeep(this.oldPositions)),this.drawConfig.material||(this.drawConfig.material=S.fromCssColorString("#ff0").withAlpha(.5)),this.drawConfig.outlineMaterial||(this.drawConfig.outlineMaterial=new Yt({dashLength:16,color:S.fromCssColorString("#00f").withAlpha(.7)}));const i=new Ve(()=>{if(this.positions.length>1)return he.fromCartesianArray(this.positions)},!1),o=new Ve(()=>{if(this.positions.length>1){const s=he.fromCartesianArray(this.positions),a=[s.west,s.north,s.east,s.north,s.east,s.south,s.west,s.south,s.west,s.north];return l.fromRadiansArray(a)}else return},!1),r={rectangle:{coordinates:i,material:this.drawConfig.material,show:this.drawConfig.fill},polyline:{positions:o,clampToGround:!0,width:this.drawConfig.outlineWidth,material:this.drawConfig.outlineMaterial,show:this.drawConfig.outline}};this.entity=this.viewer.entities.add(r),this.setPublicParams()}showModifyRegion2Map(){this.showRegion2Map(!0);const n=this.positions;for(let i=0;i{const c=this.checkPosition(a.position);if(!c)return;this.positions.length===0&&(this.positions.push(c),n=this.createPoint(c,{oid:-1}),this.showRegion2Map()),this.positions.push(c);const f=this.positions.length-2;this.createPoint(c,{oid:f})},ae.LEFT_CLICK),(o=this.drawHandler)==null||o.setInputAction(a=>{if(this.positions.length<1){this.tooltip.showAt(a.position,"选择起点");return}this.tooltip.showAt(a.position,"新增控制点,右键结束绘制");const c=this.checkPosition(a.endPosition);c&&(n.position=c,this.positions.pop(),this.positions.push(c))},ae.MOUSE_MOVE),(r=this.drawHandler)==null||r.setInputAction(()=>{this.positions.length<2||(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.startModify())},ae.RIGHT_CLICK),(s=this.drawHandler)==null||s.setInputAction(()=>{this.positions.length<2||(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.startModify())},ae.LEFT_DOUBLE_CLICK)}startModify(){let n=!1,i;this.clearDrawHandler(),this.layerShowOrHide(!0),this.modifyHandler=new ve(this.viewer.scene.canvas),this.modifyHandler.setInputAction(o=>{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.positions[s]=r,this.tooltip.setVisible(!1))}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR)return;i=a,n=!0,this.tooltip.showAt(o.position,"移动控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.position,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.positions[s]=r)},ae.MOUSE_MOVE)}showRegion2Map(n){n&&(this.positions=this.cloneDeep(this.oldPositions)),this.drawConfig.material||(this.drawConfig.material=S.fromCssColorString("#ff0").withAlpha(.5)),this.drawConfig.outlineMaterial||(this.drawConfig.outlineMaterial=new Yt({dashLength:16,color:S.fromCssColorString("#f00").withAlpha(.7)}));const i=new Ve(()=>{if(this.positions.length>1){const s=this.getLonLatArr(this.positions),c=He.algorithm.tailedAttackArrow(s).polygonalPoint;return!c||c.length<3?void 0:new Oi(c)}else return},!1),o=new Ve(()=>{if(this.positions.length<2)return;const s=this.getLonLatArr(this.positions),c=He.algorithm.tailedAttackArrow(s).polygonalPoint;if(!c||c.length<3)return;const u=c[0];return c.push(u),c},!1),r={polygon:new _n({hierarchy:i,material:this.drawConfig.material,show:this.drawConfig.fill}),polyline:{positions:o,clampToGround:!0,width:this.drawConfig.outlineWidth,material:this.drawConfig.outlineMaterial,show:this.drawConfig.outline}};this.entity=this.viewer.entities.add(r),this.setPublicParams()}showModifyRegion2Map(){this.startModify(),this._computeTempPositions(),this.showRegion2Map(!0);const n=this.positions;for(let i=0;i{const s=this.checkPosition(r.position);if(!s)return;this.positions.length===0&&(this.positions.push(s),n=this.createPoint(s,{oid:-1}),this.showRegion2Map()),this.positions.push(s);const c=this.positions.length-2;this.createPoint(s,{oid:c}),this.positions.length>5&&(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.startModify())},ae.LEFT_CLICK),(o=this.drawHandler)==null||o.setInputAction(r=>{if(this.positions.length<1){this.tooltip.showAt(r.position,"选择起点");return}this.tooltip.showAt(r.position,"新增控制点");const s=this.checkPosition(r.endPosition);s&&(n.position=s,this.positions.pop(),this.positions.push(s))},ae.MOUSE_MOVE)}startModify(){let n=!1,i;this.clearDrawHandler(),this.layerShowOrHide(!0),this.modifyHandler=new ve(this.viewer.scene.canvas),this.modifyHandler.setInputAction(o=>{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.positions[s]=r,this.tooltip.setVisible(!1))}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR)return;i=a,n=!0,this.tooltip.showAt(o.position,"移动控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.position,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.positions[s]=r)},ae.MOUSE_MOVE)}showRegion2Map(n){n&&(this.positions=this.cloneDeep(this.oldPositions)),this.drawConfig.material||(this.drawConfig.material=S.fromCssColorString("#ff0").withAlpha(.5)),this.drawConfig.outlineMaterial||(this.drawConfig.outlineMaterial=new Yt({dashLength:16,color:S.fromCssColorString("#f00").withAlpha(.7)}));const i=new Ve(()=>{if(this.positions.length>2)try{const s=this.getLonLatArr(this.positions);this.removeDuplicate(s);const c=He.algorithm.doubleArrow(s).polygonalPoint;return!h(c)||!c||c.length<3?void 0:new Oi(c)}catch{return}else return},!1),o=new Ve(()=>{if(!(this.positions.length<3))try{const s=this.getLonLatArr(this.positions);this.removeDuplicate(s);const c=He.algorithm.doubleArrow(s).polygonalPoint;if(!h(c)||!c||c.length<3)return;const u=c[0];return c.push(u),c}catch{return}},!1),r={polygon:new _n({hierarchy:i,material:this.drawConfig.material,show:this.drawConfig.fill}),polyline:{positions:o,clampToGround:!0,width:this.drawConfig.outlineWidth,material:this.drawConfig.outlineMaterial,show:this.drawConfig.outline}};this.entity=this.viewer.entities.add(r),this.setPublicParams()}showModifyRegion2Map(){this.startModify(),this.computeTempPositions(),this.showRegion2Map(!0);const n=this.positions;for(let i=0;i{const r=this.checkPosition(o.position);r&&(this.position=r,this.entity=new Fn,this.entity.position=r,this.tooltip.setVisible(!1),this.startModify())},ae.LEFT_CLICK),(i=this.drawHandler)==null||i.setInputAction(o=>{this.tooltip.showAt(o.endPosition,"选择位置");const r=this.checkPosition(o.endPosition);r&&(this.position=r,this.entity?this.entity.position=r:this.entity=this.createPoint(this.position,{oid:0}))},ae.MOUSE_MOVE)}startModify(){let n=!1,i;this.clearDrawHandler(),this.layerShowOrHide(!0),this.modifyHandler=new ve(this.viewer.scene.canvas),this.modifyHandler.setInputAction(o=>{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.position=r,this.tooltip.setVisible(!1))}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR)return;i=a,n=!0,this.tooltip.showAt(o.position,"移动位置")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.endPosition,"移动位置");const r=this.checkPosition(o.endPosition);r&&(i.position=r,this.position=r)},ae.MOUSE_MOVE)}reEnterModify(n,i){this.objId=i,this.position=n,this.oldPosition=n,this.entity=void 0,this.entity=this.createPoint(this.position,{oid:0}),this.startModify()}drawOldData(){this.oldPosition&&(this.createPoint(this.oldPosition,{oid:0}),this.position=this.oldPosition)}}class fx extends ln{constructor(n,i={}){super(n,i);ge(this,"viewer");this.viewer=n,this.drawHandler=new ve(n.scene.canvas),this.drawType=st.POS_MEASURE.key}startDraw(){var n,i;this.entity=void 0,this.position=void 0,(n=this.drawHandler)==null||n.setInputAction(o=>{const r=this.checkPosition(o.position);if(!r)return;this.position=r,this.entity.position=r;const s=this.getMeasureTip(this.position);this.entity.label.text=s,this.tooltip.setVisible(!1),this.startModify()},ae.LEFT_CLICK),(i=this.drawHandler)==null||i.setInputAction(o=>{this.tooltip.showAt(o.endPosition,"选择位置");const r=this.checkPosition(o.endPosition);if(r)if(this.position=r,!this.entity)this.entity=this._createPoint(this.position);else{this.entity.position=r;const s=this.getMeasureTip(this.position);this.entity.label.text=s}},ae.MOUSE_MOVE)}startModify(){let n=!1,i;this.clearDrawHandler(),this.layerShowOrHide(!0),this.modifyHandler=new ve(this.viewer.scene.canvas),this.modifyHandler.setInputAction(o=>{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.position=r,this.tooltip.setVisible(!1))}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR)return;i=a,n=!0,this.tooltip.showAt(o.position,"移动位置")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.endPosition,"移动位置");const r=this.checkPosition(o.endPosition);if(!r)return;i.position=r,this.position=r;const s=this.getMeasureTip(this.position);this.entity.label.text=s},ae.MOUSE_MOVE)}_createPoint(n){const o={text:this.getMeasureTip(n),...ra};return this.createPoint(n,{oid:0,label:o})}getMeasureTip(n){const i=this.getLonLat(n);return i.alt=parseFloat(i.alt.toFixed(1)),i.lon=parseFloat(i.lon.toFixed(3)),i.lat=parseFloat(i.lat.toFixed(3)),`经度:${i.lon}, 纬度:${i.lat} 海拔: ${i.alt}米`}}class dx extends ln{constructor(n,i={}){super(n,i);ge(this,"viewer");this.viewer=n,this.drawHandler=new ve(n.scene.canvas),this.drawType=st.SPACE_DIS_MEASURE.key}startDraw(){var i,o,r;let n;this.positions=[],(i=this.drawHandler)==null||i.setInputAction(s=>{const a=this.checkPosition(s.position);if(!a)return;this.positions.length===0&&(this.positions.push(a),n=this.createPoint(a,{oid:-1}),this.showPolyline2Map()),this.positions.push(a);const u=this.positions.length-2;this.createPoint(a,{oid:u}),this.entity.position=a;const f=this.getMeasureTip(this.positions);this.entity.label.text=f},ae.LEFT_CLICK),(o=this.drawHandler)==null||o.setInputAction(s=>{if(this.positions.length<1){this.tooltip.showAt(s.endPosition,"选择起点");return}let a="点击添加下一个点";this.positions.length>2&&(a+="或右键结束绘制"),this.tooltip.showAt(s.endPosition,a);const u=this.checkPosition(s.endPosition);if(!u)return;n.position=u,this.positions.pop(),this.positions.push(u),this.entity.position=u;const f=this.getMeasureTip(this.positions);this.entity.label.text=f},ae.MOUSE_MOVE),(r=this.drawHandler)==null||r.setInputAction(()=>{this.positions.length<3||(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.clearDrawing(),this.showModifyPolyline2Map())},ae.RIGHT_CLICK)}showPolyline2Map(n){this.drawConfig.material||(this.drawConfig.material=new vi({glowPower:.25,color:S.fromCssColorString("#00f").withAlpha(.9)}));const i=new Ve(()=>n?this.tempPositions:this.positions,!1),o=this.positions.length,r=this.positions[o-1],s=this.getMeasureTip(this.tempPositions),a={position:r,label:{text:s,...ra},polyline:{positions:i,clampToGround:!1,width:this.drawConfig.polylineWidth,material:this.drawConfig.material}};this.entity=this.viewer.entities.add(a),this.setPublicParams()}showModifyPolyline2Map(){this.startModify(),this.computeTempPositions(),this.showPolyline2Map(!0);const n=this.tempPositions;for(let i=0;i{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;if(typeof s=="number"&&s>=0){i.position=r,this.tempPositions[s]=r,this.tooltip.setVisible(!1),i.flag===_e.MID_ANCHOR&&this.updateModifyAnchors(s),this.entity.position=r;const a=this.getMeasureTip(this.tempPositions);this.entity.label.text=a}}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR&&a.flag!==_e.MID_ANCHOR)return;i=a,n=!0,a.flag===_e.ANCHOR&&this.tooltip.showAt(o.position,"移动控制点"),a.flag===_e.MID_ANCHOR&&this.tooltip.showAt(o.position,"移动创建新的控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.position,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;if(typeof s=="number"&&s>=0){i.flag===_e.ANCHOR?(i.position=r,this.tempPositions[s]=r):i.flag===_e.MID_ANCHOR&&(i.position=r,this.tempPositions[s]=r),this.entity.position=r;const a=this.getMeasureTip(this.tempPositions);this.entity.label.text=a}},ae.MOUSE_MOVE)}computeLineDis3d(n){let i=0;for(let o=1;o{const a=this.checkPosition(s.position);if(!a)return;this.positions.length===0&&(this.positions.push(a),n=this.createPoint(a,{oid:-1}),this.showPolyline2Map()),this.positions.push(a);const u=this.positions.length-2;this.createPoint(a,{oid:u}),this.entity.position=a;const f=this.getMeasureTip(this.positions);this.entity.label.text=f},ae.LEFT_CLICK),(o=this.drawHandler)==null||o.setInputAction(s=>{if(this.positions.length<1){this.tooltip.showAt(s.endPosition,"选择起点");return}let a="点击添加下一个点";this.positions.length>2&&(a+="或右键结束绘制"),this.tooltip.showAt(s.endPosition,a);const u=this.checkPosition(s.endPosition);if(!u)return;n.position=u,this.positions.pop(),this.positions.push(u),this.entity.position=u;const f=this.getMeasureTip(this.positions);this.entity.label.text=f},ae.MOUSE_MOVE),(r=this.drawHandler)==null||r.setInputAction(()=>{this.positions.length<3||(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.clearDrawing(),this.showModifyPolyline2Map())},ae.RIGHT_CLICK)}showPolyline2Map(n){this.drawConfig.material||(this.drawConfig.material=new vi({glowPower:.25,color:S.fromCssColorString("#00f").withAlpha(.9)}));const i=new Ve(()=>n?this.tempPositions:this.positions,!1),o=this.positions.length,r=this.positions[o-1],s=n?this.getMeasureTip(this.tempPositions):"",a={position:r,label:{text:s,...ra},polyline:{positions:i,clampToGround:!0,width:this.drawConfig.polylineWidth,material:this.drawConfig.material}};this.entity=this.viewer.entities.add(a),this.setPublicParams()}showModifyPolyline2Map(){this.startModify(),this.computeTempPositions(),this.showPolyline2Map(!0);const n=this.tempPositions;for(let i=0;i{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;if(typeof s=="number"&&s>=0){i.position=r,this.tempPositions[s]=r,this.tooltip.setVisible(!1),i.flag===_e.MID_ANCHOR&&this.updateModifyAnchors(s),this.entity.position=r;const a=this.getMeasureTip(this.tempPositions);this.entity.label.text=a}}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR&&a.flag!==_e.MID_ANCHOR)return;i=a,n=!0,a.flag===_e.ANCHOR&&this.tooltip.showAt(o.position,"移动控制点"),a.flag===_e.MID_ANCHOR&&this.tooltip.showAt(o.position,"移动创建新的控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.position,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;if(typeof s=="number"&&s>=0){i.flag===_e.ANCHOR?(i.position=r,this.tempPositions[s]=r,this.updateNewMidAnchors(s)):i.flag===_e.MID_ANCHOR&&(i.position=r,this.tempPositions[s]=r),this.entity.position=r;const a=this.getMeasureTip(this.tempPositions);this.entity.label.text=a}},ae.MOUSE_MOVE)}getStick2GroundLine(n){const i=FS.generateArc({positions:n,granularity:.01}),o=[];for(let s=0;s{const a=this.checkPosition(s.position);if(!a)return;this.positions.length===0&&(this.positions.push(a),n=this.createPoint(a,{oid:-1}),this.showRegion2Map()),this.positions.push(a);const u=this.positions.length-2;this.createPoint(a,{oid:u}),this.entity.position=a;const f=this.getMeasureTip(this.positions);this.entity.label.text=f},ae.LEFT_CLICK),(o=this.drawHandler)==null||o.setInputAction(s=>{if(this.positions.length<1){this.tooltip.showAt(s.endPosition,"选择起点");return}let a="点击添加下一个点";this.positions.length>2&&(a+="或右键结束绘制"),this.tooltip.showAt(s.endPosition,a);const u=this.checkPosition(s.endPosition);if(!u)return;n.position=u,this.positions.pop(),this.positions.push(u),this.entity.position=u;const f=this.getMeasureTip(this.positions);this.entity.label.text=f},ae.MOUSE_MOVE),(r=this.drawHandler)==null||r.setInputAction(()=>{this.positions.length<4||(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.clearDrawing(),this.showModifyRegion2Map())},ae.RIGHT_CLICK)}showRegion2Map(n){this.drawConfig.material||(this.drawConfig.material=S.fromCssColorString("#ff0").withAlpha(.5)),this.drawConfig.outlineMaterial||(this.drawConfig.outlineMaterial=new Yt({dashLength:16,color:S.fromCssColorString("#00f").withAlpha(.7)}));const i=new Ve(()=>{if(this.positions.length>2)return new Oi(n?this.tempPositions:this.positions)},!1),o=new Ve(()=>{if(this.positions.length>1){const u=this.cloneDeep(n?this.tempPositions:this.positions),f=n?this.tempPositions[0]:this.positions[0];return u.push(f),u}else return},!1),r=n?this.tempPositions.length:this.positions.length,s=n?this.tempPositions[r-1]:this.positions[r-1],a=n?this.getMeasureTip(this.tempPositions):"",c={position:s,label:{text:a,...ra},polygon:new _n({hierarchy:i,material:this.drawConfig.material,show:this.drawConfig.fill}),polyline:{positions:o,clampToGround:!0,width:this.drawConfig.outlineWidth,material:this.drawConfig.outlineMaterial,show:this.drawConfig.outline}};this.entity=this.viewer.entities.add(c),this.setPublicParams()}showModifyRegion2Map(){this.startModify(),this._computeTempPositions(),this.showRegion2Map(!0);const n=this.tempPositions;for(let i=0;i{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;if(typeof s=="number"&&s>=0){i.position=r,this.tempPositions[s]=r,this.tooltip.setVisible(!1),i.flag===_e.MID_ANCHOR&&this._updateModifyAnchors(s),this.entity.position=r;const a=this.getMeasureTip(this.tempPositions);this.entity.label.text=a}}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR&&a.flag!==_e.MID_ANCHOR)return;i=a,n=!0,a.flag===_e.ANCHOR&&this.tooltip.showAt(o.position,"移动控制点"),a.flag===_e.MID_ANCHOR&&this.tooltip.showAt(o.position,"移动创建新的控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.endPosition,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;if(typeof s=="number"&&s>=0){i.flag===_e.ANCHOR?(i.position=r,this.tempPositions[s]=r,this.updateNewMidAnchors(s)):i.flag===_e.MID_ANCHOR&&(i.position=r,this.tempPositions[s]=r),this.entity.position=r;const a=this.getMeasureTip(this.tempPositions);this.entity.label.text=a}},ae.MOUSE_MOVE)}computeLineDis3d(n){let i=0;for(let o=1;o2){const r=this.computeArea(n);o+=` 面积:${r.toFixed(3)}平方千米`}return o}computeArea(n){const i=[];for(let s=0;s{const a=this.checkPosition(s.position);if(!a)return;this.positions.length===0&&(this.positions.push(a),n=this.createPoint(a,{oid:-1}),this.showPolyline2Map()),this.positions.push(a);const u=this.positions.length-2;this.createPoint(a,{oid:u})},ae.LEFT_CLICK),(o=this.drawHandler)==null||o.setInputAction(s=>{if(this.positions.length<1){this.tooltip.showAt(s.endPosition,"选择起点");return}let a="点击添加下一个点";this.positions.length>2&&(a+="或右键结束绘制"),this.tooltip.showAt(s.endPosition,a);const u=this.checkPosition(s.endPosition);u&&(n.position=u,this.positions.pop(),this.positions.push(u))},ae.MOUSE_MOVE),(r=this.drawHandler)==null||r.setInputAction(()=>{this.positions.length<3||(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.clearDrawing(),this.showModifyPolyline2Map())},ae.RIGHT_CLICK)}showPolyline2Map(n){this.drawConfig.material||(this.drawConfig.material=new vi({glowPower:.25,color:S.fromCssColorString("#00f").withAlpha(.9)}));const o={polyline:{positions:new Ve(()=>n?this.tempPositions:this.positions,!1),clampToGround:!0,width:this.drawConfig.polylineWidth,material:this.drawConfig.material}};this.entity=this.viewer.entities.add(o),this.setPublicParams()}showModifyPolyline2Map(){this.layerShowOrHide(!0),this.startModify(),this.computeTempPositions(),this.showPolyline2Map(!0),this.reCreateAllPoint()}startModify(){let n=!1,i;this.clearDrawHandler(),this.modifyHandler=new ve(this.viewer.scene.canvas),this.modifyHandler.setInputAction(o=>{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.tempPositions[s]=r,this.tooltip.setVisible(!1),i.flag===_e.MID_ANCHOR&&this.updateModifyAnchors(s))}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR&&a.flag!==_e.MID_ANCHOR)return;i=a,n=!0,a.flag===_e.ANCHOR&&this.tooltip.showAt(o.position,"移动控制点"),a.flag===_e.MID_ANCHOR&&this.tooltip.showAt(o.position,"移动创建新的控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.position,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;typeof s=="number"&&s>=0&&(i.flag===_e.ANCHOR?(i.position=r,this.tempPositions[s]=r,this.updateNewMidAnchors(s)):i.flag===_e.MID_ANCHOR&&(i.position=r,this.tempPositions[s]=r))},ae.MOUSE_MOVE)}reEnterModify(n,i){this.objId=i,this.positions=n,this.showModifyPolyline2Map()}drawOldData(){this.showPolyline2Map()}}class gx extends ln{constructor(n,i={}){super(n,i);ge(this,"viewer");this.viewer=n,this.drawHandler=new ve(n.scene.canvas),this.drawType=st.CIRCLE.key}startDraw(){var i,o;let n;this.positions=[],(i=this.drawHandler)==null||i.setInputAction(r=>{const s=this.checkPosition(r.position);if(!s)return;const a=this.positions.length;a===0&&(this.positions.push(s),n=this.createPoint(s,{oid:-1}),this.leftClickEvent(s)),this.positions.push(s),a>0&&this.createPoint(s,{oid:1}),a>1&&(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.startModify())},ae.LEFT_CLICK),(o=this.drawHandler)==null||o.setInputAction(r=>{if(this.positions.length<1){this.tooltip.showAt(r.endPosition,"选择起点");return}this.tooltip.showAt(r.endPosition,"选择终点");const s=this.checkPosition(r.endPosition);s&&(n.position=s,this.positions.pop(),this.positions.push(s))},ae.MOUSE_MOVE)}leftClickEvent(n){this.createCenter(n,0),this.showRegion2Map(),this.showCircleOutline2Map()}showRegion2Map(n){n&&(this.positions=this.cloneDeep(this.oldPositions)),this.drawConfig.material||(this.drawConfig.material=S.fromCssColorString("#ff0").withAlpha(.5)),this.drawConfig.radiusLineMaterial==null&&(this.drawConfig.radiusLineMaterial=new Yt({dashLength:16,color:S.fromCssColorString("#00f").withAlpha(.7)}));const i=new Ve(()=>{if(this.positions.length>1){let c=this.computeCircleRadius3D(this.positions);c=parseFloat((c/1e3).toFixed(3)),this.entity.label.text=`${c}km`;const u=this.computeCirclePolygon(this.positions);return new Oi(u)}else return},!1),o=new Ve(()=>{if(this.positions.length>1)return this.positions},!1),r=new Ve(()=>{if(this.positions.length>1){const c=this.positions[0],u=this.positions[1];return this.computeCenterPotition(c,u)}else return},!1);let s="";n&&(s=this.computeCircleRadius3D(this.positions),s=`${(s/1e3).toFixed(3)}km`);const a={position:r,label:{text:s,font:"14px Helvetica",fillColor:S.SKYBLUE,outlineColor:S.BLACK,outlineWidth:1,style:Mp.FILL_AND_OUTLINE,eyeOffset:new hn(new l(0,0,-9e3)),pixelOffset:new L(16,16),disableDepthTestDistance:Number.POSITIVE_INFINITY},polygon:new _n({hierarchy:i,material:this.drawConfig.material,fill:this.drawConfig.fill,outline:this.drawConfig.outline,outlineWidth:this.drawConfig.outlineWidth,outlineColor:this.drawConfig.outlineColor}),polyline:{positions:o,clampToGround:!0,width:this.drawConfig.lineWidth,material:this.drawConfig.radiusLineMaterial,disableDepthTestDistance:Number.POSITIVE_INFINITY}};this.entity=this.viewer.entities.add(a),this.setPublicParams()}showModifyRegion2Map(){this.showRegion2Map(!0),this.createCenter(this.positions[0],0),this.createPoint(this.positions[1],{oid:1})}showCircleOutline2Map(){this.drawConfig.outlineMaterial||(this.drawConfig.outlineMaterial=new Yt({dashLength:16,color:S.fromCssColorString("#f00").withAlpha(.7)}));const i={polyline:{positions:new Ve(()=>this.computeCirclePolygon(this.positions),!1),clampToGround:!0,width:this.drawConfig.outlineWidth,material:this.drawConfig.outlineMaterial}};this.drawConfig.outlineEntity=this.viewer.entities.add(i),this.drawConfig.outlineEntity.layerId=this.drawConfig.layerId,this.drawConfig.outlineEntity.objId=this.objId,this.drawConfig.outlineEntity.drawType=this.drawType}startModify(){let n=!1,i;this.clearDrawHandler(),this.layerShowOrHide(!0),this.modifyHandler=new ve(this.viewer.scene.canvas),this.modifyHandler.setInputAction(o=>{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.positions[s]=r,this.tooltip.setVisible(!1))}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR)return;i=a,n=!0,this.tooltip.showAt(o.position,"移动控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.position,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.positions[s]=r)},ae.MOUSE_MOVE)}createCenter(n,i){return this.createPoint(n,{oid:i,image:this.drawConfig.dragIcon,needSave:!0})}computeCirclePolygon(n){try{if(!n||n.length<2)return;const i=n[0],o=this.computeCircleRadius3D(n);return this.computeCirclePolygon2(i,o)}catch{return}}computeCirclePolygon2(n,i){try{if(!n||i<=0)return;const o=XS.computeEllipsePositions({center:n,semiMajorAxis:i,semiMinorAxis:i,rotation:0,granularity:.005},!1,!0);if(!o||!o.outerPositions)return;const r=l.unpackArray(o.outerPositions),s=r[0];return r[r.length]=s,r}catch{return}}computeCircleRadius3D(n){const i=n[0],o=n[1],r=(i.x-o.x)**2,s=(i.y-o.y)**2,a=(i.z-o.z)**2;return Math.sqrt(r+s+a)}reEnterModify(n,i){this.objId=i,this.positions=n,this.oldPositions=n,this.showModifyRegion2Map(),this.showCircleOutline2Map(),this.startModify()}drawOldData(){this.createCenter(this.oldPositions[0],0),this.showRegion2Map(!0),this.showCircleOutline2Map()}}class yx extends ln{constructor(n,i={}){super(n,i);ge(this,"viewer");this.viewer=n,this.drawHandler=new ve(n.scene.canvas),this.drawType=st.POLYGON.key}startDraw(){var i,o,r;let n;this.positions=[],(i=this.drawHandler)==null||i.setInputAction(s=>{const a=this.checkPosition(s.position);if(!a)return;this.positions.length===0&&(this.positions.push(a),n=this.createPoint(a,{oid:-1}),this.showRegion2Map()),this.positions.push(a);const u=this.positions.length-2;this.createPoint(a,{oid:u})},ae.LEFT_CLICK),(o=this.drawHandler)==null||o.setInputAction(s=>{if(this.positions.length<1){this.tooltip.showAt(s.endPosition,"选择起点");return}let a="点击添加下一个点";this.positions.length>2&&(a+="或右键结束绘制"),this.tooltip.showAt(s.endPosition,a);const u=this.checkPosition(s.endPosition);u&&(n.position=u,this.positions.pop(),this.positions.push(u))},ae.MOUSE_MOVE),(r=this.drawHandler)==null||r.setInputAction(()=>{this.positions.length<4||(this.positions.pop(),this.viewer.entities.remove(n),this.tooltip.setVisible(!1),this.clearDrawing(),this.showModifyRegion2Map())},ae.RIGHT_CLICK)}showRegion2Map(n){this.drawConfig.material||(this.drawConfig.material=S.fromCssColorString("#ff0").withAlpha(.5)),this.drawConfig.outlineMaterial||(this.drawConfig.outlineMaterial=new Yt({dashLength:16,color:S.fromCssColorString("#00f").withAlpha(.7)}));const i=new Ve(()=>{if(this.positions.length>2)return new Oi(n?this.tempPositions:this.positions)},!1),o=new Ve(()=>{if(this.positions.length>1){const s=this.cloneDeep(n?this.tempPositions:this.positions),a=n?this.tempPositions[0]:this.positions[0];return s.push(a),s}else return},!1),r={polygon:new _n({hierarchy:i,material:this.drawConfig.material,show:this.drawConfig.fill}),polyline:{positions:o,clampToGround:!0,width:this.drawConfig.outlineWidth,material:this.drawConfig.outlineMaterial,show:this.drawConfig.outline}};this.entity=this.viewer.entities.add(r),this.setPublicParams()}showModifyRegion2Map(){this.startModify(),this._computeTempPositions(),this.showRegion2Map(!0),this.reCreateAllPoint()}startModify(){let n=!1,i;this.clearDrawHandler(),this.layerShowOrHide(!0),this.modifyHandler=new ve(this.viewer.scene.canvas),this.modifyHandler.setInputAction(o=>{const r=this.checkPosition(o.position);if(r)if(n){n=!1;const s=i.oid;typeof s=="number"&&s>=0&&(i.position=r,this.tempPositions[s]=r,this.tooltip.setVisible(!1),i.flag===_e.MID_ANCHOR&&this._updateModifyAnchors(s))}else{const s=this.checkModifyPosition(o.position);if(!s)return;const a=s.id;if(a.layerId!==this.drawConfig.layerId||a.flag!==_e.ANCHOR&&a.flag!==_e.MID_ANCHOR)return;i=a,n=!0,a.flag===_e.ANCHOR&&this.tooltip.showAt(o.position,"移动控制点"),a.flag===_e.MID_ANCHOR&&this.tooltip.showAt(o.position,"移动创建新的控制点")}},ae.LEFT_CLICK),this.modifyHandler.setInputAction(o=>{if(!n)return;this.tooltip.showAt(o.endPosition,"移动控制点");const r=this.checkPosition(o.endPosition);if(!r)return;const s=i.oid;typeof s=="number"&&s>=0&&(i.flag===_e.ANCHOR?(i.position=r,this.tempPositions[s]=r,this._updateNewMidAnchors(s)):i.flag===_e.MID_ANCHOR&&(i.position=r,this.tempPositions[s]=r))},ae.MOUSE_MOVE)}_updateNewMidAnchors(n){if(n==null)return;let i=null,o=null,r=null,s=null;const a=this.tempPositions.length;n===0?(i=a-2,o=a-1,r=n+1,s=n+2):n===a-2?(i=n-2,o=n-1,r=a-1,s=0):(i=n-2,o=n-1,r=n+1,s=n+2);const c=this.tempPositions[i],u=this.tempPositions[n],f=this.tempPositions[s],p=this.computeCenterPotition(c,u),_=this.computeCenterPotition(f,u);this.tempPositions[o]=p,this.tempPositions[r]=_,this.markers[o].position=p,this.markers[r].position=_}reEnterModify(n,i){this.objId=i,this.positions=n,this.showModifyRegion2Map()}drawOldData(){this.showRegion2Map()}}const wx={DrawGraphLine:_x,DrawGraphPolygon:yx,DrawGraphCircle:gx,DrawGraphStraightArrow:sx,DrawGraphBuffer:ax,DrawGraphRectangle:cx,DrawGraphAttactArrow:lx,DrawGraphPincerArrow:hx,DrawGraphPoint:ux,DrawGraphPosMeasure:fx,DrawGraphSpaceDisMeasure:dx,DrawGraphStickDisMeasure:px,DrawGraphAreaMeasure:mx},aa=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));qe.DrawFunc=wx,Object.defineProperty(qe,Symbol.toStringTag,{value:"Module"})});