Agriculture-front-end/public/Cesium/Cesium.js

14466 lines
3.7 MiB
JavaScript
Raw Normal View History

2023-04-23 09:41:12 +08:00
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.104
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
var Cesium=(()=>{var Exe=Object.create;var n3=Object.defineProperty;var bxe=Object.getOwnPropertyDescriptor;var Sxe=Object.getOwnPropertyNames;var vxe=Object.getPrototypeOf,wxe=Object.prototype.hasOwnProperty;var W_=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var tl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Dxe=(e,t)=>{for(var n in t)n3(e,n,{get:t[n],enumerable:!0})},zK=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sxe(t))!wxe.call(e,o)&&o!==n&&n3(e,o,{get:()=>t[o],enumerable:!(i=bxe(t,o))||i.enumerable});return e};var Do=(e,t,n)=>(n=e!=null?Exe(vxe(e)):{},zK(t||!e||!e.__esModule?n3(n,"default",{value:e,enumerable:!0}):n,e)),Ixe=e=>zK(n3({},"__esModule",{value:!0}),e);var i3=tl((D0t,GK)=>{var Uh=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)};Uh.prototype.init_seed=function(e){for(this.mt[0]=e>>>0,this.mti=1;this.mti<this.N;this.mti++){var e=this.mt[this.mti-1]^this.mt[this.mti-1]>>>30;this.mt[this.mti]=(((e&4294901760)>>>16)*1812433253<<16)+(e&65535)*1812433253+this.mti,this.mt[this.mti]>>>=0}};Uh.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};Uh.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<this.N-this.M;n++)e=this.mt[n]&this.UPPER_MASK|this.mt[n+1]&this.LOWER_MASK,this.mt[n]=this.mt[n+this.M]^e>>>1^t[e&1];for(;n<this.N-1;n++)e=this.mt[n]&this.UPPER_MASK|this.mt[n+1]&this.LOWER_MASK,this.mt[n]=this.mt[n+(this.M-this.N)]^e>>>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};Uh.prototype.random_int31=function(){return this.random_int()>>>1};Uh.prototype.random_incl=function(){return this.random_int()*(1/4294967295)};Uh.prototype.random=function(){return this.random_int()*(1/4294967296)};Uh.prototype.random_excl=function(){return(this.random_int()+.5)*(1/4294967296)};Uh.prototype.random_long=function(){var e=this.random_int()>>>5,t=this.random_int()>>>6;return(e*67108864+t)*(1/9007199254740992)};GK.exports=Uh});var bJ=tl((JC,ZC)=>{/*! https://mths.be/punycode v1.4.0 by @mathias */(function(e){var t=typeof JC=="object"&&JC&&!JC.nodeType&&JC,n=typeof ZC=="object"&&ZC&&!ZC.nodeType&&ZC,i=typeof global=="object"&&global;(i.global===i||i.window===i||i.self===i)&&(e=i);var o,r=2147483647,s=36,a=1,c=26,l=38,f=700,d=72,p=128,g="-",h=/^xn--/,A=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,C={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},T=s-a,E=Math.floor,S=String.fromCharCode,w;function D(V){throw new RangeError(C[V])}function M(V,G){for(var U=V.length,q=[];U--;)q[U]=G(V[U]);return q}function O(V,G){var U=V.split("@"),q="";U.length>1&&(q=U[0]+"@",V=U[1]),V=V.replace(x,".");var Y=V.split("."),Q=M(Y,G).join(".");return q+Q}function L(V){for(var G=[],U=0,q=V.length,Y,Q;U<q;)Y=V.charCodeAt(U++),Y>=55296&&Y<=56319&&U<q?(Q=V.charCodeAt(U++),(Q&64512)==56320?G.push(((Y&1023)<<10)+(Q&1023)+65536):(G.push(Y),U--)):G.push(
* URI.js - Mutating URLs
* IPv6 Support
*
* 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,t){"use strict";typeof b3=="object"&&b3.exports?b3.exports=t():typeof define=="function"&&define.amd?define(t):e.IPv6=t(e)})(SJ,function(e){"use strict";var t=e&&e.IPv6;function n(o){var r=o.toLowerCase(),s=r.split(":"),a=s.length,c=8;s[0]===""&&s[1]===""&&s[2]===""?(s.shift(),s.shift()):s[0]===""&&s[1]===""?s.shift():s[a-1]===""&&s[a-2]===""&&s.pop(),a=s.length,s[a-1].indexOf(".")!==-1&&(c=7);var l;for(l=0;l<a&&s[l]!=="";l++);if(l<c)for(s.splice(l,1,"0000");s.length<c;)s.splice(l,0,"0000");for(var f,d=0;d<c;d++){f=s[d].split("");for(var p=0;p<3&&(f[0]==="0"&&f.length>1);p++)f.splice(0,1);s[d]=f.join("")}var g=-1,h=0,A=0,x=-1,C=!1;for(d=0;d<c;d++)C?s[d]==="0"?A+=1:(C=!1,A>h&&(g=x,h=A)):s[d]==="0"&&(C=!0,x=d,A=1);A>h&&(g=x,h=A),h>1&&s.splice(g,h,""),a=s.length;var T="";for(s[0]===""&&(T=":"),d=0;d<a&&(T+=s[d],d!==a-1);d++)T+=":";return s[a-1]===""&&(T+=":"),T}function i(){return e.IPv6===this&&(e.IPv6=t),this}return{best:n,noConflict:i}})});var DJ=tl((wJ,S3)=>{/*!
* URI.js - Mutating URLs
* Second Level Domain (SLD) Support
*
* 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,t){"use strict";typeof S3=="object"&&S3.exports?S3.exports=t():typeof define=="function"&&define.amd?define(t):e.SecondLevelDomains=t(e)})(wJ,function(e){"use strict";var t=e&&e.SecondLevelDomains,n={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ",do:" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ",in:" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow l
* 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,t){"use strict";typeof v3=="object"&&v3.exports?v3.exports=t(bJ(),vJ(),DJ()):typeof define=="function"&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],t):e.URI=t(e.punycode,e.IPv6,e.SecondLevelDomains,e)})(IJ,function(e,t,n,i){"use strict";var o=i&&i.URI;function r(b,v){var I=arguments.length>=1,R=arguments.length>=2;if(!(this instanceof r))return I?R?new r(b,v):new r(b):new r;if(b===void 0){if(I)throw new TypeError("undefined is not a valid argument for URI");typeof location<"u"?b=location.href+"":b=""}if(b===null&&I)throw new TypeError("null is not a valid argument for URI");return this.href(b),v!==void 0?this.absoluteTo(v):this}function s(b){return/^[0-9]+$/.test(b)}r.version="1.19.11";var a=r.prototype,c=Object.prototype.hasOwnProperty;function l(b){return b.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function f(b){return b===void 0?"Undefined":String(Object.prototype.toString.call(b)).slice(8,-1)}function d(b){return f(b)==="Array"}function p(b,v){var I={},R,F;if(f(v)==="RegExp")I=null;else if(d(v))for(R=0,F=v.length;R<F;R++)I[v[R]]=!0;else I[v]=!0;for(R=0,F=b.length;R<F;R++){var z=I&&I[b[R]]!==void 0||!I&&v.test(b[R]);z&&(b.splice(R,1),F--,R--)}return b}function g(b,v){var I,R;if(d(v)){for(I=0,R=v.length;I<R;I++)if(!g(b,v[I]))return!1;return!0}var F=f(v);for(I=0,R=b.length;I<R;I++)if(F==="RegExp"){if(typeof b[I]=="string"&&b[I].match(v))return!0}else if(b[I]===v)return!0;return!1}function h(b,v){if(!d(b)||!d(v)||b.length!==v.length)return!1;b.sort(),v.sort();for(var I=0,R=b.length;I<R;I++)if(b[I]!==v[I])return!1;return!0}function A(b){var v=/^\/+|\/+$/g;return b.replace(v,"")}r._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,preventInvalidHostname:r.preventInvalidHostname,duplicateQueryParameters:r.duplicateQueryParameters,escapeQuerySpace:r.escapeQuerySpace}},r.preventInvalidHostname=!1,r.duplicateQueryParameters=!1,r.escapeQuerySpace=!0,r.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,r.idn_expression=/[^a-z0-9\._-]/i,r.punycode_expression=/(xn--)/i,r.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,r.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,r.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig,r.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},r.leading_whitespace_expression=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,r.ascii_tab_whitespace=/[\u0009\u000A\u000D]+/g,r.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},r.hostProtocols=["http","https"],r.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,r.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var f=Object.hasOwnProperty,d=Object.setPrototypeOf,p=Object.isFrozen,g=Object.getPrototypeOf,h=Object.getOwnPropertyDescriptor,A=Object.freeze,x=Object.seal,C=Object.create,T=typeof Reflect<"u"&&Reflect,E=T.apply,S=T.construct;E||(E=function(Se,wt,Kt){return Se.apply(wt,Kt)}),A||(A=function(Se){return Se}),x||(x=function(Se){return Se}),S||(S=function(Se,wt){return i(Se,o(wt))});var w=F(Array.prototype.forEach),D=F(Array.prototype.pop),M=F(Array.prototype.push),O=F(String.prototype.toLowerCase),L=F(String.prototype.toString),N=F(String.prototype.match),_=F(String.prototype.replace),b=F(String.prototype.indexOf),v=F(String.prototype.trim),I=F(RegExp.prototype.test),R=z(TypeError);function F(pe){return function(Se){for(var wt=arguments.length,Kt=new Array(wt>1?wt-1:0),Kn=1;Kn<wt;Kn++)Kt[Kn-1]=arguments[Kn];return E(pe,Se,Kt)}}function z(pe){return function(){for(var Se=arguments.length,wt=new Array(Se),Kt=0;Kt<Se;Kt++)wt[Kt]=arguments[Kt];return S(pe,wt)}}function V(pe,Se,wt){wt=wt||O,d&&d(pe,null);for(var Kt=Se.length;Kt--;){var Kn=Se[Kt];if(typeof Kn=="string"){var Bo=wt(Kn);Bo!==Kn&&(p(Se)||(Se[Kt]=Bo),Kn=Bo)}pe[Kn]=!0}return pe}function G(pe){var Se=C(null),wt;for(wt in pe)E(f,pe,[wt])===!0&&(Se[wt]=pe[wt]);return Se}function U(pe,Se){for(;pe!==null;){var wt=h(pe,Se);if(wt){if(wt.get)return F(wt.get);if(typeof wt.value=="function")return F(wt.value)}pe=g(pe)}function Kt(Kn){return console.warn("fallback value for",Kn),null}return Kt}var q=A(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Y=A(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Q=A(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),W=A(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),K=A(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),J=A(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ge=A(["#text"]),Ce=A(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","
`+ks),FC&&(ks=_(ks,Kf," "),ks=_(ks,or," "),ks=_(ks,Pa," ")),ji&&Z2?ji.createHTML(ks):ks},Se.setConfig=function(bn){zH(bn),LH=!0},Se.clearConfig=function(){HC=null,LH=!1},Se.isValidAttribute=function(bn,we,At){HC||zH({});var Yt=Vs(bn),co=Vs(we);return FK(Yt,co,At)},Se.addHook=function(bn,we){typeof we=="function"&&(Lo[bn]=Lo[bn]||[],M(Lo[bn],we))},Se.removeHook=function(bn){if(Lo[bn])return D(Lo[bn])},Se.removeHooks=function(bn){Lo[bn]&&(Lo[bn]=[])},Se.removeAllHooks=function(){Lo={}},Se}var _e=Qe();return _e})});var Xoe=tl((hmn,qoe)=>{"use strict";qoe.exports=P4e;var XO=1e20;function P4e(e,t){t||(t={});var n=t.cutoff==null?.25:t.cutoff,i=t.radius==null?8:t.radius,o=t.channel||0,r,s,a,c,l,f,d,p,g,h,A;if(ArrayBuffer.isView(e)||Array.isArray(e)){if(!t.width||!t.height)throw Error("For raw data width and height should be provided by options");r=t.width,s=t.height,c=e,t.stride?f=t.stride:f=Math.floor(e.length/r/s)}else window.HTMLCanvasElement&&e instanceof window.HTMLCanvasElement?(p=e,d=p.getContext("2d"),r=p.width,s=p.height,g=d.getImageData(0,0,r,s),c=g.data,f=4):window.CanvasRenderingContext2D&&e instanceof window.CanvasRenderingContext2D?(p=e.canvas,d=e,r=p.width,s=p.height,g=d.getImageData(0,0,r,s),c=g.data,f=4):window.ImageData&&e instanceof window.ImageData&&(g=e,r=e.width,s=e.height,c=g.data,f=4);if(a=Math.max(r,s),window.Uint8ClampedArray&&c instanceof window.Uint8ClampedArray||window.Uint8Array&&c instanceof window.Uint8Array)for(l=c,c=Array(r*s),h=0,A=Math.floor(l.length/f);h<A;h++)c[h]=l[h*f+o]/255;else if(f!==1)throw Error("Raw data can have only 1 value per pixel");var x=Array(r*s),C=Array(r*s),T=Array(a),E=Array(a),S=Array(a+1),w=Array(a);for(h=0,A=r*s;h<A;h++){var D=c[h];x[h]=D===1?0:D===0?XO:Math.pow(Math.max(0,.5-D),2),C[h]=D===1?XO:D===0?0:Math.pow(Math.max(0,D-.5),2)}joe(x,r,s,T,E,w,S),joe(C,r,s,T,E,w,S);var M=window.Float32Array?new Float32Array(r*s):new Array(r*s);for(h=0,A=r*s;h<A;h++)M[h]=Math.min(Math.max(1-((x[h]-C[h])/i+n),0),1);return M}function joe(e,t,n,i,o,r,s){for(var a=0;a<t;a++){for(var c=0;c<n;c++)i[c]=e[c*t+a];for(Yoe(i,o,r,s,n),c=0;c<n;c++)e[c*t+a]=o[c]}for(c=0;c<n;c++){for(a=0;a<t;a++)i[a]=e[c*t+a];for(Yoe(i,o,r,s,t),a=0;a<t;a++)e[c*t+a]=Math.sqrt(o[a])}}function Yoe(e,t,n,i,o){n[0]=0,i[0]=-XO,i[1]=+XO;for(var r=1,s=0;r<o;r++){for(var a=(e[r]+r*r-(e[n[s]]+n[s]*n[s]))/(2*r-2*n[s]);a<=i[s];)s--,a=(e[r]+r*r-(e[n[s]]+n[s]*n[s]))/(2*r-2*n[s]);s++,n[s]=r,i[s]=a,i[s+1]=+XO}for(r=0,s=0;r<o;r++){for(;i[s+1]<r;)s++;t[r]=(r-n[s])*(r-n[s])+e[n[s]]}}});var $oe=tl((Omn,oV)=>{function z4e(){var e=0,t=1,n=2,i=3,o=4,r=5,s=6,a=7,c=8,l=9,f=10,d=11,p=12,g=13,h=14,A=15,x=16,C=17,T=0,E=1,S=2,w=3,D=4;function M(_,b){return 55296<=_.charCodeAt(b)&&_.charCodeAt(b)<=56319&&56320<=_.charCodeAt(b+1)&&_.charCodeAt(b+1)<=57343}function O(_,b){b===void 0&&(b=0);var v=_.charCodeAt(b);if(55296<=v&&v<=56319&&b<_.length-1){var I=v,R=_.charCodeAt(b+1);return 56320<=R&&R<=57343?(I-55296)*1024+(R-56320)+65536:I}if(56320<=v&&v<=57343&&b>=1){var I=_.charCodeAt(b-1),R=v;return 55296<=I&&I<=56319?(I-55296)*1024+(R-56320)+65536:R}return v}function L(_,b,v){var I=[_].concat(b).concat([v]),R=I[I.length-2],F=v,z=I.lastIndexOf(h);if(z>1&&I.slice(1,z).every(function(U){return U==i})&&[i,g,C].indexOf(_)==-1)return S;var V=I.lastIndexOf(o);if(V>0&&I.slice(1,V).every(function(U){return U==o})&&[p,o].indexOf(R)==-1)return I.filter(function(U){return U==o}).length%2==1?w:D;if(R==e&&F==t)return T;if(R==n||R==e||R==t)return F==h&&b.every(function(U){return U==i})?S:E;if(F==n||F==e||F==t)return E;if(R==s&&(F==s||F==a||F==l||F==f))return T;if((R==l||R==a)&&(F==a||F==c))return T;if((R==f||R==c)&&F==c)return T;if(F==i||F==A)return T;if(F==r)return T;if(R==p)return T;var G=I.indexOf(i)!=-1?I.lastIndexOf(i)-1:I.length-2;return[g,C].indexOf(I[G])!=-1&&I.slice(G+1,-1).every(function(U){return U==i})&&F==h||R==A&&[x,C].indexOf(F)!=-1?T:b.indexOf(o)!=-1?S:R==o&&F==o?T:E}this.nextBreak=function(_,b){if(b===void 0&&(b=0),b<0)return 0;if(b>=_.length-1)return _.length;for(var v=N(O(_,b)),I=[],R=b+1;R<_.length;R++)if(!M(_,R-1)){var F=N(O(_,R));if(L(v,I,F
* protobuf.js v7.2.3 (c) 2016, daniel wirtz
* compiled mon, 27 mar 2023 18:08:22 utc
* licensed under the bsd-3-clause license
* see: https://github.com/dcodeio/protobuf.js for details
*/(function(undefined){"use strict";(function(t,n,i){function o(s){var a=n[s];return a||t[s][0].call(a=n[s]={exports:{}},o,a,a.exports),a.exports}var r=o(i[0]);r.util.global.protobuf=r,typeof define=="function"&&define.amd&&define(["long"],function(s){return s&&s.isLong&&(r.util.Long=s,r.configure()),r}),typeof module=="object"&&module&&module.exports&&(module.exports=r)})({1:[function(e,t,n){"use strict";t.exports=i;function i(o,r){for(var s=new Array(arguments.length-1),a=0,c=2,l=!0;c<arguments.length;)s[a++]=arguments[c++];return new Promise(function(d,p){s[a]=function(h){if(l)if(l=!1,h)p(h);else{for(var A=new Array(arguments.length-1),x=0;x<A.length;)A[x++]=arguments[x];d.apply(null,A)}};try{o.apply(r||null,s)}catch(g){l&&(l=!1,p(g))}})}},{}],2:[function(e,t,n){"use strict";var i=n;i.length=function(l){var f=l.length;if(!f)return 0;for(var d=0;--f%4>1&&l.charAt(f)==="=";)++d;return Math.ceil(l.length*3)/4-d};for(var o=new Array(64),r=new Array(123),s=0;s<64;)r[o[s]=s<26?s+65:s<52?s+71:s<62?s-4:s-59|43]=s++;i.encode=function(l,f,d){for(var p=null,g=[],h=0,A=0,x;f<d;){var C=l[f++];switch(A){case 0:g[h++]=o[C>>2],x=(C&3)<<4,A=1;break;case 1:g[h++]=o[x|C>>4],x=(C&15)<<2,A=2;break;case 2:g[h++]=o[x|C>>6],g[h++]=o[C&63],A=0;break}h>8191&&((p||(p=[])).push(String.fromCharCode.apply(String,g)),h=0)}return A&&(g[h++]=o[x],g[h++]=61,A===1&&(g[h++]=61)),p?(h&&p.push(String.fromCharCode.apply(String,g.slice(0,h))),p.join("")):String.fromCharCode.apply(String,g.slice(0,h))};var a="invalid encoding";i.decode=function(l,f,d){for(var p=d,g=0,h,A=0;A<l.length;){var x=l.charCodeAt(A++);if(x===61&&g>1)break;if((x=r[x])===undefined)throw Error(a);switch(g){case 0:h=x,g=1;break;case 1:f[d++]=h<<2|(x&48)>>4,h=x,g=2;break;case 2:f[d++]=(h&15)<<4|(x&60)>>2,h=x,g=3;break;case 3:f[d++]=(h&3)<<6|x,g=0;break}}if(g===1)throw Error(a);return d-p},i.test=function(l){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(l)}},{}],3:[function(e,t,n){"use strict";t.exports=i;function i(){this._listeners={}}i.prototype.on=function(r,s,a){return(this._listeners[r]||(this._listeners[r]=[])).push({fn:s,ctx:a||this}),this},i.prototype.off=function(r,s){if(r===undefined)this._listeners={};else if(s===undefined)this._listeners[r]=[];else for(var a=this._listeners[r],c=0;c<a.length;)a[c].fn===s?a.splice(c,1):++c;return this},i.prototype.emit=function(r){var s=this._listeners[r];if(s){for(var a=[],c=1;c<arguments.length;)a.push(arguments[c++]);for(c=0;c<s.length;)s[c].fn.apply(s[c++].ctx,a)}return this}},{}],4:[function(e,t,n){"use strict";t.exports=i(i);function i(c){return typeof Float32Array<"u"?function(){var l=new Float32Array([-0]),f=new Uint8Array(l.buffer),d=f[3]===128;function p(x,C,T){l[0]=x,C[T]=f[0],C[T+1]=f[1],C[T+2]=f[2],C[T+3]=f[3]}function g(x,C,T){l[0]=x,C[T]=f[3],C[T+1]=f[2],C[T+2]=f[1],C[T+3]=f[0]}c.writeFloatLE=d?p:g,c.writeFloatBE=d?g:p;function h(x,C){return f[0]=x[C],f[1]=x[C+1],f[2]=x[C+2],f[3]=x[C+3],l[0]}function A(x,C){return f[3]=x[C],f[2]=x[C+1],f[1]=x[C+2],f[0]=x[C+3],l[0]}c.readFloatLE=d?h:A,c.readFloatBE=d?A:h}():function(){function l(d,p,g,h){var A=p<0?1:0;if(A&&(p=-p),p===0)d(1/p>0?0:2147483648,g,h);else if(isNaN(p))d(2143289344,g,h);else if(p>34028234663852886e22)d((A<<31|2139095040)>>>0,g,h);else if(p<11754943508222875e-54)d((A<<31|Math.round(p/1401298464324817e-60))>>>0,g,h);else{var x=Math.floor(Math.log(p)/Math.LN2),C=Math.round(p*Math.pow(2,-x)*8388608)&8388607;d((A<<31|x+127<<23|C)>>>0,g,h)}}c.writeFloatLE=l.bind(null,o),c.writeFloatBE=l.bind(null,r);function f(d,p,g){var h=d(p,g),A=(h>>31)*2+1,x=h>>>23&255,C=h&8388607;return x===255?C?NaN:A*(1/0):x===0?A*1401298464324817e-60*C:A*Math.pow(2,x-150)*(C+8388608)}c.readFloatLE=f.bind(null,s),c.readFloatBE=f.bind(null,a)}(),typeof Float64Array<"u"?function(){var l=new Float64Array([-0]),f=new Uint8Array(l.buffer),d=f[7]===128;function p(x,C,T){l[0]=x,C[T]=f[0],C[T+1]=f[1],C[T+2]=f[2],C[T+3]=f[3],C[T+4]=f[4],C[T+5]=f[5],C[T+6]=f[6],C[T+7]=f[7]}function g(x,C,T){l[0]=x,C[T]=f[7],C[T+1]=f[6],C[T+2]=f[5],C[T+3]=f[4],C[T+4]=f[3],C[T+5]=f[2],C[T+6]=f[1],C
NoSleep enabled for older iOS devices. This can interrupt
active or long-running network requests from completing successfully.
See https://github.com/richtr/NoSleep.js/issues/15 for more details.
`),this.noSleepTimer=window.setInterval(()=>{document.hidden||(window.location.href=window.location.href.split("#")[0],window.setTimeout(window.stop,0))},15e3),this.enabled=!0,Promise.resolve()):this.noSleepVideo.play().then(n=>(this.enabled=!0,n)).catch(n=>{throw this.enabled=!1,n})}disable(){mK()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):dK()?this.noSleepTimer&&(console.warn(`
NoSleep now disabled for older iOS devices.
`),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}};ixe.exports=hK});var n0t={};Dxe(n0t,{AlphaMode:()=>Um,AlphaPipelineStage:()=>H1,Animation:()=>u2,AnimationViewModel:()=>f2,Appearance:()=>eo,ApproximateTerrainHeights:()=>ri,ArcGISTiledElevationTerrainProvider:()=>hj,ArcGisMapServerImageryProvider:()=>Ah,ArcType:()=>Zt,ArticulationStageType:()=>Ka,AssociativeArray:()=>Ct,AttributeCompression:()=>Wn,AttributeType:()=>an,AutoExposure:()=>aL,AutomaticUniforms:()=>Kh,Axis:()=>lo,AxisAlignedBoundingBox:()=>tg,B3dmLoader:()=>s1,B3dmParser:()=>i1,BaseLayerPicker:()=>m2,BaseLayerPickerViewModel:()=>d2,BatchTable:()=>L0,BatchTableHierarchy:()=>lA,BatchTexture:()=>Mc,BatchTexturePipelineStage:()=>G1,Billboard:()=>mo,BillboardCollection:()=>nu,BillboardGraphics:()=>Ra,BillboardVisualizer:()=>ev,BingMapsGeocoderService:()=>_j,BingMapsImageryProvider:()=>Qb,BingMapsStyle:()=>Jb,BlendEquation:()=>da,BlendFunction:()=>Eo,BlendOption:()=>bo,BlendingState:()=>un,BoundingRectangle:()=>qe,BoundingSphere:()=>ae,BoundingSphereState:()=>ct,BoxEmitter:()=>SY,BoxGeometry:()=>rl,BoxGeometryUpdater:()=>lP,BoxGraphics:()=>X0,BoxOutlineGeometry:()=>ed,BrdfLutGenerator:()=>fL,Buffer:()=>ut,BufferLoader:()=>pA,BufferUsage:()=>Fe,CPUStylingPipelineStage:()=>q1,CallbackProperty:()=>ld,Camera:()=>so,CameraEventAggregator:()=>_L,CameraEventType:()=>Oi,CameraFlightPath:()=>mL,Cartesian2:()=>H,Cartesian3:()=>m,Cartesian4:()=>re,Cartographic:()=>he,CartographicGeocoderService:()=>HB,CatmullRomSpline:()=>gj,Cesium3DContentGroup:()=>cA,Cesium3DTile:()=>_f,Cesium3DTileBatchTable:()=>mp,Cesium3DTileColorBlendMode:()=>ml,Cesium3DTileContent:()=>NY,Cesium3DTileContentFactory:()=>WA,Cesium3DTileContentState:()=>Ho,Cesium3DTileContentType:()=>ls,Cesium3DTileFeature:()=>Cs,Cesium3DTileFeatureTable:()=>Td,Cesium3DTileOptimizationHint:()=>uf,Cesium3DTileOptimizations:()=>SM,Cesium3DTilePass:()=>Ro,Cesium3DTilePassState:()=>Ff,Cesium3DTilePointFeature:()=>Fp,Cesium3DTileRefine:()=>Uo,Cesium3DTileStyle:()=>I_,Cesium3DTileStyleEngine:()=>OM,Cesium3DTilesInspector:()=>T2,Cesium3DTilesInspectorViewModel:()=>C2,Cesium3DTilesVoxelProvider:()=>kY,Cesium3DTileset:()=>Ca,Cesium3DTilesetBaseTraversal:()=>FM,Cesium3DTilesetCache:()=>DM,Cesium3DTilesetGraphics:()=>tA,Cesium3DTilesetHeatmap:()=>IM,Cesium3DTilesetMetadata:()=>Qg,Cesium3DTilesetMostDetailedTraversal:()=>BM,Cesium3DTilesetSkipTraversal:()=>kM,Cesium3DTilesetStatistics:()=>$p,Cesium3DTilesetTraversal:()=>Ds,Cesium3DTilesetVisualizer:()=>zM,CesiumInspector:()=>y2,CesiumInspectorViewModel:()=>g2,CesiumTerrainProvider:()=>Vy,CesiumWidget:()=>t2,Check:()=>nl,CheckerboardMaterialProperty:()=>SE,CircleEmitter:()=>TL,CircleGeometry:()=>Tj,CircleOutlineGeometry:()=>Ej,ClassificationModelDrawCommand:()=>T1,ClassificationPipelineStage:()=>W1,ClassificationPrimitive:()=>_T,ClassificationType:()=>kn,ClearCommand:()=>li,ClippingPlane:()=>vA,ClippingPlaneCollection:()=>ss,Clock:()=>Fd,ClockRange:()=>Rr,ClockStep:()=>ho,ClockViewModel:()=>s2,CloudCollection:()=>YY,CloudType:()=>nS,Color:()=>k,ColorBlendMode:()=>Xa,ColorGeometryInstanceAttribute:()=>Ut,ColorMaterialProperty:()=>Nt,Command:()=>tK,ComponentDatatype:()=>X,Composite3DTileContent:()=>gP,CompositeEntityCollection:()=>u9,CompositeMaterialProperty:()=>wE,CompositePositionProperty:()=>Qs,CompositeProperty:()=>tc,CompressedTextureBuffer:()=>Ev,ComputeCommand:()=>Ku,ComputeEngine:()=>MB,ConditionsExpression:()=>gL,ConeEmitter:()=>XY,ConstantPositionProperty:()=>wc,ConstantProperty:()=>ei,ConstantSpline:()=>u1,ContentMetadata:()=>hM,Context:()=>UB,ContextLimits:()=>Vt,CoplanarPolygonGeometry:()=>SR,CoplanarPolygonGeometryLibrary:()=>qp,CoplanarPolygonOutlineGeometry:()=>hf,CornerType:()=>Ii,CorridorGeometry:()=>sx,CorridorGeometryLibrary:()=>Fi,CorridorGeometryUpdater:()=>JM,CorridorGraphics:()=>J0,CorridorOutlineGeometry:()=>KM,Credit:()=>Xt,CreditDisplay:()=>DL,CubeMap:()=>ka,CubeMapFace:()=>bm,CubicRealPolynomial:()=>O0,CullFace:()=>_i,CullingVolume:()=>es,CumulusCloud:()=>Mu,CustomDataSource:()=>nR,CustomHei
${this.stack.toString()}`),e};p0.throwInstantiationError=function(){throw new p0("This function defines an interface and should not be called directly.")};var fe=p0;var os={};os.typeOf={};function Oxe(e){return`${e} is required, actual value was undefined`}function GC(e,t,n){return`Expected ${n} to be typeof ${t}, actual typeof was ${e}`}os.defined=function(e,t){if(!u(t))throw new fe(Oxe(e))};os.typeOf.func=function(e,t){if(typeof t!="function")throw new fe(GC(typeof t,"function",e))};os.typeOf.string=function(e,t){if(typeof t!="string")throw new fe(GC(typeof t,"string",e))};os.typeOf.number=function(e,t){if(typeof t!="number")throw new fe(GC(typeof t,"number",e))};os.typeOf.number.lessThan=function(e,t,n){if(os.typeOf.number(e,t),t>=n)throw new fe(`Expected ${e} to be less than ${n}, actual value was ${t}`)};os.typeOf.number.lessThanOrEquals=function(e,t,n){if(os.typeOf.number(e,t),t>n)throw new fe(`Expected ${e} to be less than or equal to ${n}, actual value was ${t}`)};os.typeOf.number.greaterThan=function(e,t,n){if(os.typeOf.number(e,t),t<=n)throw new fe(`Expected ${e} to be greater than ${n}, actual value was ${t}`)};os.typeOf.number.greaterThanOrEquals=function(e,t,n){if(os.typeOf.number(e,t),t<n)throw new fe(`Expected ${e} to be greater than or equal to ${n}, actual value was ${t}`)};os.typeOf.object=function(e,t){if(typeof t!="object")throw new fe(GC(typeof t,"object",e))};os.typeOf.bool=function(e,t){if(typeof t!="boolean")throw new fe(GC(typeof t,"boolean",e))};os.typeOf.bigint=function(e,t){if(typeof t!="bigint")throw new fe(GC(typeof t,"bigint",e))};os.typeOf.number.equals=function(e,t,n,i){if(os.typeOf.number(e,n),os.typeOf.number(t,i),n!==i)throw new fe(`${e} must be equal to ${t}, the actual values are ${n} and ${i}`)};var nl=os;function ZS(){this._listeners=[],this._scopes=[],this._toRemove=[],this._insideRaiseEvent=!1}Object.defineProperties(ZS.prototype,{numberOfListeners:{get:function(){return this._listeners.length-this._toRemove.length}}});ZS.prototype.addEventListener=function(e,t){this._listeners.push(e),this._scopes.push(t);let n=this;return function(){n.removeEventListener(e,t)}};ZS.prototype.removeEventListener=function(e,t){let n=this._listeners,i=this._scopes,o=-1;for(let r=0;r<n.length;r++)if(n[r]===e&&i[r]===t){o=r;break}return o!==-1?(this._insideRaiseEvent?(this._toRemove.push(o),n[o]=void 0,i[o]=void 0):(n.splice(o,1),i.splice(o,1)),!0):!1};function Mxe(e,t){return t-e}ZS.prototype.raiseEvent=function(){this._insideRaiseEvent=!0;let e,t=this._listeners,n=this._scopes,i=t.length;for(e=0;e<i;e++){let r=t[e];u(r)&&t[e].apply(n[e],arguments)}let o=this._toRemove;if(i=o.length,i>0){for(o.sort(Mxe),e=0;e<i;e++){let r=o[e];t.splice(r,1),n.splice(r,1)}o.length=0}this._insideRaiseEvent=!1};var ye=ZS;function j_(e){this._value=void 0,this._hasClone=!1,this._hasEquals=!1,this._definitionChanged=new ye,this.setValue(e)}Object.defineProperties(j_.prototype,{isConstant:{value:!0},definitionChanged:{get:function(){return this._definitionChanged}}});j_.prototype.getValue=function(e,t){return this._hasClone?this._value.clone(t):this._value};j_.prototype.setValue=function(e){let t=this._value;if(t!==e){let n=u(e),i=n&&typeof e.clone=="function",o=n&&typeof e.equals=="function";(!o||!e.equals(t))&&(this._hasClone=i,this._hasEquals=o,this._value=i?e.clone(this._value):e,this._definitionChanged.raiseEvent(this))}};j_.prototype.equals=function(e){return this===e||e instanceof j_&&(!this._hasEquals&&this._value===e._value||this._hasEquals&&this._value.equals(e._value))};j_.prototype.valueOf=function(){return this._value};j_.prototype.toString=function(){return String(this._value)};var ei=j_;function Rxe(e,t,n,i,o){return{configurable:i,get:function(){return this[t]},set:function(r){let s=this[t],a=this[n];u(a)&&(a(),this[n]=void 0),r!==void 0&&(!u(r)||!u(r.getValue))&&u(o)&&(r=o(r)),s!==r&&(this[t]=r,this._definitionChanged.raiseEvent(this,e,r,s)),u(r)&&u(r.definitionChanged)&&(this[n]=r.definitionChanged.addEventListener(function(){this._definitionChanged.raiseEvent(this,e,r,r)},this))}}}function Bxe(e){retur
(${this[1]}, ${this[4]}, ${this[7]})
(${this[2]}, ${this[5]}, ${this[8]})`};var Z=tt;function gt(e,t,n,i){this.x=y(e,0),this.y=y(t,0),this.z=y(n,0),this.w=y(i,0)}gt.fromElements=function(e,t,n,i,o){return u(o)?(o.x=e,o.y=t,o.z=n,o.w=i,o):new gt(e,t,n,i)};gt.fromColor=function(e,t){return u(t)?(t.x=e.red,t.y=e.green,t.z=e.blue,t.w=e.alpha,t):new gt(e.red,e.green,e.blue,e.alpha)};gt.clone=function(e,t){if(u(e))return u(t)?(t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t):new gt(e.x,e.y,e.z,e.w)};gt.packedLength=4;gt.pack=function(e,t,n){return n=y(n,0),t[n++]=e.x,t[n++]=e.y,t[n++]=e.z,t[n]=e.w,t};gt.unpack=function(e,t,n){return t=y(t,0),u(n)||(n=new gt),n.x=e[t++],n.y=e[t++],n.z=e[t++],n.w=e[t],n};gt.packArray=function(e,t){let n=e.length,i=n*4;u(t)?!Array.isArray(t)&&t.length!==i||t.length!==i&&(t.length=i):t=new Array(i);for(let o=0;o<n;++o)gt.pack(e[o],t,o*4);return t};gt.unpackArray=function(e,t){let n=e.length;u(t)?t.length=n/4:t=new Array(n/4);for(let i=0;i<n;i+=4){let o=i/4;t[o]=gt.unpack(e,i,t[o])}return t};gt.fromArray=gt.unpack;gt.maximumComponent=function(e){return Math.max(e.x,e.y,e.z,e.w)};gt.minimumComponent=function(e){return Math.min(e.x,e.y,e.z,e.w)};gt.minimumByComponent=function(e,t,n){return n.x=Math.min(e.x,t.x),n.y=Math.min(e.y,t.y),n.z=Math.min(e.z,t.z),n.w=Math.min(e.w,t.w),n};gt.maximumByComponent=function(e,t,n){return n.x=Math.max(e.x,t.x),n.y=Math.max(e.y,t.y),n.z=Math.max(e.z,t.z),n.w=Math.max(e.w,t.w),n};gt.clamp=function(e,t,n,i){let o=P.clamp(e.x,t.x,n.x),r=P.clamp(e.y,t.y,n.y),s=P.clamp(e.z,t.z,n.z),a=P.clamp(e.w,t.w,n.w);return i.x=o,i.y=r,i.z=s,i.w=a,i};gt.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w};gt.magnitude=function(e){return Math.sqrt(gt.magnitudeSquared(e))};var g3=new gt;gt.distance=function(e,t){return gt.subtract(e,t,g3),gt.magnitude(g3)};gt.distanceSquared=function(e,t){return gt.subtract(e,t,g3),gt.magnitudeSquared(g3)};gt.normalize=function(e,t){let n=gt.magnitude(e);return t.x=e.x/n,t.y=e.y/n,t.z=e.z/n,t.w=e.w/n,t};gt.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w};gt.multiplyComponents=function(e,t,n){return n.x=e.x*t.x,n.y=e.y*t.y,n.z=e.z*t.z,n.w=e.w*t.w,n};gt.divideComponents=function(e,t,n){return n.x=e.x/t.x,n.y=e.y/t.y,n.z=e.z/t.z,n.w=e.w/t.w,n};gt.add=function(e,t,n){return n.x=e.x+t.x,n.y=e.y+t.y,n.z=e.z+t.z,n.w=e.w+t.w,n};gt.subtract=function(e,t,n){return n.x=e.x-t.x,n.y=e.y-t.y,n.z=e.z-t.z,n.w=e.w-t.w,n};gt.multiplyByScalar=function(e,t,n){return n.x=e.x*t,n.y=e.y*t,n.z=e.z*t,n.w=e.w*t,n};gt.divideByScalar=function(e,t,n){return n.x=e.x/t,n.y=e.y/t,n.z=e.z/t,n.w=e.w/t,n};gt.negate=function(e,t){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=-e.w,t};gt.abs=function(e,t){return t.x=Math.abs(e.x),t.y=Math.abs(e.y),t.z=Math.abs(e.z),t.w=Math.abs(e.w),t};var lJ=new gt;gt.lerp=function(e,t,n,i){return gt.multiplyByScalar(t,n,lJ),i=gt.multiplyByScalar(e,1-n,i),gt.add(lJ,i,i)};var eTe=new gt;gt.mostOrthogonalAxis=function(e,t){let n=gt.normalize(e,eTe);return gt.abs(n,n),n.x<=n.y?n.x<=n.z?n.x<=n.w?t=gt.clone(gt.UNIT_X,t):t=gt.clone(gt.UNIT_W,t):n.z<=n.w?t=gt.clone(gt.UNIT_Z,t):t=gt.clone(gt.UNIT_W,t):n.y<=n.z?n.y<=n.w?t=gt.clone(gt.UNIT_Y,t):t=gt.clone(gt.UNIT_W,t):n.z<=n.w?t=gt.clone(gt.UNIT_Z,t):t=gt.clone(gt.UNIT_W,t),t};gt.equals=function(e,t){return e===t||u(e)&&u(t)&&e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w};gt.equalsArray=function(e,t,n){return e.x===t[n]&&e.y===t[n+1]&&e.z===t[n+2]&&e.w===t[n+3]};gt.equalsEpsilon=function(e,t,n,i){return e===t||u(e)&&u(t)&&P.equalsEpsilon(e.x,t.x,n,i)&&P.equalsEpsilon(e.y,t.y,n,i)&&P.equalsEpsilon(e.z,t.z,n,i)&&P.equalsEpsilon(e.w,t.w,n,i)};gt.ZERO=Object.freeze(new gt(0,0,0,0));gt.ONE=Object.freeze(new gt(1,1,1,1));gt.UNIT_X=Object.freeze(new gt(1,0,0,0));gt.UNIT_Y=Object.freeze(new gt(0,1,0,0));gt.UNIT_Z=Object.freeze(new gt(0,0,1,0));gt.UNIT_W=Object.freeze(new gt(0,0,0,1));gt.prototype.clone=function(e){return gt.clone(this,e)};gt.prototype.equals=function(e){return gt.equals(this,e)};gt.prototype.equalsEpsilon=function(e,t,n){return gt.equalsEpsilon(this,e,t,n)};gt.prototype.toString=function(){return`(${this.x}, ${this.y}, ${this.z}, ${this.w})`
${this.stack.toString()}`),e};var de=tv;function $e(e,t,n,i,o,r,s,a,c,l,f,d,p,g,h,A){this[0]=y(e,0),this[1]=y(o,0),this[2]=y(c,0),this[3]=y(p,0),this[4]=y(t,0),this[5]=y(r,0),this[6]=y(l,0),this[7]=y(g,0),this[8]=y(n,0),this[9]=y(s,0),this[10]=y(f,0),this[11]=y(h,0),this[12]=y(i,0),this[13]=y(a,0),this[14]=y(d,0),this[15]=y(A,0)}$e.packedLength=16;$e.pack=function(e,t,n){return n=y(n,0),t[n++]=e[0],t[n++]=e[1],t[n++]=e[2],t[n++]=e[3],t[n++]=e[4],t[n++]=e[5],t[n++]=e[6],t[n++]=e[7],t[n++]=e[8],t[n++]=e[9],t[n++]=e[10],t[n++]=e[11],t[n++]=e[12],t[n++]=e[13],t[n++]=e[14],t[n]=e[15],t};$e.unpack=function(e,t,n){return t=y(t,0),u(n)||(n=new $e),n[0]=e[t++],n[1]=e[t++],n[2]=e[t++],n[3]=e[t++],n[4]=e[t++],n[5]=e[t++],n[6]=e[t++],n[7]=e[t++],n[8]=e[t++],n[9]=e[t++],n[10]=e[t++],n[11]=e[t++],n[12]=e[t++],n[13]=e[t++],n[14]=e[t++],n[15]=e[t],n};$e.packArray=function(e,t){let n=e.length,i=n*16;u(t)?!Array.isArray(t)&&t.length!==i||t.length!==i&&(t.length=i):t=new Array(i);for(let o=0;o<n;++o)$e.pack(e[o],t,o*16);return t};$e.unpackArray=function(e,t){let n=e.length;u(t)?t.length=n/16:t=new Array(n/16);for(let i=0;i<n;i+=16){let o=i/16;t[o]=$e.unpack(e,i,t[o])}return t};$e.clone=function(e,t){if(u(e))return u(t)?(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t):new $e(e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15])};$e.fromArray=$e.unpack;$e.fromColumnMajorArray=function(e,t){return $e.clone(e,t)};$e.fromRowMajorArray=function(e,t){return u(t)?(t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15],t):new $e(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])};$e.fromRotationTranslation=function(e,t,n){return t=y(t,m.ZERO),u(n)?(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=0,n[4]=e[3],n[5]=e[4],n[6]=e[5],n[7]=0,n[8]=e[6],n[9]=e[7],n[10]=e[8],n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,n):new $e(e[0],e[3],e[6],t.x,e[1],e[4],e[7],t.y,e[2],e[5],e[8],t.z,0,0,0,1)};$e.fromTranslationQuaternionRotationScale=function(e,t,n,i){u(i)||(i=new $e);let o=n.x,r=n.y,s=n.z,a=t.x*t.x,c=t.x*t.y,l=t.x*t.z,f=t.x*t.w,d=t.y*t.y,p=t.y*t.z,g=t.y*t.w,h=t.z*t.z,A=t.z*t.w,x=t.w*t.w,C=a-d-h+x,T=2*(c-A),E=2*(l+g),S=2*(c+A),w=-a+d-h+x,D=2*(p-f),M=2*(l-g),O=2*(p+f),L=-a-d+h+x;return i[0]=C*o,i[1]=S*o,i[2]=M*o,i[3]=0,i[4]=T*r,i[5]=w*r,i[6]=O*r,i[7]=0,i[8]=E*s,i[9]=D*s,i[10]=L*s,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,i};$e.fromTranslationRotationScale=function(e,t){return $e.fromTranslationQuaternionRotationScale(e.translation,e.rotation,e.scale,t)};$e.fromTranslation=function(e,t){return $e.fromRotationTranslation(Z.IDENTITY,e,t)};$e.fromScale=function(e,t){return u(t)?(t[0]=e.x,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e.y,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e.z,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t):new $e(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1)};$e.fromUniformScale=function(e,t){return u(t)?(t[0]=e,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t):new $e(e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1)};$e.fromRotation=function(e,t){return u(t)||(t=new $e),t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=0,t[4]=e[3],t[5]=e[4],t[6]=e[5],t[7]=0,t[8]=e[6],t[9]=e[7],t[10]=e[8],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t};var YC=new m,qC=new m,nv=new m;$e.fromCamera=function(e,t){let n=e.position,i=e.direction,o=e.up;m.normalize(i,YC),m.normalize(m.cross(YC,o,qC),qC),m.normalize(m.cross(qC,YC,nv),nv);let r=qC.x,s=qC.y,a=qC.z,c=YC.x,l=YC.y,f=YC.z,d=nv.x,p=nv.y,g=nv.z,h=n.x,A=n.y,x=n.z,C=r*-h+s*-A+a*-x,T=d*-h+p*-A+g*-x,E=c*h+l*A+f*x;return u(t)?(t[0]=r,t[1]=d,t[2]=-c,t[3]=0,t[4]=s,t[5]=p,t[6]=-l,t[7]=0,t[8]=a,t[9]=g,t[10]=-f,t[11]=0,t[12]=C,t[13]=T,t[14]=E,t[15]=1,t):new $e(r,s,a,C,d,p,g,T,-c,-l,-f,E,0,0,0,1)};$e.computePerspectiveFieldOfView=function(e,t,n,i,o){let s=1/Math.tan(e*.5),a=s/t,c=(i+n)/(n-i),l=2*i*n/(n-i);return o[0]=a,o
(${this[1]}, ${this[5]}, ${this[9]}, ${this[13]})
(${this[2]}, ${this[6]}, ${this[10]}, ${this[14]})
(${this[3]}, ${this[7]}, ${this[11]}, ${this[15]})`};var B=$e;function pn(e,t){this.center=m.clone(y(e,m.ZERO)),this.radius=y(t,0)}var fG=new m,dG=new m,mG=new m,hG=new m,pG=new m,_G=new m,gG=new m,zs=new m,yG=new m,AG=new m,xG=new m,CG=new m,dTe=4/3*P.PI;pn.fromPoints=function(e,t){if(u(t)||(t=new pn),!u(e)||e.length===0)return t.center=m.clone(m.ZERO,t.center),t.radius=0,t;let n=m.clone(e[0],gG),i=m.clone(n,fG),o=m.clone(n,dG),r=m.clone(n,mG),s=m.clone(n,hG),a=m.clone(n,pG),c=m.clone(n,_G),l=e.length,f;for(f=1;f<l;f++){m.clone(e[f],n);let O=n.x,L=n.y,N=n.z;O<i.x&&m.clone(n,i),O>s.x&&m.clone(n,s),L<o.y&&m.clone(n,o),L>a.y&&m.clone(n,a),N<r.z&&m.clone(n,r),N>c.z&&m.clone(n,c)}let d=m.magnitudeSquared(m.subtract(s,i,zs)),p=m.magnitudeSquared(m.subtract(a,o,zs)),g=m.magnitudeSquared(m.subtract(c,r,zs)),h=i,A=s,x=d;p>x&&(x=p,h=o,A=a),g>x&&(x=g,h=r,A=c);let C=yG;C.x=(h.x+A.x)*.5,C.y=(h.y+A.y)*.5,C.z=(h.z+A.z)*.5;let T=m.magnitudeSquared(m.subtract(A,C,zs)),E=Math.sqrt(T),S=AG;S.x=i.x,S.y=o.y,S.z=r.z;let w=xG;w.x=s.x,w.y=a.y,w.z=c.z;let D=m.midpoint(S,w,CG),M=0;for(f=0;f<l;f++){m.clone(e[f],n);let O=m.magnitude(m.subtract(n,D,zs));O>M&&(M=O);let L=m.magnitudeSquared(m.subtract(n,C,zs));if(L>T){let N=Math.sqrt(L);E=(E+N)*.5,T=E*E;let _=N-E;C.x=(E*C.x+_*n.x)/N,C.y=(E*C.y+_*n.y)/N,C.z=(E*C.z+_*n.z)/N}}return E<M?(m.clone(C,t.center),t.radius=E):(m.clone(D,t.center),t.radius=M),t};var mTe=new Si,hTe=new m,pTe=new m,lG=new he,uG=new he;pn.fromRectangle2D=function(e,t,n){return pn.fromRectangleWithHeights2D(e,t,0,0,n)};pn.fromRectangleWithHeights2D=function(e,t,n,i,o){if(u(o)||(o=new pn),!u(e))return o.center=m.clone(m.ZERO,o.center),o.radius=0,o;t=y(t,mTe),le.southwest(e,lG),lG.height=n,le.northeast(e,uG),uG.height=i;let r=t.project(lG,hTe),s=t.project(uG,pTe),a=s.x-r.x,c=s.y-r.y,l=s.z-r.z;o.radius=Math.sqrt(a*a+c*c+l*l)*.5;let f=o.center;return f.x=r.x+a*.5,f.y=r.y+c*.5,f.z=r.z+l*.5,o};var _Te=[];pn.fromRectangle3D=function(e,t,n,i){if(t=y(t,oe.WGS84),n=y(n,0),u(i)||(i=new pn),!u(e))return i.center=m.clone(m.ZERO,i.center),i.radius=0,i;let o=le.subsample(e,t,n,_Te);return pn.fromPoints(o,i)};pn.fromVertices=function(e,t,n,i){if(u(i)||(i=new pn),!u(e)||e.length===0)return i.center=m.clone(m.ZERO,i.center),i.radius=0,i;t=y(t,m.ZERO),n=y(n,3);let o=gG;o.x=e[0]+t.x,o.y=e[1]+t.y,o.z=e[2]+t.z;let r=m.clone(o,fG),s=m.clone(o,dG),a=m.clone(o,mG),c=m.clone(o,hG),l=m.clone(o,pG),f=m.clone(o,_G),d=e.length,p;for(p=0;p<d;p+=n){let N=e[p]+t.x,_=e[p+1]+t.y,b=e[p+2]+t.z;o.x=N,o.y=_,o.z=b,N<r.x&&m.clone(o,r),N>c.x&&m.clone(o,c),_<s.y&&m.clone(o,s),_>l.y&&m.clone(o,l),b<a.z&&m.clone(o,a),b>f.z&&m.clone(o,f)}let g=m.magnitudeSquared(m.subtract(c,r,zs)),h=m.magnitudeSquared(m.subtract(l,s,zs)),A=m.magnitudeSquared(m.subtract(f,a,zs)),x=r,C=c,T=g;h>T&&(T=h,x=s,C=l),A>T&&(T=A,x=a,C=f);let E=yG;E.x=(x.x+C.x)*.5,E.y=(x.y+C.y)*.5,E.z=(x.z+C.z)*.5;let S=m.magnitudeSquared(m.subtract(C,E,zs)),w=Math.sqrt(S),D=AG;D.x=r.x,D.y=s.y,D.z=a.z;let M=xG;M.x=c.x,M.y=l.y,M.z=f.z;let O=m.midpoint(D,M,CG),L=0;for(p=0;p<d;p+=n){o.x=e[p]+t.x,o.y=e[p+1]+t.y,o.z=e[p+2]+t.z;let N=m.magnitude(m.subtract(o,O,zs));N>L&&(L=N);let _=m.magnitudeSquared(m.subtract(o,E,zs));if(_>S){let b=Math.sqrt(_);w=(w+b)*.5,S=w*w;let v=b-w;E.x=(w*E.x+v*o.x)/b,E.y=(w*E.y+v*o.y)/b,E.z=(w*E.z+v*o.z)/b}}return w<L?(m.clone(E,i.center),i.radius=w):(m.clone(O,i.center),i.radius=L),i};pn.fromEncodedCartesianVertices=function(e,t,n){if(u(n)||(n=new pn),!u(e)||!u(t)||e.length!==t.length||e.length===0)return n.center=m.clone(m.ZERO,n.center),n.radius=0,n;let i=gG;i.x=e[0]+t[0],i.y=e[1]+t[1],i.z=e[2]+t[2];let o=m.clone(i,fG),r=m.clone(i,dG),s=m.clone(i,mG),a=m.clone(i,hG),c=m.clone(i,pG),l=m.clone(i,_G),f=e.length,d;for(d=0;d<f;d+=3){let L=e[d]+t[d],N=e[d+1]+t[d+1],_=e[d+2]+t[d+2];i.x=L,i.y=N,i.z=_,L<o.x&&m.clone(i,o),L>a.x&&m.clone(i,a),N<r.y&&m.clone(i,r),N>c.y&&m.clone(i,c),_<s.z&&m.clone(i,s),_>l.z&&m.clone(i,l)}let p=m.magnitudeSquared(m.subtract(a,o,zs)),g=m.magnitudeSquared(m.subtract(c,r,zs)),h=m.magnitudeSquared(m.subtract(l,s,zs)),A=o,x=a,C=p;g>C&&(C=g,A=r,x=c),h>C&&(C=h,A=s,x=l);let T=yG;T.x=
(${this[1]}, ${this[3]})`};var Qi=qt;var fa={POINTS:te.POINTS,LINES:te.LINES,LINE_LOOP:te.LINE_LOOP,LINE_STRIP:te.LINE_STRIP,TRIANGLES:te.TRIANGLES,TRIANGLE_STRIP:te.TRIANGLE_STRIP,TRIANGLE_FAN:te.TRIANGLE_FAN};fa.isLines=function(e){return e===fa.LINES||e===fa.LINE_LOOP||e===fa.LINE_STRIP};fa.isTriangles=function(e){return e===fa.TRIANGLES||e===fa.TRIANGLE_STRIP||e===fa.TRIANGLE_FAN};fa.validate=function(e){return e===fa.POINTS||e===fa.LINES||e===fa.LINE_LOOP||e===fa.LINE_STRIP||e===fa.TRIANGLES||e===fa.TRIANGLE_STRIP||e===fa.TRIANGLE_FAN};var Le=Object.freeze(fa);function it(e,t,n,i){this.x=y(e,0),this.y=y(t,0),this.z=y(n,0),this.w=y(i,0)}var iv=new m;it.fromAxisAngle=function(e,t,n){let i=t/2,o=Math.sin(i);iv=m.normalize(e,iv);let r=iv.x*o,s=iv.y*o,a=iv.z*o,c=Math.cos(i);return u(n)?(n.x=r,n.y=s,n.z=a,n.w=c,n):new it(r,s,a,c)};var kTe=[1,2,0],zTe=new Array(3);it.fromRotationMatrix=function(e,t){let n,i,o,r,s,a=e[Z.COLUMN0ROW0],c=e[Z.COLUMN1ROW1],l=e[Z.COLUMN2ROW2],f=a+c+l;if(f>0)n=Math.sqrt(f+1),s=.5*n,n=.5/n,i=(e[Z.COLUMN1ROW2]-e[Z.COLUMN2ROW1])*n,o=(e[Z.COLUMN2ROW0]-e[Z.COLUMN0ROW2])*n,r=(e[Z.COLUMN0ROW1]-e[Z.COLUMN1ROW0])*n;else{let d=kTe,p=0;c>a&&(p=1),l>a&&l>c&&(p=2);let g=d[p],h=d[g];n=Math.sqrt(e[Z.getElementIndex(p,p)]-e[Z.getElementIndex(g,g)]-e[Z.getElementIndex(h,h)]+1);let A=zTe;A[p]=.5*n,n=.5/n,s=(e[Z.getElementIndex(h,g)]-e[Z.getElementIndex(g,h)])*n,A[g]=(e[Z.getElementIndex(g,p)]+e[Z.getElementIndex(p,g)])*n,A[h]=(e[Z.getElementIndex(h,p)]+e[Z.getElementIndex(p,h)])*n,i=-A[0],o=-A[1],r=-A[2]}return u(t)?(t.x=i,t.y=o,t.z=r,t.w=s,t):new it(i,o,r,s)};var _J=new it,gJ=new it,TG=new it,yJ=new it;it.fromHeadingPitchRoll=function(e,t){return yJ=it.fromAxisAngle(m.UNIT_X,e.roll,_J),TG=it.fromAxisAngle(m.UNIT_Y,-e.pitch,t),t=it.multiply(TG,yJ,TG),gJ=it.fromAxisAngle(m.UNIT_Z,-e.heading,_J),it.multiply(gJ,t,t)};var y3=new m,EG=new m,Qf=new it,AJ=new it,A3=new it;it.packedLength=4;it.pack=function(e,t,n){return n=y(n,0),t[n++]=e.x,t[n++]=e.y,t[n++]=e.z,t[n]=e.w,t};it.unpack=function(e,t,n){return t=y(t,0),u(n)||(n=new it),n.x=e[t],n.y=e[t+1],n.z=e[t+2],n.w=e[t+3],n};it.packedInterpolationLength=3;it.convertPackedArrayForInterpolation=function(e,t,n,i){it.unpack(e,n*4,A3),it.conjugate(A3,A3);for(let o=0,r=n-t+1;o<r;o++){let s=o*3;it.unpack(e,(t+o)*4,Qf),it.multiply(Qf,A3,Qf),Qf.w<0&&it.negate(Qf,Qf),it.computeAxis(Qf,y3);let a=it.computeAngle(Qf);u(i)||(i=[]),i[s]=y3.x*a,i[s+1]=y3.y*a,i[s+2]=y3.z*a}};it.unpackInterpolationResult=function(e,t,n,i,o){u(o)||(o=new it),m.fromArray(e,0,EG);let r=m.magnitude(EG);return it.unpack(t,i*4,AJ),r===0?it.clone(it.IDENTITY,Qf):it.fromAxisAngle(EG,r,Qf),it.multiply(Qf,AJ,o)};it.clone=function(e,t){if(u(e))return u(t)?(t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t):new it(e.x,e.y,e.z,e.w)};it.conjugate=function(e,t){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w,t};it.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w};it.magnitude=function(e){return Math.sqrt(it.magnitudeSquared(e))};it.normalize=function(e,t){let n=1/it.magnitude(e),i=e.x*n,o=e.y*n,r=e.z*n,s=e.w*n;return t.x=i,t.y=o,t.z=r,t.w=s,t};it.inverse=function(e,t){let n=it.magnitudeSquared(e);return t=it.conjugate(e,t),it.multiplyByScalar(t,1/n,t)};it.add=function(e,t,n){return n.x=e.x+t.x,n.y=e.y+t.y,n.z=e.z+t.z,n.w=e.w+t.w,n};it.subtract=function(e,t,n){return n.x=e.x-t.x,n.y=e.y-t.y,n.z=e.z-t.z,n.w=e.w-t.w,n};it.negate=function(e,t){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=-e.w,t};it.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w};it.multiply=function(e,t,n){let i=e.x,o=e.y,r=e.z,s=e.w,a=t.x,c=t.y,l=t.z,f=t.w,d=s*a+i*f+o*l-r*c,p=s*c-i*l+o*f+r*a,g=s*l+i*c-o*a+r*f,h=s*f-i*a-o*c-r*l;return n.x=d,n.y=p,n.z=g,n.w=h,n};it.multiplyByScalar=function(e,t,n){return n.x=e.x*t,n.y=e.y*t,n.z=e.z*t,n.w=e.w*t,n};it.divideByScalar=function(e,t,n){return n.x=e.x/t,n.y=e.y/t,n.z=e.z/t,n.w=e.w/t,n};it.computeAxis=function(e,t){let n=e.w;if(Math.abs(n-1)<P.EPSILON6)return t.x=t.y=t.z=0,t;let i=1/Math.sqrt(1-n*n);return t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t};it.computeAngle=function(e){return Math.abs(e.w-1)<P.EPSILON6?0:2*Math.acos(e.
`);for(let i=0;i<n.length;++i){let o=n[i],r=o.indexOf(": ");if(r>0){let s=o.substring(0,r),a=o.substring(r+2);t[s]=a}}return t}var av=CEe;function NJ(e,t,n){this.statusCode=e,this.response=t,this.responseHeaders=n,typeof this.responseHeaders=="string"&&(this.responseHeaders=av(this.responseHeaders))}NJ.prototype.toString=function(){let e="Request has failed.";return u(this.statusCode)&&(e+=` Status Code: ${this.statusCode}`),e};var xm=NJ;var lv=Do(Wl(),1);function b0(e){this._comparator=e.comparator,this._array=[],this._length=0,this._maximumLength=void 0}Object.defineProperties(b0.prototype,{length:{get:function(){return this._length}},internalArray:{get:function(){return this._array}},maximumLength:{get:function(){return this._maximumLength},set:function(e){let t=this._length;if(e<t){let n=this._array;for(let i=e;i<t;++i)n[i]=void 0;this._length=e,n.length=e}this._maximumLength=e}},comparator:{get:function(){return this._comparator}}});function RG(e,t,n){let i=e[t];e[t]=e[n],e[n]=i}b0.prototype.reserve=function(e){e=y(e,this._length),this._array.length=e};b0.prototype.heapify=function(e){e=y(e,0);let t=this._length,n=this._comparator,i=this._array,o=-1,r=!0;for(;r;){let s=2*(e+1),a=s-1;a<t&&n(i[a],i[e])<0?o=a:o=e,s<t&&n(i[s],i[o])<0&&(o=s),o!==e?(RG(i,o,e),e=o):r=!1}};b0.prototype.resort=function(){let e=this._length;for(let t=Math.ceil(e/2);t>=0;--t)this.heapify(t)};b0.prototype.insert=function(e){let t=this._array,n=this._comparator,i=this._maximumLength,o=this._length++;for(o<t.length?t[o]=e:t.push(e);o!==0;){let s=Math.floor((o-1)/2);if(n(t[o],t[s])<0)RG(t,o,s),o=s;else break}let r;return u(i)&&this._length>i&&(r=t[i],this._length=i),r};b0.prototype.pop=function(e){if(e=y(e,0),this._length===0)return;let t=this._array,n=t[e];return RG(t,e,--this._length),this.heapify(e),t[this._length]=void 0,n};var cv=b0;function TEe(e,t){return e.priority-t.priority}var $i={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0},QC=20,Na=new cv({comparator:TEe});Na.maximumLength=QC;Na.reserve(QC);var Cm=[],Yh={},EEe=typeof document<"u"?new lv.default(document.location.href):new lv.default,D3=new ye;function qo(){}qo.maximumRequests=50;qo.maximumRequestsPerServer=6;qo.requestsByServer={"api.cesium.com:443":18,"assets.ion.cesium.com:443":18};qo.throttleRequests=!0;qo.debugShowStatistics=!1;qo.requestCompletedEvent=D3;Object.defineProperties(qo,{statistics:{get:function(){return $i}},priorityHeapLength:{get:function(){return QC},set:function(e){if(e<QC)for(;Na.length>e;){let t=Na.pop();S0(t)}QC=e,Na.maximumLength=e,Na.reserve(e)}}});function FJ(e){u(e.priorityFunction)&&(e.priority=e.priorityFunction())}qo.serverHasOpenSlots=function(e,t){t=y(t,1);let n=y(qo.requestsByServer[e],qo.maximumRequestsPerServer);return Yh[e]+t<=n};qo.heapHasOpenSlots=function(e){return Na.length+e<=QC};function UJ(e){return e.state===oi.UNISSUED&&(e.state=oi.ISSUED,e.deferred=Hs()),e.deferred.promise}function bEe(e){return function(t){if(e.state===oi.CANCELLED)return;let n=e.deferred;--$i.numberOfActiveRequests,--Yh[e.serverKey],D3.raiseEvent(),e.state=oi.RECEIVED,e.deferred=void 0,n.resolve(t)}}function SEe(e){return function(t){e.state!==oi.CANCELLED&&(++$i.numberOfFailedRequests,--$i.numberOfActiveRequests,--Yh[e.serverKey],D3.raiseEvent(t),e.state=oi.FAILED,e.deferred.reject(t))}}function VJ(e){let t=UJ(e);return e.state=oi.ACTIVE,Cm.push(e),++$i.numberOfActiveRequests,++$i.numberOfActiveRequestsEver,++Yh[e.serverKey],e.requestFunction().then(bEe(e)).catch(SEe(e)),t}function S0(e){let t=e.state===oi.ACTIVE;if(e.state=oi.CANCELLED,++$i.numberOfCancelledRequests,u(e.deferred)){let n=e.deferred;e.deferred=void 0,n.reject()}t&&(--$i.numberOfActiveRequests,--Yh[e.serverKey],++$i.numberOfCancelledActiveRequests),u(e.cancelFunction)&&e.cancelFunction()}qo.update=function(){let e,t,n=0,i=Cm.length;for(e=0;e<i;++e){if(t=Cm[e],t.cancelled&&S0(t),t.state!==oi.ACTIVE){++n;continue}n>0&&(Cm[e-n]=t)}Cm.length-=n;let o=Na.in
in vec3 v_normalEC;
in vec3 v_tangentEC;
in vec3 v_bitangentEC;
in vec2 v_st;
void main()
{
vec3 positionToEyeEC = -v_positionEC;
mat3 tangentToEyeMatrix = czm_tangentToEyeSpaceMatrix(v_normalEC, v_tangentEC, v_bitangentEC);
vec3 normalEC = normalize(v_normalEC);
#ifdef FACE_FORWARD
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif
czm_materialInput materialInput;
materialInput.normalEC = normalEC;
materialInput.tangentToEyeMatrix = tangentToEyeMatrix;
materialInput.positionToEyeEC = positionToEyeEC;
materialInput.st = v_st;
czm_material material = czm_getMaterial(materialInput);
#ifdef FLAT
out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
#else
out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
#endif
}
`;var yv=`in vec3 position3DHigh;
in vec3 position3DLow;
in vec3 normal;
in vec3 tangent;
in vec3 bitangent;
in vec2 st;
in float batchId;
out vec3 v_positionEC;
out vec3 v_normalEC;
out vec3 v_tangentEC;
out vec3 v_bitangentEC;
out vec2 v_st;
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_tangentEC = czm_normal * tangent; // tangent in eye coordinates
v_bitangentEC = czm_normal * bitangent; // bitangent in eye coordinates
v_st = st;
gl_Position = czm_modelViewProjectionRelativeToEye * p;
}
`;var Av=`in vec3 v_positionEC;
in vec3 v_normalEC;
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
czm_materialInput materialInput;
materialInput.normalEC = normalEC;
materialInput.positionToEyeEC = positionToEyeEC;
czm_material material = czm_getMaterial(materialInput);
#ifdef FLAT
out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
#else
out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
#endif
}
`;var xv=`in vec3 position3DHigh;
in vec3 position3DLow;
in vec3 normal;
in float batchId;
out vec3 v_positionEC;
out vec3 v_normalEC;
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
gl_Position = czm_modelViewProjectionRelativeToEye * p;
}
`;var Cv=`in vec3 v_positionEC;
in vec3 v_normalEC;
in vec2 v_st;
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
czm_materialInput materialInput;
materialInput.normalEC = normalEC;
materialInput.positionToEyeEC = positionToEyeEC;
materialInput.st = v_st;
czm_material material = czm_getMaterial(materialInput);
#ifdef FLAT
out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
#else
out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
#endif
}
`;var Tv=`in vec3 position3DHigh;
in vec3 position3DLow;
in vec3 normal;
in vec2 st;
in float batchId;
out vec3 v_positionEC;
out vec3 v_normalEC;
out vec2 v_st;
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_st = st;
gl_Position = czm_modelViewProjectionRelativeToEye * p;
}
`;var wbe={ADD:te.FUNC_ADD,SUBTRACT:te.FUNC_SUBTRACT,REVERSE_SUBTRACT:te.FUNC_REVERSE_SUBTRACT,MIN:te.MIN,MAX:te.MAX},da=Object.freeze(wbe);var Dbe={ZERO:te.ZERO,ONE:te.ONE,SOURCE_COLOR:te.SRC_COLOR,ONE_MINUS_SOURCE_COLOR:te.ONE_MINUS_SRC_COLOR,DESTINATION_COLOR:te.DST_COLOR,ONE_MINUS_DESTINATION_COLOR:te.ONE_MINUS_DST_COLOR,SOURCE_ALPHA:te.SRC_ALPHA,ONE_MINUS_SOURCE_ALPHA:te.ONE_MINUS_SRC_ALPHA,DESTINATION_ALPHA:te.DST_ALPHA,ONE_MINUS_DESTINATION_ALPHA:te.ONE_MINUS_DST_ALPHA,CONSTANT_COLOR:te.CONSTANT_COLOR,ONE_MINUS_CONSTANT_COLOR:te.ONE_MINUS_CONSTANT_COLOR,CONSTANT_ALPHA:te.CONSTANT_ALPHA,ONE_MINUS_CONSTANT_ALPHA:te.ONE_MINUS_CONSTANT_ALPHA,SOURCE_ALPHA_SATURATE:te.SRC_ALPHA_SATURATE},Eo=Object.freeze(Dbe);var Ibe={DISABLED:Object.freeze({enabled:!1}),ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:da.ADD,equationAlpha:da.ADD,functionSourceRgb:Eo.SOURCE_ALPHA,functionSourceAlpha:Eo.ONE,functionDestinationRgb:Eo.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:Eo.ONE_MINUS_SOURCE_ALPHA}),PRE_MULTIPLIED_ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:da.ADD,equationAlpha:da.ADD,functionSourceRgb:Eo.ONE,functionSourceAlpha:Eo.ONE,functionDestinationRgb:Eo.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:Eo.ONE_MINUS_SOURCE_ALPHA}),ADDITIVE_BLEND:Object.freeze({enabled:!0,equationRgb:da.ADD,equationAlpha:da.ADD,functionSourceRgb:Eo.SOURCE_ALPHA,functionSourceAlpha:Eo.ONE,functionDestinationRgb:Eo.ONE,functionDestinationAlpha:Eo.ONE})},un=Object.freeze(Ibe);var Pbe={FRONT:te.FRONT,BACK:te.BACK,FRONT_AND_BACK:te.FRONT_AND_BACK},_i=Object.freeze(Pbe);function aT(e){e=y(e,y.EMPTY_OBJECT),this.material=e.material,this.translucent=y(e.translucent,!0),this._vertexShaderSource=e.vertexShaderSource,this._fragmentShaderSource=e.fragmentShaderSource,this._renderState=e.renderState,this._closed=y(e.closed,!1)}Object.defineProperties(aT.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}}});aT.prototype.getFragmentShaderSource=function(){let e=[];return this.flat&&e.push("#define FLAT"),this.faceForward&&e.push("#define FACE_FORWARD"),u(this.material)&&e.push(this.material.shaderSource),e.push(this.fragmentShaderSource),e.join(`
`)};aT.prototype.isTranslucent=function(){return u(this.material)&&this.material.isTranslucent()||!u(this.material)&&this.translucent};aT.prototype.getRenderState=function(){let e=this.isTranslucent(),t=je(this.renderState,!1);return e?(t.depthMask=!1,t.blending=un.ALPHA_BLEND):t.depthMask=!0,t};aT.getDefaultRenderState=function(e,t,n){let i={depthTest:{enabled:!0}};return e&&(i.depthMask=!1,i.blending=un.ALPHA_BLEND),t&&(i.cull={enabled:!0,face:_i.BACK}),u(n)&&(i=ht(n,i,!0)),i};var eo=aT;function Obe(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Hn=Obe;function cT(e,t,n,i,o){this._format=e,this._datatype=t,this._width=n,this._height=i,this._buffer=o}Object.defineProperties(cT.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}}});cT.clone=function(e){if(u(e))return new cT(e._format,e._datatype,e._width,e._height,e._buffer)};cT.prototype.clone=function(){return cT.clone(this)};var Ev=cT;var mZ=Do(Wl(),1);function hZ(){if(!u(ma._canTransferArrayBuffer)){let e=new Worker(_Z("Workers/transferTypedArrayTest.js"));e.postMessage=y(e.webkitPostMessage,e.postMessage);let t=99,n=new Int8Array([t]);try{e.postMessage({array:n},[n.buffer])}catch{return ma._canTransferArrayBuffer=!1,ma._canTransferArrayBuffer}let i=Hs();e.onmessage=function(o){let r=o.data.array,s=u(r)&&r[0]===t;i.resolve(s),e.terminate(),ma._canTransferArrayBuffer=s},ma._canTransferArrayBuffer=i.promise}return ma._canTransferArrayBuffer}var KG=new ye;function pZ(e,t){--e._activeTasks;let n=t.id;if(!u(n))return;let i=e._deferreds,o=i[n];if(u(t.error)){let r=t.error;r.name==="RuntimeError"?(r=new de(t.error.message),r.stack=t.error.stack):r.name==="DeveloperError"&&(r=new fe(t.error.message),r.stack=t.error.stack),KG.raiseEvent(r),o.reject(r)}else KG.raiseEvent(),o.resolve(t.result);delete i[n]}function _Z(e){let t=tn(e);if(C0(t)){let n=`importScripts("${t}");`,i;try{i=new Blob([n],{type:"application/javascript"})}catch{let 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}var XG;function Mbe(){return u(XG)||(XG=_Z("Workers/cesiumWorkerBootstrapper.js")),XG}function gZ(e){let t=new Worker(Mbe());t.postMessage=y(t.webkitPostMessage,t.postMessage);let n={loaderConfig:{paths:{Workers:tn("Workers")},baseUrl:tn.getCesiumBaseUrl().url},workerModule:e._workerPath};return t.postMessage(n),t.onmessage=function(i){pZ(e,i.data)},t}function Rbe(e,t){let n={modulePath:void 0,wasmBinaryFile:void 0,wasmBinary:void 0};if(!kt.supportsWebAssembly()){if(!u(t.fallbackModulePath))throw new de(`This browser does not support Web Assembly, and no backup module was provided for ${e._workerPath}`);return n.modulePath=tn(t.fallbackModulePath),Promise.resolve(n)}return n.modulePath=tn(t.modulePath),n.wasmBinaryFile=tn(t.wasmBinaryFile),Ie.fetchArrayBuffer({url:n.wasmBinaryFile}).then(function(i){return n.wasmBinary=i,n})}function ma(e,t){let n=new mZ.default(e);this._workerPath=n.scheme().length!==0&&n.fragment().length===0?e:ma._workerModulePrefix+e,this._maximumActiveTasks=y(t,Number.POSITIVE_INFINITY),this._activeTasks=0,this._deferreds={},this._nextID=0}var Bbe=[];ma.prototype.scheduleTask=function(e,t){if(u(this._worker)||(this._worker=gZ(this)),this._activeTasks>=this._maximumActiveTasks)return;++this._activeTasks;let n=this;return Promise.resolve(hZ()).then(function(i){u(t)?i||(t.length=0):t=Bbe;let o=n._nextID++,r=Hs();return n._deferreds[o]=r,n._worker.postMessage({id:o,parameters:e,canTransferArrayBuffer:i},t),r.promise})};ma.prototype.initWebAssemblyModule=function(e){u(this._worker)||(this._worker=gZ(this));let t=Hs(),n=this,i=this._worker;return Rbe(this,e).then(function(o){return Promise.resolve(hZ()).then(function(r){let s,a=o.w
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;
}
`;var Dv=`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;
}
`;var Iv=`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;
}
`;var Pv=`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;
}
`;var Ov=`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;
}
`;var Mv=`#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif
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;
}
`;var Rv=`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;
}
`;var Bv=`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;
}
`;var Lv=`#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif
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;
}
`;var Nv=`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;
}
`;var Fv=`#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif
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;
}
`;var Uv=`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;
}
`;var Vv=`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;
}
`;var kv=`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;
}
`;var zv=`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;
}
`;var Hv=`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;
}
`;var Gv=`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;
}
`;var Wv=`// 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 Ye(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=y(e.minificationFilter,cn.LINEAR),this._magnificationFilter=y(e.magnificationFilter,xi.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,Nbe(e,this),Object.defineProperties(this,{type:{value:this.type,writable:!1}}),u(Ye._uniformList[this.type])||(Ye._uniformList[this.type]=Object.keys(this._uniforms))}Ye._uniformList={};Ye.fromType=function(e,t){let n=new Ye({fabric:{type:e}});if(u(t))for(let i in t)t.hasOwnProperty(i)&&(n.uniforms[i]=t[i]);return n};Ye.prototype.isTranslucent=function(){if(u(this.translucent))return typeof this.translucent=="function"?this.translucent():this.translucent;let e=!0,t=this._translucentFunctions,n=t.length;for(let i=0;i<n;++i){let o=t[i];if(typeof o=="function"?e=e&&o():e=e&&o,!e)break}return e};Ye.prototype.update=function(e){this._defaultTexture=e.defaultTexture;let t,n,i=this._loadedImages,o=i.length;for(t=0;t<o;++t){let c=i[t];n=c.id;let l=c.image,f;Array.isArray(l)&&(f=l.slice(1,l.length).map(function(A){return A.bufferView}),l=l[0]);let d=new fn({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter}),p;u(l.internalFormat)?p=new Mt({context:e,pixelFormat:l.internalFormat,width:l.width,height:l.height,source:{arrayBufferView:l.bufferView,mipLevels:f},sampler:d}):p=new Mt({context:e,source:l,sampler:d});let g=this._textures[n];u(g)&&g!==this._defaultTexture&&g.destroy(),this._textures[n]=p;let h=`${n}Dimensions`;if(this.uniforms.hasOwnProperty(h)){let A=this.uniforms[h];A.x=p._width,A.y=p._height}}i.length=0;let r=this._loadedCubeMaps;for(o=r.length,t=0;t<o;++t){let c=r[t];n=c.id;let l=c.images,f=new ka({context:e,source:{positiveX:l[0],negativeX:l[1],positiveY:l[2],negativeY:l[3],positiveZ:l[4],negativeZ:l[5]},sampler:new fn({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter})});this._textures[n]=f}r.length=0;let s=this._updateFunctions;for(o=s.length,t=0;t<o;++t)s[t](this,e);let a=this.materials;for(let c in a)a.hasOwnProperty(c)&&a[c].update(e)};Ye.prototype.isDestroyed=function(){return!1};Ye.prototype.destroy=function(){let e=this._textures;for(let n in e)if(e.hasOwnProperty(n)){let i=e[n];i!==this._defaultTexture&&i.destroy()}let t=this.materials;for(let n in t)t.hasOwnProperty(n)&&t[n].destroy();return ue(this)};function Nbe(e,t){e=y(e,y.EMPTY_OBJECT),t._strict=y(e.strict,!1),t._count=y(e.count,0),t._template=je(y(e.fabric,y.EMPTY_OBJECT)),t._template.uniforms=je(y(t._template.uniforms,y.EMPTY_OBJECT)),t._template.materials=je(y(t._template.materials,y.EMPTY_OBJECT)),t.type=u(t._template.type)?t._template.type:Hn(),t.shaderSource="",t.materials={},t.uniforms={},t._uniforms={},t._translucentFunctions=[];let n,i=Ye._materialCache.getMaterial(t.type);if(u(i)){let r=je(i.fabric,!0);t._template=ht(t._template,r,!0),n=i.translucent}kbe(t),u(i)||Ye._materialCache.addMaterial(t.type,t),Hbe(t),Ybe(t),Xbe(t);let o=t._translucentFunctions.length===0?!0:void 0;if(n=y(n,o),n=y(e.translucent,n),u(n))if(typeof n=="function"){let r=function(){return n(t)};t._translucentFunctions.push(r)}else t._translucentFunctions.push(n)}function JG(e,t,n,i){if(u(e)){for(let o in e)if(e.hasOwnProperty(o)){let r=t.indexOf(o)!==-1;(i&&!r||!i&&r)&&n(o,t)}}}function xZ(e,t){}function Fbe(e,t){}var Ube=["type","materials","uniforms","components","source"],Vbe=["diffuse","specular","shininess","normal","emission","alpha"];function kbe(e){let t=e._template,n=t.uniforms,i=t.materials,o=t.components;JG(t,Ube,xZ,!0),JG(o,Vbe,xZ,!0);let r=[];for(let s in i)i.hasOwnProperty(s)&&r.push(s);JG(n,r,Fbe,!1)}function zbe(e,t){let n=t._template.materials;for(let i in n)if(n.hasOwnProperty(i)&&e.indexOf(i)>-1)return!0;return!1}function Hbe(e){let t=e._template.components,n=e._template.source;if(u(n))e.shaderSource+=`${n}
`;else{if(e.shaderSource+=`czm_material czm_getMaterial(czm_materialInput materialInput)
{
`,e.shaderSource+=`czm_material material = czm_getDefaultMaterial(materialInput);
`,u(t)){let i=Object.keys(e._template.materials).length>0;for(let o in t)if(t.hasOwnProperty(o))if(o==="diffuse"||o==="emission"){let s=i&&zbe(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;
}
`}}var CZ={mat2:Qi,mat3:Z,mat4:B},Gbe=/\.ktx2$/i;function Wbe(e){let t;return function(n,i){let o=n.uniforms,r=o[e],s=t!==r,a=!u(r)||r===Ye.DefaultImageId;t=r;let c=n._textures[e],l,f;if(r instanceof HTMLVideoElement){if(r.readyState>=2){if(s&&u(c)&&(c!==i.defaultTexture&&c.destroy(),c=void 0),!u(c)||c===i.defaultTexture){let p=new fn({minificationFilter:n._minificationFilter,magnificationFilter:n._magnificationFilter});c=new Mt({context:i,source:r,sampler:p}),n._textures[e]=c;return}c.copyFrom({source:r})}else u(c)||(n._textures[e]=i.defaultTexture);return}if(r instanceof Mt&&r!==c){n._texturePaths[e]=void 0;let p=n._textures[e];u(p)&&p!==n._defaultTexture&&p.destroy(),n._textures[e]=r,l=`${e}Dimensions`,o.hasOwnProperty(l)&&(f=o[l],f.x=r._width,f.y=r._height);return}if(s&&u(c)&&a&&(c!==n._defaultTexture&&c.destroy(),c=void 0),u(c)||(n._texturePaths[e]=void 0,c=n._textures[e]=n._defaultTexture,l=`${e}Dimensions`,o.hasOwnProperty(l)&&(f=o[l],f.x=c._width,f.y=c._height)),a)return;let d=r instanceof Ie;if(!u(n._texturePaths[e])||d&&r.url!==n._texturePaths[e].url||!d&&r!==n._texturePaths[e]){if(typeof r=="string"||d){let p=d?r:Ie.createIfNeeded(r),g;Gbe.test(p.url)?g=sl(p.url):g=p.fetchImage(),Promise.resolve(g).then(function(h){n._loadedImages.push({id:e,image:h})}).catch(function(){u(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 jbe(e){return function(t,n){let i=t.uniforms[e];if(i instanceof ka){let r=t._textures[e];r!==t._defaultTexture&&r.destroy(),t._texturePaths[e]=void 0,t._textures[e]=i;return}if(u(t._textures[e])||(t._texturePaths[e]=void 0,t._textures[e]=n.defaultCubeMap),i===Ye.DefaultCubeMapId)return;let o=i.positiveX+i.negativeX+i.positiveY+i.negativeY+i.positiveZ+i.negativeZ;if(o!==t._texturePaths[e]){let 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 Ybe(e){let t=e._template.uniforms;for(let n in t)t.hasOwnProperty(n)&&TZ(e,n)}function TZ(e,t){let n=e._strict,i=e._template.uniforms,o=i[t],r=qbe(o),s;if(r==="channels")s=jv(e,t,o,!1);else{if(r==="sampler2D"){let l=`${t}Dimensions`;Kbe(e,l)>0&&(i[l]={type:"ivec3",x:1,y:1},TZ(e,l))}if(!new RegExp(`uniform\\s+${r}\\s+${t}\\s*;`).test(e.shaderSource)){let l=`uniform ${r} ${t};`;e.shaderSource=l+e.shaderSource}let c=`${t}_${e._count++}`;if(s=jv(e,t,c),e.uniforms[t]=o,r==="sampler2D")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(Wbe(t));else if(r==="samplerCube")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(jbe(t));else if(r.indexOf("mat")!==-1){let l=new CZ[r];e._uniforms[c]=function(){return CZ[r].fromColumnMajorArray(e.uniforms[t],l)}}else e._uniforms[c]=function(){return e.uniforms[t]}}}function qbe(e){let t=e.type;if(!u(t)){let 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===Ye.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(let o in e)e.hasOwnProperty(o)&&(i+=1);i>=2&&i<=4?t=`vec${i}`:i===6&&(t="samplerCube")}}return t}function Xbe(e){let t=e._strict,n=e._template.materials;for(let i in n)if(n.hasOwnProperty(i)){let o=new Ye({strict:t,fabric:n[i],count:e._count});e._count=o._count,e._uniforms=ht(e._uniforms,o._uniforms,!0),e.materials[i]=o,e._translucentFunctions=e._translucentFunctions.concat(o._translucentFunctions);let r="czm_getMaterial",s=`${r}_${e._count++}`;jv(o,r,s),e.shaderSource=o.shaderSource+e.shaderSource;let a=`${s}(
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);
}
`;var qv=`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;
}
`;var P0=`in vec4 v_color;
void main()
{
out_FragColor = czm_gammaCorrect(v_color);
}
`;var Xv=`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 Xh(e){e=y(e,y.EMPTY_OBJECT);let t=y(e.translucent,!0),n=y(e.closed,!1),i=y(e.flat,!1),o=i?Xv:qv,r=i?P0:Yv,s=i?Xh.FLAT_VERTEX_FORMAT:Xh.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=y(e.vertexShaderSource,o),this._fragmentShaderSource=y(e.fragmentShaderSource,r),this._renderState=eo.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=s,this._flat=i,this._faceForward=y(e.faceForward,!n)}Object.defineProperties(Xh.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}}});Xh.VERTEX_FORMAT=Oe.POSITION_AND_NORMAL;Xh.FLAT_VERTEX_FORMAT=Oe.POSITION_ONLY;Xh.prototype.getFragmentShaderSource=eo.prototype.getFragmentShaderSource;Xh.prototype.isTranslucent=eo.prototype.isTranslucent;Xh.prototype.getRenderState=eo.prototype.getRenderState;var sn=Xh;function lT(e){this._definitionChanged=new ye,this._color=void 0,this._colorSubscription=void 0,this.color=e}Object.defineProperties(lT.prototype,{isConstant:{get:function(){return j.isConstant(this._color)}},definitionChanged:{get:function(){return this._definitionChanged}},color:ce("color")});lT.prototype.getType=function(e){return"Color"};lT.prototype.getValue=function(e,t){return u(t)||(t={}),t.color=j.getValueOrClonedDefault(this._color,e,k.WHITE,t.color),t};lT.prototype.equals=function(e){return this===e||e instanceof lT&&j.equals(this._color,e._color)};var Nt=lT;function eg(e){e=y(e,y.EMPTY_OBJECT),this._ellipsoid=y(e.ellipsoid,oe.WGS84),this._rectangle=y(e.rectangle,le.MAX_VALUE),this._projection=new Si(this._ellipsoid),this._numberOfLevelZeroTilesX=y(e.numberOfLevelZeroTilesX,2),this._numberOfLevelZeroTilesY=y(e.numberOfLevelZeroTilesY,1)}Object.defineProperties(eg.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}});eg.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e};eg.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e};eg.prototype.rectangleToNativeRectangle=function(e,t){let n=P.toDegrees(e.west),i=P.toDegrees(e.south),o=P.toDegrees(e.east),r=P.toDegrees(e.north);return u(t)?(t.west=n,t.south=i,t.east=o,t.north=r,t):new le(n,i,o,r)};eg.prototype.tileXYToNativeRectangle=function(e,t,n,i){let o=this.tileXYToRectangle(e,t,n,i);return o.west=P.toDegrees(o.west),o.south=P.toDegrees(o.south),o.east=P.toDegrees(o.east),o.north=P.toDegrees(o.north),o};eg.prototype.tileXYToRectangle=function(e,t,n,i){let o=this._rectangle,r=this.getNumberOfXTilesAtLevel(n),s=this.getNumberOfYTilesAtLevel(n),a=o.width/r,c=e*a+o.west,l=(e+1)*a+o.west,f=o.height/s,d=o.north-t*f,p=o.north-(t+1)*f;return u(i)||(i=new le(c,p,l,d)),i.west=c,i.south=p,i.east=l,i.north=d,i};eg.prototype.positionToTileXY=function(e,t,n){let i=this._rectangle;if(!le.contains(i,e))return;let o=this.getNumberOfXTilesAtLevel(t),r=this.getNumberOfYTilesAtLevel(t),s=i.width/o,a=i.height/r,c=e.longitude;i.east<i.west&&(c+=P.TWO_PI);let l=(c-i.west)/s|0;l>=o&&(l=o-1);let f=(i.north-e.latitude)/a|0;return f>=r&&(f=r-1),u(n)?(n.x=l,n.y=f,n):new H(l,f)};var Hi=eg;var EZ=new m,bZ=new m,SZ=new he,ZG=new m,Jbe=new m,vZ=new ae,Zbe=new Hi,Kv=[new he,new he,new he,new he],Jv=new H,zr={};zr.initialize=function(){let e=zr._initPromise;return u(e)||(e=Ie.fetchJson(tn("Assets/approximateTerrainHeights.json")).then(function(t){zr._terrainHeights=t}),zr._initPromise=e),e};zr.getMinimumMaximumHeights=function(e,t){t=y(t,oe.WGS84);let n=wZ(e),i=zr._defaultMinTerrainHeight,o=zr._defaultMaxTerrainHeight;if(u(n)){let r=`${n.level}-${n.x}-${n.y}`,s=zr._terrainHeights[r];u(s)&&(i=s[0],o=s[1]),t.cartographicToCartesian(le.northeast(e,SZ),EZ),t.cartographicToCarte
${n}`),l=`Vertex shader failed to compile. Compile log: ${c}`):(c=e.getShaderInfoLog(r),console.error(`${Im}Fragment shader compile log: ${c}`),console.error(`${Im} Fragment shader source:
${i}`),l=`Fragment shader failed to compile. Compile log: ${c}`),e.deleteShader(o),e.deleteShader(r),e.deleteProgram(s),new de(l);function d(p,g){if(!u(f))return;let h=f.getTranslatedShaderSource(p);if(h===""){console.error(`${Im}${g} shader translation failed.`);return}console.error(`${Im}Translated ${g} shaderSource:
${h}`)}}function wve(e,t,n){let i={};for(let o=0;o<n;++o){let r=e.getActiveAttrib(t,o),s=e.getAttribLocation(t,r.name);i[r.name]={name:r.name,type:r.type,index:s}}return i}function Dve(e,t){let n={},i=[],o=[],r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<r;++s){let a=e.getActiveUniform(t,s),c="[0]",l=a.name.indexOf(c,a.name.length-c.length)!==-1?a.name.slice(0,a.name.length-3):a.name;if(l.indexOf("gl_")!==0)if(a.name.indexOf("[")<0){let f=e.getUniformLocation(t,l);if(f!==null){let d=tw(e,a,l,f);n[l]=d,i.push(d),d._setSampler&&o.push(d)}}else{let f,d,p,g,h=l.indexOf("[");if(h>=0){if(f=n[l.slice(0,h)],!u(f))continue;d=f._locations,d.length<=1&&(p=f.value,g=e.getUniformLocation(t,l),g!==null&&(d.push(g),p.push(e.getUniform(t,g))))}else{d=[];for(let A=0;A<a.size;++A)g=e.getUniformLocation(t,`${l}[${A}]`),g!==null&&d.push(g);f=nw(e,a,l,d),n[l]=f,i.push(f),f._setSampler&&o.push(f)}}}return{uniformsByName:n,uniforms:i,samplerUniforms:o}}function Ive(e,t){let n=[],i=[];for(let o in t)if(t.hasOwnProperty(o)){let r=t[o],s=o,a=e._duplicateUniformNames[s];u(a)&&(r.name=a,s=a);let c=Kh[s];u(c)?n.push({uniform:r,automaticUniform:c}):i.push(r)}return{automaticUniforms:n,manualUniforms:i}}function Pve(e,t,n){e.useProgram(t);let i=0,o=n.length;for(let r=0;r<o;++r)i=n[r]._setSampler(i);return e.useProgram(null),i}function W3(e){u(e._program)||RQ(e)}function RQ(e){let t=e._program,n=e._gl,i=vve(n,e,e._debugShaders),o=n.getProgramParameter(i,n.ACTIVE_ATTRIBUTES),r=Dve(n,i),s=Ive(e,r.uniformsByName);e._program=i,e._numberOfVertexAttributes=o,e._vertexAttributes=wve(n,i,o),e._uniformsByName=r.uniformsByName,e._uniforms=r.uniforms,e._automaticUniforms=s.automaticUniforms,e._manualUniforms=s.manualUniforms,e.maximumTextureUnitIndex=Pve(n,i,r.samplerUniforms),t&&e._gl.deleteProgram(t),typeof spector<"u"&&(e._program.__SPECTOR_rebuildProgram=function(a,c,l,f){let d=e._vertexShaderText,p=e._fragmentShaderText,g=/ ! = /g;e._vertexShaderText=a.replace(g," != "),e._fragmentShaderText=c.replace(g," != ");try{RQ(e),l(e._program)}catch(h){e._vertexShaderText=d,e._fragmentShaderText=p;let x=/(?:Compile|Link) error: ([^]*)/.exec(h.message);f(x?x[1]:h.message)}})}Jh.prototype._bind=function(){W3(this),this._gl.useProgram(this._program)};Jh.prototype._setUniforms=function(e,t,n){let i,o;if(u(e)){let a=this._manualUniforms;for(i=a.length,o=0;o<i;++o){let c=a[o];c.value=e[c.name]()}}let r=this._automaticUniforms;for(i=r.length,o=0;o<i;++o){let a=r[o];a.uniform.value=a.automaticUniform.getValue(t)}let s=this._uniforms;for(i=s.length,o=0;o<i;++o)s[o].set();if(n){let a=this._gl,c=this._program;a.validateProgram(c)}};Jh.prototype.isDestroyed=function(){return!1};Jh.prototype.destroy=function(){this._cachedShader.cache.releaseShaderProgram(this)};Jh.prototype.finalDestroy=function(){return this._gl.deleteProgram(this._program),ue(this)};var Jt=Jh;var iw=`/**
* A built-in GLSL floating-point constant for converting radians to degrees.
*
* @alias czm_degreesPerRadian
* @glslConstant
*
* @see CesiumMath.DEGREES_PER_RADIAN
*
* @example
* // GLSL declaration
* const float czm_degreesPerRadian = ...;
*
* // Example
* float deg = czm_degreesPerRadian * rad;
*/
const float czm_degreesPerRadian = 57.29577951308232;
`;var ow=`/**
* A built-in GLSL vec2 constant for defining the depth range.
* This is a workaround to a bug where IE11 does not implement gl_DepthRange.
*
* @alias czm_depthRange
* @glslConstant
*
* @example
* // GLSL declaration
* float depthRangeNear = czm_depthRange.near;
* float depthRangeFar = czm_depthRange.far;
*
*/
const czm_depthRangeStruct czm_depthRange = czm_depthRangeStruct(0.0, 1.0);
`;var rw=`/**
* 0.1
*
* @name czm_epsilon1
* @glslConstant
*/
const float czm_epsilon1 = 0.1;
`;var sw=`/**
* 0.01
*
* @name czm_epsilon2
* @glslConstant
*/
const float czm_epsilon2 = 0.01;
`;var aw=`/**
* 0.001
*
* @name czm_epsilon3
* @glslConstant
*/
const float czm_epsilon3 = 0.001;
`;var cw=`/**
* 0.0001
*
* @name czm_epsilon4
* @glslConstant
*/
const float czm_epsilon4 = 0.0001;
`;var lw=`/**
* 0.00001
*
* @name czm_epsilon5
* @glslConstant
*/
const float czm_epsilon5 = 0.00001;
`;var uw=`/**
* 0.000001
*
* @name czm_epsilon6
* @glslConstant
*/
const float czm_epsilon6 = 0.000001;
`;var fw=`/**
* 0.0000001
*
* @name czm_epsilon7
* @glslConstant
*/
const float czm_epsilon7 = 0.0000001;
`;var dw=`/**
* DOC_TBA
*
* @name czm_infinity
* @glslConstant
*/
const float czm_infinity = 5906376272000.0; // Distance from the Sun to Pluto in meters. TODO: What is best given lowp, mediump, and highp?
`;var mw=`/**
* A built-in GLSL floating-point constant for <code>1/pi</code>.
*
* @alias czm_oneOverPi
* @glslConstant
*
* @see CesiumMath.ONE_OVER_PI
*
* @example
* // GLSL declaration
* const float czm_oneOverPi = ...;
*
* // Example
* float pi = 1.0 / czm_oneOverPi;
*/
const float czm_oneOverPi = 0.3183098861837907;
`;var hw=`/**
* A built-in GLSL floating-point constant for <code>1/2pi</code>.
*
* @alias czm_oneOverTwoPi
* @glslConstant
*
* @see CesiumMath.ONE_OVER_TWO_PI
*
* @example
* // GLSL declaration
* const float czm_oneOverTwoPi = ...;
*
* // Example
* float pi = 2.0 * czm_oneOverTwoPi;
*/
const float czm_oneOverTwoPi = 0.15915494309189535;
`;var pw=`/**
* The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE}
*
* @name czm_passCesium3DTile
* @glslConstant
*
* @see czm_pass
*/
const float czm_passCesium3DTile = 4.0;
`;var _w=`/**
* The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION}
*
* @name czm_passCesium3DTileClassification
* @glslConstant
*
* @see czm_pass
*/
const float czm_passCesium3DTileClassification = 5.0;
`;var gw=`/**
* The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW}
*
* @name czm_passCesium3DTileClassificationIgnoreShow
* @glslConstant
*
* @see czm_pass
*/
const float czm_passCesium3DTileClassificationIgnoreShow = 6.0;
`;var yw=`/**
* The automatic GLSL constant for {@link Pass#CLASSIFICATION}
*
* @name czm_passClassification
* @glslConstant
*
* @see czm_pass
*/
const float czm_passClassification = 7.0;
`;var Aw=`/**
* The automatic GLSL constant for {@link Pass#COMPUTE}
*
* @name czm_passCompute
* @glslConstant
*
* @see czm_pass
*/
const float czm_passCompute = 1.0;
`;var xw=`/**
* The automatic GLSL constant for {@link Pass#ENVIRONMENT}
*
* @name czm_passEnvironment
* @glslConstant
*
* @see czm_pass
*/
const float czm_passEnvironment = 0.0;
`;var Cw=`/**
* The automatic GLSL constant for {@link Pass#GLOBE}
*
* @name czm_passGlobe
* @glslConstant
*
* @see czm_pass
*/
const float czm_passGlobe = 2.0;
`;var Tw=`/**
* The automatic GLSL constant for {@link Pass#OPAQUE}
*
* @name czm_passOpaque
* @glslConstant
*
* @see czm_pass
*/
const float czm_passOpaque = 7.0;
`;var Ew=`/**
* The automatic GLSL constant for {@link Pass#OVERLAY}
*
* @name czm_passOverlay
* @glslConstant
*
* @see czm_pass
*/
const float czm_passOverlay = 10.0;
`;var bw=`/**
* The automatic GLSL constant for {@link Pass#TERRAIN_CLASSIFICATION}
*
* @name czm_passTerrainClassification
* @glslConstant
*
* @see czm_pass
*/
const float czm_passTerrainClassification = 3.0;
`;var Sw=`/**
* The automatic GLSL constant for {@link Pass#TRANSLUCENT}
*
* @name czm_passTranslucent
* @glslConstant
*
* @see czm_pass
*/
const float czm_passTranslucent = 8.0;
`;var vw=`/**
* The automatic GLSL constant for {@link Pass#VOXELS}
*
* @name czm_passVoxels
* @glslConstant
*
* @see czm_pass
*/
const float czm_passVoxels = 9.0;
`;var ww=`/**
* A built-in GLSL floating-point constant for <code>Math.PI</code>.
*
* @alias czm_pi
* @glslConstant
*
* @see CesiumMath.PI
*
* @example
* // GLSL declaration
* const float czm_pi = ...;
*
* // Example
* float twoPi = 2.0 * czm_pi;
*/
const float czm_pi = 3.141592653589793;
`;var Dw=`/**
* A built-in GLSL floating-point constant for <code>pi/4</code>.
*
* @alias czm_piOverFour
* @glslConstant
*
* @see CesiumMath.PI_OVER_FOUR
*
* @example
* // GLSL declaration
* const float czm_piOverFour = ...;
*
* // Example
* float pi = 4.0 * czm_piOverFour;
*/
const float czm_piOverFour = 0.7853981633974483;
`;var Iw=`/**
* A built-in GLSL floating-point constant for <code>pi/6</code>.
*
* @alias czm_piOverSix
* @glslConstant
*
* @see CesiumMath.PI_OVER_SIX
*
* @example
* // GLSL declaration
* const float czm_piOverSix = ...;
*
* // Example
* float pi = 6.0 * czm_piOverSix;
*/
const float czm_piOverSix = 0.5235987755982988;
`;var Pw=`/**
* A built-in GLSL floating-point constant for <code>pi/3</code>.
*
* @alias czm_piOverThree
* @glslConstant
*
* @see CesiumMath.PI_OVER_THREE
*
* @example
* // GLSL declaration
* const float czm_piOverThree = ...;
*
* // Example
* float pi = 3.0 * czm_piOverThree;
*/
const float czm_piOverThree = 1.0471975511965976;
`;var Ow=`/**
* A built-in GLSL floating-point constant for <code>pi/2</code>.
*
* @alias czm_piOverTwo
* @glslConstant
*
* @see CesiumMath.PI_OVER_TWO
*
* @example
* // GLSL declaration
* const float czm_piOverTwo = ...;
*
* // Example
* float pi = 2.0 * czm_piOverTwo;
*/
const float czm_piOverTwo = 1.5707963267948966;
`;var Mw=`/**
* A built-in GLSL floating-point constant for converting degrees to radians.
*
* @alias czm_radiansPerDegree
* @glslConstant
*
* @see CesiumMath.RADIANS_PER_DEGREE
*
* @example
* // GLSL declaration
* const float czm_radiansPerDegree = ...;
*
* // Example
* float rad = czm_radiansPerDegree * deg;
*/
const float czm_radiansPerDegree = 0.017453292519943295;
`;var Rw=`/**
* The constant identifier for the 2D {@link SceneMode}
*
* @name czm_sceneMode2D
* @glslConstant
* @see czm_sceneMode
* @see czm_sceneModeColumbusView
* @see czm_sceneMode3D
* @see czm_sceneModeMorphing
*/
const float czm_sceneMode2D = 2.0;
`;var Bw=`/**
* The constant identifier for the 3D {@link SceneMode}
*
* @name czm_sceneMode3D
* @glslConstant
* @see czm_sceneMode
* @see czm_sceneMode2D
* @see czm_sceneModeColumbusView
* @see czm_sceneModeMorphing
*/
const float czm_sceneMode3D = 3.0;
`;var Lw=`/**
* The constant identifier for the Columbus View {@link SceneMode}
*
* @name czm_sceneModeColumbusView
* @glslConstant
* @see czm_sceneMode
* @see czm_sceneMode2D
* @see czm_sceneMode3D
* @see czm_sceneModeMorphing
*/
const float czm_sceneModeColumbusView = 1.0;
`;var Nw=`/**
* The constant identifier for the Morphing {@link SceneMode}
*
* @name czm_sceneModeMorphing
* @glslConstant
* @see czm_sceneMode
* @see czm_sceneMode2D
* @see czm_sceneModeColumbusView
* @see czm_sceneMode3D
*/
const float czm_sceneModeMorphing = 0.0;
`;var Fw=`/**
* A built-in GLSL floating-point constant for one solar radius.
*
* @alias czm_solarRadius
* @glslConstant
*
* @see CesiumMath.SOLAR_RADIUS
*
* @example
* // GLSL declaration
* const float czm_solarRadius = ...;
*/
const float czm_solarRadius = 695500000.0;
`;var Uw=`/**
* A built-in GLSL floating-point constant for <code>3pi/2</code>.
*
* @alias czm_threePiOver2
* @glslConstant
*
* @see CesiumMath.THREE_PI_OVER_TWO
*
* @example
* // GLSL declaration
* const float czm_threePiOver2 = ...;
*
* // Example
* float pi = (2.0 / 3.0) * czm_threePiOver2;
*/
const float czm_threePiOver2 = 4.71238898038469;
`;var Vw=`/**
* A built-in GLSL floating-point constant for <code>2pi</code>.
*
* @alias czm_twoPi
* @glslConstant
*
* @see CesiumMath.TWO_PI
*
* @example
* // GLSL declaration
* const float czm_twoPi = ...;
*
* // Example
* float pi = czm_twoPi / 2.0;
*/
const float czm_twoPi = 6.283185307179586;
`;var kw=`/**
* The maximum latitude, in radians, both North and South, supported by a Web Mercator
* (EPSG:3857) projection. Technically, the Mercator projection is defined
* for any latitude up to (but not including) 90 degrees, but it makes sense
* to cut it off sooner because it grows exponentially with increasing latitude.
* The logic behind this particular cutoff value, which is the one used by
* Google Maps, Bing Maps, and Esri, is that it makes the projection
* square. That is, the rectangle is equal in the X and Y directions.
*
* The constant value is computed as follows:
* czm_pi * 0.5 - (2.0 * atan(exp(-czm_pi)))
*
* @name czm_webMercatorMaxLatitude
* @glslConstant
*/
const float czm_webMercatorMaxLatitude = 1.4844222297453324;
`;var zw=`/**
* @name czm_depthRangeStruct
* @glslStruct
*/
struct czm_depthRangeStruct
{
float near;
float far;
};
`;var Hw=`/**
* Holds material information that can be used for lighting. Returned by all czm_getMaterial functions.
*
* @name czm_material
* @glslStruct
*
* @property {vec3} diffuse Incoming light that scatters evenly in all directions.
* @property {float} specular Intensity of incoming light reflecting in a single direction.
* @property {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight.
* @property {vec3} normal Surface's normal in eye coordinates. It is used for effects such as normal mapping. The default is the surface's unmodified normal.
* @property {vec3} emission Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.
* @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.
*/
struct czm_material
{
vec3 diffuse;
float specular;
float shininess;
vec3 normal;
vec3 emission;
float alpha;
};
`;var Gw=`/**
* Used as input to every material's czm_getMaterial function.
*
* @name czm_materialInput
* @glslStruct
*
* @property {float} s 1D texture coordinates.
* @property {vec2} st 2D texture coordinates.
* @property {vec3} str 3D texture coordinates.
* @property {vec3} normalEC Unperturbed surface normal in eye coordinates.
* @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space.
* @property {vec3} positionToEyeEC Vector from the fragment to the eye in eye coordinates. The magnitude is the distance in meters from the fragment to the eye.
* @property {float} height The height of the terrain in meters above or below the WGS84 ellipsoid. Only available for globe materials.
* @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.
* @property {float} aspect The aspect of the terrain in radians. 0 is East, pi/2 is North, pi is West, 3pi/2 is South. Only available for globe materials.
*/
struct czm_materialInput
{
float s;
vec2 st;
vec3 str;
vec3 normalEC;
mat3 tangentToEyeMatrix;
vec3 positionToEyeEC;
float height;
float slope;
float aspect;
};
`;var Ww=`/**
* Struct for representing a material for a {@link Model}. The model
* rendering pipeline will pass this struct between material, custom shaders,
* and lighting stages. This is not to be confused with {@link czm_material}
* which is used by the older Fabric materials system, although they are similar.
* <p>
* All color values (diffuse, specular, emissive) are in linear color space.
* </p>
*
* @name czm_modelMaterial
* @glslStruct
*
* @property {vec3} diffuse Incoming light that scatters evenly in all directions.
* @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.
* @property {vec3} specular Color of reflected light at normal incidence in PBR materials. This is sometimes referred to as f0 in the literature.
* @property {float} roughness A number from 0.0 to 1.0 representing how rough the surface is. Values near 0.0 produce glossy surfaces, while values near 1.0 produce rough surfaces.
* @property {vec3} normalEC Surface's normal in eye coordinates. It is used for effects such as normal mapping. The default is the surface's unmodified normal.
* @property {float} occlusion Ambient occlusion recieved at this point on the material. 1.0 means fully lit, 0.0 means fully occluded.
* @property {vec3} emissive Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.
*/
struct czm_modelMaterial {
vec3 diffuse;
float alpha;
vec3 specular;
float roughness;
vec3 normalEC;
float occlusion;
vec3 emissive;
};
`;var jw=`/**
* Struct for representing the output of a custom vertex shader.
*
* @name czm_modelVertexOutput
* @glslStruct
*
* @see {@link CustomShader}
* @see {@link Model}
*
* @property {vec3} positionMC The position of the vertex in model coordinates
* @property {float} pointSize A custom value for gl_PointSize. This is only used for point primitives.
*/
struct czm_modelVertexOutput {
vec3 positionMC;
float pointSize;
};
`;var Yw=`/**
* Parameters for {@link czm_pbrLighting}
*
* @name czm_material
* @glslStruct
*
* @property {vec3} diffuseColor the diffuse color of the material for the lambert term of the rendering equation
* @property {float} roughness a value from 0.0 to 1.0 that indicates how rough the surface of the material is.
* @property {vec3} f0 The reflectance of the material at normal incidence
*/
struct czm_pbrParameters
{
vec3 diffuseColor;
float roughness;
vec3 f0;
};
`;var qw=`/**
* DOC_TBA
*
* @name czm_ray
* @glslStruct
*/
struct czm_ray
{
vec3 origin;
vec3 direction;
};
`;var Xw=`/**
* DOC_TBA
*
* @name czm_raySegment
* @glslStruct
*/
struct czm_raySegment
{
float start;
float stop;
};
/**
* DOC_TBA
*
* @name czm_emptyRaySegment
* @glslConstant
*/
const czm_raySegment czm_emptyRaySegment = czm_raySegment(-czm_infinity, -czm_infinity);
/**
* DOC_TBA
*
* @name czm_fullRaySegment
* @glslConstant
*/
const czm_raySegment czm_fullRaySegment = czm_raySegment(0.0, czm_infinity);
`;var Kw=`struct czm_shadowParameters
{
#ifdef USE_CUBE_MAP_SHADOW
vec3 texCoords;
#else
vec2 texCoords;
#endif
float depthBias;
float depth;
float nDotL;
vec2 texelStepSize;
float normalShadingSmooth;
float darkness;
};
`;var Jw=`/**
* Converts an HSB color (hue, saturation, brightness) to RGB
* HSB <-> RGB conversion with minimal branching: {@link http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl}
*
* @name czm_HSBToRGB
* @glslFunction
*
* @param {vec3} hsb The color in HSB.
*
* @returns {vec3} The color in RGB.
*
* @example
* vec3 hsb = czm_RGBToHSB(rgb);
* hsb.z *= 0.1;
* rgb = czm_HSBToRGB(hsb);
*/
const vec4 K_HSB2RGB = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 czm_HSBToRGB(vec3 hsb)
{
vec3 p = abs(fract(hsb.xxx + K_HSB2RGB.xyz) * 6.0 - K_HSB2RGB.www);
return hsb.z * mix(K_HSB2RGB.xxx, clamp(p - K_HSB2RGB.xxx, 0.0, 1.0), hsb.y);
}
`;var Zw=`/**
* Converts an HSL color (hue, saturation, lightness) to RGB
* HSL <-> RGB conversion: {@link http://www.chilliant.com/rgb2hsv.html}
*
* @name czm_HSLToRGB
* @glslFunction
*
* @param {vec3} rgb The color in HSL.
*
* @returns {vec3} The color in RGB.
*
* @example
* vec3 hsl = czm_RGBToHSL(rgb);
* hsl.z *= 0.1;
* rgb = czm_HSLToRGB(hsl);
*/
vec3 hueToRGB(float hue)
{
float r = abs(hue * 6.0 - 3.0) - 1.0;
float g = 2.0 - abs(hue * 6.0 - 2.0);
float b = 2.0 - abs(hue * 6.0 - 4.0);
return clamp(vec3(r, g, b), 0.0, 1.0);
}
vec3 czm_HSLToRGB(vec3 hsl)
{
vec3 rgb = hueToRGB(hsl.x);
float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
return (rgb - 0.5) * c + hsl.z;
}
`;var Qw=`/**
* Converts an RGB color to HSB (hue, saturation, brightness)
* HSB <-> RGB conversion with minimal branching: {@link http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl}
*
* @name czm_RGBToHSB
* @glslFunction
*
* @param {vec3} rgb The color in RGB.
*
* @returns {vec3} The color in HSB.
*
* @example
* vec3 hsb = czm_RGBToHSB(rgb);
* hsb.z *= 0.1;
* rgb = czm_HSBToRGB(hsb);
*/
const vec4 K_RGB2HSB = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec3 czm_RGBToHSB(vec3 rgb)
{
vec4 p = mix(vec4(rgb.bg, K_RGB2HSB.wz), vec4(rgb.gb, K_RGB2HSB.xy), step(rgb.b, rgb.g));
vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));
float d = q.x - min(q.w, q.y);
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + czm_epsilon7)), d / (q.x + czm_epsilon7), q.x);
}
`;var $w=`/**
* Converts an RGB color to HSL (hue, saturation, lightness)
* HSL <-> RGB conversion: {@link http://www.chilliant.com/rgb2hsv.html}
*
* @name czm_RGBToHSL
* @glslFunction
*
* @param {vec3} rgb The color in RGB.
*
* @returns {vec3} The color in HSL.
*
* @example
* vec3 hsl = czm_RGBToHSL(rgb);
* hsl.z *= 0.1;
* rgb = czm_HSLToRGB(hsl);
*/
vec3 RGBtoHCV(vec3 rgb)
{
// Based on work by Sam Hocevar and Emil Persson
vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 2.0 / 3.0) : vec4(rgb.gb, 0.0, -1.0 / 3.0);
vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);
float c = q.x - min(q.w, q.y);
float h = abs((q.w - q.y) / (6.0 * c + czm_epsilon7) + q.z);
return vec3(h, c, q.x);
}
vec3 czm_RGBToHSL(vec3 rgb)
{
vec3 hcv = RGBtoHCV(rgb);
float l = hcv.z - hcv.y * 0.5;
float s = hcv.y / (1.0 - abs(l * 2.0 - 1.0) + czm_epsilon7);
return vec3(hcv.x, s, l);
}
`;var eD=`/**
* Converts an RGB color to CIE Yxy.
* <p>The conversion is described in
* {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}
* </p>
*
* @name czm_RGBToXYZ
* @glslFunction
*
* @param {vec3} rgb The color in RGB.
*
* @returns {vec3} The color in CIE Yxy.
*
* @example
* vec3 xyz = czm_RGBToXYZ(rgb);
* xyz.x = max(xyz.x - luminanceThreshold, 0.0);
* rgb = czm_XYZToRGB(xyz);
*/
vec3 czm_RGBToXYZ(vec3 rgb)
{
const mat3 RGB2XYZ = mat3(0.4124, 0.2126, 0.0193,
0.3576, 0.7152, 0.1192,
0.1805, 0.0722, 0.9505);
vec3 xyz = RGB2XYZ * rgb;
vec3 Yxy;
Yxy.r = xyz.g;
float temp = dot(vec3(1.0), xyz);
Yxy.gb = xyz.rg / temp;
return Yxy;
}
`;var tD=`/**
* Converts a CIE Yxy color to RGB.
* <p>The conversion is described in
* {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}
* </p>
*
* @name czm_XYZToRGB
* @glslFunction
*
* @param {vec3} Yxy The color in CIE Yxy.
*
* @returns {vec3} The color in RGB.
*
* @example
* vec3 xyz = czm_RGBToXYZ(rgb);
* xyz.x = max(xyz.x - luminanceThreshold, 0.0);
* rgb = czm_XYZToRGB(xyz);
*/
vec3 czm_XYZToRGB(vec3 Yxy)
{
const mat3 XYZ2RGB = mat3( 3.2405, -0.9693, 0.0556,
-1.5371, 1.8760, -0.2040,
-0.4985, 0.0416, 1.0572);
vec3 xyz;
xyz.r = Yxy.r * Yxy.g / Yxy.b;
xyz.g = Yxy.r;
xyz.b = Yxy.r * (1.0 - Yxy.g - Yxy.b) / Yxy.b;
return XYZ2RGB * xyz;
}
`;var nD=`// See:
// https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
vec3 czm_acesTonemapping(vec3 color) {
float g = 0.985;
float a = 0.065;
float b = 0.0001;
float c = 0.433;
float d = 0.238;
color = (color * (color + a) - b) / (color * (g * color + c) + d);
color = clamp(color, 0.0, 1.0);
return color;
}
`;var iD=`/**
* @private
*/
float czm_alphaWeight(float a)
{
float z = (gl_FragCoord.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2];
// See Weighted Blended Order-Independent Transparency for examples of different weighting functions:
// http://jcgt.org/published/0002/02/09/
return pow(a + 0.01, 4.0) + max(1e-2, min(3.0 * 1e3, 0.003 / (1e-5 + pow(abs(z) / 200.0, 4.0))));
}
`;var oD=`/**
* Procedural anti-aliasing by blurring two colors that meet at a sharp edge.
*
* @name czm_antialias
* @glslFunction
*
* @param {vec4} color1 The color on one side of the edge.
* @param {vec4} color2 The color on the other side of the edge.
* @param {vec4} currentcolor The current color, either <code>color1</code> or <code>color2</code>.
* @param {float} dist The distance to the edge in texture coordinates.
* @param {float} [fuzzFactor=0.1] Controls the blurriness between the two colors.
* @returns {vec4} The anti-aliased color.
*
* @example
* // GLSL declarations
* vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor);
* vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist);
*
* // get the color for a material that has a sharp edge at the line y = 0.5 in texture space
* float dist = abs(textureCoordinates.t - 0.5);
* vec4 currentColor = mix(bottomColor, topColor, step(0.5, textureCoordinates.t));
* vec4 color = czm_antialias(bottomColor, topColor, currentColor, dist, 0.1);
*/
vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor)
{
float val1 = clamp(dist / fuzzFactor, 0.0, 1.0);
float val2 = clamp((dist - 0.5) / fuzzFactor, 0.0, 1.0);
val1 = val1 * (1.0 - val2);
val1 = val1 * val1 * (3.0 - (2.0 * val1));
val1 = pow(val1, 0.5); //makes the transition nicer
vec4 midColor = (color1 + color2) * 0.5;
return mix(midColor, currentColor, val1);
}
vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist)
{
return czm_antialias(color1, color2, currentColor, dist, 0.1);
}
`;var rD=`/**
* Approximately computes spherical coordinates given a normal.
* Uses approximate inverse trigonometry for speed and consistency,
* since inverse trigonometry can differ from vendor-to-vendor and when compared with the CPU.
*
* @name czm_approximateSphericalCoordinates
* @glslFunction
*
* @param {vec3} normal arbitrary-length normal.
*
* @returns {vec2} Approximate latitude and longitude spherical coordinates.
*/
vec2 czm_approximateSphericalCoordinates(vec3 normal) {
// Project into plane with vertical for latitude
float latitudeApproximation = czm_fastApproximateAtan(sqrt(normal.x * normal.x + normal.y * normal.y), normal.z);
float longitudeApproximation = czm_fastApproximateAtan(normal.x, normal.y);
return vec2(latitudeApproximation, longitudeApproximation);
}
`;var sD=`/**
* Determines if the fragment is back facing
*
* @name czm_backFacing
* @glslFunction
*
* @returns {bool} <code>true</code> if the fragment is back facing; otherwise, <code>false</code>.
*/
bool czm_backFacing()
{
// !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/CesiumGS/cesium/pull/8494.
return gl_FrontFacing == false;
}
`;var aD=`/**
* Branchless ternary operator to be used when it's inexpensive to explicitly
* evaluate both possibilities for a float expression.
*
* @name czm_branchFreeTernary
* @glslFunction
*
* @param {bool} comparison A comparison statement
* @param {float} a Value to return if the comparison is true.
* @param {float} b Value to return if the comparison is false.
*
* @returns {float} equivalent of comparison ? a : b
*/
float czm_branchFreeTernary(bool comparison, float a, float b) {
float useA = float(comparison);
return a * useA + b * (1.0 - useA);
}
/**
* Branchless ternary operator to be used when it's inexpensive to explicitly
* evaluate both possibilities for a vec2 expression.
*
* @name czm_branchFreeTernary
* @glslFunction
*
* @param {bool} comparison A comparison statement
* @param {vec2} a Value to return if the comparison is true.
* @param {vec2} b Value to return if the comparison is false.
*
* @returns {vec2} equivalent of comparison ? a : b
*/
vec2 czm_branchFreeTernary(bool comparison, vec2 a, vec2 b) {
float useA = float(comparison);
return a * useA + b * (1.0 - useA);
}
/**
* Branchless ternary operator to be used when it's inexpensive to explicitly
* evaluate both possibilities for a vec3 expression.
*
* @name czm_branchFreeTernary
* @glslFunction
*
* @param {bool} comparison A comparison statement
* @param {vec3} a Value to return if the comparison is true.
* @param {vec3} b Value to return if the comparison is false.
*
* @returns {vec3} equivalent of comparison ? a : b
*/
vec3 czm_branchFreeTernary(bool comparison, vec3 a, vec3 b) {
float useA = float(comparison);
return a * useA + b * (1.0 - useA);
}
/**
* Branchless ternary operator to be used when it's inexpensive to explicitly
* evaluate both possibilities for a vec4 expression.
*
* @name czm_branchFreeTernary
* @glslFunction
*
* @param {bool} comparison A comparison statement
* @param {vec3} a Value to return if the comparison is true.
* @param {vec3} b Value to return if the comparison is false.
*
* @returns {vec3} equivalent of comparison ? a : b
*/
vec4 czm_branchFreeTernary(bool comparison, vec4 a, vec4 b) {
float useA = float(comparison);
return a * useA + b * (1.0 - useA);
}
`;var cD=`
vec4 czm_cascadeColor(vec4 weights)
{
return vec4(1.0, 0.0, 0.0, 1.0) * weights.x +
vec4(0.0, 1.0, 0.0, 1.0) * weights.y +
vec4(0.0, 0.0, 1.0, 1.0) * weights.z +
vec4(1.0, 0.0, 1.0, 1.0) * weights.w;
}
`;var lD=`
uniform vec4 shadowMap_cascadeDistances;
float czm_cascadeDistance(vec4 weights)
{
return dot(shadowMap_cascadeDistances, weights);
}
`;var uD=`
uniform mat4 shadowMap_cascadeMatrices[4];
mat4 czm_cascadeMatrix(vec4 weights)
{
return shadowMap_cascadeMatrices[0] * weights.x +
shadowMap_cascadeMatrices[1] * weights.y +
shadowMap_cascadeMatrices[2] * weights.z +
shadowMap_cascadeMatrices[3] * weights.w;
}
`;var fD=`
uniform vec4 shadowMap_cascadeSplits[2];
vec4 czm_cascadeWeights(float depthEye)
{
// One component is set to 1.0 and all others set to 0.0.
vec4 near = step(shadowMap_cascadeSplits[0], vec4(depthEye));
vec4 far = step(depthEye, shadowMap_cascadeSplits[1]);
return near * far;
}
`;var dD=`/**
* DOC_TBA
*
* @name czm_columbusViewMorph
* @glslFunction
*/
vec4 czm_columbusViewMorph(vec4 position2D, vec4 position3D, float time)
{
// Just linear for now.
vec3 p = mix(position2D.xyz, position3D.xyz, time);
return vec4(p, 1.0);
}
`;var mD=`/**
* Returns a position in model coordinates relative to eye taking into
* account the current scene mode: 3D, 2D, or Columbus view.
* <p>
* This uses standard position attributes, <code>position3DHigh</code>,
* <code>position3DLow</code>, <code>position2DHigh</code>, and <code>position2DLow</code>,
* and should be used when writing a vertex shader for an {@link Appearance}.
* </p>
*
* @name czm_computePosition
* @glslFunction
*
* @returns {vec4} The position relative to eye.
*
* @example
* vec4 p = czm_computePosition();
* v_positionEC = (czm_modelViewRelativeToEye * p).xyz;
* gl_Position = czm_modelViewProjectionRelativeToEye * p;
*
* @see czm_translateRelativeToEye
*/
vec4 czm_computePosition();
`;var hD=`/**
* @private
*/
vec2 cordic(float angle)
{
// Scale the vector by the appropriate factor for the 24 iterations to follow.
vec2 vector = vec2(6.0725293500888267e-1, 0.0);
// Iteration 1
float sense = (angle < 0.0) ? -1.0 : 1.0;
// float factor = sense * 1.0; // 2^-0
mat2 rotation = mat2(1.0, sense, -sense, 1.0);
vector = rotation * vector;
angle -= sense * 7.8539816339744828e-1; // atan(2^-0)
// Iteration 2
sense = (angle < 0.0) ? -1.0 : 1.0;
float factor = sense * 5.0e-1; // 2^-1
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 4.6364760900080609e-1; // atan(2^-1)
// Iteration 3
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 2.5e-1; // 2^-2
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 2.4497866312686414e-1; // atan(2^-2)
// Iteration 4
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 1.25e-1; // 2^-3
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 1.2435499454676144e-1; // atan(2^-3)
// Iteration 5
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 6.25e-2; // 2^-4
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 6.2418809995957350e-2; // atan(2^-4)
// Iteration 6
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 3.125e-2; // 2^-5
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 3.1239833430268277e-2; // atan(2^-5)
// Iteration 7
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 1.5625e-2; // 2^-6
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 1.5623728620476831e-2; // atan(2^-6)
// Iteration 8
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 7.8125e-3; // 2^-7
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 7.8123410601011111e-3; // atan(2^-7)
// Iteration 9
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 3.90625e-3; // 2^-8
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 3.9062301319669718e-3; // atan(2^-8)
// Iteration 10
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 1.953125e-3; // 2^-9
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 1.9531225164788188e-3; // atan(2^-9)
// Iteration 11
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 9.765625e-4; // 2^-10
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 9.7656218955931946e-4; // atan(2^-10)
// Iteration 12
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 4.8828125e-4; // 2^-11
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 4.8828121119489829e-4; // atan(2^-11)
// Iteration 13
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 2.44140625e-4; // 2^-12
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 2.4414062014936177e-4; // atan(2^-12)
// Iteration 14
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 1.220703125e-4; // 2^-13
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 1.2207031189367021e-4; // atan(2^-13)
// Iteration 15
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 6.103515625e-5; // 2^-14
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 6.1035156174208773e-5; // atan(2^-14)
// Iteration 16
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 3.0517578125e-5; // 2^-15
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 3.0517578115526096e-5; // atan(2^-15)
// Iteration 17
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 1.52587890625e-5; // 2^-16
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 1.5258789061315762e-5; // atan(2^-16)
// Iteration 18
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 7.62939453125e-6; // 2^-17
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 7.6293945311019700e-6; // atan(2^-17)
// Iteration 19
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 3.814697265625e-6; // 2^-18
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 3.8146972656064961e-6; // atan(2^-18)
// Iteration 20
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 1.9073486328125e-6; // 2^-19
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 1.9073486328101870e-6; // atan(2^-19)
// Iteration 21
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 9.5367431640625e-7; // 2^-20
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 9.5367431640596084e-7; // atan(2^-20)
// Iteration 22
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 4.76837158203125e-7; // 2^-21
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 4.7683715820308884e-7; // atan(2^-21)
// Iteration 23
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 2.384185791015625e-7; // 2^-22
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
angle -= sense * 2.3841857910155797e-7; // atan(2^-22)
// Iteration 24
sense = (angle < 0.0) ? -1.0 : 1.0;
factor = sense * 1.1920928955078125e-7; // 2^-23
rotation[0][1] = factor;
rotation[1][0] = -factor;
vector = rotation * vector;
// angle -= sense * 1.1920928955078068e-7; // atan(2^-23)
return vector;
}
/**
* Computes the cosine and sine of the provided angle using the CORDIC algorithm.
*
* @name czm_cosineAndSine
* @glslFunction
*
* @param {float} angle The angle in radians.
*
* @returns {vec2} The resulting cosine of the angle (as the x coordinate) and sine of the angle (as the y coordinate).
*
* @example
* vec2 v = czm_cosineAndSine(czm_piOverSix);
* float cosine = v.x;
* float sine = v.y;
*/
vec2 czm_cosineAndSine(float angle)
{
if (angle < -czm_piOverTwo || angle > czm_piOverTwo)
{
if (angle < 0.0)
{
return -cordic(angle + czm_pi);
}
else
{
return -cordic(angle - czm_pi);
}
}
else
{
return cordic(angle);
}
}
`;var pD=`/**
* Decompresses texture coordinates that were packed into a single float.
*
* @name czm_decompressTextureCoordinates
* @glslFunction
*
* @param {float} encoded The compressed texture coordinates.
* @returns {vec2} The decompressed texture coordinates.
*/
vec2 czm_decompressTextureCoordinates(float encoded)
{
float temp = encoded / 4096.0;
float xZeroTo4095 = floor(temp);
float stx = xZeroTo4095 / 4095.0;
float sty = (encoded - xZeroTo4095 * 4096.0) / 4095.0;
return vec2(stx, sty);
}
`;var _D=`/**
* Get default parameters for physically based rendering. These defaults
* describe a rough dielectric (non-metal) surface (e.g. rough plastic).
*
* @return {czm_pbrParameters} Default parameters for {@link czm_pbrLighting}
*/
czm_pbrParameters czm_defaultPbrMaterial()
{
czm_pbrParameters results;
results.diffuseColor = vec3(1.0);
results.roughness = 1.0;
const vec3 REFLECTANCE_DIELECTRIC = vec3(0.04);
results.f0 = REFLECTANCE_DIELECTRIC;
return results;
}
`;var gD=`// emulated noperspective
#if (__VERSION__ == 300 || defined(GL_EXT_frag_depth)) && !defined(LOG_DEPTH)
out float v_WindowZ;
#endif
/**
* Emulates GL_DEPTH_CLAMP, which is not available in WebGL 1 or 2.
* GL_DEPTH_CLAMP clamps geometry that is outside the near and far planes,
* capping the shadow volume. More information here:
* https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_depth_clamp.txt.
*
* When GL_EXT_frag_depth is available we emulate GL_DEPTH_CLAMP by ensuring
* no geometry gets clipped by setting the clip space z value to 0.0 and then
* sending the unaltered screen space z value (using emulated noperspective
* interpolation) to the frag shader where it is clamped to [0,1] and then
* written with gl_FragDepth (see czm_writeDepthClamp). This technique is based on:
* https://stackoverflow.com/questions/5960757/how-to-emulate-gl-depth-clamp-nv.
*
* When GL_EXT_frag_depth is not available, which is the case on some mobile
* devices, we must attempt to fix this only in the vertex shader.
* The approach is to clamp the z value to the far plane, which closes the
* shadow volume but also distorts the geometry, so there can still be artifacts
* on frustum seams.
*
* @name czm_depthClamp
* @glslFunction
*
* @param {vec4} coords The vertex in clip coordinates.
* @returns {vec4} The modified vertex.
*
* @example
* gl_Position = czm_depthClamp(czm_modelViewProjection * vec4(position, 1.0));
*
* @see czm_writeDepthClamp
*/
vec4 czm_depthClamp(vec4 coords)
{
#ifndef LOG_DEPTH
#if __VERSION__ == 300 || defined(GL_EXT_frag_depth)
v_WindowZ = (0.5 * (coords.z / coords.w) + 0.5) * coords.w;
coords.z = 0.0;
#else
coords.z = min(coords.z, coords.w);
#endif
#endif
return coords;
}
`;var yD=`/**
* Computes a 3x3 rotation matrix that transforms vectors from an ellipsoid's east-north-up coordinate system
* to eye coordinates. In east-north-up coordinates, x points east, y points north, and z points along the
* surface normal. East-north-up can be used as an ellipsoid's tangent space for operations such as bump mapping.
* <br /><br />
* The ellipsoid is assumed to be centered at the model coordinate's origin.
*
* @name czm_eastNorthUpToEyeCoordinates
* @glslFunction
*
* @param {vec3} positionMC The position on the ellipsoid in model coordinates.
* @param {vec3} normalEC The normalized ellipsoid surface normal, at <code>positionMC</code>, in eye coordinates.
*
* @returns {mat3} A 3x3 rotation matrix that transforms vectors from the east-north-up coordinate system to eye coordinates.
*
* @example
* // Transform a vector defined in the east-north-up coordinate
* // system, (0, 0, 1) which is the surface normal, to eye
* // coordinates.
* mat3 m = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);
* vec3 normalEC = m * vec3(0.0, 0.0, 1.0);
*/
mat3 czm_eastNorthUpToEyeCoordinates(vec3 positionMC, vec3 normalEC)
{
vec3 tangentMC = normalize(vec3(-positionMC.y, positionMC.x, 0.0)); // normalized surface tangent in model coordinates
vec3 tangentEC = normalize(czm_normal3D * tangentMC); // normalized surface tangent in eye coordiantes
vec3 bitangentEC = normalize(cross(normalEC, tangentEC)); // normalized surface bitangent in eye coordinates
return mat3(
tangentEC.x, tangentEC.y, tangentEC.z,
bitangentEC.x, bitangentEC.y, bitangentEC.z,
normalEC.x, normalEC.y, normalEC.z);
}
`;var AD=`/**
* DOC_TBA
*
* @name czm_ellipsoidContainsPoint
* @glslFunction
*
*/
bool czm_ellipsoidContainsPoint(vec3 ellipsoid_inverseRadii, vec3 point)
{
vec3 scaled = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz;
return (dot(scaled, scaled) <= 1.0);
}
`;var xD=`/**
* DOC_TBA
*
* @name czm_ellipsoidWgs84TextureCoordinates
* @glslFunction
*/
vec2 czm_ellipsoidWgs84TextureCoordinates(vec3 normal)
{
return vec2(atan(normal.y, normal.x) * czm_oneOverTwoPi + 0.5, asin(normal.z) * czm_oneOverPi + 0.5);
}
`;var CD=`/**
* Compares <code>left</code> and <code>right</code> componentwise. Returns <code>true</code>
* if they are within <code>epsilon</code> and <code>false</code> otherwise. The inputs
* <code>left</code> and <code>right</code> can be <code>float</code>s, <code>vec2</code>s,
* <code>vec3</code>s, or <code>vec4</code>s.
*
* @name czm_equalsEpsilon
* @glslFunction
*
* @param {} left The first vector.
* @param {} right The second vector.
* @param {float} epsilon The epsilon to use for equality testing.
* @returns {bool} <code>true</code> if the components are within <code>epsilon</code> and <code>false</code> otherwise.
*
* @example
* // GLSL declarations
* bool czm_equalsEpsilon(float left, float right, float epsilon);
* bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon);
* bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon);
* bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon);
*/
bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon) {
return all(lessThanEqual(abs(left - right), vec4(epsilon)));
}
bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon) {
return all(lessThanEqual(abs(left - right), vec3(epsilon)));
}
bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon) {
return all(lessThanEqual(abs(left - right), vec2(epsilon)));
}
bool czm_equalsEpsilon(float left, float right, float epsilon) {
return (abs(left - right) <= epsilon);
}
`;var TD=`/**
* DOC_TBA
*
* @name czm_eyeOffset
* @glslFunction
*
* @param {vec4} positionEC DOC_TBA.
* @param {vec3} eyeOffset DOC_TBA.
*
* @returns {vec4} DOC_TBA.
*/
vec4 czm_eyeOffset(vec4 positionEC, vec3 eyeOffset)
{
// This equation is approximate in x and y.
vec4 p = positionEC;
vec4 zEyeOffset = normalize(p) * eyeOffset.z;
p.xy += eyeOffset.xy + zEyeOffset.xy;
p.z += zEyeOffset.z;
return p;
}
`;var ED=`/**
* Transforms a position from eye to window coordinates. The transformation
* from eye to clip coordinates is done using {@link czm_projection}.
* The transform from normalized device coordinates to window coordinates is
* done using {@link czm_viewportTransformation}, which assumes a depth range
* of <code>near = 0</code> and <code>far = 1</code>.
* <br /><br />
* This transform is useful when there is a need to manipulate window coordinates
* in a vertex shader as done by {@link BillboardCollection}.
*
* @name czm_eyeToWindowCoordinates
* @glslFunction
*
* @param {vec4} position The position in eye coordinates to transform.
*
* @returns {vec4} The transformed position in window coordinates.
*
* @see czm_modelToWindowCoordinates
* @see czm_projection
* @see czm_viewportTransformation
* @see BillboardCollection
*
* @example
* vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);
*/
vec4 czm_eyeToWindowCoordinates(vec4 positionEC)
{
vec4 q = czm_projection * positionEC; // clip coordinates
q.xyz /= q.w; // normalized device coordinates
q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates
return q;
}
`;var bD=`/**
* Approxiamtes atan over the range [0, 1]. Safe to flip output for negative input.
*
* Based on Michal Drobot's approximation from ShaderFastLibs, which in turn is based on
* "Efficient approximations for the arctangent function," Rajan, S. Sichun Wang Inkol, R. Joyal, A., May 2006.
* Adapted from ShaderFastLibs under MIT License.
*
* Chosen for the following characteristics over range [0, 1]:
* - basically no error at 0 and 1, important for getting around range limit (naive atan2 via atan requires infinite range atan)
* - no visible artifacts from first-derivative discontinuities, unlike latitude via range-reduced sqrt asin approximations (at equator)
*
* The original code is x * (-0.1784 * abs(x) - 0.0663 * x * x + 1.0301);
* Removed the abs() in here because it isn't needed, the input range is guaranteed as [0, 1] by how we're approximating atan2.
*
* @name czm_fastApproximateAtan
* @glslFunction
*
* @param {float} x Value between 0 and 1 inclusive.
*
* @returns {float} Approximation of atan(x)
*/
float czm_fastApproximateAtan(float x) {
return x * (-0.1784 * x - 0.0663 * x * x + 1.0301);
}
/**
* Approximation of atan2.
*
* Range reduction math based on nvidia's cg reference implementation for atan2: http://developer.download.nvidia.com/cg/atan2.html
* However, we replaced their atan curve with Michael Drobot's (see above).
*
* @name czm_fastApproximateAtan
* @glslFunction
*
* @param {float} x Value between -1 and 1 inclusive.
* @param {float} y Value between -1 and 1 inclusive.
*
* @returns {float} Approximation of atan2(x, y)
*/
float czm_fastApproximateAtan(float x, float y) {
// atan approximations are usually only reliable over [-1, 1], or, in our case, [0, 1] due to modifications.
// So range-reduce using abs and by flipping whether x or y is on top.
float t = abs(x); // t used as swap and atan result.
float opposite = abs(y);
float adjacent = max(t, opposite);
opposite = min(t, opposite);
t = czm_fastApproximateAtan(opposite / adjacent);
// Undo range reduction
t = czm_branchFreeTernary(abs(y) > 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;
}
`;var SD=`/**
* 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);
}
`;var vD=`/**
* 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;
}
`;var wD=`/**
* 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);
}
`;var DD=`/**
* 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;
}
`;var ID=`/**
* 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);
}
`;var PD=`/**
* 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));
}
`;var OD=`/**
* @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;
}
`;var MD=`/**
* 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;
}
`;var RD=`/**
* 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));
}
`;var BD=`/**
* Determines if a time interval is empty.
*
* @name czm_isEmpty
* @glslFunction
*
* @param {czm_raySegment} interval The interval to test.
*
* @returns {bool} <code>true</code> if the time interval is empty; otherwise, <code>false</code>.
*
* @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);
}
`;var LD=`/**
* Determines if a time interval is empty.
*
* @name czm_isFull
* @glslFunction
*
* @param {czm_raySegment} interval The interval to test.
*
* @returns {bool} <code>true</code> if the time interval is empty; otherwise, <code>false</code>.
*
* @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);
}
`;var ND=`/**
* 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;
}
`;var FD=`/**
* 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);
}
`;var UD=`/**
* 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);
}
`;var VD=`/**
* 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);
}
`;var kD=`/**
* Computes the size of a pixel in meters at a distance from the eye.
* <p>
* Use this version when passing in a custom pixel ratio. For example, passing in 1.0 will return meters per native device pixel.
* </p>
* @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.
* <p>
* Use this version when scaling by pixel ratio.
* </p>
* @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);
}
`;var zD=`/**
* 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 <code>near = 0</code> and <code>far = 1</code>.
* <br /><br />
* This transform is useful when there is a need to manipulate window coordinates
* in a vertex shader as done by {@link BillboardCollection}.
* <br /><br />
* 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;
}
`;var HD=`/**
* 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;
}
`;var GD=`/**
* 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);
}
`;var WD=` /**
* 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));
}
`;var jD=`/**
* 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\u010Dius' 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;
}
`;var YD=`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.
* <p>
* This function only handles the lighting calculations. Metallic/roughness
* and specular/glossy must be handled separately. See {@czm_pbrMetallicRoughnessMaterial}, {@czm_pbrSpecularGlossinessMaterial} and {@czm_defaultPbrMaterial}
* </p>
*
* @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;
}
`;var qD=`/**
* 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;
}
`;var XD=`/**
* 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;
}
`;var KD=`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);
}
`;var JD=`/**
* 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);
}
`;var ZD=`/**
* Computes the point along a ray at the given time. <code>time</code> 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);
}
`;var QD=`/**
* 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;
}
}
}
`;var $D=`/**
* 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;
}
`;var eI=`float czm_readDepth(sampler2D depthTexture, vec2 texCoords)
{
return czm_reverseLogDepth(texture(depthTexture, texCoords).r);
}
`;var tI=`/**
* 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;
}
`;var nI=`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;
}
`;var iI=`/**
* 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);
}
`;var oI=`/**
* 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);
}
`;var rI=`/**
* 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);
}
`;var sI=`
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));
}
`;var aI=`
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
`;var cI=`/**
* 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 <code>sign</code> 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));
}
`;var lI=`/**
* Computes a color from the third order spherical harmonic coefficients and a normalized direction vector.
* <p>
* The order of the coefficients is [L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22].
* </p>
*
* @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);
}
`;var uI=`/**
* 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);
}
`;var fI=`/**
* 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);
}
`;var dI=`/**
* 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
}`;var mI=`/**
* 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;
}
`;var hI=`/**
* Translates a position (or any <code>vec3</code>) that was encoded with {@link EncodedCartesian3},
* and then provided to the shader as separate <code>high</code> and <code>low</code> 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.
* <p>
* 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}.
* </p>
*
* @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);
}
`;var pI=`/**
* @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);
}
`;var _I=`/**
* Returns the transpose of the matrix. The input <code>matrix</code> can be
* a <code>mat2</code>, <code>mat3</code>, or <code>mat4</code>.
*
* @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]);
}
`;var gI=`/**
* 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\u010Dius' 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));
}
`;var yI=`/**
* 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;
}
`;var AI=`/**
* Unpack unsigned integers of 1-4 bytes. in WebGL 1, there is no uint type,
* so the return value is an int.
* <p>
* 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.
* </p>
*
* @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)));
}
`;var xI=`/**
* 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;
}
`;var CI=`#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.
* <p>
* 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.
* </p>
* @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
}
`;var TI=`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 <code>czm_viewportTransformation</code>. The transformation from
* normalized device coordinates to clip coordinates is done using <code>fragmentCoordinate.w</code>,
* 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);
}
`;var EI=`// 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
}
`;var bI=`#ifdef LOG_DEPTH
in float v_depthFromNearPlusOne;
#ifdef POLYGON_OFFSET
uniform vec2 u_polygonOffset;
#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif
#endif
#endif
/**
* Writes the fragment depth to the logarithmic depth buffer.
* <p>
* Use this when the vertex shader does not call {@link czm_vertexlogDepth}, for example, when
* ray-casting geometry using a full screen quad.
* </p>
* @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.
* <p>
* Use this when the vertex shader calls {@link czm_vertexlogDepth}.
* </p>
*
* @name czm_writeLogDepth
* @glslFunction
*/
void czm_writeLogDepth() {
#ifdef LOG_DEPTH
czm_writeLogDepth(v_depthFromNearPlusOne);
#endif
}
`;var SI=`/**
* 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;
}
`;var B0={czm_degreesPerRadian:iw,czm_depthRange:ow,czm_epsilon1:rw,czm_epsilon2:sw,czm_epsilon3:aw,czm_epsilon4:cw,czm_epsilon5:lw,czm_epsilon6:uw,czm_epsilon7:fw,czm_infinity:dw,czm_oneOverPi:mw,czm_oneOverTwoPi:hw,czm_passCesium3DTile:pw,czm_passCesium3DTileClassification:_w,czm_passCesium3DTileClassificationIgnoreShow:gw,czm_passClassification:yw,czm_passCompute:Aw,czm_passEnvironment:xw,czm_passGlobe:Cw,czm_passOpaque:Tw,czm_passOverlay:Ew,czm_passTerrainClassification:bw,czm_passTranslucent:Sw,czm_passVoxels:vw,czm_pi:ww,czm_piOverFour:Dw,czm_piOverSix:Iw,czm_piOverThree:Pw,czm_piOverTwo:Ow,czm_radiansPerDegree:Mw,czm_sceneMode2D:Rw,czm_sceneMode3D:Bw,czm_sceneModeColumbusView:Lw,czm_sceneModeMorphing:Nw,czm_solarRadius:Fw,czm_threePiOver2:Uw,czm_twoPi:Vw,czm_webMercatorMaxLatitude:kw,czm_depthRangeStruct:zw,czm_material:Hw,czm_materialInput:Gw,czm_modelMaterial:Ww,czm_modelVertexOutput:jw,czm_pbrParameters:Yw,czm_ray:qw,czm_raySegment:Xw,czm_shadowParameters:Kw,czm_HSBToRGB:Jw,czm_HSLToRGB:Zw,czm_RGBToHSB:Qw,czm_RGBToHSL:$w,czm_RGBToXYZ:eD,czm_XYZToRGB:tD,czm_acesTonemapping:nD,czm_alphaWeight:iD,czm_antialias:oD,czm_approximateSphericalCoordinates:rD,czm_backFacing:sD,czm_branchFreeTernary:aD,czm_cascadeColor:cD,czm_cascadeDistance:lD,czm_cascadeMatrix:uD,czm_cascadeWeights:fD,czm_columbusViewMorph:dD,czm_computePosition:mD,czm_cosineAndSine:hD,czm_decompressTextureCoordinates:pD,czm_defaultPbrMaterial:_D,czm_depthClamp:gD,czm_eastNorthUpToEyeCoordinates:yD,czm_ellipsoidContainsPoint:AD,czm_ellipsoidWgs84TextureCoordinates:xD,czm_equalsEpsilon:CD,czm_eyeOffset:TD,czm_eyeToWindowCoordinates:ED,czm_fastApproximateAtan:bD,czm_fog:SD,czm_gammaCorrect:vD,czm_geodeticSurfaceNormal:wD,czm_getDefaultMaterial:DD,czm_getLambertDiffuse:ID,czm_getSpecular:PD,czm_getWaterNoise:OD,czm_hue:MD,czm_inverseGamma:RD,czm_isEmpty:BD,czm_isFull:LD,czm_latitudeToWebMercatorFraction:ND,czm_lineDistance:FD,czm_linearToSrgb:UD,czm_luminance:VD,czm_metersPerPixel:kD,czm_modelToWindowCoordinates:zD,czm_multiplyWithColorBalance:HD,czm_nearFarScalar:GD,czm_octDecode:WD,czm_packDepth:jD,czm_pbrLighting:YD,czm_pbrMetallicRoughnessMaterial:qD,czm_pbrSpecularGlossinessMaterial:XD,czm_phong:KD,czm_planeDistance:JD,czm_pointAlongRay:ZD,czm_rayEllipsoidIntersectionInterval:QD,czm_raySphereIntersectionInterval:$D,czm_readDepth:eI,czm_readNonPerspective:tI,czm_reverseLogDepth:nI,czm_round:iI,czm_sampleOctahedralProjection:oI,czm_saturation:rI,czm_shadowDepthCompare:sI,czm_shadowVisibility:aI,czm_signNotZero:cI,czm_sphericalHarmonics:lI,czm_srgbToLinear:uI,czm_tangentToEyeSpaceMatrix:fI,czm_textureCube:dI,czm_transformPlane:mI,czm_translateRelativeToEye:hI,czm_translucentPhong:pI,czm_transpose:_I,czm_unpackDepth:gI,czm_unpackFloat:yI,czm_unpackUint:AI,czm_valueTransform:xI,czm_vertexLogDepth:CI,czm_windowToEyeCoordinates:TI,czm_writeDepthClamp:EI,czm_writeLogDepth:bI,czm_writeNonPerspective:SI};function Ove(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(/out_FragColor/g,"gl_FragColor"),n=n.replaceAll(/out_FragColor\[(\d+)\]/g,"gl_FragColor[$1]"),n=n.replaceAll(/layout\s+\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor/g,""),/gl_FragDepth/.test(n)&&(n=`#extension GL_EXT_frag_depth : enable
${n}`,n=n.replaceAll(/gl_FragDepth/g,"gl_FragDepthEXT"))):(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}var vI=Ove;function BQ(e){return e=e.replace(/\/\/.*/g,""),e.replace(/\/\*\*[\s\S]*?\*\//gm,function(t){let n=t.match(/\n/gm).length,i="";for(let o=0;o<n;++o)i+=`
`;return i})}function LQ(e,t,n){let i;for(let o=0;o<n.length;++o)n[o].name===e&&(i=n[o]);return u(i)||(t=BQ(t),i={name:e,glslSource:t,dependsOn:[],requiredBy:[],evaluated:!1},n.push(i)),i}function NQ(e,t){if(e.evaluated)return;e.evaluated=!0;let n=e.glslSource.match(/\bczm_[a-zA-Z0-9_]*/g);u(n)&&n!==null&&(n=n.filter(function(i,o){return n.indexOf(i)===o}),n.forEach(function(i){if(i!==e.name&&As._czmBuiltinsAndUniforms.hasOwnProperty(i)){let o=LQ(i,As._czmBuiltinsAndUniforms[i],t);e.dependsOn.push(o),o.requiredBy.push(e),NQ(o,t)}}))}function Mve(e){let t=[],n=[];for(;e.length>0;){let o=e.pop();n.push(o),o.requiredBy.length===0&&t.push(o)}for(;t.length>0;){let o=t.shift();e.push(o);for(let r=0;r<o.dependsOn.length;++r){let s=o.dependsOn[r],a=s.requiredBy.indexOf(o);s.requiredBy.splice(a,1),s.requiredBy.length===0&&t.push(s)}}let i=[];for(let o=0;o<n.length;++o)n[o].requiredBy.length!==0&&i.push(n[o])}function Rve(e){let t=[],n=LQ("main",e,t);NQ(n,t),Mve(t);let i="";for(let o=t.length-1;o>=0;--o)i=`${i+t[o].glslSource}
`;return i.replace(n.glslSource,"")}function FQ(e,t,n){let i,o,r="",s=e.sources;if(u(s))for(i=0,o=s.length;i<o;++i)r+=`
#line 0
${s[i]}`;r=BQ(r);let a;r=r.replace(/#version\s+(.*?)\n/gm,function(A,x){return a=x,`
`});let c=[];r=r.replace(/#extension.*\n/gm,function(A){return c.push(A),`
`}),r=r.replace(/precision\s(lowp|mediump|highp)\s(float|int);/,"");let l=e.pickColorQualifier;u(l)&&(r=As.createPickFragmentShaderSource(r,l));let f="",d=c.length;for(i=0;i<d;i++)f+=c[i];t&&(f+=`#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
precision highp int;
#else
precision mediump float;
precision mediump int;
#define highp mediump
#endif
`);let p=e.defines;if(u(p))for(i=0,o=p.length;i<o;++i){let A=p[i];A.length!==0&&(f+=`#define ${A}
`)}n.textureFloatLinear&&(f+=`#define OES_texture_float_linear
`),n.floatingPointTexture&&(f+=`#define OES_texture_float
`);let g="";e.includeBuiltIns&&(g=Rve(r)),f+=`
#line 0
`;let h=g+r;return n.webgl2&&t&&!/layout\s*\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor;/g.test(h)&&!/czm_out_FragColor/g.test(h)&&/out_FragColor/g.test(h)&&(f+=`layout(location = 0) out vec4 out_FragColor;
`),f+=g,f+=r,n.webgl2?f=`#version 300 es
${f}`:f=vI(f,t),f}function As(e){e=y(e,y.EMPTY_OBJECT);let t=e.pickColorQualifier;this.defines=u(e.defines)?e.defines.slice(0):[],this.sources=u(e.sources)?e.sources.slice(0):[],this.pickColorQualifier=t,this.includeBuiltIns=y(e.includeBuiltIns,!0)}As.prototype.clone=function(){return new As({sources:this.sources,defines:this.defines,pickColorQualifier:this.pickColorQualifier,includeBuiltIns:this.includeBuiltIns})};As.replaceMain=function(e,t){return t=`void ${t}()`,e.replace(/void\s+main\s*\(\s*(?:void)?\s*\)/g,t)};As.prototype.getCacheKey=function(){let t=this.defines.slice().sort().join(","),n=this.pickColorQualifier,i=this.includeBuiltIns,o=this.sources.join(`
`);return`${t}:${n}:${i}:${o}`};As.prototype.createCombinedVertexShader=function(e){return FQ(this,!1,e)};As.prototype.createCombinedFragmentShader=function(e){return FQ(this,!0,e)};As._czmBuiltinsAndUniforms={};for(let e in B0)B0.hasOwnProperty(e)&&(As._czmBuiltinsAndUniforms[e]=B0[e]);for(let e in Kh)if(Kh.hasOwnProperty(e)){let t=Kh[e];typeof t.getDeclaration=="function"&&(As._czmBuiltinsAndUniforms[e]=t.getDeclaration(e))}As.createPickVertexShaderSource=function(e){return`${As.replaceMain(e,"czm_old_main")}
in vec4 pickColor;
out vec4 czm_pickColor;
void main()
{
czm_old_main();
czm_pickColor = pickColor;
}`};As.createPickFragmentShaderSource=function(e,t){let n=As.replaceMain(e,"czm_old_main"),i=`${t} vec4 czm_pickColor;
void main()
{
czm_old_main();
if (out_FragColor.a == 0.0) {
discard;
}
out_FragColor = czm_pickColor;
}`;return`${n}
${i}`};function Bve(e,t){let n=e.defines,i=n.length;for(let o=0;o<i;++o)if(n[o]===t)return!0;return!1}function UQ(e,t){let n=e.sources,i=n.length;for(let o=0;o<i;++o)if(n[o].indexOf(t)!==-1)return!0;return!1}function VQ(e,t){let n=t.length;for(let i=0;i<n;++i){let o=t[i];if(UQ(e,o))return o}}var Lve=["v_normalEC","v_normal"];As.findNormalVarying=function(e){return UQ(e,"#ifdef HAS_NORMALS")?Bve(e,"HAS_NORMALS")?"v_normalEC":void 0:VQ(e,Lve)};var Nve=["v_positionEC"];As.findPositionVarying=function(e){return VQ(e,Nve)};var He=As;var wI=`in vec3 position3DHigh;
in vec3 position3DLow;
in float batchId;
#ifdef EXTRUDED_GEOMETRY
in vec3 extrudeDirection;
uniform float u_globeMinimumAltitude;
#endif // EXTRUDED_GEOMETRY
#ifdef PER_INSTANCE_COLOR
out vec4 v_color;
#endif // PER_INSTANCE_COLOR
#ifdef TEXTURE_COORDINATES
#ifdef SPHERICAL
out vec4 v_sphericalExtents;
#else // SPHERICAL
out vec2 v_inversePlaneExtents;
out vec4 v_westPlane;
out vec4 v_southPlane;
#endif // SPHERICAL
out vec3 v_uvMinAndSphericalLongitudeRotation;
out vec3 v_uMaxAndInverseDistance;
out vec3 v_vMaxAndInverseDistance;
#endif // TEXTURE_COORDINATES
void main()
{
vec4 position = czm_computePosition();
#ifdef EXTRUDED_GEOMETRY
float delta = min(u_globeMinimumAltitude, czm_geometricToleranceOverMeter * length(position.xyz));
delta *= czm_sceneMode == czm_sceneMode3D ? 1.0 : 0.0;
//extrudeDirection is zero for the top layer
position = position + vec4(extrudeDirection * delta, 0.0);
#endif
#ifdef TEXTURE_COORDINATES
#ifdef SPHERICAL
v_sphericalExtents = czm_batchTable_sphericalExtents(batchId);
v_uvMinAndSphericalLongitudeRotation.z = czm_batchTable_longitudeRotation(batchId);
#else // SPHERICAL
#ifdef COLUMBUS_VIEW_2D
vec4 planes2D_high = czm_batchTable_planes2D_HIGH(batchId);
vec4 planes2D_low = czm_batchTable_planes2D_LOW(batchId);
// If the primitive is split across the IDL (planes2D_high.x > 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);
}
`;var ig=`#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();
}
`;var kQ={TERRAIN:0,CESIUM_3D_TILE:1,BOTH:2};kQ.NUMBER_OF_CLASSIFICATION_TYPES=3;var kn=Object.freeze(kQ);var Fve={NEVER:te.NEVER,LESS:te.LESS,EQUAL:te.EQUAL,LESS_OR_EQUAL:te.LEQUAL,GREATER:te.GREATER,NOT_EQUAL:te.NOTEQUAL,GREATER_OR_EQUAL:te.GEQUAL,ALWAYS:te.ALWAYS},Ha=Object.freeze(Fve);function Pm(){this.high=m.clone(m.ZERO),this.low=m.clone(m.ZERO)}Pm.encode=function(e,t){u(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};var Zh={high:0,low:0};Pm.fromCartesian=function(e,t){u(t)||(t=new Pm);let n=t.high,i=t.low;return Pm.encode(e.x,Zh),n.x=Zh.high,i.x=Zh.low,Pm.encode(e.y,Zh),n.y=Zh.high,i.y=Zh.low,Pm.encode(e.z,Zh),n.z=Zh.high,i.z=Zh.low,t};var a8=new Pm;Pm.writeElements=function(e,t,n){Pm.fromCartesian(e,a8);let i=a8.high,o=a8.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};var Gn=Pm;function Uve(e,t){let n=[],i=e.length,o=0;for(;o<i;){let r=Math.ceil((i-o)/t--);n.push(e.slice(o,o+r)),o+=r}return n}var DI=Uve;var j3={STREAM_DRAW:te.STREAM_DRAW,STATIC_DRAW:te.STATIC_DRAW,DYNAMIC_DRAW:te.DYNAMIC_DRAW,validate:function(e){return e===j3.STREAM_DRAW||e===j3.STATIC_DRAW||e===j3.DYNAMIC_DRAW}},Fe=Object.freeze(j3);var xs={UNSIGNED_BYTE:te.UNSIGNED_BYTE,UNSIGNED_SHORT:te.UNSIGNED_SHORT,UNSIGNED_INT:te.UNSIGNED_INT};xs.getSizeInBytes=function(e){switch(e){case xs.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case xs.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case xs.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT}};xs.fromSizeInBytes=function(e){switch(e){case 2:return xs.UNSIGNED_SHORT;case 4:return xs.UNSIGNED_INT;case 1:return xs.UNSIGNED_BYTE}};xs.validate=function(e){return u(e)&&(e===xs.UNSIGNED_BYTE||e===xs.UNSIGNED_SHORT||e===xs.UNSIGNED_INT)};xs.createTypedArray=function(e,t){return e>=P.SIXTY_FOUR_KILOBYTES?new Uint32Array(t):new Uint16Array(t)};xs.createTypedArrayFromArrayBuffer=function(e,t,n,i){return e>=P.SIXTY_FOUR_KILOBYTES?new Uint32Array(t,n,i):new Uint16Array(t,n,i)};xs.fromTypedArray=function(e){if(e instanceof Uint8Array)return xs.UNSIGNED_BYTE;if(e instanceof Uint16Array)return xs.UNSIGNED_SHORT;if(e instanceof Uint32Array)return xs.UNSIGNED_INT};var Ue=Object.freeze(xs);function Wu(e){e=y(e,y.EMPTY_OBJECT);let t=e.context._gl,n=e.bufferTarget,i=e.typedArray,o=e.sizeInBytes,r=e.usage,s=u(i);s&&(o=i.byteLength);let a=t.createBuffer();t.bindBuffer(n,a),t.bufferData(n,s?i:o,r),t.bindBuffer(n,null),this._id=Hn(),this._gl=t,this._webgl2=e.context._webgl2,this._bufferTarget=n,this._sizeInBytes=o,this._usage=r,this._buffer=a,this.vertexArrayDestroyable=!0}Wu.createVertexBuffer=function(e){return new Wu({context:e.context,bufferTarget:te.ARRAY_BUFFER,typedArray:e.typedArray,sizeInBytes:e.sizeInBytes,usage:e.usage})};Wu.createIndexBuffer=function(e){let t=e.context,n=e.indexDatatype,i=Ue.getSizeInBytes(n),o=new Wu({context:t,bufferTarget:te.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(Wu.prototype,{sizeInBytes:{get:function(){return this._sizeInBytes}},usage:{get:function(){return this._usage}}});Wu.prototype._getBuffer=function(){return this._buffer};Wu.prototype.copyFromArrayView=function(e,t){t=y(t,0);let n=this._gl,i=this._bufferTarget;n.bindBuffer(i,this._buffer),n.bufferSubData(i,t,e),n.bindBuffer(i,null)};Wu.prototype.copyFromBuffer=function(e,t,n,i){let o=te.COPY_READ_BUFFER,r=te.COPY_WRITE_BUFFER,s=this._gl;s.bindBuffer(r,this._buffer),s.bindBuffer(o,e._buffer),s.copyBufferSubData(o,r,t,n,i),s.bindBuffer(r,null),s.bindBuffer(o,null)};Wu.prototype.getBufferData=function(e,t,n,i){t=y(t,0),n=y(n,0);let o=this._gl,r=te.COPY_READ_BUFFER;o.bindBuffer(r,this._buffer),o.getBufferSubData(r,t,e,n,i),o.bindBuffer(r,null)};Wu.prototype.isDestroyed=function(){return!1};Wu.prototype.destroy=function(){return this._gl.deleteBuffer(this._buffer)
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 ewe(e){return e===1?"float":`vec${e}`}function twe(e){return e===1?".x":e===2?".xy":e===3?".xyz":""}function nwe(e,t){let i=e._attributes[t],o=i.componentsPerAttribute,r=i.functionName,s=ewe(o),a=twe(o),c=e._offsets[t],l=`${s} ${r}(float batchId)
{
vec2 st = computeSt(batchId);
st.x += batchTextureStep.x * float(${c});
`;return e._packFloats&&i.componentDatatype!==Ke.UNSIGNED_BYTE?l+=`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)));
`:l+=` vec4 textureValue = texture(batchTexture, st);
`,l+=` ${s} value = textureValue${a};
`,e._pixelDatatype===Ke.UNSIGNED_BYTE&&i.componentDatatype===X.UNSIGNED_BYTE&&!i.normalize?l+=`value *= 255.0;
`:e._pixelDatatype===Ke.FLOAT&&i.componentDatatype===X.UNSIGNED_BYTE&&i.normalize&&(l+=`value /= 255.0;
`),l+=` return value;
}
`,l}$h.prototype.getVertexShaderCallback=function(){let e=this._attributes;if(e.length===0)return function(i){return i};let t=`uniform highp sampler2D batchTexture;
`;t+=`${$ve(this)}
`;let n=e.length;for(let i=0;i<n;++i)t+=nwe(this,i);return function(i){let o=i.indexOf("void main"),r=i.substring(0,o),s=i.substring(o);return`${r}
${t}
${s}`}};$h.prototype.isDestroyed=function(){return!1};$h.prototype.destroy=function(){return this._texture=this._texture&&this._texture.destroy(),ue(this)};var L0=$h;var to={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};to.getMathType=function(e){switch(e){case to.SCALAR:return Number;case to.VEC2:return H;case to.VEC3:return m;case to.VEC4:return re;case to.MAT2:return Qi;case to.MAT3:return Z;case to.MAT4:return B}};to.getNumberOfComponents=function(e){switch(e){case to.SCALAR:return 1;case to.VEC2:return 2;case to.VEC3:return 3;case to.VEC4:case to.MAT2:return 4;case to.MAT3:return 9;case to.MAT4:return 16}};to.getAttributeLocationCount=function(e){switch(e){case to.SCALAR:case to.VEC2:case to.VEC3:case to.VEC4:return 1;case to.MAT2:return 2;case to.MAT3:return 3;case to.MAT4:return 4}};to.getGlslType=function(e){switch(e){case to.SCALAR:return"float";case to.VEC2:return"vec2";case to.VEC3:return"vec3";case to.VEC4:return"vec4";case to.MAT2:return"mat2";case to.MAT3:return"mat3";case to.MAT4:return"mat4"}};var an=Object.freeze(to);var jQ=1/256,YQ=256,Ao={};Ao.octEncodeInRange=function(e,t,n){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){let i=n.x,o=n.y;n.x=(1-Math.abs(o))*P.signNotZero(i),n.y=(1-Math.abs(i))*P.signNotZero(o)}return n.x=P.toSNorm(n.x,t),n.y=P.toSNorm(n.y,t),n};Ao.octEncode=function(e,t){return Ao.octEncodeInRange(e,255,t)};var PI=new H,qQ=new Uint8Array(1);function Y3(e){return qQ[0]=e,qQ[0]}Ao.octEncodeToCartesian4=function(e,t){return Ao.octEncodeInRange(e,65535,PI),t.x=Y3(PI.x*jQ),t.y=Y3(PI.x),t.z=Y3(PI.y*jQ),t.w=Y3(PI.y),t};Ao.octDecodeInRange=function(e,t,n,i){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){let o=i.x;i.x=(1-Math.abs(i.y))*P.signNotZero(o),i.y=(1-Math.abs(o))*P.signNotZero(i.y)}return m.normalize(i,i)};Ao.octDecode=function(e,t,n){return Ao.octDecodeInRange(e,t,255,n)};Ao.octDecodeFromCartesian4=function(e,t){let n=e.x,i=e.y,o=e.z,r=e.w,s=n*YQ+i,a=o*YQ+r;return Ao.octDecodeInRange(s,a,65535,t)};Ao.octPackFloat=function(e){return 256*e.x+e.y};var l8=new H;Ao.octEncodeFloat=function(e){return Ao.octEncode(e,l8),Ao.octPackFloat(l8)};Ao.octDecodeFloat=function(e,t){let n=e/256,i=Math.floor(n),o=(n-i)*256;return Ao.octDecode(i,o,t)};Ao.octPack=function(e,t,n,i){let o=Ao.octEncodeFloat(e),r=Ao.octEncodeFloat(t),s=Ao.octEncode(n,l8);return i.x=65536*s.x+o,i.y=65536*s.y+r,i};Ao.octUnpack=function(e,t,n,i){let o=e.x/65536,r=Math.floor(o),s=(o-r)*65536;o=e.y/65536;let a=Math.floor(o),c=(o-a)*65536;Ao.octDecodeFloat(s,t),Ao.octDecodeFloat(c,n),Ao.octDecode(r,a,i)};Ao.compressTextureCoordinates=function(e){let t=e.x*4095|0,n=e.y*4095|0;return 4096*t+n};Ao.decompressTextureCoordinates=function(e,t){let n=e/4096,i=Math.floor(n);return t.x=i/4095,t.y=(e-i*4096)/4095,t};function c8(e){return e>>1^-(e&1)}Ao.zigZagDeltaDecode=function(e,t,n){let i=e.length,o=0,r=0,s=0;for(let a=0;a<i;++a)o+=c8(e[a]),r+=c8(t[a]),e[a]=o,t[a]=r,u(n)&&(s+=c8(n[a]),n[a]=s)};Ao.dequantize=function(e,t,n,i){let o=an.getNumberOfComponents(n),r;switch(t){case X.BYTE:r=127;break;case X.UNSIGNED_BYTE:r=255;break;case X.SHORT:r=32767;break;case X.UNSIGNED_SHORT:r=65535;break;case X.INT:r=2147483647;break;case X.UNSIGNED_INT:r=4294967295;break}let s=new Float32Array(i*o);for(let a=0;a<i;a++)for(let c=0;c<o;c++){let l=a*o+c;s[l]=Math.max(e[l]/r,-1)}return s};Ao.decodeRGB565=function(e,t){let n=e.length;u(t)||(t=new Float32Array(n*3));let i=(1<<5)-1,o=(1<<6)-1,r=1/31,s=1/63;for(let a=0;a<n;a++){let c=e[a],l=c>>11,f=c>>5&o,d=c&i,p=3*a;t[p]=l*r,t[p+1]=f*s,t[p+2]=d*r}return t};var Wn=Ao;var XQ=new m,KQ=new m,JQ=new m;function iwe(e,t,n,i,o){u(o)||(o=new m);let r,s,a,c,l,f,d,p;if(u(t.z)){if(m.equalsEpsilon(e,t,P.EPSILON14))return m.clone(m.UNIT_X,o);if(m.equalsEpsilon(e,n,P.EPSILON14))return m.clone(m.UNIT_Y,o);if(m.equalsEpsilon(e,i,P.EPSILON14))return m.clone(m.UNIT_Z,o);r=m.subtract(n,t,XQ),s=m.subtract(i,t,KQ),a=m.subtract(e,t,JQ),c=m.dot(r,r),l=m.dot(r,s),f=m.dot(r,a),d=m.dot(s,s)
`),u(e.rtcCenter)?(t=t.replace(/in\s+vec(?:3|4)\s+position3DHigh;/g,""),t=t.replace(/in\s+vec(?:3|4)\s+position3DLow;/g,""),o+=`uniform mat4 u_modifiedModelView;
`,r+=`in vec4 position;
`,s+=`${c}
{
return u_modifiedModelView * position;
}
`,t=t.replace(/czm_modelViewRelativeToEye\s+\*\s+/g,""),t=t.replace(/czm_modelViewProjectionRelativeToEye/g,"czm_projection")):n?s+=`${c}
{
return czm_translateRelativeToEye(${a}3DHigh, ${a}3DLow);
}
`:(r+=`in vec3 ${a}2DHigh;
in vec3 ${a}2DLow;
`,s+=`${c}
{
vec4 p;
if (czm_morphTime == 1.0)
{
p = czm_translateRelativeToEye(${a}3DHigh, ${a}3DLow);
}
else if (czm_morphTime == 0.0)
{
p = czm_translateRelativeToEye(${a}2DHigh.zxy, ${a}2DLow.zxy);
}
else
{
p = czm_columbusViewMorph(
czm_translateRelativeToEye(${a}2DHigh.zxy, ${a}2DLow.zxy),
czm_translateRelativeToEye(${a}3DHigh, ${a}3DLow),
czm_morphTime);
}
return p;
}
`)}return[o,r,t,s].join(`
`)};_r._appendShowToShader=function(e,t){return u(e._batchTableAttributeIndices.show)?`${He.replaceMain(t,"czm_non_show_main")}
void main()
{
czm_non_show_main();
gl_Position *= czm_batchTable_show(batchId);
}`:t};_r._updateColorAttribute=function(e,t,n){if(!u(e._batchTableAttributeIndices.color)&&!u(e._batchTableAttributeIndices.depthFailColor)||t.search(/in\s+vec4\s+color;/g)===-1)return t;let i=t;return i=i.replace(/in\s+vec4\s+color;/g,""),n?i=i.replace(/(\b)color(\b)/g,"$1czm_batchTable_depthFailColor(batchId)$2"):i=i.replace(/(\b)color(\b)/g,"$1czm_batchTable_color(batchId)$2"),i};function p$(e){return`${He.replaceMain(e,"czm_non_pick_main")}
out vec4 v_pickColor;
void main()
{
czm_non_pick_main();
v_pickColor = czm_batchTable_pickColor(batchId);
}`}function _$(e){return`in vec4 v_pickColor;
${e}`}_r._updatePickColorAttribute=function(e){let t=e.replace(/in\s+vec4\s+pickColor;/g,"");return t=t.replace(/(\b)pickColor(\b)/g,"$1czm_batchTable_pickColor(batchId)$2"),t};_r._appendOffsetToShader=function(e,t){if(!u(e._batchTableAttributeIndices.offset))return t;let n=`in float batchId;
`;n+="in float applyOffset;";let i=t.replace(/in\s+float\s+batchId;/g,n),o=`vec4 $1 = czm_computePosition();
`;return o+=` if (czm_sceneMode == czm_sceneMode3D)
`,o+=` {
`,o+=" $1 = $1 + vec4(czm_batchTable_offset(batchId) * applyOffset, 0.0);",o+=` }
`,o+=` else
`,o+=` {
`,o+=" $1 = $1 + vec4(czm_batchTable_offset2D(batchId) * applyOffset, 0.0);",o+=` }
`,i=i.replace(/vec4\s+([A-Za-z0-9_]+)\s+=\s+czm_computePosition\(\);/g,o),i};_r._appendDistanceDisplayConditionToShader=function(e,t,n){if(!u(e._batchTableAttributeIndices.distanceDisplayCondition))return t;let i=He.replaceMain(t,"czm_non_distanceDisplayCondition_main"),o=`void main()
{
czm_non_distanceDisplayCondition_main();
vec2 distanceDisplayCondition = czm_batchTable_distanceDisplayCondition(batchId);
vec3 boundingSphereCenter3DHigh = czm_batchTable_boundingSphereCenter3DHigh(batchId);
vec3 boundingSphereCenter3DLow = czm_batchTable_boundingSphereCenter3DLow(batchId);
float boundingSphereRadius = czm_batchTable_boundingSphereRadius(batchId);
`;return n?o+=` vec4 centerRTE = czm_translateRelativeToEye(boundingSphereCenter3DHigh, boundingSphereCenter3DLow);
`:o+=` vec3 boundingSphereCenter2DHigh = czm_batchTable_boundingSphereCenter2DHigh(batchId);
vec3 boundingSphereCenter2DLow = czm_batchTable_boundingSphereCenter2DLow(batchId);
vec4 centerRTE;
if (czm_morphTime == 1.0)
{
centerRTE = czm_translateRelativeToEye(boundingSphereCenter3DHigh, boundingSphereCenter3DLow);
}
else if (czm_morphTime == 0.0)
{
centerRTE = czm_translateRelativeToEye(boundingSphereCenter2DHigh.zxy, boundingSphereCenter2DLow.zxy);
}
else
{
centerRTE = czm_columbusViewMorph(
czm_translateRelativeToEye(boundingSphereCenter2DHigh.zxy, boundingSphereCenter2DLow.zxy),
czm_translateRelativeToEye(boundingSphereCenter3DHigh, boundingSphereCenter3DLow),
czm_morphTime);
}
`,o+=` float radiusSq = boundingSphereRadius * boundingSphereRadius;
float distanceSq;
if (czm_sceneMode == czm_sceneMode2D)
{
distanceSq = czm_eyeHeight2D.y - radiusSq;
}
else
{
distanceSq = dot(centerRTE.xyz, centerRTE.xyz) - radiusSq;
}
distanceSq = max(distanceSq, 0.0);
float nearSq = distanceDisplayCondition.x * distanceDisplayCondition.x;
float farSq = distanceDisplayCondition.y * distanceDisplayCondition.y;
float show = (distanceSq >= nearSq && distanceSq <= farSq) ? 1.0 : 0.0;
gl_Position *= show;
}`,`${i}
${o}`};function g$(e,t){if(!e.compressVertices)return t;let 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;let o=t.search(/in\s+vec3\s+tangent;/g)!==-1,r=t.search(/in\s+vec3\s+bitangent;/g)!==-1,s=i&&n?2:1;s+=o||r?1:0;let a=s>1?`vec${s}`:"float",c="compressedAttributes",l=`in ${a} ${c};`,f="",d="";if(i){f+=`vec2 st;
`;let h=s>1?`${c}.x`:c;d+=` st = czm_decompressTextureCoordinates(${h});
`}n&&o&&r?(f+=`vec3 normal;
vec3 tangent;
vec3 bitangent;
`,d+=` czm_octDecode(${c}.${i?"yz":"xy"}, normal, tangent, bitangent);
`):(n&&(f+=`vec3 normal;
`,d+=` normal = czm_octDecode(${c}${s>1?`.${i?"y":"x"}`:""});
`),o&&(f+=`vec3 tangent;
`,d+=` tangent = czm_octDecode(${c}.${i&&n?"z":"y"});
`),r&&(f+=`vec3 bitangent;
`,d+=` bitangent = czm_octDecode(${c}.${i&&n?"z":"y"});
`));let p=t;p=p.replace(/in\s+vec3\s+normal;/g,""),p=p.replace(/in\s+vec2\s+st;/g,""),p=p.replace(/in\s+vec3\s+tangent;/g,""),p=p.replace(/in\s+vec3\s+bitangent;/g,""),p=He.replaceMain(p,"czm_non_compressed_main");let g=`void main()
{
${d} czm_non_compressed_main();
}`;return[l,f,p,g].join(`
`)}function $we(e){let t=He.replaceMain(e,"czm_non_depth_clamp_main");return t+=`void main() {
czm_non_depth_clamp_main();
gl_Position = czm_depthClamp(gl_Position);}
`,t}function eDe(e){let t=He.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 y$(e,t){let n=e.vertexAttributes}function tDe(e,t){return function(){return e[t]}}var E8=Math.max(kt.hardwareConcurrency-1,1),tU,nDe=new gi("combineGeometry");function iDe(e,t){let n,i,o,r,s=e._instanceIds;if(e._state===pr.READY){n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];let a=e._numberOfInstances=n.length,c=[],l=[];for(o=0;o<a;++o)i=n[o].geometry,s.push(n[o].id),l.push({moduleName:i._workerName,geometry:i});if(!u(tU))for(tU=new Array(E8),o=0;o<E8;o++)tU[o]=new gi("createGeometry");let f;for(l=DI(l,E8),o=0;o<l.length;o++){let d=0,p=l[o],g=p.length;for(r=0;r<g;++r)f=p[r],i=f.geometry,u(i.constructor.pack)&&(f.offset=d,d+=y(i.constructor.packedLength,i.packedLength));let h;if(d>0){let A=new Float64Array(d);for(h=[A.buffer],r=0;r<g;++r)f=p[r],i=f.geometry,u(i.constructor.pack)&&(i.constructor.pack(i,A,f.offset),f.geometry=A)}c.push(tU[o].scheduleTask({subTasks:l[o]},h))}e._state=pr.CREATING,Promise.all(c).then(function(d){e._createGeometryResults=d,e._state=pr.CREATED}).catch(function(d){NI(e,t,pr.FAILED,d)})}else if(e._state===pr.CREATED){let a=[];n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];let c=t.scene3DOnly,l=t.mapProjection,f=nDe.scheduleTask(z0.packCombineGeometryParameters({createGeometryResults:e._createGeometryResults,instances:n,ellipsoid:l.ellipsoid,projection:l,elementIndexUintSupported:t.context.elementIndexUint,scene3DOnly:c,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e._createPickOffsets},a),a);e._createGeometryResults=void 0,e._state=pr.COMBINING,Promise.resolve(f).then(function(d){let p=z0.unpackCombineGeometryResults(d);e._geometries=p.geometries,e._attributeLocations=p.attributeLocations,e.modelMatrix=B.clone(p.modelMatrix,e.modelMatrix),e._pickOffsets=p.pickOffsets,e._offsetInstanceExtend=p.offsetInstanceExtend,e._instanceBoundingSpheres=p.boundingSpheres,e._instanceBoundingSpheresCV=p.boundingSpheresCV,u(e._geometries)&&e._geometries.length>0?(e._recomputeBoundingSpheres=!0,e._state=pr.COMBINED):NI(e,t,pr.FAILED,void 0)}).catch(function(d){NI(e,t,pr.FAILED,d)})}}function oDe(e,t){let n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances],i=e._numberOfInstances=n.length,o=new Array(i),r=e._instanceIds,s,a,c=0;for(a=0;a<i;a++){s=n[a];let p=s.geometry,g;u(p.attributes)&&u(p.primitiveType)?g=Jwe(p):g=p.constructor.createGeometry(p),o[c++]=Zwe(s,g),r.push(s.id)}o.length=c;let l=t.scene3DOnly,f=t.mapProjection,d=z0.combineGeometry({instances:o,ellipsoid:f.ellipsoid,projection:f,elementIndexUintSupported:t.context.elementIndexUint,scene3DOnly:l,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e._createPickOffsets});e._geometries=d.geometries,e._attributeLocations=d.attributeLocations,e.modelMatrix=B.clone(d.modelMatrix,e.modelMatrix),e._pickOffsets=d.pickOffsets,e._offsetInstanceExtend=d.offsetInstanceExtend,e._instanceBoundingSpheres=d.boundingSpheres,e._instanceBoundingSpheresCV=d.boundingSpheresCV,u(e._geometries)&&e._geometries.length>0?(e._recomputeBoundingSpheres=!0,e._state=pr.COMBINED):NI(e,t,pr.FAILED,void 0)}function rDe(e,t){let n=e._batchTableAttributeIndices.offset;if(!e._recomputeBoundingSpheres||!u(n)){e._recomputeBoundingSpheres=!1;return}let i,o=e._offsetInstanceExtend,r=e._instanceBoundingSpheres,s=r.length,a=e._tempBoundingSpheres;if(!u(a)){for(a=new Array(s),i=0;i<s;i++)a[i]=new ae;e._tempBoundingSpheres=a}for(i=0;i<s;++i){let A=a[i],x=e._batchTable.getBatchedAttribute(i,n,new m);A=r[i].clone(A),D$(A,x,o[i])}let c=[],l=[],f=[];for(i=0;i<s;++i){let A=a[i];A.center.x-A.radius>0||ae.intersectPlane(A,ln.ORIGIN_ZX_PLANE)!==en.INTERSECTING?c.push(A):(l.push(A),f.push(A))}let d=c[0],p=f[0],g=l[0];for(i=1;i<c.length;i++)d=ae.union(d,c[i]);for(i=1;i<f.length;i++)p=ae.union(p,f[i]);for(i=1;i<l.length;i++)g=ae.union(g,l[i]);let h=[];for(u(d)&&h.push(d),u(p)&&h.push(p),u(g)&&h.push(g),i=0;i<h.length;i++){let A=h[i].clone(e._boundingSpheres[i]);e.
#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 qu(e,t,n){this._projectionExtentDefines={eastMostYhighDefine:"",eastMostYlowDefine:"",westMostYhighDefine:"",westMostYlowDefine:""};let i=new S8;i.requiresTextureCoordinates=e,i.requiresEC=!n.flat;let o=new S8;if(o.requiresTextureCoordinates=e,n instanceof sn)i.requiresNormalEC=!n.flat;else{let 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}qu.prototype.createFragmentShader=function(e){let 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 sn&&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 sn||(o=t.material.shaderSource),new He({defines:i,sources:[o,hT]})};qu.prototype.createPickFragmentShader=function(e){let 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 He({defines:n,sources:[hT],pickColorQualifier:"in"})};qu.prototype.createVertexShader=function(e,t,n,i){return N$(this._colorShaderDependencies,this._planarExtents,n,e,t,this._appearance,i,this._projectionExtentDefines)};qu.prototype.createPickVertexShader=function(e,t,n,i){return N$(this._pickShaderDependencies,this._planarExtents,n,e,t,void 0,i,this._projectionExtentDefines)};var I$=new m,P$=new he,O$={high:0,low:0};function N$(e,t,n,i,o,r,s,a){let c=i.slice();if(a.eastMostYhighDefine===""){let l=P$;l.longitude=P.PI,l.latitude=0,l.height=0;let f=s.project(l,I$),d=Gn.encode(f.x,O$);a.eastMostYhighDefine=`EAST_MOST_X_HIGH ${d.high.toFixed(`${d.high}`.length+1)}`,a.eastMostYlowDefine=`EAST_MOST_X_LOW ${d.low.toFixed(`${d.low}`.length+1)}`;let p=P$;p.longitude=-P.PI,p.latitude=0,p.height=0;let g=s.project(p,I$);d=Gn.encode(g.x,O$),a.westMostYhighDefine=`WEST_MOST_X_HIGH ${d.high.toFixed(`${d.high}`.length+1)}`,a.westMostYlowDefine=`WEST_MOST_X_LOW ${d.low.toFixed(`${d.low}`.length+1)}`}return n&&(c.push(a.eastMostYhighDefine),c.push(a.eastMostYlowDefine),c.push(a.westMostYhighDefine),c.push(a.westMostYlowDefine)),u(r)&&r instanceof sn&&c.push("PER_INSTANCE_COLOR"),e.requiresTextureCoordinates&&(c.push("TEXTURE_COORDINATES"),t||n||c.push("SPHERICAL"),n&&c.push("COLUMBUS_VIEW_2D")),new He({defines:c,sources:[o]})}function S8(){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(S8.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:functio
`,r=` extrudeDirection = czm_octDecode(${n}, 65535.0);
`,s=t;s=s.replace(/in\s+vec3\s+extrudeDirection;/g,""),s=He.replaceMain(s,"czm_non_compressed_main");let a=`void main()
{
${r} czm_non_compressed_main();
}`;return[i,o,s,a].join(`
`)}}function VDe(e,t){let n=t.context,i=e._primitive,o=wI;o=e._primitive._batchTable.getVertexShaderCallback()(o),o=vn._appendDistanceDisplayConditionToShader(i,o),o=vn._modifyShaderPosition(e,o,t.scene3DOnly),o=vn._updateColorAttribute(i,o);let r=e._hasPlanarExtentsAttributes,s=r||e._hasSphericalExtentsAttribute;e._extruded&&(o=UDe(i,o));let a=e._extruded?"EXTRUDED_GEOMETRY":"",c=new He({defines:[a],sources:[o]}),l=new He({sources:[ig]}),f=e._primitive._attributeLocations,d=new Xl(s,r,e.appearance);if(e._spStencil=Jt.replaceCache({context:n,shaderProgram:e._spStencil,vertexShaderSource:c,fragmentShaderSource:l,attributeLocations:f}),e._primitive.allowPicking){let h=He.createPickVertexShaderSource(o);h=vn._appendShowToShader(i,h),h=vn._updatePickColorAttribute(h);let A=d.createPickFragmentShader(!1),x=d.createPickVertexShader([a],h,!1,t.mapProjection);if(e._spPick=Jt.replaceCache({context:n,shaderProgram:e._spPick,vertexShaderSource:x,fragmentShaderSource:A,attributeLocations:f}),s){let C=n.shaderCache.getDerivedShaderProgram(e._spPick,"2dPick");if(!u(C)){let T=d.createPickFragmentShader(!0),E=d.createPickVertexShader([a],h,!0,t.mapProjection);C=n.shaderCache.createDerivedShaderProgram(e._spPick,"2dPick",{vertexShaderSource:E,fragmentShaderSource:T,attributeLocations:f})}e._spPick2D=C}}else e._spPick=Jt.fromCache({context:n,vertexShaderSource:c,fragmentShaderSource:l,attributeLocations:f});o=vn._appendShowToShader(i,o),c=new He({defines:[a],sources:[o]}),e._sp=Jt.replaceCache({context:n,shaderProgram:e._sp,vertexShaderSource:c,fragmentShaderSource:l,attributeLocations:f});let p=d.createFragmentShader(!1),g=d.createVertexShader([a],o,!1,t.mapProjection);if(e._spColor=Jt.replaceCache({context:n,shaderProgram:e._spColor,vertexShaderSource:g,fragmentShaderSource:p,attributeLocations:f}),s){let h=n.shaderCache.getDerivedShaderProgram(e._spColor,"2dColor");if(!u(h)){let A=d.createFragmentShader(!0),x=d.createVertexShader([a],o,!0,t.mapProjection);h=n.shaderCache.createDerivedShaderProgram(e._spColor,"2dColor",{vertexShaderSource:x,fragmentShaderSource:A,attributeLocations:f})}e._spColor2D=h}}function kDe(e,t){let n=e._primitive,i=n._va.length*2;t.length=i;let o,r,s,a=0,c=n._batchTable.getUniformMapCallback()(e._uniformMap),l=e._needs2DShader;for(o=0;o<i;o+=2){let g=n._va[a++];r=t[o],u(r)||(r=t[o]=new nt({owner:e,primitiveType:n._primitiveType})),r.vertexArray=g,r.renderState=e._rsStencilDepthPass,r.shaderProgram=e._sp,r.uniformMap=c,r.pass=be.TERRAIN_CLASSIFICATION,s=nt.shallowClone(r,r.derivedCommands.tileset),s.renderState=e._rsStencilDepthPass3DTiles,s.pass=be.CESIUM_3D_TILE_CLASSIFICATION,r.derivedCommands.tileset=s,r=t[o+1],u(r)||(r=t[o+1]=new nt({owner:e,primitiveType:n._primitiveType})),r.vertexArray=g,r.renderState=e._rsColorPass,r.shaderProgram=e._spColor,r.pass=be.TERRAIN_CLASSIFICATION;let A=e.appearance.material;if(u(A)&&(c=ht(c,A._uniforms)),r.uniformMap=c,s=nt.shallowClone(r,r.derivedCommands.tileset),s.pass=be.CESIUM_3D_TILE_CLASSIFICATION,r.derivedCommands.tileset=s,l){let x=nt.shallowClone(r,r.derivedCommands.appearance2D);x.shaderProgram=e._spColor2D,r.derivedCommands.appearance2D=x,x=nt.shallowClone(s,s.derivedCommands.appearance2D),x.shaderProgram=e._spColor2D,s.derivedCommands.appearance2D=x}}let f=e._commandsIgnoreShow,d=e._spStencil,p=0;i=f.length=i/2;for(let g=0;g<i;++g){let h=f[g]=nt.shallowClone(t[p],f[g]);h.shaderProgram=d,h.pass=be.CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW,p+=2}}function zDe(e,t){let n=e._usePickOffsets,i=e._primitive,o=i._va.length*2,r,s=0,a;n&&(r=i._pickOffsets,o=r.length*2),t.length=o;let c,l,f,d=0,p=i._batchTable.getUniformMapCallback()(e._uniformMap),g=e._needs2DShader;for(c=0;c<o;c+=2){let h=i._va[d++];if(n&&(a=r[s++],h=i._va[a.index]),l=t[c],u(l)||(l=t[c]=new nt({owner:e,primitiveType:i._primitiveType,pickOnly:!0})),l.vertexArray=h,l.renderState=e._rsStencilDepthPass,l.shaderProgram=e._sp,l.uniformMap=p,l.pass=be.TERRAIN_CLASSIFICATION,n&&(l.offset=a.offset,l.count=a.count),f=nt.shallowClone(l,l.derivedCommands.tileset),f.renderState=e._rsStencilDepthPass3DTiles,f.pass=be.CE
in vec4 v_endPlaneNormalEcAndBatchId;
in vec4 v_rightPlaneEC; // Technically can compute distance for this here
in vec4 v_endEcAndStartEcX;
in vec4 v_texcoordNormalizationAndStartEcYZ;
#ifdef PER_INSTANCE_COLOR
in vec4 v_color;
#endif
void main(void)
{
float logDepthOrDepth = czm_branchFreeTernary(czm_sceneMode == czm_sceneMode2D, gl_FragCoord.z, czm_unpackDepth(texture(czm_globeDepthTexture, gl_FragCoord.xy / czm_viewport.zw)));
vec3 ecStart = vec3(v_endEcAndStartEcX.w, v_texcoordNormalizationAndStartEcYZ.zw);
// Discard for sky
if (logDepthOrDepth == 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
}
vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);
eyeCoordinate /= eyeCoordinate.w;
float halfMaxWidth = v_startPlaneNormalEcAndHalfWidth.w * czm_metersPerPixel(eyeCoordinate);
// Check distance of the eye coordinate against the right-facing plane
float widthwiseDistance = czm_planeDistance(v_rightPlaneEC, eyeCoordinate.xyz);
// Check eye coordinate against the mitering planes
float distanceFromStart = czm_planeDistance(v_startPlaneNormalEcAndHalfWidth.xyz, -dot(ecStart, v_startPlaneNormalEcAndHalfWidth.xyz), eyeCoordinate.xyz);
float distanceFromEnd = czm_planeDistance(v_endPlaneNormalEcAndBatchId.xyz, -dot(v_endEcAndStartEcX.xyz, v_endPlaneNormalEcAndBatchId.xyz), eyeCoordinate.xyz);
if (abs(widthwiseDistance) > 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();
}
`;var kI=`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
}
`;var zI=`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
}
`;var HI=`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
}
`;var GI=`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;
}
`;var Kl=`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);
}
`;var z8=`${Kl}
${GI}`,ZIe=P0;kt.isInternetExplorer()||(z8=`#define CLIP_POLYLINE
${z8}`);function j0(e){e=y(e,y.EMPTY_OBJECT);let t=y(e.translucent,!0),n=!1,i=j0.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=y(e.vertexShaderSource,z8),this._fragmentShaderSource=y(e.fragmentShaderSource,ZIe),this._renderState=eo.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(j0.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}}});j0.VERTEX_FORMAT=Oe.POSITION_ONLY;j0.prototype.getFragmentShaderSource=eo.prototype.getFragmentShaderSource;j0.prototype.isTranslucent=eo.prototype.isTranslucent;j0.prototype.getRenderState=eo.prototype.getRenderState;var Hr=j0;var WI=`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;
}
`;var Y0=`#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();
}
`;var H8=`${Kl}
${WI}`,QIe=Y0;kt.isInternetExplorer()||(H8=`#define CLIP_POLYLINE
${H8}`);function q0(e){e=y(e,y.EMPTY_OBJECT);let t=y(e.translucent,!0),n=!1,i=q0.VERTEX_FORMAT;this.material=u(e.material)?e.material:zi.fromType(zi.ColorType),this.translucent=t,this._vertexShaderSource=y(e.vertexShaderSource,H8),this._fragmentShaderSource=y(e.fragmentShaderSource,QIe),this._renderState=eo.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(q0.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}}});q0.VERTEX_FORMAT=Oe.POSITION_AND_ST;q0.prototype.getFragmentShaderSource=eo.prototype.getFragmentShaderSource;q0.prototype.isTranslucent=eo.prototype.isTranslucent;q0.prototype.getRenderState=eo.prototype.getRenderState;var Ws=q0;function ip(e){e=y(e,y.EMPTY_OBJECT),this.geometryInstances=e.geometryInstances,this._hasPerInstanceColors=!0;let t=e.appearance;u(t)||(t=new Ws),this.appearance=t,this.show=y(e.show,!0),this.classificationType=y(e.classificationType,kn.BOTH),this.debugShowBoundingVolume=y(e.debugShowBoundingVolume,!1),this._debugShowShadowVolume=y(e.debugShowShadowVolume,!1),this._primitiveOptions={geometryInstances:void 0,appearance:void 0,vertexCacheOptimize:!1,interleave:y(e.interleave,!1),releaseGeometryInstances:y(e.releaseGeometryInstances,!0),allowPicking:y(e.allowPicking,!0),asynchronous:y(e.asynchronous,!0),compressVertices:!1,_createShaderProgramFunction:void 0,_createCommandsFunction:void 0,_updateAndQueueCommandsFunction:void 0},this._zIndex=void 0,this._ready=!1;let n=this;this._readyPromise=new Promise((i,o)=>{n._completeLoad=()=>{this._ready=!0,this.releaseGeometryInstances&&(this.geometryInstances=void 0);let r=this._error;u(r)?o(r):i(this)}}),this._primitive=void 0,this._sp=void 0,this._sp2D=void 0,this._spMorph=void 0,this._renderState=Eee(!1),this._renderState3DTiles=Eee(!0),this._renderStateMorph=ke.fromCache({cull:{enabled:!0,face:_i.FRONT},depthTest:{enabled:!0},blending:un.PRE_MULTIPLIED_ALPHA_BLEND,depthMask:!1})}Object.defineProperties(ip.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}},readyPromise:{get:function(){return $("GroundPolylinePrimitive.readyPromise","GroundPolylinePrimitive.readyPromise was deprecated in CesiumJS 1.104. It will be removed in 1.107. Wait for GroundPolylinePrimitive.ready to return true instead."),this._readyPromise}},debugShowShadowVolume:{get:function(){return this._debugShowShadowVolume}}});ip.initializeTerrainHeights=function(){return ri.initialize()};function $Ie(e,t,n){let i=t.context,o=e._primitive,r=o._attributeLocations,s=o._batchTable.getVertexShaderCallback()(HI);s=vn._appendShowToShader(o,s),s=vn._appendDistanceDisplayConditionToShader(o,s),s=vn._modifyShaderPosition(e,s,t.scene3DOnly);let a=o._batchTable.getVertexShaderCallback()(zI);a=vn._appendShowToShader(o,a),a=vn._appendDistanceDisplayConditionToShader(o,a),a=vn._modifyShaderPosition(e,a,t.scene3DOnly);let c=o._batchTable.getVertexShaderCallback()(VI),l=[`GLOBE_MINIMUM_ALTITUDE ${t.mapProjection.ellipsoid.minimumRadius.toFixed(1)}`],f="",d="";u(n.material)?(d=u(n.material)?n.material.shaderSource:"",d.search(/in\s+float\s+v_polylineAngle;/g)!==-1&&l.push("ANGLE_VARYING"),d.search(/in\s+float\s+v_width;/g)!==-1&&l.push("WIDTH_VARYING")):f="PER_INSTANCE_COLOR",l.push(f);let p=e.debugShowShadowVolume?["DEBUG_SHOW_VOLUME",f]:[f],g=new He({defines:l,sources:[s]}),h=new He({defines:p,sources:[d,c]});e._sp=Jt.replaceCache({context:i,shaderProgram:o._sp,vertexShaderSource:g,fragmentShaderSource:h,attributeLocations:r});let A=i.shaderCache.getDerivedShaderProgram(e._sp,"2dColor");if(!u(A)){let C=new He({defines:l.concat(["COLUMBUS_VIEW_2D"]),sources:[s]});A=i.shaderCache.createDerivedShaderProgram(e._sp,"2dColor",{context:i,shaderProgram:e._sp2D,vertexShaderSource:C,fragmentShaderSource:h,attributeLocations:r})}e._sp2D=A;let x=i.shaderCache.getDerivedShaderProgram(e._sp,"MorphColor");if(!u(x)){let C=new He({defines:l.concat([`MAX_TERRAIN_HEIGHT ${ri._defaultMaxTerrainHeight.toFixed(1)}`]),sources:[a]});c=o._batchTable.getVertexShaderCallback()(kI
uniform float originalSize;
uniform sampler2D texture0;
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D texture3;
uniform sampler2D texture4;
uniform sampler2D texture5;
const float yMipLevel1 = 1.0 - (1.0 / pow(2.0, 1.0));
const float yMipLevel2 = 1.0 - (1.0 / pow(2.0, 2.0));
const float yMipLevel3 = 1.0 - (1.0 / pow(2.0, 3.0));
const float yMipLevel4 = 1.0 - (1.0 / pow(2.0, 4.0));
void main()
{
vec2 uv = v_textureCoordinates;
vec2 textureSize = vec2(originalSize * 1.5 + 2.0, originalSize);
vec2 pixel = 1.0 / textureSize;
float mipLevel = 0.0;
if (uv.x - pixel.x > (textureSize.y / textureSize.x))
{
mipLevel = 1.0;
if (uv.y - pixel.y > yMipLevel1)
{
mipLevel = 2.0;
if (uv.y - pixel.y * 3.0 > yMipLevel2)
{
mipLevel = 3.0;
if (uv.y - pixel.y * 5.0 > yMipLevel3)
{
mipLevel = 4.0;
if (uv.y - pixel.y * 7.0 > yMipLevel4)
{
mipLevel = 5.0;
}
}
}
}
}
if (mipLevel > 0.0)
{
float scale = pow(2.0, mipLevel);
uv.y -= (pixel.y * (mipLevel - 1.0) * 2.0);
uv.x *= ((textureSize.x - 2.0) / textureSize.y);
uv.x -= 1.0 + pixel.x;
uv.y -= (1.0 - (1.0 / pow(2.0, mipLevel - 1.0)));
uv *= scale;
}
else
{
uv.x *= (textureSize.x / textureSize.y);
}
if(mipLevel == 0.0)
{
out_FragColor = texture(texture0, uv);
}
else if(mipLevel == 1.0)
{
out_FragColor = texture(texture1, uv);
}
else if(mipLevel == 2.0)
{
out_FragColor = texture(texture2, uv);
}
else if(mipLevel == 3.0)
{
out_FragColor = texture(texture3, uv);
}
else if(mipLevel == 4.0)
{
out_FragColor = texture(texture4, uv);
}
else if(mipLevel == 5.0)
{
out_FragColor = texture(texture5, uv);
}
else
{
out_FragColor = vec4(0.0);
}
}
`;var fP=`in vec3 v_cubeMapCoordinates;
uniform samplerCube cubeMap;
void main()
{
vec4 rgba = czm_textureCube(cubeMap, v_cubeMapCoordinates);
#ifdef RGBA_NORMALIZED
out_FragColor = vec4(rgba.rgb, 1.0);
#else
float m = rgba.a * 16.0;
vec3 r = rgba.rgb * m;
out_FragColor = vec4(r * r, 1.0);
#endif
}
`;var dP=`in vec4 position;
in vec3 cubeMapCoordinates;
out vec3 v_cubeMapCoordinates;
void main()
{
gl_Position = position;
v_cubeMapCoordinates = cubeMapCoordinates;
}
`;function rA(e){this._url=e,this._cubeMapBuffers=void 0,this._cubeMaps=void 0,this._texture=void 0,this._mipTextures=void 0,this._va=void 0,this._sp=void 0,this._maximumMipmapLevel=void 0,this._loading=!1,this._ready=!1,this._errorEvent=new ye}Object.defineProperties(rA.prototype,{url:{get:function(){return this._url}},errorEvent:{get:function(){return this._errorEvent}},texture:{get:function(){return this._texture}},maximumMipmapLevel:{get:function(){return this._maximumMipmapLevel}},ready:{get:function(){return this._ready}}});rA.isSupported=function(e){return e.colorBufferHalfFloat&&e.halfFloatingPointTexture||e.floatingPointTexture&&e.colorBufferFloat};var LPe=new m(1,0,0),NPe=new m(0,0,1),FPe=new m(-1,0,0),UPe=new m(0,0,-1),lU=new m(0,1,0),VPe=new m(0,-1,0),Vee=[lU,FPe,NPe,VPe,LPe,lU,UPe,lU,lU],kee=Vee.length,zee=new Float32Array(kee*3),Fee=0;for(let e=0;e<kee;++e,Fee+=3)m.pack(Vee[e],zee,Fee);var kPe=new Float32Array([-1,1,-1,0,0,1,0,0,1,0,1,1,0,-1,-1,-1,1,-1]),zPe=new Uint16Array([0,1,2,2,3,1,7,6,1,3,6,1,2,5,4,3,4,2,4,8,6,3,4,6]);function HPe(e){let t=ut.createVertexBuffer({context:e,typedArray:kPe,usage:Fe.STATIC_DRAW}),n=ut.createVertexBuffer({context:e,typedArray:zee,usage:Fe.STATIC_DRAW}),i=ut.createIndexBuffer({context:e,typedArray:zPe,usage:Fe.STATIC_DRAW,indexDatatype:Ue.UNSIGNED_SHORT}),o=[{index:0,vertexBuffer:t,componentsPerAttribute:2,componentDatatype:X.FLOAT},{index:1,vertexBuffer:n,componentsPerAttribute:3,componentDatatype:X.FLOAT}];return new si({context:e,attributes:o,indexBuffer:i})}function Uee(e){return function(){return e}}function K8(e){e._va=e._va&&e._va.destroy(),e._sp=e._sp&&e._sp.destroy();let t,n,i=e._cubeMaps;if(u(i))for(n=i.length,t=0;t<n;++t)i[t].destroy();let o=e._mipTextures;if(u(o))for(n=o.length,t=0;t<n;++t)o[t].destroy();e._va=void 0,e._sp=void 0,e._cubeMaps=void 0,e._cubeMapBuffers=void 0,e._mipTextures=void 0}rA.prototype.update=function(e){let t=e.context;if(!rA.isSupported(t)||(u(this._texture)&&u(this._va)&&K8(this),u(this._texture)))return;if(!u(this._texture)&&!this._loading){let g=e.context.textureCache.getTexture(this._url);u(g)&&(K8(this),this._texture=g,this._maximumMipmapLevel=this._texture.maximumMipmapLevel,this._ready=!0)}let n=this._cubeMapBuffers;if(!u(n)&&!this._loading){let g=this;sl(this._url).then(function(h){g._cubeMapBuffers=h,g._loading=!1}).catch(function(h){g.isDestroyed()||g._errorEvent.raiseEvent(h)}),this._loading=!0}if(!u(this._cubeMapBuffers))return;let i=[],o=n[0].positiveX.pixelDatatype;u(o)?i.push("RGBA_NORMALIZED"):o=t.halfFloatingPointTexture?Ke.HALF_FLOAT:Ke.FLOAT;let r=st.RGBA,s=new He({defines:i,sources:[fP]});this._va=HPe(t),this._sp=Jt.fromCache({context:t,vertexShaderSource:dP,fragmentShaderSource:s,attributeLocations:{position:0,cubeMapCoordinates:1}});let a=Math.min(n.length,6);this._maximumMipmapLevel=a-1;let c=this._cubeMaps=new Array(a),l=this._mipTextures=new Array(a),f=n[0].positiveX.width*2,d={originalSize:function(){return f}};for(let g=0;g<a;++g){let h=n[g].positiveY;n[g].positiveY=n[g].negativeY,n[g].negativeY=h;let A=c[g]=new ka({context:t,source:n[g],pixelDatatype:o}),x=c[g].width*2,C=l[g]=new Mt({context:t,width:x,height:x,pixelDatatype:o,pixelFormat:r}),T=new Ku({vertexArray:this._va,shaderProgram:this._sp,uniformMap:{cubeMap:Uee(A)},outputTexture:C,persists:!0,owner:this});e.commandList.push(T),d[`texture${g}`]=Uee(C)}this._texture=new Mt({context:t,width:f*1.5+2,height:f,pixelDatatype:o,pixelFormat:r}),this._texture.maximumMipmapLevel=this._maximumMipmapLevel,t.textureCache.addTexture(this._url,this._texture);let p=new Ku({fragmentShaderSource:uP,uniformMap:d,outputTexture:this._texture,persists:!1,owner:this});e.commandList.push(p),this._ready=!0};rA.prototype.isDestroyed=function(){return!1};rA.prototype.destroy=function(){return K8(this),this._texture=this._texture&&this._texture.destroy(),ue(this)};var ud=rA;function mP(e){e=y(e,y.EMPTY_OBJECT);let t=u(e.imageBasedLightingFactor)?H.clone(e.imageBasedLightingFactor):new H(1,1);this._imageBasedLightingFactor=t;let n=y(e.luminanceAtZenith,.2);this._luminanceAtZenith=n;
vec2 computeSt(float batchId)
{
float stepX = tile_textureStep.x;
float centerX = tile_textureStep.y;
return vec2(centerX + (batchId * stepX), 0.5);
}
`:`uniform vec4 tile_textureStep;
uniform vec2 tile_textureDimensions;
vec2 computeSt(float batchId)
{
float stepX = tile_textureStep.x;
float centerX = tile_textureStep.y;
float stepY = tile_textureStep.z;
float centerY = tile_textureStep.w;
float xId = mod(batchId, tile_textureDimensions.x);
float yId = floor(batchId / tile_textureDimensions.x);
return vec2(centerX + (xId * stepX), centerY + (yId * stepY));
}
`}uo.prototype.getVertexShaderCallback=function(e,t,n){if(this.featuresLength===0)return;let i=this;return function(o){let r=Qee(o,n,!1),s;return Vt.maximumVertexTextureImageUnits>0?(s="",e&&(s+=`uniform bool tile_translucentCommand;
`),s+=`uniform sampler2D tile_batchTexture;
out vec4 tile_featureColor;
out vec2 tile_featureSt;
void main()
{
vec2 st = computeSt(${t});
vec4 featureProperties = texture(tile_batchTexture, st);
tile_color(featureProperties);
float show = ceil(featureProperties.a);
gl_Position *= show;
`,e&&(s+=` bool isStyleTranslucent = (featureProperties.a != 1.0);
if (czm_pass == czm_passTranslucent)
{
if (!isStyleTranslucent && !tile_translucentCommand)
{
gl_Position *= 0.0;
}
}
else
{
if (isStyleTranslucent)
{
gl_Position *= 0.0;
}
}
`),s+=` tile_featureColor = featureProperties;
tile_featureSt = st;
}`):s=`out vec2 tile_featureSt;
void main()
{
tile_color(vec4(1.0));
tile_featureSt = computeSt(${t});
}`,`${r}
${C1e(i)}${s}`}};function Jee(e,t){return e=He.replaceMain(e,"tile_main"),t?`${e}uniform float tile_colorBlend;
void tile_color(vec4 tile_featureColor)
{
tile_main();
tile_featureColor = czm_gammaCorrect(tile_featureColor);
out_FragColor.a *= tile_featureColor.a;
float highlight = ceil(tile_colorBlend);
out_FragColor.rgb *= mix(tile_featureColor.rgb, vec3(1.0), highlight);
}
`:`${e}void tile_color(vec4 tile_featureColor)
{
tile_main();
}
`}function T1e(e,t){let n=`texture(${t}`,i=0,o=e.indexOf(n,i),r;for(;o>-1;){let s=0;for(let l=o;l<e.length;++l){let f=e.charAt(l);if(f==="(")++s;else if(f===")"&&(--s,s===0)){r=l+1;break}}let c=`tile_diffuse_final(${e.slice(o,r)}, tile_diffuse)`;e=e.slice(0,o)+c+e.slice(r),i=o+c.length,o=e.indexOf(n,i)}return e}function Qee(e,t,n){if(!u(t))return Jee(e,n);let i=new RegExp(`(uniform|attribute|in)\\s+(vec[34]|sampler2D)\\s+${t};`),o=e.match(i);if(!u(o))return Jee(e,n);let r=o[0],s=o[2];e=He.replaceMain(e,"tile_main"),e=e.replace(r,"");let a=`bool isWhite(vec3 color)
{
return all(greaterThan(color, vec3(1.0 - czm_epsilon3)));
}
vec4 tile_diffuse_final(vec4 sourceDiffuse, vec4 tileDiffuse)
{
vec4 blendDiffuse = mix(sourceDiffuse, tileDiffuse, tile_colorBlend);
vec4 diffuse = isWhite(tileDiffuse.rgb) ? sourceDiffuse : blendDiffuse;
return vec4(diffuse.rgb, sourceDiffuse.a);
}
`,c=` tile_featureColor = czm_gammaCorrect(tile_featureColor);
out_FragColor.a *= tile_featureColor.a;
float highlight = ceil(tile_colorBlend);
out_FragColor.rgb *= mix(tile_featureColor.rgb, vec3(1.0), highlight);
`,l;if(s==="vec3"||s==="vec4"){let f=s==="vec3"?`vec4(${t}, 1.0)`:t,d=s==="vec3"?"tile_diffuse.xyz":"tile_diffuse";i=new RegExp(t,"g"),e=e.replace(i,d),l=` vec4 source = ${f};
tile_diffuse = tile_diffuse_final(source, tile_featureColor);
tile_main();
`}else s==="sampler2D"&&(e=T1e(e,t),l=` tile_diffuse = tile_featureColor;
tile_main();
`);return e=`uniform float tile_colorBlend;
vec4 tile_diffuse = vec4(1.0);
${a}${r}
${e}
void tile_color(vec4 tile_featureColor)
{
${l}`,n&&(e+=c),e+=`}
`,e}uo.prototype.getFragmentShaderCallback=function(e,t,n){if(this.featuresLength!==0)return function(i){return i=Qee(i,t,!0),Vt.maximumVertexTextureImageUnits>0?(i+=`uniform sampler2D tile_pickTexture;
in vec2 tile_featureSt;
in vec4 tile_featureColor;
void main()
{
tile_color(tile_featureColor);
`,n&&(i+=` out_FragColor.rgb *= out_FragColor.a;
`),i+="}"):(e&&(i+=`uniform bool tile_translucentCommand;
`),i+=`uniform sampler2D tile_pickTexture;
uniform sampler2D tile_batchTexture;
in vec2 tile_featureSt;
void main()
{
vec4 featureProperties = texture(tile_batchTexture, tile_featureSt);
if (featureProperties.a == 0.0) {
discard;
}
`,e&&(i+=` bool isStyleTranslucent = (featureProperties.a != 1.0);
if (czm_pass == czm_passTranslucent)
{
if (!isStyleTranslucent && !tile_translucentCommand)
{
discard;
}
}
else
{
if (isStyleTranslucent)
{
discard;
}
}
`),i+=` tile_color(featureProperties);
`,n&&(i+=` out_FragColor.rgb *= out_FragColor.a;
`),i+=`}
`),i}};uo.prototype.getClassificationFragmentShaderCallback=function(){if(this.featuresLength!==0)return function(e){return e=He.replaceMain(e,"tile_main"),Vt.maximumVertexTextureImageUnits>0?e+=`uniform sampler2D tile_pickTexture;
in vec2 tile_featureSt;
in vec4 tile_featureColor;
void main()
{
tile_main();
out_FragColor = tile_featureColor;
out_FragColor.rgb *= out_FragColor.a;
}`:e+=`uniform sampler2D tile_batchTexture;
uniform sampler2D tile_pickTexture;
in vec2 tile_featureSt;
void main()
{
tile_main();
vec4 featureProperties = texture(tile_batchTexture, tile_featureSt);
if (featureProperties.a == 0.0) {
discard;
}
out_FragColor = featureProperties;
out_FragColor.rgb *= out_FragColor.a;
}
`,e}};function E1e(e){let t=e._content.tileset,n=t.colorBlendMode,i=t.colorBlendAmount;if(n===ml.HIGHLIGHT)return 0;if(n===ml.REPLACE)return 1;if(n===ml.MIX)return P.clamp(i,P.EPSILON4,1)}uo.prototype.getUniformMapCallback=function(){if(this.featuresLength===0)return;let e=this;return function(t){return ht(t,{tile_batchTexture:function(){return y(e._batchTexture.batchTexture,e._batchTexture.defaultTexture)},tile_textureDimensions:function(){return e._batchTexture.textureDimensions},tile_textureStep:function(){return e._batchTexture.textureStep},tile_colorBlend:function(){return E1e(e)},tile_pickTexture:function(){return e._batchTexture.pickTexture}})}};uo.prototype.getPickId=function(){return"texture(tile_pickTexture, tile_featureSt)"};var fg={ALL_OPAQUE:0,ALL_TRANSLUCENT:1,OPAQUE_AND_TRANSLUCENT:2};uo.prototype.addDerivedCommands=function(e,t){let n=e.commandList,i=n.length,o=this._content._tile,r=o._finalResolution,s=o.tileset,a=s.isSkippingLevelOfDetail&&s.hasMixedContent&&e.context.stencilBuffer,c=b1e(this);for(let l=t;l<i;++l){let f=n[l];if(f.pass===be.COMPUTE)continue;let d=f.derivedCommands.tileset;(!u(d)||f.dirty)&&(d={},f.derivedCommands.tileset=d,d.originalCommand=S1e(f),f.dirty=!1);let p=d.originalCommand;c!==fg.ALL_OPAQUE&&f.pass!==be.TRANSLUCENT&&(u(d.translucent)||(d.translucent=v1e(p))),c!==fg.ALL_TRANSLUCENT&&f.pass!==be.TRANSLUCENT&&(u(d.opaque)||(d.opaque=w1e(p)),a&&(r||(u(d.zback)||(d.zback=I1e(e.context,p)),s._backfaceCommands.push(d.zback)),(!u(d.stencil)||o._selectionDepth!==O1e(d.stencil))&&(f.renderState.depthMask?d.stencil=P1e(p,o._selectionDepth):d.stencil=d.opaque)));let g=a?d.stencil:d.opaque,h=d.translucent;f.pass!==be.TRANSLUCENT?(c===fg.ALL_OPAQUE&&(n[l]=g),c===fg.ALL_TRANSLUCENT&&(n[l]=h),c===fg.OPAQUE_AND_TRANSLUCENT&&(n[l]=g,n.push(h))):n[l]=p}};function b1e(e){let t=e._batchTexture.translucentFeaturesLength;return t===0?fg.ALL_OPAQUE:t===e.featuresLength?fg.ALL_TRANSLUCENT:fg.OPAQUE_AND_TRANSLUCENT}function S1e(e){let t=nt.shallowClone(e),n=t.pass===be.TRANSLUCENT;return t.uniformMap=u(t.uniformMap)?t.uniformMap:{},t.uniformMap.tile_translucentCommand=function(){return n},t}function v1e(e){let t=nt.shallowClone(e);return t.pass=be.TRANSLUCENT,t.renderState=M1e(e.renderState),t}function w1e(e){let t=nt.shallowClone(e);return t.renderState=R1e(e.renderState),t}function D1e(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"zBackfaceLogDepth");if(!u(n)){let i=t.fragmentShaderSource.clone();i.defines=u(i.defines)?i.defines.slice(0):[],i.defines.push("POLYGON_OFFSET"),i.sources.unshift(`#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif
`),n=e.shaderCache.createDerivedShaderProgram(t,"zBackfaceLogDepth",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:i,attributeLocations:t._attributeLocations})}return n}function I1e(e,t){let n=nt.shallowClone(t),i=je(n.renderState,!0);i.cull.enabled=!0,i.cull.face=_i.FRONT,i.colorMask={red:!1,green:!1,blue:!1,alpha:!1},i.polygonOffset={enabled:!0,factor:5,units:5},i.stencilTest=Lt.setCesium3DTileBit(),i.stencilMask=Lt.CESIUM_3D_TILE_MASK,n.renderState=ke.fromCache(i),n.castShadows=!1,n.receiveShadows=!1,n.uniformMap=je(t.uniformMap);let o=new H(5,5);return n.uniformMap.u_polygonOffset=function(){return o},n.shaderProgram=D1e(e,t.shaderProgram),n}function P1e(e,t){let n=nt.shallowClone(e),i=je(n.renderState,!0);return i.stencilTest.enabled=!0,i.stencilTest.mask=Lt.SKIP_LOD_MASK,i.stencilTest.reference=Lt.CESIUM_3D_TILE_MASK|t<<Lt.SKIP_LOD_BIT_SHIFT,i.stencilTest.frontFunction=zn.GREATER_OR_EQUAL,i.stencilTest.frontOperation.zPass=ft.REPLACE,i.stencilTest.backFunction=zn.GREATER_OR_EQUAL,i.stencilTest.backOperation.zPass=ft.REPLACE,i.stencilMask=Lt.CESIUM_3D_TILE_MASK|Lt.SKIP_LOD_MASK,n.renderState=ke.fromCache(i),n}function O1e(e){return(e.renderState.stencilTest.reference&Lt.SKIP_LOD_MASK)>>>Lt.SKIP_LOD_BIT_SHIFT}function M1e(e){let t=je(e,!0);return t.cull.enabled=!1,t.depthTest.enabled=!0,t.depthMask=!1,t.blending=un.ALPHA_BLEND,t.stencilTest=Lt.setCesium3DTileBit(),t.stencilMask=Lt.CESIUM_3D_TILE_MASK,ke.fromCache(t)}function R1e(e){let t=je(e,!0);return t.stencilTest=Lt.setCesium3DTileBit(),t.stencilMask=Lt.CESIUM_3D_TILE_MASK,ke.fromCache(t)}uo.prototype.update=function(e,t){this._batchTexture.update(e,t)};uo.prototype.isDestroyed=function(){return!1};uo.prototype.destroy=function(){return this._batchTexture=this._batchTexture&&this._batchTexture.destroy(),ue(this)};var mp=uo;function B1e(e){this.offset=e.offset,this.count=e.count,this.color=e.color,this.batchIds=e.batchIds}var Lm=B1e;var bT=`in vec3 position;
in float a_batchId;
uniform mat4 u_modifiedModelViewProjection;
void main()
{
gl_Position = czm_depthClamp(u_modifiedModelViewProjection * vec4(position, 1.0));
}
`;function Zu(e,t){this._content=e,this._batchId=t,this._color=void 0}Object.defineProperties(Zu.prototype,{show:{get:function(){return this._content.batchTable.getShow(this._batchId)},set:function(e){this._content.batchTable.setShow(this._batchId,e)}},color:{get:function(){return u(this._color)||(this._color=new k),this._content.batchTable.getColor(this._batchId,this._color)},set:function(e){this._content.batchTable.setColor(this._batchId,e)}},polylinePositions:{get:function(){if(u(this._content.getPolylinePositions))return this._content.getPolylinePositions(this._batchId)}},content:{get:function(){return this._content}},tileset:{get:function(){return this._content.tileset}},primitive:{get:function(){return this._content.tileset}},featureId:{get:function(){return this._batchId}},pickId:{get:function(){return this._content.batchTable.getPickColor(this._batchId)}}});Zu.prototype.hasProperty=function(e){return this._content.batchTable.hasProperty(this._batchId,e)};Zu.prototype.getPropertyIds=function(e){return this._content.batchTable.getPropertyIds(this._batchId,e)};Zu.prototype.getProperty=function(e){return this._content.batchTable.getProperty(this._batchId,e)};Zu.getPropertyInherited=function(e,t,n){let i=e.batchTable;if(u(i)){if(i.hasPropertyBySemantic(t,n))return i.getPropertyBySemantic(t,n);if(i.hasProperty(t,n))return i.getProperty(t,n)}let o=e.metadata;if(u(o)){if(o.hasPropertyBySemantic(n))return o.getPropertyBySemantic(n);if(o.hasProperty(n))return o.getProperty(n)}let r=e.tile,s=r.metadata;if(u(s)){if(s.hasPropertyBySemantic(n))return s.getPropertyBySemantic(n);if(s.hasProperty(n))return s.getProperty(n)}let a;if(u(r.implicitSubtree)&&(a=r.implicitSubtree.metadata),u(a)){if(a.hasPropertyBySemantic(n))return a.getPropertyBySemantic(n);if(a.hasProperty(n))return a.getProperty(n)}let c=u(e.group)?e.group.metadata:void 0;if(u(c)){if(c.hasPropertyBySemantic(n))return c.getPropertyBySemantic(n);if(c.hasProperty(n))return c.getProperty(n)}let l=e.tileset.metadata;if(u(l)){if(l.hasPropertyBySemantic(n))return l.getPropertyBySemantic(n);if(l.hasProperty(n))return l.getProperty(n)}};Zu.prototype.getPropertyInherited=function(e){return Zu.getPropertyInherited(this._content,this._batchId,e)};Zu.prototype.setProperty=function(e,t){this._content.batchTable.setProperty(this._batchId,e,t),this._content.featurePropertiesDirty=!0};Zu.prototype.isExactClass=function(e){return this._content.batchTable.isExactClass(this._batchId,e)};Zu.prototype.isClass=function(e){return this._content.batchTable.isClass(this._batchId,e)};Zu.prototype.getExactClassName=function(){return this._content.batchTable.getExactClassName(this._batchId)};var Cs=Zu;var t5=class{add(t,n,i){if(typeof arguments[0]!="string")for(let o in arguments[0])this.add(o,arguments[0][o],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(o){this[o]=this[o]||[],n&&this[o][i?"unshift":"push"](n)},this)}run(t,n){this[t]=this[t]||[],this[t].forEach(function(i){i.call(n&&n.context?n.context:n,n)})}},n5=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(n=>{if(typeof n!="object"||!n.name||!n.init)throw new Error("Invalid JSEP plugin format");this.registered[n.name]||(n.init(this.jsep),this.registered[n.name]=n)})}},Ge=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Ge.version}static addUnaryOp(t){return Ge.max_unop_len=Math.max(t.length,Ge.max_unop_len),Ge.unary_ops[t]=1,Ge}static addBinaryOp(t,n,i){return Ge.max_binop_len=Math.max(t.length,Ge.max_binop_len),Ge.binary_ops[t]=n,i?Ge.right_associative.add(t):Ge.right_associative.delete(t),Ge}static addIdentifierChar(t){return Ge.additional_identifier_chars.add(t),Ge}static addLiteral(t,n){return Ge.literals[t]=n,Ge}static removeUnaryOp(t){return delete Ge.unary_ops[t],t.length===Ge.max_unop_len&&(Ge.max_unop_len=Ge.getMaxKeyLen(Ge.unary_ops)),Ge}static removeAllUnaryOps(){return Ge.unary_ops={},Ge.max_unop_len=0,Ge}static removeIdentifierChar(t){return Ge.additional_identifier_chars.delete(t),Ge}static removeBinaryOp(t){return delete Ge.bin
`;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=r}else t+=r}return o||this.throwError('Unclosed quote after "'+t+'"'),{type:Ge.LITERAL,value:t,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let t=this.code,n=this.index;for(Ge.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,Ge.isIdentifierPart(t));)this.index++;return{type:Ge.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(t){let n=[],i=!1,o=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let r=this.code;if(r===t){i=!0,this.index++,t===Ge.CPAREN_CODE&&o&&o>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(r===Ge.COMMA_CODE){if(this.index++,o++,o!==n.length){if(t===Ge.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===Ge.CBRACK_CODE)for(let s=n.length;s<o;s++)n.push(null)}}else if(n.length!==o&&o!==0)this.throwError("Expected comma");else{let s=this.gobbleExpression();(!s||s.type===Ge.COMPOUND)&&this.throwError("Expected comma"),n.push(s)}}return i||this.throwError("Expected "+String.fromCharCode(t)),n}gobbleGroup(){this.index++;let t=this.gobbleExpressions(Ge.CPAREN_CODE);if(this.code===Ge.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:Ge.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Ge.ARRAY_EXP,elements:this.gobbleArguments(Ge.CBRACK_CODE)}}},L1e=new t5;Object.assign(Ge,{hooks:L1e,plugins:new n5(Ge),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});Ge.max_unop_len=Ge.getMaxKeyLen(Ge.unary_ops);Ge.max_binop_len=Ge.getMaxKeyLen(Ge.binary_ops);var dg=e=>new Ge(e).parse(),N1e=Object.getOwnPropertyNames(Ge);N1e.forEach(e=>{dg[e]===void 0&&e!=="prototype"&&(dg[e]=Ge[e])});dg.Jsep=Ge;var F1e="ConditionalExpression",U1e={name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let i=n.node,o=this.gobbleExpression();if(o||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),n.node={type:F1e,test:i,consequent:o,alternate:r},i.operator&&e.binary_ops[i.operator]<=.9){let s=i;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;n.node.test=s.right,s.right=n.node,n.node=i}}else this.throwError("Expected :")}})}};dg.plugins.register(U1e);var V1e={VARIABLE:0,UNARY:1,BINARY:2,TERNARY:3,CONDITIONAL:4,MEMBER:5,FUNCTION_CALL:6,ARRAY:7,REGEX:8,VARIABLE_IN_STRING:9,LITERAL_NULL:10,LITERAL_BOOLEAN:11,LITERAL_NUMBER:12,LITERAL_STRING:13,LITERAL_COLOR:14,LITERAL_VECTOR:15,LITERAL_REGEX:16,LITERAL_UNDEFINED:17,BUILTIN_VARIABLE:18},pt=Object.freeze(V1e);function hd(e,t){this._expression=e,e=Q1e(e,t),e=eOe($1e(e)),dg.addBinaryOp("=~",0),dg.addBinaryOp("!~",0);let n;try{n=dg(e)}catch(i){throw new de(i)}this._runtimeAst=Ci(this,n)}Object.defineProperties(hd.prototype,{expression:{get:function(){return this._expression}}});var Rn={arrayIndex:0,arrayArray:[[]],cartesian2Index:0,cartesian3Index:0,cartesian4Index:0,cartesian2Array:[new H],cartesian3Array:[new m],cartesian4Array:[new re],reset:function(){this.arrayIndex=0,this.cartesian2Index=0,this.cartesian3Index=0,this.cartesian4I
{
return ${o};
}
`,o};hd.prototype.getShaderExpression=function(e,t){return this._runtimeAst.getShaderExpression(e,t)};hd.prototype.getVariables=function(){let e=[];return this._runtimeAst.getVariables(e),e=e.filter(function(t,n,i){return i.indexOf(t)===n}),e};var k1e=["!","-","+"],$ee=["+","-","*","/","%","===","!==",">",">=","<","<=","&&","||","!~","=~"],hU=/\${(.*?)}/g,z1e=/\\/g,H1e="@#%",G1e=/@#%/g,pU=new k,_U={abs:Ts(Math.abs),sqrt:Ts(Math.sqrt),cos:Ts(Math.cos),sin:Ts(Math.sin),tan:Ts(Math.tan),acos:Ts(Math.acos),asin:Ts(Math.asin),atan:Ts(Math.atan),radians:Ts(P.toRadians),degrees:Ts(P.toDegrees),sign:Ts(P.sign),floor:Ts(Math.floor),ceil:Ts(Math.ceil),round:Ts(Math.round),exp:Ts(Math.exp),exp2:Ts(j1e),log:Ts(Math.log),log2:Ts(Y1e),fract:Ts(W1e),length:q1e,normalize:X1e},gU={atan2:dU(Math.atan2,!1),pow:dU(Math.pow,!1),min:dU(Math.min,!0),max:dU(Math.max,!0),distance:K1e,dot:J1e,cross:Z1e},r5={clamp:ete(P.clamp,!0),mix:ete(P.lerp,!0)};function W1e(e){return e-Math.floor(e)}function j1e(e){return Math.pow(2,e)}function Y1e(e){return P.log2(e)}function Ts(e){return function(t,n){if(typeof n=="number")return e(n);if(n instanceof H)return H.fromElements(e(n.x),e(n.y),Rn.getCartesian2());if(n instanceof m)return m.fromElements(e(n.x),e(n.y),e(n.z),Rn.getCartesian3());if(n instanceof re)return re.fromElements(e(n.x),e(n.y),e(n.z),e(n.w),Rn.getCartesian4());throw new de(`Function "${t}" requires a vector or number argument. Argument is ${n}.`)}}function dU(e,t){return function(n,i,o){if(t&&typeof o=="number"){if(typeof i=="number")return e(i,o);if(i instanceof H)return H.fromElements(e(i.x,o),e(i.y,o),Rn.getCartesian2());if(i instanceof m)return m.fromElements(e(i.x,o),e(i.y,o),e(i.z,o),Rn.getCartesian3());if(i instanceof re)return re.fromElements(e(i.x,o),e(i.y,o),e(i.z,o),e(i.w,o),Rn.getCartesian4())}if(typeof i=="number"&&typeof o=="number")return e(i,o);if(i instanceof H&&o instanceof H)return H.fromElements(e(i.x,o.x),e(i.y,o.y),Rn.getCartesian2());if(i instanceof m&&o instanceof m)return m.fromElements(e(i.x,o.x),e(i.y,o.y),e(i.z,o.z),Rn.getCartesian3());if(i instanceof re&&o instanceof re)return re.fromElements(e(i.x,o.x),e(i.y,o.y),e(i.z,o.z),e(i.w,o.w),Rn.getCartesian4());throw new de(`Function "${n}" requires vector or number arguments of matching types. Arguments are ${i} and ${o}.`)}}function ete(e,t){return function(n,i,o,r){if(t&&typeof r=="number"){if(typeof i=="number"&&typeof o=="number")return e(i,o,r);if(i instanceof H&&o instanceof H)return H.fromElements(e(i.x,o.x,r),e(i.y,o.y,r),Rn.getCartesian2());if(i instanceof m&&o instanceof m)return m.fromElements(e(i.x,o.x,r),e(i.y,o.y,r),e(i.z,o.z,r),Rn.getCartesian3());if(i instanceof re&&o instanceof re)return re.fromElements(e(i.x,o.x,r),e(i.y,o.y,r),e(i.z,o.z,r),e(i.w,o.w,r),Rn.getCartesian4())}if(typeof i=="number"&&typeof o=="number"&&typeof r=="number")return e(i,o,r);if(i instanceof H&&o instanceof H&&r instanceof H)return H.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y),Rn.getCartesian2());if(i instanceof m&&o instanceof m&&r instanceof m)return m.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y),e(i.z,o.z,r.z),Rn.getCartesian3());if(i instanceof re&&o instanceof re&&r instanceof re)return re.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y),e(i.z,o.z,r.z),e(i.w,o.w,r.w),Rn.getCartesian4());throw new de(`Function "${n}" requires vector or number arguments of matching types. Arguments are ${i}, ${o}, and ${r}.`)}}function q1e(e,t){if(typeof t=="number")return Math.abs(t);if(t instanceof H)return H.magnitude(t);if(t instanceof m)return m.magnitude(t);if(t instanceof re)return re.magnitude(t);throw new de(`Function "${e}" requires a vector or number argument. Argument is ${t}.`)}function X1e(e,t){if(typeof t=="number")return 1;if(t instanceof H)return H.normalize(t,Rn.getCartesian2());if(t instanceof m)return m.normalize(t,Rn.getCartesian3());if(t instanceof re)return re.normalize(t,Rn.getCartesian4());throw new de(`Function "${e}" requires a vector or number argument. Argument is ${t}.`)}function K1e(e,t,n){if(typeof t=="number"&&typeof n=="number")return Math.abs(t-n);if(t instanceof H
{
czm_non_pick_main();
out_FragColor = ${o};
}
`,e._spPick=Jt.fromCache({context:t,vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:i});return}let a=n.getVertexShaderCallback(!1,"a_batchId",void 0)(bT),c=n.getFragmentShaderCallback(!1,void 0,!0)(ig);o=n.getPickId();let l=new He({sources:[a]}),f=new He({defines:["VECTOR_TILE"],sources:[c]});e._sp=Jt.fromCache({context:t,vertexShaderSource:l,fragmentShaderSource:f,attributeLocations:i}),l=new He({sources:[bT]}),f=new He({defines:["VECTOR_TILE"],sources:[ig]}),e._spStencil=Jt.fromCache({context:t,vertexShaderSource:l,fragmentShaderSource:f,attributeLocations:i}),c=He.replaceMain(c,"czm_non_pick_main"),c=`${c}
void main()
{
czm_non_pick_main();
out_FragColor = ${o};
}
`;let d=new He({sources:[a]}),p=new He({defines:["VECTOR_TILE"],sources:[c]});e._spPick=Jt.fromCache({context:t,vertexShaderSource:d,fragmentShaderSource:p,attributeLocations:i})}function rte(e){let t=e?zn.EQUAL:zn.ALWAYS;return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:t,frontOperation:{fail:ft.KEEP,zFail:ft.DECREMENT_WRAP,zPass:ft.KEEP},backFunction:t,backOperation:{fail:ft.KEEP,zFail:ft.INCREMENT_WRAP,zPass:ft.KEEP},reference:Lt.CESIUM_3D_TILE_MASK,mask:Lt.CESIUM_3D_TILE_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:Ha.LESS_OR_EQUAL},depthMask:!1}}var AOe={stencilTest:{enabled:!0,frontFunction:zn.NOT_EQUAL,frontOperation:{fail:ft.ZERO,zFail:ft.ZERO,zPass:ft.ZERO},backFunction:zn.NOT_EQUAL,backOperation:{fail:ft.ZERO,zFail:ft.ZERO,zPass:ft.ZERO},reference:0,mask:Lt.CLASSIFICATION_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:un.PRE_MULTIPLIED_ALPHA_BLEND},xOe={stencilTest:{enabled:!0,frontFunction:zn.NOT_EQUAL,frontOperation:{fail:ft.ZERO,zFail:ft.ZERO,zPass:ft.ZERO},backFunction:zn.NOT_EQUAL,backOperation:{fail:ft.ZERO,zFail:ft.ZERO,zPass:ft.ZERO},reference:0,mask:Lt.CLASSIFICATION_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1};function COe(e){u(e._rsStencilDepthPass)||(e._rsStencilDepthPass=ke.fromCache(rte(!1)),e._rsStencilDepthPass3DTiles=ke.fromCache(rte(!0)),e._rsColorPass=ke.fromCache(AOe),e._rsPickPass=ke.fromCache(xOe))}var fA=new B,ste=new m;function TOe(e,t){if(u(e._uniformMap))return;let n={u_modifiedModelViewProjection:function(){let i=t.uniformState.view,o=t.uniformState.projection;return B.clone(i,fA),B.multiplyByPoint(fA,e._center,ste),B.setTranslation(fA,ste,fA),B.multiply(o,fA,fA),fA},u_highlightColor:function(){return e._highlightColor}};e._uniformMap=e._batchTable.getUniformMapCallback()(n)}function s5(e,t,n,i,o,r,s){let a=e.constructor.BYTES_PER_ELEMENT,c=r.length;for(let l=0;l<c;++l){let f=r[l],d=s[f],p=i[d],g=o[d],h=new e.constructor(e.buffer,a*p,g);t.set(h,n),i[d]=n,n+=g}return n}function EOe(e,t){let n=e._indices,i=e._indexOffsets,o=e._indexCounts,r=e._batchIdLookUp,s=new n.constructor(n.length),a=t.pop(),c=[a],l=s5(n,s,0,i,o,a.batchIds,r);for(a.offset=0,a.count=l;t.length>0;){let f=t.pop();if(k.equals(f.color,a.color))l=s5(n,s,l,i,o,f.batchIds,r),a.batchIds=a.batchIds.concat(f.batchIds),a.count=l-a.offset;else{let d=l;l=s5(n,s,l,i,o,f.batchIds,r),f.offset=d,f.count=l-d,c.push(f),a=f}}e._va.indexBuffer.copyFromArrayView(s),e._indices=s,e._batchedIndices=c}function a5(e,t,n,i,o,r,s){let a=e.bytesPerIndex,c=r.length;for(let l=0;l<c;++l){let f=r[l],d=s[f],p=i[d],g=o[d];t.copyFromBuffer(e,p*a,n*a,g*a),i[d]=n,n+=g}return n}function bOe(e,t){let n=e._indexOffsets,i=e._indexCounts,o=e._batchIdLookUp,r=t.pop(),s=[r],a=e._va.indexBuffer,c=e._vaSwap.indexBuffer,l=a5(a,c,0,n,i,r.batchIds,o);for(r.offset=0,r.count=l;t.length>0;){let d=t.pop();if(k.equals(d.color,r.color))l=a5(a,c,l,n,i,d.batchIds,o),r.batchIds=r.batchIds.concat(d.batchIds),r.count=l-r.offset;else{let p=l;l=a5(a,c,l,n,i,d.batchIds,o),d.offset=p,d.count=l-p,s.push(d),r=d}}let f=e._va;e._va=e._vaSwap,e._vaSwap=f,e._batchedIndices=s}function SOe(e,t){return t.color.toRgba()-e.color.toRgba()}function vOe(e,t){if(!e._batchDirty)return!1;let n=e._batchedIndices,i=n.length,o=!1,r={};for(let s=0;s<i;++s){let c=n[s].color.toRgba();if(u(r[c])){o=!0;break}else r[c]=!0}if(!o)return e._batchDirty=!1,!1;if(o&&!e.forceRebatch&&e._framesSinceLastRebatch<120){++e._framesSinceLastRebatch;return}return n.sort(SOe),t.webgl2?bOe(e,n):EOe(e,n),e._framesSinceLastRebatch=0,e._batchDirty=!1,e._pickCommandsDirty=!0,e._wireframeDirty=!0,!0}function wOe(e,t){let n=vOe(e,t),i=e._commands,o=e._batchedIndices,r=o.length,s=r*2;if(u(i)&&!n&&i.length===s)return;i.length=s;let a=e._va,c=e._sp,l=y(e._modelMatrix,B.IDENTITY),f=e._uniformMap,d=e._boundingVolume;for(let p=0;p<r;++p){let g=o[p].offset,h=o[p].count,A=i[p*2];u(A)||(A=i[p*2]=new nt({owner:e})),A.vertexArray=a,A.modelMatrix=l,A.offset=g,A.count=h,A.renderState=e._rsStencilDepthPass,A.
${t.message}`);let n=new de(e);return u(t)&&(n.stack=`Original stack:
${t.stack}
Handler stack:
${n.stack}`),n};yg.prototype.isDestroyed=function(){return!1};yg.prototype.destroy=function(){return this.unload(),ue(this)};var io=yg;var OMe={UNLOADED:0,LOADING:1,LOADED:2,PROCESSING:3,READY:4,FAILED:5},St=Object.freeze(OMe);function xp(e){e=y(e,y.EMPTY_OBJECT);let t=e.typedArray,n=e.resource,i=e.cacheKey;this._typedArray=t,this._resource=n,this._cacheKey=i,this._state=St.UNLOADED,this._promise=void 0}u(Object.create)&&(xp.prototype=Object.create(io.prototype),xp.prototype.constructor=xp);Object.defineProperties(xp.prototype,{cacheKey:{get:function(){return this._cacheKey}},typedArray:{get:function(){return this._typedArray}}});xp.prototype.load=async function(){return u(this._promise)?this._promise:u(this._typedArray)?(this._promise=Promise.resolve(this),this._promise):(this._promise=MMe(this),this._promise)};async function MMe(e){let t=e._resource;e._state=St.LOADING;try{let n=await xp._fetchArrayBuffer(t);return e.isDestroyed()?void 0:(e._typedArray=new Uint8Array(n),e._state=St.READY,e)}catch(n){if(e.isDestroyed())return;e._state=St.FAILED;let i=`Failed to load external buffer: ${t.url}`;throw e.getError(i,n)}}xp._fetchArrayBuffer=function(e){return e.fetchArrayBuffer()};xp.prototype.unload=function(){this._typedArray=void 0};var pA=xp;var uWt=function(){"use strict";var e="B9h79tEBBBENQ9gEUEU9gEUB9gBB9gVUUUUUEU9gDUUEU9gLUUUUEU9gVUUUUUB9gLUUUUB9gIUUUEU9gD99UE99I8ayDILEVLEVLOOOOORRVBWWBEdddLVE9wEIIVIEBEOWEUEC+g/KEKR/QIhO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9fw9u9j9v9kw9WwvTw949C919m9mwvBE8f9tw79o9v9wT9fw9u9j9v9kw9WwvTw949C919m9mwv9C9v919u9kBDe9tw79o9v9wT9fw9u9j9v9kw9WwvTw949Wwv79p9v9uBIy9tw79o9v9wT9fw9u9j9v9kw69u9kw949C919m9mwvBL8e9tw79o9v9wT9fw9u9j9v9kw69u9kw949C919m9mwv9C9v919u9kBV8a9tw79o9v9wT9fw9u9j9v9kw69u9kw949Wwv79p9v9uBOe9tw79o9v9wT9fw9u9j9v9kw69u9kw949Twg91w9u9jwBRA9tw79o9v9wT9fw9u9j9v9kw69u9kw949Twg91w9u9jw9C9v919u9kBWl9tw79o9v9wT9fw9u9j9v9kws9p2Twv9P9jTBdk9tw79o9v9wT9fw9u9j9v9kws9p2Twv9R919hTBQl9tw79o9v9wT9fw9u9j9v9kws9p2Twvt949wBKe9tw79o9v9wT9f9v9wT9p9t9p96w9WwvTw94j9h9j9owBpA9tw79o9v9wT9f9v9wT9p9t9p96w9WwvTw94j9h9j9ow9TTv9p9wBSA9tw79o9v9wT9f9v9wT9p9t9p96w9WwvTw94swT9j9o9Sw9t9h9wBZL79iv9rBhdWEBCEKDxcQ+1tyDBK/hKEyU8jJJJJBCJO9rGV8kJJJJBCBHODNALCEFAE0MBABCBrB+Q+KJJBC+gEv86BBAVCJDFCBCJDZ+TJJJB8aDNAItMBAVCJDFADALZmJJJB8aKABAEFHRABCEFHWAVALFCBCBCJDAL9rALCfE0eZ+TJJJB8aAVAVCJDFALZmJJJBHdCJ/ABAL9uHEDNDNALtMBAEC/wfBgGECJDAECJD6eHQCBHKINAKAI9PMEAdCJLFCBCJDZ+TJJJB8aAQAIAK9rAKAQFAI6eGXCSFGECL4CIFCD4HMADAKAL2FHpDNDNDNDNDNAEC9wgGStMBCBHZCEHhApHoAWHaXEKDNAXtMBCBHaCEHhApHcINAdAaFrBBHxAcHECBHOINAdCJLFAOFAErBBGqAx9rGxCETAxCkTCk91CR4786BBAEALFHEAqHxAOCEFGOAX9HMBKARAW9rAM6MIAWCBAMZ+TJJJBGEtMIAEAMFHWAcCEFHcAaCEFGaAL6HhAaAL9HMBXVKKARAW9rAM6MOAWCBAMZ+TJJJB8aCEHEINAWGxAMFHWALAEGOsMLDNARAW9rAM6MBAOCEFHEAWCBAMZ+TJJJB8aAxMEKKCBHWAOAL6MOXIKINDNAXtMBAdAZFrBBHxCBHEAoHOINAdCJLFAEFAOrBBGqAx9rGxCETAxCkTCk91CR4786BBAOALFHOAqHxAECEFGEAX9HMBKKARAa9rAM6MEARAaCBAMZ+TJJJBGlAMFGW9rCk6MDCBHkAdCJLFHcINAdCJLFAkFHyCWH8aCZHaCEHqINDNDNAqCE9HMBCUHOAyrBBMECBHODNINAOGECSsMEAECEFHOAcAEFCEFrBBtMBKKCUCBAECS6eHOXEKAqCETC/+fffEgHOCUAqTCU7CfEgHxCBHEINAOAxAcAEFrBB9NFHOAECEFGECZ9HMBKKAOAaAOAa6GEeHaAqA8aAEeH8aAqCETGqCW6MBKDNDNDNDNA8aCUFpDIEBKAlAkCO4FGEAErBBCDCIA8aCLseAkCI4COgTv86BBA8aCW9HMEAWAy8pBB83BBAWCWFAyCWF8pBB83BBAWCZFHWXDKAlAkCO4FGEAErBBCEAkCI4COgTv86BBKDNCWA8a9tGeMBINAWCB86BBAWCEFHWXBKKCUA8aTCU7HqCBH3AcH5INA5HEAeHxCBHOINAErBBGaAqAaAqCfEgGy6eAOCfEgA8aTvHOAECEFHEAxCUFGxMBKAWAO86BBA5AeFH5AWCEFHWA3AeFG3CZ6MBKCBHEINDNAcAEFrBBGOAy6MBAWAO86BBAWCEFHWKAECEFGECZ9HMBKKDNAkCZFGkAS9PMBAcCZFHcARAW9rCl0MEKKAkAS6MEAWtMEAoCEFHoAZCEFGZAL6HhAWHaAZALsMIXBKKCBHWAhCEgtMEXLKCBHWAhCEgMIKAdApAXCUFAL2FALZmJJJB8aAXAKFHKAWMBKCBHOXDKCBHOARAW9rCAALALCA6e6MEDNALC8f0MBAWCBCAAL9rGEZ+TJJJBAEFHWKAWAdCJDFALZmJJJBALFAB9rHOXEKCBHOKAVCJOF8kJJJJBAOK9HEEUAECAAECA0eABCJ/ABAE9uC/wfBgGDCJDADCJD6eGDFCUFAD9uAE2ADCL4CIFCD4ADv2FCEFKMBCBABbD+Q+KJJBK/YSE3U8jJJJJBC/AE9rGL8kJJJJBCBHVDNAICI9uGOChFAE0MBABCBYDn+KJJBGVC/gEv86BBALC/ABFCfECJEZ+TJJJB8aALCuFGR9CU83IBALC8wFGW9CU83IBALCYFGd9CU83IBALCAFGQ9CU83IBALCkFGK9CU83IBALCZFGX9CU83IBAL9CU83IWAL9CU83IBABAEFC9wFHMABCEFGpAOFHEDNAItMBCMCSAVCB9K
${n.message}`);let o=new de(i);return u(n)&&(o.stack=`Original stack:
${n.stack}
Handler stack:
${o.stack}`),o};Za.getNodeTransform=function(e){return u(e.matrix)?e.matrix:B.fromTranslationQuaternionRotationScale(u(e.translation)?e.translation:m.ZERO,u(e.rotation)?e.rotation:Ne.IDENTITY,u(e.scale)?e.scale:m.ONE)};Za.getAttributeBySemantic=function(e,t,n){let i=e.attributes,o=i.length;for(let r=0;r<o;++r){let s=i[r],a=u(n)?s.setIndex===n:!0;if(s.semantic===t&&a)return s}};Za.getAttributeByName=function(e,t){let n=e.attributes,i=n.length;for(let o=0;o<i;++o){let r=n[o];if(r.name===t)return r}};Za.getFeatureIdsByLabel=function(e,t){for(let n=0;n<e.length;n++){let i=e[n];if(i.positionalLabel===t||i.label===t)return i}};Za.hasQuantizedAttributes=function(e){if(!u(e))return!1;for(let t=0;t<e.length;t++){let n=e[t];if(u(n.quantization))return!0}return!1};Za.getAttributeInfo=function(e){let t=e.semantic,n=e.setIndex,i,o=!1;u(t)?(i=Tt.getVariableName(t,n),o=!0):(i=e.name,i=i.replace(/^_/,""),i=i.toLowerCase());let r=/^color_\d+$/.test(i),s=e.type,a=an.getGlslType(s);r&&(a="vec4");let c=u(e.quantization),l;return c&&(l=r?"vec4":an.getGlslType(e.quantization.type)),{attribute:e,isQuantized:c,variableName:i,hasSemantic:o,glslType:a,quantizedGlslType:l}};var qLe=new m,XLe=new m;Za.getPositionMinMax=function(e,t,n){let i=Za.getAttributeBySemantic(e,"POSITION"),o=i.max,r=i.min;return u(n)&&u(t)&&(r=m.add(r,t,XLe),o=m.add(o,n,qLe)),{min:r,max:o}};Za.getAxisCorrectionMatrix=function(e,t,n){return n=B.clone(B.IDENTITY,n),e===lo.Y?n=B.clone(lo.Y_UP_TO_Z_UP,n):e===lo.X&&(n=B.clone(lo.X_UP_TO_Z_UP,n)),t===lo.Z&&(n=B.multiplyTransformation(n,lo.Z_UP_TO_X_UP,n)),n};var KLe=new Z;Za.getCullFace=function(e,t){if(!Le.isTriangles(t))return _i.BACK;let n=B.getMatrix3(e,KLe);return Z.determinant(n)<0?_i.FRONT:_i.BACK};Za.sanitizeGlslIdentifier=function(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g,"_");return t=t.replace(/^gl_/,""),/^\d/.test(t)&&(t=`_${t}`),t};Za.supportedExtensions={AGI_articulations:!0,CESIUM_primitive_outline:!0,CESIUM_RTC:!0,EXT_feature_metadata:!0,EXT_instance_features:!0,EXT_mesh_features:!0,EXT_mesh_gpu_instancing:!0,EXT_meshopt_compression:!0,EXT_structural_metadata:!0,EXT_texture_webp:!0,KHR_blend:!0,KHR_draco_mesh_compression:!0,KHR_techniques_webgl:!0,KHR_materials_common:!0,KHR_materials_pbrSpecularGlossiness:!0,KHR_materials_unlit:!0,KHR_mesh_quantization:!0,KHR_texture_basisu:!0,KHR_texture_transform:!0,WEB3D_quantized_attributes:!0};Za.checkSupportedExtensions=function(e){let t=e.length;for(let n=0;n<t;n++){let i=e[n];if(!Za.supportedExtensions[i])throw new de(`Unsupported glTF Extension: ${i}`)}};var Qt=Za;var kT={TRANSLATION:"TRANSLATION",ROTATION:"ROTATION",SCALE:"SCALE",FEATURE_ID:"_FEATURE_ID"};kT.fromGltfSemantic=function(e){let t=e,i=/^(\w+)_\d+$/.exec(e);switch(i!==null&&(t=i[1]),t){case"TRANSLATION":return kT.TRANSLATION;case"ROTATION":return kT.ROTATION;case"SCALE":return kT.SCALE;case"_FEATURE_ID":return kT.FEATURE_ID}};var jr=Object.freeze(kT);var JLe=65534,ZLe=255;function LU(e){e=y(e,y.EMPTY_OBJECT);let t=e.triangleIndices,n=e.outlineIndices,i=e.originalVertexCount;this._triangleIndices=t,this._originalVertexCount=i,this._edges=new xne(n,i),this._outlineCoordinatesTypedArray=void 0,this._extraVertices=[],QLe(this)}Object.defineProperties(LU.prototype,{updatedTriangleIndices:{get:function(){return this._triangleIndices}},outlineCoordinates:{get:function(){return this._outlineCoordinatesTypedArray}}});function QLe(e){let t=e._triangleIndices,n=e._edges,i=[],o=e._extraVertices,r=e._originalVertexCount,s={};for(let a=0;a<t.length;a+=3){let c=t[a],l=t[a+1],f=t[a+2],d=!1,p=d||n.hasEdge(c,l),g=d||n.hasEdge(l,f),h=d||n.hasEdge(f,c),A=yne(i,c,l,f,p,g,h);for(;u(A);){let x=s[A];if(!u(x)){x=r+o.length;let C=A;for(;C>=r;)C=o[C-r];o.push(C),s[A]=x}x>JLe&&(t instanceof Uint16Array||t instanceof Uint8Array)?t=new Uint32Array(t):x>ZLe&&t instanceof Uint8Array&&(t=new Uint16Array(t)),A===c?(c=x,t[a]=x):A===l?(l=x,t[a+1]=x):(f=x,t[a+2]=x),A=yne(i,c,l,f,p,g,h)}}e._triangleIndices=t,e._outlineCoordinatesTypedArray=new Float32Array(i)}function yne(e,t,n,i,o,r,s){let a=s?1:0,c=o?1:0,l=0,f=P5(e,t,a,c,l);if(f===0)return t;let d
Unsupported glTF version: ${i}`)}let o=n.extensionsRequired;return u(o)&&(Qt.checkSupportedExtensions(o),e._hasKhrMeshQuantization=o.includes("KHR_mesh_quantization")),e._state=Mo.LOADED,e._textureState=Mo.LOADED,e}catch(t){if(e.isDestroyed())return;e._state=Mo.FAILED,e._textureState=Mo.FAILED,FU(e,t)}}async function wNe(e,t){kt.supportsWebP.initialized||await kt.supportsWebP.initialize();let n=new QP({webp:kt.supportsWebP(),basis:t.context.supportsBasis}),i=e.gltfJson,o=bFe(e,i,n,t);return e._state=Mo.PROCESSING,e._textureState=Mo.PROCESSING,u(e._gltfJsonLoader)&&e._releaseGltfJson&&(Li.unload(e._gltfJsonLoader),e._gltfJsonLoader=void 0),o}xd.prototype.load=async function(){return u(this._promise)?this._promise:(this._promise=vNe(this),this._promise)};function FU(e,t){e.unload();let n="Failed to load glTF";throw e.getError(n,t)}function DNe(e,t){let n,i=!0,o=e._geometryLoaders,r=o.length;for(n=0;n<r;++n){let a=o[n].process(t);a&&u(e._geometryCallbacks[n])&&(e._geometryCallbacks[n](),e._geometryCallbacks[n]=void 0),i=i&&a}let s=e._structuralMetadataLoader;if(u(s)){let a=s.process(t);a&&(e._components.structuralMetadata=s.structuralMetadata),i=i&&a}i&&(e._state=Mo.POST_PROCESSING)}function INe(e,t){let n=e._primitiveLoadPlans,i=n.length;for(let o=0;o<i;o++){let r=n[o];r.postProcess(t),r.needsOutlines&&PNe(e,r)}}function PNe(e,t){let n=e._postProcessBuffers,i=t.primitive,o=i.outlineCoordinates;u(o)&&n.push(o.buffer);let r=i.attributes,s=r.length;for(let c=0;c<s;c++){let l=r[c];u(l.buffer)&&n.push(l.buffer)}let a=i.indices;u(a)&&u(a.buffer)&&n.push(a.buffer)}xd.prototype._process=function(e){return this._state===Mo.READY?!0:(this._state===Mo.PROCESSING&&DNe(this,e),this._resourcesLoaded&&this._state===Mo.POST_PROCESSING&&(INe(this,e.context),this._state=Mo.PROCESSED),this._resourcesLoaded&&this._state===Mo.PROCESSED?(Rne(this),this._typedArray=void 0,this._state=Mo.READY,!0):!1)};xd.prototype._processTextures=function(e){if(this._textureState===Mo.READY)return!0;if(this._textureState!==Mo.PROCESSING)return!1;let t,n=!0,i=this._textureLoaders,o=i.length;for(t=0;t<o;++t){let r=i[t].process(e);r&&u(this._textureCallbacks[t])&&(this._textureCallbacks[t](),this._textureCallbacks[t]=void 0),n=n&&r}return n?(this._textureState=Mo.READY,this._texturesLoaded=!0,!0):!1};xd.prototype.process=function(e){if(this._state===Mo.LOADED&&!u(this._loadResourcesPromise)&&(this._loadResourcesPromise=wNe(this,e).then(()=>{this._resourcesLoaded=!0}).catch(o=>{this._processError=o})),u(this._processError)){this._state=Mo.FAILED;let o=this._processError;this._processError=void 0,FU(this,o)}let t=this._textureErrors.pop();if(u(t)){let o=this.getError("Failed to load glTF texture",t);throw o.name="TextureError",o}if(this._state===Mo.FAILED)return!1;let n=!1;try{n=this._process(e)}catch(o){this._state=Mo.FAILED,FU(this,o)}let i=!1;try{i=this._processTextures(e)}catch(o){this._textureState=Mo.FAILED,FU(this,o)}return this._incrementallyLoadTextures?n:n&&i};function ONe(e,t,n,i,o,r,s,a){let l=t.accessors[n].bufferView;return Li.getVertexBufferLoader({gltf:t,gltfResource:e._gltfResource,baseResource:e._baseResource,frameState:a,bufferViewId:l,draco:o,attributeSemantic:i,accessorId:n,asynchronous:e._asynchronous,loadBuffer:r,loadTypedArray:s})}function MNe(e,t,n,i,o,r,s){return Li.getIndexBufferLoader({gltf:t,accessorId:n,gltfResource:e._gltfResource,baseResource:e._baseResource,frameState:s,draco:i,asynchronous:e._asynchronous,loadBuffer:o,loadTypedArray:r})}function RNe(e,t,n){let i=Li.getBufferViewLoader({gltf:t,bufferViewId:n,gltfResource:e._gltfResource,baseResource:e._baseResource});return e._bufferViewLoaders.push(i),i}function Sne(e,t,n){let i=t.byteOffset,o=pl(e,t),r=t.count,s=$l(t.type),a=t.componentType,c=X.getSizeInBytes(a),l=c*s,f=r*s;if(o===l)return n=new Uint8Array(n),X.createArrayBufferView(a,n.buffer,n.byteOffset+i,f);let d=X.createTypedArray(a,f),p=new DataView(n.buffer),g=new Array(s),h=Ep(t.componentType);i=n.byteOffset+i;for(let A=0;A<r;++A){h(p,i,s,c,g);for(let x=0;x<s;++x)d[A*s+x]=g[x];i+=o}return d}function BNe(e,t){let n=e.type;i
uniform sampler2D u_pointCloud_depthGBuffer;
uniform vec2 u_distanceAndEdlStrength;
in vec2 v_textureCoordinates;
vec2 neighborContribution(float log2Depth, vec2 offset)
{
float dist = u_distanceAndEdlStrength.x;
vec2 texCoordOrig = v_textureCoordinates + offset * dist;
vec2 texCoord0 = v_textureCoordinates + offset * floor(dist);
vec2 texCoord1 = v_textureCoordinates + offset * ceil(dist);
float depthOrLogDepth0 = czm_unpackDepth(texture(u_pointCloud_depthGBuffer, texCoord0));
float depthOrLogDepth1 = czm_unpackDepth(texture(u_pointCloud_depthGBuffer, texCoord1));
// ignore depth values that are the clear depth
if (depthOrLogDepth0 == 0.0 || depthOrLogDepth1 == 0.0) {
return vec2(0.0);
}
// interpolate the two adjacent depth values
float depthMix = mix(depthOrLogDepth0, depthOrLogDepth1, fract(dist));
vec4 eyeCoordinate = czm_windowToEyeCoordinates(texCoordOrig, depthMix);
return vec2(max(0.0, log2Depth - log2(-eyeCoordinate.z / eyeCoordinate.w)), 1.0);
}
void main()
{
float depthOrLogDepth = czm_unpackDepth(texture(u_pointCloud_depthGBuffer, v_textureCoordinates));
vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, depthOrLogDepth);
eyeCoordinate /= eyeCoordinate.w;
float log2Depth = log2(-eyeCoordinate.z);
if (depthOrLogDepth == 0.0) // 0.0 is the clear value for the gbuffer
{
discard;
}
vec4 color = texture(u_pointCloud_colorGBuffer, v_textureCoordinates);
// sample from neighbors left, right, down, up
vec2 texelSize = 1.0 / czm_viewport.zw;
vec2 responseAndCount = vec2(0.0);
responseAndCount += neighborContribution(log2Depth, vec2(-texelSize.x, 0.0));
responseAndCount += neighborContribution(log2Depth, vec2(+texelSize.x, 0.0));
responseAndCount += neighborContribution(log2Depth, vec2(0.0, -texelSize.y));
responseAndCount += neighborContribution(log2Depth, vec2(0.0, +texelSize.y));
float response = responseAndCount.x / responseAndCount.y;
float strength = u_distanceAndEdlStrength.y;
float shade = exp(-response * 300.0 * strength);
color.rgb *= shade;
out_FragColor = vec4(color);
// Input and output depth are the same.
gl_FragDepth = depthOrLogDepth;
}
`;function HT(){this._framebuffer=new mi({colorAttachmentsLength:2,depth:!0,supportsDepthTexture:!0}),this._drawCommand=void 0,this._clearCommand=void 0,this._strength=1,this._radius=1}Object.defineProperties(HT.prototype,{framebuffer:{get:function(){return this._framebuffer.framebuffer}},colorGBuffer:{get:function(){return this._framebuffer.getColorTexture(0)}},depthGBuffer:{get:function(){return this._framebuffer.getColorTexture(1)}}});function IFe(e){e._framebuffer.destroy(),e._drawCommand=void 0,e._clearCommand=void 0}var B5=new H;function PFe(e,t){let n=new He({defines:["LOG_DEPTH_WRITE"],sources:[t1]}),i={u_pointCloud_colorGBuffer:function(){return e.colorGBuffer},u_pointCloud_depthGBuffer:function(){return e.depthGBuffer},u_distanceAndEdlStrength:function(){return B5.x=e._radius,B5.y=e._strength,B5}},o=ke.fromCache({blending:un.ALPHA_BLEND,depthMask:!0,depthTest:{enabled:!0},stencilTest:Lt.setCesium3DTileBit(),stencilMask:Lt.CESIUM_3D_TILE_MASK});e._drawCommand=t.createViewportQuadCommand(n,{uniformMap:i,renderState:o,pass:be.CESIUM_3D_TILE,owner:e}),e._clearCommand=new li({framebuffer:e.framebuffer,color:new k(0,0,0,0),depth:1,renderState:ke.fromCache(),pass:be.CESIUM_3D_TILE,owner:e})}function OFe(e,t){let n=t.drawingBufferWidth,i=t.drawingBufferHeight;e._framebuffer.update(t,n,i),PFe(e,t)}function Bne(e){return e.drawBuffers&&e.fragmentDepth}HT.isSupported=Bne;function MFe(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"EC");if(!u(n)){let i=t._attributeLocations,o=t.fragmentShaderSource.clone();o.sources.splice(0,0,`layout (location = 0) out vec4 out_FragData_0;
layout (location = 1) out vec4 out_FragData_1;`),o.sources=o.sources.map(function(r){return r=He.replaceMain(r,"czm_point_cloud_post_process_main"),r=r.replaceAll(/out_FragColor/g,"out_FragData_0"),r}),o.sources.push(`void main()
{
czm_point_cloud_post_process_main();
#ifdef LOG_DEPTH
czm_writeLogDepth();
out_FragData_1 = czm_packDepth(gl_FragDepth);
#else
out_FragData_1 = czm_packDepth(gl_FragCoord.z);
#endif
}`),n=e.shaderCache.createDerivedShaderProgram(t,"EC",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:o,attributeLocations:i})}return n}HT.prototype.update=function(e,t,n,i){if(!Bne(e.context))return;this._strength=n.eyeDomeLightingStrength,this._radius=n.eyeDomeLightingRadius*e.pixelRatio,OFe(this,e.context);let o,r=e.commandList,s=r.length;for(o=t;o<s;++o){let l=r[o];if(l.primitiveType!==Le.POINTS||l.pass===be.TRANSLUCENT)continue;let f,d,p=l.derivedCommands.pointCloudProcessor;u(p)&&(f=p.command,d=p.originalShaderProgram),(!u(f)||l.dirty||d!==l.shaderProgram||f.framebuffer!==this.framebuffer)&&(f=nt.shallowClone(l,f),f.framebuffer=this.framebuffer,f.shaderProgram=MFe(e.context,l.shaderProgram),f.castShadows=!1,f.receiveShadows=!1,u(p)||(p={command:f,originalShaderProgram:l.shaderProgram},l.derivedCommands.pointCloudProcessor=p),p.originalShaderProgram=l.shaderProgram),r[o]=f}let a=this._clearCommand,c=this._drawCommand;c.boundingVolume=i,r.push(c),r.push(a)};HT.prototype.isDestroyed=function(){return!1};HT.prototype.destroy=function(){return IFe(this),ue(this)};var vp=HT;function Lne(e){let t=y(e,{});this.attenuation=y(t.attenuation,!1),this.geometricErrorScale=y(t.geometricErrorScale,1),this.maximumAttenuation=t.maximumAttenuation,this.baseResolution=t.baseResolution,this.eyeDomeLighting=y(t.eyeDomeLighting,!0),this.eyeDomeLightingStrength=y(t.eyeDomeLightingStrength,1),this.eyeDomeLightingRadius=y(t.eyeDomeLightingRadius,1),this.backFaceCulling=y(t.backFaceCulling,!1),this.normalShading=y(t.normalShading,!0)}Lne.isSupported=function(e){return vp.isSupported(e.context)};var km=Lne;var Aa={},RFe=new re(0,0,0,1),Qa=new re,BFe=new qe,L5=new H,N5=new H;Aa.wgs84ToWindowCoordinates=function(e,t,n){return Aa.wgs84WithEyeOffsetToWindowCoordinates(e,t,m.ZERO,n)};var Nne=new re,Fne=new m;function n1(e,t,n,i){let o=n.viewMatrix,r=B.multiplyByVector(o,re.fromElements(e.x,e.y,e.z,1,Nne),Nne),s=m.multiplyComponents(t,m.normalize(r,Fne),Fne);return r.x+=t.x+s.x,r.y+=t.y+s.y,r.z+=s.z,B.multiplyByVector(n.frustum.projectionMatrix,r,i)}var LFe=new he(Math.PI,P.PI_OVER_TWO),NFe=new m,FFe=new m;Aa.wgs84WithEyeOffsetToWindowCoordinates=function(e,t,n,i){let o=e.frameState,r=Aa.computeActualWgs84Position(o,t,RFe);if(!u(r))return;let s=e.canvas,a=BFe;a.x=0,a.y=0,a.width=s.clientWidth,a.height=s.clientHeight;let c=e.camera,l=!1;if(o.mode===ne.SCENE2D){let f=e.mapProjection,d=LFe,p=f.project(d,NFe),g=m.clone(c.position,FFe),h=c.frustum.clone(),A=B.computeViewportTransformation(a,0,1,new B),x=c.frustum.projectionMatrix,C=c.positionWC.y,T=m.fromElements(P.sign(C)*p.x-C,0,-c.positionWC.x),E=Ot.pointToGLWindowCoordinates(x,A,T);if(C===0||E.x<=0||E.x>=s.clientWidth)l=!0;else{if(E.x>s.clientWidth*.5){a.width=E.x,c.frustum.right=p.x-C,Qa=n1(r,n,c,Qa),Aa.clipToGLWindowCoordinates(a,Qa,L5),a.x+=E.x,c.position.x=-c.position.x;let S=c.frustum.right;c.frustum.right=-c.frustum.left,c.frustum.left=-S,Qa=n1(r,n,c,Qa),Aa.clipToGLWindowCoordinates(a,Qa,N5)}else{a.x+=E.x,a.width-=E.x,c.frustum.left=-p.x-C,Qa=n1(r,n,c,Qa),Aa.clipToGLWindowCoordinates(a,Qa,L5),a.x=a.x-a.width,c.position.x=-c.position.x;let S=c.frustum.left;c.frustum.left=-c.frustum.right,c.frustum.right=-S,Qa=n1(r,n,c,Qa),Aa.clipToGLWindowCoordinates(a,Qa,N5)}m.clone(g,c.position),c.frustum=h.clone(),i=H.clone(L5,i),(i.x<0||i.x>s.clientWidth)&&(i.x=N5.x)}}if(o.mode!==ne.SCENE2D||l){if(Qa=n1(r,n,c,Qa),Qa.z<0&&!(c.frustum instanceof nn)&&!(c.frustum instanceof br))return;i=Aa.clipToGLWindowCoordinates(a,Qa,i)}return i.y=s.clientHeight-i.y,i};Aa.wgs84ToDrawingBufferCoordinates=function(e,t,n){if(n=Aa.wgs84ToWindowCoordinates(e,t,n),!!u(n))return Aa.transformWindowToDrawingBuffer(e,n,n)};var wp=new m,UFe=new he;Aa.computeActualWgs84Position=function(e,t,n){let i=e.mode;if(i===ne.SCENE3D)return m.clone(t,n);let o=e.mapProjection,r=o.ellipsoid.cartesianToCartographic(t,UFe);if(!u(r))return;if(o.project(r,wp),i===ne.COLUMBUS_VIEW)return m.fromElements(wp.z,wp.x,wp.y,n);if(i===ne.SCENE2D)return m.fromElements(0,wp.x,wp.y,n);let s=e.morphTime;return m.fromElements(P.lerp(wp.z,t.x,s),P.ler
#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif
#endif
czm_modelMaterial defaultModelMaterial()
{
czm_modelMaterial material;
material.diffuse = vec3(0.0);
material.specular = vec3(1.0);
material.roughness = 1.0;
material.occlusion = 1.0;
material.normalEC = vec3(0.0, 0.0, 1.0);
material.emissive = vec3(0.0);
material.alpha = 1.0;
return material;
}
vec4 handleAlpha(vec3 color, float alpha)
{
#ifdef ALPHA_MODE_MASK
if (alpha < u_alphaCutoff) {
discard;
}
#endif
return vec4(color, alpha);
}
SelectedFeature selectedFeature;
void main()
{
#ifdef HAS_MODEL_SPLITTER
modelSplitterStage();
#endif
czm_modelMaterial material = defaultModelMaterial();
ProcessedAttributes attributes;
geometryStage(attributes);
FeatureIds featureIds;
featureIdStage(featureIds, attributes);
Metadata metadata;
MetadataClass metadataClass;
MetadataStatistics metadataStatistics;
metadataStage(metadata, metadataClass, metadataStatistics, attributes);
#ifdef HAS_SELECTED_FEATURE_ID
selectedFeatureIdStage(selectedFeature, featureIds);
#endif
#ifndef CUSTOM_SHADER_REPLACE_MATERIAL
materialStage(material, attributes, selectedFeature);
#endif
#ifdef HAS_CUSTOM_FRAGMENT_SHADER
customShaderStage(material, attributes, featureIds, metadata, metadataClass, metadataStatistics);
#endif
lightingStage(material, attributes);
#ifdef HAS_SELECTED_FEATURE_ID
cpuStylingStage(material, selectedFeature);
#endif
#ifdef HAS_MODEL_COLOR
modelColorStage(material);
#endif
#ifdef HAS_PRIMITIVE_OUTLINE
primitiveOutlineStage(material);
#endif
vec4 color = handleAlpha(material.diffuse, material.alpha);
#ifdef HAS_CLIPPING_PLANES
modelClippingPlanesStage(color);
#endif
#if defined(HAS_SILHOUETTE) && defined(HAS_NORMALS)
silhouetteStage(color);
#endif
out_FragColor = color;
}
`;var x1=`precision highp float;
czm_modelVertexOutput defaultVertexOutput(vec3 positionMC) {
czm_modelVertexOutput vsOutput;
vsOutput.positionMC = positionMC;
vsOutput.pointSize = 1.0;
return vsOutput;
}
void main()
{
// Initialize the attributes struct with all
// attributes except quantized ones.
ProcessedAttributes attributes;
initializeAttributes(attributes);
// Dequantize the quantized ones and add them to the
// attributes struct.
#ifdef USE_DEQUANTIZATION
dequantizationStage(attributes);
#endif
#ifdef HAS_MORPH_TARGETS
morphTargetsStage(attributes);
#endif
#ifdef HAS_SKINNING
skinningStage(attributes);
#endif
#ifdef HAS_PRIMITIVE_OUTLINE
primitiveOutlineStage();
#endif
// Compute the bitangent according to the formula in the glTF spec.
// Normal and tangents can be affected by morphing and skinning, so
// the bitangent should not be computed until their values are finalized.
#ifdef HAS_BITANGENTS
attributes.bitangentMC = normalize(cross(attributes.normalMC, attributes.tangentMC) * attributes.tangentSignMC);
#endif
FeatureIds featureIds;
featureIdStage(featureIds, attributes);
#ifdef HAS_SELECTED_FEATURE_ID
SelectedFeature feature;
selectedFeatureIdStage(feature, featureIds);
// Handle any show properties that come from the style.
cpuStylingStage(attributes.positionMC, feature);
#endif
#if defined(USE_2D_POSITIONS) || defined(USE_2D_INSTANCING)
// The scene mode 2D pipeline stage and instancing stage add a different
// model view matrix to accurately project the model to 2D. However, the
// output positions and normals should be transformed by the 3D matrices
// to keep the data the same for the fragment shader.
mat4 modelView = czm_modelView3D;
mat3 normal = czm_normal3D;
#else
// These are used for individual model projection because they will
// automatically change based on the scene mode.
mat4 modelView = czm_modelView;
mat3 normal = czm_normal;
#endif
// Update the position for this instance in place
#ifdef HAS_INSTANCING
// The legacy instance stage is used when rendering i3dm models that
// encode instances transforms in world space, as opposed to glTF models
// that use EXT_mesh_gpu_instancing, where instance transforms are encoded
// in object space.
#ifdef USE_LEGACY_INSTANCING
mat4 instanceModelView;
mat3 instanceModelViewInverseTranspose;
legacyInstancingStage(attributes, instanceModelView, instanceModelViewInverseTranspose);
modelView = instanceModelView;
normal = instanceModelViewInverseTranspose;
#else
instancingStage(attributes);
#endif
#ifdef USE_PICKING
v_pickColor = a_pickColor;
#endif
#endif
Metadata metadata;
MetadataClass metadataClass;
MetadataStatistics metadataStatistics;
metadataStage(metadata, metadataClass, metadataStatistics, attributes);
#ifdef HAS_CUSTOM_VERTEX_SHADER
czm_modelVertexOutput vsOutput = defaultVertexOutput(attributes.positionMC);
customShaderStage(vsOutput, attributes, featureIds, metadata, metadataClass, metadataStatistics);
#endif
// Compute the final position in each coordinate system needed.
// This returns the value that will be assigned to gl_Position.
vec4 positionClip = geometryStage(attributes, modelView, normal);
#ifdef HAS_SILHOUETTE
silhouetteStage(attributes, positionClip);
#endif
#ifdef HAS_POINT_CLOUD_SHOW_STYLE
float show = pointCloudShowStylingStage(attributes, metadata);
#else
float show = 1.0;
#endif
#ifdef HAS_POINT_CLOUD_BACK_FACE_CULLING
show *= pointCloudBackFaceCullingStage();
#endif
#ifdef HAS_POINT_CLOUD_COLOR_STYLE
v_pointCloudColor = pointCloudColorStylingStage(attributes, metadata);
#endif
#ifdef PRIMITIVE_TYPE_POINTS
#ifdef HAS_CUSTOM_VERTEX_SHADER
gl_PointSize = vsOutput.pointSize;
#elif defined(HAS_POINT_CLOUD_POINT_SIZE_STYLE) || defined(HAS_POINT_CLOUD_ATTENUATION)
gl_PointSize = pointCloudPointSizeStylingStage(attributes, metadata);
#else
gl_PointSize = 1.0;
#endif
gl_PointSize *= show;
#endif
gl_Position = show * positionClip;
}
`;function j5(e){e=y(e,y.EMPTY_OBJECT);let t=e.command,n=e.primitiveRenderResources,i=n.model;this._command=t,this._model=i,this._runtimePrimitive=n.runtimePrimitive,this._modelMatrix=t.modelMatrix,this._boundingVolume=t.boundingVolume,this._cullFace=t.renderState.cull.face;let o=i.classificationType;this._classificationType=o,this._classifiesTerrain=o!==kn.CESIUM_3D_TILE,this._classifies3DTiles=o!==kn.TERRAIN,this._useDebugWireframe=i._enableDebugWireframe&&i.debugWireframe,this._pickId=n.pickId,this._commandListTerrain=[],this._commandList3DTiles=[],this._commandListIgnoreShow=[],this._commandListDebugWireframe=[],this._commandListTerrainPicking=[],this._commandList3DTilesPicking=[],R2e(this)}function P2e(e){return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:e,frontOperation:{fail:ft.KEEP,zFail:ft.DECREMENT_WRAP,zPass:ft.KEEP},backFunction:e,backOperation:{fail:ft.KEEP,zFail:ft.INCREMENT_WRAP,zPass:ft.KEEP},reference:Lt.CESIUM_3D_TILE_MASK,mask:Lt.CESIUM_3D_TILE_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:Ha.LESS_OR_EQUAL},depthMask:!1}}var O2e={stencilTest:{enabled:!0,frontFunction:zn.NOT_EQUAL,frontOperation:{fail:ft.ZERO,zFail:ft.ZERO,zPass:ft.ZERO},backFunction:zn.NOT_EQUAL,backOperation:{fail:ft.ZERO,zFail:ft.ZERO,zPass:ft.ZERO},reference:0,mask:Lt.CLASSIFICATION_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:un.PRE_MULTIPLIED_ALPHA_BLEND},M2e={stencilTest:{enabled:!0,frontFunction:zn.NOT_EQUAL,frontOperation:{fail:ft.ZERO,zFail:ft.ZERO,zPass:ft.ZERO},backFunction:zn.NOT_EQUAL,backOperation:{fail:ft.ZERO,zFail:ft.ZERO,zPass:ft.ZERO},reference:0,mask:Lt.CLASSIFICATION_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1},iie=[];function R2e(e){let t=e._command,n=iie;if(e._useDebugWireframe){t.pass=be.OPAQUE,n.length=0,n.push(t),e._commandListDebugWireframe=C1(e,n,e._commandListDebugWireframe);let r=e._commandListDebugWireframe,s=r.length;for(let a=0;a<s;a++){let c=r[a];c.count*=2,c.offset*=2}return}let o=e.model.allowPicking;if(e._classifiesTerrain){let r=be.TERRAIN_CLASSIFICATION,s=W5(t,r),a=tie(t,r);n.length=0,n.push(s,a),e._commandListTerrain=C1(e,n,e._commandListTerrain),o&&(e._commandListTerrainPicking=nie(e,n,e._commandListTerrainPicking))}if(e._classifies3DTiles){let r=be.CESIUM_3D_TILE_CLASSIFICATION,s=W5(t,r),a=tie(t,r);n.length=0,n.push(s,a),e._commandList3DTiles=C1(e,n,e._commandList3DTiles),o&&(e._commandList3DTilesPicking=nie(e,n,e._commandList3DTilesPicking))}}function C1(e,t,n){let i=e._runtimePrimitive,o=i.batchLengths,r=i.batchOffsets,s=o.length,a=t.length;for(let c=0;c<s;c++){let l=o[c],f=r[c];for(let d=0;d<a;d++){let p=t[d],g=nt.shallowClone(p);g.count=l,g.offset=f,n.push(g)}}return n}function W5(e,t){let n=nt.shallowClone(e);n.cull=!1,n.pass=t;let i=t===be.TERRAIN_CLASSIFICATION?zn.ALWAYS:zn.EQUAL,o=P2e(i);return n.renderState=ke.fromCache(o),n}function tie(e,t){let n=nt.shallowClone(e);return n.cull=!1,n.pass=t,n.renderState=ke.fromCache(O2e),n}var B2e=[];function nie(e,t,n){let i=ke.fromCache(M2e),o=t[0],r=t[1],s=nt.shallowClone(o);s.cull=!0,s.pickOnly=!0;let a=nt.shallowClone(r);a.cull=!0,a.pickOnly=!0,a.renderState=i,a.pickId=e._pickId;let c=B2e;return c.length=0,c.push(s,a),C1(e,c,n)}Object.defineProperties(j5.prototype,{command:{get:function(){return this._command}},runtimePrimitive:{get:function(){return this._runtimePrimitive}},batchLengths:{get:function(){return this._runtimePrimitive.batchLengths}},batchOffsets:{get:function(){return this._runtimePrimitive.batchOffsets}},model:{get:function(){return this._model}},classificationType:{get:function(){return this._classificationType}},modelMatrix:{get:function(){return this._modelMatrix},set:function(e){this._modelMatrix=B.clone(e,this._modelMatrix);let t=this._runtimePrimitive.boundingSphere;this._boundingVolume=ae.transform(t,this._modelMatrix,this._boundingVolume)}},boundingVolume:{get:function(){return this._boundingVolume}},cullFace:{get:function(){return this._cullFace},set:function(e){this._cullFace=e}}});j5
vec3 positionEC,
vec3 normalEC,
vec3 lightDirectionEC,
vec3 lightColorHdr,
czm_pbrParameters pbrParameters
) {
vec3 v = -positionEC;
vec3 positionWC = vec3(czm_inverseView * vec4(positionEC, 1.0));
vec3 vWC = -normalize(positionWC);
vec3 l = normalize(lightDirectionEC);
vec3 n = normalEC;
vec3 r = normalize(czm_inverseViewRotation * normalize(reflect(v, n)));
float NdotL = clamp(dot(n, l), 0.001, 1.0);
float NdotV = abs(dot(n, v)) + 0.001;
// Figure out if the reflection vector hits the ellipsoid
float vertexRadius = length(positionWC);
float horizonDotNadir = 1.0 - min(1.0, czm_ellipsoidRadii.x / vertexRadius);
float reflectionDotNadir = dot(r, normalize(positionWC));
// Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z.
r.x = -r.x;
r = -normalize(czm_temeToPseudoFixed * r);
r.x = -r.x;
vec3 diffuseColor = pbrParameters.diffuseColor;
float roughness = pbrParameters.roughness;
vec3 specularColor = pbrParameters.f0;
float inverseRoughness = 1.04 - roughness;
inverseRoughness *= inverseRoughness;
vec3 sceneSkyBox = czm_textureCube(czm_environmentMap, r).rgb * inverseRoughness;
float atmosphereHeight = 0.05;
float blendRegionSize = 0.1 * ((1.0 - inverseRoughness) * 8.0 + 1.1 - horizonDotNadir);
float blendRegionOffset = roughness * -1.0;
float farAboveHorizon = clamp(horizonDotNadir - blendRegionSize * 0.5 + blendRegionOffset, 1.0e-10 - blendRegionSize, 0.99999);
float aroundHorizon = clamp(horizonDotNadir + blendRegionSize * 0.5, 1.0e-10 - blendRegionSize, 0.99999);
float farBelowHorizon = clamp(horizonDotNadir + blendRegionSize * 1.5, 1.0e-10 - blendRegionSize, 0.99999);
float smoothstepHeight = smoothstep(0.0, atmosphereHeight, horizonDotNadir);
vec3 belowHorizonColor = mix(vec3(0.1, 0.15, 0.25), vec3(0.4, 0.7, 0.9), smoothstepHeight);
vec3 nadirColor = belowHorizonColor * 0.5;
vec3 aboveHorizonColor = mix(vec3(0.9, 1.0, 1.2), belowHorizonColor, roughness * 0.5);
vec3 blueSkyColor = mix(vec3(0.18, 0.26, 0.48), aboveHorizonColor, reflectionDotNadir * inverseRoughness * 0.5 + 0.75);
vec3 zenithColor = mix(blueSkyColor, sceneSkyBox, smoothstepHeight);
vec3 blueSkyDiffuseColor = vec3(0.7, 0.85, 0.9);
float diffuseIrradianceFromEarth = (1.0 - horizonDotNadir) * (reflectionDotNadir * 0.25 + 0.75) * smoothstepHeight;
float diffuseIrradianceFromSky = (1.0 - smoothstepHeight) * (1.0 - (reflectionDotNadir * 0.25 + 0.25));
vec3 diffuseIrradiance = blueSkyDiffuseColor * clamp(diffuseIrradianceFromEarth + diffuseIrradianceFromSky, 0.0, 1.0);
float notDistantRough = (1.0 - horizonDotNadir * roughness * 0.8);
vec3 specularIrradiance = mix(zenithColor, aboveHorizonColor, smoothstep(farAboveHorizon, aroundHorizon, reflectionDotNadir) * notDistantRough);
specularIrradiance = mix(specularIrradiance, belowHorizonColor, smoothstep(aroundHorizon, farBelowHorizon, reflectionDotNadir) * inverseRoughness);
specularIrradiance = mix(specularIrradiance, nadirColor, smoothstep(farBelowHorizon, 1.0, reflectionDotNadir) * inverseRoughness);
// Luminance model from page 40 of http://silviojemma.com/public/papers/lighting/spherical-harmonic-lighting.pdf
#ifdef USE_SUN_LUMINANCE
// Angle between sun and zenith
float LdotZenith = clamp(dot(normalize(czm_inverseViewRotation * l), vWC), 0.001, 1.0);
float S = acos(LdotZenith);
// Angle between zenith and current pixel
float NdotZenith = clamp(dot(normalize(czm_inverseViewRotation * n), vWC), 0.001, 1.0);
// Angle between sun and current pixel
float gamma = acos(NdotL);
float numerator = ((0.91 + 10.0 * exp(-3.0 * gamma) + 0.45 * pow(NdotL, 2.0)) * (1.0 - exp(-0.32 / NdotZenith)));
float denominator = (0.91 + 10.0 * exp(-3.0 * S) + 0.45 * pow(LdotZenith,2.0)) * (1.0 - exp(-0.32));
float luminance = model_luminanceAtZenith * (numerator / denominator);
#endif
vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;
vec3 iblColor = (diffuseIrradiance * diffuseColor * model_iblFactor.x) + (specularIrradiance * czm_srgbToLinear(specularColor * brdfLut.x + brdfLut.y) * model_iblFactor.y);
float maximumComponent = max(max(lightColorHdr.x, lightColorHdr.y), lightColorHdr.z);
vec3 lightColor = lightColorHdr / max(maximumComponent, 1.0);
iblColor *= lightColor;
#ifdef USE_SUN_LUMINANCE
iblColor *= luminance;
#endif
return iblColor;
}
#if defined(DIFFUSE_IBL) || defined(SPECULAR_IBL)
vec3 textureIBL(
vec3 positionEC,
vec3 normalEC,
vec3 lightDirectionEC,
czm_pbrParameters pbrParameters
) {
vec3 diffuseColor = pbrParameters.diffuseColor;
float roughness = pbrParameters.roughness;
vec3 specularColor = pbrParameters.f0;
vec3 v = -positionEC;
vec3 n = normalEC;
vec3 l = normalize(lightDirectionEC);
vec3 h = normalize(v + l);
float NdotV = abs(dot(n, v)) + 0.001;
float VdotH = clamp(dot(v, h), 0.0, 1.0);
const mat3 yUpToZUp = mat3(
-1.0, 0.0, 0.0,
0.0, 0.0, -1.0,
0.0, 1.0, 0.0
);
vec3 cubeDir = normalize(yUpToZUp * model_iblReferenceFrameMatrix * normalize(reflect(-v, n)));
#ifdef DIFFUSE_IBL
#ifdef CUSTOM_SPHERICAL_HARMONICS
vec3 diffuseIrradiance = czm_sphericalHarmonics(cubeDir, model_sphericalHarmonicCoefficients);
#else
vec3 diffuseIrradiance = czm_sphericalHarmonics(cubeDir, czm_sphericalHarmonicCoefficients);
#endif
#else
vec3 diffuseIrradiance = vec3(0.0);
#endif
#ifdef SPECULAR_IBL
vec3 r0 = specularColor.rgb;
float reflectance = max(max(r0.r, r0.g), r0.b);
vec3 r90 = vec3(clamp(reflectance * 25.0, 0.0, 1.0));
vec3 F = fresnelSchlick2(r0, r90, VdotH);
vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;
#ifdef CUSTOM_SPECULAR_IBL
vec3 specularIBL = czm_sampleOctahedralProjection(model_specularEnvironmentMaps, model_specularEnvironmentMapsSize, cubeDir, roughness * model_specularEnvironmentMapsMaximumLOD, model_specularEnvironmentMapsMaximumLOD);
#else
vec3 specularIBL = czm_sampleOctahedralProjection(czm_specularEnvironmentMaps, czm_specularEnvironmentMapSize, cubeDir, roughness * czm_specularEnvironmentMapsMaximumLOD, czm_specularEnvironmentMapsMaximumLOD);
#endif
specularIBL *= F * brdfLut.x + brdfLut.y;
#else
vec3 specularIBL = vec3(0.0);
#endif
return diffuseColor * diffuseIrradiance + specularColor * specularIBL;
}
#endif
vec3 imageBasedLightingStage(
vec3 positionEC,
vec3 normalEC,
vec3 lightDirectionEC,
vec3 lightColorHdr,
czm_pbrParameters pbrParameters
) {
#if defined(DIFFUSE_IBL) || defined(SPECULAR_IBL)
// Environment maps were provided, use them for IBL
return textureIBL(
positionEC,
normalEC,
lightDirectionEC,
pbrParameters
);
#else
// Use the procedural IBL if there are no environment maps
return proceduralIBL(
positionEC,
normalEC,
lightDirectionEC,
lightColorHdr,
pbrParameters
);
#endif
}`;var sie={name:"ImageBasedLightingPipelineStage"};sie.process=function(e,t,n){let i=t.imageBasedLighting,o=e.shaderBuilder;o.addDefine("USE_IBL_LIGHTING",void 0,Ee.FRAGMENT),o.addUniform("vec2","model_iblFactor",Ee.FRAGMENT),ud.isSupported(n.context)&&((i.useSphericalHarmonics||i.useSpecularEnvironmentMaps||i.enabled)&&o.addUniform("mat3","model_iblReferenceFrameMatrix",Ee.FRAGMENT),u(i.sphericalHarmonicCoefficients)?(o.addDefine("DIFFUSE_IBL",void 0,Ee.FRAGMENT),o.addDefine("CUSTOM_SPHERICAL_HARMONICS",void 0,Ee.FRAGMENT),o.addUniform("vec3","model_sphericalHarmonicCoefficients[9]",Ee.FRAGMENT)):i.useDefaultSphericalHarmonics&&o.addDefine("DIFFUSE_IBL",void 0,Ee.FRAGMENT),u(i.specularEnvironmentMapAtlas)&&i.specularEnvironmentMapAtlas.ready?(o.addDefine("SPECULAR_IBL",void 0,Ee.FRAGMENT),o.addDefine("CUSTOM_SPECULAR_IBL",void 0,Ee.FRAGMENT),o.addUniform("sampler2D","model_specularEnvironmentMaps",Ee.FRAGMENT),o.addUniform("vec2","model_specularEnvironmentMapsSize",Ee.FRAGMENT),o.addUniform("float","model_specularEnvironmentMapsMaximumLOD",Ee.FRAGMENT)):t.useDefaultSpecularMaps&&o.addDefine("SPECULAR_IBL",void 0,Ee.FRAGMENT)),u(i.luminanceAtZenith)&&(o.addDefine("USE_SUN_LUMINANCE",void 0,Ee.FRAGMENT),o.addUniform("float","model_luminanceAtZenith",Ee.FRAGMENT)),o.addFragmentLines(v1);let r={model_iblFactor:function(){return i.imageBasedLightingFactor},model_iblReferenceFrameMatrix:function(){return t._iblReferenceFrameMatrix},model_luminanceAtZenith:function(){return i.luminanceAtZenith},model_sphericalHarmonicCoefficients:function(){return i.sphericalHarmonicCoefficients},model_specularEnvironmentMaps:function(){return i.specularEnvironmentMapAtlas.texture},model_specularEnvironmentMapsSize:function(){return i.specularEnvironmentMapAtlas.texture.dimensions},model_specularEnvironmentMapsMaximumLOD:function(){return i.specularEnvironmentMapAtlas.maximumMipmapLevel}};e.uniformMap=ht(r,e.uniformMap)};var w1=sie;var Q2e=P.EPSILON16;function q5(e){e=y(e,y.EMPTY_OBJECT);let t=e.stage,n=e.runtimeArticulation;this._stage=t,this._runtimeArticulation=n,this._name=t.name,this._type=t.type,this._minimumValue=t.minimumValue,this._maximumValue=t.maximumValue,this._currentValue=t.initialValue}Object.defineProperties(q5.prototype,{stage:{get:function(){return this._stage}},runtimeArticulation:{get:function(){return this._runtimeArticulation}},name:{get:function(){return this._name}},type:{get:function(){return this._type}},minimumValue:{get:function(){return this._minimumValue}},maximumValue:{get:function(){return this._maximumValue}},currentValue:{get:function(){return this._currentValue},set:function(e){e=P.clamp(e,this.minimumValue,this.maximumValue),P.equalsEpsilon(this._currentValue,e,Q2e)||(this._currentValue=e,this.runtimeArticulation._dirty=!0)}}});var $2e=new m,Y5=new Z;q5.prototype.applyStageToMatrix=function(e){let t=this.type,n=this.currentValue,i=$2e,o;switch(t){case Ka.XROTATE:o=Z.fromRotationX(P.toRadians(n),Y5),e=B.multiplyByMatrix3(e,o,e);break;case Ka.YROTATE:o=Z.fromRotationY(P.toRadians(n),Y5),e=B.multiplyByMatrix3(e,o,e);break;case Ka.ZROTATE:o=Z.fromRotationZ(P.toRadians(n),Y5),e=B.multiplyByMatrix3(e,o,e);break;case Ka.XTRANSLATE:i.x=n,i.y=0,i.z=0,e=B.multiplyByTranslation(e,i,e);break;case Ka.YTRANSLATE:i.x=0,i.y=n,i.z=0,e=B.multiplyByTranslation(e,i,e);break;case Ka.ZTRANSLATE:i.x=0,i.y=0,i.z=n,e=B.multiplyByTranslation(e,i,e);break;case Ka.XSCALE:i.x=n,i.y=1,i.z=1,e=B.multiplyByScale(e,i,e);break;case Ka.YSCALE:i.x=1,i.y=n,i.z=1,e=B.multiplyByScale(e,i,e);break;case Ka.ZSCALE:i.x=1,i.y=1,i.z=n,e=B.multiplyByScale(e,i,e);break;case Ka.UNIFORMSCALE:e=B.multiplyByUniformScale(e,n,e);break;default:break}return e};var D1=q5;function YU(e){e=y(e,y.EMPTY_OBJECT);let t=e.articulation,n=e.sceneGraph;this._articulation=t,this._sceneGraph=n,this._name=t.name,this._runtimeStages=[],this._runtimeStagesByName={},this._runtimeNodes=[],this._dirty=!0,e3e(this)}Object.defineProperties(YU.prototype,{articulation:{get:function(){return this._articulation}},sceneGraph:{get:function(){return this._sceneGraph}},name:{get:function
{
material.diffuse = mix(material.diffuse, model_color.rgb, model_colorBlend);
float highlight = ceil(model_colorBlend);
material.diffuse *= mix(model_color.rgb, vec3(1.0), highlight);
material.alpha *= model_color.a;
}`;var $T={name:"ModelColorPipelineStage",COLOR_UNIFORM_NAME:"model_color",COLOR_BLEND_UNIFORM_NAME:"model_colorBlend"};$T.process=function(e,t,n){let i=e.shaderBuilder;i.addDefine("HAS_MODEL_COLOR",void 0,Ee.FRAGMENT),i.addFragmentLines(P1);let o={},r=t.color;r.alpha===0&&!t.hasSilhouette(n)&&(e.renderStateOptions.colorMask={red:!1,green:!1,blue:!1,alpha:!1}),r.alpha<1&&(e.alphaOptions.pass=be.TRANSLUCENT),i.addUniform("vec4",$T.COLOR_UNIFORM_NAME,Ee.FRAGMENT),o[$T.COLOR_UNIFORM_NAME]=function(){return t.color},i.addUniform("float",$T.COLOR_BLEND_UNIFORM_NAME,Ee.FRAGMENT),o[$T.COLOR_BLEND_UNIFORM_NAME]=function(){return Xa.getColorBlend(t.colorBlendMode,t.colorBlendAmount)},e.uniformMap=ht(o,e.uniformMap)};var Bg=$T;var O1=`#ifdef USE_CLIPPING_PLANES_FLOAT_TEXTURE
vec4 getClippingPlane(
highp sampler2D packedClippingPlanes,
int clippingPlaneNumber,
mat4 transform
) {
int pixY = clippingPlaneNumber / CLIPPING_PLANES_TEXTURE_WIDTH;
int pixX = clippingPlaneNumber - (pixY * CLIPPING_PLANES_TEXTURE_WIDTH);
float pixelWidth = 1.0 / float(CLIPPING_PLANES_TEXTURE_WIDTH);
float pixelHeight = 1.0 / float(CLIPPING_PLANES_TEXTURE_HEIGHT);
float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
float v = (float(pixY) + 0.5) * pixelHeight;
vec4 plane = texture(packedClippingPlanes, vec2(u, v));
return czm_transformPlane(plane, transform);
}
#else
// Handle uint8 clipping texture instead
vec4 getClippingPlane(
highp sampler2D packedClippingPlanes,
int clippingPlaneNumber,
mat4 transform
) {
int clippingPlaneStartIndex = clippingPlaneNumber * 2; // clipping planes are two pixels each
int pixY = clippingPlaneStartIndex / CLIPPING_PLANES_TEXTURE_WIDTH;
int pixX = clippingPlaneStartIndex - (pixY * CLIPPING_PLANES_TEXTURE_WIDTH);
float pixelWidth = 1.0 / float(CLIPPING_PLANES_TEXTURE_WIDTH);
float pixelHeight = 1.0 / float(CLIPPING_PLANES_TEXTURE_HEIGHT);
float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
float v = (float(pixY) + 0.5) * pixelHeight;
vec4 oct32 = texture(packedClippingPlanes, vec2(u, v)) * 255.0;
vec2 oct = vec2(oct32.x * 256.0 + oct32.y, oct32.z * 256.0 + oct32.w);
vec4 plane;
plane.xyz = czm_octDecode(oct, 65535.0);
plane.w = czm_unpackFloat(texture(packedClippingPlanes, vec2(u + pixelWidth, v)));
return czm_transformPlane(plane, transform);
}
#endif
float clip(vec4 fragCoord, sampler2D clippingPlanes, mat4 clippingPlanesMatrix) {
vec4 position = czm_windowToEyeCoordinates(fragCoord);
vec3 clipNormal = vec3(0.0);
vec3 clipPosition = vec3(0.0);
float pixelWidth = czm_metersPerPixel(position);
#ifdef UNION_CLIPPING_REGIONS
float clipAmount; // For union planes, we want to get the min distance. So we set the initial value to the first plane distance in the loop below.
#else
float clipAmount = 0.0;
bool clipped = true;
#endif
for (int i = 0; i < CLIPPING_PLANES_LENGTH; ++i) {
vec4 clippingPlane = getClippingPlane(clippingPlanes, i, clippingPlanesMatrix);
clipNormal = clippingPlane.xyz;
clipPosition = -clippingPlane.w * clipNormal;
float amount = dot(clipNormal, (position.xyz - clipPosition)) / pixelWidth;
#ifdef UNION_CLIPPING_REGIONS
clipAmount = czm_branchFreeTernary(i == 0, amount, min(amount, clipAmount));
if (amount <= 0.0) {
discard;
}
#else
clipAmount = max(amount, clipAmount);
clipped = clipped && (amount <= 0.0);
#endif
}
#ifndef UNION_CLIPPING_REGIONS
if (clipped) {
discard;
}
#endif
return clipAmount;
}
void modelClippingPlanesStage(inout vec4 color)
{
float clipDistance = clip(gl_FragCoord, model_clippingPlanes, model_clippingPlanesMatrix);
vec4 clippingPlanesEdgeColor = vec4(1.0);
clippingPlanesEdgeColor.rgb = model_clippingPlanesEdgeStyle.rgb;
float clippingPlanesEdgeWidth = model_clippingPlanesEdgeStyle.a;
if (clipDistance > 0.0 && clipDistance < clippingPlanesEdgeWidth) {
color = clippingPlanesEdgeColor;
}
}
`;var aie={name:"ModelClippingPlanesPipelineStage"},i3e=new H;aie.process=function(e,t,n){let i=t.clippingPlanes,o=n.context,r=e.shaderBuilder;r.addDefine("HAS_CLIPPING_PLANES",void 0,Ee.FRAGMENT),r.addDefine("CLIPPING_PLANES_LENGTH",i.length,Ee.FRAGMENT),i.unionClippingRegions&&r.addDefine("UNION_CLIPPING_REGIONS",void 0,Ee.FRAGMENT),ss.useFloatTexture(o)&&r.addDefine("USE_CLIPPING_PLANES_FLOAT_TEXTURE",void 0,Ee.FRAGMENT);let s=ss.getTextureResolution(i,o,i3e);r.addDefine("CLIPPING_PLANES_TEXTURE_WIDTH",s.x,Ee.FRAGMENT),r.addDefine("CLIPPING_PLANES_TEXTURE_HEIGHT",s.y,Ee.FRAGMENT),r.addUniform("sampler2D","model_clippingPlanes",Ee.FRAGMENT),r.addUniform("vec4","model_clippingPlanesEdgeStyle",Ee.FRAGMENT),r.addUniform("mat4","model_clippingPlanesMatrix",Ee.FRAGMENT),r.addFragmentLines(O1);let a={model_clippingPlanes:function(){return i.texture},model_clippingPlanesEdgeStyle:function(){let c=k.clone(i.edgeColor);return c.alpha=i.edgeWidth,c},model_clippingPlanesMatrix:function(){return t._clippingPlanesMatrix}};e.uniformMap=ht(a,e.uniformMap)};var M1=aie;function cie(e,t){this._model=e,this._runtimeNode=t}Object.defineProperties(cie.prototype,{name:{get:function(){return this._runtimeNode._name}},id:{get:function(){return this._runtimeNode._id}},show:{get:function(){return this._runtimeNode.show},set:function(e){this._runtimeNode.show=e}},matrix:{get:function(){return this._runtimeNode.transform},set:function(e){u(e)?(this._runtimeNode.transform=e,this._runtimeNode.userAnimated=!0,this._model._userAnimationDirty=!0):(this._runtimeNode.transform=this.originalMatrix,this._runtimeNode.userAnimated=!1)}},originalMatrix:{get:function(){return this._runtimeNode.originalTransform}}});var R1=cie;var B1=`mat4 getInstancingTransform()
{
mat4 instancingTransform;
#ifdef HAS_INSTANCE_MATRICES
instancingTransform = mat4(
a_instancingTransformRow0.x, a_instancingTransformRow1.x, a_instancingTransformRow2.x, 0.0, // Column 1
a_instancingTransformRow0.y, a_instancingTransformRow1.y, a_instancingTransformRow2.y, 0.0, // Column 2
a_instancingTransformRow0.z, a_instancingTransformRow1.z, a_instancingTransformRow2.z, 0.0, // Column 3
a_instancingTransformRow0.w, a_instancingTransformRow1.w, a_instancingTransformRow2.w, 1.0 // Column 4
);
#else
vec3 translation = vec3(0.0, 0.0, 0.0);
vec3 scale = vec3(1.0, 1.0, 1.0);
#ifdef HAS_INSTANCE_TRANSLATION
translation = a_instanceTranslation;
#endif
#ifdef HAS_INSTANCE_SCALE
scale = a_instanceScale;
#endif
instancingTransform = mat4(
scale.x, 0.0, 0.0, 0.0,
0.0, scale.y, 0.0, 0.0,
0.0, 0.0, scale.z, 0.0,
translation.x, translation.y, translation.z, 1.0
);
#endif
return instancingTransform;
}
#ifdef USE_2D_INSTANCING
mat4 getInstancingTransform2D()
{
mat4 instancingTransform2D;
#ifdef HAS_INSTANCE_MATRICES
instancingTransform2D = mat4(
a_instancingTransform2DRow0.x, a_instancingTransform2DRow1.x, a_instancingTransform2DRow2.x, 0.0, // Column 1
a_instancingTransform2DRow0.y, a_instancingTransform2DRow1.y, a_instancingTransform2DRow2.y, 0.0, // Column 2
a_instancingTransform2DRow0.z, a_instancingTransform2DRow1.z, a_instancingTransform2DRow2.z, 0.0, // Column 3
a_instancingTransform2DRow0.w, a_instancingTransform2DRow1.w, a_instancingTransform2DRow2.w, 1.0 // Column 4
);
#else
vec3 translation2D = vec3(0.0, 0.0, 0.0);
vec3 scale = vec3(1.0, 1.0, 1.0);
#ifdef HAS_INSTANCE_TRANSLATION
translation2D = a_instanceTranslation2D;
#endif
#ifdef HAS_INSTANCE_SCALE
scale = a_instanceScale;
#endif
instancingTransform2D = mat4(
scale.x, 0.0, 0.0, 0.0,
0.0, scale.y, 0.0, 0.0,
0.0, 0.0, scale.z, 0.0,
translation2D.x, translation2D.y, translation2D.z, 1.0
);
#endif
return instancingTransform2D;
}
#endif
`;var L1=`void instancingStage(inout ProcessedAttributes attributes)
{
vec3 positionMC = attributes.positionMC;
mat4 instancingTransform = getInstancingTransform();
attributes.positionMC = (instancingTransform * vec4(positionMC, 1.0)).xyz;
#ifdef HAS_NORMALS
vec3 normalMC = attributes.normalMC;
attributes.normalMC = (instancingTransform * vec4(normalMC, 0.0)).xyz;
#endif
#ifdef USE_2D_INSTANCING
mat4 instancingTransform2D = getInstancingTransform2D();
attributes.position2D = (instancingTransform2D * vec4(positionMC, 1.0)).xyz;
#endif
}
`;var N1=`void legacyInstancingStage(
inout ProcessedAttributes attributes,
out mat4 instanceModelView,
out mat3 instanceModelViewInverseTranspose)
{
vec3 positionMC = attributes.positionMC;
mat4 instancingTransform = getInstancingTransform();
mat4 instanceModel = instancingTransform * u_instance_nodeTransform;
instanceModelView = u_instance_modifiedModelView;
instanceModelViewInverseTranspose = mat3(u_instance_modifiedModelView * instanceModel);
attributes.positionMC = (instanceModel * vec4(positionMC, 1.0)).xyz;
#ifdef USE_2D_INSTANCING
mat4 instancingTransform2D = getInstancingTransform2D();
attributes.position2D = (instancingTransform2D * vec4(positionMC, 1.0)).xyz;
#endif
}
`;var qU=new B,o3e=new B,r3e=new B,uie={name:"InstancingPipelineStage",_getInstanceTransformsAsMatrices:pie,_transformsToTypedArray:K5};uie.process=function(e,t,n){let i=t.instances,o=i.attributes[0].count,r=e.shaderBuilder;r.addDefine("HAS_INSTANCING"),r.addVertexLines(B1);let s=e.model,a=s.sceneGraph,c=e.runtimeNode,l=n.mode!==ne.SCENE3D&&!n.scene3DOnly&&s._projectTo2D,f=[];x3e(e,n,i,f,l),E3e(e,n,i,f);let d={};if(i.transformInWorldSpace?(r.addDefine("USE_LEGACY_INSTANCING",void 0,Ee.VERTEX),r.addUniform("mat4","u_instance_modifiedModelView",Ee.VERTEX),r.addUniform("mat4","u_instance_nodeTransform",Ee.VERTEX),d.u_instance_modifiedModelView=function(){let p=B.multiplyTransformation(s.modelMatrix,a.components.transform,qU);return l?B.multiplyTransformation(n.context.uniformState.view3D,p,qU):(n.mode!==ne.SCENE3D&&(p=Ot.basisTo2D(n.mapProjection,p,qU)),B.multiplyTransformation(n.context.uniformState.view,p,qU))},d.u_instance_nodeTransform=function(){return B.multiplyTransformation(a.axisCorrectionMatrix,c.computedTransform,o3e)},r.addVertexLines(N1)):r.addVertexLines(L1),l){r.addDefine("USE_2D_INSTANCING",void 0,Ee.VERTEX),r.addUniform("mat4","u_modelView2D",Ee.VERTEX);let p=n.context,g=B.fromTranslation(c.instancingReferencePoint2D,new B);d.u_modelView2D=function(){return B.multiplyTransformation(p.uniformState.view,g,r3e)}}e.uniformMap=ht(d,e.uniformMap),e.instanceCount=o,e.attributes.push.apply(e.attributes,f)};var F1=new B,s3e=new m;function a3e(e,t,n,i,o){let r=B.multiplyTransformation(t,e,F1);return r=B.multiplyTransformation(r,n,F1),o=Ot.basisTo2D(i.mapProjection,r,o),o}function c3e(e,t,n,i,o){let r=B.fromTranslation(e,F1),s=B.multiplyTransformation(t,r,F1);s=B.multiplyTransformation(s,n,F1);let a=B.getTranslation(s,s3e);return o=Ki.computeActualWgs84Position(i,a,o),o}function fie(e,t,n){let i=e.model,o=i.sceneGraph;e.runtimeNode.node.instances.transformInWorldSpace?(t=B.multiplyTransformation(i.modelMatrix,o.components.transform,t),n=B.multiplyTransformation(o.axisCorrectionMatrix,e.runtimeNode.computedTransform,n)):(t=B.clone(o.computedModelMatrix,t),t=B.multiplyTransformation(t,e.runtimeNode.computedTransform,t),n=B.clone(B.IDENTITY,n))}var die=new B,mie=new B,l3e=new B,u3e=new m;function f3e(e,t,n,i){let o=die,r=mie;fie(t,o,r);let a=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let l=0;l<c;l++){let f=e[l],d=a3e(f,o,r,n,l3e),p=B.getTranslation(d,u3e),g=m.subtract(p,a,p);i[l]=B.setTranslation(d,g,i[l])}return i}function d3e(e,t,n,i){let o=die,r=mie;fie(t,o,r);let a=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let l=0;l<c;l++){let f=e[l],d=c3e(f,o,r,n,f);i[l]=m.subtract(d,a,i[l])}return i}var m3e=new m,h3e=new m;function hie(e,t){let n=e.runtimeNode,i=e.model.sceneGraph.computedModelMatrix,o=B.multiplyByPoint(i,n.instancingTranslationMin,m3e),r=Ki.computeActualWgs84Position(t,o,o),s=B.multiplyByPoint(i,n.instancingTranslationMax,h3e),a=Ki.computeActualWgs84Position(t,s,s);n.instancingReferencePoint2D=m.lerp(r,a,.5,new m)}function K5(e){let n=e.length,i=new Float32Array(n*12);for(let o=0;o<n;o++){let r=e[o],s=12*o;i[s+0]=r[0],i[s+1]=r[4],i[s+2]=r[8],i[s+3]=r[12],i[s+4]=r[1],i[s+5]=r[5],i[s+6]=r[9],i[s+7]=r[13],i[s+8]=r[2],i[s+9]=r[6],i[s+10]=r[10],i[s+11]=r[14]}return i}function p3e(e){let n=e.length,i=new Float32Array(n*3);for(let o=0;o<n;o++){let r=e[o],s=3*o;i[s+0]=r[0],i[s+1]=r[4],i[s+2]=r[8]}return i}var _3e=new m,g3e=new Ne,y3e=new m;function pie(e,t,n){let i=new Array(t),o=Qt.getAttributeBySemantic(e,jr.TRANSLATION),r=Qt.getAttributeBySemantic(e,jr.ROTATION),s=Qt.getAttributeBySemantic(e,jr.SCALE),a=new m(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),c=new m(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),l=u(o),f=u(r),d=u(s),p=l?o.typedArray:new Float32Array(t*3),g=f?r.typedArray:new Float32Array(t*4);f&&r.normalized&&(g=Wn.dequantize(g,r.componentDatatype,r.type,t));let h;d?h=s.typedArray:(h=new Float32Array(t*3),h.fill(1));for(let x=0;x<t;x++){let C=new m(p[x*3],p[x*3+1],p[x*3+2],_3e);m.maximumByComponent(a,C,a),m.minimumByComponent(c,C,c);let T=new Ne(g[x*4],g[x*4+1],g[x
{
bool styleTranslucent = (featureColor.a != 1.0);
// Only render translucent features in the translucent pass (if the style or the original command has translucency).
if (czm_pass == czm_passTranslucent && !styleTranslucent && !model_commandTranslucent)
{
// If the model has a translucent silhouette, it needs to render during the silhouette color command,
// (i.e. the command where model_silhouettePass = true), even if the model isn't translucent.
#ifdef HAS_SILHOUETTE
positionMC *= float(model_silhouettePass);
#else
positionMC *= 0.0;
#endif
}
// If the current pass is not the translucent pass and the style is not translucent, don't render the feature.
else if (czm_pass != czm_passTranslucent && styleTranslucent)
{
positionMC *= 0.0;
}
}
void cpuStylingStage(inout vec3 positionMC, inout SelectedFeature feature)
{
float show = ceil(feature.color.a);
positionMC *= show;
#if defined(HAS_SELECTED_FEATURE_ID_ATTRIBUTE) && !defined(HAS_CLASSIFICATION)
filterByPassType(positionMC, feature.color);
#endif
}
`;var Y1=`void filterByPassType(vec4 featureColor)
{
bool styleTranslucent = (featureColor.a != 1.0);
// Only render translucent features in the translucent pass (if the style or the original command has translucency).
if (czm_pass == czm_passTranslucent && !styleTranslucent && !model_commandTranslucent)
{
// If the model has a translucent silhouette, it needs to render during the silhouette color command,
// (i.e. the command where model_silhouettePass = true), even if the model isn't translucent.
#ifdef HAS_SILHOUETTE
if(!model_silhouettePass) {
discard;
}
#else
discard;
#endif
}
// If the current pass is not the translucent pass and the style is not translucent, don't render the feature.
else if (czm_pass != czm_passTranslucent && styleTranslucent)
{
discard;
}
}
void cpuStylingStage(inout czm_modelMaterial material, SelectedFeature feature)
{
vec4 featureColor = feature.color;
if (featureColor.a == 0.0)
{
discard;
}
// If a feature ID vertex attribute is used, the pass type filter is applied in the vertex shader.
// So, we only apply in in the fragment shader if the feature ID texture is used.
#if defined(HAS_SELECTED_FEATURE_ID_TEXTURE) && !defined(HAS_CLASSIFICATION)
filterByPassType(featureColor);
#endif
featureColor = czm_gammaCorrect(featureColor);
// Classification models compute the diffuse differently.
#ifdef HAS_CLASSIFICATION
material.diffuse = featureColor.rgb * featureColor.a;
#else
float highlight = ceil(model_colorBlend);
material.diffuse *= mix(featureColor.rgb, vec3(1.0), highlight);
#endif
material.alpha *= featureColor.a;
}
`;var Eie={name:"CPUStylingPipelineStage"};Eie.process=function(e,t,n){let i=e.model,o=e.shaderBuilder;o.addVertexLines(j1),o.addFragmentLines(Y1),o.addDefine("USE_CPU_STYLING",void 0,Ee.BOTH),u(i.color)||(o.addUniform("float",Bg.COLOR_BLEND_UNIFORM_NAME,Ee.FRAGMENT),e.uniformMap[Bg.COLOR_BLEND_UNIFORM_NAME]=function(){return Xa.getColorBlend(i.colorBlendMode,i.colorBlendAmount)}),o.addUniform("bool","model_commandTranslucent",Ee.BOTH),e.uniformMap.model_commandTranslucent=function(){return e.alphaOptions.pass===be.TRANSLUCENT}};var q1=Eie;var bie={MODIFY_MATERIAL:"MODIFY_MATERIAL",REPLACE_MATERIAL:"REPLACE_MATERIAL"};bie.getDefineName=function(e){return`CUSTOM_SHADER_${e}`};var Bp=Object.freeze(bie);var X1=`void customShaderStage(
inout czm_modelVertexOutput vsOutput,
inout ProcessedAttributes attributes,
FeatureIds featureIds,
Metadata metadata,
MetadataClass metadataClass,
MetadataStatistics metadataStatistics
) {
// VertexInput and initializeInputStruct() are dynamically generated in JS,
// see CustomShaderPipelineStage.js
VertexInput vsInput;
initializeInputStruct(vsInput, attributes);
vsInput.featureIds = featureIds;
vsInput.metadata = metadata;
vsInput.metadataClass = metadataClass;
vsInput.metadataStatistics = metadataStatistics;
vertexMain(vsInput, vsOutput);
attributes.positionMC = vsOutput.positionMC;
}
`;var K1=`void customShaderStage(
inout czm_modelMaterial material,
ProcessedAttributes attributes,
FeatureIds featureIds,
Metadata metadata,
MetadataClass metadataClass,
MetadataStatistics metadataStatistics
) {
// FragmentInput and initializeInputStruct() are dynamically generated in JS,
// see CustomShaderPipelineStage.js
FragmentInput fsInput;
initializeInputStruct(fsInput, attributes);
fsInput.featureIds = featureIds;
fsInput.metadata = metadata;
fsInput.metadataClass = metadataClass;
fsInput.metadataStatistics = metadataStatistics;
fragmentMain(fsInput, material);
}
`;var J1=`void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes) {
initializeFeatureIds(featureIds, attributes);
initializeFeatureIdAliases(featureIds);
}
`;var Z1=`void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes)
{
initializeFeatureIds(featureIds, attributes);
initializeFeatureIdAliases(featureIds);
setFeatureIdVaryings();
}
`;var Ni={name:"FeatureIdPipelineStage",STRUCT_ID_FEATURE_IDS_VS:"FeatureIdsVS",STRUCT_ID_FEATURE_IDS_FS:"FeatureIdsFS",STRUCT_NAME_FEATURE_IDS:"FeatureIds",FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS:"initializeFeatureIdsVS",FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS:"initializeFeatureIdsFS",FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_VS:"initializeFeatureIdAliasesVS",FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_FS:"initializeFeatureIdAliasesFS",FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS:"void initializeFeatureIds(out FeatureIds featureIds, ProcessedAttributes attributes)",FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES:"void initializeFeatureIdAliases(inout FeatureIds featureIds)",FUNCTION_ID_SET_FEATURE_ID_VARYINGS:"setFeatureIdVaryings",FUNCTION_SIGNATURE_SET_FEATURE_ID_VARYINGS:"void setFeatureIdVaryings()"};Ni.process=function(e,t,n){let i=e.shaderBuilder;v3e(i);let o=e.runtimeNode.node.instances;u(o)&&w3e(e,o,n),D3e(e,t,n),i.addVertexLines(Z1),i.addFragmentLines(J1)};function v3e(e){e.addStruct(Ni.STRUCT_ID_FEATURE_IDS_VS,Ni.STRUCT_NAME_FEATURE_IDS,Ee.VERTEX),e.addStruct(Ni.STRUCT_ID_FEATURE_IDS_FS,Ni.STRUCT_NAME_FEATURE_IDS,Ee.FRAGMENT),e.addFunction(Ni.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,Ni.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,Ee.VERTEX),e.addFunction(Ni.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,Ni.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,Ee.FRAGMENT),e.addFunction(Ni.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_VS,Ni.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,Ee.VERTEX),e.addFunction(Ni.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_FS,Ni.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,Ee.FRAGMENT),e.addFunction(Ni.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,Ni.FUNCTION_SIGNATURE_SET_FEATURE_ID_VARYINGS,Ee.VERTEX)}function w3e(e,t,n){let i=t.featureIds,o=t.attributes[0].count;for(let r=0;r<i.length;r++){let s=i[r],a=s.positionalLabel;s instanceof Bt.FeatureIdAttribute?I3e(e,s,a):Sie(e,s,a,o,1,n);let c=s.label;u(c)&&vie(e,a,c,Ee.BOTH)}}function D3e(e,t,n){let i=t.featureIds,r=Qt.getAttributeBySemantic(t,Tt.POSITION).count;for(let s=0;s<i.length;s++){let a=i[s],c=a.positionalLabel,l=Ee.BOTH;a instanceof Bt.FeatureIdAttribute?P3e(e,a,c):a instanceof Bt.FeatureIdImplicitRange?Sie(e,a,c,r,void 0,n):(O3e(e,a,c,s,n),l=Ee.FRAGMENT);let f=a.label;u(f)&&vie(e,c,f,l)}}function I3e(e,t,n){let i=e.shaderBuilder;i.addStructField(Ni.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(Ni.STRUCT_ID_FEATURE_IDS_FS,"int",n);let o=t.setIndex,r=n.replace(/_\d+$/,"_"),s=`a_${r}${o}`,a=`v_${r}${o}`,c=`featureIds.${n} = int(czm_round(${s}));`,l=`featureIds.${n} = int(czm_round(${a}));`;i.addFunctionLines(Ni.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[c]),i.addFunctionLines(Ni.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[l]),i.addVarying("float",a),i.addFunctionLines(Ni.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[`${a} = ${s};`])}function P3e(e,t,n){let i=e.shaderBuilder;i.addStructField(Ni.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(Ni.STRUCT_ID_FEATURE_IDS_FS,"int",n);let o=t.setIndex,r=n.replace(/_\d+$/,"_"),s=[`featureIds.${n} = int(czm_round(attributes.${r}${o}));`];i.addFunctionLines(Ni.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,s),i.addFunctionLines(Ni.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,s)}function Sie(e,t,n,i,o,r){M3e(e,t,i,o,r);let s=e.shaderBuilder,a=`a_implicit_${n}`;s.addAttribute("float",a);let c=`v_implicit_${n}`;s.addVarying("float",c),s.addStructField(Ni.STRUCT_ID_FEATURE_IDS_VS,"int",n),s.addStructField(Ni.STRUCT_ID_FEATURE_IDS_FS,"int",n),s.addFunctionLines(Ni.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[`${c} = ${a};`]),s.addFunctionLines(Ni.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[`featureIds.${n} = int(czm_round(${a}));`]),s.addFunctionLines(Ni.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[`featureIds.${n} = int(czm_round(${c}));`])}function O3e(e,t,n,i,o){let r=`u_featureIdTexture_${i}`,s=e.uniformMap,a=t.textureReader;s[r]=function(){return y(a.texture,o.context.defaultTexture)};let c=a.channels,l=e.shaderBuilder;l.addStructField(Ni.STRUCT_ID_FEATURE_IDS_FS,"int",n),l.addUniform("sampler2D",r,Ee.FRAGMENT);let f=`v_texCoord_${a.texCoord}`,d=`texture(${r}, ${f}).${
out Metadata metadata,
out MetadataClass metadataClass,
out MetadataStatistics metadataStatistics,
ProcessedAttributes attributes
)
{
initializeMetadata(metadata, metadataClass, metadataStatistics, attributes);
}
`;var $1=`void metadataStage(
out Metadata metadata,
out MetadataClass metadataClass,
out MetadataStatistics metadataStatistics,
ProcessedAttributes attributes
)
{
initializeMetadata(metadata, metadataClass, metadataStatistics, attributes);
setMetadataVaryings();
}
`;var Ti={name:"MetadataPipelineStage",STRUCT_ID_METADATA_VS:"MetadataVS",STRUCT_ID_METADATA_FS:"MetadataFS",STRUCT_NAME_METADATA:"Metadata",STRUCT_ID_METADATA_CLASS_VS:"MetadataClassVS",STRUCT_ID_METADATA_CLASS_FS:"MetadataClassFS",STRUCT_NAME_METADATA_CLASS:"MetadataClass",STRUCT_ID_METADATA_STATISTICS_VS:"MetadataStatisticsVS",STRUCT_ID_METADATA_STATISTICS_FS:"MetadataStatisticsFS",STRUCT_NAME_METADATA_STATISTICS:"MetadataStatistics",FUNCTION_ID_INITIALIZE_METADATA_VS:"initializeMetadataVS",FUNCTION_ID_INITIALIZE_METADATA_FS:"initializeMetadataFS",FUNCTION_SIGNATURE_INITIALIZE_METADATA:"void initializeMetadata(out Metadata metadata, out MetadataClass metadataClass, out MetadataStatistics metadataStatistics, ProcessedAttributes attributes)",FUNCTION_ID_SET_METADATA_VARYINGS:"setMetadataVaryings",FUNCTION_SIGNATURE_SET_METADATA_VARYINGS:"void setMetadataVaryings()",METADATA_CLASS_FIELDS:[{specName:"noData",shaderName:"noData"},{specName:"default",shaderName:"defaultValue"},{specName:"min",shaderName:"minValue"},{specName:"max",shaderName:"maxValue"}],METADATA_STATISTICS_FIELDS:[{specName:"min",shaderName:"minValue"},{specName:"max",shaderName:"maxValue"},{specName:"mean",shaderName:"mean",type:"float"},{specName:"median",shaderName:"median"},{specName:"standardDeviation",shaderName:"standardDeviation",type:"float"},{specName:"variance",shaderName:"variance",type:"float"},{specName:"sum",shaderName:"sum"}]};Ti.process=function(e,t,n){let{shaderBuilder:i,model:o}=e,{structuralMetadata:r={},content:s}=o,a=s?.tileset.metadataExtension?.statistics,c=B3e(r.propertyAttributes,t,a),l=N3e(r.propertyTextures,a),f=c.concat(l);U3e(i,f),z3e(i),i.addVertexLines($1),i.addFragmentLines(Q1);for(let d=0;d<c.length;d++){let p=c[d];H3e(e,p)}for(let d=0;d<l.length;d++){let p=l[d];W3e(e,p)}};function B3e(e,t,n){return u(e)?e.flatMap(i=>L3e(i,t,n)):[]}function L3e(e,t,n){let{getAttributeByName:i,getAttributeInfo:o,sanitizeGlslIdentifier:r}=Qt,s=e.class.id,a=n?.classes[s],c=Object.entries(e.properties),l=new Array(c.length);for(let f=0;f<c.length;f++){let[d,p]=c[f],g=i(t,p.attribute),{glslType:h,variableName:A}=o(g);l[f]={metadataVariable:r(d),property:p,type:p.classProperty.type,glslType:h,variableName:A,propertyStatistics:a?.properties[d],shaderDestination:Ee.BOTH}}return l}function N3e(e,t){return u(e)?e.flatMap(n=>F3e(n,t)):[]}function F3e(e,t){let{sanitizeGlslIdentifier:n}=Qt,i=e.class.id,o=t?.classes[i],r=Object.entries(e.properties).filter(([a,c])=>c.isGpuCompatible()),s=new Array(r.length);for(let a=0;a<r.length;a++){let[c,l]=r[a];s[a]={metadataVariable:n(c),property:l,type:l.classProperty.type,glslType:l.getGlslType(),propertyStatistics:o?.properties[c],shaderDestination:Ee.FRAGMENT}}return s}function U3e(e,t){let n=new Set,i=new Set;for(let a=0;a<t.length;a++){let{type:c,glslType:l,propertyStatistics:f}=t[a];n.add(l),u(f)&&c!==Ht.ENUM&&i.add(l)}let o=Ti.METADATA_CLASS_FIELDS;for(let a of n){let c=`${a}MetadataClass`;s(c,a,o)}let r=Ti.METADATA_STATISTICS_FIELDS;for(let a of i){let c=`${a}MetadataStatistics`;s(c,a,r)}function s(a,c,l){e.addStruct(a,a,Ee.BOTH);for(let f=0;f<l.length;f++){let{shaderName:d}=l[f],p=l[f].type==="float"?k3e(c):c;e.addStructField(a,p,d)}}}var V3e={int:"float",ivec2:"vec2",ivec3:"vec3",ivec4:"vec4"};function k3e(e){let t=V3e[e];return u(t)?t:e}function z3e(e){e.addStruct(Ti.STRUCT_ID_METADATA_VS,Ti.STRUCT_NAME_METADATA,Ee.VERTEX),e.addStruct(Ti.STRUCT_ID_METADATA_FS,Ti.STRUCT_NAME_METADATA,Ee.FRAGMENT),e.addStruct(Ti.STRUCT_ID_METADATA_CLASS_VS,Ti.STRUCT_NAME_METADATA_CLASS,Ee.VERTEX),e.addStruct(Ti.STRUCT_ID_METADATA_CLASS_FS,Ti.STRUCT_NAME_METADATA_CLASS,Ee.FRAGMENT),e.addStruct(Ti.STRUCT_ID_METADATA_STATISTICS_VS,Ti.STRUCT_NAME_METADATA_STATISTICS,Ee.VERTEX),e.addStruct(Ti.STRUCT_ID_METADATA_STATISTICS_FS,Ti.STRUCT_NAME_METADATA_STATISTICS,Ee.FRAGMENT),e.addFunction(Ti.FUNCTION_ID_INITIALIZE_METADATA_VS,Ti.FUNCTION_SIGNATURE_INITIALIZE_METADATA,Ee.VERTEX),e.addFunction(Ti.FUNCTION_ID_INITIALIZE_METADATA_FS,Ti.FUNCTION_SIGNATURE_INITIALIZE_METADATA,Ee.FRAGMENT),e.addFunction(Ti.FUNCTION_ID_SET_METADATA_VARY
{
attributes.positionMC = v_positionMC;
attributes.positionEC = v_positionEC;
#ifdef COMPUTE_POSITION_WC_CUSTOM_SHADER
attributes.positionWC = v_positionWC;
#endif
#ifdef HAS_NORMALS
// renormalize after interpolation
attributes.normalEC = normalize(v_normalEC);
#endif
#ifdef HAS_TANGENTS
attributes.tangentEC = normalize(v_tangentEC);
#endif
#ifdef HAS_BITANGENTS
attributes.bitangentEC = normalize(v_bitangentEC);
#endif
// Everything else is dynamically generated in GeometryPipelineStage
setDynamicVaryings(attributes);
}
`;var oO=`vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 normal)
{
vec4 computedPosition;
// Compute positions in different coordinate systems
vec3 positionMC = attributes.positionMC;
v_positionMC = positionMC;
v_positionEC = (modelView * vec4(positionMC, 1.0)).xyz;
#if defined(USE_2D_POSITIONS) || defined(USE_2D_INSTANCING)
vec3 position2D = attributes.position2D;
vec3 positionEC = (u_modelView2D * vec4(position2D, 1.0)).xyz;
computedPosition = czm_projection * vec4(positionEC, 1.0);
#else
computedPosition = czm_projection * vec4(v_positionEC, 1.0);
#endif
// Sometimes the custom shader and/or style needs this
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE)
// Note that this is a 32-bit position which may result in jitter on small
// scales.
v_positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;
#endif
#ifdef HAS_NORMALS
v_normalEC = normalize(normal * attributes.normalMC);
#endif
#ifdef HAS_TANGENTS
v_tangentEC = normalize(normal * attributes.tangentMC);
#endif
#ifdef HAS_BITANGENTS
v_bitangentEC = normalize(normal * attributes.bitangentMC);
#endif
// All other varyings need to be dynamically generated in
// GeometryPipelineStage
setDynamicVaryings(attributes);
return computedPosition;
}
`;var tE=`vec2 computeSt(float featureId)
{
float stepX = model_textureStep.x;
float centerX = model_textureStep.y;
#ifdef MULTILINE_BATCH_TEXTURE
float stepY = model_textureStep.z;
float centerY = model_textureStep.w;
float xId = mod(featureId, model_textureDimensions.x);
float yId = floor(featureId / model_textureDimensions.x);
return vec2(centerX + (xId * stepX), centerY + (yId * stepY));
#else
return vec2(centerX + (featureId * stepX), 0.5);
#endif
}
void selectedFeatureIdStage(out SelectedFeature feature, FeatureIds featureIds)
{
int featureId = featureIds.SELECTED_FEATURE_ID;
if (featureId < model_featuresLength)
{
vec2 featureSt = computeSt(float(featureId));
feature.id = featureId;
feature.st = featureSt;
feature.color = texture(model_batchTexture, featureSt);
}
// Floating point comparisons can be unreliable in GLSL, so we
// increment the feature ID to make sure it's always greater
// then the model_featuresLength - a condition we check for in the
// pick ID, to avoid sampling the pick texture if the feature ID is
// greater than the number of features.
else
{
feature.id = model_featuresLength + 1;
feature.st = vec2(0.0);
feature.color = vec4(1.0);
}
#ifdef HAS_NULL_FEATURE_ID
if (featureId == model_nullFeatureId) {
feature.id = featureId;
feature.st = vec2(0.0);
feature.color = vec4(1.0);
}
#endif
}
`;var rO={name:"SelectedFeatureIdPipelineStage",STRUCT_ID_SELECTED_FEATURE:"SelectedFeature",STRUCT_NAME_SELECTED_FEATURE:"SelectedFeature",FUNCTION_ID_FEATURE_VARYINGS_VS:"updateFeatureStructVS",FUNCTION_ID_FEATURE_VARYINGS_FS:"updateFeatureStructFS",FUNCTION_SIGNATURE_UPDATE_FEATURE:"void updateFeatureStruct(inout SelectedFeature feature)"};rO.process=function(e,t,n){let i=e.shaderBuilder;e.hasPropertyTable=!0;let o=e.model,r=e.runtimeNode.node,s=lUe(o,r,t),a=s.shaderDestination;i.addDefine("HAS_SELECTED_FEATURE_ID",void 0,a),i.addDefine("SELECTED_FEATURE_ID",s.variableName,a),i.addDefine(s.featureIdDefine,void 0,a),uUe(i);let c=s.featureIds.nullFeatureId,l=e.uniformMap;u(c)&&(i.addDefine("HAS_NULL_FEATURE_ID",void 0,a),i.addUniform("int","model_nullFeatureId",a),l.model_nullFeatureId=function(){return c}),s.shaderDestination===Ee.BOTH&&i.addVertexLines(tE),i.addFragmentLines(tE)};function Bie(e){return e instanceof Bt.FeatureIdTexture?"HAS_SELECTED_FEATURE_ID_TEXTURE":"HAS_SELECTED_FEATURE_ID_ATTRIBUTE"}function Lie(e){return e instanceof Bt.FeatureIdTexture?Ee.FRAGMENT:Ee.BOTH}function lUe(e,t,n){let i,o;return u(t.instances)&&(o=Qt.getFeatureIdsByLabel(t.instances.featureIds,e.instanceFeatureIdLabel),u(o))?(i=y(o.label,o.positionalLabel),{featureIds:o,variableName:i,shaderDestination:Lie(o),featureIdDefine:Bie(o)}):(o=Qt.getFeatureIdsByLabel(n.featureIds,e.featureIdLabel),i=y(o.label,o.positionalLabel),{featureIds:o,variableName:i,shaderDestination:Lie(o),featureIdDefine:Bie(o)})}function uUe(e){e.addStructField(rO.STRUCT_ID_SELECTED_FEATURE,"int","id"),e.addStructField(rO.STRUCT_ID_SELECTED_FEATURE,"vec2","st"),e.addStructField(rO.STRUCT_ID_SELECTED_FEATURE,"vec4","color")}var Fg=rO;var Es={name:"GeometryPipelineStage",STRUCT_ID_PROCESSED_ATTRIBUTES_VS:"ProcessedAttributesVS",STRUCT_ID_PROCESSED_ATTRIBUTES_FS:"ProcessedAttributesFS",STRUCT_NAME_PROCESSED_ATTRIBUTES:"ProcessedAttributes",FUNCTION_ID_INITIALIZE_ATTRIBUTES:"initializeAttributes",FUNCTION_SIGNATURE_INITIALIZE_ATTRIBUTES:"void initializeAttributes(out ProcessedAttributes attributes)",FUNCTION_ID_SET_DYNAMIC_VARYINGS_VS:"setDynamicVaryingsVS",FUNCTION_ID_SET_DYNAMIC_VARYINGS_FS:"setDynamicVaryingsFS",FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS:"void setDynamicVaryings(inout ProcessedAttributes attributes)"};Es.process=function(e,t,n){let i=e.shaderBuilder,o=e.model;i.addStruct(Es.STRUCT_ID_PROCESSED_ATTRIBUTES_VS,"ProcessedAttributes",Ee.VERTEX),i.addStruct(Es.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"ProcessedAttributes",Ee.FRAGMENT),i.addStruct(Fg.STRUCT_ID_SELECTED_FEATURE,Fg.STRUCT_NAME_SELECTED_FEATURE,Ee.BOTH),i.addFunction(Es.FUNCTION_ID_INITIALIZE_ATTRIBUTES,Es.FUNCTION_SIGNATURE_INITIALIZE_ATTRIBUTES,Ee.VERTEX),i.addVarying("vec3","v_positionWC"),i.addVarying("vec3","v_positionEC"),i.addStructField(Es.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionWC"),i.addStructField(Es.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionEC"),i.addFunction(Es.FUNCTION_ID_SET_DYNAMIC_VARYINGS_VS,Es.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,Ee.VERTEX),i.addFunction(Es.FUNCTION_ID_SET_DYNAMIC_VARYINGS_FS,Es.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,Ee.FRAGMENT),o.type===Fo.TILE_PNTS&&i.addDefine("HAS_SRGB_COLOR",void 0,Ee.FRAGMENT);let s=n.mode!==ne.SCENE3D&&!n.scene3DOnly&&o._projectTo2D,a=u(e.runtimeNode.node.instances),c=s&&!a,l=t.attributes.length;for(let f=0;f<l;f++){let d=t.attributes[f],p=an.getAttributeLocationCount(d.type),g=d.semantic===Tt.POSITION,h;p>1?(h=e.attributeIndex,e.attributeIndex+=p):g&&!c?h=0:h=e.attributeIndex++,fUe(e,d,h,p,s,a)}xUe(i,t.attributes),t.primitiveType===Le.POINTS&&i.addDefine("PRIMITIVE_TYPE_POINTS"),i.addVertexLines(oO),i.addFragmentLines(iO)};function fUe(e,t,n,i,o,r){let s=e.shaderBuilder,a=Qt.getAttributeInfo(t),c=o&&!r;i>1?hUe(e,t,n,i):mUe(e,t,n,c),_Ue(s,a,c),pUe(s,a),u(t.semantic)&&dUe(s,t),gUe(s,a,o),yUe(s,a,c),AUe(s,a)}function dUe(e,t){let n=t.semantic,i=t.setIndex;switch(n){case Tt.NORMAL:e.addDefine("HAS_NORMALS");break;case Tt.TANGENT:e.addDefine("HAS_TANGENTS");break;case Tt.FEATURE_ID:e.addDefine(`HAS${n}_${i}`);break;case Tt.
vec3 computePbrLighting(czm_modelMaterial inputMaterial, ProcessedAttributes attributes)
{
czm_pbrParameters pbrParameters;
pbrParameters.diffuseColor = inputMaterial.diffuse;
pbrParameters.f0 = inputMaterial.specular;
pbrParameters.roughness = inputMaterial.roughness;
#ifdef USE_CUSTOM_LIGHT_COLOR
vec3 lightColorHdr = model_lightColorHdr;
#else
vec3 lightColorHdr = czm_lightColorHdr;
#endif
vec3 color = inputMaterial.diffuse;
#ifdef HAS_NORMALS
color = czm_pbrLighting(
attributes.positionEC,
inputMaterial.normalEC,
czm_lightDirectionEC,
lightColorHdr,
pbrParameters
);
#ifdef USE_IBL_LIGHTING
color += imageBasedLightingStage(
attributes.positionEC,
inputMaterial.normalEC,
czm_lightDirectionEC,
lightColorHdr,
pbrParameters
);
#endif
#endif
color *= inputMaterial.occlusion;
color += inputMaterial.emissive;
// In HDR mode, the frame buffer is in linear color space. The
// post-processing stages (see PostProcessStageCollection) will handle
// tonemapping. However, if HDR is not enabled, we must tonemap else large
// values may be clamped to 1.0
#ifndef HDR
color = czm_acesTonemapping(color);
#endif
return color;
}
#endif
void lightingStage(inout czm_modelMaterial material, ProcessedAttributes attributes)
{
// Even though the lighting will only set the diffuse color,
// pass all other properties so further stages have access to them.
vec3 color = vec3(0.0);
#ifdef LIGHTING_PBR
color = computePbrLighting(material, attributes);
#else // unlit
color = material.diffuse;
#endif
#ifdef HAS_POINT_CLOUD_COLOR_STYLE
// The colors resulting from point cloud styles are adjusted differently.
color = czm_gammaCorrect(color);
#elif !defined(HDR)
// If HDR is not enabled, the frame buffer stores sRGB colors rather than
// linear colors so the linear value must be converted.
color = czm_linearToSrgb(color);
#endif
material.diffuse = color;
}
`;var CUe={UNLIT:0,PBR:1},zm=Object.freeze(CUe);var Nie={name:"LightingPipelineStage"};Nie.process=function(e,t){let n=e.model,i=e.lightingOptions,o=e.shaderBuilder;if(u(n.lightColor)){o.addDefine("USE_CUSTOM_LIGHT_COLOR",void 0,Ee.FRAGMENT),o.addUniform("vec3","model_lightColorHdr",Ee.FRAGMENT);let s=e.uniformMap;s.model_lightColorHdr=function(){return n.lightColor}}i.lightingModel===zm.PBR?o.addDefine("LIGHTING_PBR",void 0,Ee.FRAGMENT):o.addDefine("LIGHTING_UNLIT",void 0,Ee.FRAGMENT),o.addFragmentLines(aO)};var cO=Nie;var lO=`// If the style color is white, it implies the feature has not been styled.
bool isDefaultStyleColor(vec3 color)
{
return all(greaterThan(color, vec3(1.0 - czm_epsilon3)));
}
vec3 blend(vec3 sourceColor, vec3 styleColor, float styleColorBlend)
{
vec3 blendColor = mix(sourceColor, styleColor, styleColorBlend);
vec3 color = isDefaultStyleColor(styleColor.rgb) ? sourceColor : blendColor;
return color;
}
vec2 computeTextureTransform(vec2 texCoord, mat3 textureTransform)
{
return vec2(textureTransform * vec3(texCoord, 1.0));
}
#ifdef HAS_NORMALS
vec3 computeNormal(ProcessedAttributes attributes)
{
// Geometry normal. This is already normalized
vec3 ng = attributes.normalEC;
vec3 normal = ng;
#if defined(HAS_NORMAL_TEXTURE) && !defined(HAS_WIREFRAME)
vec2 normalTexCoords = TEXCOORD_NORMAL;
#ifdef HAS_NORMAL_TEXTURE_TRANSFORM
normalTexCoords = computeTextureTransform(normalTexCoords, u_normalTextureTransform);
#endif
// If HAS_BITANGENTS is set, then HAS_TANGENTS is also set
#ifdef HAS_BITANGENTS
vec3 t = attributes.tangentEC;
vec3 b = attributes.bitangentEC;
mat3 tbn = mat3(t, b, ng);
vec3 n = texture(u_normalTexture, normalTexCoords).rgb;
normal = normalize(tbn * (2.0 * n - 1.0));
#elif (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
// If derivatives are available (not IE 10), compute tangents
vec3 positionEC = attributes.positionEC;
vec3 pos_dx = dFdx(positionEC);
vec3 pos_dy = dFdy(positionEC);
vec3 tex_dx = dFdx(vec3(normalTexCoords,0.0));
vec3 tex_dy = dFdy(vec3(normalTexCoords,0.0));
vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
t = normalize(t - ng * dot(ng, t));
vec3 b = normalize(cross(ng, t));
mat3 tbn = mat3(t, b, ng);
vec3 n = texture(u_normalTexture, normalTexCoords).rgb;
normal = normalize(tbn * (2.0 * n - 1.0));
#endif
#endif
#ifdef HAS_DOUBLE_SIDED_MATERIAL
if (czm_backFacing()) {
normal = -normal;
}
#endif
return normal;
}
#endif
void materialStage(inout czm_modelMaterial material, ProcessedAttributes attributes, SelectedFeature feature)
{
#ifdef HAS_NORMALS
material.normalEC = computeNormal(attributes);
#endif
vec4 baseColorWithAlpha = vec4(1.0);
// Regardless of whether we use PBR, set a base color
#ifdef HAS_BASE_COLOR_TEXTURE
vec2 baseColorTexCoords = TEXCOORD_BASE_COLOR;
#ifdef HAS_BASE_COLOR_TEXTURE_TRANSFORM
baseColorTexCoords = computeTextureTransform(baseColorTexCoords, u_baseColorTextureTransform);
#endif
baseColorWithAlpha = czm_srgbToLinear(texture(u_baseColorTexture, baseColorTexCoords));
#ifdef HAS_BASE_COLOR_FACTOR
baseColorWithAlpha *= u_baseColorFactor;
#endif
#elif defined(HAS_BASE_COLOR_FACTOR)
baseColorWithAlpha = u_baseColorFactor;
#endif
#ifdef HAS_POINT_CLOUD_COLOR_STYLE
baseColorWithAlpha = v_pointCloudColor;
#elif defined(HAS_COLOR_0)
vec4 color = attributes.color_0;
// .pnts files store colors in the sRGB color space
#ifdef HAS_SRGB_COLOR
color = czm_srgbToLinear(color);
#endif
baseColorWithAlpha *= color;
#endif
material.diffuse = baseColorWithAlpha.rgb;
material.alpha = baseColorWithAlpha.a;
#ifdef USE_CPU_STYLING
material.diffuse = blend(material.diffuse, feature.color.rgb, model_colorBlend);
#endif
#ifdef HAS_OCCLUSION_TEXTURE
vec2 occlusionTexCoords = TEXCOORD_OCCLUSION;
#ifdef HAS_OCCLUSION_TEXTURE_TRANSFORM
occlusionTexCoords = computeTextureTransform(occlusionTexCoords, u_occlusionTextureTransform);
#endif
material.occlusion = texture(u_occlusionTexture, occlusionTexCoords).r;
#endif
#ifdef HAS_EMISSIVE_TEXTURE
vec2 emissiveTexCoords = TEXCOORD_EMISSIVE;
#ifdef HAS_EMISSIVE_TEXTURE_TRANSFORM
emissiveTexCoords = computeTextureTransform(emissiveTexCoords, u_emissiveTextureTransform);
#endif
vec3 emissive = czm_srgbToLinear(texture(u_emissiveTexture, emissiveTexCoords).rgb);
#ifdef HAS_EMISSIVE_FACTOR
emissive *= u_emissiveFactor;
#endif
material.emissive = emissive;
#elif defined(HAS_EMISSIVE_FACTOR)
material.emissive = u_emissiveFactor;
#endif
#if defined(LIGHTING_PBR) && defined(USE_SPECULAR_GLOSSINESS)
#ifdef HAS_SPECULAR_GLOSSINESS_TEXTURE
vec2 specularGlossinessTexCoords = TEXCOORD_SPECULAR_GLOSSINESS;
#ifdef HAS_SPECULAR_GLOSSINESS_TEXTURE_TRANSFORM
specularGlossinessTexCoords = computeTextureTransform(specularGlossinessTexCoords, u_specularGlossinessTextureTransform);
#endif
vec4 specularGlossiness = czm_srgbToLinear(texture(u_specularGlossinessTexture, specularGlossinessTexCoords));
vec3 specular = specularGlossiness.rgb;
float glossiness = specularGlossiness.a;
#ifdef HAS_SPECULAR_FACTOR
specular *= u_specularFactor;
#endif
#ifdef HAS_GLOSSINESS_FACTOR
glossiness *= u_glossinessFactor;
#endif
#else
#ifdef HAS_SPECULAR_FACTOR
vec3 specular = clamp(u_specularFactor, vec3(0.0), vec3(1.0));
#else
vec3 specular = vec3(1.0);
#endif
#ifdef HAS_GLOSSINESS_FACTOR
float glossiness = clamp(u_glossinessFactor, 0.0, 1.0);
#else
float glossiness = 1.0;
#endif
#endif
#ifdef HAS_DIFFUSE_TEXTURE
vec2 diffuseTexCoords = TEXCOORD_DIFFUSE;
#ifdef HAS_DIFFUSE_TEXTURE_TRANSFORM
diffuseTexCoords = computeTextureTransform(diffuseTexCoords, u_diffuseTextureTransform);
#endif
vec4 diffuse = czm_srgbToLinear(texture(u_diffuseTexture, diffuseTexCoords));
#ifdef HAS_DIFFUSE_FACTOR
diffuse *= u_diffuseFactor;
#endif
#elif defined(HAS_DIFFUSE_FACTOR)
vec4 diffuse = clamp(u_diffuseFactor, vec4(0.0), vec4(1.0));
#else
vec4 diffuse = vec4(1.0);
#endif
czm_pbrParameters parameters = czm_pbrSpecularGlossinessMaterial(
diffuse.rgb,
specular,
glossiness
);
material.diffuse = parameters.diffuseColor;
// the specular glossiness extension's alpha overrides anything set
// by the base material.
material.alpha = diffuse.a;
material.specular = parameters.f0;
material.roughness = parameters.roughness;
#elif defined(LIGHTING_PBR)
#ifdef HAS_METALLIC_ROUGHNESS_TEXTURE
vec2 metallicRoughnessTexCoords = TEXCOORD_METALLIC_ROUGHNESS;
#ifdef HAS_METALLIC_ROUGHNESS_TEXTURE_TRANSFORM
metallicRoughnessTexCoords = computeTextureTransform(metallicRoughnessTexCoords, u_metallicRoughnessTextureTransform);
#endif
vec3 metallicRoughness = texture(u_metallicRoughnessTexture, metallicRoughnessTexCoords).rgb;
float metalness = clamp(metallicRoughness.b, 0.0, 1.0);
float roughness = clamp(metallicRoughness.g, 0.04, 1.0);
#ifdef HAS_METALLIC_FACTOR
metalness *= u_metallicFactor;
#endif
#ifdef HAS_ROUGHNESS_FACTOR
roughness *= u_roughnessFactor;
#endif
#else
#ifdef HAS_METALLIC_FACTOR
float metalness = clamp(u_metallicFactor, 0.0, 1.0);
#else
float metalness = 1.0;
#endif
#ifdef HAS_ROUGHNESS_FACTOR
float roughness = clamp(u_roughnessFactor, 0.04, 1.0);
#else
float roughness = 1.0;
#endif
#endif
czm_pbrParameters parameters = czm_pbrMetallicRoughnessMaterial(
material.diffuse,
metalness,
roughness
);
material.diffuse = parameters.diffuseColor;
material.specular = parameters.f0;
material.roughness = parameters.roughness;
#endif
}
`;var TUe=Bt.Material,$5=Bt.MetallicRoughness,e6=Bt.SpecularGlossiness,Fie={name:"MaterialPipelineStage",_processTexture:Ug,_processTextureTransform:Uie};Fie.process=function(e,t,n){let i=t.material,o=e.model,r=u(o.classificationType),s=r,a=e.uniformMap,c=e.shaderBuilder,l=n.context.defaultTexture,f=n.context.defaultNormalTexture,d=n.context.defaultEmissiveTexture;EUe(i,a,c,l,f,d,s),u(i.specularGlossiness)?bUe(i,a,c,l,s):SUe(i,a,c,l,s);let p=Qt.getAttributeBySemantic(t,Tt.NORMAL),g=e.lightingOptions;i.unlit||!p||r?g.lightingModel=zm.UNLIT:g.lightingModel=zm.PBR;let h=o.backFaceCulling&&!i.doubleSided;e.renderStateOptions.cull.enabled=h;let A=e.alphaOptions;i.alphaMode===Um.BLEND?A.pass=be.TRANSLUCENT:i.alphaMode===Um.MASK&&(A.alphaCutoff=i.alphaCutoff),c.addFragmentLines(lO),i.doubleSided&&c.addDefine("HAS_DOUBLE_SIDED_MATERIAL",void 0,Ee.BOTH)};function Uie(e,t,n,i,o){let r=`HAS_${o}_TEXTURE_TRANSFORM`;e.addDefine(r,void 0,Ee.FRAGMENT);let s=`${i}Transform`;e.addUniform("mat3",s,Ee.FRAGMENT),t[s]=function(){return n.transform}}function Ug(e,t,n,i,o,r){e.addUniform("sampler2D",i,Ee.FRAGMENT),t[i]=function(){return y(n.texture,r)};let s=`HAS_${o}_TEXTURE`;e.addDefine(s,void 0,Ee.FRAGMENT);let c=`v_texCoord_${n.texCoord}`,l=`TEXCOORD_${o}`;e.addDefine(l,c,Ee.FRAGMENT);let f=n.transform;u(f)&&!Z.equals(f,Z.IDENTITY)&&Uie(e,t,n,i,o)}function EUe(e,t,n,i,o,r,s){let a=e.emissiveTexture;u(a)&&!s&&Ug(n,t,a,"u_emissiveTexture","EMISSIVE",r);let c=e.emissiveFactor;u(c)&&!m.equals(c,TUe.DEFAULT_EMISSIVE_FACTOR)&&(n.addUniform("vec3","u_emissiveFactor",Ee.FRAGMENT),t.u_emissiveFactor=function(){return e.emissiveFactor},n.addDefine("HAS_EMISSIVE_FACTOR",void 0,Ee.FRAGMENT));let l=e.normalTexture;u(l)&&!s&&Ug(n,t,l,"u_normalTexture","NORMAL",o);let f=e.occlusionTexture;u(f)&&!s&&Ug(n,t,f,"u_occlusionTexture","OCCLUSION",i)}function bUe(e,t,n,i,o){let r=e.specularGlossiness;n.addDefine("USE_SPECULAR_GLOSSINESS",void 0,Ee.FRAGMENT);let s=r.diffuseTexture;u(s)&&!o&&Ug(n,t,s,"u_diffuseTexture","DIFFUSE",i);let a=r.diffuseFactor;u(a)&&!re.equals(a,e6.DEFAULT_DIFFUSE_FACTOR)&&(n.addUniform("vec4","u_diffuseFactor",Ee.FRAGMENT),t.u_diffuseFactor=function(){return r.diffuseFactor},n.addDefine("HAS_DIFFUSE_FACTOR",void 0,Ee.FRAGMENT));let c=r.specularGlossinessTexture;u(c)&&!o&&Ug(n,t,c,"u_specularGlossinessTexture","SPECULAR_GLOSSINESS",i);let l=r.specularFactor;u(l)&&!m.equals(l,e6.DEFAULT_SPECULAR_FACTOR)&&(n.addUniform("vec3","u_specularFactor",Ee.FRAGMENT),t.u_specularFactor=function(){return r.specularFactor},n.addDefine("HAS_SPECULAR_FACTOR",void 0,Ee.FRAGMENT));let f=r.glossinessFactor;u(f)&&f!==e6.DEFAULT_GLOSSINESS_FACTOR&&(n.addUniform("float","u_glossinessFactor",Ee.FRAGMENT),t.u_glossinessFactor=function(){return r.glossinessFactor},n.addDefine("HAS_GLOSSINESS_FACTOR",void 0,Ee.FRAGMENT))}function SUe(e,t,n,i,o){let r=e.metallicRoughness;n.addDefine("USE_METALLIC_ROUGHNESS",void 0,Ee.FRAGMENT);let s=r.baseColorTexture;u(s)&&!o&&Ug(n,t,s,"u_baseColorTexture","BASE_COLOR",i);let a=r.baseColorFactor;u(a)&&!re.equals(a,$5.DEFAULT_BASE_COLOR_FACTOR)&&(n.addUniform("vec4","u_baseColorFactor",Ee.FRAGMENT),t.u_baseColorFactor=function(){return r.baseColorFactor},n.addDefine("HAS_BASE_COLOR_FACTOR",void 0,Ee.FRAGMENT));let c=r.metallicRoughnessTexture;u(c)&&!o&&Ug(n,t,c,"u_metallicRoughnessTexture","METALLIC_ROUGHNESS",i);let l=r.metallicFactor;u(l)&&l!==$5.DEFAULT_METALLIC_FACTOR&&(n.addUniform("float","u_metallicFactor",Ee.FRAGMENT),t.u_metallicFactor=function(){return r.metallicFactor},n.addDefine("HAS_METALLIC_FACTOR",void 0,Ee.FRAGMENT));let f=r.roughnessFactor;u(f)&&f!==$5.DEFAULT_ROUGHNESS_FACTOR&&(n.addUniform("float","u_roughnessFactor",Ee.FRAGMENT),t.u_roughnessFactor=function(){return r.roughnessFactor},n.addDefine("HAS_ROUGHNESS_FACTOR",void 0,Ee.FRAGMENT))}var uO=Fie;var fO=`void morphTargetsStage(inout ProcessedAttributes attributes)
{
vec3 positionMC = attributes.positionMC;
attributes.positionMC = getMorphedPosition(positionMC);
#ifdef HAS_NORMALS
vec3 normalMC = attributes.normalMC;
attributes.normalMC = getMorphedNormal(normalMC);
#endif
#ifdef HAS_TANGENTS
vec3 tangentMC = attributes.tangentMC;
attributes.tangentMC = getMorphedTangent(tangentMC);
#endif
}`;var xa={name:"MorphTargetsPipelineStage",FUNCTION_ID_GET_MORPHED_POSITION:"getMorphedPosition",FUNCTION_SIGNATURE_GET_MORPHED_POSITION:"vec3 getMorphedPosition(in vec3 position)",FUNCTION_ID_GET_MORPHED_NORMAL:"getMorphedNormal",FUNCTION_SIGNATURE_GET_MORPHED_NORMAL:"vec3 getMorphedNormal(in vec3 normal)",FUNCTION_ID_GET_MORPHED_TANGENT:"getMorphedTangent",FUNCTION_SIGNATURE_GET_MORPHED_TANGENT:"vec3 getMorphedTangent(in vec3 tangent)"};xa.process=function(e,t){let n=e.shaderBuilder;n.addDefine("HAS_MORPH_TARGETS",void 0,Ee.VERTEX),OUe(n);let i=t.morphTargets.length;for(let a=0;a<i;a++){let c=t.morphTargets[a].attributes,l=c.length;for(let f=0;f<l;f++){let d=c[f],p=d.semantic;p!==Tt.POSITION&&p!==Tt.NORMAL&&p!==Tt.TANGENT||(wUe(e,d,e.attributeIndex,a),e.attributeIndex++)}}MUe(n);let r=e.runtimeNode.morphWeights.length;n.addUniform("float",`u_morphWeights[${r}]`,Ee.VERTEX),n.addVertexLines(fO);let s={u_morphWeights:function(){return e.runtimeNode.morphWeights}};e.uniformMap=ht(s,e.uniformMap)};var vUe={attributeString:void 0,functionId:void 0};function wUe(e,t,n,i){let o=e.shaderBuilder;DUe(e,t,n);let r=IUe(t,vUe);PUe(o,r,i)}function DUe(e,t,n){let i={index:n,value:u(t.buffer)?void 0:t.constant,vertexBuffer:t.buffer,componentsPerAttribute:an.getNumberOfComponents(t.type),componentDatatype:t.componentDatatype,offsetInBytes:t.byteOffset,strideInBytes:t.byteStride,normalize:t.normalized};e.attributes.push(i)}function IUe(e,t){switch(e.semantic){case Tt.POSITION:t.attributeString="Position",t.functionId=xa.FUNCTION_ID_GET_MORPHED_POSITION;break;case Tt.NORMAL:t.attributeString="Normal",t.functionId=xa.FUNCTION_ID_GET_MORPHED_NORMAL;break;case Tt.TANGENT:t.attributeString="Tangent",t.functionId=xa.FUNCTION_ID_GET_MORPHED_TANGENT;break;default:break}return t}function PUe(e,t,n){let i=t.attributeString,o=`a_target${i}_${n}`,r=`morphed${i} += u_morphWeights[${n}] * a_target${i}_${n};`;e.addAttribute("vec3",o),e.addFunctionLines(t.functionId,[r])}function OUe(e){e.addFunction(xa.FUNCTION_ID_GET_MORPHED_POSITION,xa.FUNCTION_SIGNATURE_GET_MORPHED_POSITION,Ee.VERTEX);let t="vec3 morphedPosition = position;";e.addFunctionLines(xa.FUNCTION_ID_GET_MORPHED_POSITION,[t]),e.addFunction(xa.FUNCTION_ID_GET_MORPHED_NORMAL,xa.FUNCTION_SIGNATURE_GET_MORPHED_NORMAL,Ee.VERTEX);let n="vec3 morphedNormal = normal;";e.addFunctionLines(xa.FUNCTION_ID_GET_MORPHED_NORMAL,[n]),e.addFunction(xa.FUNCTION_ID_GET_MORPHED_TANGENT,xa.FUNCTION_SIGNATURE_GET_MORPHED_TANGENT,Ee.VERTEX);let i="vec3 morphedTangent = tangent;";e.addFunctionLines(xa.FUNCTION_ID_GET_MORPHED_TANGENT,[i])}function MUe(e){let t="return morphedPosition;";e.addFunctionLines(xa.FUNCTION_ID_GET_MORPHED_POSITION,[t]);let n="return morphedNormal;";e.addFunctionLines(xa.FUNCTION_ID_GET_MORPHED_NORMAL,[n]);let i="return morphedTangent;";e.addFunctionLines(xa.FUNCTION_ID_GET_MORPHED_TANGENT,[i])}var dO=xa;var Vie={name:"PickingPipelineStage"};Vie.process=function(e,t,n){let i=n.context,o=e.runtimeNode,r=e.shaderBuilder,s=e.model,a=o.node.instances;if(e.hasPropertyTable)RUe(e,t,a,i);else if(u(a))BUe(e,i);else{let c=kie(e),l=i.createPickId(c);s._pipelineResources.push(l),s._pickIds.push(l),r.addUniform("vec4","czm_pickColor",Ee.FRAGMENT);let f=e.uniformMap;f.czm_pickColor=function(){return l.color},e.pickId="czm_pickColor"}};function kie(e,t){let n=e.model;if(u(n.pickObject))return n.pickObject;let i={model:n,node:e.runtimeNode,primitive:e.runtimePrimitive},o;if(Fo.is3DTiles(n.type)){let r=n.content;o={content:r,primitive:r.tileset,detail:i}}else o={primitive:n,detail:i};return o.id=n.id,u(t)&&(o.instanceId=t),o}function RUe(e,t,n){let i=e.model,o,r,s=i.featureIdLabel,a=i.instanceFeatureIdLabel;u(i.featureTableId)?o=i.featureTableId:u(n)?(r=Qt.getFeatureIdsByLabel(n.featureIds,a),o=r.propertyTableId):(r=Qt.getFeatureIdsByLabel(t.featureIds,s),o=r.propertyTableId);let c=i.featureTables[o];e.shaderBuilder.addUniform("sampler2D","model_pickTexture",Ee.FRAGMENT);let f=c.batchTexture;e.uniformMap.model_pickTexture=function(){return y(f.pickTexture,f.defaultTexture)},e.pickId="((selectedFeature.id <
// Variables are packed into a single vector to minimize gl.uniformXXX() calls
float pointSize = model_pointCloudParameters.x;
float geometricError = model_pointCloudParameters.y;
float depthMultiplier = model_pointCloudParameters.z;
float depth = -positionEC.z;
return min((geometricError / depth) * depthMultiplier, pointSize);
}
#ifdef HAS_POINT_CLOUD_SHOW_STYLE
float pointCloudShowStylingStage(in ProcessedAttributes attributes, in Metadata metadata) {
float tiles3d_tileset_time = model_pointCloudParameters.w;
return float(getShowFromStyle(attributes, metadata, tiles3d_tileset_time));
}
#endif
#ifdef HAS_POINT_CLOUD_COLOR_STYLE
vec4 pointCloudColorStylingStage(in ProcessedAttributes attributes, in Metadata metadata) {
float tiles3d_tileset_time = model_pointCloudParameters.w;
return getColorFromStyle(attributes, metadata, tiles3d_tileset_time);
}
#endif
#ifdef HAS_POINT_CLOUD_POINT_SIZE_STYLE
float pointCloudPointSizeStylingStage(in ProcessedAttributes attributes, in Metadata metadata) {
float tiles3d_tileset_time = model_pointCloudParameters.w;
return float(getPointSizeFromStyle(attributes, metadata, tiles3d_tileset_time));
}
#elif defined(HAS_POINT_CLOUD_ATTENUATION)
float pointCloudPointSizeStylingStage(in ProcessedAttributes attributes, in Metadata metadata) {
return getPointSizeFromAttenuation(v_positionEC);
}
#endif
#ifdef HAS_POINT_CLOUD_BACK_FACE_CULLING
float pointCloudBackFaceCullingStage() {
#if defined(HAS_NORMALS) && !defined(HAS_DOUBLE_SIDED_MATERIAL)
// This needs to be computed in eye coordinates so we can't use attributes.normalMC
return step(-v_normalEC.z, 0.0);
#else
return 1.0;
#endif
}
#endif`;var NUe=new re,Hie={name:"PointCloudStylingPipelineStage"};Hie.process=function(e,t,n){let i=e.shaderBuilder,o=e.model,r=o.style,s=o.structuralMetadata,a=u(s)?s.propertyAttributes:void 0,c=u(o.featureTableId)&&o.featureTables[o.featureTableId].featuresLength>0,l=!u(a)&&c;if(u(r)&&!l){let A=kUe(a),x=zUe(r,A);HUe(i,x);let T=GUe(x).indexOf("normalMC")>=0,E=Qt.getAttributeBySemantic(t,Tt.NORMAL);if(T&&!E)throw new de("Style references the NORMAL semantic but the point cloud does not have normals");i.addDefine("COMPUTE_POSITION_WC_STYLE",void 0,Ee.VERTEX),x.styleTranslucent&&(e.alphaOptions.pass=be.TRANSLUCENT)}let f=o.pointCloudShading;f.attenuation&&i.addDefine("HAS_POINT_CLOUD_ATTENUATION",void 0,Ee.VERTEX),f.backFaceCulling&&i.addDefine("HAS_POINT_CLOUD_BACK_FACE_CULLING",void 0,Ee.VERTEX);let d,p,g;Fo.is3DTiles(o.type)&&(p=!0,d=o.content,g=d.tile.refine===Uo.ADD),i.addUniform("vec4","model_pointCloudParameters",Ee.VERTEX),i.addVertexLines(hO);let h=e.uniformMap;h.model_pointCloudParameters=function(){let A=NUe,x=1;p&&(x=g?5:d.tileset.maximumScreenSpaceError),A.x=y(f.maximumAttenuation,x),A.x*=n.pixelRatio;let C=FUe(e,t,f,d);A.y=C*f.geometricErrorScale;let T=n.context,E=n.camera.frustum,S;return n.mode===ne.SCENE2D||E instanceof nn?S=Number.POSITIVE_INFINITY:S=T.drawingBufferHeight/n.camera.frustum.sseDenominator,A.z=S,p&&(A.w=d.tileset.timeSinceLoad),A}};var zie=new m;function FUe(e,t,n,i){if(u(i)){let f=i.tile.geometricError;if(f>0)return f}if(u(n.baseResolution))return n.baseResolution;let o=Qt.getAttributeBySemantic(t,Tt.POSITION),r=o.count,s=e.runtimeNode.transform,a=m.subtract(o.max,o.min,zie);a=B.multiplyByPointAsVector(s,a,zie);let c=a.x*a.y*a.z;return P.cbrt(c/r)}var UUe={colorStyleFunction:void 0,showStyleFunction:void 0,pointSizeStyleFunction:void 0,styleTranslucent:!1},VUe={POSITION:"attributes.positionMC",POSITION_ABSOLUTE:"v_positionWC",COLOR:"attributes.color_0",NORMAL:"attributes.normalMC"};function kUe(e){let t=je(VUe);if(!u(e))return t;for(let n=0;n<e.length;n++){let o=e[n].properties;for(let r in o)o.hasOwnProperty(r)&&(t[r]=`metadata.${r}`)}return t}var t6="ProcessedAttributes attributes, Metadata metadata, float tiles3d_tileset_time";function zUe(e,t){let n=UUe,i={translucent:!1};return n.colorStyleFunction=e.getColorShaderFunction(`getColorFromStyle(${t6})`,t,i),n.showStyleFunction=e.getShowShaderFunction(`getShowFromStyle(${t6})`,t,i),n.pointSizeStyleFunction=e.getPointSizeShaderFunction(`getPointSizeFromStyle(${t6})`,t,i),n.styleTranslucent=u(n.colorStyleFunction)&&i.translucent,n}function HUe(e,t){let n=t.colorStyleFunction;u(n)&&(e.addDefine("HAS_POINT_CLOUD_COLOR_STYLE",void 0,Ee.BOTH),e.addVertexLines(n),e.addVarying("vec4","v_pointCloudColor"));let i=t.showStyleFunction;u(i)&&(e.addDefine("HAS_POINT_CLOUD_SHOW_STYLE",void 0,Ee.VERTEX),e.addVertexLines(i));let o=t.pointSizeStyleFunction;u(o)&&(e.addDefine("HAS_POINT_CLOUD_POINT_SIZE_STYLE",void 0,Ee.VERTEX),e.addVertexLines(o))}function n6(e,t){let n=/attributes\.(\w+)/g,i=n.exec(e);for(;i!==null;){let o=i[1];t.indexOf(o)===-1&&t.push(o),i=n.exec(e)}}function GUe(e){let t=e.colorStyleFunction,n=e.showStyleFunction,i=e.pointSizeStyleFunction,o=[];return u(t)&&n6(t,o),u(n)&&n6(n,o),u(i)&&n6(i,o),o}var pO=Hie;var _O=`void primitiveOutlineStage() {
v_outlineCoordinates = a_outlineCoordinates;
}
`;var gO=`void primitiveOutlineStage(inout czm_modelMaterial material) {
if (!model_showOutline) {
return;
}
float outlineX =
texture(model_outlineTexture, vec2(v_outlineCoordinates.x, 0.5)).r;
float outlineY =
texture(model_outlineTexture, vec2(v_outlineCoordinates.y, 0.5)).r;
float outlineZ =
texture(model_outlineTexture, vec2(v_outlineCoordinates.z, 0.5)).r;
float outlineness = max(outlineX, max(outlineY, outlineZ));
material.diffuse = mix(material.diffuse, model_outlineColor.rgb, model_outlineColor.a * outlineness);
}
`;var Gie={name:"PrimitiveOutlinePipelineStage"};Gie.process=function(e,t,n){let i=e.shaderBuilder,o=e.uniformMap;i.addDefine("HAS_PRIMITIVE_OUTLINE",void 0,Ee.BOTH),i.addAttribute("vec3","a_outlineCoordinates"),i.addVarying("vec3","v_outlineCoordinates");let r=t.outlineCoordinates,s={index:e.attributeIndex++,vertexBuffer:r.buffer,componentsPerAttribute:an.getNumberOfComponents(r.type),componentDatatype:r.componentDatatype,offsetInBytes:r.byteOffset,strideInBytes:r.byteStride,normalize:r.normalized};e.attributes.push(s),i.addUniform("sampler2D","model_outlineTexture",Ee.FRAGMENT);let a=IA.createTexture(n.context);o.model_outlineTexture=function(){return a};let c=e.model;i.addUniform("vec4","model_outlineColor",Ee.FRAGMENT),o.model_outlineColor=function(){return c.outlineColor},i.addUniform("bool","model_showOutline",Ee.FRAGMENT),o.model_showOutline=function(){return c.showOutline},i.addVertexLines(_O),i.addFragmentLines(gO)};var yO=Gie;var Wie={name:"PrimitiveStatisticsPipelineStage",_countGeometry:jie,_count2DPositions:Yie,_countMorphTargetAttributes:qie,_countMaterialTextures:Xie,_countFeatureIdTextures:Kie,_countBinaryMetadata:Jie};Wie.process=function(e,t,n){let i=e.model,o=i.statistics;jie(o,t),Yie(o,e.runtimePrimitive),qie(o,t),Xie(o,t.material),Kie(o,t.featureIds),Jie(o,i)};function jie(e,t){let n=u(t.indices)?t.indices.count:Qt.getAttributeBySemantic(t,"POSITION").count,i=t.primitiveType;i===Le.POINTS?e.pointsLength+=n:Le.isTriangles(i)&&(e.trianglesLength+=WUe(i,n));let o=t.attributes,r=o.length;for(let c=0;c<r;c++){let l=o[c];if(u(l.buffer)){let f=u(l.typedArray);e.addBuffer(l.buffer,f)}}let s=t.outlineCoordinates;u(s)&&u(s.buffer)&&e.addBuffer(s.buffer,!1);let a=t.indices;if(u(a)&&u(a.buffer)){let c=u(a.typedArray);e.addBuffer(a.buffer,c)}}function WUe(e,t){switch(e){case Le.TRIANGLES:return t/3;case Le.TRIANGLE_STRIP:case Le.TRIANGLE_FAN:return Math.max(t-2,0);default:return 0}}function Yie(e,t){let n=t.positionBuffer2D;u(n)&&e.addBuffer(n,!0)}function qie(e,t){let n=t.morphTargets;if(!u(n))return;let i=!1,o=n.length;for(let r=0;r<o;r++){let s=n[r].attributes,a=s.length;for(let c=0;c<a;c++){let l=s[c];u(l.buffer)&&e.addBuffer(l.buffer,i)}}}function Xie(e,t){let n=jUe(t),i=n.length;for(let o=0;o<i;o++){let r=n[o];u(r)&&u(r.texture)&&e.addTexture(r.texture)}}function jUe(e){let t=e.metallicRoughness,n=[e.emissiveTexture,e.normalTexture,e.occlusionTexture,t.baseColorTexture,t.metallicRoughnessTexture],i=e.specularGlossiness;return u(i)&&(n.push(i.diffuseTexture),n.push(i.specularGlossinessTexture)),n}function Kie(e,t){let n=t.length;for(let i=0;i<n;i++){let o=t[i];if(o instanceof Bt.FeatureIdTexture){let r=o.textureReader;u(r.texture)&&e.addTexture(r.texture)}}}function Jie(e,t){let n=t.structuralMetadata;u(n)&&(YUe(e,n),e.propertyTablesByteLength+=n.propertyTablesByteLength);let i=t.featureTables;if(!u(i))return;let o=i.length;for(let r=0;r<o;r++){let s=i[r];e.addBatchTexture(s.batchTexture)}}function YUe(e,t){let n=t.propertyTextures;if(!u(n))return;let i=n.length;for(let o=0;o<i;o++){let s=n[o].properties;for(let a in s)if(s.hasOwnProperty(a)){let l=s[a].textureReader;u(l.texture)&&e.addTexture(l.texture)}}}var AO=Wie;var qUe=new B,XUe=new B,Zie={name:"SceneMode2DPipelineStage"};Zie.process=function(e,t,n){let i=Qt.getAttributeBySemantic(t,Tt.POSITION),o=e.shaderBuilder,r=e.model,s=r.sceneGraph.computedModelMatrix,a=e.runtimeNode.computedTransform,c=B.multiplyTransformation(s,a,qUe),l=ZUe(e,c,n),f=e.runtimePrimitive;f.boundingSphere2D=l;let d=e.runtimeNode.node.instances;if(u(d))return;if(u(i.typedArray)){let A=eVe(i,c,l,n);f.positionBuffer2D=A,r._modelResources.push(A),i.typedArray=void 0}o.addDefine("USE_2D_POSITIONS",void 0,Ee.VERTEX),o.addUniform("mat4","u_modelView2D",Ee.VERTEX);let p=B.fromTranslation(l.center,new B),g=n.context,h={u_modelView2D:function(){return B.multiplyTransformation(g.uniformState.view,p,XUe)}};e.uniformMap=ht(h,e.uniformMap)};var KUe=new m,JUe=new m;function ZUe(e,t,n){let i=B.multiplyByPoint(t,e.positionMin,KUe),o=Ki.computeActualWgs84Position(n,i,i),r=B.multiplyByPoint(t,e.posi
{
mat4 skinningMatrix = getSkinningMatrix();
mat3 skinningMatrixMat3 = mat3(skinningMatrix);
vec4 positionMC = vec4(attributes.positionMC, 1.0);
attributes.positionMC = vec3(skinningMatrix * positionMC);
#ifdef HAS_NORMALS
vec3 normalMC = attributes.normalMC;
attributes.normalMC = skinningMatrixMat3 * normalMC;
#endif
#ifdef HAS_TANGENTS
vec3 tangentMC = attributes.tangentMC;
attributes.tangentMC = skinningMatrixMat3 * tangentMC;
#endif
}`;var LA={name:"SkinningPipelineStage",FUNCTION_ID_GET_SKINNING_MATRIX:"getSkinningMatrix",FUNCTION_SIGNATURE_GET_SKINNING_MATRIX:"mat4 getSkinningMatrix()"};LA.process=function(e,t){let n=e.shaderBuilder;n.addDefine("HAS_SKINNING",void 0,Ee.VERTEX),nVe(n,t);let i=e.runtimeNode,o=i.computedJointMatrices;n.addUniform("mat4",`u_jointMatrices[${o.length}]`,Ee.VERTEX),n.addVertexLines(CO);let r={u_jointMatrices:function(){return i.computedJointMatrices}};e.uniformMap=ht(r,e.uniformMap)};function tVe(e){let t=-1,n=e.attributes,i=n.length;for(let o=0;o<i;o++){let r=n[o];(r.semantic===Tt.JOINTS||r.semantic===Tt.WEIGHTS)&&(t=Math.max(t,r.setIndex))}return t}function nVe(e,t){e.addFunction(LA.FUNCTION_ID_GET_SKINNING_MATRIX,LA.FUNCTION_SIGNATURE_GET_SKINNING_MATRIX,Ee.VERTEX);let n="mat4 skinnedMatrix = mat4(0);";e.addFunctionLines(LA.FUNCTION_ID_GET_SKINNING_MATRIX,[n]);let i,o,r=["x","y","z","w"],s=tVe(t);for(i=0;i<=s;i++)for(o=0;o<=3;o++){let c=r[o],l=`skinnedMatrix += a_weights_${i}.${c} * u_jointMatrices[int(a_joints_${i}.${c})];`;e.addFunctionLines(LA.FUNCTION_ID_GET_SKINNING_MATRIX,[l])}let a="return skinnedMatrix;";e.addFunctionLines(LA.FUNCTION_ID_GET_SKINNING_MATRIX,[a])}var TO=LA;var i6={};function iVe(e){let t=Ue.createTypedArray(e,e*2),n=e,i=0;for(let o=0;o<n;o+=3)t[i++]=o,t[i++]=o+1,t[i++]=o+1,t[i++]=o+2,t[i++]=o+2,t[i++]=o;return t}function oVe(e,t){let n=t.length,i=Ue.createTypedArray(e,n*2),o=0;for(let r=0;r<n;r+=3){let s=t[r],a=t[r+1],c=t[r+2];i[o++]=s,i[o++]=a,i[o++]=a,i[o++]=c,i[o++]=c,i[o++]=s}return i}function rVe(e){let t=e-2,n=2+t*4,i=Ue.createTypedArray(e,n),o=0;i[o++]=0,i[o++]=1;for(let r=0;r<t;r++)i[o++]=r+1,i[o++]=r+2,i[o++]=r+2,i[o++]=r;return i}function sVe(e,t){let i=t.length-2,o=2+i*4,r=Ue.createTypedArray(e,o),s=0;r[s++]=t[0],r[s++]=t[1];for(let a=0;a<i;a++){let c=t[a],l=t[a+1],f=t[a+2];r[s++]=l,r[s++]=f,r[s++]=f,r[s++]=c}return r}function aVe(e){let t=e-2,n=2+t*4,i=Ue.createTypedArray(e,n),o=0;i[o++]=0,i[o++]=1;for(let r=0;r<t;r++)i[o++]=r+1,i[o++]=r+2,i[o++]=r+2,i[o++]=0;return i}function cVe(e,t){let i=t.length-2,o=2+i*4,r=Ue.createTypedArray(e,o),s=0,a=t[0];r[s++]=a,r[s++]=t[1];for(let c=0;c<i;c++){let l=t[c+1],f=t[c+2];r[s++]=l,r[s++]=f,r[s++]=f,r[s++]=a}return r}i6.createWireframeIndices=function(e,t,n){let i=u(n);if(e===Le.TRIANGLES)return i?oVe(t,n):iVe(t);if(e===Le.TRIANGLE_STRIP)return i?sVe(t,n):rVe(t);if(e===Le.TRIANGLE_FAN)return i?cVe(t,n):aVe(t)};i6.getWireframeIndicesCount=function(e,t){return e===Le.TRIANGLES?t*2:e===Le.TRIANGLE_STRIP||e===Le.TRIANGLE_FAN?2+(t-2)*4:t};var nE=i6;var $ie={name:"WireframePipelineStage"};$ie.process=function(e,t,n){e.shaderBuilder.addDefine("HAS_WIREFRAME",void 0,Ee.FRAGMENT);let o=e.model,r=lVe(t,e.indices,n);o._pipelineResources.push(r),e.wireframeIndexBuffer=r;let s=!1;o.statistics.addBuffer(r,s);let a=e.primitiveType,c=e.count;e.primitiveType=Le.LINES,e.count=nE.getWireframeIndicesCount(a,c)};function lVe(e,t,n){let o=Qt.getAttributeBySemantic(e,Tt.POSITION).count,r=n.context.webgl2,s;if(u(t)){let f=t.buffer,d=t.count;u(f)&&r?(s=f.sizeInBytes===d?new Uint8Array(d):Ue.createTypedArray(o,d),f.getBufferData(s)):s=t.typedArray}let a=e.primitiveType,c=nE.createWireframeIndices(a,o,s),l=Ue.fromSizeInBytes(c.BYTES_PER_ELEMENT);return ut.createIndexBuffer({context:n.context,typedArray:c,usage:Fe.STATIC_DRAW,indexDatatype:l})}var EO=$ie;function eoe(e){e=y(e,y.EMPTY_OBJECT);let t=e.primitive,n=e.node,i=e.model;this.primitive=t,this.node=n,this.model=i,this.pipelineStages=[],this.drawCommand=void 0,this.boundingSphere=void 0,this.boundingSphere2D=void 0,this.positionBuffer2D=void 0,this.batchLengths=void 0,this.batchOffsets=void 0,this.updateStages=[]}eoe.prototype.configurePipeline=function(e){let t=this.pipelineStages;t.length=0;let n=this.primitive,i=this.node,o=this.model,r=o.customShader,s=o.style,a=e.context.webgl2,l=e.mode!==ne.SCENE3D&&!e.scene3DOnly&&o._projectTo2D,f=u(n.morphTargets)&&n.morphTargets.length>0,d=u(i.skin),p=u(r),h=!(p&&u(r.fragmentShaderText))||r.mode!==Bp.REPLACE_MATERIAL,A=Qt.hasQuantizedAttributes(n.attributes),x=o.debugWirefra
`),r=new He({defines:this._vertexShaderParts.defineLines,sources:[o]}),s=this._fragmentShaderParts.uniformLines.concat(this._fragmentShaderParts.varyingLines,n.fragmentLines,i.fragmentLines,this._fragmentShaderParts.shaderLines).join(`
`),a=new He({defines:this._fragmentShaderParts.defineLines,sources:[s]});return Jt.fromCache({context:e,vertexShaderSource:r,fragmentShaderSource:a,attributeLocations:this._attributeLocations})};Nc.prototype.clone=function(){return je(this,!0)};function mVe(e){let t=[],n=[],i,o=e._vertexShaderParts.structIds,r,s,a;for(i=0;i<o.length;i++)r=o[i],s=e._structs[r],a=s.generateGlslLines(),t.push.apply(t,a);for(o=e._fragmentShaderParts.structIds,i=0;i<o.length;i++)r=o[i],s=e._structs[r],a=s.generateGlslLines(),n.push.apply(n,a);return{vertexLines:t,fragmentLines:n}}function hVe(e){switch(e){case"mat2":return 2;case"mat3":return 3;case"mat4":return 4;default:return 1}}function pVe(e){let t=[],n=[],i,o=e._vertexShaderParts.functionIds,r,s,a;for(i=0;i<o.length;i++)r=o[i],s=e._functions[r],a=s.generateGlslLines(),t.push.apply(t,a);for(o=e._fragmentShaderParts.functionIds,i=0;i<o.length;i++)r=o[i],s=e._functions[r],a=s.generateGlslLines(),n.push.apply(n,a);return{vertexLines:t,fragmentLines:n}}var NA=Nc;function _Ve(e){this.shaderBuilder=new NA,this.model=e,this.uniformMap={},this.alphaOptions=new vO,this.renderStateOptions=ke.getState(ke.fromCache({depthTest:{enabled:!0,func:Ha.LESS_OR_EQUAL}})),this.hasSilhouette=!1,this.hasSkipLevelOfDetail=!1}var IO=_Ve;var PO=`void silhouetteStage(inout vec4 color) {
if(model_silhouettePass) {
color = czm_gammaCorrect(model_silhouetteColor);
}
}`;var OO=`void silhouetteStage(in ProcessedAttributes attributes, inout vec4 positionClip) {
#ifdef HAS_NORMALS
if(model_silhouettePass) {
vec3 normal = normalize(czm_normal3D * attributes.normalMC);
normal.x *= czm_projection[0][0];
normal.y *= czm_projection[1][1];
positionClip.xy += normal.xy * positionClip.w * model_silhouetteSize * czm_pixelRatio / czm_viewport.z;
}
#endif
}
`;var XU={name:"ModelSilhouettePipelineStage"};XU.silhouettesLength=0;XU.process=function(e,t,n){u(t._silhouetteId)||(t._silhouetteId=++XU.silhouettesLength);let i=e.shaderBuilder;i.addDefine("HAS_SILHOUETTE",void 0,Ee.BOTH),i.addVertexLines(OO),i.addFragmentLines(PO),i.addUniform("vec4","model_silhouetteColor",Ee.FRAGMENT),i.addUniform("float","model_silhouetteSize",Ee.VERTEX),i.addUniform("bool","model_silhouettePass",Ee.BOTH);let o={model_silhouetteColor:function(){return t.silhouetteColor},model_silhouetteSize:function(){return t.silhouetteSize},model_silhouettePass:function(){return!1}};e.uniformMap=ht(o,e.uniformMap),e.hasSilhouette=!0};var MO=XU;var RO=`void modelSplitterStage()
{
// Don't split when rendering the shadow map, because it is rendered from
// the perspective of a totally different camera.
#ifndef SHADOW_MAP
if (model_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;
if (model_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
#endif
}
`;var KU={name:"ModelSplitterPipelineStage",SPLIT_DIRECTION_UNIFORM_NAME:"model_splitDirection"};KU.process=function(e,t,n){let i=e.shaderBuilder;i.addDefine("HAS_MODEL_SPLITTER",void 0,Ee.FRAGMENT),i.addFragmentLines(RO);let o={};i.addUniform("float",KU.SPLIT_DIRECTION_UNIFORM_NAME,Ee.FRAGMENT),o[KU.SPLIT_DIRECTION_UNIFORM_NAME]=function(){return t.splitDirection},e.uniformMap=ht(o,e.uniformMap)};var BO=KU;function gVe(e,t){this.model=e.model,this.shaderBuilder=e.shaderBuilder.clone(),this.uniformMap=je(e.uniformMap),this.alphaOptions=je(e.alphaOptions),this.renderStateOptions=je(e.renderStateOptions,!0),this.hasSilhouette=e.hasSilhouette,this.hasSkipLevelOfDetail=e.hasSkipLevelOfDetail,this.runtimeNode=t,this.attributes=[],this.attributeIndex=1,this.featureIdVertexAttributeSetIndex=0,this.instanceCount=0}var LO=gVe;function yVe(e){e=y(e,y.EMPTY_OBJECT),this.lightingModel=y(e.lightingModel,zm.UNLIT)}var NO=yVe;function AVe(e,t){this.model=e.model,this.runtimeNode=e.runtimeNode,this.attributes=e.attributes.slice(),this.attributeIndex=e.attributeIndex,this.featureIdVertexAttributeSetIndex=e.featureIdVertexAttributeSetIndex,this.uniformMap=je(e.uniformMap),this.alphaOptions=je(e.alphaOptions),this.renderStateOptions=je(e.renderStateOptions,!0),this.hasSilhouette=e.hasSilhouette,this.hasSkipLevelOfDetail=e.hasSkipLevelOfDetail,this.shaderBuilder=e.shaderBuilder.clone(),this.instanceCount=e.instanceCount,this.runtimePrimitive=t;let n=t.primitive;this.count=u(n.indices)?n.indices.count:Qt.getAttributeBySemantic(n,"POSITION").count,this.hasPropertyTable=!1,this.indices=n.indices,this.wireframeIndexBuffer=void 0,this.primitiveType=n.primitiveType;let i=Qt.getPositionMinMax(n,this.runtimeNode.instancingTranslationMin,this.runtimeNode.instancingTranslationMax);this.positionMin=m.clone(i.min,new m),this.positionMax=m.clone(i.max,new m),this.boundingSphere=ae.fromCornerPoints(this.positionMin,this.positionMax,new ae),this.lightingOptions=new NO,this.pickId=void 0}var FO=AVe;function tu(e){e=y(e,y.EMPTY_OBJECT);let t=e.modelComponents;this._model=e.model,this._components=t,this._pipelineStages=[],this._updateStages=[],this._runtimeNodes=[],this._rootNodes=[],this._skinnedNodes=[],this._runtimeSkins=[],this.modelPipelineStages=[],this._boundingSphere=void 0,this._boundingSphere2D=void 0,this._computedModelMatrix=B.clone(B.IDENTITY),this._computedModelMatrix2D=B.clone(B.IDENTITY),this._axisCorrectionMatrix=Qt.getAxisCorrectionMatrix(t.upAxis,t.forwardAxis,new B),this._runtimeArticulations={},xVe(this)}Object.defineProperties(tu.prototype,{components:{get:function(){return this._components}},computedModelMatrix:{get:function(){return this._computedModelMatrix}},axisCorrectionMatrix:{get:function(){return this._axisCorrectionMatrix}},boundingSphere:{get:function(){return this._boundingSphere}}});function xVe(e){let t=e._components,n=t.scene,o=e._model.modelMatrix;noe(e,o);let r=t.articulations,s=r.length,a=e._runtimeArticulations;for(let T=0;T<s;T++){let E=r[T],S=new I1({articulation:E,sceneGraph:e}),w=S.name;a[w]=S}let c=t.nodes,l=c.length;e._runtimeNodes=new Array(l);let d=n.nodes.length,p=B.IDENTITY;for(let T=0;T<d;T++){let E=n.nodes[T],S=ioe(e,E,p);e._rootNodes.push(S)}let g=t.skins,h=e._runtimeSkins,A=g.length;for(let T=0;T<A;T++){let E=g[T];h.push(new SO({skin:E,sceneGraph:e}))}let x=e._skinnedNodes,C=x.length;for(let T=0;T<C;T++){let E=x[T],S=e._runtimeNodes[E],D=c[E].skin.index;S._runtimeSkin=h[D],S.updateJointMatrices()}e.applyArticulations()}function noe(e,t){let n=e._components,i=e._model;e._computedModelMatrix=B.multiplyTransformation(t,n.transform,e._computedModelMatrix),e._computedModelMatrix=B.multiplyTransformation(e._computedModelMatrix,e._axisCorrectionMatrix,e._computedModelMatrix),e._computedModelMatrix=B.multiplyByUniformScale(e._computedModelMatrix,i.computedScale,e._computedModelMatrix)}var CVe=new m;function TVe(e,t){let n=e._computedModelMatrix,i=B.getTranslation(n,CVe);if(!m.equals(i,m.ZERO))e._computedModelMatrix2D=Ot.basisTo2D(t.mapProjection,n,e._computedModelMatrix2D);else{let o=e.boundingSphere.center,r=O
#extension GL_OES_standard_derivatives : enable
#endif
uniform sampler2D u_atlas;
#ifdef VECTOR_TILE
uniform vec4 u_highlightColor;
#endif
in vec2 v_textureCoordinates;
in vec4 v_pickColor;
in vec4 v_color;
#ifdef SDF
in vec4 v_outlineColor;
in float v_outlineWidth;
#endif
#ifdef FRAGMENT_DEPTH_CHECK
in vec4 v_textureCoordinateBounds; // the min and max x and y values for the texture coordinates
in vec4 v_originTextureCoordinateAndTranslate; // texture coordinate at the origin, billboard translate (used for label glyphs)
in vec4 v_compressed; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize
in mat2 v_rotationMatrix;
const float SHIFT_LEFT12 = 4096.0;
const float SHIFT_LEFT1 = 2.0;
const float SHIFT_RIGHT12 = 1.0 / 4096.0;
const float SHIFT_RIGHT1 = 1.0 / 2.0;
float getGlobeDepth(vec2 adjustedST, vec2 depthLookupST, bool applyTranslate, vec2 dimensions, vec2 imageSize)
{
vec2 lookupVector = imageSize * (depthLookupST - adjustedST);
lookupVector = v_rotationMatrix * lookupVector;
vec2 labelOffset = (dimensions - imageSize) * (depthLookupST - vec2(0.0, v_originTextureCoordinateAndTranslate.y)); // aligns label glyph with bounding rectangle. Will be zero for billboards because dimensions and imageSize will be equal
vec2 translation = v_originTextureCoordinateAndTranslate.zw;
if (applyTranslate)
{
// this is only needed for labels where the horizontal origin is not LEFT
// it moves the label back to where the "origin" should be since all label glyphs are set to HorizontalOrigin.LEFT
translation += (dimensions * v_originTextureCoordinateAndTranslate.xy * vec2(1.0, 0.0));
}
vec2 st = ((lookupVector - translation + labelOffset) + gl_FragCoord.xy) / czm_viewport.zw;
float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, st));
if (logDepthOrDepth == 0.0)
{
return 0.0; // not on the globe
}
vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);
return eyeCoordinate.z / eyeCoordinate.w;
}
#endif
#ifdef SDF
// Get the distance from the edge of a glyph at a given position sampling an SDF texture.
float getDistance(vec2 position)
{
return texture(u_atlas, position).r;
}
// Samples the sdf texture at the given position and produces a color based on the fill color and the outline.
vec4 getSDFColor(vec2 position, float outlineWidth, vec4 outlineColor, float smoothing)
{
float distance = getDistance(position);
if (outlineWidth > 0.0)
{
// Don't get the outline edge exceed the SDF_EDGE
float outlineEdge = clamp(SDF_EDGE - outlineWidth, 0.0, SDF_EDGE);
float outlineFactor = smoothstep(SDF_EDGE - smoothing, SDF_EDGE + smoothing, distance);
vec4 sdfColor = mix(outlineColor, v_color, outlineFactor);
float alpha = smoothstep(outlineEdge - smoothing, outlineEdge + smoothing, distance);
return vec4(sdfColor.rgb, sdfColor.a * alpha);
}
else
{
float alpha = smoothstep(SDF_EDGE - smoothing, SDF_EDGE + smoothing, distance);
return vec4(v_color.rgb, v_color.a * alpha);
}
}
#endif
void main()
{
vec4 color = texture(u_atlas, v_textureCoordinates);
#ifdef SDF
float outlineWidth = v_outlineWidth;
vec4 outlineColor = v_outlineColor;
// Get the current distance
float distance = getDistance(v_textureCoordinates);
#if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
float smoothing = fwidth(distance);
// Get an offset that is approximately half the distance to the neighbor pixels
// 0.354 is approximately half of 1/sqrt(2)
vec2 sampleOffset = 0.354 * vec2(dFdx(v_textureCoordinates) + dFdy(v_textureCoordinates));
// Sample the center point
vec4 center = getSDFColor(v_textureCoordinates, outlineWidth, outlineColor, smoothing);
// Sample the 4 neighbors
vec4 color1 = getSDFColor(v_textureCoordinates + vec2(sampleOffset.x, sampleOffset.y), outlineWidth, outlineColor, smoothing);
vec4 color2 = getSDFColor(v_textureCoordinates + vec2(-sampleOffset.x, sampleOffset.y), outlineWidth, outlineColor, smoothing);
vec4 color3 = getSDFColor(v_textureCoordinates + vec2(-sampleOffset.x, -sampleOffset.y), outlineWidth, outlineColor, smoothing);
vec4 color4 = getSDFColor(v_textureCoordinates + vec2(sampleOffset.x, -sampleOffset.y), outlineWidth, outlineColor, smoothing);
// Equally weight the center sample and the 4 neighboring samples
color = (center + color1 + color2 + color3 + color4)/5.0;
#else
// If no derivatives available (IE 10?), just do a single sample
float smoothing = 1.0/32.0;
color = getSDFColor(v_textureCoordinates, outlineWidth, outlineColor, smoothing);
#endif
color = czm_gammaCorrect(color);
#else
color = czm_gammaCorrect(color);
color *= czm_gammaCorrect(v_color);
#endif
// Fully transparent parts of the billboard are not pickable.
#if !defined(OPAQUE) && !defined(TRANSLUCENT)
if (color.a < 0.005) // matches 0/255 and 1/255
{
discard;
}
#else
// The billboard is rendered twice. The opaque pass discards translucent fragments
// and the translucent pass discards opaque fragments.
#ifdef OPAQUE
if (color.a < 0.995) // matches < 254/255
{
discard;
}
#else
if (color.a >= 0.995) // matches 254/255 and 255/255
{
discard;
}
#endif
#endif
#ifdef VECTOR_TILE
color *= u_highlightColor;
#endif
out_FragColor = color;
#ifdef LOG_DEPTH
czm_writeLogDepth();
#endif
#ifdef FRAGMENT_DEPTH_CHECK
float temp = v_compressed.y;
temp = temp * SHIFT_RIGHT1;
float temp2 = (temp - floor(temp)) * SHIFT_LEFT1;
bool enableDepthTest = temp2 != 0.0;
bool applyTranslate = floor(temp) != 0.0;
if (enableDepthTest) {
temp = v_compressed.z;
temp = temp * SHIFT_RIGHT12;
vec2 dimensions;
dimensions.y = (temp - floor(temp)) * SHIFT_LEFT12;
dimensions.x = floor(temp);
temp = v_compressed.w;
temp = temp * SHIFT_RIGHT12;
vec2 imageSize;
imageSize.y = (temp - floor(temp)) * SHIFT_LEFT12;
imageSize.x = floor(temp);
vec2 adjustedST = v_textureCoordinates - v_textureCoordinateBounds.xy;
adjustedST = adjustedST / vec2(v_textureCoordinateBounds.z - v_textureCoordinateBounds.x, v_textureCoordinateBounds.w - v_textureCoordinateBounds.y);
float epsilonEyeDepth = v_compressed.x + czm_epsilon1;
float globeDepth1 = getGlobeDepth(adjustedST, v_originTextureCoordinateAndTranslate.xy, applyTranslate, dimensions, imageSize);
// negative values go into the screen
if (globeDepth1 != 0.0 && globeDepth1 > epsilonEyeDepth)
{
float globeDepth2 = getGlobeDepth(adjustedST, vec2(0.0, 1.0), applyTranslate, dimensions, imageSize); // top left corner
if (globeDepth2 != 0.0 && globeDepth2 > epsilonEyeDepth)
{
float globeDepth3 = getGlobeDepth(adjustedST, vec2(1.0, 1.0), applyTranslate, dimensions, imageSize); // top right corner
if (globeDepth3 != 0.0 && globeDepth3 > epsilonEyeDepth)
{
discard;
}
}
}
}
#endif
}
`;var WO=`#ifdef INSTANCED
in vec2 direction;
#endif
in vec4 positionHighAndScale;
in vec4 positionLowAndRotation;
in vec4 compressedAttribute0; // pixel offset, translate, horizontal origin, vertical origin, show, direction, texture coordinates (texture offset)
in vec4 compressedAttribute1; // aligned axis, translucency by distance, image width
in vec4 compressedAttribute2; // label horizontal origin, image height, color, pick color, size in meters, valid aligned axis, 13 bits free
in vec4 eyeOffset; // eye offset in meters, 4 bytes free (texture range)
in vec4 scaleByDistance; // near, nearScale, far, farScale
in vec4 pixelOffsetScaleByDistance; // near, nearScale, far, farScale
in vec4 compressedAttribute3; // distance display condition near, far, disableDepthTestDistance, dimensions
in vec2 sdf; // sdf outline color (rgb) and width (w)
#if defined(VERTEX_DEPTH_CHECK) || defined(FRAGMENT_DEPTH_CHECK)
in vec4 textureCoordinateBoundsOrLabelTranslate; // the min and max x and y values for the texture coordinates
#endif
#ifdef VECTOR_TILE
in float a_batchId;
#endif
out vec2 v_textureCoordinates;
#ifdef FRAGMENT_DEPTH_CHECK
out vec4 v_textureCoordinateBounds;
out vec4 v_originTextureCoordinateAndTranslate;
out vec4 v_compressed; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize
out mat2 v_rotationMatrix;
#endif
out vec4 v_pickColor;
out vec4 v_color;
#ifdef SDF
out vec4 v_outlineColor;
out float v_outlineWidth;
#endif
const float UPPER_BOUND = 32768.0;
const float SHIFT_LEFT16 = 65536.0;
const float SHIFT_LEFT12 = 4096.0;
const float SHIFT_LEFT8 = 256.0;
const float SHIFT_LEFT7 = 128.0;
const float SHIFT_LEFT5 = 32.0;
const float SHIFT_LEFT3 = 8.0;
const float SHIFT_LEFT2 = 4.0;
const float SHIFT_LEFT1 = 2.0;
const float SHIFT_RIGHT12 = 1.0 / 4096.0;
const float SHIFT_RIGHT8 = 1.0 / 256.0;
const float SHIFT_RIGHT7 = 1.0 / 128.0;
const float SHIFT_RIGHT5 = 1.0 / 32.0;
const float SHIFT_RIGHT3 = 1.0 / 8.0;
const float SHIFT_RIGHT2 = 1.0 / 4.0;
const float SHIFT_RIGHT1 = 1.0 / 2.0;
vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 direction, vec2 origin, vec2 translate, vec2 pixelOffset, vec3 alignedAxis, bool validAlignedAxis, float rotation, bool sizeInMeters, out mat2 rotationMatrix, out float mpp)
{
// Note the halfSize cannot be computed in JavaScript because it is sent via
// compressed vertex attributes that coerce it to an integer.
vec2 halfSize = imageSize * scale * 0.5;
halfSize *= ((direction * 2.0) - 1.0);
vec2 originTranslate = origin * abs(halfSize);
#if defined(ROTATION) || defined(ALIGNED_AXIS)
if (validAlignedAxis || rotation != 0.0)
{
float angle = rotation;
if (validAlignedAxis)
{
vec4 projectedAlignedAxis = czm_modelView3D * vec4(alignedAxis, 0.0);
angle += sign(-projectedAlignedAxis.x) * acos(sign(projectedAlignedAxis.y) * (projectedAlignedAxis.y * projectedAlignedAxis.y) /
(projectedAlignedAxis.x * projectedAlignedAxis.x + projectedAlignedAxis.y * projectedAlignedAxis.y));
}
float cosTheta = cos(angle);
float sinTheta = sin(angle);
rotationMatrix = mat2(cosTheta, sinTheta, -sinTheta, cosTheta);
halfSize = rotationMatrix * halfSize;
}
else
{
rotationMatrix = mat2(1.0, 0.0, 0.0, 1.0);
}
#endif
mpp = czm_metersPerPixel(positionEC);
positionEC.xy += (originTranslate + halfSize) * czm_branchFreeTernary(sizeInMeters, 1.0, mpp);
positionEC.xy += (translate + pixelOffset) * mpp;
return positionEC;
}
#ifdef VERTEX_DEPTH_CHECK
float getGlobeDepth(vec4 positionEC)
{
vec4 posWC = czm_eyeToWindowCoordinates(positionEC);
float globeDepth = czm_unpackDepth(texture(czm_globeDepthTexture, posWC.xy / czm_viewport.zw));
if (globeDepth == 0.0)
{
return 0.0; // not on the globe
}
vec4 eyeCoordinate = czm_windowToEyeCoordinates(posWC.xy, globeDepth);
return eyeCoordinate.z / eyeCoordinate.w;
}
#endif
void main()
{
// Modifying this shader may also require modifications to Billboard._computeScreenSpacePosition
// unpack attributes
vec3 positionHigh = positionHighAndScale.xyz;
vec3 positionLow = positionLowAndRotation.xyz;
float scale = positionHighAndScale.w;
#if defined(ROTATION) || defined(ALIGNED_AXIS)
float rotation = positionLowAndRotation.w;
#else
float rotation = 0.0;
#endif
float compressed = compressedAttribute0.x;
vec2 pixelOffset;
pixelOffset.x = floor(compressed * SHIFT_RIGHT7);
compressed -= pixelOffset.x * SHIFT_LEFT7;
pixelOffset.x -= UPPER_BOUND;
vec2 origin;
origin.x = floor(compressed * SHIFT_RIGHT5);
compressed -= origin.x * SHIFT_LEFT5;
origin.y = floor(compressed * SHIFT_RIGHT3);
compressed -= origin.y * SHIFT_LEFT3;
#ifdef FRAGMENT_DEPTH_CHECK
vec2 depthOrigin = origin.xy;
#endif
origin -= vec2(1.0);
float show = floor(compressed * SHIFT_RIGHT2);
compressed -= show * SHIFT_LEFT2;
#ifdef INSTANCED
vec2 textureCoordinatesBottomLeft = czm_decompressTextureCoordinates(compressedAttribute0.w);
vec2 textureCoordinatesRange = czm_decompressTextureCoordinates(eyeOffset.w);
vec2 textureCoordinates = textureCoordinatesBottomLeft + direction * textureCoordinatesRange;
#else
vec2 direction;
direction.x = floor(compressed * SHIFT_RIGHT1);
direction.y = compressed - direction.x * SHIFT_LEFT1;
vec2 textureCoordinates = czm_decompressTextureCoordinates(compressedAttribute0.w);
#endif
float temp = compressedAttribute0.y * SHIFT_RIGHT8;
pixelOffset.y = -(floor(temp) - UPPER_BOUND);
vec2 translate;
translate.y = (temp - floor(temp)) * SHIFT_LEFT16;
temp = compressedAttribute0.z * SHIFT_RIGHT8;
translate.x = floor(temp) - UPPER_BOUND;
translate.y += (temp - floor(temp)) * SHIFT_LEFT8;
translate.y -= UPPER_BOUND;
temp = compressedAttribute1.x * SHIFT_RIGHT8;
float temp2 = floor(compressedAttribute2.w * SHIFT_RIGHT2);
vec2 imageSize = vec2(floor(temp), temp2);
#ifdef FRAGMENT_DEPTH_CHECK
float labelHorizontalOrigin = floor(compressedAttribute2.w - (temp2 * SHIFT_LEFT2));
float applyTranslate = 0.0;
if (labelHorizontalOrigin != 0.0) // is a billboard, so set apply translate to false
{
applyTranslate = 1.0;
labelHorizontalOrigin -= 2.0;
depthOrigin.x = labelHorizontalOrigin + 1.0;
}
depthOrigin = vec2(1.0) - (depthOrigin * 0.5);
#endif
#ifdef EYE_DISTANCE_TRANSLUCENCY
vec4 translucencyByDistance;
translucencyByDistance.x = compressedAttribute1.z;
translucencyByDistance.z = compressedAttribute1.w;
translucencyByDistance.y = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;
temp = compressedAttribute1.y * SHIFT_RIGHT8;
translucencyByDistance.w = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;
#endif
#if defined(VERTEX_DEPTH_CHECK) || defined(FRAGMENT_DEPTH_CHECK)
temp = compressedAttribute3.w;
temp = temp * SHIFT_RIGHT12;
vec2 dimensions;
dimensions.y = (temp - floor(temp)) * SHIFT_LEFT12;
dimensions.x = floor(temp);
#endif
#ifdef ALIGNED_AXIS
vec3 alignedAxis = czm_octDecode(floor(compressedAttribute1.y * SHIFT_RIGHT8));
temp = compressedAttribute2.z * SHIFT_RIGHT5;
bool validAlignedAxis = (temp - floor(temp)) * SHIFT_LEFT1 > 0.0;
#else
vec3 alignedAxis = vec3(0.0);
bool validAlignedAxis = false;
#endif
vec4 pickColor;
vec4 color;
temp = compressedAttribute2.y;
temp = temp * SHIFT_RIGHT8;
pickColor.b = (temp - floor(temp)) * SHIFT_LEFT8;
temp = floor(temp) * SHIFT_RIGHT8;
pickColor.g = (temp - floor(temp)) * SHIFT_LEFT8;
pickColor.r = floor(temp);
temp = compressedAttribute2.x;
temp = temp * SHIFT_RIGHT8;
color.b = (temp - floor(temp)) * SHIFT_LEFT8;
temp = floor(temp) * SHIFT_RIGHT8;
color.g = (temp - floor(temp)) * SHIFT_LEFT8;
color.r = floor(temp);
temp = compressedAttribute2.z * SHIFT_RIGHT8;
bool sizeInMeters = floor((temp - floor(temp)) * SHIFT_LEFT7) > 0.0;
temp = floor(temp) * SHIFT_RIGHT8;
pickColor.a = (temp - floor(temp)) * SHIFT_LEFT8;
pickColor /= 255.0;
color.a = floor(temp);
color /= 255.0;
///////////////////////////////////////////////////////////////////////////
vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);
vec4 positionEC = czm_modelViewRelativeToEye * p;
#if defined(FRAGMENT_DEPTH_CHECK) || defined(VERTEX_DEPTH_CHECK)
float eyeDepth = positionEC.z;
#endif
positionEC = czm_eyeOffset(positionEC, eyeOffset.xyz);
positionEC.xyz *= show;
///////////////////////////////////////////////////////////////////////////
#if defined(EYE_DISTANCE_SCALING) || defined(EYE_DISTANCE_TRANSLUCENCY) || defined(EYE_DISTANCE_PIXEL_OFFSET) || defined(DISTANCE_DISPLAY_CONDITION) || defined(DISABLE_DEPTH_DISTANCE)
float lengthSq;
if (czm_sceneMode == czm_sceneMode2D)
{
// 2D camera distance is a special case
// treat all billboards as flattened to the z=0.0 plane
lengthSq = czm_eyeHeight2D.y;
}
else
{
lengthSq = dot(positionEC.xyz, positionEC.xyz);
}
#endif
#ifdef EYE_DISTANCE_SCALING
float distanceScale = czm_nearFarScalar(scaleByDistance, lengthSq);
scale *= distanceScale;
translate *= distanceScale;
// push vertex behind near plane for clipping
if (scale == 0.0)
{
positionEC.xyz = vec3(0.0);
}
#endif
float translucency = 1.0;
#ifdef EYE_DISTANCE_TRANSLUCENCY
translucency = czm_nearFarScalar(translucencyByDistance, lengthSq);
// push vertex behind near plane for clipping
if (translucency == 0.0)
{
positionEC.xyz = vec3(0.0);
}
#endif
#ifdef EYE_DISTANCE_PIXEL_OFFSET
float pixelOffsetScale = czm_nearFarScalar(pixelOffsetScaleByDistance, lengthSq);
pixelOffset *= pixelOffsetScale;
#endif
#ifdef DISTANCE_DISPLAY_CONDITION
float nearSq = compressedAttribute3.x;
float farSq = compressedAttribute3.y;
if (lengthSq < nearSq || lengthSq > farSq)
{
positionEC.xyz = vec3(0.0);
}
#endif
mat2 rotationMatrix;
float mpp;
#ifdef DISABLE_DEPTH_DISTANCE
float disableDepthTestDistance = compressedAttribute3.z;
#endif
#ifdef VERTEX_DEPTH_CHECK
if (lengthSq < disableDepthTestDistance) {
float depthsilon = 10.0;
vec2 labelTranslate = textureCoordinateBoundsOrLabelTranslate.xy;
vec4 pEC1 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0), origin, labelTranslate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
float globeDepth1 = getGlobeDepth(pEC1);
if (globeDepth1 != 0.0 && pEC1.z + depthsilon < globeDepth1)
{
vec4 pEC2 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0, 1.0), origin, labelTranslate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
float globeDepth2 = getGlobeDepth(pEC2);
if (globeDepth2 != 0.0 && pEC2.z + depthsilon < globeDepth2)
{
vec4 pEC3 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(1.0), origin, labelTranslate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
float globeDepth3 = getGlobeDepth(pEC3);
if (globeDepth3 != 0.0 && pEC3.z + depthsilon < globeDepth3)
{
positionEC.xyz = vec3(0.0);
}
}
}
}
#endif
positionEC = addScreenSpaceOffset(positionEC, imageSize, scale, direction, origin, translate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
gl_Position = czm_projection * positionEC;
v_textureCoordinates = textureCoordinates;
#ifdef LOG_DEPTH
czm_vertexLogDepth();
#endif
#ifdef DISABLE_DEPTH_DISTANCE
if (disableDepthTestDistance == 0.0 && czm_minimumDisableDepthTestDistance != 0.0)
{
disableDepthTestDistance = czm_minimumDisableDepthTestDistance;
}
if (disableDepthTestDistance != 0.0)
{
// Don't try to "multiply both sides" by w. Greater/less-than comparisons won't work for negative values of w.
float zclip = gl_Position.z / gl_Position.w;
bool clipped = (zclip < -1.0 || zclip > 1.0);
if (!clipped && (disableDepthTestDistance < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistance)))
{
// Position z on the near plane.
gl_Position.z = -gl_Position.w;
#ifdef LOG_DEPTH
v_depthFromNearPlusOne = 1.0;
#endif
}
}
#endif
#ifdef FRAGMENT_DEPTH_CHECK
if (sizeInMeters) {
translate /= mpp;
dimensions /= mpp;
imageSize /= mpp;
}
#if defined(ROTATION) || defined(ALIGNED_AXIS)
v_rotationMatrix = rotationMatrix;
#else
v_rotationMatrix = mat2(1.0, 0.0, 0.0, 1.0);
#endif
float enableDepthCheck = 0.0;
if (lengthSq < disableDepthTestDistance)
{
enableDepthCheck = 1.0;
}
float dw = floor(clamp(dimensions.x, 0.0, SHIFT_LEFT12));
float dh = floor(clamp(dimensions.y, 0.0, SHIFT_LEFT12));
float iw = floor(clamp(imageSize.x, 0.0, SHIFT_LEFT12));
float ih = floor(clamp(imageSize.y, 0.0, SHIFT_LEFT12));
v_compressed.x = eyeDepth;
v_compressed.y = applyTranslate * SHIFT_LEFT1 + enableDepthCheck;
v_compressed.z = dw * SHIFT_LEFT12 + dh;
v_compressed.w = iw * SHIFT_LEFT12 + ih;
v_originTextureCoordinateAndTranslate.xy = depthOrigin;
v_originTextureCoordinateAndTranslate.zw = translate;
v_textureCoordinateBounds = textureCoordinateBoundsOrLabelTranslate;
#endif
#ifdef SDF
vec4 outlineColor;
float outlineWidth;
temp = sdf.x;
temp = temp * SHIFT_RIGHT8;
outlineColor.b = (temp - floor(temp)) * SHIFT_LEFT8;
temp = floor(temp) * SHIFT_RIGHT8;
outlineColor.g = (temp - floor(temp)) * SHIFT_LEFT8;
outlineColor.r = floor(temp);
temp = sdf.y;
temp = temp * SHIFT_RIGHT8;
float temp3 = (temp - floor(temp)) * SHIFT_LEFT8;
temp = floor(temp) * SHIFT_RIGHT8;
outlineWidth = (temp - floor(temp)) * SHIFT_LEFT8;
outlineColor.a = floor(temp);
outlineColor /= 255.0;
v_outlineWidth = outlineWidth / 255.0;
v_outlineColor = outlineColor;
v_outlineColor.a *= translucency;
#endif
v_pickColor = pickColor;
v_color = color;
v_color.a *= translucency;
}
`;function Ei(e,t){e=y(e,y.EMPTY_OBJECT);let n=e.translucencyByDistance,i=e.pixelOffsetScaleByDistance,o=e.scaleByDistance,r=e.distanceDisplayCondition;u(n)&&(n=Pt.clone(n)),u(i)&&(i=Pt.clone(i)),u(o)&&(o=Pt.clone(o)),u(r)&&(r=vt.clone(r)),this._show=y(e.show,!0),this._position=m.clone(y(e.position,m.ZERO)),this._actualPosition=m.clone(this._position),this._pixelOffset=H.clone(y(e.pixelOffset,H.ZERO)),this._translate=new H(0,0),this._eyeOffset=m.clone(y(e.eyeOffset,m.ZERO)),this._heightReference=y(e.heightReference,We.NONE),this._verticalOrigin=y(e.verticalOrigin,On.CENTER),this._horizontalOrigin=y(e.horizontalOrigin,pi.CENTER),this._scale=y(e.scale,1),this._color=k.clone(y(e.color,k.WHITE)),this._rotation=y(e.rotation,0),this._alignedAxis=m.clone(y(e.alignedAxis,m.ZERO)),this._width=e.width,this._height=e.height,this._scaleByDistance=o,this._translucencyByDistance=n,this._pixelOffsetScaleByDistance=i,this._sizeInMeters=y(e.sizeInMeters,!1),this._distanceDisplayCondition=r,this._disableDepthTestDistance=e.disableDepthTestDistance,this._id=e.id,this._collection=y(e.collection,t),this._pickId=void 0,this._pickPrimitive=y(e._pickPrimitive,this),this._billboardCollection=t,this._dirty=!1,this._index=-1,this._batchIndex=void 0,this._imageIndex=-1,this._imageIndexPromise=void 0,this._imageId=void 0,this._image=void 0,this._imageSubRegion=void 0,this._imageWidth=void 0,this._imageHeight=void 0,this._labelDimensions=void 0,this._labelHorizontalOrigin=void 0,this._labelTranslate=void 0;let s=e.image,a=e.imageId;u(s)&&(u(a)||(typeof s=="string"?a=s:u(s.src)?a=s.src:a=Hn()),this._imageId=a,this._image=s),u(e.imageSubRegion)&&(this._imageId=a,this._imageSubRegion=e.imageSubRegion),u(this._billboardCollection._textureAtlas)&&this._loadImage(),this._actualClampedPosition=void 0,this._removeCallbackFunc=void 0,this._mode=ne.SCENE3D,this._clusterShow=!0,this._outlineColor=k.clone(y(e.outlineColor,k.BLACK)),this._outlineWidth=y(e.outlineWidth,0),this._updateClamping()}var hoe=Ei.SHOW_INDEX=0,tV=Ei.POSITION_INDEX=1,Aoe=Ei.PIXEL_OFFSET_INDEX=2,zke=Ei.EYE_OFFSET_INDEX=3,Hke=Ei.HORIZONTAL_ORIGIN_INDEX=4,Gke=Ei.VERTICAL_ORIGIN_INDEX=5,Wke=Ei.SCALE_INDEX=6,nV=Ei.IMAGE_INDEX_INDEX=7,poe=Ei.COLOR_INDEX=8,jke=Ei.ROTATION_INDEX=9,Yke=Ei.ALIGNED_AXIS_INDEX=10,qke=Ei.SCALE_BY_DISTANCE_INDEX=11,Xke=Ei.TRANSLUCENCY_BY_DISTANCE_INDEX=12,Kke=Ei.PIXEL_OFFSET_SCALE_BY_DISTANCE_INDEX=13,Jke=Ei.DISTANCE_DISPLAY_CONDITION=14,Zke=Ei.DISABLE_DEPTH_DISTANCE=15;Ei.TEXTURE_COORDINATE_BOUNDS=16;var _oe=Ei.SDF_INDEX=17;Ei.NUMBER_OF_PROPERTIES=18;function Vo(e,t){let n=e._billboardCollection;u(n)&&(n._updateBillboard(e,t),e._dirty=!0)}Object.defineProperties(Ei.prototype,{show:{get:function(){return this._show},set:function(e){this._show!==e&&(this._show=e,Vo(this,hoe))}},position:{get:function(){return this._position},set:function(e){let t=this._position;m.equals(t,e)||(m.clone(e,t),m.clone(e,this._actualPosition),this._updateClamping(),Vo(this,tV))}},heightReference:{get:function(){return this._heightReference},set:function(e){let t=this._heightReference;e!==t&&(this._heightReference=e,this._updateClamping(),Vo(this,tV))}},pixelOffset:{get:function(){return this._pixelOffset},set:function(e){let t=this._pixelOffset;H.equals(t,e)||(H.clone(e,t),Vo(this,Aoe))}},scaleByDistance:{get:function(){return this._scaleByDistance},set:function(e){let t=this._scaleByDistance;Pt.equals(t,e)||(this._scaleByDistance=Pt.clone(e,t),Vo(this,qke))}},translucencyByDistance:{get:function(){return this._translucencyByDistance},set:function(e){let t=this._translucencyByDistance;Pt.equals(t,e)||(this._translucencyByDistance=Pt.clone(e,t),Vo(this,Xke))}},pixelOffsetScaleByDistance:{get:function(){return this._pixelOffsetScaleByDistance},set:function(e){let t=this._pixelOffsetScaleByDistance;Pt.equals(t,e)||(this._pixelOffsetScaleByDistance=Pt.clone(e,t),Vo(this,Kke))}},eyeOffset:{get:function(){return this._eyeOffset},set:function(e){let t=this._eyeOffset;m.equals(t,e)||(m.clone(e,t),Vo(this,zke))}},horizontalOrigin:{get:function(){return this._horizontalOrigin},set:function(e){this._hor
in vec2 v_textureCoordinates;
void main()
{
out_FragColor = texture(billboard_texture, v_textureCoordinates);
}
`,i=t.createViewportQuadCommand(n,{uniformMap:{billboard_texture:function(){return e._textureAtlas.texture}}});return i.pass=be.OVERLAY,i}var S4e=[];rf.prototype.update=function(e){if(g6(this),!this.show)return;let t=this._billboards,n=t.length,i=e.context;this._instanced=i.instancedArrays,Co=this._instanced?f4e:u4e,u6=this._instanced?m4e:d4e;let o=this._textureAtlas;if(!u(o)){o=this._textureAtlas=new zg({context:i});for(let O=0;O<n;++O)t[O]._loadImage()}let r=o.textureCoordinates;if(r.length===0)return;T4e(this,e),t=this._billboards,n=t.length;let s=this._billboardsToUpdate,a=this._billboardsToUpdateIndex,c=this._propertiesChanged,l=o.guid,f=this._createVertexArray||this._textureAtlasGUID!==l;this._textureAtlasGUID=l;let d,p=e.passes,g=p.pick;if(f||!g&&this.computeNewBuffersUsage()){this._createVertexArray=!1;for(let O=0;O<_6;++O)c[O]=0;if(this._vaf=this._vaf&&this._vaf.destroy(),n>0){this._vaf=p4e(i,n,this._buffersUsage,this._instanced,this._batchTable,this._sdf),d=this._vaf.writers;for(let O=0;O<n;++O){let L=this._billboards[O];L._dirty=!1,C4e(this,e,r,d,L)}this._vaf.commit(u6(i))}this._billboardsToUpdateIndex=0}else if(a>0){let O=S4e;O.length=0,(c[qO]||c[s4e]||c[r4e])&&O.push(Moe),(c[YO]||c[Eoe]||c[i4e]||c[o4e]||c[n4e])&&(O.push(Uoe),this._instanced&&O.push(p6)),(c[YO]||c[a4e]||c[woe])&&(O.push(Voe),O.push(h6)),(c[YO]||c[Soe])&&O.push(h6),c[boe]&&O.push(p6),c[voe]&&O.push(koe),c[Doe]&&O.push(zoe),(c[Ioe]||c[c4e]||c[YO]||c[qO])&&O.push(Hoe),(c[YO]||c[qO])&&O.push(Goe),c[Poe]&&O.push(Woe);let L=O.length;if(d=this._vaf.writers,a/n>.1){for(let N=0;N<a;++N){let _=s[N];_._dirty=!1;for(let b=0;b<L;++b)O[b](this,e,r,d,_)}this._vaf.commit(u6(i))}else{for(let N=0;N<a;++N){let _=s[N];_._dirty=!1;for(let b=0;b<L;++b)O[b](this,e,r,d,_);this._instanced?this._vaf.subCommit(_._index,1):this._vaf.subCommit(_._index*4,4)}this._vaf.endSubCommits()}this._billboardsToUpdateIndex=0}if(a>n*1.5&&(s.length=n),!u(this._vaf)||!u(this._vaf.va))return;this._boundingVolumeDirty&&(this._boundingVolumeDirty=!1,ae.transform(this._baseVolume,this.modelMatrix,this._baseVolumeWC));let h,A=B.IDENTITY;e.mode===ne.SCENE3D?(A=this.modelMatrix,h=ae.clone(this._baseVolumeWC,this._boundingVolume)):h=ae.clone(this._baseVolume2D,this._boundingVolume),E4e(this,e,h);let x=this._blendOption!==this.blendOption;if(this._blendOption=this.blendOption,x){this._blendOption===bo.OPAQUE||this._blendOption===bo.OPAQUE_AND_TRANSLUCENT?this._rsOpaque=ke.fromCache({depthTest:{enabled:!0,func:te.LESS},depthMask:!0}):this._rsOpaque=void 0;let O=this._blendOption===bo.TRANSLUCENT;this._blendOption===bo.TRANSLUCENT||this._blendOption===bo.OPAQUE_AND_TRANSLUCENT?this._rsTranslucent=ke.fromCache({depthTest:{enabled:!0,func:O?te.LEQUAL:te.LESS},depthMask:O,blending:un.ALPHA_BLEND}):this._rsTranslucent=void 0}this._shaderDisableDepthDistance=this._shaderDisableDepthDistance||e.minimumDisableDepthTestDistance!==0;let C,T,E,S,w,D=Vt.maximumVertexTextureImageUnits>0;if(x||this._shaderRotation!==this._compiledShaderRotation||this._shaderAlignedAxis!==this._compiledShaderAlignedAxis||this._shaderScaleByDistance!==this._compiledShaderScaleByDistance||this._shaderTranslucencyByDistance!==this._compiledShaderTranslucencyByDistance||this._shaderPixelOffsetScaleByDistance!==this._compiledShaderPixelOffsetScaleByDistance||this._shaderDistanceDisplayCondition!==this._compiledShaderDistanceDisplayCondition||this._shaderDisableDepthDistance!==this._compiledShaderDisableDepthDistance||this._shaderClampToGround!==this._compiledShaderClampToGround||this._sdf!==this._compiledSDF){C=WO,T=GO,w=[],u(this._batchTable)&&(w.push("VECTOR_TILE"),C=this._batchTable.getVertexShaderCallback(!1,"a_batchId",void 0)(C),T=this._batchTable.getFragmentShaderCallback(!1,void 0)(T)),E=new He({defines:w,sources:[C]}),this._instanced&&E.defines.push("INSTANCED"),this._shaderRotation&&E.defines.push("ROTATION"),this._shaderAlignedAxis&&E.defines.push("ALIGNED_AXIS"),this._shaderScaleByDistance&&E.defines.push("EYE_DISTANCE_SCALING"),this._shaderTranslucencyByDistance&&E.defines.push("EYE_DISTANCE_TRANSLUCENCY"),this._shad
`),n="";for(let i=0;i<t.length;i++){let o=t[i],r=Zoe.test(o.charAt(0)),s=L4e(o,Zoe),a=0,c="";for(let l=0;l<s.length;++l){let f=s[l],d=f.Type===ts.BRACKETS?F4e(f.Word):N4e(f.Word);r?f.Type===ts.RTL?(c=d+c,a=0):f.Type===ts.LTR?(c=ZO(c,a,f.Word),a+=f.Word.length):(f.Type===ts.WEAK||f.Type===ts.BRACKETS)&&(f.Type===ts.WEAK&&s[l-1].Type===ts.BRACKETS?c=d+c:s[l-1].Type===ts.RTL?(c=d+c,a=0):s.length>l+1?s[l+1].Type===ts.RTL?(c=d+c,a=0):(c=ZO(c,a,f.Word),a+=f.Word.length):c=ZO(c,0,d)):f.Type===ts.RTL?c=ZO(c,a,d):f.Type===ts.LTR?(c+=f.Word,a=c.length):(f.Type===ts.WEAK||f.Type===ts.BRACKETS)&&(l>0&&s[l-1].Type===ts.RTL?s.length>l+1?s[l+1].Type===ts.RTL?c=ZO(c,a,d):(c+=f.Word,a=c.length):c+=f.Word:(c+=f.Word,a=c.length))}n+=c,i<t.length-1&&(n+=`
`)}return n}var Hg=Up;var nre=Do($oe(),1);function H4e(){this.textureInfo=void 0,this.dimensions=void 0,this.billboard=void 0}function G4e(e,t,n){this.labelCollection=e,this.index=t,this.dimensions=n}var W4e=1.2,ire="ID_WHITE_PIXEL",y6=new H(4,4),j4e=new qe(1,1,1,1);function Y4e(e){let t=document.createElement("canvas");t.width=y6.x,t.height=y6.y;let n=t.getContext("2d");n.fillStyle="#fff",n.fillRect(0,0,t.width,t.height),e.addImage(ire,t)}var sf={};function q4e(e,t,n,i,o,r,s){return sf.font=t,sf.fillColor=n,sf.strokeColor=i,sf.strokeWidth=o,sf.padding=vs.PADDING,s===On.CENTER?sf.textBaseline="middle":s===On.TOP?sf.textBaseline="top":sf.textBaseline="bottom",sf.fill=r===zo.FILL||r===zo.FILL_AND_OUTLINE,sf.stroke=r===zo.OUTLINE||r===zo.FILL_AND_OUTLINE,sf.backgroundColor=k.BLACK,zA(e,sf)}function A6(e,t){t.textureInfo=void 0,t.dimensions=void 0;let n=t.billboard;u(n)&&(n.show=!1,n.image=void 0,u(n._removeCallbackFunc)&&(n._removeCallbackFunc(),n._removeCallbackFunc=void 0),e._spareBillboards.push(n),t.billboard=void 0)}function X4e(e,t,n,i){i.index=e.addImageSync(t,n)}var K4e=new nre.default;function J4e(e,t){let n=t._renderedText,i=K4e.splitGraphemes(n),o=i.length,r=t._glyphs,s=r.length,a,c,l;if(t._relativeSize=t._fontSize/vs.FONT_SIZE,o<s)for(c=o;c<s;++c)A6(e,r[c]);r.length=o;let f=t._showBackground&&n.split(`
`).join("").length>0,d=t._backgroundBillboard,p=e._backgroundBillboardCollection;f?(u(d)||(d=p.add({collection:e,image:ire,imageSubRegion:j4e}),t._backgroundBillboard=d),d.color=t._backgroundColor,d.show=t._show,d.position=t._position,d.eyeOffset=t._eyeOffset,d.pixelOffset=t._pixelOffset,d.horizontalOrigin=pi.LEFT,d.verticalOrigin=t._verticalOrigin,d.heightReference=t._heightReference,d.scale=t.totalScale,d.pickPrimitive=t,d.id=t._id,d.translucencyByDistance=t._translucencyByDistance,d.pixelOffsetScaleByDistance=t._pixelOffsetScaleByDistance,d.scaleByDistance=t._scaleByDistance,d.distanceDisplayCondition=t._distanceDisplayCondition,d.disableDepthTestDistance=t._disableDepthTestDistance):u(d)&&(p.remove(d),t._backgroundBillboard=d=void 0);let g=e._glyphTextureCache;for(l=0;l<o;++l){let h=i[l],A=t._verticalOrigin,x=JSON.stringify([h,t._fontFamily,t._fontStyle,t._fontWeight,+A]),C=g[x];if(!u(C)){let T=`${t._fontStyle} ${t._fontWeight} ${vs.FONT_SIZE}px ${t._fontFamily}`,E=q4e(h,T,k.WHITE,k.WHITE,0,zo.FILL,A);if(C=new G4e(e,-1,E.dimensions),g[x]=C,E.width>0&&E.height>0){let S=(0,tre.default)(E,{cutoff:vs.CUTOFF,radius:vs.RADIUS}),w=E.getContext("2d"),D=E.width,M=E.height,O=w.getImageData(0,0,D,M);for(let L=0;L<D;L++)for(let N=0;N<M;N++){let _=N*D+L,b=S[_]*255,v=_*4;O.data[v+0]=b,O.data[v+1]=b,O.data[v+2]=b,O.data[v+3]=b}w.putImageData(O,0,0),h!==" "&&X4e(e._textureAtlas,x,E,C)}}if(a=r[l],u(a)?C.index===-1?A6(e,a):u(a.textureInfo)&&(a.textureInfo=void 0):(a=new H4e,r[l]=a),a.textureInfo=C,a.dimensions=C.dimensions,C.index!==-1){let T=a.billboard,E=e._spareBillboards;u(T)||(E.length>0?T=E.pop():(T=e._billboardCollection.add({collection:e}),T._labelDimensions=new H,T._labelTranslate=new H),a.billboard=T),T.show=t._show,T.position=t._position,T.eyeOffset=t._eyeOffset,T.pixelOffset=t._pixelOffset,T.horizontalOrigin=pi.LEFT,T.verticalOrigin=t._verticalOrigin,T.heightReference=t._heightReference,T.scale=t.totalScale,T.pickPrimitive=t,T.id=t._id,T.image=x,T.translucencyByDistance=t._translucencyByDistance,T.pixelOffsetScaleByDistance=t._pixelOffsetScaleByDistance,T.scaleByDistance=t._scaleByDistance,T.distanceDisplayCondition=t._distanceDisplayCondition,T.disableDepthTestDistance=t._disableDepthTestDistance,T._batchIndex=t._batchIndex,T.outlineColor=t.outlineColor,t.style===zo.FILL_AND_OUTLINE?(T.color=t._fillColor,T.outlineWidth=t.outlineWidth):t.style===zo.FILL?(T.color=t._fillColor,T.outlineWidth=0):t.style===zo.OUTLINE&&(T.color=k.TRANSPARENT,T.outlineWidth=t.outlineWidth)}}t._repositionAllGlyphs=!0}function ere(e,t,n){return t===pi.CENTER?-e/2:t===pi.RIGHT?-(e+n.x):n.x}var ar=new H,Z4e=new H;function Q4e(e){let t=e._glyphs,n=e._renderedText,i,o,r=0,s=0,a=[],c=Number.NEGATIVE_INFINITY,l=0,f=1,d,p=t.length,g=e._backgroundBillboard,h=H.clone(u(g)?e._backgroundPadding:H.ZERO,Z4e);for(h.x/=e._relativeSize,h.y/=e._relativeSize,d=0;d<p;++d)n.charAt(d)===`
`?(a.push(r),++f,r=0):(i=t[d],o=i.dimensions,l=Math.max(l,o.height-o.descent),c=Math.max(c,o.descent),r+=o.width-o.minx,d<p-1&&(r+=t[d+1].dimensions.minx),s=Math.max(s,r));a.push(r);let A=l+c,x=e.totalScale,C=e._horizontalOrigin,T=e._verticalOrigin,E=0,S=a[E],w=ere(S,C,h),D=(u(e._lineHeight)?e._lineHeight:W4e*e._fontSize)/e._relativeSize,M=D*(f-1),O=s,L=A+M;u(g)&&(O+=h.x*2,L+=h.y*2,g._labelHorizontalOrigin=C),ar.x=w*x,ar.y=0;let N=!0,_=0;for(d=0;d<p;++d)if(n.charAt(d)===`
`)++E,_+=D,S=a[E],w=ere(S,C,h),ar.x=w*x,N=!0;else if(i=t[d],o=i.dimensions,T===On.TOP?(ar.y=o.height-l-h.y,ar.y+=vs.PADDING):T===On.CENTER?ar.y=(M+o.height-l)/2:T===On.BASELINE?(ar.y=M,ar.y-=vs.PADDING):(ar.y=M+c+h.y,ar.y-=vs.PADDING),ar.y=(ar.y-o.descent-_)*x,N&&(ar.x-=vs.PADDING*x,N=!1),u(i.billboard)&&(i.billboard._setTranslate(ar),i.billboard._labelDimensions.x=O,i.billboard._labelDimensions.y=L,i.billboard._labelHorizontalOrigin=C),d<p-1){let b=t[d+1];ar.x+=(o.width-o.minx+b.dimensions.minx)*x}if(u(g)&&n.split(`
`).join("").length>0&&(C===pi.CENTER?w=-s/2-h.x:C===pi.RIGHT?w=-(s+h.x*2):w=0,ar.x=w*x,T===On.TOP?ar.y=A-l-c:T===On.CENTER?ar.y=(A-l)/2-c:T===On.BASELINE?ar.y=-h.y-c:ar.y=0,ar.y=ar.y*x,g.width=O,g.height=L,g._setTranslate(ar),g._labelTranslate=H.clone(ar,g._labelTranslate)),e.heightReference===We.CLAMP_TO_GROUND)for(d=0;d<p;++d){i=t[d];let b=i.billboard;u(b)&&(b._labelTranslate=H.clone(ar,b._labelTranslate))}}function ore(e,t){let n=t._glyphs;for(let i=0,o=n.length;i<o;++i)A6(e,n[i]);u(t._backgroundBillboard)&&(e._backgroundBillboardCollection.remove(t._backgroundBillboard),t._backgroundBillboard=void 0),t._labelCollection=void 0,u(t._removeCallbackFunc)&&t._removeCallbackFunc(),ue(t)}function jm(e){e=y(e,y.EMPTY_OBJECT),this._scene=e.scene,this._batchTable=e.batchTable,this._textureAtlas=void 0,this._backgroundTextureAtlas=void 0,this._backgroundBillboardCollection=new nu({scene:this._scene}),this._backgroundBillboardCollection.destroyTextureAtlas=!1,this._billboardCollection=new nu({scene:this._scene,batchTable:this._batchTable}),this._billboardCollection.destroyTextureAtlas=!1,this._billboardCollection._sdf=!0,this._spareBillboards=[],this._glyphTextureCache={},this._labels=[],this._labelsToUpdate=[],this._totalGlyphCount=0,this._highlightColor=k.clone(k.WHITE),this.show=y(e.show,!0),this.modelMatrix=B.clone(y(e.modelMatrix,B.IDENTITY)),this.debugShowBoundingVolume=y(e.debugShowBoundingVolume,!1),this.blendOption=y(e.blendOption,bo.OPAQUE_AND_TRANSLUCENT)}Object.defineProperties(jm.prototype,{length:{get:function(){return this._labels.length}}});jm.prototype.add=function(e){let t=new Hg(e,this);return this._labels.push(t),this._labelsToUpdate.push(t),t};jm.prototype.remove=function(e){if(u(e)&&e._labelCollection===this){let t=this._labels.indexOf(e);if(t!==-1)return this._labels.splice(t,1),ore(this,e),!0}return!1};jm.prototype.removeAll=function(){let e=this._labels;for(let t=0,n=e.length;t<n;++t)ore(this,e[t]);e.length=0};jm.prototype.contains=function(e){return u(e)&&e._labelCollection===this};jm.prototype.get=function(e){return this._labels[e]};jm.prototype.update=function(e){if(!this.show)return;let t=this._billboardCollection,n=this._backgroundBillboardCollection;t.modelMatrix=this.modelMatrix,t.debugShowBoundingVolume=this.debugShowBoundingVolume,n.modelMatrix=this.modelMatrix,n.debugShowBoundingVolume=this.debugShowBoundingVolume;let i=e.context;u(this._textureAtlas)||(this._textureAtlas=new zg({context:i}),t.textureAtlas=this._textureAtlas),u(this._backgroundTextureAtlas)||(this._backgroundTextureAtlas=new zg({context:i,initialSize:y6}),n.textureAtlas=this._backgroundTextureAtlas,Y4e(this._backgroundTextureAtlas));let o=this._labelsToUpdate.length;for(let s=0;s<o;++s){let a=this._labelsToUpdate[s];if(a.isDestroyed())continue;let c=a._glyphs.length;a._rebindAllGlyphs&&(J4e(this,a),a._rebindAllGlyphs=!1),a._repositionAllGlyphs&&(Q4e(a),a._repositionAllGlyphs=!1);let l=a._glyphs.length-c;this._totalGlyphCount+=l}let r=n.length>0?bo.TRANSLUCENT:this.blendOption;t.blendOption=r,n.blendOption=r,t._highlightColor=this._highlightColor,n._highlightColor=this._highlightColor,this._labelsToUpdate.length=0,n.update(e),t.update(e)};jm.prototype.isDestroyed=function(){return!1};jm.prototype.destroy=function(){return this.removeAll(),this._billboardCollection=this._billboardCollection.destroy(),this._textureAtlas=this._textureAtlas&&this._textureAtlas.destroy(),this._backgroundBillboardCollection=this._backgroundBillboardCollection.destroy(),this._backgroundTextureAtlas=this._backgroundTextureAtlas&&this._backgroundTextureAtlas.destroy(),ue(this)};var Ym=jm;var QO=`in vec3 position3DHigh;
in vec3 position3DLow;
in vec3 position2DHigh;
in vec3 position2DLow;
in vec3 prevPosition3DHigh;
in vec3 prevPosition3DLow;
in vec3 prevPosition2DHigh;
in vec3 prevPosition2DLow;
in vec3 nextPosition3DHigh;
in vec3 nextPosition3DLow;
in vec3 nextPosition2DHigh;
in vec3 nextPosition2DLow;
in vec4 texCoordExpandAndBatchIndex;
out vec2 v_st;
out float v_width;
out vec4 v_pickColor;
out float v_polylineAngle;
void main()
{
float texCoord = texCoordExpandAndBatchIndex.x;
float expandDir = texCoordExpandAndBatchIndex.y;
bool usePrev = texCoordExpandAndBatchIndex.z < 0.0;
float batchTableIndex = texCoordExpandAndBatchIndex.w;
vec2 widthAndShow = batchTable_getWidthAndShow(batchTableIndex);
float width = widthAndShow.x + 0.5;
float show = widthAndShow.y;
if (width < 1.0)
{
show = 0.0;
}
vec4 pickColor = batchTable_getPickColor(batchTableIndex);
vec4 p, prev, next;
if (czm_morphTime == 1.0)
{
p = czm_translateRelativeToEye(position3DHigh.xyz, position3DLow.xyz);
prev = czm_translateRelativeToEye(prevPosition3DHigh.xyz, prevPosition3DLow.xyz);
next = czm_translateRelativeToEye(nextPosition3DHigh.xyz, nextPosition3DLow.xyz);
}
else if (czm_morphTime == 0.0)
{
p = czm_translateRelativeToEye(position2DHigh.zxy, position2DLow.zxy);
prev = czm_translateRelativeToEye(prevPosition2DHigh.zxy, prevPosition2DLow.zxy);
next = czm_translateRelativeToEye(nextPosition2DHigh.zxy, nextPosition2DLow.zxy);
}
else
{
p = czm_columbusViewMorph(
czm_translateRelativeToEye(position2DHigh.zxy, position2DLow.zxy),
czm_translateRelativeToEye(position3DHigh.xyz, position3DLow.xyz),
czm_morphTime);
prev = czm_columbusViewMorph(
czm_translateRelativeToEye(prevPosition2DHigh.zxy, prevPosition2DLow.zxy),
czm_translateRelativeToEye(prevPosition3DHigh.xyz, prevPosition3DLow.xyz),
czm_morphTime);
next = czm_columbusViewMorph(
czm_translateRelativeToEye(nextPosition2DHigh.zxy, nextPosition2DLow.zxy),
czm_translateRelativeToEye(nextPosition3DHigh.xyz, nextPosition3DLow.xyz),
czm_morphTime);
}
#ifdef DISTANCE_DISPLAY_CONDITION
vec3 centerHigh = batchTable_getCenterHigh(batchTableIndex);
vec4 centerLowAndRadius = batchTable_getCenterLowAndRadius(batchTableIndex);
vec3 centerLow = centerLowAndRadius.xyz;
float radius = centerLowAndRadius.w;
vec2 distanceDisplayCondition = batchTable_getDistanceDisplayCondition(batchTableIndex);
float lengthSq;
if (czm_sceneMode == czm_sceneMode2D)
{
lengthSq = czm_eyeHeight2D.y;
}
else
{
vec4 center = czm_translateRelativeToEye(centerHigh.xyz, centerLow.xyz);
lengthSq = max(0.0, dot(center.xyz, center.xyz) - radius * radius);
}
float nearSq = distanceDisplayCondition.x * distanceDisplayCondition.x;
float farSq = distanceDisplayCondition.y * distanceDisplayCondition.y;
if (lengthSq < nearSq || lengthSq > farSq)
{
show = 0.0;
}
#endif
float polylineAngle;
vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, polylineAngle);
gl_Position = czm_viewportOrthographic * positionWC * show;
v_st.s = texCoord;
v_st.t = czm_writeNonPerspective(clamp(expandDir, 0.0, 1.0), gl_Position.w);
v_width = width;
v_pickColor = pickColor;
v_polylineAngle = polylineAngle;
}
`;var Fc={};Fc.numberOfPoints=function(e,t,n){let i=m.distance(e,t);return Math.ceil(i/n)};Fc.numberOfPointsRhumbLine=function(e,t,n){let i=Math.pow(e.longitude-t.longitude,2)+Math.pow(e.latitude-t.latitude,2);return Math.max(1,Math.ceil(Math.sqrt(i/(n*n))))};var $4e=new he;Fc.extractHeights=function(e,t){let n=e.length,i=new Array(n);for(let o=0;o<n;o++){let r=e[o];i[o]=t.cartesianToCartographic(r,$4e).height}return i};var eze=new B,tze=new m,rre=new m,nze=new ln(m.UNIT_X,0),sre=new m,ize=new ln(m.UNIT_X,0),oze=new m,rze=new m,C6=[];function cre(e,t,n){let i=C6;i.length=e;let o;if(t===n){for(o=0;o<e;o++)i[o]=t;return i}let s=(n-t)/e;for(o=0;o<e;o++){let a=t+o*s;i[o]=a}return i}var sV=new he,rV=new he,Gg=new m,T6=new m,sze=new m,x6=new Xu,$O=new pa;function aze(e,t,n,i,o,r,s,a){let c=i.scaleToGeodeticSurface(e,T6),l=i.scaleToGeodeticSurface(t,sze),f=Fc.numberOfPoints(e,t,n),d=i.cartesianToCartographic(c,sV),p=i.cartesianToCartographic(l,rV),g=cre(f,o,r);x6.setEndPoints(d,p);let h=x6.surfaceDistance/f,A=a;d.height=o;let x=i.cartographicToCartesian(d,Gg);m.pack(x,s,A),A+=3;for(let C=1;C<f;C++){let T=x6.interpolateUsingSurfaceDistance(C*h,rV);T.height=g[C],x=i.cartographicToCartesian(T,Gg),m.pack(x,s,A),A+=3}return A}function cze(e,t,n,i,o,r,s,a){let c=i.cartesianToCartographic(e,sV),l=i.cartesianToCartographic(t,rV),f=Fc.numberOfPointsRhumbLine(c,l,n);c.height=0,l.height=0;let d=cre(f,o,r);$O.ellipsoid.equals(i)||($O=new pa(void 0,void 0,i)),$O.setEndPoints(c,l);let p=$O.surfaceDistance/f,g=a;c.height=o;let h=i.cartographicToCartesian(c,Gg);m.pack(h,s,g),g+=3;for(let A=1;A<f;A++){let x=$O.interpolateUsingSurfaceDistance(A*p,rV);x.height=d[A],h=i.cartographicToCartesian(x,Gg),m.pack(h,s,g),g+=3}return g}Fc.wrapLongitude=function(e,t){let n=[],i=[];if(u(e)&&e.length>0){t=y(t,B.IDENTITY);let o=B.inverseTransformation(t,eze),r=B.multiplyByPoint(o,m.ZERO,tze),s=m.normalize(B.multiplyByPointAsVector(o,m.UNIT_Y,rre),rre),a=ln.fromPointNormal(r,s,nze),c=m.normalize(B.multiplyByPointAsVector(o,m.UNIT_X,sre),sre),l=ln.fromPointNormal(r,c,ize),f=1;n.push(m.clone(e[0]));let d=n[0],p=e.length;for(let g=1;g<p;++g){let h=e[g];if(ln.getPointDistance(l,d)<0||ln.getPointDistance(l,h)<0){let A=Xi.lineSegmentPlane(d,h,a,oze);if(u(A)){let x=m.multiplyByScalar(s,5e-9,rze);ln.getPointDistance(a,d)<0&&m.negate(x,x),n.push(m.add(A,x,new m)),i.push(f+1),m.negate(x,x),n.push(m.add(A,x,new m)),f=1}}n.push(m.clone(e[g])),f++,d=h}i.push(f)}return{positions:n,lengths:i}};Fc.generateArc=function(e){u(e)||(e={});let t=e.positions,n=t.length,i=y(e.ellipsoid,oe.WGS84),o=y(e.height,0),r=Array.isArray(o);if(n<1)return[];if(n===1){let A=i.scaleToGeodeticSurface(t[0],T6);if(o=r?o[0]:o,o!==0){let x=i.geodeticSurfaceNormal(A,Gg);m.multiplyByScalar(x,o,x),m.add(A,x,A)}return[A.x,A.y,A.z]}let s=e.minDistance;if(!u(s)){let A=y(e.granularity,P.RADIANS_PER_DEGREE);s=P.chordLength(A,i.maximumRadius)}let a=0,c;for(c=0;c<n-1;c++)a+=Fc.numberOfPoints(t[c],t[c+1],s);let l=(a+1)*3,f=new Array(l),d=0;for(c=0;c<n-1;c++){let A=t[c],x=t[c+1],C=r?o[c]:o,T=r?o[c+1]:o;d=aze(A,x,s,i,C,T,f,d)}C6.length=0;let p=t[n-1],g=i.cartesianToCartographic(p,sV);g.height=r?o[n-1]:o;let h=i.cartographicToCartesian(g,Gg);return m.pack(h,f,l-3),f};var are=new he,lze=new he;Fc.generateRhumbArc=function(e){u(e)||(e={});let t=e.positions,n=t.length,i=y(e.ellipsoid,oe.WGS84),o=y(e.height,0),r=Array.isArray(o);if(n<1)return[];if(n===1){let C=i.scaleToGeodeticSurface(t[0],T6);if(o=r?o[0]:o,o!==0){let T=i.geodeticSurfaceNormal(C,Gg);m.multiplyByScalar(T,o,T),m.add(C,T,C)}return[C.x,C.y,C.z]}let s=y(e.granularity,P.RADIANS_PER_DEGREE),a=0,c,l=i.cartesianToCartographic(t[0],are),f;for(c=0;c<n-1;c++)f=i.cartesianToCartographic(t[c+1],lze),a+=Fc.numberOfPointsRhumbLine(l,f,s),l=he.clone(f,are);let d=(a+1)*3,p=new Array(d),g=0;for(c=0;c<n-1;c++){let C=t[c],T=t[c+1],E=r?o[c]:o,S=r?o[c+1]:o;g=cze(C,T,s,i,E,S,p,g)}C6.length=0;let h=t[n-1],A=i.cartesianToCartographic(h,sV);A.height=r?o[n-1]:o;let x=i.cartographicToCartesian(A,Gg);return m.pack(x,p,d-3),p};Fc.generateCartesianArc=function(e){let t=Fc.generateArc(
`,this.material.shaderSource,Y0]}),r=t.getVertexShaderCallback()(QO),s=new He({defines:i,sources:[Kl,r]});this.shaderProgram=Jt.fromCache({context:e,vertexShaderSource:s,fragmentShaderSource:o,attributeLocations:Tl})};function bre(e){return m.dot(m.UNIT_X,e._boundingVolume.center)<0||e._boundingVolume.intersectPlane(ln.ORIGIN_ZX_PLANE)===en.INTERSECTING}qm.prototype.getPolylinePositionsLength=function(e){let t;if(this.mode===ne.SCENE3D||!bre(e))return t=e._actualPositions.length,t*4-4;let n=0,i=e._segments.lengths;t=i.length;for(let o=0;o<t;++o)n+=i[o]*4-4;return n};var cs=new m,cf=new m,lf=new m,cV=new m,Sze=new re,vze=new H;qm.prototype.write=function(e,t,n,i,o,r,s,a){let c=this.mode,l=a.ellipsoid.maximumRadius*P.PI,f=this.polylines,d=f.length;for(let p=0;p<d;++p){let g=f[p],h=g.width,A=g.show&&h>0,x=g._index,C=this.getSegments(g,a),T=C.positions,E=C.lengths,S=T.length,w=g.getPickId(s).color,D=0,M=0,O;for(let z=0;z<S;++z){z===0?g._loop?O=T[S-2]:(O=cV,m.subtract(T[0],T[1],O),m.add(T[0],O,O)):O=T[z-1],m.clone(O,cf),m.clone(T[z],cs),z===S-1?g._loop?O=T[1]:(O=cV,m.subtract(T[S-1],T[S-2],O),m.add(T[S-1],O,O)):O=T[z+1],m.clone(O,lf);let V=E[D];z===M+V&&(M+=V,++D);let G=z-M===0,U=z===M+E[D]-1;c===ne.SCENE2D&&(cf.z=0,cs.z=0,lf.z=0),(c===ne.SCENE2D||c===ne.MORPHING)&&(G||U)&&l-Math.abs(cs.x)<1&&((cs.x<0&&cf.x>0||cs.x>0&&cf.x<0)&&m.clone(cs,cf),(cs.x<0&&lf.x>0||cs.x>0&&lf.x<0)&&m.clone(cs,lf));let q=G?2:0,Y=U?2:4;for(let Q=q;Q<Y;++Q){Gn.writeElements(cs,e,n),Gn.writeElements(cf,e,n+6),Gn.writeElements(lf,e,n+12);let W=Q-2<0?-1:1;t[o]=z/(S-1),t[o+1]=2*(Q%2)-1,t[o+2]=W,t[o+3]=x,n+=6*3,o+=4}}let L=Sze;L.x=k.floatToByte(w.red),L.y=k.floatToByte(w.green),L.z=k.floatToByte(w.blue),L.w=k.floatToByte(w.alpha);let N=vze;N.x=h,N.y=A?1:0;let _=c===ne.SCENE2D?g._boundingVolume2D:g._boundingVolumeWC,b=Gn.fromCartesian(_.center,Are),v=b.high,I=re.fromElements(b.low.x,b.low.y,b.low.z,_.radius,xre),R=Cre;R.x=0,R.y=Number.MAX_VALUE;let F=g.distanceDisplayCondition;u(F)&&(R.x=F.near,R.y=F.far),r.setBatchedAttribute(x,0,N),r.setBatchedAttribute(x,1,L),r.attributes.length>2&&(r.setBatchedAttribute(x,2,v),r.setBatchedAttribute(x,3,I),r.setBatchedAttribute(x,4,R))}};var wze=new m,Dze=new m,Ize=new m,pre=new m;qm.prototype.writeForMorph=function(e,t){let n=this.modelMatrix,i=this.polylines,o=i.length;for(let r=0;r<o;++r){let s=i[r],a=s._segments.positions,c=s._segments.lengths,l=a.length,f=0,d=0;for(let p=0;p<l;++p){let g;p===0?s._loop?g=a[l-2]:(g=pre,m.subtract(a[0],a[1],g),m.add(a[0],g,g)):g=a[p-1],g=B.multiplyByPoint(n,g,Dze);let h=B.multiplyByPoint(n,a[p],wze),A;p===l-1?s._loop?A=a[1]:(A=pre,m.subtract(a[l-1],a[l-2],A),m.add(a[l-1],A,A)):A=a[p+1],A=B.multiplyByPoint(n,A,Ize);let x=c[f];p===d+x&&(d+=x,++f);let C=p-d===0,T=p===d+c[f]-1,E=C?2:0,S=T?2:4;for(let w=E;w<S;++w)Gn.writeElements(h,e,t),Gn.writeElements(g,e,t+6),Gn.writeElements(A,e,t+12),t+=6*3}}};var Pze=new Array(1);qm.prototype.updateIndices=function(e,t,n,i){let o=n.length-1,r=new E6(0,i,this);n[o].push(r);let s=0,a=e[e.length-1],c=0;a.length>0&&(c=a[a.length-1]+1);let l=this.polylines,f=l.length;for(let d=0;d<f;++d){let p=l[d];p._locatorBuckets=[];let g;if(this.mode===ne.SCENE3D){g=Pze;let A=p._actualPositions.length;if(A>0)g[0]=A;else continue}else g=p._segments.lengths;let h=g.length;if(h>0){let A=0;for(let x=0;x<h;++x){let C=g[x]-1;for(let T=0;T<C;++T)c+4>P.SIXTY_FOUR_KILOBYTES&&(p._locatorBuckets.push({locator:r,count:A}),A=0,t.push(4),a=[],e.push(a),c=0,r.count=s,s=0,i=0,r=new E6(0,0,this),n[++o]=[r]),a.push(c,c+2,c+1),a.push(c+1,c+2,c+3),A+=6,s+=6,i+=6,c+=4}p._locatorBuckets.push({locator:r,count:A}),c+4>P.SIXTY_FOUR_KILOBYTES&&(t.push(0),a=[],e.push(a),c=0,r.count=s,i=0,s=0,r=new E6(0,0,this),n[++o]=[r])}p._clean()}return r.count=s,i};qm.prototype.getPolylineStartIndex=function(e){let t=this.polylines,n=0,i=t.length;for(let o=0;o<i;++o){let r=t[o];if(r===e)break;n+=r._actualLength}return n};var cE={positions:void 0,lengths:void 0},_re=new Array(1),Oze=new m,Mze=new he;qm.prototype.getSegments=function(e,t){let n=e._actualPositions;if(this.mode===ne.SCENE3D)return _re[0]=n.lengt
in vec4 previousPosition;
in vec4 nextPosition;
in vec2 expandAndWidth;
in float a_batchId;
uniform mat4 u_modifiedModelView;
void main()
{
float expandDir = expandAndWidth.x;
float width = abs(expandAndWidth.y) + 0.5;
bool usePrev = expandAndWidth.y < 0.0;
vec4 p = u_modifiedModelView * currentPosition;
vec4 prev = u_modifiedModelView * previousPosition;
vec4 next = u_modifiedModelView * nextPosition;
float angle;
vec4 positionWC = getPolylineWindowCoordinatesEC(p, prev, next, expandDir, width, usePrev, angle);
gl_Position = czm_viewportOrthographic * positionWC;
}
`;function Id(e){this._positions=e.positions,this._widths=e.widths,this._counts=e.counts,this._batchIds=e.batchIds,this._ellipsoid=y(e.ellipsoid,oe.WGS84),this._minimumHeight=e.minimumHeight,this._maximumHeight=e.maximumHeight,this._center=e.center,this._rectangle=e.rectangle,this._boundingVolume=e.boundingVolume,this._batchTable=e.batchTable,this._va=void 0,this._sp=void 0,this._rs=void 0,this._uniformMap=void 0,this._command=void 0,this._transferrableBatchIds=void 0,this._packedBuffer=void 0,this._keepDecodedPositions=e.keepDecodedPositions,this._decodedPositions=void 0,this._decodedPositionOffsets=void 0,this._currentPositions=void 0,this._previousPositions=void 0,this._nextPositions=void 0,this._expandAndWidth=void 0,this._vertexBatchIds=void 0,this._indices=void 0,this._constantColor=k.clone(k.WHITE),this._highlightColor=this._constantColor,this._trianglesLength=0,this._geometryByteLength=0,this._ready=!1,this._promise=void 0,this._error=void 0}Object.defineProperties(Id.prototype,{trianglesLength:{get:function(){return this._trianglesLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}}});function Jze(e){let t=e._rectangle,n=e._minimumHeight,i=e._maximumHeight,o=e._ellipsoid,r=e._center,s=2+le.packedLength+oe.packedLength+m.packedLength,a=new Float64Array(s),c=0;return a[c++]=n,a[c++]=i,le.pack(t,a,c),c+=le.packedLength,oe.pack(o,a,c),c+=oe.packedLength,m.pack(r,a,c),a}var Zze=new gi("createVectorTilePolylines",5),lE={previousPosition:0,currentPosition:1,nextPosition:2,expandAndWidth:3,a_batchId:4};function Qze(e,t){if(u(e._va))return;let n=e._positions,i=e._widths,o=e._counts,r=e._transferrableBatchIds,s=e._packedBuffer;u(s)||(n=e._positions=n.slice(),i=e._widths=i.slice(),o=e._counts=o.slice(),r=e._transferrableBatchIds=e._batchIds.slice(),s=e._packedBuffer=Jze(e));let a=[n.buffer,i.buffer,o.buffer,r.buffer,s.buffer],c={positions:n.buffer,widths:i.buffer,counts:o.buffer,batchIds:r.buffer,packedBuffer:s.buffer,keepDecodedPositions:e._keepDecodedPositions},l=Zze.scheduleTask(c,a);if(u(l))return l.then(function(f){if(e.isDestroyed())return;e._keepDecodedPositions&&(e._decodedPositions=new Float64Array(f.decodedPositions),e._decodedPositionOffsets=new Uint32Array(f.decodedPositionOffsets)),e._currentPositions=new Float32Array(f.currentPositions),e._previousPositions=new Float32Array(f.previousPositions),e._nextPositions=new Float32Array(f.nextPositions),e._expandAndWidth=new Float32Array(f.expandAndWidth),e._vertexBatchIds=new Uint16Array(f.batchIds);let d=f.indexDatatype;e._indices=d===Ue.UNSIGNED_SHORT?new Uint16Array(f.indices):new Uint32Array(f.indices),$ze(e,t),e._ready=!0}).catch(f=>{e.isDestroyed()||(e._error=f)})}function $ze(e,t){if(!u(e._va)){let n=e._currentPositions,i=e._previousPositions,o=e._nextPositions,r=e._expandAndWidth,s=e._vertexBatchIds,a=e._indices,c=i.byteLength+n.byteLength+o.byteLength;c+=r.byteLength+s.byteLength+a.byteLength,e._trianglesLength=a.length/3,e._geometryByteLength=c;let l=ut.createVertexBuffer({context:t,typedArray:i,usage:Fe.STATIC_DRAW}),f=ut.createVertexBuffer({context:t,typedArray:n,usage:Fe.STATIC_DRAW}),d=ut.createVertexBuffer({context:t,typedArray:o,usage:Fe.STATIC_DRAW}),p=ut.createVertexBuffer({context:t,typedArray:r,usage:Fe.STATIC_DRAW}),g=ut.createVertexBuffer({context:t,typedArray:s,usage:Fe.STATIC_DRAW}),h=ut.createIndexBuffer({context:t,typedArray:a,usage:Fe.STATIC_DRAW,indexDatatype:a.BYTES_PER_ELEMENT===2?Ue.UNSIGNED_SHORT:Ue.UNSIGNED_INT}),A=[{index:lE.previousPosition,vertexBuffer:l,componentDatatype:X.FLOAT,componentsPerAttribute:3},{index:lE.currentPosition,vertexBuffer:f,componentDatatype:X.FLOAT,componentsPerAttribute:3},{index:lE.nextPosition,vertexBuffer:d,componentDatatype:X.FLOAT,componentsPerAttribute:3},{index:lE.expandAndWidth,vertexBuffer:p,componentDatatype:X.FLOAT,componentsPerAttribute:2},{index:lE.a_batchId,vertexBuffer:g,componentDatatype:X.UNSIGNED_SHORT,componentsPerAttribute:1}];e._va=new si({context:t,attributes:A,indexBuffer:h}),e._positions=void 0,e._widths=void 0,e._co
void main()
{
out_FragColor = u_highlightColor;
}
`;function iHe(e,t){if(u(e._sp))return;let n=e._batchTable,i=n.getVertexShaderCallback(!1,"a_batchId",void 0)(sM),o=n.getFragmentShaderCallback(!1,void 0,!1)(nHe),r=new He({defines:["VECTOR_TILE",kt.isInternetExplorer()?"":"CLIP_POLYLINE"],sources:[Kl,i]}),s=new He({defines:["VECTOR_TILE"],sources:[o]});e._sp=Jt.fromCache({context:t,vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:lE})}function oHe(e,t){if(!u(e._command)){let n=e._batchTable.getUniformMapCallback()(e._uniformMap);e._command=new nt({owner:e,vertexArray:e._va,renderState:e._rs,shaderProgram:e._sp,uniformMap:n,boundingVolume:e._boundingVolume,pass:be.TRANSLUCENT,pickId:e._batchTable.getPickId()})}t.commandList.push(e._command)}Id.getPolylinePositions=function(e,t){let n=e._batchIds,i=e._decodedPositions,o=e._decodedPositionOffsets;if(!u(n)||!u(i))return;let r,s,a=n.length,c=0,l=0;for(r=0;r<a;++r)n[r]===t&&(c+=o[r+1]-o[r]);if(c===0)return;let f=new Float64Array(c*3);for(r=0;r<a;++r)if(n[r]===t){let d=o[r],p=o[r+1]-d;for(s=0;s<p;++s){let g=(d+s)*3;f[l++]=i[g],f[l++]=i[g+1],f[l++]=i[g+2]}}return f};Id.prototype.getPositions=function(e){return Id.getPolylinePositions(this,e)};Id.prototype.createFeatures=function(e,t){let n=this._batchIds,i=n.length;for(let o=0;o<i;++o){let r=n[o];t[r]=new Cs(e,r)}};Id.prototype.applyDebugSettings=function(e,t){this._highlightColor=e?t:this._constantColor};function rHe(e,t){let n=e._batchIds,i=n.length;for(let o=0;o<i;++o){let r=n[o],s=t[r];s.show=!0,s.color=k.WHITE}}var sHe=new k,aHe=k.WHITE,cHe=!0;Id.prototype.applyStyle=function(e,t){if(!u(e)){rHe(this,t);return}let n=this._batchIds,i=n.length;for(let o=0;o<i;++o){let r=n[o],s=t[r];s.color=u(e.color)?e.color.evaluateColor(s,sHe):aHe,s.show=u(e.show)?e.show.evaluate(s):cHe}};Id.prototype.update=function(e){let t=e.context;if(!this._ready){if(u(this._promise)||(this._promise=Qze(this,t)),u(this._error)){let i=this._error;throw this._error=void 0,i}return}eHe(this,t),iHe(this,t),tHe(this);let n=e.passes;(n.render||n.pick)&&oHe(this,e)};Id.prototype.isDestroyed=function(){return!1};Id.prototype.destroy=function(){return this._va=this._va&&this._va.destroy(),this._sp=this._sp&&this._sp.destroy(),ue(this)};var GA=Id;var cM=`in vec3 startEllipsoidNormal;
in vec3 endEllipsoidNormal;
in vec4 startPositionAndHeight;
in vec4 endPositionAndHeight;
in vec4 startFaceNormalAndVertexCorner;
in vec4 endFaceNormalAndHalfWidth;
in float a_batchId;
uniform mat4 u_modifiedModelView;
uniform vec2 u_minimumMaximumVectorHeights;
out vec4 v_startPlaneEC;
out vec4 v_endPlaneEC;
out vec4 v_rightPlaneEC;
out float v_halfWidth;
out vec3 v_volumeUpEC;
void main()
{
// vertex corner IDs
// 3-----------7
// /| left /|
// / | 1 / |
// 2-----------6 5 end
// | / | /
// start |/ right |/
// 0-----------4
//
float isEnd = floor(startFaceNormalAndVertexCorner.w * 0.251); // 0 for front, 1 for end
float isTop = floor(startFaceNormalAndVertexCorner.w * mix(0.51, 0.19, isEnd)); // 0 for bottom, 1 for top
vec3 forward = endPositionAndHeight.xyz - startPositionAndHeight.xyz;
vec3 right = normalize(cross(forward, startEllipsoidNormal));
vec4 position = vec4(startPositionAndHeight.xyz, 1.0);
position.xyz += forward * isEnd;
v_volumeUpEC = czm_normal * normalize(cross(right, forward));
// Push for volume height
float offset;
vec3 ellipsoidNormal = mix(startEllipsoidNormal, endEllipsoidNormal, isEnd);
// offset height to create volume
offset = mix(startPositionAndHeight.w, endPositionAndHeight.w, isEnd);
offset = mix(u_minimumMaximumVectorHeights.y, u_minimumMaximumVectorHeights.x, isTop) - offset;
position.xyz += offset * ellipsoidNormal;
// move from RTC to EC
position = u_modifiedModelView * position;
right = czm_normal * right;
// Push for width in a direction that is in the start or end plane and in a plane with right
// N = normalEC ("right-facing" direction for push)
// R = right
// 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 ---->
//
vec3 scratchNormal = mix(-startFaceNormalAndVertexCorner.xyz, endFaceNormalAndHalfWidth.xyz, isEnd);
scratchNormal = cross(scratchNormal, mix(startEllipsoidNormal, endEllipsoidNormal, isEnd));
vec3 miterPushNormal = czm_normal * normalize(scratchNormal);
offset = 2.0 * endFaceNormalAndHalfWidth.w * max(0.0, czm_metersPerPixel(position)); // offset = widthEC
offset = offset / dot(miterPushNormal, right);
position.xyz += miterPushNormal * (offset * sign(0.5 - mod(startFaceNormalAndVertexCorner.w, 2.0)));
gl_Position = czm_depthClamp(czm_projection * position);
position = u_modifiedModelView * vec4(startPositionAndHeight.xyz, 1.0);
vec3 startNormalEC = czm_normal * startFaceNormalAndVertexCorner.xyz;
v_startPlaneEC = vec4(startNormalEC, -dot(startNormalEC, position.xyz));
v_rightPlaneEC = vec4(right, -dot(right, position.xyz));
position = u_modifiedModelView * vec4(endPositionAndHeight.xyz, 1.0);
vec3 endNormalEC = czm_normal * endFaceNormalAndHalfWidth.xyz;
v_endPlaneEC = vec4(endNormalEC, -dot(endNormalEC, position.xyz));
v_halfWidth = endFaceNormalAndHalfWidth.w;
}
`;var lM=`in vec4 v_startPlaneEC;
in vec4 v_endPlaneEC;
in vec4 v_rightPlaneEC;
in float v_halfWidth;
in vec3 v_volumeUpEC;
uniform vec4 u_highlightColor;
void main()
{
float logDepthOrDepth = czm_branchFreeTernary(czm_sceneMode == czm_sceneMode2D, gl_FragCoord.z, czm_unpackDepth(texture(czm_globeDepthTexture, gl_FragCoord.xy / czm_viewport.zw)));
// Discard for sky
if (logDepthOrDepth == 0.0) {
#ifdef DEBUG_SHOW_VOLUME
out_FragColor = vec4(0.0, 0.0, 1.0, 0.5);
return;
#else // DEBUG_SHOW_VOLUME
discard;
#endif // DEBUG_SHOW_VOLUME
}
vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);
eyeCoordinate /= eyeCoordinate.w;
float halfMaxWidth = v_halfWidth * czm_metersPerPixel(eyeCoordinate);
// Expand halfMaxWidth if direction to camera is almost perpendicular with the volume's up direction
halfMaxWidth += halfMaxWidth * (1.0 - dot(-normalize(eyeCoordinate.xyz), v_volumeUpEC));
// Check distance of the eye coordinate against the right-facing plane
float widthwiseDistance = czm_planeDistance(v_rightPlaneEC, eyeCoordinate.xyz);
// Check eye coordinate against the mitering planes
float distanceFromStart = czm_planeDistance(v_startPlaneEC, eyeCoordinate.xyz);
float distanceFromEnd = czm_planeDistance(v_endPlaneEC, eyeCoordinate.xyz);
if (abs(widthwiseDistance) > halfMaxWidth || distanceFromStart < 0.0 || distanceFromEnd < 0.0) {
#ifdef DEBUG_SHOW_VOLUME
out_FragColor = vec4(logDepthOrDepth, 0.0, 0.0, 0.5);
return;
#else // DEBUG_SHOW_VOLUME
discard;
#endif // DEBUG_SHOW_VOLUME
}
out_FragColor = u_highlightColor;
czm_writeDepthClamp();
}
`;function zp(e){this._positions=e.positions,this._widths=e.widths,this._counts=e.counts,this._batchIds=e.batchIds,this._ellipsoid=y(e.ellipsoid,oe.WGS84),this._minimumHeight=e.minimumHeight,this._maximumHeight=e.maximumHeight,this._center=e.center,this._rectangle=e.rectangle,this._batchTable=e.batchTable,this._va=void 0,this._sp=void 0,this._rs=void 0,this._uniformMap=void 0,this._command=void 0,this._transferrableBatchIds=void 0,this._packedBuffer=void 0,this._minimumMaximumVectorHeights=new H(ri._defaultMinTerrainHeight,ri._defaultMaxTerrainHeight),this._boundingVolume=Mn.fromRectangle(e.rectangle,ri._defaultMinTerrainHeight,ri._defaultMaxTerrainHeight,this._ellipsoid),this._classificationType=e.classificationType,this._keepDecodedPositions=e.keepDecodedPositions,this._decodedPositions=void 0,this._decodedPositionOffsets=void 0,this._startEllipsoidNormals=void 0,this._endEllipsoidNormals=void 0,this._startPositionAndHeights=void 0,this._startFaceNormalAndVertexCornerIds=void 0,this._endPositionAndHeights=void 0,this._endFaceNormalAndHalfWidths=void 0,this._vertexBatchIds=void 0,this._indices=void 0,this._constantColor=k.clone(k.WHITE),this._highlightColor=this._constantColor,this._trianglesLength=0,this._geometryByteLength=0,this._ready=!1,this._promise=void 0,this._error=void 0}Object.defineProperties(zp.prototype,{trianglesLength:{get:function(){return this._trianglesLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}}});function lHe(e,t,n){let i=ri.getMinimumMaximumHeights(t,n),o=i.minimumTerrainHeight,r=i.maximumTerrainHeight,s=e._minimumMaximumVectorHeights;s.x=o,s.y=r;let a=e._boundingVolume,c=e._rectangle;Mn.fromRectangle(c,o,r,n,a)}function uHe(e){let t=e._rectangle,n=e._minimumHeight,i=e._maximumHeight,o=e._ellipsoid,r=e._center,s=2+le.packedLength+oe.packedLength+m.packedLength,a=new Float64Array(s),c=0;return a[c++]=n,a[c++]=i,le.pack(t,a,c),c+=le.packedLength,oe.pack(o,a,c),c+=oe.packedLength,m.pack(r,a,c),a}var fHe=new gi("createVectorTileClampedPolylines"),jg={startEllipsoidNormal:0,endEllipsoidNormal:1,startPositionAndHeight:2,endPositionAndHeight:3,startFaceNormalAndVertexCorner:4,endFaceNormalAndHalfWidth:5,a_batchId:6};function dHe(e,t){if(u(e._va))return;let n=e._positions,i=e._widths,o=e._counts,r=e._transferrableBatchIds,s=e._packedBuffer;u(s)||(n=e._positions=n.slice(),i=e._widths=i.slice(),o=e._counts=o.slice(),r=e._transferrableBatchIds=e._batchIds.slice(),s=e._packedBuffer=uHe(e));let a=[n.buffer,i.buffer,o.buffer,r.buffer,s.buffer],c={positions:n.buffer,widths:i.buffer,counts:o.buffer,batchIds:r.buffer,packedBuffer:s.buffer,keepDecodedPositions:e._keepDecodedPositions},l=fHe.scheduleTask(c,a);if(u(l))return l.then(function(f){if(e.isDestroyed())return;e._keepDecodedPositions&&(e._decodedPositions=new Float64Array(f.decodedPositions),e._decodedPositionOffsets=new Uint32Array(f.decodedPositionOffsets)),e._startEllipsoidNormals=new Float32Array(f.startEllipsoidNormals),e._endEllipsoidNormals=new Float32Array(f.endEllipsoidNormals),e._startPositionAndHeights=new Float32Array(f.startPositionAndHeights),e._startFaceNormalAndVertexCornerIds=new Float32Array(f.startFaceNormalAndVertexCornerIds),e._endPositionAndHeights=new Float32Array(f.endPositionAndHeights),e._endFaceNormalAndHalfWidths=new Float32Array(f.endFaceNormalAndHalfWidths),e._vertexBatchIds=new Uint16Array(f.vertexBatchIds);let d=f.indexDatatype;e._indices=d===Ue.UNSIGNED_SHORT?new Uint16Array(f.indices):new Uint32Array(f.indices),mHe(e,t),e._ready=!0}).catch(f=>{e.isDestroyed()||(e._error=f)})}function mHe(e,t){if(!u(e._va)){let n=e._startEllipsoidNormals,i=e._endEllipsoidNormals,o=e._startPositionAndHeights,r=e._endPositionAndHeights,s=e._startFaceNormalAndVertexCornerIds,a=e._endFaceNormalAndHalfWidths,c=e._vertexBatchIds,l=e._indices,f=n.byteLength+i.byteLength;f+=o.byteLength+r.byteLength,f+=s.byteLength+a.byteLength,f+=c.byteLength+l.byteLength,e._trianglesLength=l.length/3,e._geometryByteLength=f;let d=ut.createVertexBuffer({context:t,typedArray:n,usage:Fe.STATIC
Geometric error: ${e.geometricError}`,o++),t.debugShowRenderingStatistics&&(i+=`
Commands: ${e.commandsLength}`,o++,e.content.pointsLength>0&&(i+=`
Points: ${e.content.pointsLength}`,o++),e.content.trianglesLength>0&&(i+=`
Triangles: ${e.content.trianglesLength}`,o++),i+=`
Features: ${e.content.featuresLength}`,o++),t.debugShowMemoryUsage&&(i+=`
Texture Memory: ${Nse(e.content.texturesByteLength)}`,i+=`
Geometry Memory: ${Nse(e.content.geometryByteLength)}`,o+=2),t.debugShowUrl)if(e.hasMultipleContents){i+=`
Urls:`;let s=e.content.innerContentUrls;for(let a=0;a<s.length;a++)i+=`
- ${s[a]}`;o+=s.length}else i+=`
Url: ${e._contentHeader.uri}`,o++;let r={text:i.substring(1),position:n,font:`${19-o}px sans-serif`,showBackground:!0,disableDepthTestDistance:Number.POSITIVE_INFINITY};return t._tileDebugLabels.add(r)}function h5e(e,t){let n=e._selectedTiles,i=n.length,o=e._emptyTiles,r=o.length;if(e._tileDebugLabels.removeAll(),e.debugPickedTileLabelOnly){if(u(e.debugPickedTile)){let s=u(e.debugPickPosition)?e.debugPickPosition:s9(e.debugPickedTile),a=a9(e.debugPickedTile,e,s);a.pixelOffset=new H(15,-15)}}else{for(let s=0;s<i;++s){let a=n[s];a9(a,e,s9(a))}for(let s=0;s<r;++s){let a=o[s];(a.hasTilesetContent||a.hasImplicitContent)&&a9(a,e,s9(a))}}e._tileDebugLabels.update(t)}function p5e(e,t,n){e._styleEngine.applyStyle(e),e._styleApplied=!0;let{commandList:i,context:o}=t,r=i.length,s=e._selectedTiles,a=e.isSkippingLevelOfDetail&&e._hasMixedContent&&o.stencilBuffer&&s.length>0;e._backfaceCommands.length=0,a&&(u(e._stencilClearCommand)||(e._stencilClearCommand=new li({stencil:0,pass:be.CESIUM_3D_TILE,renderState:ke.fromCache({stencilMask:Lt.SKIP_LOD_MASK})})),i.push(e._stencilClearCommand));let{statistics:c,tileVisible:l}=e,f=n.isRender,d=i.length;for(let h=0;h<s.length;++h){let A=s[h];f&&l.raiseEvent(A),A.update(e,t,n),c.incrementSelectionCounts(A.content),++c.selected}let p=e._emptyTiles;for(let h=0;h<p.length;++h)p[h].update(e,t,n);let g=i.length-d;if(e._backfaceCommands.trim(),a){let h=e._backfaceCommands.values,A=h.length;i.length+=A;for(let x=g-1;x>=0;--x)i[d+A+x]=i[d+x];for(let x=0;x<A;++x)i[d+x]=h[x]}g=i.length-r,c.numberOfCommands=g,f&&(e.pointCloudShading.attenuation&&e.pointCloudShading.eyeDomeLighting&&g>0&&e._pointCloudEyeDomeLighting.update(t,r,e.pointCloudShading,e.boundingSphere),e.debugShowGeometricError||e.debugShowRenderingStatistics||e.debugShowMemoryUsage||e.debugShowUrl?(u(e._tileDebugLabels)||(e._tileDebugLabels=new Ym),h5e(e,t)):e._tileDebugLabels=e._tileDebugLabels&&e._tileDebugLabels.destroy())}var Vse=[];function _5e(e,t){let n=t,i=Vse;for(i.push(t);i.length>0;){t=i.pop();let o=t.children;for(let r=0;r<o.length;++r)i.push(o[r]);t!==n&&(g5e(e,t),--e._statistics.numberOfTilesTotal)}n.children=[]}function kse(e,t){e.tileUnload.raiseEvent(t),e._statistics.decrementLoadCounts(t.content),--e._statistics.numberOfTilesWithContentReady,t.unloadContent()}function g5e(e,t){e._cache.unloadTile(e,t,kse),t.destroy()}yr.prototype.trimLoadedTiles=function(){this._cache.trim()};function y5e(e,t){let n=e._statistics,i=e._statisticsLast,o=n.numberOfPendingRequests,r=n.numberOfTilesProcessing,s=i.numberOfPendingRequests,a=i.numberOfTilesProcessing;$p.clone(n,i);let c=o!==s||r!==a;c&&t.afterRender.push(function(){return e.loadProgress.raiseEvent(o,r),!0}),e._tilesLoaded=n.numberOfPendingRequests===0&&n.numberOfTilesProcessing===0&&n.numberOfAttemptedRequests===0,c&&e._tilesLoaded&&(t.afterRender.push(function(){return e.allTilesLoaded.raiseEvent(),!0}),e._initialTilesLoaded||(e._initialTilesLoaded=!0,t.afterRender.push(function(){return e.initialTilesLoaded.raiseEvent(),!0})))}function A5e(e){e._heatmap.resetMinimumMaximum(),e._minimumPriority.depth=Number.MAX_VALUE,e._maximumPriority.depth=-Number.MAX_VALUE,e._minimumPriority.foveatedFactor=Number.MAX_VALUE,e._maximumPriority.foveatedFactor=-Number.MAX_VALUE,e._minimumPriority.distance=Number.MAX_VALUE,e._maximumPriority.distance=-Number.MAX_VALUE,e._minimumPriority.reverseScreenSpaceError=Number.MAX_VALUE,e._maximumPriority.reverseScreenSpaceError=-Number.MAX_VALUE}function x5e(e,t){t.frameNumber===e._updatedModelMatrixFrame&&u(e._previousModelMatrix)||(e._updatedModelMatrixFrame=t.frameNumber,e._modelMatrixChanged=!B.equals(e.modelMatrix,e._previousModelMatrix),e._modelMatrixChanged&&(e._previousModelMatrix=B.clone(e.modelMatrix,e._previousModelMatrix)))}function C5e(e,t,n,i){if(t.mode===ne.MORPHING||!u(e._root))return!1;let o=e._statistics;o.clear(),++e._updatedVisibilityFrame,A5e(e),x5e(e,t),e._cullRequestsWhileMoving=e.cullRequestsWhileMoving&&!e._modelMatrixChanged;let r=e.getTraversal(i).selectTiles(e,t);if(i.requestTiles&&u5e(e),p5e(e,t,i),$p.clone(o,n),i.isRender){let s=
in vec4 v_outlineColor;
in float v_innerPercent;
in float v_pixelDistance;
in vec4 v_pickColor;
void main()
{
// The distance in UV space from this fragment to the center of the point, at most 0.5.
float distanceToCenter = length(gl_PointCoord - vec2(0.5));
// The max distance stops one pixel shy of the edge to leave space for anti-aliasing.
float maxDistance = max(0.0, 0.5 - v_pixelDistance);
float wholeAlpha = 1.0 - smoothstep(maxDistance, 0.5, distanceToCenter);
float innerAlpha = 1.0 - smoothstep(maxDistance * v_innerPercent, 0.5 * v_innerPercent, distanceToCenter);
vec4 color = mix(v_outlineColor, v_color, innerAlpha);
color.a *= wholeAlpha;
// Fully transparent parts of the billboard are not pickable.
#if !defined(OPAQUE) && !defined(TRANSLUCENT)
if (color.a < 0.005) // matches 0/255 and 1/255
{
discard;
}
#else
// The billboard is rendered twice. The opaque pass discards translucent fragments
// and the translucent pass discards opaque fragments.
#ifdef OPAQUE
if (color.a < 0.995) // matches < 254/255
{
discard;
}
#else
if (color.a >= 0.995) // matches 254/255 and 255/255
{
discard;
}
#endif
#endif
out_FragColor = czm_gammaCorrect(color);
czm_writeLogDepth();
}
`;var ZM=`uniform float u_maxTotalPointSize;
in vec4 positionHighAndSize;
in vec4 positionLowAndOutline;
in vec4 compressedAttribute0; // color, outlineColor, pick color
in vec4 compressedAttribute1; // show, translucency by distance, some free space
in vec4 scaleByDistance; // near, nearScale, far, farScale
in vec3 distanceDisplayConditionAndDisableDepth; // near, far, disableDepthTestDistance
out vec4 v_color;
out vec4 v_outlineColor;
out float v_innerPercent;
out float v_pixelDistance;
out vec4 v_pickColor;
const float SHIFT_LEFT8 = 256.0;
const float SHIFT_RIGHT8 = 1.0 / 256.0;
void main()
{
// Modifying this shader may also require modifications to PointPrimitive._computeScreenSpacePosition
// unpack attributes
vec3 positionHigh = positionHighAndSize.xyz;
vec3 positionLow = positionLowAndOutline.xyz;
float outlineWidthBothSides = 2.0 * positionLowAndOutline.w;
float totalSize = positionHighAndSize.w + outlineWidthBothSides;
float outlinePercent = outlineWidthBothSides / totalSize;
// Scale in response to browser-zoom.
totalSize *= czm_pixelRatio;
float temp = compressedAttribute1.x * SHIFT_RIGHT8;
float show = floor(temp);
#ifdef EYE_DISTANCE_TRANSLUCENCY
vec4 translucencyByDistance;
translucencyByDistance.x = compressedAttribute1.z;
translucencyByDistance.z = compressedAttribute1.w;
translucencyByDistance.y = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;
temp = compressedAttribute1.y * SHIFT_RIGHT8;
translucencyByDistance.w = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;
#endif
///////////////////////////////////////////////////////////////////////////
vec4 color;
vec4 outlineColor;
vec4 pickColor;
// compressedAttribute0.z => pickColor.rgb
temp = compressedAttribute0.z * SHIFT_RIGHT8;
pickColor.b = (temp - floor(temp)) * SHIFT_LEFT8;
temp = floor(temp) * SHIFT_RIGHT8;
pickColor.g = (temp - floor(temp)) * SHIFT_LEFT8;
pickColor.r = floor(temp);
// compressedAttribute0.x => color.rgb
temp = compressedAttribute0.x * SHIFT_RIGHT8;
color.b = (temp - floor(temp)) * SHIFT_LEFT8;
temp = floor(temp) * SHIFT_RIGHT8;
color.g = (temp - floor(temp)) * SHIFT_LEFT8;
color.r = floor(temp);
// compressedAttribute0.y => outlineColor.rgb
temp = compressedAttribute0.y * SHIFT_RIGHT8;
outlineColor.b = (temp - floor(temp)) * SHIFT_LEFT8;
temp = floor(temp) * SHIFT_RIGHT8;
outlineColor.g = (temp - floor(temp)) * SHIFT_LEFT8;
outlineColor.r = floor(temp);
// compressedAttribute0.w => color.a, outlineColor.a, pickColor.a
temp = compressedAttribute0.w * SHIFT_RIGHT8;
pickColor.a = (temp - floor(temp)) * SHIFT_LEFT8;
pickColor = pickColor / 255.0;
temp = floor(temp) * SHIFT_RIGHT8;
outlineColor.a = (temp - floor(temp)) * SHIFT_LEFT8;
outlineColor /= 255.0;
color.a = floor(temp);
color /= 255.0;
///////////////////////////////////////////////////////////////////////////
vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);
vec4 positionEC = czm_modelViewRelativeToEye * p;
///////////////////////////////////////////////////////////////////////////
#if defined(EYE_DISTANCE_SCALING) || defined(EYE_DISTANCE_TRANSLUCENCY) || defined(DISTANCE_DISPLAY_CONDITION) || defined(DISABLE_DEPTH_DISTANCE)
float lengthSq;
if (czm_sceneMode == czm_sceneMode2D)
{
// 2D camera distance is a special case
// treat all billboards as flattened to the z=0.0 plane
lengthSq = czm_eyeHeight2D.y;
}
else
{
lengthSq = dot(positionEC.xyz, positionEC.xyz);
}
#endif
#ifdef EYE_DISTANCE_SCALING
totalSize *= czm_nearFarScalar(scaleByDistance, lengthSq);
#endif
if (totalSize > 0.0) {
// Add padding for anti-aliasing on both sides.
totalSize += 3.0;
}
// Clamp to max point size.
totalSize = min(totalSize, u_maxTotalPointSize);
// If size is too small, push vertex behind near plane for clipping.
// Note that context.minimumAliasedPointSize "will be at most 1.0".
if (totalSize < 1.0)
{
positionEC.xyz = vec3(0.0);
totalSize = 1.0;
}
float translucency = 1.0;
#ifdef EYE_DISTANCE_TRANSLUCENCY
translucency = czm_nearFarScalar(translucencyByDistance, lengthSq);
// push vertex behind near plane for clipping
if (translucency < 0.004)
{
positionEC.xyz = vec3(0.0);
}
#endif
#ifdef DISTANCE_DISPLAY_CONDITION
float nearSq = distanceDisplayConditionAndDisableDepth.x;
float farSq = distanceDisplayConditionAndDisableDepth.y;
if (lengthSq < nearSq || lengthSq > farSq) {
// push vertex behind camera to force it to be clipped
positionEC.xyz = vec3(0.0, 0.0, 1.0);
}
#endif
gl_Position = czm_projection * positionEC;
czm_vertexLogDepth();
#ifdef DISABLE_DEPTH_DISTANCE
float disableDepthTestDistance = distanceDisplayConditionAndDisableDepth.z;
if (disableDepthTestDistance == 0.0 && czm_minimumDisableDepthTestDistance != 0.0)
{
disableDepthTestDistance = czm_minimumDisableDepthTestDistance;
}
if (disableDepthTestDistance != 0.0)
{
// Don't try to "multiply both sides" by w. Greater/less-than comparisons won't work for negative values of w.
float zclip = gl_Position.z / gl_Position.w;
bool clipped = (zclip < -1.0 || zclip > 1.0);
if (!clipped && (disableDepthTestDistance < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistance)))
{
// Position z on the near plane.
gl_Position.z = -gl_Position.w;
#ifdef LOG_DEPTH
czm_vertexLogDepth(vec4(czm_currentFrustum.x));
#endif
}
}
#endif
v_color = color;
v_color.a *= translucency * show;
v_outlineColor = outlineColor;
v_outlineColor.a *= translucency * show;
v_innerPercent = 1.0 - outlinePercent;
v_pixelDistance = 2.0 / totalSize;
gl_PointSize = totalSize * show;
gl_Position *= show;
v_pickColor = pickColor;
}
`;var I6e=Ps.SHOW_INDEX,v9=Ps.POSITION_INDEX,Nae=Ps.COLOR_INDEX,P6e=Ps.OUTLINE_COLOR_INDEX,O6e=Ps.OUTLINE_WIDTH_INDEX,M6e=Ps.PIXEL_SIZE_INDEX,Fae=Ps.SCALE_BY_DISTANCE_INDEX,Uae=Ps.TRANSLUCENCY_BY_DISTANCE_INDEX,Vae=Ps.DISTANCE_DISPLAY_CONDITION_INDEX,R6e=Ps.DISABLE_DEPTH_DISTANCE_INDEX,w9=Ps.NUMBER_OF_PROPERTIES,nc={positionHighAndSize:0,positionLowAndOutline:1,compressedAttribute0:2,compressedAttribute1:3,scaleByDistance:4,distanceDisplayConditionAndDisableDepth:5};function xf(e){e=y(e,y.EMPTY_OBJECT),this._sp=void 0,this._spTranslucent=void 0,this._rsOpaque=void 0,this._rsTranslucent=void 0,this._vaf=void 0,this._pointPrimitives=[],this._pointPrimitivesToUpdate=[],this._pointPrimitivesToUpdateIndex=0,this._pointPrimitivesRemoved=!1,this._createVertexArray=!1,this._shaderScaleByDistance=!1,this._compiledShaderScaleByDistance=!1,this._shaderTranslucencyByDistance=!1,this._compiledShaderTranslucencyByDistance=!1,this._shaderDistanceDisplayCondition=!1,this._compiledShaderDistanceDisplayCondition=!1,this._shaderDisableDepthDistance=!1,this._compiledShaderDisableDepthDistance=!1,this._propertiesChanged=new Uint32Array(w9),this._maxPixelSize=1,this._baseVolume=new ae,this._baseVolumeWC=new ae,this._baseVolume2D=new ae,this._boundingVolume=new ae,this._boundingVolumeDirty=!1,this._colorCommands=[],this.show=y(e.show,!0),this.modelMatrix=B.clone(y(e.modelMatrix,B.IDENTITY)),this._modelMatrix=B.clone(B.IDENTITY),this.debugShowBoundingVolume=y(e.debugShowBoundingVolume,!1),this.blendOption=y(e.blendOption,bo.OPAQUE_AND_TRANSLUCENT),this._blendOption=void 0,this._mode=ne.SCENE3D,this._maxTotalPointSize=1,this._buffersUsage=[Fe.STATIC_DRAW,Fe.STATIC_DRAW,Fe.STATIC_DRAW,Fe.STATIC_DRAW,Fe.STATIC_DRAW,Fe.STATIC_DRAW,Fe.STATIC_DRAW,Fe.STATIC_DRAW,Fe.STATIC_DRAW];let t=this;this._uniforms={u_maxTotalPointSize:function(){return t._maxTotalPointSize}}}Object.defineProperties(xf.prototype,{length:{get:function(){return D9(this),this._pointPrimitives.length}}});function kae(e){let t=e.length;for(let n=0;n<t;++n)e[n]&&e[n]._destroy()}xf.prototype.add=function(e){let t=new Ps(e,this);return t._index=this._pointPrimitives.length,this._pointPrimitives.push(t),this._createVertexArray=!0,t};xf.prototype.remove=function(e){return this.contains(e)?(this._pointPrimitives[e._index]=null,this._pointPrimitivesRemoved=!0,this._createVertexArray=!0,e._destroy(),!0):!1};xf.prototype.removeAll=function(){kae(this._pointPrimitives),this._pointPrimitives=[],this._pointPrimitivesToUpdate=[],this._pointPrimitivesToUpdateIndex=0,this._pointPrimitivesRemoved=!1,this._createVertexArray=!0};function D9(e){if(e._pointPrimitivesRemoved){e._pointPrimitivesRemoved=!1;let t=[],n=e._pointPrimitives,i=n.length;for(let o=0,r=0;o<i;++o){let s=n[o];s&&(s._index=r++,t.push(s))}e._pointPrimitives=t}}xf.prototype._updatePointPrimitive=function(e,t){e._dirty||(this._pointPrimitivesToUpdate[this._pointPrimitivesToUpdateIndex++]=e),++this._propertiesChanged[t]};xf.prototype.contains=function(e){return u(e)&&e._pointPrimitiveCollection===this};xf.prototype.get=function(e){return D9(this),this._pointPrimitives[e]};xf.prototype.computeNewBuffersUsage=function(){let e=this._buffersUsage,t=!1,n=this._propertiesChanged;for(let i=0;i<w9;++i){let o=n[i]===0?Fe.STATIC_DRAW:Fe.STREAM_DRAW;t=t||e[i]!==o,e[i]=o}return t};function B6e(e,t,n){return new Lp(e,[{index:nc.positionHighAndSize,componentsPerAttribute:4,componentDatatype:X.FLOAT,usage:n[v9]},{index:nc.positionLowAndShow,componentsPerAttribute:4,componentDatatype:X.FLOAT,usage:n[v9]},{index:nc.compressedAttribute0,componentsPerAttribute:4,componentDatatype:X.FLOAT,usage:n[Nae]},{index:nc.compressedAttribute1,componentsPerAttribute:4,componentDatatype:X.FLOAT,usage:n[Uae]},{index:nc.scaleByDistance,componentsPerAttribute:4,componentDatatype:X.FLOAT,usage:n[Fae]},{index:nc.distanceDisplayConditionAndDisableDepth,componentsPerAttribute:3,componentDatatype:X.FLOAT,usage:n[Vae]}],t)}var b9=new Gn;function zae(e,t,n,i){let o=i._index,r=i._getActualPosition();e._mode===ne.SCENE3D&&(ae.expand(e._baseVolume,r,e._baseVolume),e._boundingVolume
in vec2 textureCoordinates;
out vec2 v_textureCoordinates;
void main()
{
gl_Position = position;
v_textureCoordinates = textureCoordinates;
}
`;function g4(e){this._context=e}var OB,aZe=new nt({primitiveType:Le.TRIANGLES}),cZe=new li({color:new k(0,0,0,0)});function lZe(e,t){return new Ks({context:e,colorTextures:[t],destroyAttachments:!1})}function uZe(e,t){return Jt.fromCache({context:e,vertexShaderSource:Nx,fragmentShaderSource:t,attributeLocations:{position:0,textureCoordinates:1}})}function fZe(e,t){return(!u(OB)||OB.viewport.width!==e||OB.viewport.height!==t)&&(OB=ke.fromCache({viewport:new qe(0,0,e,t)})),OB}g4.prototype.execute=function(e){u(e.preExecute)&&e.preExecute(e);let t=e.outputTexture,n=t.width,i=t.height,o=this._context,r=u(e.vertexArray)?e.vertexArray:o.getViewportQuadVertexArray(),s=u(e.shaderProgram)?e.shaderProgram:uZe(o,e.fragmentShaderSource),a=lZe(o,t),c=fZe(n,i),l=e.uniformMap,f=cZe;f.framebuffer=a,f.renderState=c,f.execute(o);let d=aZe;d.vertexArray=r,d.renderState=c,d.shaderProgram=s,d.uniformMap=l,d.framebuffer=a,d.execute(o),a.destroy(),e.persists||(s.destroy(),u(e.vertexArray)&&r.destroy()),u(e.postExecute)&&e.postExecute(t)};g4.prototype.isDestroyed=function(){return!1};g4.prototype.destroy=function(){return ue(this)};var MB=g4;function dZe(e){this.context=e,this.framebuffer=void 0,this.blendingEnabled=void 0,this.scissorTest=void 0,this.viewport=void 0}var sc=dZe;function nm(e){this._context=e,this._shaders={},this._numberOfShaders=0,this._shadersToRelease={}}Object.defineProperties(nm.prototype,{numberOfShaders:{get:function(){return this._numberOfShaders}}});nm.prototype.replaceShaderProgram=function(e){return u(e.shaderProgram)&&e.shaderProgram.destroy(),this.getShaderProgram(e)};function mZe(e){let t=Object.keys(e).sort();return JSON.stringify(e,t)}nm.prototype.getShaderProgram=function(e){let t=e.vertexShaderSource,n=e.fragmentShaderSource,i=e.attributeLocations;typeof t=="string"&&(t=new He({sources:[t]})),typeof n=="string"&&(n=new He({sources:[n]}));let o=t.getCacheKey(),r=n.getCacheKey(),s=u(i)?mZe(i):"",a=`${o}:${r}:${s}`,c;if(u(this._shaders[a]))c=this._shaders[a],delete this._shadersToRelease[a];else{let l=this._context,f=t.createCombinedVertexShader(l),d=n.createCombinedFragmentShader(l),p=new Jt({gl:l._gl,logShaderCompilation:l.logShaderCompilation,debugShaders:l.debugShaders,vertexShaderSource:t,vertexShaderText:f,fragmentShaderSource:n,fragmentShaderText:d,attributeLocations:i});c={cache:this,shaderProgram:p,keyword:a,derivedKeywords:[],count:0},p._cachedShader=c,this._shaders[a]=c,++this._numberOfShaders}return++c.count,c.shaderProgram};nm.prototype.replaceDerivedShaderProgram=function(e,t,n){let i=e._cachedShader,o=t+i.keyword,r=this._shaders[o];if(u(r)){oj(this,r);let s=i.derivedKeywords.indexOf(t);s>-1&&i.derivedKeywords.splice(s,1)}return this.createDerivedShaderProgram(e,t,n)};nm.prototype.getDerivedShaderProgram=function(e,t){let n=e._cachedShader,i=t+n.keyword,o=this._shaders[i];if(u(o))return o.shaderProgram};nm.prototype.createDerivedShaderProgram=function(e,t,n){let i=e._cachedShader,o=t+i.keyword,r=n.vertexShaderSource,s=n.fragmentShaderSource,a=n.attributeLocations;typeof r=="string"&&(r=new He({sources:[r]})),typeof s=="string"&&(s=new He({sources:[s]}));let c=this._context,l=r.createCombinedVertexShader(c),f=s.createCombinedFragmentShader(c),d=new Jt({gl:c._gl,logShaderCompilation:c.logShaderCompilation,debugShaders:c.debugShaders,vertexShaderSource:r,vertexShaderText:l,fragmentShaderSource:s,fragmentShaderText:f,attributeLocations:a}),p={cache:this,shaderProgram:d,keyword:o,derivedKeywords:[],count:0};return i.derivedKeywords.push(t),d._cachedShader=p,this._shaders[o]=p,d};function oj(e,t){let n=t.derivedKeywords,i=n.length;for(let o=0;o<i;++o){let r=n[o]+t.keyword,s=e._shaders[r];oj(e,s)}delete e._shaders[t.keyword],t.shaderProgram.finalDestroy()}nm.prototype.destroyReleasedShaderPrograms=function(){let e=this._shadersToRelease;for(let t in e)if(e.hasOwnProperty(t)){let n=e[t];oj(this,n),--this._numberOfShaders}this._shadersToRelease={}};nm.prototype.releaseShaderProgram=function(e){if(u(e)){let t=e._cachedShader;t&&--t.count===0&&(this._shadersToRelease[t.keyword]=t)}};nm.prototype.isDestroyed=
${o}`),t}var ph=E$e;function S4(e,t,n,i,o,r,s){this.provider=e,this.message=t,this.x=n,this.y=i,this.level=o,this.timesRetried=y(r,0),this.retry=!1,this.error=s}S4.reportError=function(e,t,n,i,o,r,s,a){let c=e;return u(e)?(c.provider=t,c.message=i,c.x=o,c.y=r,c.level=s,c.retry=!1,c.error=a,++c.timesRetried):c=new S4(t,i,o,r,s,0,a),u(n)&&n.numberOfListeners>0?n.raiseEvent(c):u(t)&&console.log(`An error occurred in "${t.constructor.name}": ${ph(i)}`),c};S4.reportSuccess=function(e){u(e)&&(e.timesRetried=-1)};var Ai=S4;function Ly(e){if(e=y(e,y.EMPTY_OBJECT),this._ellipsoid=y(e.ellipsoid,oe.WGS84),this._numberOfLevelZeroTilesX=y(e.numberOfLevelZeroTilesX,1),this._numberOfLevelZeroTilesY=y(e.numberOfLevelZeroTilesY,1),this._projection=new wi(this._ellipsoid),u(e.rectangleSouthwestInMeters)&&u(e.rectangleNortheastInMeters))this._rectangleSouthwestInMeters=e.rectangleSouthwestInMeters,this._rectangleNortheastInMeters=e.rectangleNortheastInMeters;else{let i=this._ellipsoid.maximumRadius*Math.PI;this._rectangleSouthwestInMeters=new H(-i,-i),this._rectangleNortheastInMeters=new H(i,i)}let t=this._projection.unproject(this._rectangleSouthwestInMeters),n=this._projection.unproject(this._rectangleNortheastInMeters);this._rectangle=new le(t.longitude,t.latitude,n.longitude,n.latitude)}Object.defineProperties(Ly.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}});Ly.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e};Ly.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e};Ly.prototype.rectangleToNativeRectangle=function(e,t){let n=this._projection,i=n.project(le.southwest(e)),o=n.project(le.northeast(e));return u(t)?(t.west=i.x,t.south=i.y,t.east=o.x,t.north=o.y,t):new le(i.x,i.y,o.x,o.y)};Ly.prototype.tileXYToNativeRectangle=function(e,t,n,i){let o=this.getNumberOfXTilesAtLevel(n),r=this.getNumberOfYTilesAtLevel(n),s=(this._rectangleNortheastInMeters.x-this._rectangleSouthwestInMeters.x)/o,a=this._rectangleSouthwestInMeters.x+e*s,c=this._rectangleSouthwestInMeters.x+(e+1)*s,l=(this._rectangleNortheastInMeters.y-this._rectangleSouthwestInMeters.y)/r,f=this._rectangleNortheastInMeters.y-t*l,d=this._rectangleNortheastInMeters.y-(t+1)*l;return u(i)?(i.west=a,i.south=d,i.east=c,i.north=f,i):new le(a,d,c,f)};Ly.prototype.tileXYToRectangle=function(e,t,n,i){let o=this.tileXYToNativeRectangle(e,t,n,i),r=this._projection,s=r.unproject(new H(o.west,o.south)),a=r.unproject(new H(o.east,o.north));return o.west=s.longitude,o.south=s.latitude,o.east=a.longitude,o.north=a.latitude,o};Ly.prototype.positionToTileXY=function(e,t,n){let i=this._rectangle;if(!le.contains(i,e))return;let o=this.getNumberOfXTilesAtLevel(t),r=this.getNumberOfYTilesAtLevel(t),a=(this._rectangleNortheastInMeters.x-this._rectangleSouthwestInMeters.x)/o,l=(this._rectangleNortheastInMeters.y-this._rectangleSouthwestInMeters.y)/r,d=this._projection.project(e),p=d.x-this._rectangleSouthwestInMeters.x,g=this._rectangleNortheastInMeters.y-d.y,h=p/a|0;h>=o&&(h=o-1);let A=g/l|0;return A>=r&&(A=r-1),u(n)?(n.x=h,n.y=A,n):new H(h,A)};var Nr=Ly;var b$e=15;function dj(e){this.ellipsoid=y(e.ellipsoid,oe.WGS84),this.credit=void 0,this.tilingScheme=void 0,this.height=void 0,this.width=void 0,this.encoding=void 0,this.lodCount=void 0,this.hasAvailability=!1,this.tilesAvailable=void 0,this.tilesAvailabilityLoaded=void 0,this.levelZeroMaximumGeometricError=void 0,this.terrainDataStructure=void 0}dj.prototype.build=function(e){e._credit=this.credit,e._tilingScheme=this.tilingScheme,e._height=this.height,e._width=this.width,e._encoding=this.encoding,e._lodCount=this.lodCount,e._hasAvailability=this.hasAvailability,e._tilesAvailable=this.tilesAvailable,e._tilesAvailabilityLoaded=this.tilesAvailabilityLoaded,e._levelZeroMaximumGeometricError=this.levelZeroMaximumGeometricError,e._terrainDataStructure=this.terrainDataStructure,e._ready=!0};function S$e(e,t){let n=t.copyrightText;u(n)&&(e.credit=new Xt(n));let i=t.s
${t.message}`),e.previousError=Ai.reportError(e.previousError,n,u(n)?n._errorEvent:void 0,i),e.previousError.retry)return I4(e,n);throw new de(i)}async function H$e(e,t,n){await epe(e,t,n);let i=e.overallAvailability.length;if(i>0){let o=e.availability=new om(e.tilingScheme,e.overallMaxZoom);for(let r=0;r<i;++r){let s=e.overallAvailability[r];for(let a=0;a<s.length;++a){let c=s[a];o.addAvailableTileRange(r,c[0],c[1],c[2],c[3])}}}if(e.attribution.length>0){let o=new Xt(e.attribution);e.tileCredits.push(o)}return!0}async function I4(e,t){try{let n=await e.layerJsonResource.fetchJson();return H$e(e,n,t)}catch(n){return u(n)&&n.statusCode===404?(await epe(e,{tilejson:"2.1.0",format:"heightmap-1.0",version:"1.0.0",scheme:"tms",tiles:["{z}/{x}/{y}.terrain?v={version}"]},t),!0):z$e(e,n,t)}}function vu(e){e=y(e,y.EMPTY_OBJECT),this._heightmapWidth=void 0,this._heightmapStructure=void 0,this._hasWaterMask=!1,this._hasVertexNormals=!1,this._hasMetadata=!1,this._scheme=void 0,this._ellipsoid=e.ellipsoid,this._requestVertexNormals=y(e.requestVertexNormals,!1),this._requestWaterMask=y(e.requestWaterMask,!1),this._requestMetadata=y(e.requestMetadata,!0),this._errorEvent=new ye;let t=e.credit;typeof t=="string"&&(t=new Xt(t)),this._credit=t,this._availability=void 0,this._tilingScheme=void 0,this._levelZeroMaximumGeometricError=void 0,this._layers=void 0,this._ready=!1,this._tileCredits=void 0,this._readyPromise=Promise.resolve(!0),u(e.url)&&($("CesiumTerrainProvider options.url","options.url was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use CesiumTerrainProvider.fromIonAssetId or CesiumTerrainProvider.fromUrl instead."),this._readyPromise=vu._initializeReadyPromise(e,this))}vu._initializeReadyPromise=async function(e,t){let n=await Promise.resolve(e.url),i=new Cj(e),o=Ie.createIfNeeded(n);return o.appendForwardSlash(),i.lastResource=o,i.layerJsonResource=i.lastResource.getDerivedResource({url:"layer.json"}),await I4(i,t),i.build(t),!0};var Aj={OCT_VERTEX_NORMALS:1,WATER_MASK:2,METADATA:4};function $he(e){return!u(e)||e.length===0?{Accept:"application/vnd.quantized-mesh,application/octet-stream;q=0.9,*/*;q=0.01"}:{Accept:`application/vnd.quantized-mesh;extensions=${e.join("-")},application/octet-stream;q=0.9,*/*;q=0.01`}}function G$e(e,t,n,i,o){let r=new Uint16Array(t,0,e._heightmapWidth*e._heightmapWidth);return new Sa({buffer:r,childTileMask:new Uint8Array(t,r.byteLength,1)[0],waterMask:new Uint8Array(t,r.byteLength+1,t.byteLength-r.byteLength-1),width:e._heightmapWidth,height:e._heightmapWidth,structure:e._heightmapStructure,credits:e._tileCredits})}function W$e(e,t,n,i,o,r){let s=r.littleEndianExtensionSize,a=0,c=3,l=c+1,f=Float64Array.BYTES_PER_ELEMENT*c,d=Float64Array.BYTES_PER_ELEMENT*l,p=3,g=Uint16Array.BYTES_PER_ELEMENT*p,h=3,A=Uint16Array.BYTES_PER_ELEMENT,x=A*h,C=new DataView(t),T=new m(C.getFloat64(a,!0),C.getFloat64(a+8,!0),C.getFloat64(a+16,!0));a+=f;let E=C.getFloat32(a,!0);a+=Float32Array.BYTES_PER_ELEMENT;let S=C.getFloat32(a,!0);a+=Float32Array.BYTES_PER_ELEMENT;let w=new ae(new m(C.getFloat64(a,!0),C.getFloat64(a+8,!0),C.getFloat64(a+16,!0)),C.getFloat64(a+f,!0));a+=d;let D=new m(C.getFloat64(a,!0),C.getFloat64(a+8,!0),C.getFloat64(a+16,!0));a+=f;let M=C.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let O=new Uint16Array(t,a,M*3);a+=M*g,M>64*1024&&(A=Uint32Array.BYTES_PER_ELEMENT,x=A*h);let L=O.subarray(0,M),N=O.subarray(M,2*M),_=O.subarray(M*2,3*M);Wn.zigZagDeltaDecode(L,N,_),a%A!==0&&(a+=A-a%A);let b=C.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let v=Ue.createTypedArrayFromArrayBuffer(M,t,a,b*h);a+=b*x;let I=0,R=v.length;for(let se=0;se<R;++se){let xe=v[se];v[se]=I-xe,xe===0&&++I}let F=C.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let z=Ue.createTypedArrayFromArrayBuffer(M,t,a,F);a+=F*A;let V=C.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let G=Ue.createTypedArrayFromArrayBuffer(M,t,a,V);a+=V*A;let U=C.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let q=Ue.createTypedArrayFromArrayBuffer(M,t,a,U);a+=U*A;let Y=C.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let Q=Ue.creat
wmi\xD6\xF0\x9Ck\x93\xA1\xBDNu\xE0A[\xDF@V\f\xD9\xBBr\x9B\x81|3S\xEEOl\xD4q\xB0{\xC0\x7FEVZ\xADwUe\v3\x92*\xACl5\xC50s\xF83>mF8J\xB4\xDD\xF0.\xDDu\xDA\x8CDt"\xFAa"\f3"So\xAF9D\v\x8C9\xD99L\xB9\xBF\x7F\xAB\\\x8CP_\x9F"ux\xE9\x07q\x91h;\xC1\xC4\x9B\x7F\xF0<VqH\x82'UfYNe\x98u\xA3aF}a?A\0\x9F\xD7\xB44M\xCE\x87F\xB0\xD5\xB8\x8A'{\x8B\xDC+\xBBMg0\xC8\xD1\xF6\\\x8FP\xFA[/F\x9Bn5/'C.\xEB
\f^\xA5s\x1Be4\xE5l.jC'c#U\xA9?q{gC}:\xAF\xCD\xE2TU\x9C\xFDK\xC6\xE2\x9F/(\xED\xCB\\\xC6-f\x07\x88\xA7;/*"N\xB0k.\xDD\r\x95}}G\xBAC\xB2\xB2+>M\xAA>}\xE6\xCEI\x89\xC6\xE6x\fa1-\xA4O\xA5~q \x88\xEC\r1\xE8N\v\0nPh}=\b\r\x95\xA6n\xA3h\x97$[k\xF3#\xF3\xB6s\xB3\r\v@\xC0\x9F\xD8Q]\xFA".j\xDFI\0\xB9\xA0wU\xC6\xEFj\xBF{GL\x7F\x83\xEE\xDC\xDCF\x85\xA9\xADS\x07+S4\x07\xFF\x94Y\xE48\xE81\x83N\xB9XFk\xCB-#\x86\x92p\x005\x88"\xCF1\xB2&/\xE7\xC3u-6,rt\xB0#G\xB7\xD3\xD1&\x857r\xE2\0\x8CD\xCF\xDA3-\xDE\`\x86i#i*|\xCDKQ\r\x95T9w.)\xEA\x1B\xA6P\xA2j\x8FoP\x99\\>T\xFB\xEFP[\v\x07E\x89m(w7\xDB\x8EJfJo\x99 \xE5p\xE2\xB9q~\fmI-z\xFEr\xC7\xF2Y0\x8F\xBB]s\xE5\xC9 \xEAx\xEC \x90\xF0\x8A\x7FB|G\`\xB0\xBD&\xB7q\xB6\xC7\x9F\xD13\x82=\xD3\xAB\xEEc\x99\xC8+S\xA0D\\q\xC6\xCCD2O<\xCA\xC0)=R\xD3aX\xA9}e\xB4\xDC\xCF\r\xF4=\xF1\b\xA9B\xDA# \xD8\xBF^PI\xF8M\xC0\xCBGLO\xF7{+\xD8\xC51\x92;\xB5o\xDCl\r\x92\x88\xD1\x9E\xDB?\xE2\xE9\xDA_\xD4\x84\xE2FaZ\xDEU\xCF\xA4\0\xBE\xFD\xCEg\xF1Ji\x97\xE6 H\xD8]\x7F~\xAEq N\xAE\xC0V\xA9\x91<\x82r\xE7v\xEC)I\xD6]-\x83\xE3\xDB6\xA9;f\x97\x87j\xD5\xB6=P^R\xB9K\xC7sWx\xC9\xF4.Y\x07\x95\x93o\xD0KW>''\xC7\`\xDB;\xED\x9ASD>?\x8D\x92mw\xA2
\xEB?R\xA8\xC6U^1I7\x85\xF4\xC5&-\xA9\xBF\x8B'T\xDA\xC3j \xE5*x\xB0\xD6\x90pr\xAA\x8Bh\xBD\x88\xF7_H\xB1~\xC0XL?f\xF9>\xE1e\xC0p\xA7\xCF8i\xAF\xF0VldI\x9C'\xADxtO\xC2\x87\xDEV9\0\xDAw\v\xCB-\x1B\x89\xFB5O\xF5\bQ\`\xC1
ZGM&30x\xDA\xC0\x9CFG\xE2[y\`In7gS
>\xE9\xECF9\xB2\xF14\r\xC6\x84Sun\xE1\fY\xD9\xDE)\x85{II\xA5wy\xBEIV.6\xE7\v:\xBBOb{\xD2M1\x95/\xBD8{\xA8O!\xE1\xECFpv\x95})"x\x88
\x90\xDD\x9D\\\xDA\xDEQ\xCF\xF0\xFCYRe|3\xDF\xF3H\xDA\xBB*u\xDB\`\xB2\xD4\xFC\xED\x1B\xEC\x7F5\xA8\xFF(1\x07-\xC8\xDC\x88F|\x8A["`);function Du(e){if(this.imageryPresent=!0,this.protoImagery=void 0,this.terrainPresent=!0,this.negativeAltitudeExponentBias=32,this.negativeAltitudeThreshold=P.EPSILON12,this.providers={},this.key=void 0,this._resource=void 0,this._quadPacketVersion=1,this._tileInfo={},this._subtreePromises={},this._readyPromise=Promise.resolve(!0),u(e)){$("GoogleEarthEnterpriseMetadata options.url","GoogleEarthEnterpriseMetadata constructor parmeter resourceOrUrl was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use GoogleEarthEnterpriseMetadata.fromUrl instead.");let t=e;typeof t!="string"&&!(t instanceof Ie)&&(t=e.url);let n=Ie.createIfNeeded(t);n.appendForwardSlash(),this._resource=n;let i=this;this._readyPromise=hpe(this).then(function(){return i.getQuadTreePacket("",i._quadPacketVersion)}).then(function(){return!0}).catch(function(o){let r=`An error occurred while accessing ${Nj(i,"",1).url}.`;return Promise.reject(new de(r))})}}Object.defineProperties(Du.prototype,{url:{get:function(){return this._resource.url}},proxy:{get:function(){return this._resource.proxy}},resource:{get:function(){return this._resource}},readyPromise:{get:function(){return $("GoogleEarthEnterpriseMetadata.readyPromise","GoogleEarthEnterpriseMetadata.readyPromise was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use GoogleEarthEnterpriseMetadata.fromUrl instead."),this._readyPromise}}});Du.fromUrl=async function(e){let t=e;typeof t!="string"&&!(t instanceof Ie)&&(t=e.url);let n=Ie.createIfNeeded(t);n.appendForwardSlash();let i=new Du;i._resource=n;try{await hpe(i),await i.getQuadTreePacket("",i._quadPacketVersion)}catch(o){let r=`An error occurred while accessing ${Nj(i,"",1).url}: ${o}`;throw new de(r)}return i};Du.tileXYToQuadKey=function(e,t,n){let i="";for(let o=n;o>=0;--o){let r=1<<o,s=0;uc(t,r)?uc(e,r)&&(s|=1):(s|=2,uc(e,r)||(s|=1)),i+=s}return i};Du.quadKeyToTileXY=function(e){let t=0,n=0,i=e.length-1;for(let o=i;o>=0;--o){let r=1<<o,s=+e[i-o];uc(s,2)?uc(s,1)||(t|=r):(n|=r,uc(s,1)&&(t|=r))}return{x:t,y:n,level:i}};Du.prototype.isValid=function(e){let t=this.getTileInformationFromQuadKey(e);if(u(t))return t!==null;let n=!0,i=e,o;for(;i.length>1;)if(o=i.substring(i.length-1),i=i.substring(0,i.length-1),t=this.getTileInformationFromQuadKey(i),u(t)){!t.hasSubtree()&&!t.hasChild(parseInt(o))&&(n=!1);break}else if(t===null){n=!1;break}return n};var mpe=new gi("decodeGoogleEarthEnterprisePacket");Du.prototype.getQuadTreePacket=function(e,t,n){t=y(t,1),e=y(e,"");let o=Nj(this,e,t,n).fetchArrayBuffer();if(!u(o))return;let r=this._tileInfo,s=this.key;return o.then(function(a){return mpe.scheduleTask({buffer:a,quadKey:e,type:"Metadata",key:s},[a]).then(function(l){let f,d=-1;if(e!==""){d=e.length+1;let h=l[e];f=r[e],f._bits|=h._bits,delete l[e]}let p=Object.keys(l);p.sort(function(h,A){return h.length-A.length});let g=p.length;for(let h=0;h<g;++h){let A=p[h];if(l[A]!==null){let C=qB.clone(l[A]),T=A.length;if(T===d)C.setParent(f);else if(T>1){let E=r[A.substring(0,A.length-1)];C.setParent(E)}r[A]=C}else r[A]=null}})})};Du.prototype.populateSubtree=function(e,t,n,i){let o=Du.tileXYToQuadKey(e,t,n);return Lj(this,o,i)};function Lj(e,t,n){let i=e._tileInfo,o=t,r=i[o];if(u(r)&&(!r.hasSubtree()||r.hasChildren()))return r;for(;r===void 0&&o.length>1;)o=o.substring(0,o.length-1),r=i[o];let s,a=e._subtreePromises,c=a[o];if(u(c))return c.then(function(){return s=new Yo({throttle:n.throttle,throttleByServer:n.throttleByServer,type:n.type,priorityFunction:n.priorityFunction}),Lj(e,t,s)});if(!u(r)||!r.hasSubtree())return Promise.reject(new de(`Couldn't load metadata for tile ${t}`));if(c=e.getQuadTreePacket(o,r.cnodeVersion,n),!!u(c))return a[o]=c,c.then(function(){return s=new Yo({throttle:n.throttle,throttleByServer:n.throttleByServer,type:n.type,priorityFunction:n.priorityFunction}),Lj(e,t,s)}).finally(function(){delete a[o]})}Du.prototype.getTileInformation=function(e,t,n){let i=Du.tileXYToQuadKey(e,t,n)
in vec2 v_textureCoordinates;
float sampleTexture(vec2 offset) {
`;return e===0?n+=` vec4 color = texture(colorTexture, v_textureCoordinates + offset);
return czm_luminance(color.rgb);
`:n+=` return texture(colorTexture, v_textureCoordinates + offset).r;
`,n+=`}
`,n+=`uniform vec2 colorTextureDimensions;
uniform vec2 minMaxLuminance;
uniform sampler2D previousLuminance;
void main() {
float color = 0.0;
float xStep = 1.0 / colorTextureDimensions.x;
float yStep = 1.0 / colorTextureDimensions.y;
int count = 0;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
vec2 offset;
offset.x = -xStep + float(i) * xStep;
offset.y = -yStep + float(j) * yStep;
if (offset.x < 0.0 || offset.x > 1.0 || offset.y < 0.0 || offset.y > 1.0) {
continue;
}
color += sampleTexture(offset);
++count;
}
}
if (count > 0) {
color /= float(count);
}
`,e===t-1&&(n+=` float previous = texture(previousLuminance, vec2(0.5)).r;
color = clamp(color, minMaxLuminance.x, minMaxLuminance.y);
color = previous + (color - previous) / (60.0 * 1.5);
color = clamp(color, minMaxLuminance.x, minMaxLuminance.y);
`),n+=` out_FragColor = vec4(color);
}
`,n}function Ftt(e,t){o_e(e);let n=e._framebuffers,i=n.length,o=new Array(i);for(let r=0;r<i;++r)o[r]=t.createViewportQuadCommand(Ntt(r,i),{framebuffer:n[r].framebuffer,uniformMap:Ltt(e,r)});e._commands=o}Kx.prototype.clear=function(e){let t=this._framebuffers;if(!u(t))return;let n=this._clearCommand;u(n)||(n=this._clearCommand=new li({color:new k(0,0,0,0),framebuffer:void 0}));let i=t.length;for(let o=0;o<i;++o)t[o].clear(e,n)};Kx.prototype.update=function(e){let t=e.drawingBufferWidth,n=e.drawingBufferHeight;(t!==this._width||n!==this._height)&&(this._width=t,this._height=n,Btt(this,e),Ftt(this,e),this._ready||(this._ready=!0)),this._minMaxLuminance.x=this.minimumLuminance,this._minMaxLuminance.y=this.maximumLuminance;let i=this._framebuffers,o=i[i.length-1];i[i.length-1]=this._previousLuminance,this._commands[this._commands.length-1].framebuffer=this._previousLuminance.framebuffer,this._previousLuminance=o};Kx.prototype.execute=function(e,t){this._colorTexture=t;let n=this._commands;if(!u(n))return;let i=n.length;for(let o=0;o<i;++o)n[o].execute(e)};Kx.prototype.isDestroyed=function(){return!1};Kx.prototype.destroy=function(){return i_e(this),o_e(this),ue(this)};var aL=Kx;var Utt={AERIAL:"Aerial",AERIAL_WITH_LABELS:"AerialWithLabels",AERIAL_WITH_LABELS_ON_DEMAND:"AerialWithLabelsOnDemand",ROAD:"Road",ROAD_ON_DEMAND:"RoadOnDemand",CANVAS_DARK:"CanvasDark",CANVAS_LIGHT:"CanvasLight",CANVAS_GRAY:"CanvasGray",ORDNANCE_SURVEY:"OrdnanceSurvey",COLLINS_BART:"CollinsBart"},Jb=Object.freeze(Utt);function cL(e){}cL.prototype.isReady=function(){return!0};cL.prototype.shouldDiscardImage=function(e){return cL.EMPTY_IMAGE===e};var H4;Object.defineProperties(cL,{EMPTY_IMAGE:{get:function(){return u(H4)||(H4=new Image,H4.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),H4}}});var Zb=cL;function EY(e){this.tileWidth=void 0,this.tileHeight=void 0,this.maximumLevel=void 0,this.imageUrlSubdomains=void 0,this.imageUrlTemplate=void 0,this.attributionList=void 0}EY.prototype.build=function(e){e._tileWidth=this.tileWidth,e._tileHeight=this.tileHeight,e._maximumLevel=this.maximumLevel,e._imageUrlSubdomains=this.imageUrlSubdomains,e._imageUrlTemplate=this.imageUrlTemplate;let t=e._attributionList=this.attributionList;t||(t=[]),e._attributionList=t;for(let n=0,i=t.length;n<i;++n){let o=t[n];if(o.credit instanceof Xt)break;o.credit=new Xt(o.attribution);let r=o.coverageAreas;for(let s=0,a=o.coverageAreas.length;s<a;++s){let c=r[s],l=c.bbox;c.bbox=new le(P.toRadians(l[1]),P.toRadians(l[0]),P.toRadians(l[3]),P.toRadians(l[2]))}}e._ready=!0};function Vtt(e,t){if(e.resourceSets.length!==1)throw new de("metadata does not specify one resource in resourceSets");let n=e.resourceSets[0].resources[0];t.tileWidth=n.imageWidth,t.tileHeight=n.imageHeight,t.maximumLevel=n.zoomMax-1,t.imageUrlSubdomains=n.imageUrlSubdomains,t.imageUrlTemplate=n.imageUrl,t.attributionList=n.imageryProviders}function ktt(e,t,n){let i=`An error occurred while accessing ${e.url}`;throw u(t)&&u(t.message)&&(i+=`: ${t.message}`),Ai.reportError(void 0,n,u(n)?n._errorEvent:void 0,i,void 0,void 0,void 0,t),new de(i)}async function r_e(e,t,n){let i=e.url,o=hs._metadataCache[i];u(o)||(o=e.fetchJsonp("jsonp"),hs._metadataCache[i]=o);try{let r=await o;return Vtt(r,t)}catch(r){ktt(e,r,n)}}function hs(e){if(e=y(e,y.EMPTY_OBJECT),this._defaultAlpha=void 0,this._defaultNightAlpha=void 0,this._defaultDayAlpha=void 0,this._defaultBrightness=void 0,this._defaultContrast=void 0,this._defaultHue=void 0,this._defaultSaturation=void 0,this._defaultGamma=1,this._defaultMinificationFilter=void 0,this._defaultMagnificationFilter=void 0,this._mapStyle=y(e.mapStyle,Jb.AERIAL),this._culture=y(e.culture,""),this._key=e.key,this._tileDiscardPolicy=e.tileDiscardPolicy,u(this._tileDiscardPolicy)||(this._tileDiscardPolicy=new Zb),this._proxy=e.proxy,this._credit=new Xt(`<a href="https://www.microsoft.com/en-us/maps/product/enduserterms"><img src="${hs.logoUrl}" title="Bing Imagery"/></a>`),this._tilingScheme=new Nr({numberOfLevelZeroTiles
const float M_PI = 3.141592653589793;
float vdcRadicalInverse(int i)
{
float r;
float base = 2.0;
float value = 0.0;
float invBase = 1.0 / base;
float invBi = invBase;
for (int x = 0; x < 100; x++)
{
if (i <= 0)
{
break;
}
r = mod(float(i), base);
value += r * invBi;
invBi *= invBase;
i = int(float(i) * invBase);
}
return value;
}
vec2 hammersley2D(int i, int N)
{
return vec2(float(i) / float(N), vdcRadicalInverse(i));
}
vec3 importanceSampleGGX(vec2 xi, float roughness, vec3 N)
{
float a = roughness * roughness;
float phi = 2.0 * M_PI * xi.x;
float cosTheta = sqrt((1.0 - xi.y) / (1.0 + (a * a - 1.0) * xi.y));
float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
vec3 H = vec3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);
vec3 upVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
vec3 tangentX = normalize(cross(upVector, N));
vec3 tangentY = cross(N, tangentX);
return tangentX * H.x + tangentY * H.y + N * H.z;
}
float G1_Smith(float NdotV, float k)
{
return NdotV / (NdotV * (1.0 - k) + k);
}
float G_Smith(float roughness, float NdotV, float NdotL)
{
float k = roughness * roughness / 2.0;
return G1_Smith(NdotV, k) * G1_Smith(NdotL, k);
}
vec2 integrateBrdf(float roughness, float NdotV)
{
vec3 V = vec3(sqrt(1.0 - NdotV * NdotV), 0.0, NdotV);
float A = 0.0;
float B = 0.0;
const int NumSamples = 1024;
for (int i = 0; i < NumSamples; i++)
{
vec2 xi = hammersley2D(i, NumSamples);
vec3 H = importanceSampleGGX(xi, roughness, vec3(0.0, 0.0, 1.0));
vec3 L = 2.0 * dot(V, H) * H - V;
float NdotL = clamp(L.z, 0.0, 1.0);
float NdotH = clamp(H.z, 0.0, 1.0);
float VdotH = clamp(dot(V, H), 0.0, 1.0);
if (NdotL > 0.0)
{
float G = G_Smith(roughness, NdotV, NdotL);
float G_Vis = G * VdotH / (NdotH * NdotV);
float Fc = pow(1.0 - VdotH, 5.0);
A += (1.0 - Fc) * G_Vis;
B += Fc * G_Vis;
}
}
return vec2(A, B) / float(NumSamples);
}
void main()
{
out_FragColor = vec4(integrateBrdf(v_textureCoordinates.y, v_textureCoordinates.x), 0.0, 1.0);
}
`;function uL(){this._colorTexture=void 0,this._drawCommand=void 0}Object.defineProperties(uL.prototype,{colorTexture:{get:function(){return this._colorTexture}}});function qtt(e,t,n){let i=t.createViewportQuadCommand(lL,{framebuffer:n,renderState:ke.fromCache({viewport:new qe(0,0,256,256)})});e._drawCommand=i}uL.prototype.update=function(e){if(!u(this._colorTexture)){let t=e.context,n=new Mt({context:t,width:256,height:256,pixelFormat:st.RGBA,pixelDatatype:Ke.UNSIGNED_BYTE,sampler:fn.NEAREST});this._colorTexture=n;let i=new Ks({context:t,colorTextures:[n],destroyAttachments:!1});qtt(this,t,i),this._drawCommand.execute(t),i.destroy(),this._drawCommand.shaderProgram=this._drawCommand.shaderProgram&&this._drawCommand.shaderProgram.destroy()}};uL.prototype.isDestroyed=function(){return!1};uL.prototype.destroy=function(){return this._colorTexture=this._colorTexture&&this._colorTexture.destroy(),ue(this)};var fL=uL;var l_e={};function Xtt(e,t,n){let i,o,r;if(e instanceof bi){let s=Math.tan(.5*e.fovy);return i=e.near,o=e.near*s,r=e.aspectRatio*o,Math.max(t*i/r,n*i/o)}else if(e instanceof Yc)return i=e.near,o=e.top,r=e.right,Math.max(t*i/r,n*i/o);return Math.max(t,n)}var Ktt=new m,s_e=new m;function u_e(e,t,n,i){if(u(i)&&n(.5)>i){let o=n(0),r=n(1),s=n(.5),a=s-o,c=s-r;return function(l){let f=n(l);if(l<=.5){let p=(f-o)/a;return P.lerp(e,-P.PI_OVER_TWO,p)}let d=(f-r)/c;return P.lerp(-P.PI_OVER_TWO,t,1-d)}}return function(o){return P.lerp(e,t,o)}}function wY(e,t,n,i,o){let r=o,s=Math.max(n,i);if(!u(r)){let a=e.position,c=t,l=e.up,f=e.right,d=e.frustum,p=m.subtract(a,c,Ktt),g=m.magnitude(m.multiplyByScalar(l,m.dot(p,l),s_e)),h=m.magnitude(m.multiplyByScalar(f,m.dot(p,f),s_e));r=Math.min(Xtt(d,g,h)*.2,1e9)}if(s<r){let l=-Math.pow((r-n)*1e6,.125),f=Math.pow((r-i)*1e6,1/8);return function(d){let p=d*(f-l)+l;return-Math.pow(p,8)/1e6+r}}return function(a){return P.lerp(n,i,a)}}function dL(e,t){return P.equalsEpsilon(e,P.TWO_PI,P.EPSILON11)&&(e=0),t>e+Math.PI?e+=P.TWO_PI:t<e-Math.PI&&(e-=P.TWO_PI),e}var f_e=new m;function Jtt(e,t,n,i,o,r,s,a){let c=e.camera,l=m.clone(c.position,f_e),f=c.pitch,d=dL(c.heading,i),p=dL(c.roll,r),g=wY(c,n,l.z,n.z,s),h=u_e(f,o,g,a);function A(x){let C=x.time/t;c.setView({orientation:{heading:P.lerp(d,i,C),pitch:h(C),roll:P.lerp(p,r,C)}}),H.lerp(l,n,C,c.position),c.position.z=g(C)}return A}function Ztt(e,t){e.longitude<t.longitude?e.longitude+=P.TWO_PI:t.longitude+=P.TWO_PI}function Qtt(e,t){let n=e.longitude-t.longitude;n<-P.PI?e.longitude+=P.TWO_PI:n>P.PI&&(t.longitude+=P.TWO_PI)}var $tt=new he,ent=new he;function tnt(e,t,n,i,o,r,s,a,c,l){let f=e.camera,p=e.mapProjection.ellipsoid,g=he.clone(f.positionCartographic,$tt),h=f.pitch,A=dL(f.heading,i),x=dL(f.roll,r),C=p.cartesianToCartographic(n,ent);g.longitude=P.zeroToTwoPi(g.longitude),C.longitude=P.zeroToTwoPi(C.longitude);let T=!1;if(u(a)){let D=P.zeroToTwoPi(a),M=Math.min(g.longitude,C.longitude),O=Math.max(g.longitude,C.longitude),L=D>=M&&D<=O;if(u(c)){let N=Math.abs(g.longitude-C.longitude),_=P.TWO_PI-N;(L?N:_)<(L?_:N)*c&&!L&&(T=!0)}else L||(T=!0)}T?Ztt(g,C):Qtt(g,C);let E=wY(f,n,g.height,C.height,s),S=u_e(h,o,E,l);function w(){let D=g.longitude,M=C.longitude,O=g.latitude,L=C.latitude;return function(_){let b=_.time/t,v=m.fromRadians(P.lerp(D,M,b),P.lerp(O,L,b),E(b),p);f.setView({destination:v,orientation:{heading:P.lerp(A,i,b),pitch:S(b),roll:P.lerp(x,r,b)}})}}return w()}function nnt(e,t,n,i,o,r,s){let a=e.camera,c=m.clone(a.position,f_e),l=dL(a.heading,i),f=a.frustum.right-a.frustum.left,d=wY(a,n,f,n.z,s);function p(g){let h=g.time/t;a.setView({orientation:{heading:P.lerp(l,i,h)}}),H.lerp(c,n,h,a.position);let A=d(h),x=a.frustum,C=x.top/x.right,T=(A-(x.right-x.left))*.5;x.right+=T,x.left-=T,x.top=C*x.right,x.bottom=-x.top}return p}var a_e=new he,int=new m;function vY(e,t){return{startObject:{},stopObject:{},duration:0,complete:e,cancel:t}}function c_e(e,t){function n(){typeof t=="function"&&t(),e.enableInputs=!0}return n}l_e.createTween=function(e,t){t=y(t,y.EMPTY_OBJECT);let n=t.destination,i=e.mode;if(i===ne.MORPHING)return vY();let o=y(t.convert,!0),
{
return ${f};
}
`}return r=`${i} ${e}
{
${r} return ${i}(1.0);
}
`,r};tS.prototype.getVariables=function(){let e=[],t=this._runtimeConditions;if(!u(t)||t.length===0)return e;let n=t.length;for(let i=0;i<n;++i){let o=t[i];e.push.apply(e,o.condition.getVariables()),e.push.apply(e,o.expression.getVariables())}return e=e.filter(function(i,o,r){return r.indexOf(i)===o}),e};var gL=tS;function Xy(e){this._style={},this._ready=!1,this._show=void 0,this._color=void 0,this._pointSize=void 0,this._pointOutlineColor=void 0,this._pointOutlineWidth=void 0,this._labelColor=void 0,this._labelOutlineColor=void 0,this._labelOutlineWidth=void 0,this._font=void 0,this._labelStyle=void 0,this._labelText=void 0,this._backgroundColor=void 0,this._backgroundPadding=void 0,this._backgroundEnabled=void 0,this._scaleByDistance=void 0,this._translucencyByDistance=void 0,this._distanceDisplayCondition=void 0,this._heightOffset=void 0,this._anchorLineEnabled=void 0,this._anchorLineColor=void 0,this._image=void 0,this._disableDepthTestDistance=void 0,this._horizontalOrigin=void 0,this._verticalOrigin=void 0,this._labelHorizontalOrigin=void 0,this._labelVerticalOrigin=void 0,this._meta=void 0,this._colorShaderFunction=void 0,this._showShaderFunction=void 0,this._pointSizeShaderFunction=void 0,this._colorShaderFunctionReady=!1,this._showShaderFunctionReady=!1,this._pointSizeShaderFunctionReady=!1,this._colorShaderTranslucent=!1,Git(this,e)}function Git(e,t){t=y(je(t,!0),e._style),e._style=t,e.show=t.show,e.color=t.color,e.pointSize=t.pointSize,e.pointOutlineColor=t.pointOutlineColor,e.pointOutlineWidth=t.pointOutlineWidth,e.labelColor=t.labelColor,e.labelOutlineColor=t.labelOutlineColor,e.labelOutlineWidth=t.labelOutlineWidth,e.labelStyle=t.labelStyle,e.font=t.font,e.labelText=t.labelText,e.backgroundColor=t.backgroundColor,e.backgroundPadding=t.backgroundPadding,e.backgroundEnabled=t.backgroundEnabled,e.scaleByDistance=t.scaleByDistance,e.translucencyByDistance=t.translucencyByDistance,e.distanceDisplayCondition=t.distanceDisplayCondition,e.heightOffset=t.heightOffset,e.anchorLineEnabled=t.anchorLineEnabled,e.anchorLineColor=t.anchorLineColor,e.image=t.image,e.disableDepthTestDistance=t.disableDepthTestDistance,e.horizontalOrigin=t.horizontalOrigin,e.verticalOrigin=t.verticalOrigin,e.labelHorizontalOrigin=t.labelHorizontalOrigin,e.labelVerticalOrigin=t.labelVerticalOrigin;let n={};if(u(t.meta)){let i=t.defines,o=y(t.meta,y.EMPTY_OBJECT);for(let r in o)o.hasOwnProperty(r)&&(n[r]=new Qu(o[r],i))}e._meta=n,e._ready=!0}function er(e,t){let n=y(e._style,y.EMPTY_OBJECT).defines;if(u(t)){if(typeof t=="boolean"||typeof t=="number")return new Qu(String(t));if(typeof t=="string")return new Qu(t,n);if(u(t.conditions))return new gL(t,n)}else return;return t}function tr(e){if(u(e)){if(u(e.expression))return e.expression;if(u(e.conditionsExpression))return je(e.conditionsExpression,!0)}else return;return e}Object.defineProperties(Xy.prototype,{style:{get:function(){return this._style}},show:{get:function(){return this._show},set:function(e){this._show=er(this,e),this._style.show=tr(this._show),this._showShaderFunctionReady=!1}},color:{get:function(){return this._color},set:function(e){this._color=er(this,e),this._style.color=tr(this._color),this._colorShaderFunctionReady=!1}},pointSize:{get:function(){return this._pointSize},set:function(e){this._pointSize=er(this,e),this._style.pointSize=tr(this._pointSize),this._pointSizeShaderFunctionReady=!1}},pointOutlineColor:{get:function(){return this._pointOutlineColor},set:function(e){this._pointOutlineColor=er(this,e),this._style.pointOutlineColor=tr(this._pointOutlineColor)}},pointOutlineWidth:{get:function(){return this._pointOutlineWidth},set:function(e){this._pointOutlineWidth=er(this,e),this._style.pointOutlineWidth=tr(this._pointOutlineWidth)}},labelColor:{get:function(){return this._labelColor},set:function(e){this._labelColor=er(this,e),this._style.labelColor=tr(this._labelColor)}},labelOutlineColor:{get:function(){return this._labelOutlineColor},set:function(e){this._labelOutlineColor=er(this,e),this._style.labelOutlineColor=tr(this._labelOutlineColor)}},labelOutlineWidth:{ge
uniform vec3 u_noiseTextureDimensions;
uniform float u_noiseDetail;
in vec2 v_offset;
in vec3 v_maximumSize;
in vec4 v_color;
in float v_slice;
in float v_brightness;
float wrap(float value, float rangeLength) {
if(value < 0.0) {
float absValue = abs(value);
float modValue = mod(absValue, rangeLength);
return mod(rangeLength - modValue, rangeLength);
}
return mod(value, rangeLength);
}
vec3 wrapVec(vec3 value, float rangeLength) {
return vec3(wrap(value.x, rangeLength),
wrap(value.y, rangeLength),
wrap(value.z, rangeLength));
}
vec2 voxelToUV(vec3 voxelIndex) {
float textureSliceWidth = u_noiseTextureDimensions.x;
float noiseTextureRows = u_noiseTextureDimensions.y;
float inverseNoiseTextureRows = u_noiseTextureDimensions.z;
float textureSliceWidthSquared = textureSliceWidth * textureSliceWidth;
vec2 inverseNoiseTextureDimensions = vec2(noiseTextureRows / textureSliceWidthSquared,
inverseNoiseTextureRows / textureSliceWidth);
vec3 wrappedIndex = wrapVec(voxelIndex, textureSliceWidth);
float column = mod(wrappedIndex.z, textureSliceWidth * inverseNoiseTextureRows);
float row = floor(wrappedIndex.z / textureSliceWidth * noiseTextureRows);
float xPixelCoord = wrappedIndex.x + column * textureSliceWidth;
float yPixelCoord = wrappedIndex.y + row * textureSliceWidth;
return vec2(xPixelCoord, yPixelCoord) * inverseNoiseTextureDimensions;
}
// Interpolate a voxel with its neighbor (along the positive X-axis)
vec4 lerpSamplesX(vec3 voxelIndex, float x) {
vec2 uv0 = voxelToUV(voxelIndex);
vec2 uv1 = voxelToUV(voxelIndex + vec3(1.0, 0.0, 0.0));
vec4 sample0 = texture(u_noiseTexture, uv0);
vec4 sample1 = texture(u_noiseTexture, uv1);
return mix(sample0, sample1, x);
}
vec4 sampleNoiseTexture(vec3 position) {
float textureSliceWidth = u_noiseTextureDimensions.x;
vec3 recenteredPos = position + vec3(textureSliceWidth / 2.0);
vec3 lerpValue = fract(recenteredPos);
vec3 voxelIndex = floor(recenteredPos);
vec4 xLerp00 = lerpSamplesX(voxelIndex, lerpValue.x);
vec4 xLerp01 = lerpSamplesX(voxelIndex + vec3(0.0, 0.0, 1.0), lerpValue.x);
vec4 xLerp10 = lerpSamplesX(voxelIndex + vec3(0.0, 1.0, 0.0), lerpValue.x);
vec4 xLerp11 = lerpSamplesX(voxelIndex + vec3(0.0, 1.0, 1.0), lerpValue.x);
vec4 yLerp0 = mix(xLerp00, xLerp10, lerpValue.y);
vec4 yLerp1 = mix(xLerp01, xLerp11, lerpValue.y);
return mix(yLerp0, yLerp1, lerpValue.z);
}
// Intersection with a unit sphere with radius 0.5 at center (0, 0, 0).
bool intersectSphere(vec3 origin, vec3 dir, float slice,
out vec3 point, out vec3 normal) {
float A = dot(dir, dir);
float B = dot(origin, dir);
float C = dot(origin, origin) - 0.25;
float discriminant = (B * B) - (A * C);
if(discriminant < 0.0) {
return false;
}
float root = sqrt(discriminant);
float t = (-B - root) / A;
if(t < 0.0) {
t = (-B + root) / A;
}
point = origin + t * dir;
if(slice >= 0.0) {
point.z = (slice / 2.0) - 0.5;
if(length(point) > 0.5) {
return false;
}
}
normal = normalize(point);
point -= czm_epsilon2 * normal;
return true;
}
// Transforms the ray origin and direction into unit sphere space,
// then transforms the result back into the ellipsoid's space.
bool intersectEllipsoid(vec3 origin, vec3 dir, vec3 center, vec3 scale, float slice,
out vec3 point, out vec3 normal) {
if(scale.x <= 0.01 || scale.y < 0.01 || scale.z < 0.01) {
return false;
}
vec3 o = (origin - center) / scale;
vec3 d = dir / scale;
vec3 p, n;
bool intersected = intersectSphere(o, d, slice, p, n);
if(intersected) {
point = (p * scale) + center;
normal = n;
}
return intersected;
}
// Assume that if phase shift is being called for octave i,
// the frequency is of i - 1. This saves us from doing extra
// division / multiplication operations.
vec2 phaseShift2D(vec2 p, vec2 freq) {
return (czm_pi / 2.0) * sin(freq.yx * p.yx);
}
vec2 phaseShift3D(vec3 p, vec2 freq) {
return phaseShift2D(p.xy, freq) + czm_pi * vec2(sin(freq.x * p.z));
}
// The cloud texture function derived from Gardner's 1985 paper,
// "Visual Simulation of Clouds."
// https://www.cs.drexel.edu/~david/Classes/Papers/p297-gardner.pdf
const float T0 = 0.6; // contrast of the texture pattern
const float k = 0.1; // computed to produce a maximum value of 1
const float C0 = 0.8; // coefficient
const float FX0 = 0.6; // frequency X
const float FY0 = 0.6; // frequency Y
const int octaves = 5;
float T(vec3 point) {
vec2 sum = vec2(0.0);
float Ci = C0;
vec2 FXY = vec2(FX0, FY0);
vec2 PXY = vec2(0.0);
for(int i = 1; i <= octaves; i++) {
PXY = phaseShift3D(point, FXY);
Ci *= 0.707;
FXY *= 2.0;
vec2 sinTerm = sin(FXY * point.xy + PXY);
sum += Ci * sinTerm + vec2(T0);
}
return k * sum.x * sum.y;
}
const float a = 0.5; // fraction of surface reflection due to ambient or scattered light,
const float t = 0.4; // fraction of texture shading
const float s = 0.25; // fraction of specular reflection
float I(float Id, float Is, float It) {
return (1.0 - a) * ((1.0 - t) * ((1.0 - s) * Id + s * Is) + t * It) + a;
}
const vec3 lightDir = normalize(vec3(0.2, -1.0, 0.7));
vec4 drawCloud(vec3 rayOrigin, vec3 rayDir, vec3 cloudCenter, vec3 cloudScale, float cloudSlice,
float brightness) {
vec3 cloudPoint, cloudNormal;
if(!intersectEllipsoid(rayOrigin, rayDir, cloudCenter, cloudScale, cloudSlice,
cloudPoint, cloudNormal)) {
return vec4(0.0);
}
float Id = clamp(dot(cloudNormal, -lightDir), 0.0, 1.0); // diffuse reflection
float Is = max(pow(dot(-lightDir, -rayDir), 2.0), 0.0); // specular reflection
float It = T(cloudPoint); // texture function
float intensity = I(Id, Is, It);
vec3 color = vec3(intensity * clamp(brightness, 0.1, 1.0));
vec4 noise = sampleNoiseTexture(u_noiseDetail * cloudPoint);
float W = noise.x;
float W2 = noise.y;
float W3 = noise.z;
// The dot product between the cloud's normal and the ray's direction is greatest
// in the center of the ellipsoid's surface. It decreases towards the edge.
// Thus, it is used to blur the areas leading to the edges of the ellipsoid,
// so that no harsh lines appear.
// The first (and biggest) layer of worley noise is then subtracted from this.
// The final result is scaled up so that the base cloud is not too translucent.
float ndDot = clamp(dot(cloudNormal, -rayDir), 0.0, 1.0);
float TR = pow(ndDot, 3.0) - W; // translucency
TR *= 1.3;
// Subtracting the second and third layers of worley noise is more complicated.
// If these layers of noise were simply subtracted from the current translucency,
// the shape derived from the first layer of noise would be completely deleted.
// The erosion of this noise should thus be constricted to the edges of the cloud.
// However, because the edges of the ellipsoid were already blurred away, mapping
// the noise to (1.0 - ndDot) will have no impact on most of the cloud's appearance.
// The value of (0.5 - ndDot) provides the best compromise.
float minusDot = 0.5 - ndDot;
// Even with the previous calculation, subtracting the second layer of wnoise
// erode too much of the cloud. The addition of it, however, will detailed
// volume to the cloud. As long as the noise is only added and not subtracted,
// the results are aesthetically pleasing.
// The minusDot product is mapped in a way that it is larger at the edges of
// the ellipsoid, so a subtraction and min operation are used instead of
// an addition and max one.
TR -= min(minusDot * W2, 0.0);
// The third level of worley noise is subtracted from the result, with some
// modifications. First, a scalar is added to minusDot so that the noise
// starts affecting the shape farther away from the center of the ellipsoid's
// surface. Then, it is scaled down so its impact is not too intense.
TR -= 0.8 * (minusDot + 0.25) * W3;
// The texture function's shading does not correlate with the shape of the cloud
// produced by the layers of noise, so an extra shading scalar is calculated.
// The darkest areas of the cloud are assigned to be where the noise erodes
// the cloud the most. This is then interpolated based on the translucency
// and the diffuse shading term of that point in the cloud.
float shading = mix(1.0 - 0.8 * W * W, 1.0, Id * TR);
// To avoid values that are too dark, this scalar is increased by a small amount
// and clamped so it never goes to zero.
shading = clamp(shading + 0.2, 0.3, 1.0);
// Finally, the contrast of the cloud's color is increased.
vec3 finalColor = mix(vec3(0.5), shading * color, 1.15);
return vec4(finalColor, clamp(TR, 0.0, 1.0)) * v_color;
}
void main() {
#ifdef DEBUG_BILLBOARDS
out_FragColor = vec4(0.0, 0.5, 0.5, 1.0);
#endif
// To avoid calculations with high values,
// we raycast from an arbitrarily smaller space.
vec2 coordinate = v_maximumSize.xy * v_offset;
vec3 ellipsoidScale = 0.82 * v_maximumSize;
vec3 ellipsoidCenter = vec3(0.0);
float zOffset = max(ellipsoidScale.z - 10.0, 0.0);
vec3 eye = vec3(0, 0, -10.0 - zOffset);
vec3 rayDir = normalize(vec3(coordinate, 1.0) - eye);
vec3 rayOrigin = eye;
#ifdef DEBUG_ELLIPSOIDS
vec3 point, normal;
if(intersectEllipsoid(rayOrigin, rayDir, ellipsoidCenter, ellipsoidScale, v_slice,
point, normal)) {
out_FragColor = v_brightness * v_color;
}
#else
#ifndef DEBUG_BILLBOARDS
vec4 cloud = drawCloud(rayOrigin, rayDir,
ellipsoidCenter, ellipsoidScale, v_slice, v_brightness);
if(cloud.w < 0.01) {
discard;
}
out_FragColor = cloud;
#endif
#endif
}
`;var bL=`#ifdef INSTANCED
in vec2 direction;
#endif
in vec4 positionHighAndScaleX;
in vec4 positionLowAndScaleY;
in vec4 packedAttribute0;
in vec4 packedAttribute1;
in vec4 color;
out vec2 v_offset;
out vec3 v_maximumSize;
out vec4 v_color;
out float v_slice;
out float v_brightness;
void main() {
// Unpack attributes.
vec3 positionHigh = positionHighAndScaleX.xyz;
vec3 positionLow = positionLowAndScaleY.xyz;
vec2 scale = vec2(positionHighAndScaleX.w, positionLowAndScaleY.w);
float show = packedAttribute0.x;
float brightness = packedAttribute0.y;
vec2 coordinates = packedAttribute0.wz;
vec3 maximumSize = packedAttribute1.xyz;
float slice = packedAttribute1.w;
#ifdef INSTANCED
vec2 dir = direction;
#else
vec2 dir = coordinates;
#endif
vec2 offset = dir - vec2(0.5, 0.5);
vec2 scaledOffset = scale * offset;
vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);
vec4 positionEC = czm_modelViewRelativeToEye * p;
positionEC.xy += scaledOffset;
positionEC.xyz *= show;
gl_Position = czm_projection * positionEC;
v_offset = offset;
v_maximumSize = maximumSize;
v_color = color;
v_slice = slice;
v_brightness = brightness;
}
`;var SL=`uniform vec3 u_noiseTextureDimensions;
uniform float u_noiseDetail;
uniform vec3 u_noiseOffset;
in vec2 v_position;
float wrap(float value, float rangeLength) {
if(value < 0.0) {
float absValue = abs(value);
float modValue = mod(absValue, rangeLength);
return mod(rangeLength - modValue, rangeLength);
}
return mod(value, rangeLength);
}
vec3 wrapVec(vec3 value, float rangeLength) {
return vec3(wrap(value.x, rangeLength),
wrap(value.y, rangeLength),
wrap(value.z, rangeLength));
}
vec3 random3(vec3 p) {
float dot1 = dot(p, vec3(127.1, 311.7, 932.8));
float dot2 = dot(p, vec3(269.5, 183.3, 421.4));
return fract(vec3(sin(dot1 - dot2), cos(dot1 * dot2), dot1 * dot2));
}
// Frequency corresponds to cell size.
// The higher the frequency, the smaller the cell size.
vec3 getWorleyCellPoint(vec3 centerCell, vec3 offset, float freq) {
float textureSliceWidth = u_noiseTextureDimensions.x;
vec3 cell = centerCell + offset;
cell = wrapVec(cell, textureSliceWidth / u_noiseDetail);
cell += floor(u_noiseOffset / u_noiseDetail);
vec3 p = offset + random3(cell);
return p;
}
float worleyNoise(vec3 p, float freq) {
vec3 centerCell = floor(p * freq);
vec3 pointInCell = fract(p * freq);
float shortestDistance = 1000.0;
for(float z = -1.0; z <= 1.0; z++) {
for(float y = -1.0; y <= 1.0; y++) {
for(float x = -1.0; x <= 1.0; x++) {
vec3 offset = vec3(x, y, z);
vec3 point = getWorleyCellPoint(centerCell, offset, freq);
float distance = length(pointInCell - point);
if(distance < shortestDistance) {
shortestDistance = distance;
}
}
}
}
return shortestDistance;
}
const float MAX_FBM_ITERATIONS = 10.0;
float worleyFBMNoise(vec3 p, float octaves, float scale) {
float noise = 0.0;
float freq = 1.0;
float persistence = 0.625;
for(float i = 0.0; i < MAX_FBM_ITERATIONS; i++) {
if(i >= octaves) {
break;
}
noise += worleyNoise(p * scale, freq * scale) * persistence;
persistence *= 0.5;
freq *= 2.0;
}
return noise;
}
void main() {
float textureSliceWidth = u_noiseTextureDimensions.x;
float inverseNoiseTextureRows = u_noiseTextureDimensions.z;
float x = mod(v_position.x, textureSliceWidth);
float y = mod(v_position.y, textureSliceWidth);
float sliceRow = floor(v_position.y / textureSliceWidth);
float z = floor(v_position.x / textureSliceWidth) + sliceRow * inverseNoiseTextureRows * textureSliceWidth;
vec3 position = vec3(x, y, z);
position /= u_noiseDetail;
float worley0 = clamp(worleyFBMNoise(position, 3.0, 1.0), 0.0, 1.0);
float worley1 = clamp(worleyFBMNoise(position, 3.0, 2.0), 0.0, 1.0);
float worley2 = clamp(worleyFBMNoise(position, 3.0, 3.0), 0.0, 1.0);
out_FragColor = vec4(worley0, worley1, worley2, 1.0);
}
`;var vL=`uniform vec3 u_noiseTextureDimensions;
in vec2 position;
out vec2 v_position;
void main()
{
gl_Position = vec4(position, 0.1, 1.0);
float textureSliceWidth = u_noiseTextureDimensions.x;
float noiseTextureRows = u_noiseTextureDimensions.y;
float inverseNoiseTextureRows = u_noiseTextureDimensions.z;
vec2 transformedPos = (position * 0.5) + vec2(0.5);
transformedPos *= textureSliceWidth;
transformedPos.x *= textureSliceWidth * inverseNoiseTextureRows;
transformedPos.y *= noiseTextureRows;
v_position = transformedPos;
}
`;function lm(e,t){if(e=y(e,y.EMPTY_OBJECT),this._show=y(e.show,!0),this._position=m.clone(y(e.position,m.ZERO)),!u(e.scale)&&u(e.maximumSize))this._maximumSize=m.clone(e.maximumSize),this._scale=new H(this._maximumSize.x,this._maximumSize.y);else{this._scale=H.clone(y(e.scale,new H(20,12)));let n=new m(this._scale.x,this._scale.y,Math.min(this._scale.x,this._scale.y)/1.5);this._maximumSize=m.clone(y(e.maximumSize,n))}this._slice=y(e.slice,-1),this._color=k.clone(y(e.color,k.WHITE)),this._brightness=y(e.brightness,1),this._cloudCollection=t,this._index=-1}var Mot=lm.SHOW_INDEX=0,Rot=lm.POSITION_INDEX=1,Bot=lm.SCALE_INDEX=2,Lot=lm.MAXIMUM_SIZE_INDEX=3,Not=lm.SLICE_INDEX=4,Fot=lm.BRIGHTNESS_INDEX=5,Uot=lm.COLOR_INDEX=6;lm.NUMBER_OF_PROPERTIES=7;function Zx(e,t){let n=e._cloudCollection;u(n)&&(n._updateCloud(e,t),e._dirty=!0)}Object.defineProperties(lm.prototype,{show:{get:function(){return this._show},set:function(e){this._show!==e&&(this._show=e,Zx(this,Mot))}},position:{get:function(){return this._position},set:function(e){let t=this._position;m.equals(t,e)||(m.clone(e,t),Zx(this,Rot))}},scale:{get:function(){return this._scale},set:function(e){let t=this._scale;H.equals(t,e)||(H.clone(e,t),Zx(this,Bot))}},maximumSize:{get:function(){return this._maximumSize},set:function(e){let t=this._maximumSize;m.equals(t,e)||(m.clone(e,t),Zx(this,Lot))}},color:{get:function(){return this._color},set:function(e){let t=this._color;k.equals(t,e)||(k.clone(e,t),Zx(this,Uot))}},slice:{get:function(){return this._slice},set:function(e){this._slice!==e&&(this._slice=e,Zx(this,Not))}},brightness:{get:function(){return this._brightness},set:function(e){this._brightness!==e&&(this._brightness=e,Zx(this,Fot))}}});lm.prototype._destroy=function(){this._cloudCollection=void 0};var Mu=lm;var Ru,Z4=new m,Vot={positionHighAndScaleX:0,positionLowAndScaleY:1,packedAttribute0:2,packedAttribute1:3,color:4},kot={direction:0,positionHighAndScaleX:1,positionLowAndScaleY:2,packedAttribute0:3,packedAttribute1:4,color:5},zot=Mu.SHOW_INDEX,Hot=Mu.POSITION_INDEX,Got=Mu.SCALE_INDEX,Wot=Mu.MAXIMUM_SIZE_INDEX,jot=Mu.SLICE_INDEX,Yot=Mu.BRIGHTNESS_INDEX,qot=Mu.NUMBER_OF_PROPERTIES,Xot=Mu.COLOR_INDEX;function um(e){e=y(e,y.EMPTY_OBJECT),this._clouds=[],this._cloudsToUpdate=[],this._cloudsToUpdateIndex=0,this._cloudsRemoved=!1,this._createVertexArray=!1,this._propertiesChanged=new Uint32Array(qot),this._noiseTexture=void 0,this._textureSliceWidth=128,this._noiseTextureRows=4,this.noiseDetail=y(e.noiseDetail,16),this.noiseOffset=m.clone(y(e.noiseOffset,m.ZERO)),this._loading=!1,this._ready=!1;let t=this;this._uniforms={u_noiseTexture:function(){return t._noiseTexture},u_noiseTextureDimensions:$_e(t),u_noiseDetail:function(){return t.noiseDetail}},this._vaNoise=void 0,this._spNoise=void 0,this._spCreated=!1,this._sp=void 0,this._rs=void 0,this.show=y(e.show,!0),this._colorCommands=[],this.debugBillboards=y(e.debugBillboards,!1),this._compiledDebugBillboards=!1,this.debugEllipsoids=y(e.debugEllipsoids,!1),this._compiledDebugEllipsoids=!1}function $_e(e){return function(){return Z4.x=e._textureSliceWidth,Z4.y=e._noiseTextureRows,Z4.z=1/e._noiseTextureRows,Z4}}Object.defineProperties(um.prototype,{length:{get:function(){return WY(this),this._clouds.length}}});function ege(e){let t=e.length;for(let n=0;n<t;++n)e[n]&&e[n]._destroy()}um.prototype.add=function(e){e=y(e,y.EMPTY_OBJECT);let t=y(e.cloudType,nS.CUMULUS),n;return t===nS.CUMULUS&&(n=new Mu(e,this),n._index=this._clouds.length,this._clouds.push(n),this._createVertexArray=!0),n};um.prototype.remove=function(e){return this.contains(e)?(this._clouds[e._index]=void 0,this._cloudsRemoved=!0,this._createVertexArray=!0,e._destroy(),!0):!1};um.prototype.removeAll=function(){ege(this._clouds),this._clouds=[],this._cloudsToUpdate=[],this._cloudsToUpdateIndex=0,this._cloudsRemoved=!1,this._createVertexArray=!0};function WY(e){if(e._cloudsRemoved){e._cloudsRemoved=!1;let t=[],n=e._clouds,i=n.length;for(let o=0,r=0;o<i;++o){let s=n[o];u(s)&&(n._index=r++,t.push(s))}e._clouds=t}}um.prototype._updateCloud=function(e,t){e._dirty||
`,n}function hrt(e){let t="";t+=pc(".cesium-credit-lightbox-overlay",{display:"none","z-index":"1",position:"absolute",top:"0",left:"0",width:"100%",height:"100%","background-color":"rgba(80, 80, 80, 0.8)"}),t+=pc(".cesium-credit-lightbox",{"background-color":"#303336",color:wL,position:"relative","min-height":`${urt}px`,margin:"auto"}),t+=pc(".cesium-credit-lightbox > ul > li a, .cesium-credit-lightbox > ul > li a:visited",{color:wL}),t+=pc(".cesium-credit-lightbox > ul > li a:hover",{color:KY}),t+=pc(".cesium-credit-lightbox.cesium-credit-lightbox-expanded",{border:"1px solid #444","border-radius":"5px","max-width":"370px"}),t+=pc(".cesium-credit-lightbox.cesium-credit-lightbox-mobile",{height:"100%",width:"100%"}),t+=pc(".cesium-credit-lightbox-title",{padding:"20px 20px 0 20px"}),t+=pc(".cesium-credit-lightbox-close",{"font-size":"18pt",cursor:"pointer",position:"absolute",top:"0",right:"6px",color:wL}),t+=pc(".cesium-credit-lightbox-close:hover",{color:KY}),t+=pc(".cesium-credit-lightbox > ul",{margin:"0",padding:"12px 20px 12px 40px","font-size":"13px"}),t+=pc(".cesium-credit-lightbox > ul > li",{"padding-bottom":"6px"}),t+=pc(".cesium-credit-lightbox > ul > li *",{padding:"0",margin:"0"}),t+=pc(".cesium-credit-expand-link",{"padding-left":"5px",cursor:"pointer","text-decoration":"underline",color:wL}),t+=pc(".cesium-credit-expand-link:hover",{color:KY}),t+=pc(".cesium-credit-text",{color:wL}),t+=pc(".cesium-credit-textContainer *, .cesium-credit-logoContainer *",{display:"inline"});function n(r){if(r.shadowRoot)return r.shadowRoot;if(r.getRootNode){let s=r.getRootNode();if(s instanceof ShadowRoot)return s}}let i=y(n(e),document.head),o=document.createElement("style");o.innerHTML=t,i.appendChild(o)}function xr(e,t,n){let i=this;n=y(n,document.body);let o=document.createElement("div");o.className="cesium-credit-lightbox-overlay",n.appendChild(o);let r=document.createElement("div");r.className="cesium-credit-lightbox",o.appendChild(r);function s(h){r.contains(h.target)||i.hideLightbox()}o.addEventListener("click",s,!1);let a=document.createElement("div");a.className="cesium-credit-lightbox-title",a.textContent="Data provided by:",r.appendChild(a);let c=document.createElement("a");c.onclick=this.hideLightbox.bind(this),c.innerHTML="&times;",c.className="cesium-credit-lightbox-close",r.appendChild(c);let l=document.createElement("ul");r.appendChild(l);let f=document.createElement("div");f.className="cesium-credit-logoContainer",f.style.display="inline",e.appendChild(f);let d=document.createElement("div");d.className="cesium-credit-textContainer",d.style.display="inline",e.appendChild(d);let p=document.createElement("a");p.className="cesium-credit-expand-link",p.onclick=this.showLightbox.bind(this),p.textContent="Data attribution",e.appendChild(p),hrt(e);let g=Xt.clone(xr.cesiumCredit);this._delimiter=y(t," \u2022 "),this._screenContainer=d,this._cesiumCreditContainer=f,this._lastViewportHeight=void 0,this._lastViewportWidth=void 0,this._lightboxCredits=r,this._creditList=l,this._lightbox=o,this._hideLightbox=s,this._expandLink=p,this._expanded=!1,this._defaultCredits=[],this._cesiumCredit=g,this._previousCesiumCredit=void 0,this._currentCesiumCredit=g,this._creditDisplayElementPool=[],this._creditDisplayElementIndex=0,this._currentFrameCredits={screenCredits:new Ct,lightboxCredits:new Ct},this._defaultCredit=void 0,this.viewport=n,this.container=e}function dge(e,t,n,i){i=y(i,1);let o=t.get(n.id);if(u(o))o.count<Number.MAX_VALUE&&(o.count+=i);else{let r=e._creditDisplayElementPool,s=e._creditDisplayElementPoolIndex;s<r.length?(o=r[s],o.credit=n,o.count=i):(o=new uge(n,i),r.push(o)),++e._creditDisplayElementPoolIndex,t.set(n.id,o)}}xr.prototype.addCredit=function(e){if(e._isIon){u(this._defaultCredit)||(this._defaultCredit=Xt.clone(mge())),this._currentCesiumCredit=this._defaultCredit;return}let t;e.showOnScreen?t=this._currentFrameCredits.screenCredits:t=this._currentFrameCredits.lightboxCredits,dge(this,t,e)};xr.prototype.addDefaultCredit=function(e){let t=this._defaultCredits;frt(t,e)||t.push(e)};xr.prototype.removeD
`;else switch(t==="st"&&(i="vec2"),i){case"float":r=`vec4 getColor() { return vec4(vec3(${o}), 1.0); }
`;break;case"vec2":r=`vec4 getColor() { return vec4(${o}, 0.0, 1.0); }
`;break;case"vec3":r=`vec4 getColor() { return vec4(${o}, 1.0); }
`;break;case"vec4":r=`vec4 getColor() { return ${o}; }
`;break}let s=`in vec3 position3DHigh;
in vec3 position3DLow;
in float batchId;
${n?"":`in ${i} ${t};
`}out ${i} ${o};
void main()
{
vec4 p = czm_translateRelativeToEye(position3DHigh, position3DLow);
${n?`${o} = czm_batchTable_${t}(batchId);
`:`${o} = ${t};
`}gl_Position = czm_modelViewProjectionRelativeToEye * p;
}`,a=`in ${i} ${o};
${r}
void main()
{
out_FragColor = getColor();
}`;this.material=void 0,this.translucent=y(e.translucent,!1),this._vertexShaderSource=y(e.vertexShaderSource,s),this._fragmentShaderSource=y(e.fragmentShaderSource,a),this._renderState=eo.getDefaultRenderState(!1,!1,e.renderState),this._closed=y(e.closed,!1),this._attributeName=t,this._glslDatatype=i}Object.defineProperties(IL.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}},attributeName:{get:function(){return this._attributeName}},glslDatatype:{get:function(){return this._glslDatatype}}});IL.prototype.getFragmentShaderSource=eo.prototype.getFragmentShaderSource;IL.prototype.isTranslucent=eo.prototype.isTranslucent;IL.prototype.getRenderState=eo.prototype.getRenderState;var JY=IL;function $4(e){e=y(e,y.EMPTY_OBJECT),this._camera=e.camera,this._frustumSplits=e.frustumSplits,this._color=y(e.color,k.CYAN),this._updateOnChange=y(e.updateOnChange,!0),this.show=y(e.show,!0),this.id=e.id,this._id=void 0,this._outlinePrimitives=[],this._planesPrimitives=[]}var prt=new m,_rt=new Z,grt=new Ne,yrt=new bi,Art=new Yc,xrt=new nn,Crt=new br,Trt=new k,Ert=[1,1e5];$4.prototype.update=function(e){if(!this.show)return;let t=this._planesPrimitives,n=this._outlinePrimitives,i,o;if(this._updateOnChange){for(o=t.length,i=0;i<o;++i)n[i]=n[i]&&n[i].destroy(),t[i]=t[i]&&t[i].destroy();t.length=0,n.length=0}if(t.length===0){let r=this._camera,s=r.frustum,a;s instanceof bi?a=yrt:s instanceof Yc?a=Art:s instanceof nn?a=xrt:a=Crt,a=s.clone(a);let c,l=this._frustumSplits;!u(l)||l.length<=1?(l=Ert,l[0]=this._camera.frustum.near,l[1]=this._camera.frustum.far,c=1):c=l.length-1;let f=r.positionWC,d=r.directionWC,p=r.upWC,g=r.rightWC;g=m.negate(g,prt);let h=_rt;Z.setColumn(h,0,g,h),Z.setColumn(h,1,p,h),Z.setColumn(h,2,d,h);let A=Ne.fromRotationMatrix(h,grt);for(t.length=n.length=c,i=0;i<c;++i)a.near=l[i],a.far=l[i+1],t[i]=new vn({geometryInstances:new xt({geometry:new Gx({origin:f,orientation:A,frustum:a,_drawNearPlane:i===0}),attributes:{color:Ut.fromColor(k.fromAlpha(this._color,.1,Trt))},id:this.id,pickPrimitive:this}),appearance:new sn({translucent:!0,flat:!0}),asynchronous:!1}),n[i]=new vn({geometryInstances:new xt({geometry:new YB({origin:f,orientation:A,frustum:a,_drawNearPlane:i===0}),attributes:{color:Ut.fromColor(this._color)},id:this.id,pickPrimitive:this}),appearance:new sn({translucent:!1,flat:!0}),asynchronous:!1})}for(o=t.length,i=0;i<o;++i)n[i].update(e),t[i].update(e)};$4.prototype.isDestroyed=function(){return!1};$4.prototype.destroy=function(){let e=this._planesPrimitives.length;for(let t=0;t<e;++t)this._outlinePrimitives[t]=this._outlinePrimitives[t]&&this._outlinePrimitives[t].destroy(),this._planesPrimitives[t]=this._planesPrimitives[t]&&this._planesPrimitives[t].destroy();return ue(this)};var Th=$4;function hge(){this._cachedShowFrustumsShaders={}}function brt(e){let t={},n=e.vertexAttributes;for(let i in n)n.hasOwnProperty(i)&&(t[i]=n[i].index);return t}function Srt(e,t){let n=e.context,i=t,o=i.fragmentShaderSource.clone(),r=[];o.sources=o.sources.map(function(f){f=He.replaceMain(f,"czm_Debug_main");let d=/out_FragData_(\d+)/g,p;for(;(p=d.exec(f))!==null;)r.indexOf(p[1])===-1&&r.push(p[1]);return f});let s=r.length,a="";a+=`uniform vec3 debugShowCommandsColor;
`,a+=`uniform vec3 debugShowFrustumsColor;
`,a+=`void main()
{
czm_Debug_main();
`;let c;if(s>0)for(c=0;c<s;++c)a+=` out_FragData_${r[c]}.rgb *= debugShowCommandsColor;
`,a+=` out_FragData_${r[c]}.rgb *= debugShowFrustumsColor;
`;else a+=` out_FragColor.rgb *= debugShowCommandsColor;
`,a+=` out_FragColor.rgb *= debugShowFrustumsColor;
`;a+="}",o.sources.push(a);let l=brt(i);return Jt.fromCache({context:n,vertexShaderSource:i.vertexShaderSource,fragmentShaderSource:o,attributeLocations:l})}var PL=new k;function vrt(e,t){let n;return u(t.uniformMap)?n=t.uniformMap:n={},u(n.debugShowCommandsColor)||u(n.debugShowFrustumsColor)||(n.debugShowCommandsColor=function(){return e.debugShowCommands?(u(t._debugColor)||(t._debugColor=k.fromRandom()),t._debugColor):k.WHITE},n.debugShowFrustumsColor=function(){return e.debugShowFrustums?(PL.red=t.debugOverlappingFrustums&1<<0?1:0,PL.green=t.debugOverlappingFrustums&1<<1?1:0,PL.blue=t.debugOverlappingFrustums&1<<2?1:0,PL.alpha=1,PL):k.WHITE}),n}var wrt=new nt;hge.prototype.executeDebugShowFrustumsCommand=function(e,t,n){let i=t.shaderProgram.id,o=this._cachedShowFrustumsShaders[i];u(o)||(o=Srt(e,t.shaderProgram),this._cachedShowFrustumsShaders[i]=o);let r=nt.shallowClone(t,wrt);r.shaderProgram=o,r.uniformMap=vrt(e,t),r.execute(e.context,n)};var OL=hge;function ez(e){e=y(e,y.EMPTY_OBJECT),this.length=y(e.length,1e7),this._length=void 0,this.width=y(e.width,2),this._width=void 0,this.show=y(e.show,!0),this.modelMatrix=B.clone(y(e.modelMatrix,B.IDENTITY)),this._modelMatrix=new B,this.id=e.id,this._id=void 0,this._primitive=void 0}ez.prototype.update=function(e){if(this.show){if(!u(this._primitive)||!B.equals(this._modelMatrix,this.modelMatrix)||this._length!==this.length||this._width!==this.width||this._id!==this.id){this._modelMatrix=B.clone(this.modelMatrix,this._modelMatrix),this._length=this.length,this._width=this.width,this._id=this.id,u(this._primitive)&&this._primitive.destroy(),this.modelMatrix[12]===0&&this.modelMatrix[13]===0&&this.modelMatrix[14]===0&&(this.modelMatrix[14]=.01);let t=new xt({geometry:new y_({positions:[m.ZERO,m.UNIT_X],width:this.width,vertexFormat:Hr.VERTEX_FORMAT,colors:[k.RED,k.RED],arcType:Zt.NONE}),modelMatrix:B.multiplyByUniformScale(this.modelMatrix,this.length,new B),id:this.id,pickPrimitive:this}),n=new xt({geometry:new y_({positions:[m.ZERO,m.UNIT_Y],width:this.width,vertexFormat:Hr.VERTEX_FORMAT,colors:[k.GREEN,k.GREEN],arcType:Zt.NONE}),modelMatrix:B.multiplyByUniformScale(this.modelMatrix,this.length,new B),id:this.id,pickPrimitive:this}),i=new xt({geometry:new y_({positions:[m.ZERO,m.UNIT_Z],width:this.width,vertexFormat:Hr.VERTEX_FORMAT,colors:[k.BLUE,k.BLUE],arcType:Zt.NONE}),modelMatrix:B.multiplyByUniformScale(this.modelMatrix,this.length,new B),id:this.id,pickPrimitive:this});this._primitive=new vn({geometryInstances:[t,n,i],appearance:new Hr,asynchronous:!1})}this._primitive.update(e)}};ez.prototype.isDestroyed=function(){return!1};ez.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),ue(this)};var ML=ez;var RL=`in vec4 positionEC;
void main()
{
vec3 position;
vec3 direction;
if (czm_orthographicIn3D == 1.0)
{
vec2 uv = (gl_FragCoord.xy - czm_viewport.xy) / czm_viewport.zw;
vec2 minPlane = vec2(czm_frustumPlanes.z, czm_frustumPlanes.y); // left, bottom
vec2 maxPlane = vec2(czm_frustumPlanes.w, czm_frustumPlanes.x); // right, top
position = vec3(mix(minPlane, maxPlane, uv), 0.0);
direction = vec3(0.0, 0.0, -1.0);
}
else
{
position = vec3(0.0);
direction = normalize(positionEC.xyz);
}
czm_ray ray = czm_ray(position, direction);
vec3 ellipsoid_center = czm_view[3].xyz;
czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoidInverseRadii);
if (!czm_isEmpty(intersection))
{
out_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
}
else
{
discard;
}
czm_writeLogDepth();
}
`;var BL=`in vec4 position;
out vec4 positionEC;
void main()
{
positionEC = czm_modelView * position;
gl_Position = czm_projection * positionEC;
czm_vertexLogDepth();
}
`;function NL(e){this._rs=void 0,this._sp=void 0,this._va=void 0,this._command=void 0,this._mode=void 0,this._useLogDepth=!1,this._ellipsoidOffset=y(e,0)}var LL=kt.supportsTypedArrays()?new Float32Array(12):[],pge=new m,_ge=new m,ZY=new m,gge=new m,tz=new m;function Drt(e,t){let n=e.radii,i=t.camera,o,r,s;if(i.frustum instanceof nn)o=m.ZERO,r=i.rightWC,s=i.upWC;else{let d=i.positionWC,p=m.multiplyComponents(e.oneOverRadii,d,pge),g=m.normalize(p,_ge),h=m.normalize(m.cross(m.UNIT_Z,p,ZY),ZY),A=m.normalize(m.cross(g,h,gge),gge),x=m.magnitude(p),C=Math.sqrt(x*x-1);o=m.multiplyByScalar(g,1/x,pge);let T=C/x;r=m.multiplyByScalar(h,T,_ge),s=m.multiplyByScalar(A,T,ZY)}let a=m.add(o,s,tz);m.subtract(a,r,a),m.multiplyComponents(n,a,a),m.pack(a,LL,0);let c=m.subtract(o,s,tz);m.subtract(c,r,c),m.multiplyComponents(n,c,c),m.pack(c,LL,3);let l=m.add(o,s,tz);m.add(l,r,l),m.multiplyComponents(n,l,l),m.pack(l,LL,6);let f=m.subtract(o,s,tz);return m.add(f,r,f),m.multiplyComponents(n,f,f),m.pack(f,LL,9),LL}NL.prototype.update=function(e){if(this._mode=e.mode,e.mode!==ne.SCENE3D)return;let t=e.context,n=e.mapProjection.ellipsoid.radii,i=new oe(n.x+this._ellipsoidOffset,n.y+this._ellipsoidOffset,n.z+this._ellipsoidOffset),o=e.useLogDepth;if(u(this._command)||(this._rs=ke.fromCache({cull:{enabled:!0},depthTest:{enabled:!0},colorMask:{red:!1,green:!1,blue:!1,alpha:!1}}),this._command=new nt({renderState:this._rs,boundingVolume:new ae(m.ZERO,i.maximumRadius),pass:be.OPAQUE,owner:this})),!u(this._sp)||this._useLogDepth!==o){this._useLogDepth=o;let s=new He({sources:[BL]}),a=new He({sources:[RL]});o&&(a.defines.push("LOG_DEPTH"),s.defines.push("LOG_DEPTH")),this._sp=Jt.replaceCache({shaderProgram:this._sp,context:t,vertexShaderSource:s,fragmentShaderSource:a,attributeLocations:{position:0}}),this._command.shaderProgram=this._sp}let r=Drt(i,e);if(u(this._va))this._va.getAttribute(0).vertexBuffer.copyFromArrayView(r);else{let s=new lt({attributes:{position:new De({componentDatatype:X.FLOAT,componentsPerAttribute:3,values:r})},indices:[0,1,2,2,1,3],primitiveType:Le.TRIANGLES});this._va=si.fromGeometry({context:t,geometry:s,attributeLocations:{position:0},bufferUsage:Fe.DYNAMIC_DRAW}),this._command.vertexArray=this._va}};NL.prototype.execute=function(e,t){this._mode===ne.SCENE3D&&this._command.execute(e,t)};NL.prototype.isDestroyed=function(){return!1};NL.prototype.destroy=function(){this._sp=this._sp&&this._sp.destroy(),this._va=this._va&&this._va.destroy()};var FL=NL;function UL(){}var Irt=/\bgl_FragDepth\b/,Prt=/\bdiscard\b/;function Ort(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"depthOnly");if(!u(n)){let i=t._attributeLocations,o=t.fragmentShaderSource,r,s=!1,a=o.sources,c=a.length;for(r=0;r<c;++r)if(Irt.test(a[r])||Prt.test(a[r])){s=!0;break}let l=!1,f=o.defines;for(c=f.length,r=0;r<c;++r)if(f[r]==="LOG_DEPTH"){l=!0;break}let d;!s&&!l?(d=`void main()
{
out_FragColor = vec4(1.0);
}
`,o=new He({sources:[d]})):!s&&l&&(d=`void main()
{
out_FragColor = vec4(1.0);
czm_writeLogDepth();
}
`,o=new He({defines:["LOG_DEPTH"],sources:[d]})),n=e.shaderCache.createDerivedShaderProgram(t,"depthOnly",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:o,attributeLocations:i})}return n}function Mrt(e,t){let n=e._depthOnlyRenderStateCache,i=n[t.id];if(!u(i)){let o=ke.getState(t);o.depthMask=!0,o.colorMask={red:!1,green:!1,blue:!1,alpha:!1},i=ke.fromCache(o),n[t.id]=i}return i}UL.createDepthOnlyDerivedCommand=function(e,t,n,i){u(i)||(i={});let o,r;return u(i.depthOnlyCommand)&&(o=i.depthOnlyCommand.shaderProgram,r=i.depthOnlyCommand.renderState),i.depthOnlyCommand=nt.shallowClone(t,i.depthOnlyCommand),!u(o)||i.shaderProgramId!==t.shaderProgram.id?(i.depthOnlyCommand.shaderProgram=Ort(n,t.shaderProgram),i.depthOnlyCommand.renderState=Mrt(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.depthOnlyCommand.shaderProgram=o,i.depthOnlyCommand.renderState=r),i};var Rrt=/\s+czm_writeLogDepth\(/,Brt=/\s+czm_vertexLogDepth\(/;function Lrt(e,t){if(t.fragmentShaderSource.defines.indexOf("LOG_DEPTH_READ_ONLY")>=0)return t;let i=e.shaderCache.getDerivedShaderProgram(t,"logDepth");if(!u(i)){let o=t._attributeLocations,r=t.vertexShaderSource.clone(),s=t.fragmentShaderSource.clone();r.defines=u(r.defines)?r.defines.slice(0):[],r.defines.push("LOG_DEPTH"),s.defines=u(s.defines)?s.defines.slice(0):[],s.defines.push("LOG_DEPTH");let a,c,l=!1,f=r.sources,d=f.length;for(a=0;a<d;++a)if(Brt.test(f[a])){l=!0;break}if(!l){for(a=0;a<d;++a)f[a]=He.replaceMain(f[a],"czm_log_depth_main");c=`
void main()
{
czm_log_depth_main();
czm_vertexLogDepth();
}
`,f.push(c)}for(f=s.sources,d=f.length,l=!1,a=0;a<d;++a)Rrt.test(f[a])&&(l=!0);s.defines.indexOf("LOG_DEPTH_WRITE")!==-1&&(l=!0);let p="";if(!l){for(a=0;a<d;a++)f[a]=He.replaceMain(f[a],"czm_log_depth_main");p+=`
void main()
{
czm_log_depth_main();
czm_writeLogDepth();
}
`}f.push(p),i=e.shaderCache.createDerivedShaderProgram(t,"logDepth",{vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:o})}return i}UL.createLogDepthCommand=function(e,t,n){u(n)||(n={});let i;return u(n.command)&&(i=n.command.shaderProgram),n.command=nt.shallowClone(e,n.command),!u(i)||n.shaderProgramId!==e.shaderProgram.id?(n.command.shaderProgram=Lrt(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};function Nrt(e,t,n){let i=e.shaderCache.getDerivedShaderProgram(t,"pick");if(!u(i)){let o=t._attributeLocations,r=t.fragmentShaderSource,s=r.sources,a=s.length,c=`void main()
{
czm_non_pick_main();
if (out_FragColor.a == 0.0) {
discard;
}
out_FragColor = ${n};
}
`,l=new Array(a+1);for(let f=0;f<a;++f)l[f]=He.replaceMain(s[f],"czm_non_pick_main");l[a]=c,r=new He({sources:l,defines:r.defines}),i=e.shaderCache.createDerivedShaderProgram(t,"pick",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:r,attributeLocations:o})}return i}function Frt(e,t){let n=e.picking.pickRenderStateCache,i=n[t.id];if(!u(i)){let o=ke.getState(t);o.blending.enabled=!1,o.depthMask=!0,i=ke.fromCache(o),n[t.id]=i}return i}UL.createPickDerivedCommand=function(e,t,n,i){u(i)||(i={});let o,r;return u(i.pickCommand)&&(o=i.pickCommand.shaderProgram,r=i.pickCommand.renderState),i.pickCommand=nt.shallowClone(t,i.pickCommand),!u(o)||i.shaderProgramId!==t.shaderProgram.id?(i.pickCommand.shaderProgram=Nrt(n,t.shaderProgram,t.pickId),i.pickCommand.renderState=Frt(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.pickCommand.shaderProgram=o,i.pickCommand.renderState=r),i};function Urt(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"HDR");if(!u(n)){let i=t._attributeLocations,o=t.vertexShaderSource.clone(),r=t.fragmentShaderSource.clone();o.defines=u(o.defines)?o.defines.slice(0):[],o.defines.push("HDR"),r.defines=u(r.defines)?r.defines.slice(0):[],r.defines.push("HDR"),n=e.shaderCache.createDerivedShaderProgram(t,"HDR",{vertexShaderSource:o,fragmentShaderSource:r,attributeLocations:i})}return n}UL.createHdrCommand=function(e,t,n){u(n)||(n={});let i;return u(n.command)&&(i=n.command.shaderProgram),n.command=nt.shallowClone(e,n.command),!u(i)||n.shaderProgramId!==e.shaderProgram.id?(n.command.shaderProgram=Urt(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};var P_=UL;function nz(e){this._scene=e,this._lastAlpha=void 0,this._lastBeta=void 0,this._lastGamma=void 0,this._alpha=void 0,this._beta=void 0,this._gamma=void 0;let t=this;function n(i){let o=i.alpha;if(!u(o)){t._alpha=void 0,t._beta=void 0,t._gamma=void 0;return}t._alpha=P.toRadians(o),t._beta=P.toRadians(i.beta),t._gamma=P.toRadians(i.gamma)}window.addEventListener("deviceorientation",n,!1),this._removeListener=function(){window.removeEventListener("deviceorientation",n,!1)}}var Vrt=new Ne,yge=new Ne,krt=new Z;function zrt(e,t,n,i){let o=e.direction,r=e.right,s=e.up,a=Ne.fromAxisAngle(o,n,yge),c=Ne.fromAxisAngle(r,i,Vrt),l=Ne.multiply(c,a,c),f=Ne.fromAxisAngle(s,t,yge);Ne.multiply(f,l,l);let d=Z.fromQuaternion(l,krt);Z.multiplyByVector(d,r,r),Z.multiplyByVector(d,s,s),Z.multiplyByVector(d,o,o)}nz.prototype.update=function(){if(!u(this._alpha))return;u(this._lastAlpha)||(this._lastAlpha=this._alpha,this._lastBeta=this._beta,this._lastGamma=this._gamma);let e=this._lastAlpha-this._alpha,t=this._lastBeta-this._beta,n=this._lastGamma-this._gamma;zrt(this._scene.camera,-e,t,n),this._lastAlpha=this._alpha,this._lastBeta=this._beta,this._lastGamma=this._gamma};nz.prototype.isDestroyed=function(){return!1};nz.prototype.destroy=function(){return this._removeListener(),ue(this)};var VL=nz;function Hrt(e){this.direction=m.clone(e.direction),this.color=k.clone(y(e.color,k.WHITE)),this.intensity=y(e.intensity,1)}var QY=Hrt;var iS=`uniform vec3 u_radii;
uniform vec3 u_oneOverEllipsoidRadiiSquared;
in vec3 v_positionEC;
vec4 computeEllipsoidColor(czm_ray ray, float intersection, float side)
{
vec3 positionEC = czm_pointAlongRay(ray, intersection);
vec3 positionMC = (czm_inverseModelView * vec4(positionEC, 1.0)).xyz;
vec3 geodeticNormal = normalize(czm_geodeticSurfaceNormal(positionMC, vec3(0.0), u_oneOverEllipsoidRadiiSquared));
vec3 sphericalNormal = normalize(positionMC / u_radii);
vec3 normalMC = geodeticNormal * side; // normalized surface normal (always facing the viewer) in model coordinates
vec3 normalEC = normalize(czm_normal * normalMC); // normalized surface normal in eye coordiantes
vec2 st = czm_ellipsoidWgs84TextureCoordinates(sphericalNormal);
vec3 positionToEyeEC = -positionEC;
czm_materialInput materialInput;
materialInput.s = st.s;
materialInput.st = st;
materialInput.str = (positionMC + u_radii) / u_radii;
materialInput.normalEC = normalEC;
materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);
materialInput.positionToEyeEC = positionToEyeEC;
czm_material material = czm_getMaterial(materialInput);
#ifdef ONLY_SUN_LIGHTING
return czm_private_phong(normalize(positionToEyeEC), material, czm_sunDirectionEC);
#else
return czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
#endif
}
void main()
{
// PERFORMANCE_TODO: When dynamic branching is available, compute ratio of maximum and minimum radii
// in the vertex shader. Only when it is larger than some constant, march along the ray.
// Otherwise perform one intersection test which will be the common case.
// Test if the ray intersects a sphere with the ellipsoid's maximum radius.
// For very oblate ellipsoids, using the ellipsoid's radii for an intersection test
// may cause false negatives. This will discard fragments before marching the ray forward.
float maxRadius = max(u_radii.x, max(u_radii.y, u_radii.z)) * 1.5;
vec3 direction = normalize(v_positionEC);
vec3 ellipsoidCenter = czm_modelView[3].xyz;
float t1 = -1.0;
float t2 = -1.0;
float b = -2.0 * dot(direction, ellipsoidCenter);
float c = dot(ellipsoidCenter, ellipsoidCenter) - maxRadius * maxRadius;
float discriminant = b * b - 4.0 * c;
if (discriminant >= 0.0) {
t1 = (-b - sqrt(discriminant)) * 0.5;
t2 = (-b + sqrt(discriminant)) * 0.5;
}
if (t1 < 0.0 && t2 < 0.0) {
discard;
}
float t = min(t1, t2);
if (t < 0.0) {
t = 0.0;
}
// March ray forward to intersection with larger sphere and find
czm_ray ray = czm_ray(t * direction, direction);
vec3 ellipsoid_inverseRadii = vec3(1.0 / u_radii.x, 1.0 / u_radii.y, 1.0 / u_radii.z);
czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoidCenter, ellipsoid_inverseRadii);
if (czm_isEmpty(intersection))
{
discard;
}
// If the viewer is outside, compute outsideFaceColor, with normals facing outward.
vec4 outsideFaceColor = (intersection.start != 0.0) ? computeEllipsoidColor(ray, intersection.start, 1.0) : vec4(0.0);
// If the viewer either is inside or can see inside, compute insideFaceColor, with normals facing inward.
vec4 insideFaceColor = (outsideFaceColor.a < 1.0) ? computeEllipsoidColor(ray, intersection.stop, -1.0) : vec4(0.0);
out_FragColor = mix(insideFaceColor, outsideFaceColor, outsideFaceColor.a);
out_FragColor.a = 1.0 - (1.0 - insideFaceColor.a) * (1.0 - outsideFaceColor.a);
#if (defined(WRITE_DEPTH) && (__VERSION__ == 300 || defined(GL_EXT_frag_depth)))
t = (intersection.start != 0.0) ? intersection.start : intersection.stop;
vec3 positionEC = czm_pointAlongRay(ray, t);
vec4 positionCC = czm_projection * vec4(positionEC, 1.0);
#ifdef LOG_DEPTH
czm_writeLogDepth(1.0 + positionCC.w);
#else
float z = positionCC.z / positionCC.w;
float n = czm_depthRange.near;
float f = czm_depthRange.far;
gl_FragDepth = (z * (f - n) + f + n) * 0.5;
#endif
#endif
}
`;var oS=`in vec3 position;
uniform vec3 u_radii;
out vec3 v_positionEC;
void main()
{
// In the vertex data, the cube goes from (-1.0, -1.0, -1.0) to (1.0, 1.0, 1.0) in model coordinates.
// Scale to consider the radii. We could also do this once on the CPU when using the BoxGeometry,
// but doing it here allows us to change the radii without rewriting the vertex data, and
// allows all ellipsoids to reuse the same vertex data.
vec4 p = vec4(u_radii * position, 1.0);
v_positionEC = (czm_modelView * p).xyz; // position in eye coordinates
gl_Position = czm_modelViewProjection * p; // position in clip coordinates
// With multi-frustum, when the ellipsoid primitive is positioned on the intersection of two frustums
// and close to terrain, the terrain (writes depth) in the closest frustum can overwrite part of the
// ellipsoid (does not write depth) that was rendered in the farther frustum.
//
// Here, we clamp the depth in the vertex shader to avoid being overwritten; however, this creates
// artifacts since some fragments can be alpha blended twice. This is solved by only rendering
// the ellipsoid in the closest frustum to the viewer.
gl_Position.z = clamp(gl_Position.z, czm_depthRange.near, czm_depthRange.far);
czm_vertexLogDepth();
}
`;var $Y={position:0};function iz(e){e=y(e,y.EMPTY_OBJECT),this.center=m.clone(y(e.center,m.ZERO)),this._center=new m,this.radii=m.clone(e.radii),this._radii=new m,this._oneOverEllipsoidRadiiSquared=new m,this._boundingSphere=new ae,this.modelMatrix=B.clone(y(e.modelMatrix,B.IDENTITY)),this._modelMatrix=new B,this._computedModelMatrix=new B,this.show=y(e.show,!0),this.material=y(e.material,zi.fromType(zi.ColorType)),this._material=void 0,this._translucent=void 0,this.id=e.id,this._id=void 0,this.debugShowBoundingVolume=y(e.debugShowBoundingVolume,!1),this.onlySunLighting=y(e.onlySunLighting,!1),this._onlySunLighting=!1,this._depthTestEnabled=y(e.depthTestEnabled,!0),this._useLogDepth=!1,this._sp=void 0,this._rs=void 0,this._va=void 0,this._pickSP=void 0,this._pickId=void 0,this._colorCommand=new nt({owner:y(e._owner,this)}),this._pickCommand=new nt({owner:y(e._owner,this),pickOnly:!0});let t=this;this._uniforms={u_radii:function(){return t.radii},u_oneOverEllipsoidRadiiSquared:function(){return t._oneOverEllipsoidRadiiSquared}},this._pickUniforms={czm_pickColor:function(){return t._pickId.color}}}function Grt(e){let t=e.cache.ellipsoidPrimitive_vertexArray;if(u(t))return t;let n=rl.createGeometry(rl.fromDimensions({dimensions:new m(2,2,2),vertexFormat:Oe.POSITION_ONLY}));return t=si.fromGeometry({context:e,geometry:n,attributeLocations:$Y,bufferUsage:Fe.STATIC_DRAW,interleave:!0}),e.cache.ellipsoidPrimitive_vertexArray=t,t}iz.prototype.update=function(e){if(!this.show||e.mode!==ne.SCENE3D||!u(this.center)||!u(this.radii))return;let t=e.context,n=this.material.isTranslucent(),i=this._translucent!==n;(!u(this._rs)||i)&&(this._translucent=n,this._rs=ke.fromCache({cull:{enabled:!0,face:_i.FRONT},depthTest:{enabled:this._depthTestEnabled},depthMask:!n&&t.fragmentDepth,blending:n?un.ALPHA_BLEND:void 0})),u(this._va)||(this._va=Grt(t));let o=!1,r=this.radii;if(!m.equals(this._radii,r)){m.clone(r,this._radii);let A=this._oneOverEllipsoidRadiiSquared;A.x=1/(r.x*r.x),A.y=1/(r.y*r.y),A.z=1/(r.z*r.z),o=!0}(!B.equals(this.modelMatrix,this._modelMatrix)||!m.equals(this.center,this._center))&&(B.clone(this.modelMatrix,this._modelMatrix),m.clone(this.center,this._center),B.multiplyByTranslation(this.modelMatrix,this.center,this._computedModelMatrix),o=!0),o&&(m.clone(m.ZERO,this._boundingSphere.center),this._boundingSphere.radius=m.maximumComponent(r),ae.transform(this._boundingSphere,this._computedModelMatrix,this._boundingSphere));let s=this._material!==this.material;this._material=this.material,this._material.update(t);let a=this.onlySunLighting!==this._onlySunLighting;this._onlySunLighting=this.onlySunLighting;let c=e.useLogDepth,l=this._useLogDepth!==c;this._useLogDepth=c;let f=this._colorCommand,d,p;(s||a||i||l)&&(d=new He({sources:[oS]}),p=new He({sources:[this.material.shaderSource,iS]}),this.onlySunLighting&&p.defines.push("ONLY_SUN_LIGHTING"),!n&&t.fragmentDepth&&p.defines.push("WRITE_DEPTH"),this._useLogDepth&&(d.defines.push("LOG_DEPTH"),p.defines.push("LOG_DEPTH")),this._sp=Jt.replaceCache({context:t,shaderProgram:this._sp,vertexShaderSource:d,fragmentShaderSource:p,attributeLocations:$Y}),f.vertexArray=this._va,f.renderState=this._rs,f.shaderProgram=this._sp,f.uniformMap=ht(this._uniforms,this.material._uniforms),f.executeInClosestFrustum=n);let g=e.commandList,h=e.passes;if(h.render&&(f.boundingVolume=this._boundingSphere,f.debugShowBoundingVolume=this.debugShowBoundingVolume,f.modelMatrix=this._computedModelMatrix,f.pass=n?be.TRANSLUCENT:be.OPAQUE,g.push(f)),h.pick){let A=this._pickCommand;(!u(this._pickId)||this._id!==this.id)&&(this._id=this.id,this._pickId=this._pickId&&this._pickId.destroy(),this._pickId=t.createPickId({primitive:this,id:this.id})),(s||a||!u(this._pickSP)||l)&&(d=new He({sources:[oS]}),p=new He({sources:[this.material.shaderSource,iS],pickColorQualifier:"uniform"}),this.onlySunLighting&&p.defines.push("ONLY_SUN_LIGHTING"),!n&&t.fragmentDepth&&p.defines.push("WRITE_DEPTH"),this._useLogDepth&&(d.defines.push("LOG_DEPTH"),p.defines.push("LOG_DEPTH")),this._pickSP=Jt.replaceCache({context:t,shaderProgra
in vec3 v_positionEC;
in vec2 v_st;
void main()
{
czm_materialInput materialInput;
vec3 normalEC = normalize(czm_normal3D * czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0)));
#ifdef FACE_FORWARD
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
#endif
materialInput.s = v_st.s;
materialInput.st = v_st;
materialInput.str = vec3(v_st, 0.0);
// Convert tangent space material normal to eye space
materialInput.normalEC = normalEC;
materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, materialInput.normalEC);
// Convert view vector to world space
vec3 positionToEyeEC = -v_positionEC;
materialInput.positionToEyeEC = positionToEyeEC;
czm_material material = czm_getMaterial(materialInput);
#ifdef FLAT
out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
#else
out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
#endif
}
`;var HL=`in vec3 position3DHigh;
in vec3 position3DLow;
in vec2 st;
in float batchId;
out vec3 v_positionMC;
out vec3 v_positionEC;
out vec2 v_st;
void main()
{
vec4 p = czm_computePosition();
v_positionMC = position3DHigh + position3DLow; // position in model coordinates
v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates
v_st = st;
gl_Position = czm_modelViewProjectionRelativeToEye * p;
}
`;function Qx(e){e=y(e,y.EMPTY_OBJECT);let t=y(e.translucent,!0),n=y(e.aboveGround,!1);this.material=u(e.material)?e.material:zi.fromType(zi.ColorType),this.translucent=y(e.translucent,!0),this._vertexShaderSource=y(e.vertexShaderSource,HL),this._fragmentShaderSource=y(e.fragmentShaderSource,zL),this._renderState=eo.getDefaultRenderState(t,!n,e.renderState),this._closed=!1,this._flat=y(e.flat,!1),this._faceForward=y(e.faceForward,n),this._aboveGround=n}Object.defineProperties(Qx.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 Qx.VERTEX_FORMAT}},flat:{get:function(){return this._flat}},faceForward:{get:function(){return this._faceForward}},aboveGround:{get:function(){return this._aboveGround}}});Qx.VERTEX_FORMAT=Oe.POSITION_AND_ST;Qx.prototype.getFragmentShaderSource=eo.prototype.getFragmentShaderSource;Qx.prototype.isTranslucent=eo.prototype.isTranslucent;Qx.prototype.getRenderState=eo.prototype.getRenderState;var eq=Qx;function Age(){this.enabled=!0,this.renderable=!0,this.density=2e-4,this.screenSpaceErrorFactor=2,this.minimumBrightness=.03}var oz=[359.393,800.749,1275.6501,2151.1192,3141.7763,4777.5198,6281.2493,12364.307,15900.765,49889.0549,78026.8259,99260.7344,120036.3873,151011.0158,156091.1953,203849.3112,274866.9803,319916.3149,493552.0528,628733.5874],Eh=[2e-5,2e-4,1e-4,7e-5,5e-5,4e-5,3e-5,19e-6,1e-5,85e-7,62e-7,58e-7,53e-7,52e-7,51e-7,42e-7,4e-6,34e-7,26e-7,22e-7];for(let e=0;e<Eh.length;++e)Eh[e]*=1e6;var xge=Eh[1],tq=Eh[Eh.length-1];for(let e=0;e<Eh.length;++e)Eh[e]=(Eh[e]-tq)/(xge-tq);var sa=0;function Wrt(e){let t=oz,n=t.length;if(e<t[0])return sa=0,sa;if(e>t[n-1])return sa=n-2,sa;if(e>=t[sa]){if(sa+1<n&&e<t[sa+1])return sa;if(sa+2<n&&e<t[sa+2])return++sa,sa}else if(sa-1>=0&&e>=t[sa-1])return--sa,sa;let i;for(i=0;i<n-2&&!(e>=t[i]&&e<t[i+1]);++i);return sa=i,sa}var jrt=new m;Age.prototype.update=function(e){if(!(e.fog.enabled=this.enabled))return;e.fog.renderable=this.renderable;let n=e.camera,i=n.positionCartographic;if(!u(i)||i.height>8e5||e.mode!==ne.SCENE3D){e.fog.enabled=!1;return}let o=i.height,r=Wrt(o),s=P.clamp((o-oz[r])/(oz[r+1]-oz[r]),0,1),a=P.lerp(Eh[r],Eh[r+1],s),c=this.density*1e6,l=c/xge*tq;a=a*(c-l)*1e-6;let f=m.normalize(n.positionWC,jrt),d=Math.abs(m.dot(n.directionWC,f));a*=1-d,e.fog.density=a,e.fog.sse=this.screenSpaceErrorFactor,e.fog.minimumBrightness=this.minimumBrightness};var GL=Age;function Fl(e){this._scene=e.scene,this.samplingWindow=y(e.samplingWindow,Fl.defaultSettings.samplingWindow),this.quietPeriod=y(e.quietPeriod,Fl.defaultSettings.quietPeriod),this.warmupPeriod=y(e.warmupPeriod,Fl.defaultSettings.warmupPeriod),this.minimumFrameRateDuringWarmup=y(e.minimumFrameRateDuringWarmup,Fl.defaultSettings.minimumFrameRateDuringWarmup),this.minimumFrameRateAfterWarmup=y(e.minimumFrameRateAfterWarmup,Fl.defaultSettings.minimumFrameRateAfterWarmup),this._lowFrameRate=new ye,this._nominalFrameRate=new ye,this._frameTimes=[],this._needsQuietPeriod=!0,this._quietPeriodEndTime=0,this._warmupPeriodEndTime=0,this._frameRateIsLow=!1,this._lastFramesPerSecond=void 0,this._pauseCount=0;let t=this;this._preUpdateRemoveListener=this._scene.preUpdate.addEventListener(function(o,r){Yrt(t,r)}),this._hiddenPropertyName=document.hidden!==void 0?"hidden":document.mozHidden!==void 0?"mozHidden":document.msHidden!==void 0?"msHidden":document.webkitHidden!==void 0?"webkitHidden":void 0;let n=document.hidden!==void 0?"visibilitychange":document.mozHidden!==void 0?"mozvisibilitychange":document.msHidden!==void 0?"msvisibilitychange":document.webkitHidden!==void 0?"webkitvisibilitychange":void 0;function i(){qrt(t)}this._visibilityChangeRemoveListener=void 0,u(n)&&(document.addEventListener(n,i,!1),this._visibilityChangeRemoveListener=function(){document.removeEventListener(n,i,!1)})}Fl.defaultSettings={samplingWindow:5,quietPeriod:2,warmupPeriod:5,minimumFrameRateDuringW
#if TEXTURE_UNITS > 0
uniform sampler2D u_dayTextures[TEXTURE_UNITS];
uniform vec4 u_dayTextureTranslationAndScale[TEXTURE_UNITS];
uniform bool u_dayTextureUseWebMercatorT[TEXTURE_UNITS];
#ifdef APPLY_ALPHA
uniform float u_dayTextureAlpha[TEXTURE_UNITS];
#endif
#ifdef APPLY_DAY_NIGHT_ALPHA
uniform float u_dayTextureNightAlpha[TEXTURE_UNITS];
uniform float u_dayTextureDayAlpha[TEXTURE_UNITS];
#endif
#ifdef APPLY_SPLIT
uniform float u_dayTextureSplit[TEXTURE_UNITS];
#endif
#ifdef APPLY_BRIGHTNESS
uniform float u_dayTextureBrightness[TEXTURE_UNITS];
#endif
#ifdef APPLY_CONTRAST
uniform float u_dayTextureContrast[TEXTURE_UNITS];
#endif
#ifdef APPLY_HUE
uniform float u_dayTextureHue[TEXTURE_UNITS];
#endif
#ifdef APPLY_SATURATION
uniform float u_dayTextureSaturation[TEXTURE_UNITS];
#endif
#ifdef APPLY_GAMMA
uniform float u_dayTextureOneOverGamma[TEXTURE_UNITS];
#endif
#ifdef APPLY_IMAGERY_CUTOUT
uniform vec4 u_dayTextureCutoutRectangles[TEXTURE_UNITS];
#endif
#ifdef APPLY_COLOR_TO_ALPHA
uniform vec4 u_colorsToAlpha[TEXTURE_UNITS];
#endif
uniform vec4 u_dayTextureTexCoordsRectangle[TEXTURE_UNITS];
#endif
#ifdef SHOW_REFLECTIVE_OCEAN
uniform sampler2D u_waterMask;
uniform vec4 u_waterMaskTranslationAndScale;
uniform float u_zoomedOutOceanSpecularIntensity;
#endif
#ifdef SHOW_OCEAN_WAVES
uniform sampler2D u_oceanNormalMap;
#endif
#if defined(ENABLE_DAYNIGHT_SHADING) || defined(GROUND_ATMOSPHERE)
uniform vec2 u_lightingFadeDistance;
#endif
#ifdef TILE_LIMIT_RECTANGLE
uniform vec4 u_cartographicLimitRectangle;
#endif
#ifdef GROUND_ATMOSPHERE
uniform vec2 u_nightFadeDistance;
#endif
#ifdef ENABLE_CLIPPING_PLANES
uniform highp sampler2D u_clippingPlanes;
uniform mat4 u_clippingPlanesMatrix;
uniform vec4 u_clippingPlanesEdgeStyle;
#endif
#if defined(GROUND_ATMOSPHERE) || defined(FOG) && defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
uniform float u_minimumBrightness;
#endif
#ifdef COLOR_CORRECT
uniform vec3 u_hsbShift; // Hue, saturation, brightness
#endif
#ifdef HIGHLIGHT_FILL_TILE
uniform vec4 u_fillHighlightColor;
#endif
#ifdef TRANSLUCENT
uniform vec4 u_frontFaceAlphaByDistance;
uniform vec4 u_backFaceAlphaByDistance;
uniform vec4 u_translucencyRectangle;
#endif
#ifdef UNDERGROUND_COLOR
uniform vec4 u_undergroundColor;
uniform vec4 u_undergroundColorAlphaByDistance;
#endif
#ifdef ENABLE_VERTEX_LIGHTING
uniform float u_lambertDiffuseMultiplier;
uniform float u_vertexShadowDarkness;
#endif
in vec3 v_positionMC;
in vec3 v_positionEC;
in vec3 v_textureCoordinates;
in vec3 v_normalMC;
in vec3 v_normalEC;
#ifdef APPLY_MATERIAL
in float v_height;
in float v_slope;
in float v_aspect;
#endif
#if defined(FOG) || defined(GROUND_ATMOSPHERE) || defined(UNDERGROUND_COLOR) || defined(TRANSLUCENT)
in float v_distance;
#endif
#if defined(GROUND_ATMOSPHERE) || defined(FOG)
in vec3 v_atmosphereRayleighColor;
in vec3 v_atmosphereMieColor;
in float v_atmosphereOpacity;
#endif
#if defined(UNDERGROUND_COLOR) || defined(TRANSLUCENT)
float interpolateByDistance(vec4 nearFarScalar, float distance)
{
float startDistance = nearFarScalar.x;
float startValue = nearFarScalar.y;
float endDistance = nearFarScalar.z;
float endValue = nearFarScalar.w;
float t = clamp((distance - startDistance) / (endDistance - startDistance), 0.0, 1.0);
return mix(startValue, endValue, t);
}
#endif
#if defined(UNDERGROUND_COLOR) || defined(TRANSLUCENT) || defined(APPLY_MATERIAL)
vec4 alphaBlend(vec4 sourceColor, vec4 destinationColor)
{
return sourceColor * vec4(sourceColor.aaa, 1.0) + destinationColor * (1.0 - sourceColor.a);
}
#endif
#ifdef TRANSLUCENT
bool inTranslucencyRectangle()
{
return
v_textureCoordinates.x > u_translucencyRectangle.x &&
v_textureCoordinates.x < u_translucencyRectangle.z &&
v_textureCoordinates.y > u_translucencyRectangle.y &&
v_textureCoordinates.y < u_translucencyRectangle.w;
}
#endif
vec4 sampleAndBlend(
vec4 previousColor,
sampler2D textureToSample,
vec2 tileTextureCoordinates,
vec4 textureCoordinateRectangle,
vec4 textureCoordinateTranslationAndScale,
float textureAlpha,
float textureNightAlpha,
float textureDayAlpha,
float textureBrightness,
float textureContrast,
float textureHue,
float textureSaturation,
float textureOneOverGamma,
float split,
vec4 colorToAlpha,
float nightBlend)
{
// This crazy step stuff sets the alpha to 0.0 if this following condition is true:
// tileTextureCoordinates.s < textureCoordinateRectangle.s ||
// tileTextureCoordinates.s > textureCoordinateRectangle.p ||
// tileTextureCoordinates.t < textureCoordinateRectangle.t ||
// tileTextureCoordinates.t > textureCoordinateRectangle.q
// In other words, the alpha is zero if the fragment is outside the rectangle
// covered by this texture. Would an actual 'if' yield better performance?
vec2 alphaMultiplier = step(textureCoordinateRectangle.st, tileTextureCoordinates);
textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
alphaMultiplier = step(vec2(0.0), textureCoordinateRectangle.pq - tileTextureCoordinates);
textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
#if defined(APPLY_DAY_NIGHT_ALPHA) && defined(ENABLE_DAYNIGHT_SHADING)
textureAlpha *= mix(textureDayAlpha, textureNightAlpha, nightBlend);
#endif
vec2 translation = textureCoordinateTranslationAndScale.xy;
vec2 scale = textureCoordinateTranslationAndScale.zw;
vec2 textureCoordinates = tileTextureCoordinates * scale + translation;
vec4 value = texture(textureToSample, textureCoordinates);
vec3 color = value.rgb;
float alpha = value.a;
#ifdef APPLY_COLOR_TO_ALPHA
vec3 colorDiff = abs(color.rgb - colorToAlpha.rgb);
colorDiff.r = max(max(colorDiff.r, colorDiff.g), colorDiff.b);
alpha = czm_branchFreeTernary(colorDiff.r < colorToAlpha.a, 0.0, alpha);
#endif
#if !defined(APPLY_GAMMA)
vec4 tempColor = czm_gammaCorrect(vec4(color, alpha));
color = tempColor.rgb;
alpha = tempColor.a;
#else
color = pow(color, vec3(textureOneOverGamma));
#endif
#ifdef APPLY_SPLIT
float splitPosition = czm_splitPosition;
// Split to the left
if (split < 0.0 && gl_FragCoord.x > splitPosition) {
alpha = 0.0;
}
// Split to the right
else if (split > 0.0 && gl_FragCoord.x < splitPosition) {
alpha = 0.0;
}
#endif
#ifdef APPLY_BRIGHTNESS
color = mix(vec3(0.0), color, textureBrightness);
#endif
#ifdef APPLY_CONTRAST
color = mix(vec3(0.5), color, textureContrast);
#endif
#ifdef APPLY_HUE
color = czm_hue(color, textureHue);
#endif
#ifdef APPLY_SATURATION
color = czm_saturation(color, textureSaturation);
#endif
float sourceAlpha = alpha * textureAlpha;
float outAlpha = mix(previousColor.a, 1.0, sourceAlpha);
outAlpha += sign(outAlpha) - 1.0;
vec3 outColor = mix(previousColor.rgb * previousColor.a, color, sourceAlpha) / outAlpha;
// When rendering imagery for a tile in multiple passes,
// some GPU/WebGL implementation combinations will not blend fragments in
// additional passes correctly if their computation includes an unmasked
// divide-by-zero operation,
// even if it's not in the output or if the output has alpha zero.
//
// For example, without sanitization for outAlpha,
// this renders without artifacts:
// if (outAlpha == 0.0) { outColor = vec3(0.0); }
//
// but using czm_branchFreeTernary will cause portions of the tile that are
// alpha-zero in the additional pass to render as black instead of blending
// with the previous pass:
// outColor = czm_branchFreeTernary(outAlpha == 0.0, vec3(0.0), outColor);
//
// So instead, sanitize against divide-by-zero,
// store this state on the sign of outAlpha, and correct on return.
return vec4(outColor, max(outAlpha, 0.0));
}
vec3 colorCorrect(vec3 rgb) {
#ifdef COLOR_CORRECT
// Convert rgb color to hsb
vec3 hsb = czm_RGBToHSB(rgb);
// Perform hsb shift
hsb.x += u_hsbShift.x; // hue
hsb.y = clamp(hsb.y + u_hsbShift.y, 0.0, 1.0); // saturation
hsb.z = hsb.z > czm_epsilon7 ? hsb.z + u_hsbShift.z : 0.0; // brightness
// Convert shifted hsb back to rgb
rgb = czm_HSBToRGB(hsb);
#endif
return rgb;
}
vec4 computeDayColor(vec4 initialColor, vec3 textureCoordinates, float nightBlend);
vec4 computeWaterColor(vec3 positionEyeCoordinates, vec2 textureCoordinates, mat3 enuToEye, vec4 imageryColor, float specularMapValue, float fade);
const float fExposure = 2.0;
vec3 computeEllipsoidPosition()
{
float mpp = czm_metersPerPixel(vec4(0.0, 0.0, -czm_currentFrustum.x, 1.0), 1.0);
vec2 xy = gl_FragCoord.xy / czm_viewport.zw * 2.0 - vec2(1.0);
xy *= czm_viewport.zw * mpp * 0.5;
vec3 direction = normalize(vec3(xy, -czm_currentFrustum.x));
czm_ray ray = czm_ray(vec3(0.0), direction);
vec3 ellipsoid_center = czm_view[3].xyz;
czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoidInverseRadii);
vec3 ellipsoidPosition = czm_pointAlongRay(ray, intersection.start);
return (czm_inverseView * vec4(ellipsoidPosition, 1.0)).xyz;
}
void main()
{
#ifdef TILE_LIMIT_RECTANGLE
if (v_textureCoordinates.x < u_cartographicLimitRectangle.x || u_cartographicLimitRectangle.z < v_textureCoordinates.x ||
v_textureCoordinates.y < u_cartographicLimitRectangle.y || u_cartographicLimitRectangle.w < v_textureCoordinates.y)
{
discard;
}
#endif
#ifdef ENABLE_CLIPPING_PLANES
float clipDistance = clip(gl_FragCoord, u_clippingPlanes, u_clippingPlanesMatrix);
#endif
#if defined(SHOW_REFLECTIVE_OCEAN) || defined(ENABLE_DAYNIGHT_SHADING) || defined(HDR)
vec3 normalMC = czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0)); // normalized surface normal in model coordinates
vec3 normalEC = czm_normal3D * normalMC; // normalized surface normal in eye coordiantes
#endif
#if defined(APPLY_DAY_NIGHT_ALPHA) && defined(ENABLE_DAYNIGHT_SHADING)
float nightBlend = 1.0 - clamp(czm_getLambertDiffuse(czm_lightDirectionEC, normalEC) * 5.0, 0.0, 1.0);
#else
float nightBlend = 0.0;
#endif
// The clamp below works around an apparent bug in Chrome Canary v23.0.1241.0
// where the fragment shader sees textures coordinates < 0.0 and > 1.0 for the
// fragments on the edges of tiles even though the vertex shader is outputting
// coordinates strictly in the 0-1 range.
vec4 color = computeDayColor(u_initialColor, clamp(v_textureCoordinates, 0.0, 1.0), nightBlend);
#ifdef SHOW_TILE_BOUNDARIES
if (v_textureCoordinates.x < (1.0/256.0) || v_textureCoordinates.x > (255.0/256.0) ||
v_textureCoordinates.y < (1.0/256.0) || v_textureCoordinates.y > (255.0/256.0))
{
color = vec4(1.0, 0.0, 0.0, 1.0);
}
#endif
#if defined(ENABLE_DAYNIGHT_SHADING) || defined(GROUND_ATMOSPHERE)
float cameraDist;
if (czm_sceneMode == czm_sceneMode2D)
{
cameraDist = max(czm_frustumPlanes.x - czm_frustumPlanes.y, czm_frustumPlanes.w - czm_frustumPlanes.z) * 0.5;
}
else if (czm_sceneMode == czm_sceneModeColumbusView)
{
cameraDist = -czm_view[3].z;
}
else
{
cameraDist = length(czm_view[3]);
}
float fadeOutDist = u_lightingFadeDistance.x;
float fadeInDist = u_lightingFadeDistance.y;
if (czm_sceneMode != czm_sceneMode3D) {
vec3 radii = czm_ellipsoidRadii;
float maxRadii = max(radii.x, max(radii.y, radii.z));
fadeOutDist -= maxRadii;
fadeInDist -= maxRadii;
}
float fade = clamp((cameraDist - fadeOutDist) / (fadeInDist - fadeOutDist), 0.0, 1.0);
#else
float fade = 0.0;
#endif
#ifdef SHOW_REFLECTIVE_OCEAN
vec2 waterMaskTranslation = u_waterMaskTranslationAndScale.xy;
vec2 waterMaskScale = u_waterMaskTranslationAndScale.zw;
vec2 waterMaskTextureCoordinates = v_textureCoordinates.xy * waterMaskScale + waterMaskTranslation;
waterMaskTextureCoordinates.y = 1.0 - waterMaskTextureCoordinates.y;
float mask = texture(u_waterMask, waterMaskTextureCoordinates).r;
if (mask > 0.0)
{
mat3 enuToEye = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalEC);
vec2 ellipsoidTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC);
vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC.zyx);
vec2 textureCoordinates = mix(ellipsoidTextureCoordinates, ellipsoidFlippedTextureCoordinates, czm_morphTime * smoothstep(0.9, 0.95, normalMC.z));
color = computeWaterColor(v_positionEC, textureCoordinates, enuToEye, color, mask, fade);
}
#endif
#ifdef APPLY_MATERIAL
czm_materialInput materialInput;
materialInput.st = v_textureCoordinates.st;
materialInput.normalEC = normalize(v_normalEC);
materialInput.positionToEyeEC = -v_positionEC;
materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalize(v_normalEC));
materialInput.slope = v_slope;
materialInput.height = v_height;
materialInput.aspect = v_aspect;
czm_material material = czm_getMaterial(materialInput);
vec4 materialColor = vec4(material.diffuse, material.alpha);
color = alphaBlend(materialColor, color);
#endif
#ifdef ENABLE_VERTEX_LIGHTING
float diffuseIntensity = clamp(czm_getLambertDiffuse(czm_lightDirectionEC, normalize(v_normalEC)) * u_lambertDiffuseMultiplier + u_vertexShadowDarkness, 0.0, 1.0);
vec4 finalColor = vec4(color.rgb * czm_lightColor * diffuseIntensity, color.a);
#elif defined(ENABLE_DAYNIGHT_SHADING)
float diffuseIntensity = clamp(czm_getLambertDiffuse(czm_lightDirectionEC, normalEC) * 5.0 + 0.3, 0.0, 1.0);
diffuseIntensity = mix(1.0, diffuseIntensity, fade);
vec4 finalColor = vec4(color.rgb * czm_lightColor * diffuseIntensity, color.a);
#else
vec4 finalColor = color;
#endif
#ifdef ENABLE_CLIPPING_PLANES
vec4 clippingPlanesEdgeColor = vec4(1.0);
clippingPlanesEdgeColor.rgb = u_clippingPlanesEdgeStyle.rgb;
float clippingPlanesEdgeWidth = u_clippingPlanesEdgeStyle.a;
if (clipDistance < clippingPlanesEdgeWidth)
{
finalColor = clippingPlanesEdgeColor;
}
#endif
#ifdef HIGHLIGHT_FILL_TILE
finalColor = vec4(mix(finalColor.rgb, u_fillHighlightColor.rgb, u_fillHighlightColor.a), finalColor.a);
#endif
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN)
vec3 atmosphereLightDirection = czm_sunDirectionWC;
#else
vec3 atmosphereLightDirection = czm_lightDirectionWC;
#endif
#if defined(GROUND_ATMOSPHERE) || defined(FOG)
if (!czm_backFacing())
{
bool dynamicLighting = false;
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING))
dynamicLighting = true;
#endif
vec3 rayleighColor;
vec3 mieColor;
float opacity;
vec3 positionWC;
vec3 lightDirection;
// When the camera is far away (camera distance > nightFadeOutDistance), the scattering is computed in the fragment shader.
// Otherwise, the scattering is computed in the vertex shader.
#ifdef PER_FRAGMENT_GROUND_ATMOSPHERE
positionWC = computeEllipsoidPosition();
lightDirection = czm_branchFreeTernary(dynamicLighting, atmosphereLightDirection, normalize(positionWC));
computeAtmosphereScattering(
positionWC,
lightDirection,
rayleighColor,
mieColor,
opacity
);
#else
positionWC = v_positionMC;
lightDirection = czm_branchFreeTernary(dynamicLighting, atmosphereLightDirection, normalize(positionWC));
rayleighColor = v_atmosphereRayleighColor;
mieColor = v_atmosphereMieColor;
opacity = v_atmosphereOpacity;
#endif
rayleighColor = colorCorrect(rayleighColor);
mieColor = colorCorrect(mieColor);
vec4 groundAtmosphereColor = computeAtmosphereColor(positionWC, lightDirection, rayleighColor, mieColor, opacity);
// Fog is applied to tiles selected for fog, close to the Earth.
#ifdef FOG
vec3 fogColor = groundAtmosphereColor.rgb;
// If there is lighting, apply that to the fog.
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
float darken = clamp(dot(normalize(czm_viewerPositionWC), atmosphereLightDirection), u_minimumBrightness, 1.0);
fogColor *= darken;
#endif
#ifndef HDR
fogColor.rgb = czm_acesTonemapping(fogColor.rgb);
fogColor.rgb = czm_inverseGamma(fogColor.rgb);
#endif
const float modifier = 0.15;
finalColor = vec4(czm_fog(v_distance, finalColor.rgb, fogColor.rgb, modifier), finalColor.a);
#else
// The transmittance is based on optical depth i.e. the length of segment of the ray inside the atmosphere.
// This value is larger near the "circumference", as it is further away from the camera. We use it to
// brighten up that area of the ground atmosphere.
const float transmittanceModifier = 0.5;
float transmittance = transmittanceModifier + clamp(1.0 - groundAtmosphereColor.a, 0.0, 1.0);
vec3 finalAtmosphereColor = finalColor.rgb + groundAtmosphereColor.rgb * transmittance;
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
float fadeInDist = u_nightFadeDistance.x;
float fadeOutDist = u_nightFadeDistance.y;
float sunlitAtmosphereIntensity = clamp((cameraDist - fadeOutDist) / (fadeInDist - fadeOutDist), 0.05, 1.0);
float darken = clamp(dot(normalize(positionWC), atmosphereLightDirection), 0.0, 1.0);
vec3 darkenendGroundAtmosphereColor = mix(groundAtmosphereColor.rgb, finalAtmosphereColor.rgb, darken);
finalAtmosphereColor = mix(darkenendGroundAtmosphereColor, finalAtmosphereColor, sunlitAtmosphereIntensity);
#endif
#ifndef HDR
finalAtmosphereColor.rgb = vec3(1.0) - exp(-fExposure * finalAtmosphereColor.rgb);
#else
finalAtmosphereColor.rgb = czm_saturation(finalAtmosphereColor.rgb, 1.6);
#endif
finalColor.rgb = mix(finalColor.rgb, finalAtmosphereColor.rgb, fade);
#endif
}
#endif
#ifdef UNDERGROUND_COLOR
if (czm_backFacing())
{
float distanceFromEllipsoid = max(czm_eyeHeight, 0.0);
float distance = max(v_distance - distanceFromEllipsoid, 0.0);
float blendAmount = interpolateByDistance(u_undergroundColorAlphaByDistance, distance);
vec4 undergroundColor = vec4(u_undergroundColor.rgb, u_undergroundColor.a * blendAmount);
finalColor = alphaBlend(undergroundColor, finalColor);
}
#endif
#ifdef TRANSLUCENT
if (inTranslucencyRectangle())
{
vec4 alphaByDistance = gl_FrontFacing ? u_frontFaceAlphaByDistance : u_backFaceAlphaByDistance;
finalColor.a *= interpolateByDistance(alphaByDistance, v_distance);
}
#endif
out_FragColor = finalColor;
}
#ifdef SHOW_REFLECTIVE_OCEAN
float waveFade(float edge0, float edge1, float x)
{
float y = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
return pow(1.0 - y, 5.0);
}
float linearFade(float edge0, float edge1, float x)
{
return clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
}
// Based on water rendering by Jonas Wagner:
// http://29a.ch/2012/7/19/webgl-terrain-rendering-water-fog
// low altitude wave settings
const float oceanFrequencyLowAltitude = 825000.0;
const float oceanAnimationSpeedLowAltitude = 0.004;
const float oceanOneOverAmplitudeLowAltitude = 1.0 / 2.0;
const float oceanSpecularIntensity = 0.5;
// high altitude wave settings
const float oceanFrequencyHighAltitude = 125000.0;
const float oceanAnimationSpeedHighAltitude = 0.008;
const float oceanOneOverAmplitudeHighAltitude = 1.0 / 2.0;
vec4 computeWaterColor(vec3 positionEyeCoordinates, vec2 textureCoordinates, mat3 enuToEye, vec4 imageryColor, float maskValue, float fade)
{
vec3 positionToEyeEC = -positionEyeCoordinates;
float positionToEyeECLength = length(positionToEyeEC);
// The double normalize below works around a bug in Firefox on Android devices.
vec3 normalizedPositionToEyeEC = normalize(normalize(positionToEyeEC));
// Fade out the waves as the camera moves far from the surface.
float waveIntensity = waveFade(70000.0, 1000000.0, positionToEyeECLength);
#ifdef SHOW_OCEAN_WAVES
// high altitude waves
float time = czm_frameNumber * oceanAnimationSpeedHighAltitude;
vec4 noise = czm_getWaterNoise(u_oceanNormalMap, textureCoordinates * oceanFrequencyHighAltitude, time, 0.0);
vec3 normalTangentSpaceHighAltitude = vec3(noise.xy, noise.z * oceanOneOverAmplitudeHighAltitude);
// low altitude waves
time = czm_frameNumber * oceanAnimationSpeedLowAltitude;
noise = czm_getWaterNoise(u_oceanNormalMap, textureCoordinates * oceanFrequencyLowAltitude, time, 0.0);
vec3 normalTangentSpaceLowAltitude = vec3(noise.xy, noise.z * oceanOneOverAmplitudeLowAltitude);
// blend the 2 wave layers based on distance to surface
float highAltitudeFade = linearFade(0.0, 60000.0, positionToEyeECLength);
float lowAltitudeFade = 1.0 - linearFade(20000.0, 60000.0, positionToEyeECLength);
vec3 normalTangentSpace =
(highAltitudeFade * normalTangentSpaceHighAltitude) +
(lowAltitudeFade * normalTangentSpaceLowAltitude);
normalTangentSpace = normalize(normalTangentSpace);
// fade out the normal perturbation as we move farther from the water surface
normalTangentSpace.xy *= waveIntensity;
normalTangentSpace = normalize(normalTangentSpace);
#else
vec3 normalTangentSpace = vec3(0.0, 0.0, 1.0);
#endif
vec3 normalEC = enuToEye * normalTangentSpace;
const vec3 waveHighlightColor = vec3(0.3, 0.45, 0.6);
// Use diffuse light to highlight the waves
float diffuseIntensity = czm_getLambertDiffuse(czm_lightDirectionEC, normalEC) * maskValue;
vec3 diffuseHighlight = waveHighlightColor * diffuseIntensity * (1.0 - fade);
#ifdef SHOW_OCEAN_WAVES
// Where diffuse light is low or non-existent, use wave highlights based solely on
// the wave bumpiness and no particular light direction.
float tsPerturbationRatio = normalTangentSpace.z;
vec3 nonDiffuseHighlight = mix(waveHighlightColor * 5.0 * (1.0 - tsPerturbationRatio), vec3(0.0), diffuseIntensity);
#else
vec3 nonDiffuseHighlight = vec3(0.0);
#endif
// Add specular highlights in 3D, and in all modes when zoomed in.
float specularIntensity = czm_getSpecular(czm_lightDirectionEC, normalizedPositionToEyeEC, normalEC, 10.0);
float surfaceReflectance = mix(0.0, mix(u_zoomedOutOceanSpecularIntensity, oceanSpecularIntensity, waveIntensity), maskValue);
float specular = specularIntensity * surfaceReflectance;
#ifdef HDR
specular *= 1.4;
float e = 0.2;
float d = 3.3;
float c = 1.7;
vec3 color = imageryColor.rgb + (c * (vec3(e) + imageryColor.rgb * d) * (diffuseHighlight + nonDiffuseHighlight + specular));
#else
vec3 color = imageryColor.rgb + diffuseHighlight + nonDiffuseHighlight + specular;
#endif
return vec4(color, imageryColor.a);
}
#endif // #ifdef SHOW_REFLECTIVE_OCEAN
`;var XL=`#ifdef QUANTIZATION_BITS12
in vec4 compressed0;
in float compressed1;
#else
in vec4 position3DAndHeight;
in vec4 textureCoordAndEncodedNormals;
#endif
#ifdef GEODETIC_SURFACE_NORMALS
in vec3 geodeticSurfaceNormal;
#endif
#ifdef EXAGGERATION
uniform vec2 u_terrainExaggerationAndRelativeHeight;
#endif
uniform vec3 u_center3D;
uniform mat4 u_modifiedModelView;
uniform mat4 u_modifiedModelViewProjection;
uniform vec4 u_tileRectangle;
// Uniforms for 2D Mercator projection
uniform vec2 u_southAndNorthLatitude;
uniform vec2 u_southMercatorYAndOneOverHeight;
out vec3 v_positionMC;
out vec3 v_positionEC;
out vec3 v_textureCoordinates;
out vec3 v_normalMC;
out vec3 v_normalEC;
#ifdef APPLY_MATERIAL
out float v_slope;
out float v_aspect;
out float v_height;
#endif
#if defined(FOG) || defined(GROUND_ATMOSPHERE) || defined(UNDERGROUND_COLOR) || defined(TRANSLUCENT)
out float v_distance;
#endif
#if defined(FOG) || defined(GROUND_ATMOSPHERE)
out vec3 v_atmosphereRayleighColor;
out vec3 v_atmosphereMieColor;
out float v_atmosphereOpacity;
#endif
// These functions are generated at runtime.
vec4 getPosition(vec3 position, float height, vec2 textureCoordinates);
float get2DYPositionFraction(vec2 textureCoordinates);
vec4 getPosition3DMode(vec3 position, float height, vec2 textureCoordinates)
{
return u_modifiedModelViewProjection * vec4(position, 1.0);
}
float get2DMercatorYPositionFraction(vec2 textureCoordinates)
{
// The width of a tile at level 11, in radians and assuming a single root tile, is
// 2.0 * czm_pi / pow(2.0, 11.0)
// We want to just linearly interpolate the 2D position from the texture coordinates
// when we're at this level or higher. The constant below is the expression
// above evaluated and then rounded up at the 4th significant digit.
const float maxTileWidth = 0.003068;
float positionFraction = textureCoordinates.y;
float southLatitude = u_southAndNorthLatitude.x;
float northLatitude = u_southAndNorthLatitude.y;
if (northLatitude - southLatitude > maxTileWidth)
{
float southMercatorY = u_southMercatorYAndOneOverHeight.x;
float oneOverMercatorHeight = u_southMercatorYAndOneOverHeight.y;
float currentLatitude = mix(southLatitude, northLatitude, textureCoordinates.y);
currentLatitude = clamp(currentLatitude, -czm_webMercatorMaxLatitude, czm_webMercatorMaxLatitude);
positionFraction = czm_latitudeToWebMercatorFraction(currentLatitude, southMercatorY, oneOverMercatorHeight);
}
return positionFraction;
}
float get2DGeographicYPositionFraction(vec2 textureCoordinates)
{
return textureCoordinates.y;
}
vec4 getPositionPlanarEarth(vec3 position, float height, vec2 textureCoordinates)
{
float yPositionFraction = get2DYPositionFraction(textureCoordinates);
vec4 rtcPosition2D = vec4(height, mix(u_tileRectangle.st, u_tileRectangle.pq, vec2(textureCoordinates.x, yPositionFraction)), 1.0);
return u_modifiedModelViewProjection * rtcPosition2D;
}
vec4 getPosition2DMode(vec3 position, float height, vec2 textureCoordinates)
{
return getPositionPlanarEarth(position, 0.0, textureCoordinates);
}
vec4 getPositionColumbusViewMode(vec3 position, float height, vec2 textureCoordinates)
{
return getPositionPlanarEarth(position, height, textureCoordinates);
}
vec4 getPositionMorphingMode(vec3 position, float height, vec2 textureCoordinates)
{
// We do not do RTC while morphing, so there is potential for jitter.
// This is unlikely to be noticeable, though.
vec3 position3DWC = position + u_center3D;
float yPositionFraction = get2DYPositionFraction(textureCoordinates);
vec4 position2DWC = vec4(height, mix(u_tileRectangle.st, u_tileRectangle.pq, vec2(textureCoordinates.x, yPositionFraction)), 1.0);
vec4 morphPosition = czm_columbusViewMorph(position2DWC, vec4(position3DWC, 1.0), czm_morphTime);
return czm_modelViewProjection * morphPosition;
}
#ifdef QUANTIZATION_BITS12
uniform vec2 u_minMaxHeight;
uniform mat4 u_scaleAndBias;
#endif
void main()
{
#ifdef QUANTIZATION_BITS12
vec2 xy = czm_decompressTextureCoordinates(compressed0.x);
vec2 zh = czm_decompressTextureCoordinates(compressed0.y);
vec3 position = vec3(xy, zh.x);
float height = zh.y;
vec2 textureCoordinates = czm_decompressTextureCoordinates(compressed0.z);
height = height * (u_minMaxHeight.y - u_minMaxHeight.x) + u_minMaxHeight.x;
position = (u_scaleAndBias * vec4(position, 1.0)).xyz;
#if (defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL)) && defined(INCLUDE_WEB_MERCATOR_Y)
float webMercatorT = czm_decompressTextureCoordinates(compressed0.w).x;
float encodedNormal = compressed1;
#elif defined(INCLUDE_WEB_MERCATOR_Y)
float webMercatorT = czm_decompressTextureCoordinates(compressed0.w).x;
float encodedNormal = 0.0;
#elif defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL)
float webMercatorT = textureCoordinates.y;
float encodedNormal = compressed0.w;
#else
float webMercatorT = textureCoordinates.y;
float encodedNormal = 0.0;
#endif
#else
// A single float per element
vec3 position = position3DAndHeight.xyz;
float height = position3DAndHeight.w;
vec2 textureCoordinates = textureCoordAndEncodedNormals.xy;
#if (defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL) || defined(APPLY_MATERIAL)) && defined(INCLUDE_WEB_MERCATOR_Y)
float webMercatorT = textureCoordAndEncodedNormals.z;
float encodedNormal = textureCoordAndEncodedNormals.w;
#elif defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL) || defined(APPLY_MATERIAL)
float webMercatorT = textureCoordinates.y;
float encodedNormal = textureCoordAndEncodedNormals.z;
#elif defined(INCLUDE_WEB_MERCATOR_Y)
float webMercatorT = textureCoordAndEncodedNormals.z;
float encodedNormal = 0.0;
#else
float webMercatorT = textureCoordinates.y;
float encodedNormal = 0.0;
#endif
#endif
vec3 position3DWC = position + u_center3D;
#ifdef GEODETIC_SURFACE_NORMALS
vec3 ellipsoidNormal = geodeticSurfaceNormal;
#else
vec3 ellipsoidNormal = normalize(position3DWC);
#endif
#if defined(EXAGGERATION) && defined(GEODETIC_SURFACE_NORMALS)
float exaggeration = u_terrainExaggerationAndRelativeHeight.x;
float relativeHeight = u_terrainExaggerationAndRelativeHeight.y;
float newHeight = (height - relativeHeight) * exaggeration + relativeHeight;
// stop from going through center of earth
float minRadius = min(min(czm_ellipsoidRadii.x, czm_ellipsoidRadii.y), czm_ellipsoidRadii.z);
newHeight = max(newHeight, -minRadius);
vec3 offset = ellipsoidNormal * (newHeight - height);
position += offset;
position3DWC += offset;
height = newHeight;
#endif
gl_Position = getPosition(position, height, textureCoordinates);
v_positionEC = (u_modifiedModelView * vec4(position, 1.0)).xyz;
v_positionMC = position3DWC; // position in model coordinates
v_textureCoordinates = vec3(textureCoordinates, webMercatorT);
#if defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL) || defined(APPLY_MATERIAL)
vec3 normalMC = czm_octDecode(encodedNormal);
#if defined(EXAGGERATION) && defined(GEODETIC_SURFACE_NORMALS)
vec3 projection = dot(normalMC, ellipsoidNormal) * ellipsoidNormal;
vec3 rejection = normalMC - projection;
normalMC = normalize(projection + rejection * exaggeration);
#endif
v_normalMC = normalMC;
v_normalEC = czm_normal3D * v_normalMC;
#endif
#if defined(FOG) || (defined(GROUND_ATMOSPHERE) && !defined(PER_FRAGMENT_GROUND_ATMOSPHERE))
bool dynamicLighting = false;
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING))
dynamicLighting = true;
#endif
#if defined(DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN)
vec3 atmosphereLightDirection = czm_sunDirectionWC;
#else
vec3 atmosphereLightDirection = czm_lightDirectionWC;
#endif
vec3 lightDirection = czm_branchFreeTernary(dynamicLighting, atmosphereLightDirection, normalize(position3DWC));
computeAtmosphereScattering(
position3DWC,
lightDirection,
v_atmosphereRayleighColor,
v_atmosphereMieColor,
v_atmosphereOpacity
);
#endif
#if defined(FOG) || defined(GROUND_ATMOSPHERE) || defined(UNDERGROUND_COLOR) || defined(TRANSLUCENT)
v_distance = length((czm_modelView3D * vec4(position3DWC, 1.0)).xyz);
#endif
#ifdef APPLY_MATERIAL
float northPoleZ = czm_ellipsoidRadii.z;
vec3 northPolePositionMC = vec3(0.0, 0.0, northPoleZ);
vec3 vectorEastMC = normalize(cross(northPolePositionMC - v_positionMC, ellipsoidNormal));
float dotProd = abs(dot(ellipsoidNormal, v_normalMC));
v_slope = acos(dotProd);
vec3 normalRejected = ellipsoidNormal * dotProd;
vec3 normalProjected = v_normalMC - normalRejected;
vec3 aspectVector = normalize(normalProjected);
v_aspect = acos(dot(aspectVector, vectorEastMC));
float determ = dot(cross(vectorEastMC, aspectVector), ellipsoidNormal);
v_aspect = czm_branchFreeTernary(determ < 0.0, 2.0 * czm_pi - v_aspect, v_aspect);
v_height = height;
#endif
}
`;var O_=`uniform vec3 u_radiiAndDynamicAtmosphereColor;
uniform float u_atmosphereLightIntensity;
uniform float u_atmosphereRayleighScaleHeight;
uniform float u_atmosphereMieScaleHeight;
uniform float u_atmosphereMieAnisotropy;
uniform vec3 u_atmosphereRayleighCoefficient;
uniform vec3 u_atmosphereMieCoefficient;
const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in meters.
const int PRIMARY_STEPS = 16; // Number of times the ray from the camera to the world position (primary ray) is sampled.
const int LIGHT_STEPS = 4; // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
/**
* This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as
* the transmittance value for the ray.
*
* @param {czm_ray} primaryRay The ray from the camera to the position.
* @param {float} primaryRayLength The length of the primary ray.
* @param {vec3} lightDirection The direction of the light to calculate the scattering from.
* @param {vec3} rayleighColor The variable the Rayleigh scattering will be written to.
* @param {vec3} mieColor The variable the Mie scattering will be written to.
* @param {float} opacity The variable the transmittance will be written to.
* @glslFunction
*/
void computeScattering(
czm_ray primaryRay,
float primaryRayLength,
vec3 lightDirection,
float atmosphereInnerRadius,
out vec3 rayleighColor,
out vec3 mieColor,
out float opacity
) {
// Initialize the default scattering amounts to 0.
rayleighColor = vec3(0.0);
mieColor = vec3(0.0);
opacity = 0.0;
float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE_THICKNESS;
vec3 origin = vec3(0.0);
// Calculate intersection from the camera to the outer ring of the atmosphere.
czm_raySegment primaryRayAtmosphereIntersect = czm_raySphereIntersectionInterval(primaryRay, origin, atmosphereOuterRadius);
// Return empty colors if no intersection with the atmosphere geometry.
if (primaryRayAtmosphereIntersect == czm_emptyRaySegment) {
return;
}
// The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);
// The ray should end at the exit from the atmosphere or at the distance to the vertex, whichever is smaller.
primaryRayAtmosphereIntersect.stop = min(primaryRayAtmosphereIntersect.stop, length(primaryRayLength));
// Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.
float rayStepLength = (primaryRayAtmosphereIntersect.stop - primaryRayAtmosphereIntersect.start) / float(PRIMARY_STEPS);
float rayPositionLength = primaryRayAtmosphereIntersect.start;
vec3 rayleighAccumulation = vec3(0.0);
vec3 mieAccumulation = vec3(0.0);
vec2 opticalDepth = vec2(0.0);
vec2 heightScale = vec2(u_atmosphereRayleighScaleHeight, u_atmosphereMieScaleHeight);
// Sample positions on the primary ray.
for (int i = 0; i < PRIMARY_STEPS; i++) {
// Calculate sample position along viewpoint ray.
vec3 samplePosition = primaryRay.origin + primaryRay.direction * (rayPositionLength + rayStepLength);
// Calculate height of sample position above ellipsoid.
float sampleHeight = length(samplePosition) - atmosphereInnerRadius;
// Calculate and accumulate density of particles at the sample position.
vec2 sampleDensity = exp(-sampleHeight / heightScale) * rayStepLength;
opticalDepth += sampleDensity;
// Generate ray from the sample position segment to the light source, up to the outer ring of the atmosphere.
czm_ray lightRay = czm_ray(samplePosition, lightDirection);
czm_raySegment lightRayAtmosphereIntersect = czm_raySphereIntersectionInterval(lightRay, origin, atmosphereOuterRadius);
float lightStepLength = lightRayAtmosphereIntersect.stop / float(LIGHT_STEPS);
float lightPositionLength = 0.0;
vec2 lightOpticalDepth = vec2(0.0);
// Sample positions along the light ray, to accumulate incidence of light on the latest sample segment.
for (int j = 0; j < LIGHT_STEPS; j++) {
// Calculate sample position along light ray.
vec3 lightPosition = samplePosition + lightDirection * (lightPositionLength + lightStepLength * 0.5);
// Calculate height of the light sample position above ellipsoid.
float lightHeight = length(lightPosition) - atmosphereInnerRadius;
// Calculate density of photons at the light sample position.
lightOpticalDepth += exp(-lightHeight / heightScale) * lightStepLength;
// Increment distance on light ray.
lightPositionLength += lightStepLength;
}
// Compute attenuation via the primary ray and the light ray.
vec3 attenuation = exp(-((u_atmosphereMieCoefficient * (opticalDepth.y + lightOpticalDepth.y)) + (u_atmosphereRayleighCoefficient * (opticalDepth.x + lightOpticalDepth.x))));
// Accumulate the scattering.
rayleighAccumulation += sampleDensity.x * attenuation;
mieAccumulation += sampleDensity.y * attenuation;
// Increment distance on primary ray.
rayPositionLength += rayStepLength;
}
// Compute the scattering amount.
rayleighColor = u_atmosphereRayleighCoefficient * rayleighAccumulation;
mieColor = u_atmosphereMieCoefficient * mieAccumulation;
// Compute the transmittance i.e. how much light is passing through the atmosphere.
opacity = length(exp(-((u_atmosphereMieCoefficient * opticalDepth.y) + (u_atmosphereRayleighCoefficient * opticalDepth.x))));
}
vec4 computeAtmosphereColor(
vec3 positionWC,
vec3 lightDirection,
vec3 rayleighColor,
vec3 mieColor,
float opacity
) {
// Setup the primary ray: from the camera position to the vertex position.
vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
float cosAngle = dot(cameraToPositionWCDirection, lightDirection);
float cosAngleSq = cosAngle * cosAngle;
float G = u_atmosphereMieAnisotropy;
float GSq = G * G;
// The Rayleigh phase function.
float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);
// The Mie phase function.
float miePhase = 3.0 / (25.1327412287) * ((1.0 - GSq) * (cosAngleSq + 1.0)) / (pow(1.0 + GSq - 2.0 * cosAngle * G, 1.5) * (2.0 + GSq));
// The final color is generated by combining the effects of the Rayleigh and Mie scattering.
vec3 rayleigh = rayleighPhase * rayleighColor;
vec3 mie = miePhase * mieColor;
vec3 color = (rayleigh + mie) * u_atmosphereLightIntensity;
return vec4(color, opacity);
}
`;var rS=`void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity) {
vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);
float atmosphereInnerRadius = length(positionWC);
computeScattering(
primaryRay,
length(cameraToPositionWC),
lightDirection,
atmosphereInnerRadius,
rayleighColor,
mieColor,
opacity
);
}
`;var ust=new H;function fst(e,t){let n=e.unionClippingRegions,i=e.length,o=ss.useFloatTexture(t),r=ss.getTextureResolution(e,t,ust),s=r.x,a=r.y,c=o?hst(s,a):pst(s,a);return c+=`
`,c+=n?dst(i):mst(i),c}function dst(e){return`float clip(vec4 fragCoord, sampler2D clippingPlanes, mat4 clippingPlanesMatrix)
{
vec4 position = czm_windowToEyeCoordinates(fragCoord);
vec3 clipNormal = vec3(0.0);
vec3 clipPosition = vec3(0.0);
float clipAmount;
float pixelWidth = czm_metersPerPixel(position);
bool breakAndDiscard = false;
for (int i = 0; i < ${e}; ++i)
{
vec4 clippingPlane = getClippingPlane(clippingPlanes, i, clippingPlanesMatrix);
clipNormal = clippingPlane.xyz;
clipPosition = -clippingPlane.w * clipNormal;
float amount = dot(clipNormal, (position.xyz - clipPosition)) / pixelWidth;
clipAmount = czm_branchFreeTernary(i == 0, amount, min(amount, clipAmount));
if (amount <= 0.0)
{
breakAndDiscard = true;
break;
}
}
if (breakAndDiscard) {
discard;
}
return clipAmount;
}
`}function mst(e){return`float clip(vec4 fragCoord, sampler2D clippingPlanes, mat4 clippingPlanesMatrix)
{
bool clipped = true;
vec4 position = czm_windowToEyeCoordinates(fragCoord);
vec3 clipNormal = vec3(0.0);
vec3 clipPosition = vec3(0.0);
float clipAmount = 0.0;
float pixelWidth = czm_metersPerPixel(position);
for (int i = 0; i < ${e}; ++i)
{
vec4 clippingPlane = getClippingPlane(clippingPlanes, i, clippingPlanesMatrix);
clipNormal = clippingPlane.xyz;
clipPosition = -clippingPlane.w * clipNormal;
float amount = dot(clipNormal, (position.xyz - clipPosition)) / pixelWidth;
clipAmount = max(amount, clipAmount);
clipped = clipped && (amount <= 0.0);
}
if (clipped)
{
discard;
}
return clipAmount;
}
`}function hst(e,t){let n=1/e,i=1/t,o=`${n}`;o.indexOf(".")===-1&&(o+=".0");let r=`${i}`;return r.indexOf(".")===-1&&(r+=".0"),`vec4 getClippingPlane(highp sampler2D packedClippingPlanes, int clippingPlaneNumber, mat4 transform)
{
int pixY = clippingPlaneNumber / ${e};
int pixX = clippingPlaneNumber - (pixY * ${e});
float u = (float(pixX) + 0.5) * ${o};
float v = (float(pixY) + 0.5) * ${r};
vec4 plane = texture(packedClippingPlanes, vec2(u, v));
return czm_transformPlane(plane, transform);
}
`}function pst(e,t){let n=1/e,i=1/t,o=`${n}`;o.indexOf(".")===-1&&(o+=".0");let r=`${i}`;return r.indexOf(".")===-1&&(r+=".0"),`vec4 getClippingPlane(highp sampler2D packedClippingPlanes, int clippingPlaneNumber, mat4 transform)
{
int clippingPlaneStartIndex = clippingPlaneNumber * 2;
int pixY = clippingPlaneStartIndex / ${e};
int pixX = clippingPlaneStartIndex - (pixY * ${e});
float u = (float(pixX) + 0.5) * ${o};
float v = (float(pixY) + 0.5) * ${r};
vec4 oct32 = texture(packedClippingPlanes, vec2(u, v)) * 255.0;
vec2 oct = vec2(oct32.x * 256.0 + oct32.y, oct32.z * 256.0 + oct32.w);
vec4 plane;
plane.xyz = czm_octDecode(oct, 65535.0);
plane.w = czm_unpackFloat(texture(packedClippingPlanes, vec2(u + ${o}, v)));
return czm_transformPlane(plane, transform);
}
`}var M_=fst;function _st(e,t,n,i,o){this.numberOfDayTextures=e,this.flags=t,this.material=n,this.shaderProgram=i,this.clippingShaderState=o}function oq(){this.baseVertexShaderSource=void 0,this.baseFragmentShaderSource=void 0,this._shadersByTexturesFlags=[],this.material=void 0}function gst(e){let t="vec4 getPosition(vec3 position, float height, vec2 textureCoordinates) { return getPosition3DMode(position, height, textureCoordinates); }",n="vec4 getPosition(vec3 position, float height, vec2 textureCoordinates) { return getPositionColumbusViewMode(position, height, textureCoordinates); }",i="vec4 getPosition(vec3 position, float height, vec2 textureCoordinates) { return getPositionMorphingMode(position, height, textureCoordinates); }",o;switch(e){case ne.SCENE3D:o=t;break;case ne.SCENE2D:case ne.COLUMBUS_VIEW:o=n;break;case ne.MORPHING:o=i;break}return o}function yst(e){return e?"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DMercatorYPositionFraction(textureCoordinates); }":"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DGeographicYPositionFraction(textureCoordinates); }"}oq.prototype.getShaderProgram=function(e){let t=e.frameState,n=e.surfaceTile,i=e.numberOfDayTextures,o=e.applyBrightness,r=e.applyContrast,s=e.applyHue,a=e.applySaturation,c=e.applyGamma,l=e.applyAlpha,f=e.applyDayNightAlpha,d=e.applySplit,p=e.showReflectiveOcean,g=e.showOceanWaves,h=e.enableLighting,A=e.dynamicAtmosphereLighting,x=e.dynamicAtmosphereLightingFromSun,C=e.showGroundAtmosphere,T=e.perFragmentGroundAtmosphere,E=e.hasVertexNormals,S=e.useWebMercatorProjection,w=e.enableFog,D=e.enableClippingPlanes,M=e.clippingPlanes,O=e.clippedByBoundaries,L=e.hasImageryLayerCutout,N=e.colorCorrect,_=e.highlightFillTile,b=e.colorToAlpha,v=e.hasGeodeticSurfaceNormals,I=e.hasExaggeration,R=e.showUndergroundColor,F=e.translucent,z=0,V="",U=n.renderedMesh.encoding;U.quantization===Bs.BITS12&&(z=1,V="QUANTIZATION_BITS12");let Y=0,Q="";O&&(Y=1,Q="TILE_LIMIT_RECTANGLE");let W=0,K="";L&&(W=1,K="APPLY_IMAGERY_CUTOUT");let J=t.mode,ge=J|o<<2|r<<3|s<<4|a<<5|c<<6|l<<7|p<<8|g<<9|h<<10|A<<11|x<<12|C<<13|T<<14|E<<15|S<<16|w<<17|z<<18|d<<19|D<<20|Y<<21|W<<22|N<<23|_<<24|b<<25|v<<26|I<<27|R<<28|F<<29|f<<30,Ce=0;u(M)&&M.length>0&&(Ce=D?M.clippingPlanesState:0);let se=n.surfaceShader;if(u(se)&&se.numberOfDayTextures===i&&se.flags===ge&&se.material===this.material&&se.clippingShaderState===Ce)return se.shaderProgram;let xe=this._shadersByTexturesFlags[i];if(u(xe)||(xe=this._shadersByTexturesFlags[i]=[]),se=xe[ge],!u(se)||se.material!==this.material||se.clippingShaderState!==Ce){let me=this.baseVertexShaderSource.clone(),ve=this.baseFragmentShaderSource.clone();Ce!==0&&ve.sources.unshift(M_(M,t.context)),me.defines.push(V),ve.defines.push(`TEXTURE_UNITS ${i}`,Q,K),o&&ve.defines.push("APPLY_BRIGHTNESS"),r&&ve.defines.push("APPLY_CONTRAST"),s&&ve.defines.push("APPLY_HUE"),a&&ve.defines.push("APPLY_SATURATION"),c&&ve.defines.push("APPLY_GAMMA"),l&&ve.defines.push("APPLY_ALPHA"),f&&ve.defines.push("APPLY_DAY_NIGHT_ALPHA"),p&&(ve.defines.push("SHOW_REFLECTIVE_OCEAN"),me.defines.push("SHOW_REFLECTIVE_OCEAN")),g&&ve.defines.push("SHOW_OCEAN_WAVES"),b&&ve.defines.push("APPLY_COLOR_TO_ALPHA"),R&&(me.defines.push("UNDERGROUND_COLOR"),ve.defines.push("UNDERGROUND_COLOR")),F&&(me.defines.push("TRANSLUCENT"),ve.defines.push("TRANSLUCENT")),h&&(E?(me.defines.push("ENABLE_VERTEX_LIGHTING"),ve.defines.push("ENABLE_VERTEX_LIGHTING")):(me.defines.push("ENABLE_DAYNIGHT_SHADING"),ve.defines.push("ENABLE_DAYNIGHT_SHADING"))),A&&(me.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),ve.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),x&&(me.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"),ve.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"))),C&&(me.defines.push("GROUND_ATMOSPHERE"),ve.defines.push("GROUND_ATMOSPHERE"),T&&(me.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE"),ve.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE"))),me.defines.push("INCLUDE_WEB_MERCATOR_Y"),ve.defines.push("INCLUDE_WEB_MERCATOR_Y"),w&&(me.defines.push("FOG"),ve.defines.push("FOG")),d&&ve.
{
vec4 color = initialColor;
`;L&&(Pe+=` vec4 cutoutAndColorResult;
bool texelUnclipped;
`);for(let Xe=0;Xe<i;++Xe)L?Pe+=` cutoutAndColorResult = u_dayTextureCutoutRectangles[${Xe}];
texelUnclipped = v_textureCoordinates.x < cutoutAndColorResult.x || cutoutAndColorResult.z < v_textureCoordinates.x || v_textureCoordinates.y < cutoutAndColorResult.y || cutoutAndColorResult.w < v_textureCoordinates.y;
cutoutAndColorResult = sampleAndBlend(
`:Pe+=` color = sampleAndBlend(
`,Pe+=` color,
u_dayTextures[${Xe}],
u_dayTextureUseWebMercatorT[${Xe}] ? textureCoordinates.xz : textureCoordinates.xy,
u_dayTextureTexCoordsRectangle[${Xe}],
u_dayTextureTranslationAndScale[${Xe}],
${l?`u_dayTextureAlpha[${Xe}]`:"1.0"},
${f?`u_dayTextureNightAlpha[${Xe}]`:"1.0"},
${f?`u_dayTextureDayAlpha[${Xe}]`:"1.0"},
${o?`u_dayTextureBrightness[${Xe}]`:"0.0"},
${r?`u_dayTextureContrast[${Xe}]`:"0.0"},
${s?`u_dayTextureHue[${Xe}]`:"0.0"},
${a?`u_dayTextureSaturation[${Xe}]`:"0.0"},
${c?`u_dayTextureOneOverGamma[${Xe}]`:"0.0"},
${d?`u_dayTextureSplit[${Xe}]`:"0.0"},
${b?`u_colorsToAlpha[${Xe}]`:"vec4(0.0)"},
nightBlend );
`,L&&(Pe+=` color = czm_branchFreeTernary(texelUnclipped, cutoutAndColorResult, color);
`);Pe+=` return color;
}`,ve.sources.push(Pe),me.sources.push(gst(J)),me.sources.push(yst(S));let Ve=Jt.fromCache({context:t.context,vertexShaderSource:me,fragmentShaderSource:ve,attributeLocations:U.getAttributeLocations()});se=xe[ge]=new _st(i,ge,this.material,Ve,Ce)}return n.surfaceShader=se,se.shaderProgram};oq.prototype.destroy=function(){let e,t,n=this._shadersByTexturesFlags;for(let i in n)if(n.hasOwnProperty(i)){let o=n[i];if(!u(o))continue;for(e in o)o.hasOwnProperty(e)&&(t=o[e],u(t)&&t.shaderProgram.destroy())}return ue(this)};var KL=oq;var Ast={UNLOADED:0,TRANSITIONING:1,RECEIVED:2,TEXTURE_LOADED:3,READY:4,FAILED:5,INVALID:6,PLACEHOLDER:7},di=Object.freeze(Ast);var xst={START:0,LOADING:1,DONE:2,FAILED:3},Ns=Object.freeze(xst);var Cst={FAILED:0,UNLOADED:1,RECEIVING:2,RECEIVED:3,TRANSFORMING:4,TRANSFORMED:5,READY:6},go=Object.freeze(Cst);function nr(){this.imagery=[],this.waterMaskTexture=void 0,this.waterMaskTranslationAndScale=new re(0,0,1,1),this.terrainData=void 0,this.vertexArray=void 0,this.tileBoundingRegion=void 0,this.occludeePointInScaledSpace=new m,this.boundingVolumeSourceTile=void 0,this.boundingVolumeIsFromMesh=!1,this.terrainState=go.UNLOADED,this.mesh=void 0,this.fill=void 0,this.pickBoundingSphere=new ae,this.surfaceShader=void 0,this.isClipped=!0,this.clippedByBoundaries=!1}Object.defineProperties(nr.prototype,{eligibleForUnloading:{get:function(){let e=this.terrainState,n=!(e===go.RECEIVING||e===go.TRANSFORMING),i=this.imagery;for(let o=0,r=i.length;n&&o<r;++o){let s=i[o];n=!u(s.loadingImagery)||s.loadingImagery.state!==di.TRANSITIONING}return n}},renderedMesh:{get:function(){if(u(this.vertexArray))return this.mesh;if(u(this.fill))return this.fill.mesh}}});var Tst=new he;function rq(e,t,n,i,o,r){let s=e.getExaggeratedPosition(i,o,r);if(u(t)&&t!==ne.SCENE3D){let c=n.ellipsoid.cartesianToCartographic(s,Tst);s=n.project(c,r),s=m.fromElements(s.z,s.x,s.y,r)}return s}var Est=new m,bst=new m,Sst=new m;nr.prototype.pick=function(e,t,n,i,o){let r=this.renderedMesh;if(!u(r))return;let s=r.vertices,a=r.indices,c=r.encoding,l=a.length,f=Number.MAX_VALUE;for(let d=0;d<l;d+=3){let p=a[d],g=a[d+1],h=a[d+2],A=rq(c,t,n,s,p,Est),x=rq(c,t,n,s,g,bst),C=rq(c,t,n,s,h,Sst),T=Xi.rayTriangleParametric(e,A,x,C,i);u(T)&&T<f&&T>=0&&(f=T)}return f!==Number.MAX_VALUE?Dn.getPoint(e,f,o):void 0};nr.prototype.freeResources=function(){u(this.waterMaskTexture)&&(--this.waterMaskTexture.referenceCount,this.waterMaskTexture.referenceCount===0&&this.waterMaskTexture.destroy(),this.waterMaskTexture=void 0),this.terrainData=void 0,this.terrainState=go.UNLOADED,this.mesh=void 0,this.fill=this.fill&&this.fill.destroy();let e=this.imagery;for(let t=0,n=e.length;t<n;++t)e[t].freeResources();this.imagery.length=0,this.freeVertexArray()};nr.prototype.freeVertexArray=function(){nr._freeVertexArray(this.vertexArray),this.vertexArray=void 0,nr._freeVertexArray(this.wireframeVertexArray),this.wireframeVertexArray=void 0};nr.initialize=function(e,t,n){let i=e.data;u(i)||(i=e.data=new nr),e.state===Ns.START&&(vst(e,t,n),e.state=Ns.LOADING)};nr.processStateMachine=function(e,t,n,i,o,r,s){nr.initialize(e,n,i);let a=e.data;if(e.state===Ns.LOADING&&wst(e,t,n,i,o,r),s)return;let c=e.renderable;e.renderable=u(a.vertexArray);let l=a.terrainState===go.READY;e.upsampledFromParent=u(a.terrainData)&&a.terrainData.wasCreatedByUpsampling();let f=a.processImagery(e,n,t);if(l&&f){let d=e._loadedCallbacks,p={};for(let g in d)d.hasOwnProperty(g)&&(d[g](e)||(p[g]=d[g]));e._loadedCallbacks=p,e.state=Ns.DONE}c&&(e.renderable=!0)};nr.prototype.processImagery=function(e,t,n,i){let o=e.data,r=e.upsampledFromParent,s=!1,a=!0,c=o.imagery,l,f;for(l=0,f=c.length;l<f;++l){let d=c[l];if(!u(d.loadingImagery)){r=!1;continue}if(d.loadingImagery.state===di.PLACEHOLDER){let g=d.loadingImagery.imageryLayer;if(g.ready&&g.imageryProvider._ready){d.freeResources(),c.splice(l,1),g._createTileImagerySkeletons(e,t,l),--l,f=c.length;continue}else r=!1}let p=d.processStateMachine(e,n,i);a=a&&p,s=s||p||u(d.readyImagery),r=r&&u(d.loadingImagery)&&(d.loadingImagery.state===di.FAILED||d.loadingImagery.state
in vec2 v_textureCoordinates;
void main()
{
out_FragColor = texture(u_texture, v_textureCoordinates);
}
`;var eN=`in vec4 position;
in float webMercatorT;
uniform vec2 u_textureDimensions;
out vec2 v_textureCoordinates;
void main()
{
v_textureCoordinates = vec2(position.x, webMercatorT);
gl_Position = czm_viewportOrthographic * (position * vec4(u_textureDimensions, 1.0, 1.0));
}
`;function pS(e,t,n,i,o){if(this.imageryLayer=e,this.x=t,this.y=n,this.level=i,this.request=void 0,i!==0){let r=t/2|0,s=n/2|0,a=i-1;this.parent=e.getImageryFromCache(r,s,a)}this.state=di.UNLOADED,this.imageUrl=void 0,this.image=void 0,this.texture=void 0,this.textureWebMercator=void 0,this.credits=void 0,this.referenceCount=0,!u(o)&&e.ready&&e.imageryProvider._ready&&(o=e.imageryProvider.tilingScheme.tileXYToRectangle(t,n,i)),this.rectangle=o}pS.createPlaceholder=function(e){let t=new pS(e,0,0,0);return t.addReference(),t.state=di.PLACEHOLDER,t};pS.prototype.addReference=function(){++this.referenceCount};pS.prototype.releaseReference=function(){return--this.referenceCount,this.referenceCount===0?(this.imageryLayer.removeImageryFromCache(this),u(this.parent)&&this.parent.releaseReference(),u(this.image)&&u(this.image.destroy)&&this.image.destroy(),u(this.texture)&&this.texture.destroy(),u(this.textureWebMercator)&&this.texture!==this.textureWebMercator&&this.textureWebMercator.destroy(),ue(this),0):this.referenceCount};pS.prototype.processStateMachine=function(e,t,n){this.state===di.UNLOADED&&!n&&(this.state=di.TRANSITIONING,this.imageryLayer._requestImagery(this)),this.state===di.RECEIVED&&(this.state=di.TRANSITIONING,this.imageryLayer._createTexture(e.context,this));let i=this.state===di.READY&&t&&!this.texture;(this.state===di.TEXTURE_LOADED||i)&&(this.state=di.TRANSITIONING,this.imageryLayer._reprojectTexture(e,this,t))};var _S=pS;function fq(e,t,n){this.readyImagery=void 0,this.loadingImagery=e,this.textureCoordinateRectangle=t,this.textureTranslationAndScale=void 0,this.useWebMercatorT=n}fq.prototype.freeResources=function(){u(this.readyImagery)&&this.readyImagery.releaseReference(),u(this.loadingImagery)&&this.loadingImagery.releaseReference()};fq.prototype.processStateMachine=function(e,t,n){let i=this.loadingImagery,o=i.imageryLayer;if(i.processStateMachine(t,!this.useWebMercatorT,n),i.state===di.READY)return u(this.readyImagery)&&this.readyImagery.releaseReference(),this.readyImagery=this.loadingImagery,this.loadingImagery=void 0,this.textureTranslationAndScale=o._calculateTextureTranslationAndScale(e,this),!0;let r=i.parent,s;for(;u(r)&&(r.state!==di.READY||!this.useWebMercatorT&&!u(r.texture));)r.state!==di.FAILED&&r.state!==di.INVALID&&(s=s||r),r=r.parent;return this.readyImagery!==r&&(u(this.readyImagery)&&this.readyImagery.releaseReference(),this.readyImagery=r,u(r)&&(r.addReference(),this.textureTranslationAndScale=o._calculateTextureTranslationAndScale(e,this))),i.state===di.FAILED||i.state===di.INVALID?u(s)?(s.processStateMachine(t,!this.useWebMercatorT,n),!1):!0:!1};var gS=fq;function hi(e,t){this._imageryProvider=e,this._readyEvent=new ye,this._errorEvent=new ye,t=y(t,y.EMPTY_OBJECT),e=y(e,y.EMPTY_OBJECT),this.alpha=y(t.alpha,y(e._defaultAlpha,1)),this.nightAlpha=y(t.nightAlpha,y(e._defaultNightAlpha,1)),this.dayAlpha=y(t.dayAlpha,y(e._defaultDayAlpha,1)),this.brightness=y(t.brightness,y(e._defaultBrightness,hi.DEFAULT_BRIGHTNESS)),this.contrast=y(t.contrast,y(e._defaultContrast,hi.DEFAULT_CONTRAST)),this.hue=y(t.hue,y(e._defaultHue,hi.DEFAULT_HUE)),this.saturation=y(t.saturation,y(e._defaultSaturation,hi.DEFAULT_SATURATION)),this.gamma=y(t.gamma,y(e._defaultGamma,hi.DEFAULT_GAMMA)),this.splitDirection=y(t.splitDirection,hi.DEFAULT_SPLIT),this.minificationFilter=y(t.minificationFilter,y(e._defaultMinificationFilter,hi.DEFAULT_MINIFICATION_FILTER)),this.magnificationFilter=y(t.magnificationFilter,y(e._defaultMagnificationFilter,hi.DEFAULT_MAGNIFICATION_FILTER)),this.show=y(t.show,!0),this._minimumTerrainLevel=t.minimumTerrainLevel,this._maximumTerrainLevel=t.maximumTerrainLevel,this._rectangle=y(t.rectangle,le.MAX_VALUE),this._maximumAnisotropy=t.maximumAnisotropy,this._imageryCache={},this._skeletonPlaceholder=new gS(_S.createPlaceholder(this)),this._show=!0,this._layerIndex=-1,this._isBaseLayer=!1,this._requestImageError=void 0,this._reprojectComputeCommands=[],this.cutoutRectangle=t.cutoutRectangle,this.colorToAlpha=t.colorToAlpha,this.colorToAlphaThreshold=y(t.colorToAlphaThreshold,hi.DEFAULT_APPLY
in vec2 v_textureCoordinates;
void main()
{
out_FragColor = texture(colorTexture, v_textureCoordinates);
}
`;var Jy=`uniform highp sampler2D u_depthTexture;
in vec2 v_textureCoordinates;
void main()
{
out_FragColor = czm_packDepth(texture(u_depthTexture, v_textureCoordinates).r);
}
`;function Sh(){this._picking=!1,this._numSamples=1,this._tempCopyDepthTexture=void 0,this._pickColorFramebuffer=new mi({depthStencil:!0,supportsDepthTexture:!0}),this._outputFramebuffer=new mi({depthStencil:!0,supportsDepthTexture:!0}),this._copyDepthFramebuffer=new mi,this._tempCopyDepthFramebuffer=new mi,this._updateDepthFramebuffer=new mi({createColorAttachments:!1,createDepthAttachments:!1,depthStencil:!0}),this._clearGlobeColorCommand=void 0,this._copyColorCommand=void 0,this._copyDepthCommand=void 0,this._tempCopyDepthCommand=void 0,this._updateDepthCommand=void 0,this._viewport=new qe,this._rs=void 0,this._rsBlend=void 0,this._rsUpdate=void 0,this._useScissorTest=!1,this._scissorRectangle=void 0,this._useHdr=void 0,this._clearGlobeDepth=void 0}Object.defineProperties(Sh.prototype,{colorFramebufferManager:{get:function(){return this._picking?this._pickColorFramebuffer:this._outputFramebuffer}},framebuffer:{get:function(){return this.colorFramebufferManager.framebuffer}},depthStencilTexture:{get:function(){return this.colorFramebufferManager.getDepthStencilTexture()}},picking:{get:function(){return this._picking},set:function(e){this._picking=e}}});function Vct(e){e._pickColorFramebuffer.destroy(),e._outputFramebuffer.destroy(),e._copyDepthFramebuffer.destroy(),e._tempCopyDepthFramebuffer.destroy(),e._updateDepthFramebuffer.destroy()}function mye(e,t,n,i,o){e._viewport.width=n,e._viewport.height=i;let r=!qe.equals(e._viewport,o.viewport),s=r!==e._useScissorTest;e._useScissorTest=r,qe.equals(e._scissorRectangle,o.viewport)||(e._scissorRectangle=qe.clone(o.viewport,e._scissorRectangle),s=!0),(!u(e._rs)||!qe.equals(e._viewport,e._rs.viewport)||s)&&(e._rs=ke.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}}),e._rsBlend=ke.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},blending:un.ALPHA_BLEND}),e._rsUpdate=ke.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:zn.EQUAL,frontOperation:{fail:ft.KEEP,zFail:ft.KEEP,zPass:ft.KEEP},backFunction:zn.NEVER,reference:Lt.CESIUM_3D_TILE_MASK,mask:Lt.CESIUM_3D_TILE_MASK}})),u(e._copyDepthCommand)||(e._copyDepthCommand=t.createViewportQuadCommand(Jy,{uniformMap:{u_depthTexture:function(){return e.colorFramebufferManager.getDepthStencilTexture()}},owner:e})),e._copyDepthCommand.framebuffer=e._copyDepthFramebuffer.framebuffer,e._copyDepthCommand.renderState=e._rs,u(e._copyColorCommand)||(e._copyColorCommand=t.createViewportQuadCommand(kl,{uniformMap:{colorTexture:function(){return e.colorFramebufferManager.getColorTexture()}},owner:e})),e._copyColorCommand.renderState=e._rs,u(e._tempCopyDepthCommand)||(e._tempCopyDepthCommand=t.createViewportQuadCommand(Jy,{uniformMap:{u_depthTexture:function(){return e._tempCopyDepthTexture}},owner:e})),e._tempCopyDepthCommand.framebuffer=e._tempCopyDepthFramebuffer.framebuffer,e._tempCopyDepthCommand.renderState=e._rs,u(e._updateDepthCommand)||(e._updateDepthCommand=t.createViewportQuadCommand(kl,{uniformMap:{colorTexture:function(){return e._tempCopyDepthFramebuffer.getColorTexture()}},owner:e})),e._updateDepthCommand.framebuffer=e._updateDepthFramebuffer.framebuffer,e._updateDepthCommand.renderState=e._rsUpdate,u(e._clearGlobeColorCommand)||(e._clearGlobeColorCommand=new li({color:new k(0,0,0,0),stencil:0,owner:e})),e._clearGlobeColorCommand.framebuffer=e.framebuffer}Sh.prototype.update=function(e,t,n,i,o,r){let s=n.width,a=n.height,c=o?e.halfFloatingPointTexture?Ke.HALF_FLOAT:Ke.FLOAT:Ke.UNSIGNED_BYTE;this._numSamples=i,this.picking?this._pickColorFramebuffer.update(e,s,a):this._outputFramebuffer.update(e,s,a,i,c),this._copyDepthFramebuffer.update(e,s,a),mye(this,e,s,a,t),e.uniformState.globeDepthTexture=void 0,this._useHdr=o,this._clearGlobeDepth=r};Sh.prototype.prepareColorTextures=function(e,t){!this.picking&&this._numSamples>1&&this._outputFramebuffer.prepareTextures(e,t)};Sh.prototype.executeCopyDepth=function(e,t){u(this._copyDepthCommand)&&(this.p
{
out_FragColor = vec4(1.0);
}
`;t.sources=[n]}function Sq(e,t){let n=t.sources,i=n.length;for(let r=0;r<i;++r)n[r]=He.replaceMain(n[r],"czm_globe_translucency_main");let o=`
uniform sampler2D u_classificationTexture;
void main()
{
vec2 st = gl_FragCoord.xy / czm_viewport.zw;
#ifdef MANUAL_DEPTH_TEST
float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, st));
if (logDepthOrDepth != 0.0)
{
vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);
float depthEC = eyeCoordinate.z / eyeCoordinate.w;
if (v_positionEC.z < depthEC)
{
discard;
}
}
#endif
czm_globe_translucency_main();
vec4 classificationColor = texture(u_classificationTexture, st);
if (classificationColor.a > 0.0)
{
// Reverse premultiplication process to get the correct composited result of the classification primitives
classificationColor.rgb /= classificationColor.a;
}
out_FragColor = classificationColor * vec4(classificationColor.aaa, 1.0) + out_FragColor * (1.0 - classificationColor.a);
}
`;n.push(o)}function bye(e,t){Sq(e,t),zf(e.defines,"GROUND_ATMOSPHERE"),zf(t.defines,"GROUND_ATMOSPHERE"),zf(e.defines,"FOG"),zf(t.defines,"FOG")}function Zct(e,t){Sq(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function Qct(e,t){bye(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function gye(e,t){let n=`uniform sampler2D u_classificationTexture;
void main()
{
vec2 st = gl_FragCoord.xy / czm_viewport.zw;
vec4 pickColor = texture(u_classificationTexture, st);
if (pickColor == vec4(0.0))
{
discard;
}
out_FragColor = pickColor;
}
`;t.sources=[n]}function $ct(e,t,n,i,o,r){if(!u(o))return t;if(!i&&u(n))return n;let s=e.shaderCache.getDerivedShaderProgram(t,r);if(!u(s)){let a=t._attributeLocations,c=t.vertexShaderSource.clone(),l=t.fragmentShaderSource.clone();c.defines=u(c.defines)?c.defines.slice(0):[],l.defines=u(l.defines)?l.defines.slice(0):[],o(c,l),s=e.shaderCache.createDerivedShaderProgram(t,r,{vertexShaderSource:c,fragmentShaderSource:l,attributeLocations:a})}return s}function elt(e){e.cull.face=_i.BACK,e.cull.enabled=!0}function tlt(e){e.cull.face=_i.FRONT,e.cull.enabled=!0}function nlt(e){e.cull.face=_i.BACK,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function ilt(e){e.cull.face=_i.FRONT,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function olt(e){e.cull.enabled=!1,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function yye(e){e.cull.face=_i.BACK,e.cull.enabled=!0,e.depthMask=!1,e.blending=un.ALPHA_BLEND}function Aye(e){e.cull.face=_i.FRONT,e.cull.enabled=!0,e.depthMask=!1,e.blending=un.ALPHA_BLEND}function rlt(e){e.cull.face=_i.BACK,e.cull.enabled=!0,e.blending.enabled=!1}function slt(e){e.cull.face=_i.FRONT,e.cull.enabled=!0,e.blending.enabled=!1}function alt(e,t,n,i,o){if(!u(i))return e;if(!n&&u(t))return t;let r=o[e.id];if(!u(r)){let s=ke.getState(e);i(s),r=ke.fromCache(s),o[e.id]=r}return r}function TS(e){return{u_classificationTexture:function(){return e._globeTranslucencyFramebuffer.classificationTexture}}}function clt(e,t,n,i,o){return u(o)?!i&&u(n)?n:ht(t,o(e),!1):t}function hm(e){this.pass=e.pass,this.pickOnly=e.pickOnly,this.getShaderProgramFunction=e.getShaderProgramFunction,this.getRenderStateFunction=e.getRenderStateFunction,this.getUniformMapFunction=e.getUniformMapFunction,this.renderStateCache={}}function llt(){return[new hm({pass:be.GLOBE,pickOnly:!1,getShaderProgramFunction:Kct,getRenderStateFunction:elt,getUniformMapFunction:void 0}),new hm({pass:be.GLOBE,pickOnly:!1,getShaderProgramFunction:Jct,getRenderStateFunction:tlt,getUniformMapFunction:void 0}),new hm({pass:be.GLOBE,pickOnly:!1,getShaderProgramFunction:bq,getRenderStateFunction:nlt,getUniformMapFunction:void 0}),new hm({pass:be.GLOBE,pickOnly:!1,getShaderProgramFunction:bq,getRenderStateFunction:ilt,getUniformMapFunction:void 0}),new hm({pass:be.GLOBE,pickOnly:!1,getShaderProgramFunction:bq,getRenderStateFunction:olt,getUniformMapFunction:void 0}),new hm({pass:be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:Sq,getRenderStateFunction:yye,getUniformMapFunction:TS}),new hm({pass:be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:bye,getRenderStateFunction:Aye,getUniformMapFunction:TS}),new hm({pass:be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:Zct,getRenderStateFunction:yye,getUniformMapFunction:TS}),new hm({pass:be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:Qct,getRenderStateFunction:Aye,getUniformMapFunction:TS}),new hm({pass:be.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:gye,getRenderStateFunction:rlt,getUniformMapFunction:TS}),new hm({pass:be.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:gye,getRenderStateFunction:slt,getUniformMapFunction:TS})]}var xye=new Array(rC),Cye=new Array(rC);sC.prototype.updateDerivedCommands=function(e,t){let n=this._derivedCommandTypesToUpdate,i=this._derivedCommandsToUpdateLength;if(i!==0){for(let o=0;o<i;++o)Cye[o]=this._derivedCommandPacks[n[o]],xye[o]=Eye[n[o]];ult(this,e,i,n,xye,Cye,t)}};function ult(e,t,n,i,o,r,s){let a=t.derivedCommands.globeTranslucency,c=e._derivedCommandsDirty;if(t.dirty||!u(a)||c){t.dirty=!1,u(a)||(a={},t.derivedCommands.globeTranslucency=a);let l=s.frameNumber,f=y(a.uniformMapDirtyFrame,0),d=y(a.shaderProgramDirtyFrame,0),p=y(a.renderStateDirtyFrame,0),g=a.uniformMap!==t.uniformMap,h=a.shaderProgramId!==t.shaderProgram.id,A=a.renderStateId!==t.renderState.id;g&&(a.uniformMapDirtyFrame=l),h&&(a.shaderProgramDirtyFrame=l),A&&(a.renderStateDirtyFrame=l),a.uniformMap=t.uniformMap,a.shaderProgramId=t.shaderProgram.id,a.renderStateId=t.renderState.id;for(let x=0;x<n;++x){let C=r[x],T=i[x],E=o[x],S=a[E],w,D,M;u(S)?(w=S.uniformMap,D=S.shaderProg
uniform sampler2D depthTexture;
uniform sampler2D classifiedTexture;
in vec2 v_textureCoordinates;
void main()
{
vec4 color = texture(colorTexture, v_textureCoordinates);
if (color.a == 0.0)
{
discard;
}
bool isClassified = all(equal(texture(classifiedTexture, v_textureCoordinates), vec4(0.0)));
#ifdef UNCLASSIFIED
vec4 highlightColor = czm_invertClassificationColor;
if (isClassified)
{
discard;
}
#else
vec4 highlightColor = vec4(1.0);
if (!isClassified)
{
discard;
}
#endif
out_FragColor = color * highlightColor;
gl_FragDepth = texture(depthTexture, v_textureCoordinates).r;
}
`,jlt=`uniform sampler2D colorTexture;
in vec2 v_textureCoordinates;
void main()
{
vec4 color = texture(colorTexture, v_textureCoordinates);
if (color.a == 0.0)
{
discard;
}
#ifdef UNCLASSIFIED
out_FragColor = color * czm_invertClassificationColor;
#else
out_FragColor = color;
#endif
}
`;vh.prototype.update=function(e,t,n){let i=this._fbo.getColorTexture(),o=this.previousFramebuffer!==this._previousFramebuffer;this._previousFramebuffer=this.previousFramebuffer;let r=this._numSamples!==t,s=e.drawingBufferWidth,a=e.drawingBufferHeight,c=!u(i)||i.width!==s||i.height!==a;if((c||o||r)&&(this._numSamples=t,this._depthStencilTexture=this._depthStencilTexture&&this._depthStencilTexture.destroy(),this._depthStencilRenderbuffer=this._depthStencilRenderbuffer&&this._depthStencilRenderbuffer.destroy(),u(this._previousFramebuffer)||(this._depthStencilTexture=new Mt({context:e,width:s,height:a,pixelFormat:st.DEPTH_STENCIL,pixelDatatype:Ke.UNSIGNED_INT_24_8}),t>1&&(this._depthStencilRenderbuffer=new eu({context:e,width:s,height:a,format:Bc.DEPTH24_STENCIL8,numSamples:t})))),!u(this._fbo.framebuffer)||c||o||r){this._fbo.destroy(),this._fboClassified.destroy();let l,f;u(this._previousFramebuffer)?(l=n.getDepthStencilTexture(),f=n.getDepthStencilRenderbuffer()):(l=this._depthStencilTexture,f=this._depthStencilRenderbuffer),this._fbo.setDepthStencilTexture(l),u(f)&&this._fbo.setDepthStencilRenderbuffer(f),this._fbo.update(e,s,a,t),u(this._previousFramebuffer)||(this._fboClassified.setDepthStencilTexture(l),this._fboClassified.update(e,s,a))}if(u(this._rsUnclassified)||(this._rsUnclassified=ke.fromCache(zlt),this._rsClassified=ke.fromCache(Hlt),this._rsDefault=ke.fromCache(Glt)),!u(this._unclassifiedCommand)||o||r){u(this._unclassifiedCommand)&&(this._unclassifiedCommand.shaderProgram=this._unclassifiedCommand.shaderProgram&&this._unclassifiedCommand.shaderProgram.destroy(),this._classifiedCommand.shaderProgram=this._classifiedCommand.shaderProgram&&this._classifiedCommand.shaderProgram.destroy());let l=u(this._previousFramebuffer)?jlt:Wlt,f=new He({defines:["UNCLASSIFIED"],sources:[l]}),d=new He({sources:[l]});this._unclassifiedCommand=e.createViewportQuadCommand(f,{renderState:u(this._previousFramebuffer)?this._rsUnclassified:this._rsDefault,uniformMap:this._uniformMap,owner:this}),this._classifiedCommand=e.createViewportQuadCommand(d,{renderState:u(this._previousFramebuffer)?this._rsClassified:this._rsDefault,uniformMap:this._uniformMap,owner:this}),u(this._translucentCommand)&&(this._translucentCommand.shaderProgram=this._translucentCommand.shaderProgram&&this._translucentCommand.shaderProgram.destroy()),u(this._previousFramebuffer)||(this._translucentCommand=e.createViewportQuadCommand(kl,{renderState:this._rsUnclassified,uniformMap:this._uniformMap,owner:this}))}};vh.prototype.prepareTextures=function(e,t){this._fbo._numSamples>1&&this._fbo.prepareTextures(e,t)};vh.prototype.clear=function(e,t){u(this._previousFramebuffer)?this._fbo.clear(e,this._clearColorCommand,t):(this._fbo.clear(e,this._clearCommand,t),this._fboClassified.clear(e,this._clearCommand,t))};vh.prototype.executeClassified=function(e,t){if(!u(this._previousFramebuffer)){let n=t.framebuffer;this.prepareTextures(e,!0),t.framebuffer=this._fboClassified.framebuffer,this._translucentCommand.execute(e,t),t.framebuffer=n}this._classifiedCommand.execute(e,t)};vh.prototype.executeUnclassified=function(e,t){this._unclassifiedCommand.execute(e,t)};vh.prototype.isDestroyed=function(){return!1};vh.prototype.destroy=function(){return this._fbo.destroy(),this._fboClassified.destroy(),this._depthStencilTexture=this._depthStencilTexture&&this._depthStencilTexture.destroy(),this._depthStencilRenderbuffer=this._depthStencilRenderbuffer&&this._depthStencilRenderbuffer.destroy(),u(this._unclassifiedCommand)&&(this._unclassifiedCommand.shaderProgram=this._unclassifiedCommand.shaderProgram&&this._unclassifiedCommand.shaderProgram.destroy(),this._classifiedCommand.shaderProgram=this._classifiedCommand.shaderProgram&&this._classifiedCommand.shaderProgram.destroy()),ue(this)};var vS=vh;function Iz(e){this._total=e,this.usedThisFrame=0,this.stolenFromMeThisFrame=0,this.starvedThisFrame=!1,this.starvedLastFrame=!1}Object.defineProperties(Iz.prototype,{total:{get:function(){return this._total}}});function Qy(e){let t=new Array(ga.NUMBER_OF_JOB_TYPES);t[ga.TEXTURE]=new Iz(u(e)?e
layout (location = 0) out vec4 out_FragData_0;
layout (location = 1) out vec4 out_FragData_1;
#else
layout (location = 0) out vec4 out_FragColor;
#endif
uniform vec4 u_bgColor;
uniform sampler2D u_depthTexture;
in vec2 v_textureCoordinates;
void main()
{
if (texture(u_depthTexture, v_textureCoordinates).r < 1.0)
{
#ifdef MRT
out_FragData_0 = u_bgColor;
out_FragData_1 = vec4(u_bgColor.a);
#else
out_FragColor = u_bgColor;
#endif
return;
}
discard;
}
`;var TN=`/**
* Compositing for Weighted Blended Order-Independent Transparency. See:
* - http://jcgt.org/published/0002/02/09/
* - http://casual-effects.blogspot.com/2014/03/weighted-blended-order-independent.html
*/
uniform sampler2D u_opaque;
uniform sampler2D u_accumulation;
uniform sampler2D u_revealage;
in vec2 v_textureCoordinates;
void main()
{
vec4 opaque = texture(u_opaque, v_textureCoordinates);
vec4 accum = texture(u_accumulation, v_textureCoordinates);
float r = texture(u_revealage, v_textureCoordinates).r;
#ifdef MRT
vec4 transparent = vec4(accum.rgb / clamp(r, 1e-4, 5e4), accum.a);
#else
vec4 transparent = vec4(accum.rgb / clamp(accum.a, 1e-4, 5e4), r);
#endif
out_FragColor = (1.0 - transparent.a) * transparent + transparent.a * opaque;
if (opaque != czm_backgroundColor)
{
out_FragColor.a = 1.0;
}
}
`;function N_(e){this._numSamples=1,this._translucentMultipassSupport=!1,this._translucentMRTSupport=!1;let t=e.colorBufferFloat&&e.depthTexture&&e.floatBlend;this._translucentMRTSupport=e.drawBuffers&&t,this._translucentMultipassSupport=!this._translucentMRTSupport&&t,this._opaqueFBO=void 0,this._opaqueTexture=void 0,this._depthStencilTexture=void 0,this._accumulationTexture=void 0,this._translucentFBO=new mi({colorAttachmentsLength:this._translucentMRTSupport?2:1,createColorAttachments:!1,createDepthAttachments:!1,depth:!0}),this._alphaFBO=new mi({createColorAttachments:!1,createDepthAttachments:!1,depth:!0}),this._adjustTranslucentFBO=new mi({colorAttachmentsLength:this._translucentMRTSupport?2:1,createColorAttachments:!1}),this._adjustAlphaFBO=new mi({createColorAttachments:!1}),this._opaqueClearCommand=new li({color:new k(0,0,0,0),owner:this}),this._translucentMRTClearCommand=new li({color:new k(0,0,0,1),owner:this}),this._translucentMultipassClearCommand=new li({color:new k(0,0,0,0),owner:this}),this._alphaClearCommand=new li({color:new k(1,1,1,1),owner:this}),this._translucentRenderStateCache={},this._alphaRenderStateCache={},this._compositeCommand=void 0,this._adjustTranslucentCommand=void 0,this._adjustAlphaCommand=void 0,this._viewport=new qe,this._rs=void 0,this._useScissorTest=!1,this._scissorRectangle=void 0,this._useHDR=!1}function Mye(e){e._accumulationTexture=e._accumulationTexture&&!e._accumulationTexture.isDestroyed()&&e._accumulationTexture.destroy(),e._revealageTexture=e._revealageTexture&&!e._revealageTexture.isDestroyed()&&e._revealageTexture.destroy()}function Lq(e){e._translucentFBO.destroy(),e._alphaFBO.destroy(),e._adjustTranslucentFBO.destroy(),e._adjustAlphaFBO.destroy()}function Rye(e){Mye(e),Lq(e)}function Jlt(e,t,n,i){Mye(e),e._accumulationTexture=new Mt({context:t,width:n,height:i,pixelFormat:st.RGBA,pixelDatatype:Ke.FLOAT});let o=new Float32Array(n*i*4);e._revealageTexture=new Mt({context:t,pixelFormat:st.RGBA,pixelDatatype:Ke.FLOAT,source:{arrayBufferView:o,width:n,height:i},flipY:!1})}function Zlt(e,t){Lq(e);let n=te.FRAMEBUFFER_COMPLETE,i=!0,{width:o,height:r}=e._accumulationTexture;if(e._translucentMRTSupport&&(e._translucentFBO.setColorTexture(e._accumulationTexture,0),e._translucentFBO.setColorTexture(e._revealageTexture,1),e._translucentFBO.setDepthStencilTexture(e._depthStencilTexture),e._translucentFBO.update(t,o,r),e._adjustTranslucentFBO.setColorTexture(e._accumulationTexture,0),e._adjustTranslucentFBO.setColorTexture(e._revealageTexture,1),e._adjustTranslucentFBO.update(t,o,r),(e._translucentFBO.status!==n||e._adjustTranslucentFBO.status!==n)&&(Lq(e),e._translucentMRTSupport=!1)),!e._translucentMRTSupport){e._translucentFBO.setColorTexture(e._accumulationTexture),e._translucentFBO.setDepthStencilTexture(e._depthStencilTexture),e._translucentFBO.update(t,o,r),e._alphaFBO.setColorTexture(e._revealageTexture),e._alphaFBO.setDepthStencilTexture(e._depthStencilTexture),e._alphaFBO.update(t,o,r),e._adjustTranslucentFBO.setColorTexture(e._accumulationTexture),e._adjustTranslucentFBO.update(t,o,r),e._adjustAlphaFBO.setColorTexture(e._revealageTexture),e._adjustAlphaFBO.update(t,o,r);let s=e._translucentFBO.status===n,a=e._alphaFBO.status===n,c=e._adjustTranslucentFBO.status===n,l=e._adjustAlphaFBO.status===n;(!s||!a||!c||!l)&&(Rye(e),e._translucentMultipassSupport=!1,i=!1)}return i}N_.prototype.update=function(e,t,n,i,o){if(!this.isSupported())return;this._opaqueFBO=n,this._opaqueTexture=n.getColorTexture(0),this._depthStencilTexture=n.getDepthStencilTexture();let{width:r,height:s}=this._opaqueTexture,a=this._accumulationTexture,c=!u(a)||a.width!==r||a.height!==s||i!==this._useHDR,l=this._numSamples!==o;if((c||l)&&(this._numSamples=o,Jlt(this,e,r,s)),(!u(this._translucentFBO.framebuffer)||c||l)&&!Zlt(this,e))return;this._useHDR=i;let f=this,d,p;u(this._compositeCommand)||(d=new He({sources:[TN]}),this._translucentMRTSupport&&d.defines.push("MRT"),p={u_opaque:function(){return f._opaqueTexture},u_accumulation:function(){return f._accumulationTexture},u_revealage:function(){return f._r
float ai = czm_out_FragColor.a;
float wzi = czm_alphaWeight(ai);
out_FragData_0 = vec4(Ci * wzi, ai);
out_FragData_1 = vec4(ai * wzi);
`,rut=` vec3 Ci = czm_out_FragColor.rgb * czm_out_FragColor.a;
float ai = czm_out_FragColor.a;
float wzi = czm_alphaWeight(ai);
out_FragColor = vec4(Ci, ai) * wzi;
`,sut=` float ai = czm_out_FragColor.a;
out_FragColor = vec4(ai);
`;function Fq(e,t,n,i){let{shaderCache:o}=e,r=o.getDerivedShaderProgram(t,n);if(u(r))return r;let s=t._attributeLocations,a=t.fragmentShaderSource.clone();a.sources=a.sources.map(function(f){return He.replaceMain(f,"czm_translucent_main").replace(/out_FragColor/g,"czm_out_FragColor").replace(/layout\s*\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor;/g,"").replace(/\bdiscard\b/g,"czm_discard = true").replace(/czm_phong/g,"czm_translucentPhong")}),a.sources.splice(0,0,`vec4 czm_out_FragColor;
bool czm_discard = false;
`);let c=[...i.matchAll(/out_FragData_(\d+)/g)],l="";for(let f=0;f<c.length;f++){let d=c[f];l=`layout (location = ${d[1]}) out vec4 ${d[0]};
${l}`}return a.sources.push(l),a.sources.push(`void main()
{
czm_translucent_main();
if (czm_discard)
{
discard;
}
${i}}
`),o.createDerivedShaderProgram(t,n,{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:a,attributeLocations:s})}function aut(e,t){return Fq(e,t,"translucentMRT",out)}function cut(e,t){return Fq(e,t,"translucentMultipass",rut)}function lut(e,t){return Fq(e,t,"alphaMultipass",sut)}N_.prototype.createDerivedCommands=function(e,t,n){if(u(n)||(n={}),this._translucentMRTSupport){let a,c;return u(n.translucentCommand)&&(a=n.translucentCommand.shaderProgram,c=n.translucentCommand.renderState),n.translucentCommand=nt.shallowClone(e,n.translucentCommand),!u(a)||n.shaderProgramId!==e.shaderProgram.id?(n.translucentCommand.shaderProgram=aut(t,e.shaderProgram),n.translucentCommand.renderState=tut(this,t,e.renderState),n.shaderProgramId=e.shaderProgram.id):(n.translucentCommand.shaderProgram=a,n.translucentCommand.renderState=c),n}let i,o,r,s;return u(n.translucentCommand)&&(i=n.translucentCommand.shaderProgram,o=n.translucentCommand.renderState,r=n.alphaCommand.shaderProgram,s=n.alphaCommand.renderState),n.translucentCommand=nt.shallowClone(e,n.translucentCommand),n.alphaCommand=nt.shallowClone(e,n.alphaCommand),!u(i)||n.shaderProgramId!==e.shaderProgram.id?(n.translucentCommand.shaderProgram=cut(t,e.shaderProgram),n.translucentCommand.renderState=nut(this,t,e.renderState),n.alphaCommand.shaderProgram=lut(t,e.shaderProgram),n.alphaCommand.renderState=iut(this,t,e.renderState),n.shaderProgramId=e.shaderProgram.id):(n.translucentCommand.shaderProgram=i,n.translucentCommand.renderState=o,n.alphaCommand.shaderProgram=r,n.alphaCommand.renderState=s),n};function uut(e,t,n,i,o,r){let s,a,c,{context:l,frameState:f}=t,{useLogDepth:d,shadowState:p}=f,g=t._hdr,h=i.framebuffer,A=p.lightShadowsEnabled;i.framebuffer=e._adjustTranslucentFBO.framebuffer,e._adjustTranslucentCommand.execute(l,i),i.framebuffer=e._adjustAlphaFBO.framebuffer,e._adjustAlphaCommand.execute(l,i);let x=e._opaqueFBO.framebuffer;for(i.framebuffer=e._translucentFBO.framebuffer,c=0;c<o.length;++c)s=o[c],s=d?s.derivedCommands.logDepth.command:s,s=g?s.derivedCommands.hdr.command:s,a=A&&s.receiveShadows?s.derivedCommands.oit.shadows.translucentCommand:s.derivedCommands.oit.translucentCommand,n(a,t,l,i,x);for(u(r)&&(s=r.unclassifiedCommand,a=A&&s.receiveShadows?s.derivedCommands.oit.shadows.translucentCommand:s.derivedCommands.oit.translucentCommand,n(a,t,l,i,x)),i.framebuffer=e._alphaFBO.framebuffer,c=0;c<o.length;++c)s=o[c],s=d?s.derivedCommands.logDepth.command:s,s=g?s.derivedCommands.hdr.command:s,a=A&&s.receiveShadows?s.derivedCommands.oit.shadows.alphaCommand:s.derivedCommands.oit.alphaCommand,n(a,t,l,i,x);u(r)&&(s=r.unclassifiedCommand,a=A&&s.receiveShadows?s.derivedCommands.oit.shadows.alphaCommand:s.derivedCommands.oit.alphaCommand,n(a,t,l,i,x)),i.framebuffer=h}function fut(e,t,n,i,o,r){let{context:s,frameState:a}=t,{useLogDepth:c,shadowState:l}=a,f=t._hdr,d=i.framebuffer,p=l.lightShadowsEnabled;i.framebuffer=e._adjustTranslucentFBO.framebuffer,e._adjustTranslucentCommand.execute(s,i);let g=e._opaqueFBO.framebuffer;i.framebuffer=e._translucentFBO.framebuffer;let h,A;for(let x=0;x<o.length;++x)h=o[x],h=c?h.derivedCommands.logDepth.command:h,h=f?h.derivedCommands.hdr.command:h,A=p&&h.receiveShadows?h.derivedCommands.oit.shadows.translucentCommand:h.derivedCommands.oit.translucentCommand,n(A,t,s,i,g);u(r)&&(h=r.unclassifiedCommand,A=p&&h.receiveShadows?h.derivedCommands.oit.shadows.translucentCommand:h.derivedCommands.oit.translucentCommand,n(A,t,s,i,g)),i.framebuffer=d}N_.prototype.executeCommands=function(e,t,n,i,o){if(this._translucentMRTSupport){fut(this,e,t,n,i,o);return}uut(this,e,t,n,i,o)};N_.prototype.execute=function(e,t){this._compositeCommand.execute(e,t)};N_.prototype.clear=function(e,t,n){let i=t.framebuffer;t.framebuffer=this._opaqueFBO.framebuffer,k.clone(n,this._opaqueClearCommand.color),this._opaqueClearCommand.execute(e,t),t.framebuffer=this._translucentFBO.framebuffer,(this._translucentMRTSupport?this._translucentMRTClearCommand:this._translucentMultipassClearCommand).execute(e,t),this._translucentMultipassSupport&&(t.framebuffer=this._alphaFBO.f
in vec2 v_textureCoordinates;
void main()
{
out_FragColor = czm_packDepth(texture(u_texture, v_textureCoordinates).r);
}
`;e._copyDepthCommand=t.createViewportQuadCommand(i,{renderState:ke.fromCache(),uniformMap:{u_texture:function(){return e._textureToCopy}},owner:e})}e._textureToCopy=n,e._copyDepthCommand.framebuffer=e.framebuffer}fC.prototype.update=function(e,t){Cut(this,e,t),Tut(this,e,t)};var Eut=new re,but=new re(1,1/255,1/65025,1/16581375);fC.prototype.getDepth=function(e,t,n){if(!u(this.framebuffer))return;let i=e.readPixels({x:t,y:n,width:1,height:1,framebuffer:this.framebuffer}),o=re.unpack(i,0,Eut);return re.divideByScalar(o,255,o),re.dot(o,but)};fC.prototype.executeCopyDepth=function(e,t){this._copyDepthCommand.execute(e,t)};fC.prototype.isDestroyed=function(){return!1};fC.prototype.destroy=function(){return this._framebuffer.destroy(),u(this._copyDepthCommand)&&(this._copyDepthCommand.shaderProgram=u(this._copyDepthCommand.shaderProgram)&&this._copyDepthCommand.shaderProgram.destroy()),ue(this)};var SN=fC;function vN(){this._framebuffer=new mi({color:!1,depthStencil:!0,supportsDepthTexture:!0}),this._passState=void 0}Object.defineProperties(vN.prototype,{framebuffer:{get:function(){return this._framebuffer.framebuffer}}});function Sut(e){e._framebuffer.destroy()}function vut(e,t){let n=t.drawingBufferWidth,i=t.drawingBufferHeight;e._framebuffer.update(t,n,i);let o=new sc(t);o.blendingEnabled=!1,o.scissorTest={enabled:!0,rectangle:new qe},o.viewport=new qe,e._passState=o}vN.prototype.update=function(e,t,n){let i=n.width,o=n.height;this._framebuffer.isDirty(i,o)&&vut(this,e);let r=this.framebuffer,s=this._passState;return s.framebuffer=r,s.viewport.width=i,s.viewport.height=o,s.scissorTest.rectangle.x=t.x,s.scissorTest.rectangle.y=o-t.y,s.scissorTest.rectangle.width=1,s.scissorTest.rectangle.height=1,s};vN.prototype.isDestroyed=function(){return!1};vN.prototype.destroy=function(){return Sut(this),ue(this)};var wN=vN;function IN(e){let t=new sc(e);t.blendingEnabled=!1,t.scissorTest={enabled:!0,rectangle:new qe},t.viewport=new qe,this._context=e,this._fb=new mi({depthStencil:!0}),this._passState=t,this._width=0,this._height=0}IN.prototype.begin=function(e,t){let n=this._context,i=t.width,o=t.height;return qe.clone(e,this._passState.scissorTest.rectangle),this._width=i,this._height=o,this._fb.update(n,i,o),this._passState.framebuffer=this._fb.framebuffer,this._passState.viewport.width=i,this._passState.viewport.height=o,this._passState};var DN=new k;IN.prototype.end=function(e){let t=y(e.width,1),n=y(e.height,1),i=this._context,o=i.readPixels({x:e.x,y:e.y,width:t,height:n,framebuffer:this._fb.framebuffer}),r=Math.max(t,n),s=r*r,a=Math.floor(t*.5),c=Math.floor(n*.5),l=0,f=0,d=0,p=-1;for(let g=0;g<s;++g){if(-a<=l&&l<=a&&-c<=f&&f<=c){let h=4*((c-f)*t+l+a);DN.red=k.byteToFloat(o[h]),DN.green=k.byteToFloat(o[h+1]),DN.blue=k.byteToFloat(o[h+2]),DN.alpha=k.byteToFloat(o[h+3]);let A=i.getObjectByPickColor(DN);if(u(A))return A}if(l===f||l<0&&-l===f||l>0&&l===1-f){let h=d;d=-p,p=h}l+=d,f+=p}};IN.prototype.isDestroyed=function(){return!1};IN.prototype.destroy=function(){return this._fb.destroy(),ue(this)};var PN=IN;function U_(){this._numSamples=1,this._colorFramebuffer=new mi({depthStencil:!0,supportsDepthTexture:!0}),this._idFramebuffer=new mi({depthStencil:!0,supportsDepthTexture:!0}),this._idClearColor=new k(0,0,0,0),this._clearCommand=new li({color:new k(0,0,0,0),depth:1,owner:this})}function wut(e){e._colorFramebuffer.destroy(),e._idFramebuffer.destroy()}Object.defineProperties(U_.prototype,{framebuffer:{get:function(){return this._colorFramebuffer.framebuffer}},idFramebuffer:{get:function(){return this._idFramebuffer.framebuffer}},depthStencilTexture:{get:function(){return this._colorFramebuffer.getDepthStencilTexture()}}});U_.prototype.update=function(e,t,n,i){let o=t.width,r=t.height,s=n?e.halfFloatingPointTexture?Ke.HALF_FLOAT:Ke.FLOAT:Ke.UNSIGNED_BYTE;this._numSamples=i,this._colorFramebuffer.update(e,o,r,i,s),this._idFramebuffer.update(e,o,r)};U_.prototype.clear=function(e,t,n){k.clone(n,this._clearCommand.color),k.clone(this._idClearColor,this._clearCommand.color),this._colorFramebuffer.clear(e,this._clearCommand,t),this._idFra
void main()
{
czm_shadow_cast_main();
v_positionEC = (czm_inverseProjection * gl_Position).xyz;
}`;o.push(c)}return new He({defines:i,sources:o})};mC.createShadowCastFragmentShader=function(e,t,n,i){let o=e.defines.slice(0),r=e.sources.slice(0);o.push("SHADOW_MAP");let s=He.findPositionVarying(e),a=u(s);a||(s="v_positionEC");let c=r.length;for(let f=0;f<c;++f)r[f]=He.replaceMain(r[f],"czm_shadow_cast_main");let l="";return t&&(a||(l+=`in vec3 v_positionEC;
`),l+=`uniform vec4 shadowMap_lightPositionEC;
`),i?l+=`void main()
{
`:l+=`void main()
{
czm_shadow_cast_main();
if (out_FragColor.a == 0.0)
{
discard;
}
`,t?l+=` float distance = length(${s});
if (distance >= shadowMap_lightPositionEC.w)
{
discard;
}
distance /= shadowMap_lightPositionEC.w; // radius
out_FragColor = czm_packDepth(distance);
`:n?l+=` out_FragColor = vec4(1.0);
`:l+=` out_FragColor = czm_packDepth(gl_FragCoord.z);
`,l+=`}
`,r.push(l),new He({defines:o,sources:r})};mC.getShadowReceiveShaderKeyword=function(e,t,n,i){let o=e._usesDepthTexture,r=e._polygonOffsetSupported,s=e._isPointLight,a=e._isSpotLight,c=e._numberOfCascades>1,l=e.debugCascadeColors,f=e.softShadows;return`receiveShadow ${o}${r}${s}${a}${c}${l}${f}${t}${n}${i}`};mC.createShadowReceiveVertexShader=function(e,t,n){let i=e.defines.slice(0),o=e.sources.slice(0);return i.push("SHADOW_MAP"),t&&(n?i.push("GENERATE_POSITION_AND_NORMAL"):i.push("GENERATE_POSITION")),new He({defines:i,sources:o})};mC.createShadowReceiveFragmentShader=function(e,t,n,i,o){let r=He.findNormalVarying(e),s=!i&&u(r)||i&&o,a=He.findPositionVarying(e),c=u(a),l=t._usesDepthTexture,f=t._polygonOffsetSupported,d=t._isPointLight,p=t._isSpotLight,g=t._numberOfCascades>1,h=t.debugCascadeColors,A=t.softShadows,x=d?t._pointBias:i?t._terrainBias:t._primitiveBias,C=e.defines.slice(0),T=e.sources.slice(0),E=T.length;for(let D=0;D<E;++D)T[D]=He.replaceMain(T[D],"czm_shadow_receive_main");d?C.push("USE_CUBE_MAP_SHADOW"):l&&C.push("USE_SHADOW_DEPTH_TEXTURE"),A&&!d&&C.push("USE_SOFT_SHADOWS"),g&&n&&i&&(s?C.push("ENABLE_VERTEX_LIGHTING"):C.push("ENABLE_DAYNIGHT_SHADING")),n&&x.normalShading&&s&&(C.push("USE_NORMAL_SHADING"),x.normalShadingSmooth>0&&C.push("USE_NORMAL_SHADING_SMOOTH"));let S="";d?S+=`uniform samplerCube shadowMap_textureCube;
`:S+=`uniform sampler2D shadowMap_texture;
`;let w;return c?w=` return vec4(${a}, 1.0);
`:w=`#ifndef LOG_DEPTH
return czm_windowToEyeCoordinates(gl_FragCoord);
#else
return vec4(v_logPositionEC, 1.0);
#endif
`,S+=`uniform mat4 shadowMap_matrix;
uniform vec3 shadowMap_lightDirectionEC;
uniform vec4 shadowMap_lightPositionEC;
uniform vec4 shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness;
uniform vec4 shadowMap_texelSizeDepthBiasAndNormalShadingSmooth;
#ifdef LOG_DEPTH
in vec3 v_logPositionEC;
#endif
vec4 getPositionEC()
{
${w}}
vec3 getNormalEC()
{
${s?` return normalize(${r});
`:` return vec3(1.0);
`}}
void applyNormalOffset(inout vec4 positionEC, vec3 normalEC, float nDotL)
{
${x.normalOffset&&s?` float normalOffset = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.x;
float normalOffsetScale = 1.0 - nDotL;
vec3 offset = normalOffset * normalOffsetScale * normalEC;
positionEC.xyz += offset;
`:""}}
`,S+=`void main()
{
czm_shadow_receive_main();
vec4 positionEC = getPositionEC();
vec3 normalEC = getNormalEC();
float depth = -positionEC.z;
`,S+=` czm_shadowParameters shadowParameters;
shadowParameters.texelStepSize = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.xy;
shadowParameters.depthBias = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.z;
shadowParameters.normalShadingSmooth = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.w;
shadowParameters.darkness = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.w;
`,i?S+=` shadowParameters.depthBias *= max(depth * 0.01, 1.0);
`:f||(S+=` shadowParameters.depthBias *= mix(1.0, 100.0, depth * 0.0015);
`),d?S+=` vec3 directionEC = positionEC.xyz - shadowMap_lightPositionEC.xyz;
float distance = length(directionEC);
directionEC = normalize(directionEC);
float radius = shadowMap_lightPositionEC.w;
// Stop early if the fragment is beyond the point light radius
if (distance > radius)
{
return;
}
vec3 directionWC = czm_inverseViewRotation * directionEC;
shadowParameters.depth = distance / radius;
shadowParameters.nDotL = clamp(dot(normalEC, -directionEC), 0.0, 1.0);
shadowParameters.texCoords = directionWC;
float visibility = czm_shadowVisibility(shadowMap_textureCube, shadowParameters);
`:p?S+=` vec3 directionEC = normalize(positionEC.xyz - shadowMap_lightPositionEC.xyz);
float nDotL = clamp(dot(normalEC, -directionEC), 0.0, 1.0);
applyNormalOffset(positionEC, normalEC, nDotL);
vec4 shadowPosition = shadowMap_matrix * positionEC;
// Spot light uses a perspective projection, so perform the perspective divide
shadowPosition /= shadowPosition.w;
// Stop early if the fragment is not in the shadow bounds
if (any(lessThan(shadowPosition.xyz, vec3(0.0))) || any(greaterThan(shadowPosition.xyz, vec3(1.0))))
{
return;
}
shadowParameters.texCoords = shadowPosition.xy;
shadowParameters.depth = shadowPosition.z;
shadowParameters.nDotL = nDotL;
float visibility = czm_shadowVisibility(shadowMap_texture, shadowParameters);
`:g?S+=` float maxDepth = shadowMap_cascadeSplits[1].w;
// Stop early if the eye depth exceeds the last cascade
if (depth > maxDepth)
{
return;
}
// Get the cascade based on the eye-space depth
vec4 weights = czm_cascadeWeights(depth);
// Apply normal offset
float nDotL = clamp(dot(normalEC, shadowMap_lightDirectionEC), 0.0, 1.0);
applyNormalOffset(positionEC, normalEC, nDotL);
// Transform position into the cascade
vec4 shadowPosition = czm_cascadeMatrix(weights) * positionEC;
// Get visibility
shadowParameters.texCoords = shadowPosition.xy;
shadowParameters.depth = shadowPosition.z;
shadowParameters.nDotL = nDotL;
float visibility = czm_shadowVisibility(shadowMap_texture, shadowParameters);
// Fade out shadows that are far away
float shadowMapMaximumDistance = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.z;
float fade = max((depth - shadowMapMaximumDistance * 0.8) / (shadowMapMaximumDistance * 0.2), 0.0);
visibility = mix(visibility, 1.0, fade);
${h?` // Draw cascade colors for debugging
out_FragColor *= czm_cascadeColor(weights);
`:""}`:S+=` float nDotL = clamp(dot(normalEC, shadowMap_lightDirectionEC), 0.0, 1.0);
applyNormalOffset(positionEC, normalEC, nDotL);
vec4 shadowPosition = shadowMap_matrix * positionEC;
// Stop early if the fragment is not in the shadow bounds
if (any(lessThan(shadowPosition.xyz, vec3(0.0))) || any(greaterThan(shadowPosition.xyz, vec3(1.0))))
{
return;
}
shadowParameters.texCoords = shadowPosition.xy;
shadowParameters.depth = shadowPosition.z;
shadowParameters.nDotL = nDotL;
float visibility = czm_shadowVisibility(shadowMap_texture, shadowParameters);
`,S+=` out_FragColor.rgb *= visibility;
}
`,T.push(S),new He({defines:C,sources:T})};var wh=mC;function Dh(e){e=y(e,y.EMPTY_OBJECT);let t=e.context;this._enabled=y(e.enabled,!0),this._softShadows=y(e.softShadows,!1),this._normalOffset=y(e.normalOffset,!0),this.dirty=!0,this.fromLightSource=y(e.fromLightSource,!0),this.darkness=y(e.darkness,.3),this._darkness=this.darkness,this.fadingEnabled=y(e.fadingEnabled,!0),this.maximumDistance=y(e.maximumDistance,5e3),this._outOfView=!1,this._outOfViewPrevious=!1,this._needsUpdate=!0;let n=!0;(kt.isInternetExplorer()||kt.isEdge()||(kt.isChrome()||kt.isFirefox())&&kt.isWindows()&&!t.depthTexture)&&(n=!1),this._polygonOffsetSupported=n,this._terrainBias={polygonOffset:n,polygonOffsetFactor:1.1,polygonOffsetUnits:4,normalOffset:this._normalOffset,normalOffsetScale:.5,normalShading:!0,normalShadingSmooth:.3,depthBias:1e-4},this._primitiveBias={polygonOffset:n,polygonOffsetFactor:1.1,polygonOffsetUnits:4,normalOffset:this._normalOffset,normalOffsetScale:.1,normalShading:!0,normalShadingSmooth:.05,depthBias:2e-5},this._pointBias={polygonOffset:!1,polygonOffsetFactor:1.1,polygonOffsetUnits:4,normalOffset:this._normalOffset,normalOffsetScale:0,normalShading:!0,normalShadingSmooth:.1,depthBias:5e-4},this._depthAttachment=void 0,this._colorAttachment=void 0,this._shadowMapMatrix=new B,this._shadowMapTexture=void 0,this._lightDirectionEC=new m,this._lightPositionEC=new re,this._distance=0,this._lightCamera=e.lightCamera,this._shadowMapCamera=new Nz,this._shadowMapCullingVolume=void 0,this._sceneCamera=void 0,this._boundingSphere=new ae,this._isPointLight=y(e.isPointLight,!1),this._pointLightRadius=y(e.pointLightRadius,100),this._cascadesEnabled=this._isPointLight?!1:y(e.cascadesEnabled,!0),this._numberOfCascades=this._cascadesEnabled?y(e.numberOfCascades,4):0,this._fitNearFar=!0,this._maximumCascadeDistances=[25,150,700,Number.MAX_VALUE],this._textureSize=new H,this._isSpotLight=!1,this._cascadesEnabled?this._shadowMapCamera.frustum=new br:u(this._lightCamera.frustum.fov)&&(this._isSpotLight=!0),this._cascadeSplits=[new re,new re],this._cascadeMatrices=[new B,new B,new B,new B],this._cascadeDistances=new re;let i;this._isPointLight?i=6:this._cascadesEnabled?i=this._numberOfCascades:i=1,this._passes=new Array(i);for(let o=0;o<i;++o)this._passes[o]=new Dut(t);this.debugShow=!1,this.debugFreezeFrame=!1,this._debugFreezeFrame=!1,this._debugCascadeColors=!1,this._debugLightFrustum=void 0,this._debugCameraFrustum=void 0,this._debugCascadeFrustums=new Array(this._numberOfCascades),this._debugShadowViewCommand=void 0,this._usesDepthTexture=t.depthTexture,this._isPointLight&&(this._usesDepthTexture=!1),this._primitiveRenderState=void 0,this._terrainRenderState=void 0,this._pointRenderState=void 0,Gq(this),this._clearCommand=new li({depth:1,color:new k}),this._clearPassState=new sc(t),this._size=y(e.size,2048),this.size=this._size}Dh.MAXIMUM_DISTANCE=2e4;function Dut(e){this.camera=new Nz,this.passState=new sc(e),this.framebuffer=void 0,this.textureOffsets=void 0,this.commandList=[],this.cullingVolume=void 0}function Hq(e,t){return ke.fromCache({cull:{enabled:!0,face:_i.BACK},depthTest:{enabled:!0},colorMask:{red:e,green:e,blue:e,alpha:e},depthMask:!0,polygonOffset:{enabled:t.polygonOffset,factor:t.polygonOffsetFactor,units:t.polygonOffsetUnits}})}function Gq(e){let t=!e._usesDepthTexture;e._primitiveRenderState=Hq(t,e._primitiveBias),e._terrainRenderState=Hq(t,e._terrainBias),e._pointRenderState=Hq(t,e._pointBias)}Dh.prototype.debugCreateRenderStates=function(){Gq(this)};Object.defineProperties(Dh.prototype,{enabled:{get:function(){return this._enabled},set:function(e){this.dirty=this._enabled!==e,this._enabled=e}},normalOffset:{get:function(){return this._normalOffset},set:function(e){this.dirty=this._normalOffset!==e,this._normalOffset=e,this._terrainBias.normalOffset=e,this._primitiveBias.normalOffset=e,this._pointBias.normalOffset=e}},softShadows:{get:function(){return this._softShadows},set:function(e){this.dirty=this._softShadows!==e,this._softShadows=e}},size:{get:function(){return this._size},set:function(e){But(this,e)}},outOfView:{
in vec2 v_textureCoordinates;
void main()
{
vec2 uv = v_textureCoordinates;
vec3 dir;
if (uv.y < 0.5)
{
if (uv.x < 0.333)
{
dir.x = -1.0;
dir.y = uv.x * 6.0 - 1.0;
dir.z = uv.y * 4.0 - 1.0;
}
else if (uv.x < 0.666)
{
dir.y = -1.0;
dir.x = uv.x * 6.0 - 3.0;
dir.z = uv.y * 4.0 - 1.0;
}
else
{
dir.z = -1.0;
dir.x = uv.x * 6.0 - 5.0;
dir.y = uv.y * 4.0 - 1.0;
}
}
else
{
if (uv.x < 0.333)
{
dir.x = 1.0;
dir.y = uv.x * 6.0 - 1.0;
dir.z = uv.y * 4.0 - 3.0;
}
else if (uv.x < 0.666)
{
dir.y = 1.0;
dir.x = uv.x * 6.0 - 3.0;
dir.z = uv.y * 4.0 - 3.0;
}
else
{
dir.z = 1.0;
dir.x = uv.x * 6.0 - 5.0;
dir.y = uv.y * 4.0 - 3.0;
}
}
float shadow = czm_unpackDepth(czm_textureCube(shadowMap_textureCube, dir));
out_FragColor = vec4(vec3(shadow), 1.0);
}
`:n=`uniform sampler2D shadowMap_texture;
in vec2 v_textureCoordinates;
void main()
{
${e._usesDepthTexture?` float shadow = texture(shadowMap_texture, v_textureCoordinates).r;
`:` float shadow = czm_unpackDepth(texture(shadowMap_texture, v_textureCoordinates));
`} out_FragColor = vec4(vec3(shadow), 1.0);
}
`;let i=t.createViewportQuadCommand(n,{uniformMap:{shadowMap_texture:function(){return e._shadowMapTexture},shadowMap_textureCube:function(){return e._shadowMapTexture}}});return i.pass=be.OVERLAY,i}function Fut(e,t){let n=t.context,i=t.context.drawingBufferWidth,o=t.context.drawingBufferHeight,r=Math.min(i,o)*.3,s=Lut;s.x=i-r,s.y=0,s.width=r,s.height=r;let a=e._debugShadowViewCommand;u(a)||(a=Nut(e,n),e._debugShadowViewCommand=a),(!u(a.renderState)||!qe.equals(a.renderState.viewport,s))&&(a.renderState=ke.fromCache({viewport:qe.clone(s)})),t.commandList.push(e._debugShadowViewCommand)}var Ih=new Array(8);Ih[0]=new re(-1,-1,-1,1);Ih[1]=new re(1,-1,-1,1);Ih[2]=new re(1,1,-1,1);Ih[3]=new re(-1,1,-1,1);Ih[4]=new re(-1,-1,1,1);Ih[5]=new re(1,-1,1,1);Ih[6]=new re(1,1,1,1);Ih[7]=new re(-1,1,1,1);var e0=new B,jq=new Array(8);for(let e=0;e<8;++e)jq[e]=new re;function Uut(e,t){let n=new xt({geometry:new ed({minimum:new m(-.5,-.5,-.5),maximum:new m(.5,.5,.5)}),attributes:{color:Ut.fromColor(t)}}),i=new xt({geometry:new Kp({radius:.5}),attributes:{color:Ut.fromColor(t)}});return new vn({geometryInstances:[n,i],appearance:new sn({translucent:!1,flat:!0}),asynchronous:!1,modelMatrix:e})}var Vut=[k.RED,k.GREEN,k.BLUE,k.MAGENTA],kut=new m;function zut(e,t){Fut(e,t);let n=e.debugFreezeFrame&&!e._debugFreezeFrame;if(e._debugFreezeFrame=e.debugFreezeFrame,e.debugFreezeFrame&&(n&&(e._debugCameraFrustum=e._debugCameraFrustum&&e._debugCameraFrustum.destroy(),e._debugCameraFrustum=new Th({camera:e._sceneCamera,color:k.CYAN,updateOnChange:!1})),e._debugCameraFrustum.update(t)),e._cascadesEnabled){if(e.debugFreezeFrame){n&&(e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=new Th({camera:e._shadowMapCamera,color:k.YELLOW,updateOnChange:!1})),e._debugLightFrustum.update(t);for(let i=0;i<e._numberOfCascades;++i)n&&(e._debugCascadeFrustums[i]=e._debugCascadeFrustums[i]&&e._debugCascadeFrustums[i].destroy(),e._debugCascadeFrustums[i]=new Th({camera:e._passes[i].camera,color:Vut[i],updateOnChange:!1})),e._debugCascadeFrustums[i].update(t)}}else if(e._isPointLight){if(!u(e._debugLightFrustum)||e._needsUpdate){let i=e._shadowMapCamera.positionWC,o=Ne.IDENTITY,r=e._pointLightRadius*2,s=m.fromElements(r,r,r,kut),a=B.fromTranslationQuaternionRotationScale(i,o,s,e0);e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=Uut(a,k.YELLOW)}e._debugLightFrustum.update(t)}else(!u(e._debugLightFrustum)||e._needsUpdate)&&(e._debugLightFrustum=new Th({camera:e._shadowMapCamera,color:k.YELLOW,updateOnChange:!1})),e._debugLightFrustum.update(t)}function Nz(){this.viewMatrix=new B,this.inverseViewMatrix=new B,this.frustum=void 0,this.positionCartographic=new he,this.positionWC=new m,this.directionWC=m.clone(m.UNIT_Z),this.upWC=m.clone(m.UNIT_Y),this.rightWC=m.clone(m.UNIT_X),this.viewProjectionMatrix=new B}Nz.prototype.clone=function(e){B.clone(e.viewMatrix,this.viewMatrix),B.clone(e.inverseViewMatrix,this.inverseViewMatrix),this.frustum=e.frustum.clone(this.frustum),he.clone(e.positionCartographic,this.positionCartographic),m.clone(e.positionWC,this.positionWC),m.clone(e.directionWC,this.directionWC),m.clone(e.upWC,this.upWC),m.clone(e.rightWC,this.rightWC)};var Hut=new B(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);Nz.prototype.getViewProjection=function(){let e=this.viewMatrix,t=this.frustum.projectionMatrix;return B.multiply(t,e,this.viewProjectionMatrix),B.multiply(Hut,this.viewProjectionMatrix,this.viewProjectionMatrix),this.viewProjectionMatrix};var Gut=new Array(5),Wut=new bi,jut=new Array(4),Gye=new m,Wye=new m;function Yut(e,t){let n=e._shadowMapCamera,i=e._sceneCamera,o=i.frustum.near,r=i.frustum.far,s=e._numberOfCascades,a,c=r-o,l=r/o,f=.9,d=!1;t.shadowState.closestObjectSize<200&&(d=!0,f=.9);let p=jut,g=Gut;for(g[0]=o,g[s]=r,a=0;a<s;++a){let N=(a+1)/s,_=o*Math.pow(l,N),b=o+c*N,v=P.lerp(b,_,f);g[a+1]=v,p[a]=v-g[a]}if(d){for(a=0;a<s;++a)p[a]=Math.min(p[a],e._maximumCascadeDistances[a]);let N=g[0];for(a=0;a<s-1;++a)N+=p[a],g[a+1]=N}re.unpack(g,0,e._cascadeSplits[0]),re.unpack(g,
uniform sampler2D u_translucentDepthTexture;
in vec2 v_textureCoordinates;
void main()
{
float opaqueDepth = texture(u_opaqueDepthTexture, v_textureCoordinates).r;
float translucentDepth = texture(u_translucentDepthTexture, v_textureCoordinates).r;
translucentDepth = czm_branchFreeTernary(translucentDepth > opaqueDepth, 1.0, translucentDepth);
out_FragColor = czm_packDepth(translucentDepth);
}
`;var hC=`uniform sampler2D colorTexture;
#ifdef DEBUG_SHOW_DEPTH
uniform sampler2D u_packedTranslucentDepth;
#endif
in vec2 v_textureCoordinates;
void main()
{
#ifdef DEBUG_SHOW_DEPTH
if (v_textureCoordinates.x < 0.5)
{
out_FragColor.rgb = vec3(czm_unpackDepth(texture(u_packedTranslucentDepth, v_textureCoordinates)));
out_FragColor.a = 1.0;
}
#else
vec4 color = texture(colorTexture, v_textureCoordinates);
#ifdef PICK
if (color == vec4(0.0))
{
discard;
}
#else
// Reverse premultiplication process to get the correct composited result of the classification primitives
color.rgb /= color.a;
#endif
out_FragColor = color;
#endif
}
`;var aft=!1;function t0(e){this._drawClassificationFBO=new mi({createDepthAttachments:!1}),this._accumulationFBO=new mi({createDepthAttachments:!1}),this._packFBO=new mi,this._opaqueDepthStencilTexture=void 0,this._textureToComposite=void 0,this._translucentDepthStencilTexture=void 0,this._packDepthCommand=void 0,this._accumulateCommand=void 0,this._compositeCommand=void 0,this._copyCommand=void 0,this._clearColorCommand=new li({color:new k(0,0,0,0),owner:this}),this._clearDepthStencilCommand=new li({depth:1,stencil:0,owner:this}),this._supported=e.depthTexture,this._viewport=new qe,this._rsDepth=void 0,this._rsAccumulate=void 0,this._rsComp=void 0,this._useScissorTest=void 0,this._scissorRectangle=void 0,this._hasTranslucentDepth=!1,this._frustumsDrawn=0}Object.defineProperties(t0.prototype,{hasTranslucentDepth:{get:function(){return this._hasTranslucentDepth}}});function qye(e){e._textureToComposite=void 0,e._translucentDepthStencilTexture=e._translucentDepthStencilTexture&&!e._translucentDepthStencilTexture.isDestroyed()&&e._translucentDepthStencilTexture.destroy()}function Xye(e){e._drawClassificationFBO.destroy(),e._accumulationFBO.destroy(),e._packFBO.destroy()}function cft(e,t,n,i){qye(e),e._translucentDepthStencilTexture=new Mt({context:t,width:n,height:i,pixelFormat:st.DEPTH_STENCIL,pixelDatatype:Ke.UNSIGNED_INT_24_8,sampler:fn.NEAREST})}function lft(e,t,n,i){Xye(e),e._drawClassificationFBO.setDepthStencilTexture(e._translucentDepthStencilTexture),e._drawClassificationFBO.update(t,n,i),e._accumulationFBO.setDepthStencilTexture(e._translucentDepthStencilTexture),e._accumulationFBO.update(t,n,i),e._packFBO.update(t,n,i)}function uft(e,t,n,i){if(!e.isSupported())return;e._opaqueDepthStencilTexture=i;let o=e._opaqueDepthStencilTexture.width,r=e._opaqueDepthStencilTexture.height;e._drawClassificationFBO.isDirty(o,r)&&(cft(e,t,o,r),lft(e,t,o,r));let s,a;if(u(e._packDepthCommand)||(s=new He({sources:[ON]}),a={u_opaqueDepthTexture:function(){return e._opaqueDepthStencilTexture},u_translucentDepthTexture:function(){return e._translucentDepthStencilTexture}},e._packDepthCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),!u(e._compositeCommand)){s=new He({sources:[hC]}),a={colorTexture:function(){return e._textureToComposite}},aft&&(s.defines=["DEBUG_SHOW_DEPTH"],a.u_packedTranslucentDepth=function(){return e._packFBO.getColorTexture()}),e._compositeCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e});let f=e._compositeCommand,d=f.shaderProgram,p=t.shaderCache.createDerivedShaderProgram(d,"pick",{vertexShaderSource:d.vertexShaderSource,fragmentShaderSource:new He({sources:s.sources,defines:["PICK"]}),attributeLocations:d._attributeLocations}),g=nt.shallowClone(f);g.shaderProgram=p,f.derivedCommands.pick=g}u(e._copyCommand)||(s=new He({sources:[hC]}),a={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._copyCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),u(e._accumulateCommand)||(s=new He({sources:[hC]}),a={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._accumulateCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),e._viewport.width=o,e._viewport.height=r;let c=!qe.equals(e._viewport,n.viewport),l=c!==e._useScissorTest;e._useScissorTest=c,qe.equals(e._scissorRectangle,n.viewport)||(e._scissorRectangle=qe.clone(n.viewport,e._scissorRectangle),l=!0),(!u(e._rsDepth)||!qe.equals(e._viewport,e._rsDepth.viewport)||l)&&(e._rsDepth=ke.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}})),u(e._packDepthCommand)&&(e._packDepthCommand.renderState=e._rsDepth),(!u(e._rsAccumulate)||!qe.equals(e._viewport,e._rsAccumulate.viewport)||l)&&(e._rsAccumulate=ke.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:zn.EQUAL,reference:Lt.CESIUM_3D_TILE_MASK}})),u(e._accumulateCommand)&&(e._accumulateCommand.renderState=e._rsAccumulate),(!u(e._rsComp)||!qe.equals(e._viewport,e._rsComp.viewport)||l)&&(e._rs
vec4 clippingPlanesEdgeColor = vec4(1.0);
clippingPlanesEdgeColor.rgb = ${n}.rgb;
float clippingPlanesEdgeWidth = ${n}.a;
if (clipDistance > 0.0 && clipDistance < clippingPlanesEdgeWidth)
{
out_FragColor = clippingPlanesEdgeColor;
}
`}var LN=Wft;var jft={modifyFragmentShader:function(t){return t=He.replaceMain(t,"czm_splitter_main"),t+=`uniform float czm_splitDirection;
void main()
{
#ifndef SHADOW_MAP
if (czm_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;
if (czm_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
#endif
czm_splitter_main();
}
`,t},addUniforms:function(t,n){n.czm_splitDirection=function(){return t.splitDirection}}},RS=jft;var _C={NEEDS_DECODE:0,DECODING:1,READY:2,FAILED:3};function NN(e){this._parsedContent=void 0,this._drawCommand=void 0,this._isTranslucent=!1,this._styleTranslucent=!1,this._constantColor=k.clone(k.DARKGRAY),this._highlightColor=k.clone(k.WHITE),this._pointSize=1,this._rtcCenter=void 0,this._quantizedVolumeScale=void 0,this._quantizedVolumeOffset=void 0,this._styleableShaderAttributes=void 0,this._isQuantized=!1,this._isOctEncoded16P=!1,this._isRGB565=!1,this._hasColors=!1,this._hasNormals=!1,this._hasBatchIds=!1,this._decodingState=_C.READY,this._dequantizeInShader=!0,this._isQuantizedDraco=!1,this._isOctEncodedDraco=!1,this._quantizedRange=0,this._octEncodedRange=0,this.backFaceCulling=!1,this._backFaceCulling=!1,this.normalShading=!0,this._normalShading=!0,this._opaqueRenderState=void 0,this._translucentRenderState=void 0,this._mode=void 0,this._ready=!1,this._pointsLength=0,this._geometryByteLength=0,this._vertexShaderLoaded=e.vertexShaderLoaded,this._fragmentShaderLoaded=e.fragmentShaderLoaded,this._uniformMapLoaded=e.uniformMapLoaded,this._batchTableLoaded=e.batchTableLoaded,this._pickIdLoaded=e.pickIdLoaded,this._opaquePass=y(e.opaquePass,be.OPAQUE),this._cull=y(e.cull,!0),this.style=void 0,this._style=void 0,this.styleDirty=!1,this.modelMatrix=B.clone(B.IDENTITY),this._modelMatrix=B.clone(B.IDENTITY),this.time=0,this.shadows=yn.ENABLED,this._boundingSphere=void 0,this.clippingPlanes=void 0,this.isClipped=!1,this.clippingPlanesDirty=!1,this.clippingPlanesOriginMatrix=void 0,this.attenuation=!1,this._attenuation=!1,this.geometricError=0,this.geometricErrorScale=1,this.maximumAttenuation=this._pointSize,this.splitDirection=y(e.splitDirection,Lc.NONE),this._splittingEnabled=!1,this._error=void 0,Yft(this,e)}Object.defineProperties(NN.prototype,{pointsLength:{get:function(){return this._pointsLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}},color:{get:function(){return k.clone(this._highlightColor)},set:function(e){this._highlightColor=k.clone(e,this._highlightColor)}},boundingSphere:{get:function(){if(u(this._drawCommand))return this._drawCommand.boundingVolume},set:function(e){this._boundingSphere=ae.clone(e,this._boundingSphere)}}});function Yft(e,t){let n=UA.parse(t.arrayBuffer,t.byteOffset);if(e._parsedContent=n,e._rtcCenter=n.rtcCenter,e._hasNormals=n.hasNormals,e._hasColors=n.hasColors,e._hasBatchIds=n.hasBatchIds,e._isTranslucent=n.isTranslucent,!n.hasBatchIds&&u(n.batchTableBinary)&&(n.styleableProperties=mp.getBinaryProperties(n.pointsLength,n.batchTableJson,n.batchTableBinary)),u(n.draco)){let a=n.draco;e._decodingState=_C.NEEDS_DECODE,a.dequantizeInShader=e._dequantizeInShader}let i=n.positions;u(i)&&(e._isQuantized=i.isQuantized,e._quantizedVolumeScale=i.quantizedVolumeScale,e._quantizedVolumeOffset=i.quantizedVolumeOffset,e._quantizedRange=i.quantizedRange);let o=n.normals;u(o)&&(e._isOctEncoded16P=o.octEncoded);let r=n.colors;u(r)&&(u(r.constantColor)&&(e._constantColor=k.clone(r.constantColor,e._constantColor),e._hasColors=!1),e._isRGB565=r.isRGB565);let s=n.batchIds;u(n.batchIds)&&(s.name="BATCH_ID",s.semantic="BATCH_ID",s.setIndex=void 0),n.hasBatchIds&&e._batchTableLoaded(n.batchLength,n.batchTableJson,n.batchTableBinary),e._pointsLength=n.pointsLength}var qft=new m,Xft=new m,Kft=new m,u0e,zz;function Jft(e){if(!u(zz)){u0e=new d0e.default(0),zz=new Array(e);for(let t=0;t<e;++t)zz[t]=u0e.random()}return zz}function Zft(e){let n=e.length/3,i=Math.min(n,20),o=Jft(20),r=Number.MAX_VALUE,s=-Number.MAX_VALUE,a=m.fromElements(r,r,r,qft),c=m.fromElements(s,s,s,Xft);for(let f=0;f<i;++f){let d=Math.floor(o[f]*n),p=m.unpack(e,d*3,Kft);m.minimumByComponent(a,p,a),m.maximumByComponent(c,p,c)}let l=ae.fromCornerPoints(a,c);return l.radius+=P.EPSILON2,l}function f0e(e,t){let n=X.fromTypedArray(e);return n===X.INT||n===X.UNSIGNED_INT||n===X.DOUBLE?(Rt("Cast pnts property to floats",`Point cloud property "${t}" will be cast to a float array because
`));let n=/czm_3dtiles_builtin_property_(\w+)/g,i=n.exec(e);for(;i!==null;){let o=i[1];t.indexOf(o)===-1&&t.push(o),i=n.exec(e)}}function Qq(e,t){let n=e.numberOfAttributes;for(let i=0;i<n;++i){let o=e.getAttribute(i);if(o.index===t)return o}}var rdt={POSITION:"czm_3dtiles_builtin_property_POSITION",POSITION_ABSOLUTE:"czm_3dtiles_builtin_property_POSITION_ABSOLUTE",COLOR:"czm_3dtiles_builtin_property_COLOR",NORMAL:"czm_3dtiles_builtin_property_NORMAL"};function sdt(e,t,n){let i,o,r,s=t.context,a=u(n),c=e._isQuantized,l=e._isQuantizedDraco,f=e._isOctEncoded16P,d=e._isOctEncodedDraco,p=e._isRGB565,g=e._isTranslucent,h=e._hasColors,A=e._hasNormals,x=e._hasBatchIds,C=e._backFaceCulling,T=e._normalShading,E=e._drawCommand.vertexArray,S=e.clippingPlanes,w=e._attenuation,D,M,O,L=g,N=je(rdt),_={},b=e._styleableShaderAttributes;for(o in b)b.hasOwnProperty(o)&&(r=b[o],N[o]=`czm_3dtiles_property_${r.location}`,_[r.location]=r);if(a){let se={translucent:!1},xe="(vec3 czm_3dtiles_builtin_property_POSITION, vec3 czm_3dtiles_builtin_property_POSITION_ABSOLUTE, vec4 czm_3dtiles_builtin_property_COLOR, vec3 czm_3dtiles_builtin_property_NORMAL)";D=n.getColorShaderFunction(`getColorFromStyle${xe}`,N,se),M=n.getShowShaderFunction(`getShowFromStyle${xe}`,N,se),O=n.getPointSizeShaderFunction(`getPointSizeFromStyle${xe}`,N,se),u(D)&&se.translucent&&(L=!0)}e._styleTranslucent=L;let v=u(D),I=u(M),R=u(O),F=e.isClipped,z=[],V=[];v&&(Jq(D,z),Zq(D,V)),I&&(Jq(M,z),Zq(M,V)),R&&(Jq(O,z),Zq(O,V));let G=V.indexOf("COLOR")>=0,U=V.indexOf("NORMAL")>=0;if(U&&!A)throw new de("Style references the NORMAL semantic but the point cloud does not have normals");for(o in b)if(b.hasOwnProperty(o)){r=b[o];let se=z.indexOf(r.location)>=0,xe=Qq(E,r.location);xe.enabled=se}let q=h&&(!v||G);if(h){let se=Qq(E,Hz);se.enabled=q}let Y=A&&(T||C||U);if(A){let se=Qq(E,$q);se.enabled=Y}let Q={a_position:m0e};q&&(Q.a_color=Hz),Y&&(Q.a_normal=$q),x&&(Q.a_batchId=h0e);let W="",K=z.length;for(i=0;i<K;++i){let se=z[i];r=_[se];let xe=r.componentCount,me=`czm_3dtiles_property_${se}`,ve;xe===1?ve="float":ve=`vec${xe}`,W+=`in ${ve} ${me};
`,Q[me]=r.location}odt(e,t);let J=`in vec3 a_position;
out vec4 v_color;
uniform vec4 u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier;
uniform vec4 u_constantColor;
uniform vec4 u_highlightColor;
`;J+=`float u_pointSize;
float tiles3d_tileset_time;
`,w&&(J+=`float u_geometricError;
float u_depthMultiplier;
`),J+=W,q&&(g?J+=`in vec4 a_color;
`:p?J+=`in float a_color;
const float SHIFT_RIGHT_11 = 1.0 / 2048.0;
const float SHIFT_RIGHT_5 = 1.0 / 32.0;
const float SHIFT_LEFT_11 = 2048.0;
const float SHIFT_LEFT_5 = 32.0;
const float NORMALIZE_6 = 1.0 / 64.0;
const float NORMALIZE_5 = 1.0 / 32.0;
`:J+=`in vec3 a_color;
`),Y&&(f||d?J+=`in vec2 a_normal;
`:J+=`in vec3 a_normal;
`),x&&(J+=`in float a_batchId;
`),(c||l||d)&&(J+=`uniform vec4 u_quantizedVolumeScaleAndOctEncodedRange;
`),v&&(J+=D),I&&(J+=M),R&&(J+=O),J+=`void main()
{
u_pointSize = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.x;
tiles3d_tileset_time = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.y;
`,w&&(J+=` u_geometricError = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.z;
u_depthMultiplier = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.w;
`),q?g?J+=` vec4 color = a_color;
`:p?J+=` float compressed = a_color;
float r = floor(compressed * SHIFT_RIGHT_11);
compressed -= r * SHIFT_LEFT_11;
float g = floor(compressed * SHIFT_RIGHT_5);
compressed -= g * SHIFT_LEFT_5;
float b = compressed;
vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);
vec4 color = vec4(rgb, 1.0);
`:J+=` vec4 color = vec4(a_color, 1.0);
`:J+=` vec4 color = u_constantColor;
`,c||l?J+=` vec3 position = a_position * u_quantizedVolumeScaleAndOctEncodedRange.xyz;
`:J+=` vec3 position = a_position;
`,J+=` vec3 position_absolute = vec3(czm_model * vec4(position, 1.0));
`,Y?(f?J+=` vec3 normal = czm_octDecode(a_normal);
`:d?J+=` vec3 normal = czm_octDecode(a_normal, u_quantizedVolumeScaleAndOctEncodedRange.w).zxy;
`:J+=` vec3 normal = a_normal;
`,J+=` vec3 normalEC = czm_normal * normal;
`):J+=` vec3 normal = vec3(1.0);
`,v&&(J+=` color = getColorFromStyle(position, position_absolute, color, normal);
`),I&&(J+=` float show = float(getShowFromStyle(position, position_absolute, color, normal));
`),R?J+=` gl_PointSize = getPointSizeFromStyle(position, position_absolute, color, normal) * czm_pixelRatio;
`:w?J+=` vec4 positionEC = czm_modelView * vec4(position, 1.0);
float depth = -positionEC.z;
gl_PointSize = min((u_geometricError / depth) * u_depthMultiplier, u_pointSize);
`:J+=` gl_PointSize = u_pointSize;
`,J+=` color = color * u_highlightColor;
`,Y&&T&&(J+=` float diffuseStrength = czm_getLambertDiffuse(czm_lightDirectionEC, normalEC);
diffuseStrength = max(diffuseStrength, 0.4);
color.xyz *= diffuseStrength * czm_lightColor;
`),J+=` v_color = color;
gl_Position = czm_modelViewProjection * vec4(position, 1.0);
`,Y&&C&&(J+=` float visible = step(-normalEC.z, 0.0);
gl_Position *= visible;
gl_PointSize *= visible;
`),I&&(J+=` gl_Position.w *= float(show);
gl_PointSize *= float(show);
`),J+=`}
`;let ge=`in vec4 v_color;
`;F&&(ge+=`uniform highp sampler2D u_clippingPlanes;
uniform mat4 u_clippingPlanesMatrix;
uniform vec4 u_clippingPlanesEdgeStyle;
`,ge+=`
`,ge+=M_(S,s),ge+=`
`),ge+=`void main()
{
out_FragColor = czm_gammaCorrect(v_color);
`,F&&(ge+=LN("u_clippingPlanes","u_clippingPlanesMatrix","u_clippingPlanesEdgeStyle")),ge+=`}
`,e.splitDirection!==Lc.NONE&&(ge=RS.modifyFragmentShader(ge)),u(e._vertexShaderLoaded)&&(J=e._vertexShaderLoaded(J)),u(e._fragmentShaderLoaded)&&(ge=e._fragmentShaderLoaded(ge));let Ce=e._drawCommand;u(Ce.shaderProgram)&&Ce.shaderProgram.destroy(),Ce.shaderProgram=Jt.fromCache({context:s,vertexShaderSource:J,fragmentShaderSource:ge,attributeLocations:Q});try{Ce.shaderProgram._bind()}catch{throw new de("Error generating style shader: this may be caused by a type mismatch, index out-of-bounds, or other syntax error.")}}function adt(e,t){if(e._decodingState===_C.READY)return!1;if(e._decodingState===_C.NEEDS_DECODE){let n=e._parsedContent,i=n.draco,o=Cp.decodePointCloud(i,t);u(o)&&(e._decodingState=_C.DECODING,o.then(function(r){e._decodingState=_C.READY;let s=u(r.POSITION)?r.POSITION.array:void 0,a=u(r.RGB)?r.RGB.array:void 0,c=u(r.RGBA)?r.RGBA.array:void 0,l=u(r.NORMAL)?r.NORMAL.array:void 0,f=u(r.BATCH_ID)?r.BATCH_ID.array:void 0,d=u(s)&&u(r.POSITION.data.quantization),p=u(l)&&u(r.NORMAL.data.quantization);if(d){let x=r.POSITION.data.quantization,C=x.range;e._quantizedVolumeScale=m.fromElements(C,C,C),e._quantizedVolumeOffset=m.unpack(x.minValues),e._quantizedRange=(1<<x.quantizationBits)-1,e._isQuantizedDraco=!0}p&&(e._octEncodedRange=(1<<r.NORMAL.data.quantization.quantizationBits)-1,e._isOctEncodedDraco=!0);let g=n.styleableProperties,h=i.batchTableProperties;for(let x in h)if(h.hasOwnProperty(x)){let C=r[x];u(g)||(g={}),g[x]={typedArray:C.array,componentCount:C.data.componentsPerAttribute}}u(s)&&(n.positions={typedArray:s});let A=y(c,a);u(A)&&(n.colors={typedArray:A}),u(l)&&(n.normals={typedArray:l}),u(f)&&(n.batchIds={typedArray:f}),n.styleableProperties=g}).catch(function(r){e._decodingState=_C.FAILED,e._error=r}))}return!0}var cdt=new re,ldt=new m;NN.prototype.update=function(e){let t=e.context;if(u(this._error)){let l=this._error;throw this._error=void 0,l}if(adt(this,t))return;let i=!1,o=!B.equals(this._modelMatrix,this.modelMatrix);if(this._mode!==e.mode&&(this._mode=e.mode,o=!0),u(this._drawCommand)||(idt(this,e),o=!0,i=!0,this._ready=!0,this._parsedContent=void 0),o){B.clone(this.modelMatrix,this._modelMatrix);let l=this._drawCommand.modelMatrix;if(B.clone(this._modelMatrix,l),u(this._rtcCenter)&&B.multiplyByTranslation(l,this._rtcCenter,l),u(this._quantizedVolumeOffset)&&B.multiplyByTranslation(l,this._quantizedVolumeOffset,l),e.mode!==ne.SCENE3D){let d=e.mapProjection,p=B.getColumn(l,3,cdt);re.equals(p,re.UNIT_W)||Ot.basisTo2D(d,l,l)}let f=this._drawCommand.boundingVolume;if(ae.clone(this._boundingSphere,f),this._cull){let d=f.center;B.multiplyByPoint(l,d,d);let p=B.getScale(l,ldt);f.radius*=m.maximumComponent(p)}}this.clippingPlanesDirty&&(this.clippingPlanesDirty=!1,i=!0),this._attenuation!==this.attenuation&&(this._attenuation=this.attenuation,i=!0),this.backFaceCulling!==this._backFaceCulling&&(this._backFaceCulling=this.backFaceCulling,i=!0),this.normalShading!==this._normalShading&&(this._normalShading=this.normalShading,i=!0),(this._style!==this.style||this.styleDirty)&&(this._style=this.style,this.styleDirty=!1,i=!0);let r=this.splitDirection!==Lc.NONE;this._splittingEnabled!==r&&(this._splittingEnabled=r,i=!0),i&&sdt(this,e,this._style),this._drawCommand.castShadows=yn.castShadows(this.shadows),this._drawCommand.receiveShadows=yn.receiveShadows(this.shadows);let s=this._highlightColor.alpha<1||this._constantColor.alpha<1||this._styleTranslucent;this._drawCommand.renderState=s?this._translucentRenderState:this._opaqueRenderState,this._drawCommand.pass=s?be.TRANSLUCENT:this._opaquePass;let a=e.commandList,c=e.passes;(c.render||c.pick)&&a.push(this._drawCommand)};NN.prototype.isDestroyed=function(){return!1};NN.prototype.destroy=function(){let e=this._drawCommand;return u(e)&&(e.vertexArray=e.vertexArray&&e.vertexArray.destroy(),e.shaderProgram=e.shaderProgram&&e.shaderProgram.destroy()),ue(this)};var FN=NN;var udt={NEAREST:0,LINEAR:1},Fu=udt;function gC(e){e=y(e,y.EMPTY_OBJECT);let t=e.fragmentShader,n=y(e.textureScale,1),i=y(e.pixelFormat,st.RGBA);this._fragmentShader=t,this._uniforms=e.uniforms,th
uniform sampler2D czm_idTexture;
uniform sampler2D czm_selectedIdTexture;
uniform float czm_selectedIdTextureStep;
in vec2 v_textureCoordinates;
bool czm_selected(vec2 offset)
{
bool selected = false;
vec4 id = texture(czm_idTexture, v_textureCoordinates + offset);
for (int i = 0; i < ${o}; ++i)
{
vec4 selectedId = texture(czm_selectedIdTexture, vec2((float(i) + 0.5) * czm_selectedIdTextureStep, 0.5));
if (all(equal(id, selectedId)))
{
return true;
}
}
return false;
}
bool czm_selected()
{
return czm_selected(vec2(0.0));
}
${n}`}let i=new He({defines:[e._useLogDepth?"LOG_DEPTH":""],sources:[n]});e._command=t.createViewportQuadCommand(i,{uniformMap:e._uniformMap,owner:e})}function gdt(e){let t=e._sampleMode,n,i;t===Fu.LINEAR?(n=cn.LINEAR,i=xi.LINEAR):(n=cn.NEAREST,i=xi.NEAREST);let o=e._sampler;(!u(o)||o.minificationFilter!==n||o.magnificationFilter!==i)&&(e._sampler=new fn({wrapS:wn.CLAMP_TO_EDGE,wrapT:wn.CLAMP_TO_EDGE,minificationFilter:n,magnificationFilter:i}))}function ydt(e,t){return function(n){e._texturesToCreate.push({name:t,source:n})}}function Adt(e,t){return function(){return e._textureCache.getOutputTexture(t)}}function xdt(e,t){let n,i,o,r=e._texturesToRelease,s=r.length;for(n=0;n<s;++n)i=r[n],i=i&&i.destroy();r.length=0;let a=e._texturesToCreate;for(s=a.length,n=0;n<s;++n){let d=a[n];o=d.name;let p=d.source;e._actualUniforms[o]=new Mt({context:t,source:p})}a.length=0;let c=e._dirtyUniforms;if(c.length===0&&!u(e._texturePromise)){e._ready=!0;return}if(c.length===0||u(e._texturePromise))return;s=c.length;let l=e._uniforms,f=[];for(n=0;n<s;++n){o=c[n];let d=l[o],p=e._textureCache.getStageByName(d);if(u(p))e._actualUniforms[o]=Adt(e,d);else if(typeof d=="string"){let g=new Ie({url:d});f.push(g.fetchImage().then(ydt(e,o)))}else e._texturesToCreate.push({name:o,source:d})}c.length=0,f.length>0?(e._ready=!1,e._texturePromise=Promise.all(f).then(function(){e._ready=!0,e._texturePromise=void 0})):e._ready=!0}function p0e(e){u(e._command)&&(e._command.shaderProgram=e._command.shaderProgram&&e._command.shaderProgram.destroy(),e._command=void 0),e._selectedIdTexture=e._selectedIdTexture&&e._selectedIdTexture.destroy();let t=e._textureCache;if(!u(t))return;let n=e._uniforms,i=e._actualUniforms;for(let o in i)i.hasOwnProperty(o)&&i[o]instanceof Mt&&(u(t.getStageByName(n[o]))||i[o].destroy(),e._dirtyUniforms.push(o))}function Cdt(e){let t=u(e._selected)?e._selected.length:0,n=u(e._parentSelected)?e._parentSelected:0,i=e._selected!==e._selectedShadow||t!==e._selectedLength;if(i=i||e._parentSelected!==e._parentSelectedShadow||n!==e._parentSelectedLength,u(e._selected)&&u(e._parentSelected)?e._combinedSelected=e._selected.concat(e._parentSelected):u(e._parentSelected)?e._combinedSelected=e._parentSelected:e._combinedSelected=e._selected,!i&&u(e._combinedSelected)){if(!u(e._combinedSelectedShadow))return!0;t=e._combinedSelected.length;for(let o=0;o<t;++o)if(e._combinedSelected[o]!==e._combinedSelectedShadow[o])return!0}return i}function Tdt(e,t){if(!e._selectedDirty)return;e._selectedIdTexture=e._selectedIdTexture&&e._selectedIdTexture.destroy(),e._selectedIdTexture=void 0;let n=e._combinedSelected;if(!u(n))return;let i,o,r=0,s=n.length;for(i=0;i<s;++i)o=n[i],u(o.pickIds)?r+=o.pickIds.length:u(o.pickId)&&++r;if(s===0||r===0){let f=new Uint8Array(4);f[0]=255,f[1]=255,f[2]=255,f[3]=255,e._selectedIdTexture=new Mt({context:t,pixelFormat:st.RGBA,pixelDatatype:Ke.UNSIGNED_BYTE,source:{arrayBufferView:f,width:1,height:1},sampler:fn.NEAREST});return}let a,c=0,l=new Uint8Array(r*4);for(i=0;i<s;++i)if(o=n[i],u(o.pickIds)){let f=o.pickIds,d=f.length;for(let p=0;p<d;++p)a=f[p].color,l[c]=k.floatToByte(a.red),l[c+1]=k.floatToByte(a.green),l[c+2]=k.floatToByte(a.blue),l[c+3]=k.floatToByte(a.alpha),c+=4}else u(o.pickId)&&(a=o.pickId.color,l[c]=k.floatToByte(a.red),l[c+1]=k.floatToByte(a.green),l[c+2]=k.floatToByte(a.blue),l[c+3]=k.floatToByte(a.alpha),c+=4);e._selectedIdTexture=new Mt({context:t,pixelFormat:st.RGBA,pixelDatatype:Ke.UNSIGNED_BYTE,source:{arrayBufferView:l,width:r,height:1},sampler:fn.NEAREST})}gC.prototype.update=function(e,t){if(this.enabled!==this._enabled&&!this.enabled&&p0e(this),this._enabled=this.enabled,!this._enabled||(this._logDepthChanged=t!==this._useLogDepth,this._useLogDepth=t,this._selectedDirty=Cdt(this),this._selectedShadow=this._selected,this._parentSelectedShadow=this._parentSelected,this._combinedSelectedShadow=this._combinedSelected,this._selectedLength=u(this._selected)?this._selected.length:0,this._parentSelectedLength=u(this._parentSelected)?this._parentSelected.length:0,Tdt(this,e),pdt(this),xdt(this,e),_dt(this,e),gd
in vec2 v_textureCoordinates;
#ifdef AUTO_EXPOSURE
uniform sampler2D autoExposure;
#endif
void main()
{
vec4 fragmentColor = texture(colorTexture, v_textureCoordinates);
vec3 color = fragmentColor.rgb;
#ifdef AUTO_EXPOSURE
color /= texture(autoExposure, vec2(0.5)).r;
#endif
color = czm_acesTonemapping(color);
color = czm_inverseGamma(color);
out_FragColor = vec4(color, fragmentColor.a);
}
`;var VN=`uniform sampler2D randomTexture;
uniform sampler2D depthTexture;
uniform float intensity;
uniform float bias;
uniform float lengthCap;
uniform float stepSize;
uniform float frustumLength;
in vec2 v_textureCoordinates;
vec4 clipToEye(vec2 uv, float depth)
{
vec2 xy = vec2((uv.x * 2.0 - 1.0), ((1.0 - uv.y) * 2.0 - 1.0));
vec4 posEC = czm_inverseProjection * vec4(xy, depth, 1.0);
posEC = posEC / posEC.w;
return posEC;
}
//Reconstruct Normal Without Edge Removation
vec3 getNormalXEdge(vec3 posInCamera, float depthU, float depthD, float depthL, float depthR, vec2 pixelSize)
{
vec4 posInCameraUp = clipToEye(v_textureCoordinates - vec2(0.0, pixelSize.y), depthU);
vec4 posInCameraDown = clipToEye(v_textureCoordinates + vec2(0.0, pixelSize.y), depthD);
vec4 posInCameraLeft = clipToEye(v_textureCoordinates - vec2(pixelSize.x, 0.0), depthL);
vec4 posInCameraRight = clipToEye(v_textureCoordinates + vec2(pixelSize.x, 0.0), depthR);
vec3 up = posInCamera.xyz - posInCameraUp.xyz;
vec3 down = posInCameraDown.xyz - posInCamera.xyz;
vec3 left = posInCamera.xyz - posInCameraLeft.xyz;
vec3 right = posInCameraRight.xyz - posInCamera.xyz;
vec3 DX = length(left) < length(right) ? left : right;
vec3 DY = length(up) < length(down) ? up : down;
return normalize(cross(DY, DX));
}
void main(void)
{
float depth = czm_readDepth(depthTexture, v_textureCoordinates);
vec4 posInCamera = clipToEye(v_textureCoordinates, depth);
if (posInCamera.z > frustumLength)
{
out_FragColor = vec4(1.0);
return;
}
vec2 pixelSize = czm_pixelRatio / czm_viewport.zw;
float depthU = czm_readDepth(depthTexture, v_textureCoordinates - vec2(0.0, pixelSize.y));
float depthD = czm_readDepth(depthTexture, v_textureCoordinates + vec2(0.0, pixelSize.y));
float depthL = czm_readDepth(depthTexture, v_textureCoordinates - vec2(pixelSize.x, 0.0));
float depthR = czm_readDepth(depthTexture, v_textureCoordinates + vec2(pixelSize.x, 0.0));
vec3 normalInCamera = getNormalXEdge(posInCamera.xyz, depthU, depthD, depthL, depthR, pixelSize);
float ao = 0.0;
vec2 sampleDirection = vec2(1.0, 0.0);
float gapAngle = 90.0 * czm_radiansPerDegree;
// RandomNoise
float randomVal = texture(randomTexture, v_textureCoordinates).x;
//Loop for each direction
for (int i = 0; i < 4; i++)
{
float newGapAngle = gapAngle * (float(i) + randomVal);
float cosVal = cos(newGapAngle);
float sinVal = sin(newGapAngle);
//Rotate Sampling Direction
vec2 rotatedSampleDirection = vec2(cosVal * sampleDirection.x - sinVal * sampleDirection.y, sinVal * sampleDirection.x + cosVal * sampleDirection.y);
float localAO = 0.0;
float localStepSize = stepSize;
//Loop for each step
for (int j = 0; j < 6; j++)
{
vec2 newCoords = v_textureCoordinates + rotatedSampleDirection * localStepSize * pixelSize;
//Exception Handling
if(newCoords.x > 1.0 || newCoords.y > 1.0 || newCoords.x < 0.0 || newCoords.y < 0.0)
{
break;
}
float stepDepthInfo = czm_readDepth(depthTexture, newCoords);
vec4 stepPosInCamera = clipToEye(newCoords, stepDepthInfo);
vec3 diffVec = stepPosInCamera.xyz - posInCamera.xyz;
float len = length(diffVec);
if (len > lengthCap)
{
break;
}
float dotVal = clamp(dot(normalInCamera, normalize(diffVec)), 0.0, 1.0 );
float weight = len / lengthCap;
weight = 1.0 - weight * weight;
if (dotVal < bias)
{
dotVal = 0.0;
}
localAO = max(localAO, dotVal * weight);
localStepSize += stepSize;
}
ao += localAO;
}
ao /= 4.0;
ao = 1.0 - clamp(ao, 0.0, 1.0);
ao = pow(ao, intensity);
out_FragColor = vec4(vec3(ao), 1.0);
}
`;var kN=`uniform sampler2D colorTexture;
uniform sampler2D ambientOcclusionTexture;
uniform bool ambientOcclusionOnly;
in vec2 v_textureCoordinates;
void main(void)
{
vec3 color = texture(colorTexture, v_textureCoordinates).rgb;
vec3 ao = texture(ambientOcclusionTexture, v_textureCoordinates).rgb;
out_FragColor.rgb = ambientOcclusionOnly ? ao : ao * color;
}
`;var zN=`uniform sampler2D colorTexture;
uniform float gradations;
in vec2 v_textureCoordinates;
void main(void)
{
vec3 rgb = texture(colorTexture, v_textureCoordinates).rgb;
#ifdef CZM_SELECTED_FEATURE
if (czm_selected()) {
out_FragColor = vec4(rgb, 1.0);
return;
}
#endif
float luminance = czm_luminance(rgb);
float darkness = luminance * gradations;
darkness = (darkness - fract(darkness)) / gradations;
out_FragColor = vec4(vec3(darkness), 1.0);
}
`;var HN=`uniform sampler2D colorTexture;
uniform sampler2D bloomTexture;
uniform bool glowOnly;
in vec2 v_textureCoordinates;
void main(void)
{
vec4 color = texture(colorTexture, v_textureCoordinates);
#ifdef CZM_SELECTED_FEATURE
if (czm_selected()) {
out_FragColor = color;
return;
}
#endif
vec4 bloom = texture(bloomTexture, v_textureCoordinates);
out_FragColor = glowOnly ? bloom : bloom + color;
}
`;var GN=`uniform sampler2D colorTexture;
uniform float brightness;
in vec2 v_textureCoordinates;
void main(void)
{
vec3 rgb = texture(colorTexture, v_textureCoordinates).rgb;
vec3 target = vec3(0.0);
out_FragColor = vec4(mix(target, rgb, brightness), 1.0);
}
`;var WN=`uniform sampler2D colorTexture;
uniform float contrast;
uniform float brightness;
in vec2 v_textureCoordinates;
void main(void)
{
vec3 sceneColor = texture(colorTexture, v_textureCoordinates).xyz;
sceneColor = czm_RGBToHSB(sceneColor);
sceneColor.z += brightness;
sceneColor = czm_HSBToRGB(sceneColor);
float factor = (259.0 * (contrast + 255.0)) / (255.0 * (259.0 - contrast));
sceneColor = factor * (sceneColor - vec3(0.5)) + vec3(0.5);
out_FragColor = vec4(sceneColor, 1.0);
}
`;var jN=`uniform sampler2D colorTexture;
uniform sampler2D blurTexture;
uniform sampler2D depthTexture;
uniform float focalDistance;
in vec2 v_textureCoordinates;
vec4 toEye(vec2 uv, float depth)
{
vec2 xy = vec2((uv.x * 2.0 - 1.0), ((1.0 - uv.y) * 2.0 - 1.0));
vec4 posInCamera = czm_inverseProjection * vec4(xy, depth, 1.0);
posInCamera = posInCamera / posInCamera.w;
return posInCamera;
}
float computeDepthBlur(float depth)
{
float f;
if (depth < focalDistance)
{
f = (focalDistance - depth) / (focalDistance - czm_currentFrustum.x);
}
else
{
f = (depth - focalDistance) / (czm_currentFrustum.y - focalDistance);
f = pow(f, 0.1);
}
f *= f;
f = clamp(f, 0.0, 1.0);
return pow(f, 0.5);
}
void main(void)
{
float depth = czm_readDepth(depthTexture, v_textureCoordinates);
vec4 posInCamera = toEye(v_textureCoordinates, depth);
float d = computeDepthBlur(-posInCamera.z);
out_FragColor = mix(texture(colorTexture, v_textureCoordinates), texture(blurTexture, v_textureCoordinates), d);
}
`;var YN=`uniform sampler2D depthTexture;
in vec2 v_textureCoordinates;
void main(void)
{
float depth = czm_readDepth(depthTexture, v_textureCoordinates);
out_FragColor = vec4(vec3(depth), 1.0);
}
`;var qN=`uniform sampler2D depthTexture;
uniform float length;
uniform vec4 color;
in vec2 v_textureCoordinates;
void main(void)
{
float directions[3];
directions[0] = -1.0;
directions[1] = 0.0;
directions[2] = 1.0;
float scalars[3];
scalars[0] = 3.0;
scalars[1] = 10.0;
scalars[2] = 3.0;
float padx = czm_pixelRatio / czm_viewport.z;
float pady = czm_pixelRatio / czm_viewport.w;
#ifdef CZM_SELECTED_FEATURE
bool selected = false;
for (int i = 0; i < 3; ++i)
{
float dir = directions[i];
selected = selected || czm_selected(vec2(-padx, dir * pady));
selected = selected || czm_selected(vec2(padx, dir * pady));
selected = selected || czm_selected(vec2(dir * padx, -pady));
selected = selected || czm_selected(vec2(dir * padx, pady));
if (selected)
{
break;
}
}
if (!selected)
{
out_FragColor = vec4(color.rgb, 0.0);
return;
}
#endif
float horizEdge = 0.0;
float vertEdge = 0.0;
for (int i = 0; i < 3; ++i)
{
float dir = directions[i];
float scale = scalars[i];
horizEdge -= texture(depthTexture, v_textureCoordinates + vec2(-padx, dir * pady)).x * scale;
horizEdge += texture(depthTexture, v_textureCoordinates + vec2(padx, dir * pady)).x * scale;
vertEdge -= texture(depthTexture, v_textureCoordinates + vec2(dir * padx, -pady)).x * scale;
vertEdge += texture(depthTexture, v_textureCoordinates + vec2(dir * padx, pady)).x * scale;
}
float len = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);
out_FragColor = vec4(color.rgb, len > length ? color.a : 0.0);
}
`;var XN=`uniform sampler2D colorTexture;
in vec2 v_textureCoordinates;
#ifdef AUTO_EXPOSURE
uniform sampler2D autoExposure;
#endif
// See slides 142 and 143:
// http://www.gdcvault.com/play/1012459/Uncharted_2__HDR_Lighting
void main()
{
vec4 fragmentColor = texture(colorTexture, v_textureCoordinates);
vec3 color = fragmentColor.rgb;
#ifdef AUTO_EXPOSURE
float exposure = texture(autoExposure, vec2(0.5)).r;
color /= exposure;
#endif
const float A = 0.22; // shoulder strength
const float B = 0.30; // linear strength
const float C = 0.10; // linear angle
const float D = 0.20; // toe strength
const float E = 0.01; // toe numerator
const float F = 0.30; // toe denominator
const float white = 11.2; // linear white point value
vec3 c = ((color * (A * color + C * B) + D * E) / (color * ( A * color + B) + D * F)) - E / F;
float w = ((white * (A * white + C * B) + D * E) / (white * ( A * white + B) + D * F)) - E / F;
c = czm_inverseGamma(c / w);
out_FragColor = vec4(c, fragmentColor.a);
}
`;var KN=`in vec2 v_textureCoordinates;
uniform sampler2D colorTexture;
const float fxaaQualitySubpix = 0.5;
const float fxaaQualityEdgeThreshold = 0.125;
const float fxaaQualityEdgeThresholdMin = 0.0833;
void main()
{
vec2 fxaaQualityRcpFrame = vec2(1.0) / czm_viewport.zw;
vec4 color = FxaaPixelShader(
v_textureCoordinates,
colorTexture,
fxaaQualityRcpFrame,
fxaaQualitySubpix,
fxaaQualityEdgeThreshold,
fxaaQualityEdgeThresholdMin);
float alpha = texture(colorTexture, v_textureCoordinates).a;
out_FragColor = vec4(color.rgb, alpha);
}
`;var n0=`#define SAMPLES 8
uniform float delta;
uniform float sigma;
uniform float direction; // 0.0 for x direction, 1.0 for y direction
uniform sampler2D colorTexture;
#ifdef USE_STEP_SIZE
uniform float stepSize;
#else
uniform vec2 step;
#endif
in vec2 v_textureCoordinates;
// Incremental Computation of the Gaussian:
// https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch40.html
void main()
{
vec2 st = v_textureCoordinates;
vec2 dir = vec2(1.0 - direction, direction);
#ifdef USE_STEP_SIZE
vec2 step = vec2(stepSize * (czm_pixelRatio / czm_viewport.zw));
#else
vec2 step = step;
#endif
vec3 g;
g.x = 1.0 / (sqrt(czm_twoPi) * sigma);
g.y = exp((-0.5 * delta * delta) / (sigma * sigma));
g.z = g.y * g.y;
vec4 result = texture(colorTexture, st) * g.x;
for (int i = 1; i < SAMPLES; ++i)
{
g.xy *= g.yz;
vec2 offset = float(i) * dir * step;
result += texture(colorTexture, st - offset) * g.x;
result += texture(colorTexture, st + offset) * g.x;
}
out_FragColor = result;
}
`;var JN=`uniform sampler2D colorTexture;
uniform sampler2D dirtTexture;
uniform sampler2D starTexture;
uniform vec2 dirtTextureDimensions;
uniform float distortion;
uniform float ghostDispersal;
uniform float haloWidth;
uniform float dirtAmount;
uniform float earthRadius;
uniform float intensity;
in vec2 v_textureCoordinates;
// whether it is in space or not
// 6500000.0 is empirical value
#define DISTANCE_TO_SPACE 6500000.0
// return ndc from world coordinate biased earthRadius
vec4 getNDCFromWC(vec3 WC, float earthRadius)
{
vec4 positionEC = czm_view * vec4(WC, 1.0);
positionEC = vec4(positionEC.x + earthRadius, positionEC.y, positionEC.z, 1.0);
vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);
return czm_viewportOrthographic * vec4(positionWC.xy, -positionWC.z, 1.0);
}
// Check if current pixel is included Earth
// if then mask it gradually
float isInEarth(vec2 texcoord, vec2 sceneSize)
{
vec2 NDC = texcoord * 2.0 - 1.0;
vec4 earthPosSC = getNDCFromWC(vec3(0.0), 0.0);
vec4 earthPosSCEdge = getNDCFromWC(vec3(0.0), earthRadius * 1.5);
NDC.xy -= earthPosSC.xy;
float X = abs(NDC.x) * sceneSize.x;
float Y = abs(NDC.y) * sceneSize.y;
return clamp(0.0, 1.0, max(sqrt(X * X + Y * Y) / max(abs(earthPosSCEdge.x * sceneSize.x), 1.0) - 0.8 , 0.0));
}
// For Chromatic effect
vec4 textureDistorted(sampler2D tex, vec2 texcoord, vec2 direction, vec3 distortion, bool isSpace)
{
vec2 sceneSize = czm_viewport.zw;
vec3 color;
if(isSpace)
{
color.r = isInEarth(texcoord + direction * distortion.r, sceneSize) * texture(tex, texcoord + direction * distortion.r).r;
color.g = isInEarth(texcoord + direction * distortion.g, sceneSize) * texture(tex, texcoord + direction * distortion.g).g;
color.b = isInEarth(texcoord + direction * distortion.b, sceneSize) * texture(tex, texcoord + direction * distortion.b).b;
}
else
{
color.r = texture(tex, texcoord + direction * distortion.r).r;
color.g = texture(tex, texcoord + direction * distortion.g).g;
color.b = texture(tex, texcoord + direction * distortion.b).b;
}
return vec4(clamp(color, 0.0, 1.0), 0.0);
}
void main(void)
{
vec4 originalColor = texture(colorTexture, v_textureCoordinates);
vec3 rgb = originalColor.rgb;
bool isSpace = length(czm_viewerPositionWC.xyz) > DISTANCE_TO_SPACE;
// Sun position
vec4 sunPos = czm_morphTime == 1.0 ? vec4(czm_sunPositionWC, 1.0) : vec4(czm_sunPositionColumbusView.zxy, 1.0);
vec4 sunPositionEC = czm_view * sunPos;
vec4 sunPositionWC = czm_eyeToWindowCoordinates(sunPositionEC);
sunPos = czm_viewportOrthographic * vec4(sunPositionWC.xy, -sunPositionWC.z, 1.0);
// If sun is not in the screen space, use original color.
if(!isSpace || !((sunPos.x >= -1.1 && sunPos.x <= 1.1) && (sunPos.y >= -1.1 && sunPos.y <= 1.1)))
{
// Lens flare is disabled when not in space until #5932 is fixed.
// https://github.com/CesiumGS/cesium/issues/5932
out_FragColor = originalColor;
return;
}
vec2 texcoord = vec2(1.0) - v_textureCoordinates;
vec2 pixelSize = czm_pixelRatio / czm_viewport.zw;
vec2 invPixelSize = 1.0 / pixelSize;
vec3 distortionVec = pixelSize.x * vec3(-distortion, 0.0, distortion);
// ghost vector to image centre:
vec2 ghostVec = (vec2(0.5) - texcoord) * ghostDispersal;
vec3 direction = normalize(vec3(ghostVec, 0.0));
// sample ghosts:
vec4 result = vec4(0.0);
vec4 ghost = vec4(0.0);
for (int i = 0; i < 4; ++i)
{
vec2 offset = fract(texcoord + ghostVec * float(i));
// Only bright spots from the centre of the source image
ghost += textureDistorted(colorTexture, offset, direction.xy, distortionVec, isSpace);
}
result += ghost;
// sample halo
vec2 haloVec = normalize(ghostVec) * haloWidth;
float weightForHalo = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));
weightForHalo = pow(1.0 - weightForHalo, 5.0);
result += textureDistorted(colorTexture, texcoord + haloVec, direction.xy, distortionVec, isSpace) * weightForHalo * 1.5;
// dirt on lens
vec2 dirtTexCoords = (v_textureCoordinates * invPixelSize) / dirtTextureDimensions;
if (dirtTexCoords.x > 1.0)
{
dirtTexCoords.x = mod(floor(dirtTexCoords.x), 2.0) == 1.0 ? 1.0 - fract(dirtTexCoords.x) : fract(dirtTexCoords.x);
}
if (dirtTexCoords.y > 1.0)
{
dirtTexCoords.y = mod(floor(dirtTexCoords.y), 2.0) == 1.0 ? 1.0 - fract(dirtTexCoords.y) : fract(dirtTexCoords.y);
}
result += dirtAmount * texture(dirtTexture, dirtTexCoords);
// Rotating starburst texture's coordinate
// dot(czm_view[0].xyz, vec3(0.0, 0.0, 1.0)) + dot(czm_view[1].xyz, vec3(0.0, 1.0, 0.0))
float camrot = czm_view[0].z + czm_view[1].y;
float cosValue = cos(camrot);
float sinValue = sin(camrot);
mat3 rotation = mat3(
cosValue, -sinValue, 0.0,
sinValue, cosValue, 0.0,
0.0, 0.0, 1.0
);
vec3 st1 = vec3(v_textureCoordinates * 2.0 - vec2(1.0), 1.0);
vec3 st2 = vec3((rotation * st1).xy, 1.0);
vec3 st3 = st2 * 0.5 + vec3(0.5);
vec2 lensStarTexcoord = st3.xy;
float weightForLensFlare = length(vec3(sunPos.xy, 0.0));
float oneMinusWeightForLensFlare = max(1.0 - weightForLensFlare, 0.0);
if (!isSpace)
{
result *= oneMinusWeightForLensFlare * intensity * 0.2;
}
else
{
result *= oneMinusWeightForLensFlare * intensity;
result *= texture(starTexture, lensStarTexcoord) * pow(weightForLensFlare, 1.0) * max((1.0 - length(vec3(st1.xy, 0.0))), 0.0) * 2.0;
}
result += texture(colorTexture, v_textureCoordinates);
out_FragColor = result;
}
`;var ZN=`uniform sampler2D colorTexture;
uniform vec3 white;
in vec2 v_textureCoordinates;
#ifdef AUTO_EXPOSURE
uniform sampler2D autoExposure;
#endif
// See equation 4:
// http://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf
void main()
{
vec4 fragmentColor = texture(colorTexture, v_textureCoordinates);
vec3 color = fragmentColor.rgb;
#ifdef AUTO_EXPOSURE
float exposure = texture(autoExposure, vec2(0.5)).r;
color /= exposure;
#endif
color = (color * (1.0 + color / white)) / (1.0 + color);
color = czm_inverseGamma(color);
out_FragColor = vec4(color, fragmentColor.a);
}
`;var QN=`uniform sampler2D colorTexture;
in vec2 v_textureCoordinates;
float rand(vec2 co)
{
return fract(sin(dot(co.xy ,vec2(12.9898, 78.233))) * 43758.5453);
}
void main(void)
{
float noiseValue = rand(v_textureCoordinates + sin(czm_frameNumber)) * 0.1;
vec3 rgb = texture(colorTexture, v_textureCoordinates).rgb;
vec3 green = vec3(0.0, 1.0, 0.0);
out_FragColor = vec4((noiseValue + rgb) * green, 1.0);
}
`;var $N=`uniform sampler2D colorTexture;
in vec2 v_textureCoordinates;
#ifdef AUTO_EXPOSURE
uniform sampler2D autoExposure;
#endif
// See equation 3:
// http://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf
void main()
{
vec4 fragmentColor = texture(colorTexture, v_textureCoordinates);
vec3 color = fragmentColor.rgb;
#ifdef AUTO_EXPOSURE
float exposure = texture(autoExposure, vec2(0.5)).r;
color /= exposure;
#endif
color = color / (1.0 + color);
color = czm_inverseGamma(color);
out_FragColor = vec4(color, fragmentColor.a);
}
`;var eF=`uniform sampler2D colorTexture;
uniform sampler2D silhouetteTexture;
in vec2 v_textureCoordinates;
void main(void)
{
vec4 silhouetteColor = texture(silhouetteTexture, v_textureCoordinates);
vec4 color = texture(colorTexture, v_textureCoordinates);
out_FragColor = mix(color, silhouetteColor, silhouetteColor.a);
}
`;/**
* @license
* Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/var tF=`/**
* @license
* Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS \`\`AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// NVIDIA GameWorks Graphics Samples GitHub link: https://github.com/NVIDIAGameWorks/GraphicsSamples
// Original FXAA 3.11 shader link: https://github.com/NVIDIAGameWorks/GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h
// Steps used to integrate into Cesium:
// * The following defines are set:
// #define FXAA_PC 1
// #define FXAA_WEBGL_1 1
// #define FXAA_GREEN_AS_LUMA 1
// #define FXAA_EARLY_EXIT 1
// #define FXAA_GLSL_120 1
// * All other preprocessor directives besides the FXAA_QUALITY__P* directives were removed.
// * Double underscores are invalid for preprocessor directives so replace them with a single underscore. Replace
// /FXAA_QUALITY__P(.*)/g with /FXAA_QUALITY__P$1/.
// * There are no implicit conversions from ivec* to vec* so replace:
// #define FxaaInt2 ivec2
// with
// #define FxaaInt2 vec2
// * The texture2DLod function is only available in vertex shaders so replace:
// #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)
// #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)
// with
// #define FxaaTexTop(t, p) texture(t, p)
// #define FxaaTexOff(t, p, o, r) texture(t, p + (o * r))
// * FXAA_QUALITY_PRESET is prepended in the javascript code. We may want to expose that setting in the future.
// * The following parameters to FxaaPixelShader are unused and can be removed:
// fxaaConsolePosPos
// fxaaConsoleRcpFrameOpt
// fxaaConsoleRcpFrameOpt2
// fxaaConsole360RcpFrameOpt2
// fxaaConsoleEdgeSharpness
// fxaaConsoleEdgeThreshold
// fxaaConsoleEdgeThresholdMi
// fxaaConsole360ConstDir
//
// Choose the quality preset.
// This needs to be compiled into the shader as it effects code.
// Best option to include multiple presets is to
// in each shader define the preset, then include this file.
//
// OPTIONS
// -----------------------------------------------------------------------
// 10 to 15 - default medium dither (10=fastest, 15=highest quality)
// 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)
// 39 - no dither, very expensive
//
// NOTES
// -----------------------------------------------------------------------
// 12 = slightly faster then FXAA 3.9 and higher edge quality (default)
// 13 = about same speed as FXAA 3.9 and better than 12
// 23 = closest to FXAA 3.9 visually and performance wise
// _ = the lowest digit is directly related to performance
// _ = the highest digit is directly related to style
//
//#define FXAA_QUALITY_PRESET 12
#if (FXAA_QUALITY_PRESET == 10)
#define FXAA_QUALITY_PS 3
#define FXAA_QUALITY_P0 1.5
#define FXAA_QUALITY_P1 3.0
#define FXAA_QUALITY_P2 12.0
#endif
#if (FXAA_QUALITY_PRESET == 11)
#define FXAA_QUALITY_PS 4
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 3.0
#define FXAA_QUALITY_P3 12.0
#endif
#if (FXAA_QUALITY_PRESET == 12)
#define FXAA_QUALITY_PS 5
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 4.0
#define FXAA_QUALITY_P4 12.0
#endif
#if (FXAA_QUALITY_PRESET == 13)
#define FXAA_QUALITY_PS 6
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 4.0
#define FXAA_QUALITY_P5 12.0
#endif
#if (FXAA_QUALITY_PRESET == 14)
#define FXAA_QUALITY_PS 7
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 4.0
#define FXAA_QUALITY_P6 12.0
#endif
#if (FXAA_QUALITY_PRESET == 15)
#define FXAA_QUALITY_PS 8
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 4.0
#define FXAA_QUALITY_P7 12.0
#endif
#if (FXAA_QUALITY_PRESET == 20)
#define FXAA_QUALITY_PS 3
#define FXAA_QUALITY_P0 1.5
#define FXAA_QUALITY_P1 2.0
#define FXAA_QUALITY_P2 8.0
#endif
#if (FXAA_QUALITY_PRESET == 21)
#define FXAA_QUALITY_PS 4
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 8.0
#endif
#if (FXAA_QUALITY_PRESET == 22)
#define FXAA_QUALITY_PS 5
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 8.0
#endif
#if (FXAA_QUALITY_PRESET == 23)
#define FXAA_QUALITY_PS 6
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 8.0
#endif
#if (FXAA_QUALITY_PRESET == 24)
#define FXAA_QUALITY_PS 7
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 3.0
#define FXAA_QUALITY_P6 8.0
#endif
#if (FXAA_QUALITY_PRESET == 25)
#define FXAA_QUALITY_PS 8
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 4.0
#define FXAA_QUALITY_P7 8.0
#endif
#if (FXAA_QUALITY_PRESET == 26)
#define FXAA_QUALITY_PS 9
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 4.0
#define FXAA_QUALITY_P8 8.0
#endif
#if (FXAA_QUALITY_PRESET == 27)
#define FXAA_QUALITY_PS 10
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 4.0
#define FXAA_QUALITY_P9 8.0
#endif
#if (FXAA_QUALITY_PRESET == 28)
#define FXAA_QUALITY_PS 11
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 2.0
#define FXAA_QUALITY_P9 4.0
#define FXAA_QUALITY_P10 8.0
#endif
#if (FXAA_QUALITY_PRESET == 29)
#define FXAA_QUALITY_PS 12
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 2.0
#define FXAA_QUALITY_P9 2.0
#define FXAA_QUALITY_P10 4.0
#define FXAA_QUALITY_P11 8.0
#endif
#if (FXAA_QUALITY_PRESET == 39)
#define FXAA_QUALITY_PS 12
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.0
#define FXAA_QUALITY_P2 1.0
#define FXAA_QUALITY_P3 1.0
#define FXAA_QUALITY_P4 1.0
#define FXAA_QUALITY_P5 1.5
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 2.0
#define FXAA_QUALITY_P9 2.0
#define FXAA_QUALITY_P10 4.0
#define FXAA_QUALITY_P11 8.0
#endif
#define FxaaBool bool
#define FxaaFloat float
#define FxaaFloat2 vec2
#define FxaaFloat3 vec3
#define FxaaFloat4 vec4
#define FxaaHalf float
#define FxaaHalf2 vec2
#define FxaaHalf3 vec3
#define FxaaHalf4 vec4
#define FxaaInt2 vec2
#define FxaaTex sampler2D
#define FxaaSat(x) clamp(x, 0.0, 1.0)
#define FxaaTexTop(t, p) texture(t, p)
#define FxaaTexOff(t, p, o, r) texture(t, p + (o * r))
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }
FxaaFloat4 FxaaPixelShader(
//
// Use noperspective interpolation here (turn off perspective interpolation).
// {xy} = center of pixel
FxaaFloat2 pos,
//
// Input color texture.
// {rgb_} = color in linear or perceptual color space
// if (FXAA_GREEN_AS_LUMA == 0)
// {___a} = luma in perceptual color space (not linear)
FxaaTex tex,
//
// Only used on FXAA Quality.
// This must be from a constant/uniform.
// {x_} = 1.0/screenWidthInPixels
// {_y} = 1.0/screenHeightInPixels
FxaaFloat2 fxaaQualityRcpFrame,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY_SUBPIX define.
// It is here now to allow easier tuning.
// Choose the amount of sub-pixel aliasing removal.
// This can effect sharpness.
// 1.00 - upper limit (softer)
// 0.75 - default amount of filtering
// 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
// 0.25 - almost off
// 0.00 - completely off
FxaaFloat fxaaQualitySubpix,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.
// It is here now to allow easier tuning.
// The minimum amount of local contrast required to apply algorithm.
// 0.333 - too little (faster)
// 0.250 - low quality
// 0.166 - default
// 0.125 - high quality
// 0.063 - overkill (slower)
FxaaFloat fxaaQualityEdgeThreshold,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.
// It is here now to allow easier tuning.
// Trims the algorithm from processing darks.
// 0.0833 - upper limit (default, the start of visible unfiltered edges)
// 0.0625 - high quality (faster)
// 0.0312 - visible limit (slower)
// Special notes when using FXAA_GREEN_AS_LUMA,
// Likely want to set this to zero.
// As colors that are mostly not-green
// will appear very dark in the green channel!
// Tune by looking at mostly non-green content,
// then start at zero and increase until aliasing is a problem.
FxaaFloat fxaaQualityEdgeThresholdMin
) {
/*--------------------------------------------------------------------------*/
FxaaFloat2 posM;
posM.x = pos.x;
posM.y = pos.y;
FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
#define lumaM rgbyM.y
FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));
FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));
FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));
FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));
/*--------------------------------------------------------------------------*/
FxaaFloat maxSM = max(lumaS, lumaM);
FxaaFloat minSM = min(lumaS, lumaM);
FxaaFloat maxESM = max(lumaE, maxSM);
FxaaFloat minESM = min(lumaE, minSM);
FxaaFloat maxWN = max(lumaN, lumaW);
FxaaFloat minWN = min(lumaN, lumaW);
FxaaFloat rangeMax = max(maxWN, maxESM);
FxaaFloat rangeMin = min(minWN, minESM);
FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;
FxaaFloat range = rangeMax - rangeMin;
FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);
FxaaBool earlyExit = range < rangeMaxClamped;
/*--------------------------------------------------------------------------*/
if(earlyExit)
return rgbyM;
/*--------------------------------------------------------------------------*/
FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));
FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));
FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));
FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
/*--------------------------------------------------------------------------*/
FxaaFloat lumaNS = lumaN + lumaS;
FxaaFloat lumaWE = lumaW + lumaE;
FxaaFloat subpixRcpRange = 1.0/range;
FxaaFloat subpixNSWE = lumaNS + lumaWE;
FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;
FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;
/*--------------------------------------------------------------------------*/
FxaaFloat lumaNESE = lumaNE + lumaSE;
FxaaFloat lumaNWNE = lumaNW + lumaNE;
FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;
/*--------------------------------------------------------------------------*/
FxaaFloat lumaNWSW = lumaNW + lumaSW;
FxaaFloat lumaSWSE = lumaSW + lumaSE;
FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);
FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);
FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;
FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;
FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;
FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;
/*--------------------------------------------------------------------------*/
FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;
FxaaFloat lengthSign = fxaaQualityRcpFrame.x;
FxaaBool horzSpan = edgeHorz >= edgeVert;
FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
/*--------------------------------------------------------------------------*/
if(!horzSpan) lumaN = lumaW;
if(!horzSpan) lumaS = lumaE;
if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;
FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;
/*--------------------------------------------------------------------------*/
FxaaFloat gradientN = lumaN - lumaM;
FxaaFloat gradientS = lumaS - lumaM;
FxaaFloat lumaNN = lumaN + lumaM;
FxaaFloat lumaSS = lumaS + lumaM;
FxaaBool pairN = abs(gradientN) >= abs(gradientS);
FxaaFloat gradient = max(abs(gradientN), abs(gradientS));
if(pairN) lengthSign = -lengthSign;
FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);
/*--------------------------------------------------------------------------*/
FxaaFloat2 posB;
posB.x = posM.x;
posB.y = posM.y;
FxaaFloat2 offNP;
offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;
offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;
if(!horzSpan) posB.x += lengthSign * 0.5;
if( horzSpan) posB.y += lengthSign * 0.5;
/*--------------------------------------------------------------------------*/
FxaaFloat2 posN;
posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;
posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;
FxaaFloat2 posP;
posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;
posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;
FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;
FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));
FxaaFloat subpixE = subpixC * subpixC;
FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));
/*--------------------------------------------------------------------------*/
if(!pairN) lumaNN = lumaSS;
FxaaFloat gradientScaled = gradient * 1.0/4.0;
FxaaFloat lumaMM = lumaM - lumaNN * 0.5;
FxaaFloat subpixF = subpixD * subpixE;
FxaaBool lumaMLTZero = lumaMM < 0.0;
/*--------------------------------------------------------------------------*/
lumaEndN -= lumaNN * 0.5;
lumaEndP -= lumaNN * 0.5;
FxaaBool doneN = abs(lumaEndN) >= gradientScaled;
FxaaBool doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;
FxaaBool doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;
/*--------------------------------------------------------------------------*/
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;
/*--------------------------------------------------------------------------*/
#if (FXAA_QUALITY_PS > 3)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;
/*--------------------------------------------------------------------------*/
#if (FXAA_QUALITY_PS > 4)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;
/*--------------------------------------------------------------------------*/
#if (FXAA_QUALITY_PS > 5)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;
/*--------------------------------------------------------------------------*/
#if (FXAA_QUALITY_PS > 6)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;
/*--------------------------------------------------------------------------*/
#if (FXAA_QUALITY_PS > 7)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;
/*--------------------------------------------------------------------------*/
#if (FXAA_QUALITY_PS > 8)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;
/*--------------------------------------------------------------------------*/
#if (FXAA_QUALITY_PS > 9)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;
/*--------------------------------------------------------------------------*/
#if (FXAA_QUALITY_PS > 10)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;
/*--------------------------------------------------------------------------*/
#if (FXAA_QUALITY_PS > 11)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;
/*--------------------------------------------------------------------------*/
#if (FXAA_QUALITY_PS > 12)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
doneN = abs(lumaEndN) >= gradientScaled;
doneP = abs(lumaEndP) >= gradientScaled;
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;
/*--------------------------------------------------------------------------*/
}
#endif
/*--------------------------------------------------------------------------*/
}
#endif
/*--------------------------------------------------------------------------*/
}
#endif
/*--------------------------------------------------------------------------*/
}
#endif
/*--------------------------------------------------------------------------*/
}
#endif
/*--------------------------------------------------------------------------*/
}
#endif
/*--------------------------------------------------------------------------*/
}
#endif
/*--------------------------------------------------------------------------*/
}
#endif
/*--------------------------------------------------------------------------*/
}
#endif
/*--------------------------------------------------------------------------*/
}
#endif
/*--------------------------------------------------------------------------*/
}
/*--------------------------------------------------------------------------*/
FxaaFloat dstN = posM.x - posN.x;
FxaaFloat dstP = posP.x - posM.x;
if(!horzSpan) dstN = posM.y - posN.y;
if(!horzSpan) dstP = posP.y - posM.y;
/*--------------------------------------------------------------------------*/
FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;
FxaaFloat spanLength = (dstP + dstN);
FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;
FxaaFloat spanLengthRcp = 1.0/spanLength;
/*--------------------------------------------------------------------------*/
FxaaBool directionN = dstN < dstP;
FxaaFloat dst = min(dstN, dstP);
FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;
FxaaFloat subpixG = subpixF * subpixF;
FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;
FxaaFloat subpixH = subpixG * fxaaQualitySubpix;
/*--------------------------------------------------------------------------*/
FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;
FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);
}
`;function yC(e){e=y(e,y.EMPTY_OBJECT),this._stages=e.stages,this._inputPreviousStageTexture=y(e.inputPreviousStageTexture,!0);let t=e.name;u(t)||(t=Hn()),this._name=t,this._uniforms=e.uniforms,this._textureCache=void 0,this._index=void 0,this._selected=void 0,this._selectedShadow=void 0,this._parentSelected=void 0,this._parentSelectedShadow=void 0,this._combinedSelected=void 0,this._combinedSelectedShadow=void 0,this._selectedLength=0,this._parentSelectedLength=0,this._selectedDirty=!0}Object.defineProperties(yC.prototype,{ready:{get:function(){let e=this._stages,t=e.length;for(let n=0;n<t;++n)if(!e[n].ready)return!1;return!0}},name:{get:function(){return this._name}},enabled:{get:function(){return this._stages[0].enabled},set:function(e){let t=this._stages,n=t.length;for(let i=0;i<n;++i)t[i].enabled=e}},uniforms:{get:function(){return this._uniforms}},inputPreviousStageTexture:{get:function(){return this._inputPreviousStageTexture}},length:{get:function(){return this._stages.length}},selected:{get:function(){return this._selected},set:function(e){this._selected=e}},parentSelected:{get:function(){return this._parentSelected},set:function(e){this._parentSelected=e}}});yC.prototype._isSupported=function(e){let t=this._stages,n=t.length;for(let i=0;i<n;++i)if(!t[i]._isSupported(e))return!1;return!0};yC.prototype.get=function(e){return this._stages[e]};function Edt(e){let t=u(e._selected)?e._selected.length:0,n=u(e._parentSelected)?e._parentSelected:0,i=e._selected!==e._selectedShadow||t!==e._selectedLength;if(i=i||e._parentSelected!==e._parentSelectedShadow||n!==e._parentSelectedLength,u(e._selected)&&u(e._parentSelected)?e._combinedSelected=e._selected.concat(e._parentSelected):u(e._parentSelected)?e._combinedSelected=e._parentSelected:e._combinedSelected=e._selected,!i&&u(e._combinedSelected)){if(!u(e._combinedSelectedShadow))return!0;t=e._combinedSelected.length;for(let o=0;o<t;++o)if(e._combinedSelected[o]!==e._combinedSelectedShadow[o])return!0}return i}yC.prototype.update=function(e,t){this._selectedDirty=Edt(this),this._selectedShadow=this._selected,this._parentSelectedShadow=this._parentSelected,this._combinedSelectedShadow=this._combinedSelected,this._selectedLength=u(this._selected)?this._selected.length:0,this._parentSelectedLength=u(this._parentSelected)?this._parentSelected.length:0;let n=this._stages,i=n.length;for(let o=0;o<i;++o){let r=n[o];this._selectedDirty&&(r.parentSelected=this._combinedSelected),r.update(e,t)}};yC.prototype.isDestroyed=function(){return!1};yC.prototype.destroy=function(){let e=this._stages,t=e.length;for(let n=0;n<t;++n)e[n].destroy();return ue(this)};var Kc=yC;var Fr={};function Gz(e){let o=`#define USE_STEP_SIZE
${n0}`,r=new yo({name:`${e}_x_direction`,fragmentShader:o,uniforms:{delta:1,sigma:2,stepSize:1,direction:0},sampleMode:Fu.LINEAR}),s=new yo({name:`${e}_y_direction`,fragmentShader:o,uniforms:{delta:1,sigma:2,stepSize:1,direction:1},sampleMode:Fu.LINEAR}),a={};return Object.defineProperties(a,{delta:{get:function(){return r.uniforms.delta},set:function(c){let l=r.uniforms,f=s.uniforms;l.delta=f.delta=c}},sigma:{get:function(){return r.uniforms.sigma},set:function(c){let l=r.uniforms,f=s.uniforms;l.sigma=f.sigma=c}},stepSize:{get:function(){return r.uniforms.stepSize},set:function(c){let l=r.uniforms,f=s.uniforms;l.stepSize=f.stepSize=c}}}),new Kc({name:e,stages:[r,s],uniforms:a})}Fr.createBlurStage=function(){return Gz("czm_blur")};Fr.createDepthOfFieldStage=function(){let e=Gz("czm_depth_of_field_blur"),t=new yo({name:"czm_depth_of_field_composite",fragmentShader:jN,uniforms:{focalDistance:5,blurTexture:e.name}}),n={};return Object.defineProperties(n,{focalDistance:{get:function(){return t.uniforms.focalDistance},set:function(i){t.uniforms.focalDistance=i}},delta:{get:function(){return e.uniforms.delta},set:function(i){e.uniforms.delta=i}},sigma:{get:function(){return e.uniforms.sigma},set:function(i){e.uniforms.sigma=i}},stepSize:{get:function(){return e.uniforms.stepSize},set:function(i){e.uniforms.stepSize=i}}}),new Kc({name:"czm_depth_of_field",stages:[e,t],inputPreviousStageTexture:!1,uniforms:n})};Fr.isDepthOfFieldSupported=function(e){return e.context.depthTexture};Fr.createEdgeDetectionStage=function(){let e=Hn();return new yo({name:`czm_edge_detection_${e}`,fragmentShader:qN,uniforms:{length:.25,color:k.clone(k.BLACK)}})};Fr.isEdgeDetectionSupported=function(e){return e.context.depthTexture};function bdt(e){if(!u(e))return Fr.createEdgeDetectionStage();let t=new Kc({name:"czm_edge_detection_multiple",stages:e,inputPreviousStageTexture:!1}),n={},i="",o="";for(let a=0;a<e.length;++a)i+=`uniform sampler2D edgeTexture${a};
`,o+=` vec4 edge${a} = texture(edgeTexture${a}, v_textureCoordinates);
if (edge${a}.a > 0.0)
{
color = edge${a};
break;
}
`,n[`edgeTexture${a}`]=e[a].name;let r=`${i}in vec2 v_textureCoordinates;
void main() {
vec4 color = vec4(0.0);
for (int i = 0; i < ${e.length}; i++)
{
${o} }
out_FragColor = color;
}
`,s=new yo({name:"czm_edge_detection_combine",fragmentShader:r,uniforms:n});return new Kc({name:"czm_edge_detection_composite",stages:[t,s]})}Fr.createSilhouetteStage=function(e){let t=bdt(e),n=new yo({name:"czm_silhouette_color_edges",fragmentShader:eF,uniforms:{silhouetteTexture:t.name}});return new Kc({name:"czm_silhouette",stages:[t,n],inputPreviousStageTexture:!1,uniforms:t.uniforms})};Fr.isSilhouetteSupported=function(e){return e.context.depthTexture};Fr.createBloomStage=function(){let e=new yo({name:"czm_bloom_contrast_bias",fragmentShader:WN,uniforms:{contrast:128,brightness:-.3}}),t=Gz("czm_bloom_blur"),n=new Kc({name:"czm_bloom_contrast_bias_blur",stages:[e,t]}),i=new yo({name:"czm_bloom_generate_composite",fragmentShader:HN,uniforms:{glowOnly:!1,bloomTexture:n.name}}),o={};return Object.defineProperties(o,{glowOnly:{get:function(){return i.uniforms.glowOnly},set:function(r){i.uniforms.glowOnly=r}},contrast:{get:function(){return e.uniforms.contrast},set:function(r){e.uniforms.contrast=r}},brightness:{get:function(){return e.uniforms.brightness},set:function(r){e.uniforms.brightness=r}},delta:{get:function(){return t.uniforms.delta},set:function(r){t.uniforms.delta=r}},sigma:{get:function(){return t.uniforms.sigma},set:function(r){t.uniforms.sigma=r}},stepSize:{get:function(){return t.uniforms.stepSize},set:function(r){t.uniforms.stepSize=r}}}),new Kc({name:"czm_bloom",stages:[n,i],inputPreviousStageTexture:!1,uniforms:o})};Fr.createAmbientOcclusionStage=function(){let e=new yo({name:"czm_ambient_occlusion_generate",fragmentShader:VN,uniforms:{intensity:3,bias:.1,lengthCap:.26,stepSize:1.95,frustumLength:1e3,randomTexture:void 0}}),t=Gz("czm_ambient_occlusion_blur");t.uniforms.stepSize=.86;let n=new Kc({name:"czm_ambient_occlusion_generate_blur",stages:[e,t]}),i=new yo({name:"czm_ambient_occlusion_composite",fragmentShader:kN,uniforms:{ambientOcclusionOnly:!1,ambientOcclusionTexture:n.name}}),o={};return Object.defineProperties(o,{intensity:{get:function(){return e.uniforms.intensity},set:function(r){e.uniforms.intensity=r}},bias:{get:function(){return e.uniforms.bias},set:function(r){e.uniforms.bias=r}},lengthCap:{get:function(){return e.uniforms.lengthCap},set:function(r){e.uniforms.lengthCap=r}},stepSize:{get:function(){return e.uniforms.stepSize},set:function(r){e.uniforms.stepSize=r}},frustumLength:{get:function(){return e.uniforms.frustumLength},set:function(r){e.uniforms.frustumLength=r}},randomTexture:{get:function(){return e.uniforms.randomTexture},set:function(r){e.uniforms.randomTexture=r}},delta:{get:function(){return t.uniforms.delta},set:function(r){t.uniforms.delta=r}},sigma:{get:function(){return t.uniforms.sigma},set:function(r){t.uniforms.sigma=r}},blurStepSize:{get:function(){return t.uniforms.stepSize},set:function(r){t.uniforms.stepSize=r}},ambientOcclusionOnly:{get:function(){return i.uniforms.ambientOcclusionOnly},set:function(r){i.uniforms.ambientOcclusionOnly=r}}}),new Kc({name:"czm_ambient_occlusion",stages:[n,i],inputPreviousStageTexture:!1,uniforms:o})};Fr.isAmbientOcclusionSupported=function(e){return e.context.depthTexture};var Sdt=`#define FXAA_QUALITY_PRESET 39
${tF}
${KN}`;Fr.createFXAAStage=function(){return new yo({name:"czm_FXAA",fragmentShader:Sdt,sampleMode:Fu.LINEAR})};Fr.createAcesTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE
`:"";return t+=UN,new yo({name:"czm_aces",fragmentShader:t,uniforms:{autoExposure:void 0}})};Fr.createFilmicTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE
`:"";return t+=XN,new yo({name:"czm_filmic",fragmentShader:t,uniforms:{autoExposure:void 0}})};Fr.createReinhardTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE
`:"";return t+=$N,new yo({name:"czm_reinhard",fragmentShader:t,uniforms:{autoExposure:void 0}})};Fr.createModifiedReinhardTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE
`:"";return t+=ZN,new yo({name:"czm_modified_reinhard",fragmentShader:t,uniforms:{white:k.WHITE,autoExposure:void 0}})};Fr.createAutoExposureStage=function(){return new aL};Fr.createBlackAndWhiteStage=function(){return new yo({name:"czm_black_and_white",fragmentShader:zN,uniforms:{gradations:5}})};Fr.createBrightnessStage=function(){return new yo({name:"czm_brightness",fragmentShader:GN,uniforms:{brightness:.5}})};Fr.createNightVisionStage=function(){return new yo({name:"czm_night_vision",fragmentShader:QN})};Fr.createDepthViewStage=function(){return new yo({name:"czm_depth_view",fragmentShader:YN})};Fr.createLensFlareStage=function(){return new yo({name:"czm_lens_flare",fragmentShader:JN,uniforms:{dirtTexture:tn("Assets/Textures/LensFlare/DirtMask.jpg"),starTexture:tn("Assets/Textures/LensFlare/StarBurst.jpg"),intensity:2,distortion:10,ghostDispersal:.4,haloWidth:.4,dirtAmount:.4,earthRadius:oe.WGS84.maximumRadius}})};var Gf=Fr;function k_(e){this._collection=e,this._framebuffers=[],this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0,this._updateDependencies=!1}function iF(e){for(;u(e.length);)e=e.get(e.length-1);return e.name}function eX(e,t,n,i,o){if(!i.enabled||!i._isSupported(t))return o;let r=n[i.name]={};if(u(o)){let a=e.getStageByName(o);r[iF(a)]=!0}let s=i.uniforms;if(u(s)){let a=Object.getOwnPropertyNames(s),c=a.length;for(let l=0;l<c;++l){let f=s[a[l]];if(typeof f=="string"){let d=e.getStageByName(f);u(d)&&(r[iF(d)]=!0)}}}return i.name}function nF(e,t,n,i,o){if(u(i.enabled)&&!i.enabled||u(i._isSupported)&&!i._isSupported(t))return o;let r=o,s=!u(i.inputPreviousStageTexture)||i.inputPreviousStageTexture,a=o,c=i.length;for(let d=0;d<c;++d){let p=i.get(d);u(p.length)?a=nF(e,t,n,p,o):a=eX(e,t,n,p,o),s&&(o=a)}let l,f;if(s)for(l=1;l<c;++l)f=iF(i.get(l)),u(n[f])||(n[f]={}),n[f][r]=!0;else for(l=1;l<c;++l){f=iF(i.get(l));let d=n[f];for(let p=0;p<l;++p)d[iF(i.get(p))]=!0}return a}function vdt(e,t){let n={};if(u(e.ambientOcclusion)){let i=e.ambientOcclusion,o=e.bloom,r=e._tonemapping,s=e.fxaa,a=nF(e,t,n,i,void 0);a=nF(e,t,n,o,a),a=eX(e,t,n,r,a),a=nF(e,t,n,e,a),eX(e,t,n,s,a)}else nF(e,t,n,e,void 0);return n}function wdt(e,t,n){let o=e._collection.getStageByName(t),r=o._textureScale,s=o._forcePowerOfTwo,a=o._pixelFormat,c=o._pixelDatatype,l=o._clearColor,f,d,p=e._framebuffers,g=p.length;for(f=0;f<g;++f){if(d=p[f],r!==d.textureScale||s!==d.forcePowerOfTwo||a!==d.pixelFormat||c!==d.pixelDatatype||!k.equals(l,d.clearColor))continue;let h=d.stages,A=h.length,x=!1;for(let C=0;C<A;++C)if(n[h[C]]){x=!0;break}if(!x)break}return u(d)&&f<g?(d.stages.push(t),d):(d={textureScale:r,forcePowerOfTwo:s,pixelFormat:a,pixelDatatype:c,clearColor:l,stages:[t],buffer:new mi({pixelFormat:a,pixelDatatype:c}),clear:void 0},p.push(d),d)}function Ddt(e,t){let n=vdt(e._collection,t);for(let i in n)n.hasOwnProperty(i)&&(e._stageNameToFramebuffer[i]=wdt(e,i,n[i]))}function tX(e){let t=e._framebuffers,n=t.length;for(let i=0;i<n;++i)t[i].buffer.destroy()}function Idt(e,t){let n=e._width,i=e._height,o=e._framebuffers,r=o.length;for(let s=0;s<r;++s){let a=o[s],c=a.textureScale,l=Math.ceil(n*c),f=Math.ceil(i*c),d=Math.min(l,f);a.forcePowerOfTwo&&(P.isPowerOfTwo(d)||(d=P.nextPowerOfTwo(d)),l=d,f=d),a.buffer.update(t,l,f),a.clear=new li({color:a.clearColor,framebuffer:a.buffer.framebuffer})}}k_.prototype.updateDependencies=function(){this._updateDependencies=!0};k_.prototype.update=function(e){let t=this._collection,n=this._updateDependencies,i=u(t.ambientOcclusion)&&t.ambientOcclusion.enabled&&t.ambientOcclusion._isSupported(e),o=u(t.bloom)&&t.bloom.enabled&&t.bloom._isSupported(e),r=u(t._tonemapping)&&t._tonemapping.enabled&&t._tonemapping._isSupported(e),s=u(t.fxaa)&&t.fxaa.enabled&&t.fxaa._isSupported(e),a=!u(t._activeStages)||t._activeStages.length>0||i||o||r||s;if((n||!a&&this._framebuffers.length>0)&&(tX(this),this._framebuffers.length=0,this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0),!n&&!a)return;this._framebuffers.length===0&&Ddt(this,e);let c=e.drawingBufferWidth,l=e.drawingBufferHeight,f=this._width!==
uniform sampler2D colorTexture2;
uniform vec2 center;
uniform float radius;
in vec2 v_textureCoordinates;
void main()
{
vec4 color0 = texture(colorTexture, v_textureCoordinates);
vec4 color1 = texture(colorTexture2, v_textureCoordinates);
float x = length(gl_FragCoord.xy - center) / radius;
float t = smoothstep(0.5, 0.8, x);
out_FragColor = mix(color0 + color1, color1, t);
}
`;var dF=`uniform sampler2D colorTexture;
uniform float avgLuminance;
uniform float threshold;
uniform float offset;
in vec2 v_textureCoordinates;
float key(float avg)
{
float guess = 1.5 - (1.5 / (avg * 0.1 + 1.0));
return max(0.0, guess) + 0.1;
}
// See section 9. "The bright-pass filter" of Realtime HDR Rendering
// http://www.cg.tuwien.ac.at/research/publications/2007/Luksch_2007_RHR/Luksch_2007_RHR-RealtimeHDR%20.pdf
void main()
{
vec4 color = texture(colorTexture, v_textureCoordinates);
vec3 xyz = czm_RGBToXYZ(color.rgb);
float luminance = xyz.r;
float scaledLum = key(avgLuminance) * luminance / avgLuminance;
float brightLum = max(scaledLum - threshold, 0.0);
float brightness = brightLum / (offset + brightLum);
xyz.r = brightness;
out_FragColor = vec4(czm_XYZToRGB(xyz), 1.0);
}
`;function z_(){this._sceneFramebuffer=new dC;let e=.125,t=new Array(6);t[0]=new yo({fragmentShader:kl,textureScale:e,forcePowerOfTwo:!0,sampleMode:Fu.LINEAR});let n=t[1]=new yo({fragmentShader:dF,uniforms:{avgLuminance:.5,threshold:.25,offset:.1},textureScale:e,forcePowerOfTwo:!0}),i=this;this._delta=1,this._sigma=2,this._blurStep=new H,t[2]=new yo({fragmentShader:n0,uniforms:{step:function(){return i._blurStep.x=i._blurStep.y=1/n.outputTexture.width,i._blurStep},delta:function(){return i._delta},sigma:function(){return i._sigma},direction:0},textureScale:e,forcePowerOfTwo:!0}),t[3]=new yo({fragmentShader:n0,uniforms:{step:function(){return i._blurStep.x=i._blurStep.y=1/n.outputTexture.width,i._blurStep},delta:function(){return i._delta},sigma:function(){return i._sigma},direction:1},textureScale:e,forcePowerOfTwo:!0}),t[4]=new yo({fragmentShader:kl,sampleMode:Fu.LINEAR}),this._uCenter=new H,this._uRadius=void 0,t[5]=new yo({fragmentShader:fF,uniforms:{center:function(){return i._uCenter},radius:function(){return i._uRadius},colorTexture2:function(){return i._sceneFramebuffer.framebuffer.getColorTexture(0)}}}),this._stages=new Kc({stages:t});let o=new AC(this),r=t.length;for(let s=0;s<r;++s)t[s]._textureCache=o;this._textureCache=o,this.length=t.length}z_.prototype.get=function(e){return this._stages.get(e)};z_.prototype.getStageByName=function(e){let t=this._stages.length;for(let n=0;n<t;++n){let i=this._stages.get(n);if(i.name===e)return i}};var ept=new re,tAe=new H,tpt=new H,nAe=new B;function npt(e,t,n){let i=t.uniformState,o=i.sunPositionWC,r=i.view,s=i.viewProjection,a=i.projection,c=B.computeViewportTransformation(n,0,1,nAe),l=B.multiplyByPoint(r,o,ept),f=Ot.pointToGLWindowCoordinates(s,c,o,tAe);l.x+=P.SOLAR_RADIUS;let d=Ot.pointToGLWindowCoordinates(a,c,l,l),p=H.magnitude(H.subtract(d,f,d))*30*2,g=tpt;g.x=p,g.y=p,e._uCenter=H.clone(f,e._uCenter),e._uRadius=Math.max(g.x,g.y)*.15;let h=t.drawingBufferWidth,A=t.drawingBufferHeight,x=e._stages,C=x.get(0),T=C.outputTexture.width,E=C.outputTexture.height,S=new qe;S.width=T,S.height=E,c=B.computeViewportTransformation(S,0,1,nAe),f=Ot.pointToGLWindowCoordinates(s,c,o,tAe),g.x*=T/h,g.y*=E/A;let w=C.scissorRectangle;w.x=Math.max(f.x-g.x*.5,0),w.y=Math.max(f.y-g.y*.5,0),w.width=Math.min(g.x,h),w.height=Math.min(g.y,A);for(let D=1;D<4;++D)qe.clone(w,x.get(D).scissorRectangle)}z_.prototype.clear=function(e,t,n){this._sceneFramebuffer.clear(e,t,n),this._textureCache.clear(e)};z_.prototype.update=function(e){let t=e.context,n=e.viewport,i=this._sceneFramebuffer;i.update(t,n);let o=i.framebuffer;return this._textureCache.update(t),this._stages.update(t,!1),npt(this,t,n),o};z_.prototype.execute=function(e){let t=this._sceneFramebuffer.framebuffer.getColorTexture(0),n=this._stages,i=n.length;n.get(0).execute(e,t);for(let o=1;o<i;++o)n.get(o).execute(e,n.get(o-1).outputTexture)};z_.prototype.copy=function(e,t){if(!u(this._copyColorCommand)){let n=this;this._copyColorCommand=e.createViewportQuadCommand(kl,{uniformMap:{colorTexture:function(){return n._stages.get(n._stages.length-1).outputTexture}},owner:this})}this._copyColorCommand.framebuffer=t,this._copyColorCommand.execute(e)};z_.prototype.isDestroyed=function(){return!1};z_.prototype.destroy=function(){return this._textureCache.destroy(),this._stages.destroy(),ue(this)};var mF=z_;var eH=function(e){return function(){e.frameState.afterRender.push(function(){e.requestRender()})}};function Wi(e){e=y(e,y.EMPTY_OBJECT);let t=e.canvas,n=e.creditContainer,i=e.creditViewport,o=je(e.contextOptions),r=u(n),s=new UB(t,o);r||(n=document.createElement("div"),n.style.position="absolute",n.style.bottom="0",n.style["text-shadow"]="0 0 2px #000000",n.style.color="#ffffff",n.style["font-size"]="10px",n.style["padding-right"]="5px",t.parentNode.appendChild(n)),u(i)||(i=t.parentNode),this._id=Hn(),this._jobScheduler=new AN,this._frameState=new jL(s,new DL(n," \u2022 ",i),this._jobScheduler),this._frameState.scene3DOnly=y(e.scene3DOnly,!1),this._removeCreditContainer=!r,this._creditContainer=n,this._canvas=t,this._context=s,this._computeEngine=ne
{
float startDistance = nearFarScalar.x;
float startValue = nearFarScalar.y;
float endDistance = nearFarScalar.z;
float endValue = nearFarScalar.w;
float t = clamp((distance - startDistance) / (endDistance - startDistance), 0.0, 1.0);
return mix(startValue, endValue, t);
}
vec3 getLightDirection(vec3 positionWC)
{
float lightEnum = u_radiiAndDynamicAtmosphereColor.z;
vec3 lightDirection =
positionWC * float(lightEnum == 0.0) +
czm_lightDirectionWC * float(lightEnum == 1.0) +
czm_sunDirectionWC * float(lightEnum == 2.0);
return normalize(lightDirection);
}
void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity, out float underTranslucentGlobe)
{
float ellipsoidRadiiDifference = czm_ellipsoidRadii.x - czm_ellipsoidRadii.z;
// Adjustment to the atmosphere radius applied based on the camera height.
float distanceAdjustMin = czm_ellipsoidRadii.x / 4.0;
float distanceAdjustMax = czm_ellipsoidRadii.x;
float distanceAdjustModifier = ellipsoidRadiiDifference / 2.0;
float distanceAdjust = distanceAdjustModifier * clamp((czm_eyeHeight - distanceAdjustMin) / (distanceAdjustMax - distanceAdjustMin), 0.0, 1.0);
// Since atmosphere scattering assumes the atmosphere is a spherical shell, we compute an inner radius of the atmosphere best fit
// for the position on the ellipsoid.
float radiusAdjust = (ellipsoidRadiiDifference / 4.0) + distanceAdjust;
float atmosphereInnerRadius = (length(czm_viewerPositionWC) - czm_eyeHeight) - radiusAdjust;
// Setup the primary ray: from the camera position to the vertex position.
vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);
underTranslucentGlobe = 0.0;
// Brighten the sky atmosphere under the Earth's atmosphere when translucency is enabled.
#if defined(GLOBE_TRANSLUCENT)
// Check for intersection with the inner radius of the atmopshere.
czm_raySegment primaryRayEarthIntersect = czm_raySphereIntersectionInterval(primaryRay, vec3(0.0), atmosphereInnerRadius + radiusAdjust);
if (primaryRayEarthIntersect.start > 0.0 && primaryRayEarthIntersect.stop > 0.0) {
// Compute position on globe.
vec3 direction = normalize(positionWC);
czm_ray ellipsoidRay = czm_ray(positionWC, -direction);
czm_raySegment ellipsoidIntersection = czm_rayEllipsoidIntersectionInterval(ellipsoidRay, vec3(0.0), czm_ellipsoidInverseRadii);
vec3 onEarth = positionWC - (direction * ellipsoidIntersection.start);
// Control the color using the camera angle.
float angle = dot(normalize(czm_viewerPositionWC), normalize(onEarth));
// Control the opacity using the distance from Earth.
opacity = interpolateByDistance(vec4(0.0, 1.0, czm_ellipsoidRadii.x, 0.0), length(czm_viewerPositionWC - onEarth));
vec3 horizonColor = vec3(0.1, 0.2, 0.3);
vec3 nearColor = vec3(0.0);
rayleighColor = mix(nearColor, horizonColor, exp(-angle) * opacity);
// Set the traslucent flag to avoid alpha adjustment in computeFinalColor funciton.
underTranslucentGlobe = 1.0;
return;
}
#endif
computeScattering(
primaryRay,
length(cameraToPositionWC),
lightDirection,
atmosphereInnerRadius,
rayleighColor,
mieColor,
opacity
);
// Alter the opacity based on how close the viewer is to the ground.
// (0.0 = At edge of atmosphere, 1.0 = On ground)
float cameraHeight = czm_eyeHeight + atmosphereInnerRadius;
float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE_THICKNESS;
opacity = clamp((atmosphereOuterRadius - cameraHeight) / (atmosphereOuterRadius - atmosphereInnerRadius), 0.0, 1.0);
// Alter alpha based on time of day (0.0 = night , 1.0 = day)
float nightAlpha = (u_radiiAndDynamicAtmosphereColor.z != 0.0) ? clamp(dot(normalize(positionWC), lightDirection), 0.0, 1.0) : 1.0;
opacity *= pow(nightAlpha, 0.5);
}
`;var _F=`in vec3 v_outerPositionWC;
uniform vec3 u_hsbShift;
#ifndef PER_FRAGMENT_ATMOSPHERE
in vec3 v_mieColor;
in vec3 v_rayleighColor;
in float v_opacity;
in float v_translucent;
#endif
void main (void)
{
vec3 lightDirection = getLightDirection(v_outerPositionWC);
vec3 mieColor;
vec3 rayleighColor;
float opacity;
float translucent;
#ifdef PER_FRAGMENT_ATMOSPHERE
computeAtmosphereScattering(
v_outerPositionWC,
lightDirection,
rayleighColor,
mieColor,
opacity,
translucent
);
#else
mieColor = v_mieColor;
rayleighColor = v_rayleighColor;
opacity = v_opacity;
translucent = v_translucent;
#endif
vec4 color = computeAtmosphereColor(v_outerPositionWC, lightDirection, rayleighColor, mieColor, opacity);
#ifndef HDR
color.rgb = czm_acesTonemapping(color.rgb);
color.rgb = czm_inverseGamma(color.rgb);
#endif
#ifdef COLOR_CORRECT
// Convert rgb color to hsb
vec3 hsb = czm_RGBToHSB(color.rgb);
// Perform hsb shift
hsb.x += u_hsbShift.x; // hue
hsb.y = clamp(hsb.y + u_hsbShift.y, 0.0, 1.0); // saturation
hsb.z = hsb.z > czm_epsilon7 ? hsb.z + u_hsbShift.z : 0.0; // brightness
// Convert shifted hsb back to rgb
color.rgb = czm_HSBToRGB(hsb);
#endif
// For the parts of the sky atmosphere that are not behind a translucent globe,
// we mix in the default opacity so that the sky atmosphere still appears at distance.
// This is needed because the opacity in the sky atmosphere is initially adjusted based
// on the camera height.
if (translucent == 0.0) {
color.a = mix(color.b, 1.0, color.a) * smoothstep(0.0, 1.0, czm_morphTime);
}
out_FragColor = color;
}
`;var gF=`in vec4 position;
out vec3 v_outerPositionWC;
#ifndef PER_FRAGMENT_ATMOSPHERE
out vec3 v_mieColor;
out vec3 v_rayleighColor;
out float v_opacity;
out float v_translucent;
#endif
void main(void)
{
vec4 positionWC = czm_model * position;
vec3 lightDirection = getLightDirection(positionWC.xyz);
#ifndef PER_FRAGMENT_ATMOSPHERE
computeAtmosphereScattering(
positionWC.xyz,
lightDirection,
v_rayleighColor,
v_mieColor,
v_opacity,
v_translucent
);
#endif
v_outerPositionWC = positionWC.xyz;
gl_Position = czm_modelViewProjection * position;
}
`;function LS(e){e=y(e,oe.WGS84),this.show=!0,this.perFragmentAtmosphere=!1,this._ellipsoid=e;let t=1.025,n=m.multiplyByScalar(e.radii,t,new m);this._scaleMatrix=B.fromScale(n),this._modelMatrix=new B,this._command=new nt({owner:this,modelMatrix:this._modelMatrix}),this._spSkyFromSpace=void 0,this._spSkyFromAtmosphere=void 0,this._flags=void 0,this.atmosphereLightIntensity=50,this.atmosphereRayleighCoefficient=new m(55e-7,13e-6,284e-7),this.atmosphereMieCoefficient=new m(21e-6,21e-6,21e-6),this.atmosphereRayleighScaleHeight=1e4,this.atmosphereMieScaleHeight=3200,this.atmosphereMieAnisotropy=.9,this.hueShift=0,this.saturationShift=0,this.brightnessShift=0,this._hueSaturationBrightness=new m;let i=new m;i.x=e.maximumRadius*t,i.y=e.maximumRadius,i.z=0,this._radiiAndDynamicAtmosphereColor=i;let o=this;this._command.uniformMap={u_radiiAndDynamicAtmosphereColor:function(){return o._radiiAndDynamicAtmosphereColor},u_hsbShift:function(){return o._hueSaturationBrightness.x=o.hueShift,o._hueSaturationBrightness.y=o.saturationShift,o._hueSaturationBrightness.z=o.brightnessShift,o._hueSaturationBrightness},u_atmosphereLightIntensity:function(){return o.atmosphereLightIntensity},u_atmosphereRayleighCoefficient:function(){return o.atmosphereRayleighCoefficient},u_atmosphereMieCoefficient:function(){return o.atmosphereMieCoefficient},u_atmosphereRayleighScaleHeight:function(){return o.atmosphereRayleighScaleHeight},u_atmosphereMieScaleHeight:function(){return o.atmosphereMieScaleHeight},u_atmosphereMieAnisotropy:function(){return o.atmosphereMieAnisotropy}}}Object.defineProperties(LS.prototype,{ellipsoid:{get:function(){return this._ellipsoid}}});LS.prototype.setDynamicAtmosphereColor=function(e,t){let n=e?t?2:1:0;this._radiiAndDynamicAtmosphereColor.z=n};var wX=new B;LS.prototype.update=function(e,t){if(!this.show)return;let n=e.mode;if(n!==ne.SCENE3D&&n!==ne.MORPHING||!e.passes.render)return;let i=B.fromRotationTranslation(e.context.uniformState.inverseViewRotation,m.ZERO,wX),o=B.multiplyTransformation(i,lo.Y_UP_TO_Z_UP,wX),r=B.multiply(this._scaleMatrix,o,wX);B.clone(r,this._modelMatrix);let s=e.context,a=Wpt(this),c=e.globeTranslucencyState.translucent,l=this.perFragmentAtmosphere||c||!u(t)||!t.show,f=this._command;if(!u(f.vertexArray)){let p=Os.createGeometry(new Os({radii:new m(1,1,1),slicePartitions:256,stackPartitions:256,vertexFormat:Oe.POSITION_ONLY}));f.vertexArray=si.fromGeometry({context:s,geometry:p,attributeLocations:Nn.createAttributeLocations(p),bufferUsage:Fe.STATIC_DRAW}),f.renderState=ke.fromCache({cull:{enabled:!0,face:_i.FRONT},blending:un.ALPHA_BLEND,depthMask:!1})}let d=a|l<<2|c<<3;if(d!==this._flags){this._flags=d;let p=[];a&&p.push("COLOR_CORRECT"),l&&p.push("PER_FRAGMENT_ATMOSPHERE"),c&&p.push("GLOBE_TRANSLUCENT");let g=new He({defines:p,sources:[O_,BS,gF]}),h=new He({defines:p,sources:[O_,BS,_F]});this._spSkyAtmosphere=Jt.fromCache({context:s,vertexShaderSource:g,fragmentShaderSource:h}),f.shaderProgram=this._spSkyAtmosphere}return f};function Wpt(e){return!(P.equalsEpsilon(e.hueShift,0,P.EPSILON7)&&P.equalsEpsilon(e.saturationShift,0,P.EPSILON7)&&P.equalsEpsilon(e.brightnessShift,0,P.EPSILON7))}LS.prototype.isDestroyed=function(){return!1};LS.prototype.destroy=function(){let e=this._command;return e.vertexArray=e.vertexArray&&e.vertexArray.destroy(),this._spSkyAtmosphere=this._spSkyAtmosphere&&this._spSkyAtmosphere.destroy(),ue(this)};var yF=LS;var AF=`uniform samplerCube u_cubeMap;
in vec3 v_texCoord;
void main()
{
vec4 color = czm_textureCube(u_cubeMap, normalize(v_texCoord));
out_FragColor = vec4(czm_gammaCorrect(color).rgb, czm_morphTime);
}
`;var xF=`in vec3 position;
out vec3 v_texCoord;
void main()
{
vec3 p = czm_viewRotation * (czm_temeToPseudoFixed * (czm_entireFrustum.y * position));
gl_Position = czm_projection * vec4(p, 1.0);
v_texCoord = position.xyz;
}
`;function tH(e){this.sources=e.sources,this._sources=void 0,this.show=y(e.show,!0),this._command=new nt({modelMatrix:B.clone(B.IDENTITY),owner:this}),this._cubeMap=void 0,this._attributeLocations=void 0,this._useHdr=void 0}tH.prototype.update=function(e,t){let n=this;if(!this.show||e.mode!==ne.SCENE3D&&e.mode!==ne.MORPHING||!e.passes.render)return;let i=e.context;if(this._sources!==this.sources){this._sources=this.sources;let r=this.sources;typeof r.positiveX=="string"?VB(i,this._sources).then(function(s){n._cubeMap=n._cubeMap&&n._cubeMap.destroy(),n._cubeMap=s}):(this._cubeMap=this._cubeMap&&this._cubeMap.destroy(),this._cubeMap=new ka({context:i,source:r}))}let o=this._command;if(!u(o.vertexArray)){o.uniformMap={u_cubeMap:function(){return n._cubeMap}};let r=rl.createGeometry(rl.fromDimensions({dimensions:new m(2,2,2),vertexFormat:Oe.POSITION_ONLY})),s=this._attributeLocations=Nn.createAttributeLocations(r);o.vertexArray=si.fromGeometry({context:i,geometry:r,attributeLocations:s,bufferUsage:Fe.STATIC_DRAW}),o.renderState=ke.fromCache({blending:un.ALPHA_BLEND})}if(!u(o.shaderProgram)||this._useHdr!==t){let r=new He({defines:[t?"HDR":""],sources:[AF]});o.shaderProgram=Jt.fromCache({context:i,vertexShaderSource:xF,fragmentShaderSource:r,attributeLocations:this._attributeLocations}),this._useHdr=t}if(u(this._cubeMap))return o};tH.prototype.isDestroyed=function(){return!1};tH.prototype.destroy=function(){let e=this._command;return e.vertexArray=e.vertexArray&&e.vertexArray.destroy(),e.shaderProgram=e.shaderProgram&&e.shaderProgram.destroy(),this._cubeMap=this._cubeMap&&this._cubeMap.destroy(),ue(this)};var CF=tH;function jf(e,t,n,i,o,r,s){this.children=void 0,this.parent=o,this.level=e,this.x=t,this.y=n,this.z=i,this.keyframeNodes=[],this.renderableKeyframeNodes=[],this.renderableKeyframeNodeLerp=0,this.renderableKeyframeNodePrevious=void 0,this.renderableKeyframeNodeNext=void 0,this.orientedBoundingBox=new Mn,this.approximateVoxelSize=0,this.screenSpaceError=0,this.visitedFrameNumber=-1,this.computeBoundingVolumes(r,s)}var jpt=new m;jf.prototype.computeBoundingVolumes=function(e,t){this.orientedBoundingBox=e.computeOrientedBoundingBoxForTile(this.level,this.x,this.y,this.z,this.orientedBoundingBox);let n=Z.getScale(this.orientedBoundingBox.halfAxes,jpt),i=2*m.maximumComponent(n);this.approximateVoxelSize=i/m.minimumComponent(t)};jf.prototype.constructChildNodes=function(e,t){let{level:n,x:i,y:o,z:r}=this,s=i*2,a=o*2,c=r*2,l=a+1,f=s+1,d=c+1,p=n+1,g=[[p,s,a,c],[p,f,a,c],[p,s,l,c],[p,f,l,c],[p,s,a,d],[p,f,a,d],[p,s,l,d],[p,f,l,d]];this.children=g.map(([h,A,x,C])=>new jf(h,A,x,C,this,e,t))};jf.prototype.visibility=function(e,t){let n=this.orientedBoundingBox;return e.cullingVolume.computeVisibilityWithPlaneMask(n,t)};jf.prototype.computeScreenSpaceError=function(e,t){let n=this.orientedBoundingBox,i=Math.sqrt(n.distanceSquaredTo(e));i=Math.max(i,P.EPSILON7);let o=this.approximateVoxelSize,r=t*(o/i);this.screenSpaceError=r};var fAe={keyframe:0};function TF(e,t){return fAe.keyframe=e,Io(t,fAe,Ji.searchComparator)}jf.prototype.computeSurroundingRenderableKeyframeNodes=function(e){let t=this,n=t.level,i=Math.floor(e),o=Math.ceil(e),r,s,a=+Number.MAX_VALUE,c=+Number.MAX_VALUE;for(;u(t);){let{renderableKeyframeNodes:d}=t;if(d.length>=1){let p=Ypt(i,d),g=d[p],h=o===i||i<g.keyframe?p:Math.min(p+1,d.length-1),A=d[h],x=i-g.keyframe,C=dAe(n-t.level,x);C<a&&(a=C,r=g);let T=A.keyframe-o,E=dAe(n-t.level,T);if(E<c&&(c=E,s=A),x===0&&T===0)break}t=t.parent}if(this.renderableKeyframeNodePrevious=r,this.renderableKeyframeNodeNext=s,!u(r)||!u(s))return;let l=r.keyframe,f=s.keyframe;this.renderableKeyframeNodeLerp=l===f?0:P.clamp((e-l)/(f-l),0,1)};function Ypt(e,t){let n=TF(e,t);return n<0?P.clamp(~n-1,0,t.length-1):n}function dAe(e,t){let n=Math.exp(e*4),i=t>=0?1:-200;return e*n+t*i}jf.prototype.isVisited=function(e){return this.visitedFrameNumber===e};jf.prototype.createKeyframeNode=function(e){let t=TF(e,this.keyframeNodes);if(t<0){t=~t;let n=new Ji(this,e);this.keyframeNodes.splice(t,0,n)}};jf.prototype.destroyKeyframeNode=function(e,t){let
in vec2 v_textureCoordinates;
void main()
{
vec4 color = texture(u_texture, v_textureCoordinates);
out_FragColor = czm_gammaCorrect(color);
}
`;var vF=`uniform float u_radiusTS;
in vec2 v_textureCoordinates;
vec2 rotate(vec2 p, vec2 direction)
{
return vec2(p.x * direction.x - p.y * direction.y, p.x * direction.y + p.y * direction.x);
}
vec4 addBurst(vec2 position, vec2 direction, float lengthScalar)
{
vec2 rotatedPosition = rotate(position, direction) * vec2(25.0, 0.75);
float radius = length(rotatedPosition) * lengthScalar;
float burst = 1.0 - smoothstep(0.0, 0.55, radius);
return vec4(burst);
}
void main()
{
float lengthScalar = 2.0 / sqrt(2.0);
vec2 position = v_textureCoordinates - vec2(0.5);
float radius = length(position) * lengthScalar;
float surface = step(radius, u_radiusTS);
vec4 color = vec4(vec2(1.0), surface + 0.2, surface);
float glow = 1.0 - smoothstep(0.0, 0.55, radius);
color.ba += mix(vec2(0.0), vec2(1.0), glow) * 0.75;
vec4 burst = vec4(0.0);
// The following loop has been manually unrolled for speed, to
// avoid sin() and cos().
//
//for (float i = 0.4; i < 3.2; i += 1.047) {
// vec2 direction = vec2(sin(i), cos(i));
// burst += 0.4 * addBurst(position, direction, lengthScalar);
//
// direction = vec2(sin(i - 0.08), cos(i - 0.08));
// burst += 0.3 * addBurst(position, direction, lengthScalar);
//}
burst += 0.4 * addBurst(position, vec2(0.38942, 0.92106), lengthScalar); // angle == 0.4
burst += 0.4 * addBurst(position, vec2(0.99235, 0.12348), lengthScalar); // angle == 0.4 + 1.047
burst += 0.4 * addBurst(position, vec2(0.60327, -0.79754), lengthScalar); // angle == 0.4 + 1.047 * 2.0
burst += 0.3 * addBurst(position, vec2(0.31457, 0.94924), lengthScalar); // angle == 0.4 - 0.08
burst += 0.3 * addBurst(position, vec2(0.97931, 0.20239), lengthScalar); // angle == 0.4 + 1.047 - 0.08
burst += 0.3 * addBurst(position, vec2(0.66507, -0.74678), lengthScalar); // angle == 0.4 + 1.047 * 2.0 - 0.08
// End of manual loop unrolling.
color += clamp(burst, vec4(0.0), vec4(1.0)) * 0.15;
out_FragColor = clamp(color, vec4(0.0), vec4(1.0));
}
`;var wF=`in vec2 direction;
uniform float u_size;
out vec2 v_textureCoordinates;
void main()
{
vec4 position;
if (czm_morphTime == 1.0)
{
position = vec4(czm_sunPositionWC, 1.0);
}
else
{
position = vec4(czm_sunPositionColumbusView.zxy, 1.0);
}
vec4 positionEC = czm_view * position;
vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);
vec2 halfSize = vec2(u_size * 0.5);
halfSize *= ((direction * 2.0) - 1.0);
gl_Position = czm_viewportOrthographic * vec4(positionWC.xy + halfSize, -positionWC.z, 1.0);
v_textureCoordinates = direction;
}
`;function IF(){this.show=!0,this._drawCommand=new nt({primitiveType:Le.TRIANGLES,boundingVolume:new ae,owner:this}),this._commands={drawCommand:this._drawCommand,computeCommand:void 0},this._boundingVolume=new ae,this._boundingVolume2D=new ae,this._texture=void 0,this._drawingBufferWidth=void 0,this._drawingBufferHeight=void 0,this._radiusTS=void 0,this._size=void 0,this.glowFactor=1,this._glowFactorDirty=!1,this._useHdr=void 0;let e=this;this._uniformMap={u_texture:function(){return e._texture},u_size:function(){return e._size}}}Object.defineProperties(IF.prototype,{glowFactor:{get:function(){return this._glowFactor},set:function(e){e=Math.max(e,0),this._glowFactor=e,this._glowFactorDirty=!0}}});var qpt=new H,Xpt=new H,Kpt=new re,DF=new re;IF.prototype.update=function(e,t,n){if(!this.show)return;let i=e.mode;if(i===ne.SCENE2D||i===ne.MORPHING||!e.passes.render)return;let o=e.context,r=t.viewport.width,s=t.viewport.height;if(!u(this._texture)||r!==this._drawingBufferWidth||s!==this._drawingBufferHeight||this._glowFactorDirty||n!==this._useHdr){this._texture=this._texture&&this._texture.destroy(),this._drawingBufferWidth=r,this._drawingBufferHeight=s,this._glowFactorDirty=!1,this._useHdr=n;let S=Math.max(r,s);S=Math.pow(2,Math.ceil(Math.log(S)/Math.log(2))-2),S=Math.max(1,S);let w=n?o.halfFloatingPointTexture?Ke.HALF_FLOAT:Ke.FLOAT:Ke.UNSIGNED_BYTE;this._texture=new Mt({context:o,width:S,height:S,pixelFormat:st.RGBA,pixelDatatype:w}),this._glowLengthTS=this._glowFactor*5,this._radiusTS=1/(1+2*this._glowLengthTS)*.5;let D=this,M={u_radiusTS:function(){return D._radiusTS}};this._commands.computeCommand=new Ku({fragmentShaderSource:vF,outputTexture:this._texture,uniformMap:M,persists:!1,owner:this,postExecute:function(){D._commands.computeCommand=void 0}})}let a=this._drawCommand;if(!u(a.vertexArray)){let S={direction:0},w=new Uint8Array(4*2);w[0]=0,w[1]=0,w[2]=255,w[3]=0,w[4]=255,w[5]=255,w[6]=0,w[7]=255;let D=ut.createVertexBuffer({context:o,typedArray:w,usage:Fe.STATIC_DRAW}),M=[{index:S.direction,vertexBuffer:D,componentsPerAttribute:2,normalize:!0,componentDatatype:X.UNSIGNED_BYTE}],O=ut.createIndexBuffer({context:o,typedArray:new Uint16Array([0,1,2,0,2,3]),usage:Fe.STATIC_DRAW,indexDatatype:Ue.UNSIGNED_SHORT});a.vertexArray=new si({context:o,attributes:M,indexBuffer:O}),a.shaderProgram=Jt.fromCache({context:o,vertexShaderSource:wF,fragmentShaderSource:SF,attributeLocations:S}),a.renderState=ke.fromCache({blending:un.ALPHA_BLEND}),a.uniformMap=this._uniformMap}let c=o.uniformState.sunPositionWC,l=o.uniformState.sunPositionColumbusView,f=this._boundingVolume,d=this._boundingVolume2D;m.clone(c,f.center),d.center.x=l.z,d.center.y=l.x,d.center.z=l.y,f.radius=P.SOLAR_RADIUS+P.SOLAR_RADIUS*this._glowLengthTS,d.radius=f.radius,i===ne.SCENE3D?ae.clone(f,a.boundingVolume):i===ne.COLUMBUS_VIEW&&ae.clone(d,a.boundingVolume);let p=Ki.computeActualWgs84Position(e,c,DF),g=m.magnitude(m.subtract(p,e.camera.position,DF)),h=o.uniformState.projection,A=Kpt;A.x=0,A.y=0,A.z=-g,A.w=1;let x=B.multiplyByVector(h,A,DF),C=Ki.clipToGLWindowCoordinates(t.viewport,x,qpt);A.x=P.SOLAR_RADIUS;let T=B.multiplyByVector(h,A,DF),E=Ki.clipToGLWindowCoordinates(t.viewport,T,Xpt);return this._size=H.magnitude(H.subtract(E,C,DF)),this._size=2*this._size*(1+2*this._glowLengthTS),this._size=Math.ceil(this._size),this._commands};IF.prototype.isDestroyed=function(){return!1};IF.prototype.destroy=function(){let e=this._drawCommand;return e.vertexArray=e.vertexArray&&e.vertexArray.destroy(),e.shaderProgram=e.shaderProgram&&e.shaderProgram.destroy(),this._texture=this._texture&&this._texture.destroy(),ue(this)};var PF=IF;function nH(e){this._ready=!1,this._provider=void 0,this._errorEvent=new ye,this._readyEvent=new ye,Zpt(this,e)}Object.defineProperties(nH.prototype,{errorEvent:{get:function(){return this._errorEvent}},readyEvent:{get:function(){return this._readyEvent}},ready:{get:function(){return this._ready}},provider:{get:function(){return this._provider}}});nH.fromWorldTerrain=function(e){return new nH(qx(e))};function Jpt(e,t){e.numberOfListeners>0?e.rais
${e}`}function e_t(e){return function(t){return ht(t,{czm_pickColor:function(){return e._pickId.color}})}}function t_t(){return"czm_pickColor"}vC.prototype.makeStyleDirty=function(){this._styleDirty=!0};vC.prototype._getAverageLoadTime=function(){return this._runningLength===0?.05:this._runningAverage};var n_t=new ee;function NX(e){let t=e._clock,n=t.canAnimate&&t.shouldAnimate,i=t.multiplier;return n?i:0}function SC(e,t){return e._intervals.indexOf(t.start)}function i_t(e,t){let n=e._intervals,i=e._clock,o=NX(e);if(o===0)return;let r=e._getAverageLoadTime(),s=ee.addSeconds(i.currentTime,r*o,n_t),a=n.indexOf(s),c=SC(e,t);return a===c&&(o>=0?++a:--a),n.get(a)}function o_t(e){let t=e._intervals,i=e._clock.currentTime,o=t.indexOf(i);return t.get(o)}function r_t(e,t,n){let i=NX(e),o=SC(e,t),r=SC(e,n);return i>=0?o>=r:o<=r}function hAe(e,t){return function(n){let i=u(n.message)?n.message:n.toString();e.frameFailed.numberOfListeners>0?e.frameFailed.raiseEvent({uri:t,message:i}):(console.log(`A frame failed to load: ${t}`),console.log(`Error: ${i}`))}}function s_t(e,t,n){let i=SC(e,t),o=e._frames,r=o[i];if(!u(r)){let s=t.data.transform,a=u(s)?B.fromArray(s):void 0,c=t.data.uri;r={pointCloud:void 0,transform:a,timestamp:yi(),sequential:!0,ready:!1,touchedFrameNumber:n.frameNumber,uri:c},o[i]=r,Ie.fetchArrayBuffer({url:c}).then(function(l){r.pointCloud=new FN({arrayBuffer:l,cull:!0,fragmentShaderLoaded:$pt,uniformMapLoaded:e_t(e),pickIdLoaded:t_t})}).catch(hAe(e,c))}return r}function a_t(e,t){e._runningSum+=t,e._runningSum-=e._runningSamples[e._runningIndex],e._runningSamples[e._runningIndex]=t,e._runningLength=Math.min(e._runningLength+1,e._runningSamples.length),e._runningIndex=(e._runningIndex+1)%e._runningSamples.length,e._runningAverage=e._runningSum/e._runningLength}function c_t(e,t,n,i){t.touchedFrameNumber<i.frameNumber-1&&(t.sequential=!1);let o=t.pointCloud;if(u(o)&&!t.ready){let r=i.commandList,s=r.length;if(pAe(e,t,n,i),o.ready&&(t.ready=!0,e._totalMemoryUsageInBytes+=o.geometryByteLength,r.length=s,t.sequential)){let a=(yi()-t.timestamp)/1e3;a_t(e,a)}}t.touchedFrameNumber=i.frameNumber}var l_t=new B;function u_t(e,t){let n=e.shading;return u(n)&&u(n.baseResolution)?n.baseResolution:u(t.boundingSphere)?P.cbrt(t.boundingSphere.volume()/t.pointsLength):0}function f_t(e){let t=e.shading;return u(t)&&u(t.maximumAttenuation)?t.maximumAttenuation:10}var d_t=new km;function pAe(e,t,n,i){let o=y(e.shading,d_t),r=t.pointCloud,s=y(t.transform,B.IDENTITY);r.modelMatrix=B.multiplyTransformation(e.modelMatrix,s,l_t),r.style=e.style,r.time=n.timeSinceLoad,r.shadows=e.shadows,r.clippingPlanes=e._clippingPlanes,r.isClipped=n.isClipped,r.attenuation=o.attenuation,r.backFaceCulling=o.backFaceCulling,r.normalShading=o.normalShading,r.geometricError=u_t(e,r),r.geometricErrorScale=o.geometricErrorScale,r.maximumAttenuation=f_t(e);try{r.update(i)}catch(a){hAe(e,t.uri)(a)}t.touchedFrameNumber=i.frameNumber}function LX(e,t,n,i){let o=s_t(e,t,i);c_t(e,o,n,i)}function m_t(e){return function(t){return t.touchedFrameNumber<e.frameNumber}}function _Ae(e,t){let n=e._frames,i=n.length;for(let o=0;o<i;++o){let r=n[o];if(u(r)&&(!u(t)||t(r))){let s=r.pointCloud;r.ready&&(e._totalMemoryUsageInBytes-=s.geometryByteLength),u(s)&&s.destroy(),r===e._lastRenderedFrame&&(e._lastRenderedFrame=void 0),n[o]=void 0}}}function h_t(e,t){let n=SC(e,t),i=e._frames[n];if(u(i)&&i.ready)return i}function mAe(e,t,n,i,o){return u(n)?n.ready?!0:(LX(e,t,i,o),n.ready):!1}function p_t(e,t,n,i,o){let r,s,a,c=e._intervals,l=e._frames,f=SC(e,n),d=SC(e,t);if(f>=d){for(r=f;r>=d;--r)if(s=c.get(r),a=l[r],mAe(e,s,a,i,o))return s}else for(r=f;r<=d;++r)if(s=c.get(r),a=l[r],mAe(e,s,a,i,o))return s;return t}function __t(e,t,n){let i=e._frames,o=i.length;for(let r=0;r<o;++r){let s=i[r];u(s)&&u(s.pointCloud)&&(s.pointCloud.clippingPlanesDirty=t,s.pointCloud.styleDirty=n)}}var FS={timeSinceLoad:0,isClipped:!1,clippingPlanesDirty:!1};vC.prototype.update=function(e){if(e.mode===ne.MORPHING||!this.show)return;u(this._pickId)||(this._pickId=e.context.createPickId({primitive:this})),u(this._lo
in vec2 v_textureCoordinates;
void main()
{
czm_materialInput materialInput;
materialInput.s = v_textureCoordinates.s;
materialInput.st = v_textureCoordinates;
materialInput.str = vec3(v_textureCoordinates, 0.0);
materialInput.normalEC = vec3(0.0, 0.0, -1.0);
czm_material material = czm_getMaterial(materialInput);
out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
}
`;function iH(e,t){this.show=!0,u(e)||(e=new qe),this.rectangle=qe.clone(e),u(t)||(t=zi.fromType(zi.ColorType,{color:new k(1,1,1,1)})),this.material=t,this._material=void 0,this._overlayCommand=void 0,this._rs=void 0}iH.prototype.update=function(e){if(!this.show)return;let t=this._rs;if((!u(t)||!qe.equals(t.viewport,this.rectangle))&&(this._rs=ke.fromCache({blending:un.ALPHA_BLEND,viewport:this.rectangle})),e.passes.render){let i=e.context;if(this._material!==this.material||!u(this._overlayCommand)){this._material=this.material,u(this._overlayCommand)&&this._overlayCommand.shaderProgram.destroy();let o=new He({sources:[this._material.shaderSource,BF]});this._overlayCommand=i.createViewportQuadCommand(o,{renderState:this._rs,uniformMap:this._material._uniforms,owner:this}),this._overlayCommand.pass=be.OVERLAY}this._material.update(i),this._overlayCommand.renderState=this._rs,this._overlayCommand.uniformMap=this._material._uniforms,e.commandList.push(this._overlayCommand)}};iH.prototype.isDestroyed=function(){return!1};iH.prototype.destroy=function(){return u(this._overlayCommand)&&(this._overlayCommand.shaderProgram=this._overlayCommand.shaderProgram&&this._overlayCommand.shaderProgram.destroy()),ue(this)};var FX=iH;var LF=`// See Intersection.glsl for the definition of intersectScene
// See IntersectionUtils.glsl for the definition of nextIntersection
// See convertUvToBox.glsl, convertUvToCylinder.glsl, or convertUvToEllipsoid.glsl
// for the definition of convertUvToShapeUvSpace. The appropriate function is
// selected based on the VoxelPrimitive shape type, and added to the shader in
// Scene/VoxelRenderResources.js.
// See Octree.glsl for the definitions of TraversalData, SampleData,
// traverseOctreeFromBeginning, and traverseOctreeFromExisting
// See Megatexture.glsl for the definition of accumulatePropertiesFromMegatexture
#define STEP_COUNT_MAX 1000 // Harcoded value because GLSL doesn't like variable length loops
#define ALPHA_ACCUM_MAX 0.98 // Must be > 0.0 and <= 1.0
uniform mat3 u_transformDirectionViewToLocal;
uniform vec3 u_cameraPositionUv;
uniform float u_stepSize;
#if defined(PICKING)
uniform vec4 u_pickColor;
#endif
#if defined(JITTER)
float hash(vec2 p)
{
vec3 p3 = fract(vec3(p.xyx) * 50.0); // magic number = hashscale
p3 += dot(p3, p3.yzx + 19.19);
return fract((p3.x + p3.y) * p3.z);
}
#endif
vec4 getStepSize(in SampleData sampleData, in Ray viewRay, in RayShapeIntersection shapeIntersection) {
#if defined(SHAPE_BOX)
Box voxelBox = constructVoxelBox(sampleData.tileCoords, sampleData.tileUv);
RayShapeIntersection voxelIntersection = intersectBox(viewRay, voxelBox);
vec4 entry = shapeIntersection.entry.w >= voxelIntersection.entry.w ? shapeIntersection.entry : voxelIntersection.entry;
float exit = min(voxelIntersection.exit.w, shapeIntersection.exit.w);
float dt = (exit - entry.w) * RAY_SCALE;
return vec4(normalize(entry.xyz), dt);
#else
float dimAtLevel = pow(2.0, float(sampleData.tileCoords.w));
return vec4(viewRay.dir, u_stepSize / dimAtLevel);
#endif
}
void main()
{
vec4 fragCoord = gl_FragCoord;
vec2 screenCoord = (fragCoord.xy - czm_viewport.xy) / czm_viewport.zw; // [0,1]
vec3 eyeDirection = normalize(czm_windowToEyeCoordinates(fragCoord).xyz);
vec3 viewDirWorld = normalize(czm_inverseViewRotation * eyeDirection); // normalize again just in case
vec3 viewDirUv = normalize(u_transformDirectionViewToLocal * eyeDirection); // normalize again just in case
vec3 viewPosUv = u_cameraPositionUv;
#if defined(SHAPE_BOX)
vec3 dInv = 1.0 / viewDirUv;
Ray viewRayUv = Ray(viewPosUv, viewDirUv, dInv);
#else
Ray viewRayUv = Ray(viewPosUv, viewDirUv);
#endif
Intersections ix;
RayShapeIntersection shapeIntersection = intersectScene(screenCoord, viewRayUv, ix);
// Exit early if the scene was completely missed.
if (shapeIntersection.entry.w == NO_HIT) {
discard;
}
float currT = shapeIntersection.entry.w * RAY_SCALE;
float endT = shapeIntersection.exit.w;
vec3 positionUv = viewPosUv + currT * viewDirUv;
vec3 positionUvShapeSpace = convertUvToShapeUvSpace(positionUv);
// Traverse the tree from the start position
TraversalData traversalData;
SampleData sampleDatas[SAMPLE_COUNT];
traverseOctreeFromBeginning(positionUvShapeSpace, traversalData, sampleDatas);
vec4 step = getStepSize(sampleDatas[0], viewRayUv, shapeIntersection);
#if defined(JITTER)
float noise = hash(screenCoord); // [0,1]
currT += noise * step.w;
positionUv += noise * step.w * viewDirUv;
#endif
FragmentInput fragmentInput;
#if defined(STATISTICS)
setStatistics(fragmentInput.metadata.statistics);
#endif
vec4 colorAccum =vec4(0.0);
for (int stepCount = 0; stepCount < STEP_COUNT_MAX; ++stepCount) {
// Read properties from the megatexture based on the traversal state
Properties properties = accumulatePropertiesFromMegatexture(sampleDatas);
// Prepare the custom shader inputs
copyPropertiesToMetadata(properties, fragmentInput.metadata);
fragmentInput.voxel.positionUv = positionUv;
fragmentInput.voxel.positionShapeUv = positionUvShapeSpace;
fragmentInput.voxel.positionUvLocal = sampleDatas[0].tileUv;
fragmentInput.voxel.viewDirUv = viewDirUv;
fragmentInput.voxel.viewDirWorld = viewDirWorld;
fragmentInput.voxel.surfaceNormal = step.xyz;
fragmentInput.voxel.travelDistance = step.w;
// Run the custom shader
czm_modelMaterial materialOutput;
fragmentMain(fragmentInput, materialOutput);
// Sanitize the custom shader output
vec4 color = vec4(materialOutput.diffuse, materialOutput.alpha);
color.rgb = max(color.rgb, vec3(0.0));
color.a = clamp(color.a, 0.0, 1.0);
// Pre-multiplied alpha blend
colorAccum += (1.0 - colorAccum.a) * vec4(color.rgb * color.a, color.a);
// Stop traversing if the alpha has been fully saturated
if (colorAccum.a > ALPHA_ACCUM_MAX) {
colorAccum.a = ALPHA_ACCUM_MAX;
break;
}
if (step.w == 0.0) {
// Shape is infinitely thin. The ray may have hit the edge of a
// foreground voxel. Step ahead slightly to check for more voxels
step.w == 0.00001;
}
// Keep raymarching
currT += step.w;
positionUv += step.w * viewDirUv;
// Check if there's more intersections.
if (currT > endT) {
#if (INTERSECTION_COUNT == 1)
break;
#else
shapeIntersection = nextIntersection(ix);
if (shapeIntersection.entry.w == NO_HIT) {
break;
} else {
// Found another intersection. Resume raymarching there
currT = shapeIntersection.entry.w * RAY_SCALE;
endT = shapeIntersection.exit.w;
positionUv = viewPosUv + currT * viewDirUv;
}
#endif
}
// Traverse the tree from the current ray position.
// This is similar to traverseOctreeFromBeginning but is faster when the ray is in the same tile as the previous step.
positionUvShapeSpace = convertUvToShapeUvSpace(positionUv);
traverseOctreeFromExisting(positionUvShapeSpace, traversalData, sampleDatas);
step = getStepSize(sampleDatas[0], viewRayUv, shapeIntersection);
}
// Convert the alpha from [0,ALPHA_ACCUM_MAX] to [0,1]
colorAccum.a /= ALPHA_ACCUM_MAX;
#if defined(PICKING)
// If alpha is 0.0 there is nothing to pick
if (colorAccum.a == 0.0) {
discard;
}
out_FragColor = u_pickColor;
#else
out_FragColor = colorAccum;
#endif
}
`;var NF=`in vec2 position;
uniform vec4 u_ndcSpaceAxisAlignedBoundingBox;
void main() {
vec2 aabbMin = u_ndcSpaceAxisAlignedBoundingBox.xy;
vec2 aabbMax = u_ndcSpaceAxisAlignedBoundingBox.zw;
vec2 translation = 0.5 * (aabbMax + aabbMin);
vec2 scale = 0.5 * (aabbMax - aabbMin);
gl_Position = vec4(position * scale + translation, 0.0, 1.0);
}
`;var FF=`/* Intersection defines
#define INTERSECTION_COUNT ###
*/
#define NO_HIT (-czm_infinity)
#define INF_HIT (czm_infinity * 0.5)
#define RAY_SHIFT (0.000003163)
#define RAY_SCALE (1.003163)
struct Ray {
vec3 pos;
vec3 dir;
#if defined(SHAPE_BOX)
vec3 dInv;
#endif
};
struct RayShapeIntersection {
vec4 entry;
vec4 exit;
};
struct Intersections {
// Don't access these member variables directly - call the functions instead.
// Store an array of ray-surface intersections. Each intersection is composed of:
// .xyz for the surface normal at the intersection point
// .w for the T value
// The scale of the normal encodes the shape intersection type:
// length(intersection.xyz) = 1: positive shape entry
// length(intersection.xyz) = 2: positive shape exit
// length(intersection.xyz) = 3: negative shape entry
// length(intersection.xyz) = 4: negative shape exit
// INTERSECTION_COUNT is the number of ray-*shape* (volume) intersections,
// so we need twice as many to track ray-*surface* intersections
vec4 intersections[INTERSECTION_COUNT * 2];
#if (INTERSECTION_COUNT > 1)
// Maintain state for future nextIntersection calls
int index;
int surroundCount;
bool surroundIsPositive;
#endif
};
RayShapeIntersection getFirstIntersection(in Intersections ix)
{
return RayShapeIntersection(ix.intersections[0], ix.intersections[1]);
}
vec4 encodeIntersectionType(vec4 intersection, int index, bool entry)
{
float scale = float(index > 0) * 2.0 + float(!entry) + 1.0;
return vec4(intersection.xyz * scale, intersection.w);
}
// Use defines instead of real functions because WebGL1 cannot access array with non-constant index.
#define setIntersection(/*inout Intersections*/ ix, /*int*/ index, /*float*/ t, /*bool*/ positive, /*bool*/ enter) (ix).intersections[(index)] = vec4(0.0, float(!positive) * 2.0 + float(!enter) + 1.0, 0.0, (t))
#define setIntersectionPair(/*inout Intersections*/ ix, /*int*/ index, /*vec2*/ entryExit) (ix).intersections[(index) * 2 + 0] = vec4(0.0, float((index) > 0) * 2.0 + 1.0, 0.0, (entryExit).x); (ix).intersections[(index) * 2 + 1] = vec4(0.0, float((index) > 0) * 2.0 + 2.0, 0.0, (entryExit).y)
#define setSurfaceIntersection(/*inout Intersections*/ ix, /*int*/ index, /*vec4*/ intersection) (ix).intersections[(index)] = intersection;
#define setShapeIntersection(/*inout Intersections*/ ix, /*int*/ index, /*RayShapeIntersection*/ intersection) (ix).intersections[(index) * 2 + 0] = encodeIntersectionType((intersection).entry, (index), true); (ix).intersections[(index) * 2 + 1] = encodeIntersectionType((intersection).exit, (index), false)
#if (INTERSECTION_COUNT > 1)
void initializeIntersections(inout Intersections ix) {
// Sort the intersections from min T to max T with bubble sort.
// Note: If this sorting function changes, some of the intersection test may
// need to be updated. Search for "bubble sort" to find those areas.
const int sortPasses = INTERSECTION_COUNT * 2 - 1;
for (int n = sortPasses; n > 0; --n) {
for (int i = 0; i < sortPasses; ++i) {
// The loop should be: for (i = 0; i < n; ++i) {...} but WebGL1 cannot
// loop with non-constant condition, so it has to break early instead
if (i >= n) { break; }
vec4 intersect0 = ix.intersections[i + 0];
vec4 intersect1 = ix.intersections[i + 1];
bool inOrder = intersect0.w <= intersect1.w;
ix.intersections[i + 0] = inOrder ? intersect0 : intersect1;
ix.intersections[i + 1] = inOrder ? intersect1 : intersect0;
}
}
// Prepare initial state for nextIntersection
ix.index = 0;
ix.surroundCount = 0;
ix.surroundIsPositive = false;
}
#endif
#if (INTERSECTION_COUNT > 1)
RayShapeIntersection nextIntersection(inout Intersections ix) {
vec4 surfaceIntersection = vec4(0.0, 0.0, 0.0, NO_HIT);
RayShapeIntersection shapeIntersection = RayShapeIntersection(surfaceIntersection, surfaceIntersection);
const int passCount = INTERSECTION_COUNT * 2;
if (ix.index == passCount) {
return shapeIntersection;
}
for (int i = 0; i < passCount; ++i) {
// The loop should be: for (i = ix.index; i < passCount; ++i) {...} but WebGL1 cannot
// loop with non-constant condition, so it has to continue instead.
if (i < ix.index) {
continue;
}
ix.index = i + 1;
surfaceIntersection = ix.intersections[i];
int intersectionType = int(length(surfaceIntersection.xyz) - 0.5);
bool currShapeIsPositive = intersectionType < 2;
bool enter = intMod(intersectionType, 2) == 0;
ix.surroundCount += enter ? +1 : -1;
ix.surroundIsPositive = currShapeIsPositive ? enter : ix.surroundIsPositive;
// entering positive or exiting negative
if (ix.surroundCount == 1 && ix.surroundIsPositive && enter == currShapeIsPositive) {
shapeIntersection.entry = surfaceIntersection;
}
// exiting positive or entering negative after being inside positive
bool exitPositive = !enter && currShapeIsPositive && ix.surroundCount == 0;
bool enterNegativeFromPositive = enter && !currShapeIsPositive && ix.surroundCount == 2 && ix.surroundIsPositive;
if (exitPositive || enterNegativeFromPositive) {
shapeIntersection.exit = surfaceIntersection;
// entry and exit have been found, so the loop can stop
if (exitPositive) {
// After exiting positive shape there is nothing left to intersect, so jump to the end index.
ix.index = passCount;
}
break;
}
}
return shapeIntersection;
}
#endif
// NOTE: initializeIntersections, nextIntersection aren't even declared unless INTERSECTION_COUNT > 1
`;var UF=`// See IntersectionUtils.glsl for the definitions of Ray, Intersections,
// setIntersectionPair, INF_HIT, NO_HIT
/* intersectDepth defines (set in Scene/VoxelRenderResources.js)
#define DEPTH_INTERSECTION_INDEX ###
*/
uniform mat4 u_transformPositionViewToUv;
void intersectDepth(in vec2 screenCoord, in Ray ray, inout Intersections ix) {
float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord));
if (logDepthOrDepth != 0.0) {
// Calculate how far the ray must travel before it hits the depth buffer.
vec4 eyeCoordinateDepth = czm_screenToEyeCoordinates(screenCoord, logDepthOrDepth);
eyeCoordinateDepth /= eyeCoordinateDepth.w;
vec3 depthPositionUv = vec3(u_transformPositionViewToUv * eyeCoordinateDepth);
float t = dot(depthPositionUv - ray.pos, ray.dir);
setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(t, +INF_HIT));
} else {
// There's no depth at this location.
setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(NO_HIT));
}
}
`;var VF=`// See IntersectionUtils.glsl for the definitions of Ray, Intersections, INF_HIT,
// NO_HIT, setIntersectionPair
/* Clipping plane defines (set in Scene/VoxelRenderResources.js)
#define CLIPPING_PLANES_UNION
#define CLIPPING_PLANES_COUNT
#define CLIPPING_PLANES_INTERSECTION_INDEX
*/
uniform sampler2D u_clippingPlanesTexture;
uniform mat4 u_clippingPlanesMatrix;
// Plane is in Hessian Normal Form
vec4 intersectPlane(in Ray ray, in vec4 plane) {
vec3 n = plane.xyz; // normal
float w = plane.w; // -dot(pointOnPlane, normal)
float a = dot(ray.pos, n);
float b = dot(ray.dir, n);
float t = -(w + a) / b;
return vec4(n, t);
}
void intersectClippingPlanes(in Ray ray, inout Intersections ix) {
vec4 backSide = vec4(-ray.dir, -INF_HIT);
vec4 farSide = vec4(ray.dir, +INF_HIT);
RayShapeIntersection clippingVolume;
#if (CLIPPING_PLANES_COUNT == 1)
// Union and intersection are the same when there's one clipping plane, and the code
// is more simplified.
vec4 planeUv = getClippingPlane(u_clippingPlanesTexture, 0, u_clippingPlanesMatrix);
vec4 intersection = intersectPlane(ray, planeUv);
bool reflects = dot(ray.dir, intersection.xyz) < 0.0;
clippingVolume.entry = reflects ? backSide : intersection;
clippingVolume.exit = reflects ? intersection : farSide;
setShapeIntersection(ix, CLIPPING_PLANES_INTERSECTION_INDEX, clippingVolume);
#elif defined(CLIPPING_PLANES_UNION)
vec4 firstTransmission = vec4(ray.dir, +INF_HIT);
vec4 lastReflection = vec4(-ray.dir, -INF_HIT);
for (int i = 0; i < CLIPPING_PLANES_COUNT; i++) {
vec4 planeUv = getClippingPlane(u_clippingPlanesTexture, i, u_clippingPlanesMatrix);
vec4 intersection = intersectPlane(ray, planeUv);
if (dot(ray.dir, planeUv.xyz) > 0.0) {
firstTransmission = intersection.w <= firstTransmission.w ? intersection : firstTransmission;
} else {
lastReflection = intersection.w >= lastReflection.w ? intersection : lastReflection;
}
}
clippingVolume.entry = backSide;
clippingVolume.exit = lastReflection;
setShapeIntersection(ix, CLIPPING_PLANES_INTERSECTION_INDEX + 0, clippingVolume);
clippingVolume.entry = firstTransmission;
clippingVolume.exit = farSide;
setShapeIntersection(ix, CLIPPING_PLANES_INTERSECTION_INDEX + 1, clippingVolume);
#else // intersection
vec4 lastTransmission = vec4(ray.dir, -INF_HIT);
vec4 firstReflection = vec4(-ray.dir, +INF_HIT);
for (int i = 0; i < CLIPPING_PLANES_COUNT; i++) {
vec4 planeUv = getClippingPlane(u_clippingPlanesTexture, i, u_clippingPlanesMatrix);
vec4 intersection = intersectPlane(ray, planeUv);
if (dot(ray.dir, planeUv.xyz) > 0.0) {
lastTransmission = intersection.w > lastTransmission.w ? intersection : lastTransmission;
} else {
firstReflection = intersection.w < firstReflection.w ? intersection: firstReflection;
}
}
if (lastTransmission.w < firstReflection.w) {
clippingVolume.entry = lastTransmission;
clippingVolume.exit = firstReflection;
} else {
clippingVolume.entry = vec4(-ray.dir, NO_HIT);
clippingVolume.exit = vec4(ray.dir, NO_HIT);
}
setShapeIntersection(ix, CLIPPING_PLANES_INTERSECTION_INDEX, clippingVolume);
#endif
}
`;var kF=`// See IntersectionUtils.glsl for the definitions of Ray and NO_HIT
// See convertUvToBox.glsl for the definition of convertShapeUvToUvSpace
/* Box defines (set in Scene/VoxelBoxShape.js)
#define BOX_INTERSECTION_INDEX ### // always 0
*/
uniform vec3 u_renderMinBounds;
uniform vec3 u_renderMaxBounds;
struct Box {
vec3 p0;
vec3 p1;
};
Box constructVoxelBox(in ivec4 octreeCoords, in vec3 tileUv)
{
// Find the min/max cornerpoints of the voxel in tile coordinates
vec3 tileOrigin = vec3(octreeCoords.xyz);
vec3 numSamples = vec3(u_dimensions);
vec3 voxelSize = 1.0 / numSamples;
vec3 coordP0 = floor(tileUv * numSamples) * voxelSize + tileOrigin;
vec3 coordP1 = coordP0 + voxelSize;
// Transform to the UV coordinates of the scaled tileset
float tileSize = 1.0 / pow(2.0, float(octreeCoords.w));
vec3 p0 = convertShapeUvToUvSpace(coordP0 * tileSize);
vec3 p1 = convertShapeUvToUvSpace(coordP1 * tileSize);
return Box(p0, p1);
}
vec3 getBoxNormal(in Box box, in Ray ray, in float t)
{
vec3 hitPoint = ray.pos + t * ray.dir;
vec3 lower = step(hitPoint, box.p0);
vec3 upper = step(box.p1, hitPoint);
return normalize(upper - lower);
}
// Find the distances along a ray at which the ray intersects an axis-aligned box
// See https://tavianator.com/2011/ray_box.html
RayShapeIntersection intersectBox(in Ray ray, in Box box)
{
// Consider the box as the intersection of the space between 3 pairs of parallel planes
// Compute the distance along the ray to each plane
vec3 t0 = (box.p0 - ray.pos) * ray.dInv;
vec3 t1 = (box.p1 - ray.pos) * ray.dInv;
// Identify candidate entries/exits based on distance from ray.pos
vec3 entries = min(t0, t1);
vec3 exits = max(t0, t1);
// The actual box intersection points are the furthest entry and the closest exit
float entryT = max(max(entries.x, entries.y), entries.z);
float exitT = min(min(exits.x, exits.y), exits.z);
vec3 entryNormal = getBoxNormal(box, ray, entryT - RAY_SHIFT);
vec3 exitNormal = getBoxNormal(box, ray, exitT + RAY_SHIFT);
if (entryT > exitT) {
entryT = NO_HIT;
exitT = NO_HIT;
}
return RayShapeIntersection(vec4(entryNormal, entryT), vec4(exitNormal, exitT));
}
void intersectShape(in Ray ray, inout Intersections ix)
{
RayShapeIntersection intersection = intersectBox(ray, Box(u_renderMinBounds, u_renderMaxBounds));
setShapeIntersection(ix, BOX_INTERSECTION_INDEX, intersection);
}
`;var zF=`// See IntersectionUtils.glsl for the definitions of Ray, setIntersection,
// setIntersectionPair
/* Cylinder defines (set in Scene/VoxelCylinderShape.js)
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MAX
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT
#define CYLINDER_HAS_RENDER_BOUNDS_HEIGHT
#define CYLINDER_HAS_RENDER_BOUNDS_HEIGHT_FLAT
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_HALF
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_ZERO
#define CYLINDER_HAS_SHAPE_BOUNDS_RADIUS
#define CYLINDER_HAS_SHAPE_BOUNDS_RADIUS_FLAT
#define CYLINDER_HAS_SHAPE_BOUNDS_HEIGHT
#define CYLINDER_HAS_SHAPE_BOUNDS_HEIGHT_FLAT
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_RANGE_EQUAL_ZERO
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_DISCONTINUITY
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MAX_DISCONTINUITY
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_MAX_REVERSED
#define CYLINDER_INTERSECTION_INDEX_RADIUS_MAX
#define CYLINDER_INTERSECTION_INDEX_RADIUS_MIN
#define CYLINDER_INTERSECTION_INDEX_ANGLE
*/
// Cylinder uniforms
#if defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MAX) || defined(CYLINDER_HAS_RENDER_BOUNDS_HEIGHT)
uniform vec3 u_cylinderUvToRenderBoundsScale;
uniform vec3 u_cylinderUvToRenderBoundsTranslate;
#endif
#if defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN) && !defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT)
uniform float u_cylinderUvToRenderRadiusMin;
#endif
#if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE)
uniform vec2 u_cylinderRenderAngleMinMax;
#endif
vec4 intersectHalfPlane(Ray ray, float angle) {
vec2 o = ray.pos.xy;
vec2 d = ray.dir.xy;
vec2 planeDirection = vec2(cos(angle), sin(angle));
vec2 planeNormal = vec2(planeDirection.y, -planeDirection.x);
float a = dot(o, planeNormal);
float b = dot(d, planeNormal);
float t = -a / b;
vec2 p = o + t * d;
bool outside = dot(p, planeDirection) < 0.0;
if (outside) return vec4(-INF_HIT, +INF_HIT, NO_HIT, NO_HIT);
return vec4(-INF_HIT, t, t, +INF_HIT);
}
#define POSITIVE_HIT vec2(t, +INF_HIT);
#define NEGATIVE_HIT vec2(-INF_HIT, t);
vec2 intersectHalfSpace(Ray ray, float angle)
{
vec2 o = ray.pos.xy;
vec2 d = ray.dir.xy;
vec2 n = vec2(sin(angle), -cos(angle));
float a = dot(o, n);
float b = dot(d, n);
float t = -a / b;
float s = sign(a);
// Half space cuts right through the camera, pick the side to intersect
if (a == 0.0) {
if (b >= 0.0) {
return POSITIVE_HIT;
} else {
return NEGATIVE_HIT;
}
}
if (t >= 0.0 != s >= 0.0) {
return POSITIVE_HIT;
} else {
return NEGATIVE_HIT;
}
}
vec2 intersectRegularWedge(Ray ray, float minAngle, float maxAngle)
{
vec2 o = ray.pos.xy;
vec2 d = ray.dir.xy;
vec2 n1 = vec2(sin(minAngle), -cos(minAngle));
vec2 n2 = vec2(-sin(maxAngle), cos(maxAngle));
float a1 = dot(o, n1);
float a2 = dot(o, n2);
float b1 = dot(d, n1);
float b2 = dot(d, n2);
float t1 = -a1 / b1;
float t2 = -a2 / b2;
float s1 = sign(a1);
float s2 = sign(a2);
float tmin = min(t1, t2);
float tmax = max(t1, t2);
float smin = tmin == t1 ? s1 : s2;
float smax = tmin == t1 ? s2 : s1;
bool e = tmin >= 0.0;
bool f = tmax >= 0.0;
bool g = smin >= 0.0;
bool h = smax >= 0.0;
if (e != g && f == h) return vec2(tmin, tmax);
else if (e == g && f == h) return vec2(-INF_HIT, tmin);
else if (e != g && f != h) return vec2(tmax, +INF_HIT);
else return vec2(NO_HIT);
}
vec4 intersectFlippedWedge(Ray ray, float minAngle, float maxAngle)
{
vec2 planeIntersectMin = intersectHalfSpace(ray, minAngle);
vec2 planeIntersectMax = intersectHalfSpace(ray, maxAngle + czm_pi);
return vec4(planeIntersectMin, planeIntersectMax);
}
vec2 intersectUnitCylinder(Ray ray)
{
vec3 o = ray.pos;
vec3 d = ray.dir;
float a = dot(d.xy, d.xy);
float b = dot(o.xy, d.xy);
float c = dot(o.xy, o.xy) - 1.0;
float det = b * b - a * c;
if (det < 0.0) {
return vec2(NO_HIT);
}
det = sqrt(det);
float ta = (-b - det) / a;
float tb = (-b + det) / a;
float t1 = min(ta, tb);
float t2 = max(ta, tb);
float z1 = o.z + t1 * d.z;
float z2 = o.z + t2 * d.z;
if (abs(z1) >= 1.0)
{
float tCap = (sign(z1) - o.z) / d.z;
t1 = abs(b + a * tCap) < det ? tCap : NO_HIT;
}
if (abs(z2) >= 1.0)
{
float tCap = (sign(z2) - o.z) / d.z;
t2 = abs(b + a * tCap) < det ? tCap : NO_HIT;
}
return vec2(t1, t2);
}
vec2 intersectUnitCircle(Ray ray) {
vec3 o = ray.pos;
vec3 d = ray.dir;
float t = -o.z / d.z;
vec2 zPlanePos = o.xy + d.xy * t;
float distSqr = dot(zPlanePos, zPlanePos);
if (distSqr > 1.0) {
return vec2(NO_HIT);
}
return vec2(t, t);
}
vec2 intersectInfiniteUnitCylinder(Ray ray)
{
vec3 o = ray.pos;
vec3 d = ray.dir;
float a = dot(d.xy, d.xy);
float b = dot(o.xy, d.xy);
float c = dot(o.xy, o.xy) - 1.0;
float det = b * b - a * c;
if (det < 0.0) {
return vec2(NO_HIT);
}
det = sqrt(det);
float t1 = (-b - det) / a;
float t2 = (-b + det) / a;
float tmin = min(t1, t2);
float tmax = max(t1, t2);
return vec2(tmin, tmax);
}
void intersectShape(Ray ray, inout Intersections ix)
{
#if defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MAX) || defined(CYLINDER_HAS_RENDER_BOUNDS_HEIGHT)
ray.pos = ray.pos * u_cylinderUvToRenderBoundsScale + u_cylinderUvToRenderBoundsTranslate;
ray.dir *= u_cylinderUvToRenderBoundsScale;
#else
// Position is converted from [0,1] to [-1,+1] because shape intersections assume unit space is [-1,+1].
// Direction is scaled as well to be in sync with position.
ray.pos = ray.pos * 2.0 - 1.0;
ray.dir *= 2.0;
#endif
#if defined(CYLINDER_HAS_RENDER_BOUNDS_HEIGHT_FLAT)
vec2 outerIntersect = intersectUnitCircle(ray);
#else
vec2 outerIntersect = intersectUnitCylinder(ray);
#endif
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MAX, outerIntersect);
if (outerIntersect.x == NO_HIT) {
return;
}
#if defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT)
// When the cylinder is perfectly thin it's necessary to sandwich the
// inner cylinder intersection inside the outer cylinder intersection.
// Without this special case,
// [outerMin, outerMax, innerMin, innerMax] will bubble sort to
// [outerMin, innerMin, outerMax, innerMax] which will cause the back
// side of the cylinder to be invisible because it will think the ray
// is still inside the inner (negative) cylinder after exiting the
// outer (positive) cylinder.
// With this special case,
// [outerMin, innerMin, innerMax, outerMax] will bubble sort to
// [outerMin, innerMin, innerMax, outerMax] which will work correctly.
// Note: If initializeIntersections() changes its sorting function
// from bubble sort to something else, this code may need to change.
vec2 innerIntersect = intersectInfiniteUnitCylinder(ray);
setIntersection(ix, 0, outerIntersect.x, true, true); // positive, enter
setIntersection(ix, 1, innerIntersect.x, false, true); // negative, enter
setIntersection(ix, 2, innerIntersect.y, false, false); // negative, exit
setIntersection(ix, 3, outerIntersect.y, true, false); // positive, exit
#elif defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN)
Ray innerRay = Ray(ray.pos * u_cylinderUvToRenderRadiusMin, ray.dir * u_cylinderUvToRenderRadiusMin);
vec2 innerIntersect = intersectInfiniteUnitCylinder(innerRay);
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MIN, innerIntersect);
#endif
#if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF)
vec2 wedgeIntersect = intersectRegularWedge(ray, u_cylinderRenderAngleMinMax.x, u_cylinderRenderAngleMinMax.y);
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_ANGLE, wedgeIntersect);
#elif defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF)
vec4 wedgeIntersect = intersectFlippedWedge(ray, u_cylinderRenderAngleMinMax.x, u_cylinderRenderAngleMinMax.y);
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 0, wedgeIntersect.xy);
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 1, wedgeIntersect.zw);
#elif defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_HALF)
vec2 wedgeIntersect = intersectHalfSpace(ray, u_cylinderRenderAngleMinMax.x);
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_ANGLE, wedgeIntersect);
#elif defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_ZERO)
vec4 wedgeIntersect = intersectHalfPlane(ray, u_cylinderRenderAngleMinMax.x);
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 0, wedgeIntersect.xy);
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 1, wedgeIntersect.zw);
#endif
}
`;var HF=`// See IntersectionUtils.glsl for the definitions of Ray, Intersections,
// setIntersection, setIntersectionPair, INF_HIT, NO_HIT
/* Ellipsoid defines (set in Scene/VoxelEllipsoidShape.js)
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_ZERO
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_UNDER_HALF
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_HALF
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_OVER_HALF
#define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE
#define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_UNDER_HALF
#define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_EQUAL_HALF
#define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_OVER_HALF
#define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_UNDER_HALF
#define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_EQUAL_HALF
#define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_OVER_HALF
#define ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_MAX
#define ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_MIN
#define ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_FLAT
#define ELLIPSOID_INTERSECTION_INDEX_LONGITUDE
#define ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX
#define ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN
#define ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MAX
#define ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MIN
*/
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE)
uniform vec2 u_ellipsoidRenderLongitudeMinMax;
#endif
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_UNDER_HALF) || defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_OVER_HALF) || defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_UNDER_HALF) || defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_OVER_HALF)
uniform vec2 u_ellipsoidRenderLatitudeCosSqrHalfMinMax;
#endif
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_MAX)
uniform float u_ellipsoidInverseOuterScaleUv;
#endif
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_MIN)
uniform float u_ellipsoidInverseInnerScaleUv;
#endif
vec2 intersectZPlane(Ray ray)
{
float o = ray.pos.z;
float d = ray.dir.z;
float t = -o / d;
float s = sign(o);
if (t >= 0.0 != s >= 0.0) return vec2(t, +INF_HIT);
else return vec2(-INF_HIT, t);
}
vec4 intersectHalfPlane(Ray ray, float angle) {
vec2 o = ray.pos.xy;
vec2 d = ray.dir.xy;
vec2 planeDirection = vec2(cos(angle), sin(angle));
vec2 planeNormal = vec2(planeDirection.y, -planeDirection.x);
float a = dot(o, planeNormal);
float b = dot(d, planeNormal);
float t = -a / b;
vec2 p = o + t * d;
bool outside = dot(p, planeDirection) < 0.0;
if (outside) return vec4(-INF_HIT, +INF_HIT, NO_HIT, NO_HIT);
return vec4(-INF_HIT, t, t, +INF_HIT);
}
vec2 intersectHalfSpace(Ray ray, float angle)
{
vec2 o = ray.pos.xy;
vec2 d = ray.dir.xy;
vec2 n = vec2(sin(angle), -cos(angle));
float a = dot(o, n);
float b = dot(d, n);
float t = -a / b;
float s = sign(a);
if (t >= 0.0 != s >= 0.0) return vec2(t, +INF_HIT);
else return vec2(-INF_HIT, t);
}
vec2 intersectRegularWedge(Ray ray, float minAngle, float maxAngle)
{
vec2 o = ray.pos.xy;
vec2 d = ray.dir.xy;
vec2 n1 = vec2(sin(minAngle), -cos(minAngle));
vec2 n2 = vec2(-sin(maxAngle), cos(maxAngle));
float a1 = dot(o, n1);
float a2 = dot(o, n2);
float b1 = dot(d, n1);
float b2 = dot(d, n2);
float t1 = -a1 / b1;
float t2 = -a2 / b2;
float s1 = sign(a1);
float s2 = sign(a2);
float tmin = min(t1, t2);
float tmax = max(t1, t2);
float smin = tmin == t1 ? s1 : s2;
float smax = tmin == t1 ? s2 : s1;
bool e = tmin >= 0.0;
bool f = tmax >= 0.0;
bool g = smin >= 0.0;
bool h = smax >= 0.0;
if (e != g && f == h) return vec2(tmin, tmax);
else if (e == g && f == h) return vec2(-INF_HIT, tmin);
else if (e != g && f != h) return vec2(tmax, +INF_HIT);
else return vec2(NO_HIT);
}
vec4 intersectFlippedWedge(Ray ray, float minAngle, float maxAngle)
{
vec2 planeIntersectMin = intersectHalfSpace(ray, minAngle);
vec2 planeIntersectMax = intersectHalfSpace(ray, maxAngle + czm_pi);
return vec4(planeIntersectMin, planeIntersectMax);
}
vec2 intersectUnitSphere(Ray ray)
{
vec3 o = ray.pos;
vec3 d = ray.dir;
float b = dot(d, o);
float c = dot(o, o) - 1.0;
float det = b * b - c;
if (det < 0.0) {
return vec2(NO_HIT);
}
det = sqrt(det);
float t1 = -b - det;
float t2 = -b + det;
float tmin = min(t1, t2);
float tmax = max(t1, t2);
return vec2(tmin, tmax);
}
vec2 intersectUnitSphereUnnormalizedDirection(Ray ray)
{
vec3 o = ray.pos;
vec3 d = ray.dir;
float a = dot(d, d);
float b = dot(d, o);
float c = dot(o, o) - 1.0;
float det = b * b - a * c;
if (det < 0.0) {
return vec2(NO_HIT);
}
det = sqrt(det);
float t1 = (-b - det) / a;
float t2 = (-b + det) / a;
float tmin = min(t1, t2);
float tmax = max(t1, t2);
return vec2(tmin, tmax);
}
vec2 intersectDoubleEndedCone(Ray ray, float cosSqrHalfAngle)
{
vec3 o = ray.pos;
vec3 d = ray.dir;
float a = d.z * d.z - dot(d, d) * cosSqrHalfAngle;
float b = d.z * o.z - dot(o, d) * cosSqrHalfAngle;
float c = o.z * o.z - dot(o, o) * cosSqrHalfAngle;
float det = b * b - a * c;
if (det < 0.0) {
return vec2(NO_HIT);
}
det = sqrt(det);
float t1 = (-b - det) / a;
float t2 = (-b + det) / a;
float tmin = min(t1, t2);
float tmax = max(t1, t2);
return vec2(tmin, tmax);
}
vec4 intersectFlippedCone(Ray ray, float cosSqrHalfAngle) {
vec2 intersect = intersectDoubleEndedCone(ray, cosSqrHalfAngle);
if (intersect.x == NO_HIT) {
return vec4(-INF_HIT, +INF_HIT, NO_HIT, NO_HIT);
}
vec3 o = ray.pos;
vec3 d = ray.dir;
float tmin = intersect.x;
float tmax = intersect.y;
float zmin = o.z + tmin * d.z;
float zmax = o.z + tmax * d.z;
// One interval
if (zmin < 0.0 && zmax < 0.0) return vec4(-INF_HIT, +INF_HIT, NO_HIT, NO_HIT);
else if (zmin < 0.0) return vec4(-INF_HIT, tmax, NO_HIT, NO_HIT);
else if (zmax < 0.0) return vec4(tmin, +INF_HIT, NO_HIT, NO_HIT);
// Two intervals
else return vec4(-INF_HIT, tmin, tmax, +INF_HIT);
}
vec2 intersectRegularCone(Ray ray, float cosSqrHalfAngle) {
vec2 intersect = intersectDoubleEndedCone(ray, cosSqrHalfAngle);
if (intersect.x == NO_HIT) {
return vec2(NO_HIT);
}
vec3 o = ray.pos;
vec3 d = ray.dir;
float tmin = intersect.x;
float tmax = intersect.y;
float zmin = o.z + tmin * d.z;
float zmax = o.z + tmax * d.z;
if (zmin < 0.0 && zmax < 0.0) return vec2(NO_HIT);
else if (zmin < 0.0) return vec2(tmax, +INF_HIT);
else if (zmax < 0.0) return vec2(-INF_HIT, tmin);
else return vec2(tmin, tmax);
}
void intersectShape(in Ray ray, inout Intersections ix) {
// Position is converted from [0,1] to [-1,+1] because shape intersections assume unit space is [-1,+1].
// Direction is scaled as well to be in sync with position.
ray.pos = ray.pos * 2.0 - 1.0;
ray.dir *= 2.0;
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_MAX)
Ray outerRay = Ray(ray.pos * u_ellipsoidInverseOuterScaleUv, ray.dir * u_ellipsoidInverseOuterScaleUv);
#else
Ray outerRay = ray;
#endif
// Outer ellipsoid
vec2 outerIntersect = intersectUnitSphereUnnormalizedDirection(outerRay);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MAX, outerIntersect);
// Exit early if the outer ellipsoid was missed.
if (outerIntersect.x == NO_HIT) {
return;
}
// Inner ellipsoid
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_FLAT)
// When the ellipsoid is perfectly thin it's necessary to sandwich the
// inner ellipsoid intersection inside the outer ellipsoid intersection.
// Without this special case,
// [outerMin, outerMax, innerMin, innerMax] will bubble sort to
// [outerMin, innerMin, outerMax, innerMax] which will cause the back
// side of the ellipsoid to be invisible because it will think the ray
// is still inside the inner (negative) ellipsoid after exiting the
// outer (positive) ellipsoid.
// With this special case,
// [outerMin, innerMin, innerMax, outerMax] will bubble sort to
// [outerMin, innerMin, innerMax, outerMax] which will work correctly.
// Note: If initializeIntersections() changes its sorting function
// from bubble sort to something else, this code may need to change.
setIntersection(ix, 0, outerIntersect.x, true, true); // positive, enter
setIntersection(ix, 1, outerIntersect.x, false, true); // negative, enter
setIntersection(ix, 2, outerIntersect.y, false, false); // negative, exit
setIntersection(ix, 3, outerIntersect.y, true, false); // positive, exit
#elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_HEIGHT_MIN)
Ray innerRay = Ray(ray.pos * u_ellipsoidInverseInnerScaleUv, ray.dir * u_ellipsoidInverseInnerScaleUv);
vec2 innerIntersect = intersectUnitSphereUnnormalizedDirection(innerRay);
if (innerIntersect == vec2(NO_HIT)) {
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MIN, innerIntersect);
} else {
// When the ellipsoid is very large and thin it's possible for floating
// point math to cause the ray to intersect the inner ellipsoid before
// the outer ellipsoid. To prevent this from happening, clamp innerIntersect
// to outerIntersect and sandwhich the intersections like described above.
//
// In theory a similar fix is needed for cylinders, however it's more
// complicated to implement because the inner shape is allowed to be
// intersected first.
innerIntersect.x = max(innerIntersect.x, outerIntersect.x);
innerIntersect.y = min(innerIntersect.y, outerIntersect.y);
setIntersection(ix, 0, outerIntersect.x, true, true); // positive, enter
setIntersection(ix, 1, innerIntersect.x, false, true); // negative, enter
setIntersection(ix, 2, innerIntersect.y, false, false); // negative, exit
setIntersection(ix, 3, outerIntersect.y, true, false); // positive, exit
}
#endif
// Flip the ray because the intersection function expects a cone growing towards +Z.
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_UNDER_HALF) || defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_EQUAL_HALF) || defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_UNDER_HALF)
Ray flippedRay = outerRay;
flippedRay.dir.z *= -1.0;
flippedRay.pos.z *= -1.0;
#endif
// Bottom cone
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_UNDER_HALF)
vec2 bottomConeIntersection = intersectRegularCone(flippedRay, u_ellipsoidRenderLatitudeCosSqrHalfMinMax.x);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN, bottomConeIntersection);
#elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_EQUAL_HALF)
vec2 bottomConeIntersection = intersectZPlane(flippedRay);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN, bottomConeIntersection);
#elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_OVER_HALF)
vec4 bottomConeIntersection = intersectFlippedCone(ray, u_ellipsoidRenderLatitudeCosSqrHalfMinMax.x);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN + 0, bottomConeIntersection.xy);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN + 1, bottomConeIntersection.zw);
#endif
// Top cone
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_UNDER_HALF)
vec4 topConeIntersection = intersectFlippedCone(flippedRay, u_ellipsoidRenderLatitudeCosSqrHalfMinMax.y);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX + 0, topConeIntersection.xy);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX + 1, topConeIntersection.zw);
#elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_EQUAL_HALF)
vec2 topConeIntersection = intersectZPlane(ray);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX, topConeIntersection);
#elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_OVER_HALF)
vec2 topConeIntersection = intersectRegularCone(ray, u_ellipsoidRenderLatitudeCosSqrHalfMinMax.y);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX, topConeIntersection);
#endif
// Wedge
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_ZERO)
vec4 wedgeIntersect = intersectHalfPlane(ray, u_ellipsoidRenderLongitudeMinMax.x);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 0, wedgeIntersect.xy);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 1, wedgeIntersect.zw);
#elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_UNDER_HALF)
vec2 wedgeIntersect = intersectRegularWedge(ray, u_ellipsoidRenderLongitudeMinMax.x, u_ellipsoidRenderLongitudeMinMax.y);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE, wedgeIntersect);
#elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_HALF)
vec2 wedgeIntersect = intersectHalfSpace(ray, u_ellipsoidRenderLongitudeMinMax.x);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE, wedgeIntersect);
#elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_OVER_HALF)
vec4 wedgeIntersect = intersectFlippedWedge(ray, u_ellipsoidRenderLongitudeMinMax.x, u_ellipsoidRenderLongitudeMinMax.y);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 0, wedgeIntersect.xy);
setIntersectionPair(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 1, wedgeIntersect.zw);
#endif
}
`;var wC=`// Main intersection function for Voxel scenes.
// See IntersectBox.glsl, IntersectCylinder.glsl, or IntersectEllipsoid.glsl
// for the definition of intersectShape. The appropriate function is selected
// based on the VoxelPrimitive shape type, and added to the shader in
// Scene/VoxelRenderResources.js.
// See also IntersectClippingPlane.glsl and IntersectDepth.glsl.
// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT,
// getFirstIntersection, initializeIntersections, nextIntersection.
/* Intersection defines (set in Scene/VoxelRenderResources.js)
#define INTERSECTION_COUNT ###
*/
RayShapeIntersection intersectScene(in vec2 screenCoord, in Ray ray, out Intersections ix) {
// Do a ray-shape intersection to find the exact starting and ending points.
intersectShape(ray, ix);
// Exit early if the positive shape was completely missed or behind the ray.
RayShapeIntersection intersection = getFirstIntersection(ix);
if (intersection.entry.w == NO_HIT) {
// Positive shape was completely missed - so exit early.
return intersection;
}
// Clipping planes
#if defined(CLIPPING_PLANES)
intersectClippingPlanes(ray, ix);
#endif
// Depth
#if defined(DEPTH_TEST)
intersectDepth(screenCoord, ray, ix);
#endif
// Find the first intersection that's in front of the ray
#if (INTERSECTION_COUNT > 1)
initializeIntersections(ix);
for (int i = 0; i < INTERSECTION_COUNT; ++i) {
intersection = nextIntersection(ix);
if (intersection.exit.w > 0.0) {
// Set start to 0.0 when ray is inside the shape.
intersection.entry.w = max(intersection.entry.w, 0.0);
break;
}
}
#else
// Set start to 0.0 when ray is inside the shape.
intersection.entry.w = max(intersection.entry.w, 0.0);
#endif
return intersection;
}
`;var GF=`/* Box defines (set in Scene/VoxelBoxShape.js)
#define BOX_HAS_SHAPE_BOUNDS
*/
#if defined(BOX_HAS_SHAPE_BOUNDS)
uniform vec3 u_boxUvToShapeUvScale;
uniform vec3 u_boxUvToShapeUvTranslate;
#endif
vec3 convertUvToShapeUvSpace(in vec3 positionUv) {
#if defined(BOX_HAS_SHAPE_BOUNDS)
return positionUv * u_boxUvToShapeUvScale + u_boxUvToShapeUvTranslate;
#else
return positionUv;
#endif
}
vec3 convertShapeUvToUvSpace(in vec3 shapeUv) {
#if defined(BOX_HAS_SHAPE_BOUNDS)
return (shapeUv - u_boxUvToShapeUvTranslate) / u_boxUvToShapeUvScale;
#else
return shapeUv;
#endif
}
`;var WF=`/* Cylinder defines (set in Scene/VoxelCylinderShape.js)
#define CYLINDER_HAS_SHAPE_BOUNDS_RADIUS
#define CYLINDER_HAS_SHAPE_BOUNDS_RADIUS_FLAT
#define CYLINDER_HAS_SHAPE_BOUNDS_HEIGHT
#define CYLINDER_HAS_SHAPE_BOUNDS_HEIGHT_FLAT
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_RANGE_EQUAL_ZERO
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_DISCONTINUITY
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MAX_DISCONTINUITY
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_MAX_REVERSED
*/
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_RADIUS)
uniform vec2 u_cylinderUvToShapeUvRadius; // x = scale, y = offset
#endif
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_HEIGHT)
uniform vec2 u_cylinderUvToShapeUvHeight; // x = scale, y = offset
#endif
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE)
uniform vec2 u_cylinderUvToShapeUvAngle; // x = scale, y = offset
#endif
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_DISCONTINUITY) || defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MAX_DISCONTINUITY)
uniform vec2 u_cylinderShapeUvAngleMinMax;
#endif
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_DISCONTINUITY) || defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MAX_DISCONTINUITY) || defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_MAX_REVERSED)
uniform float u_cylinderShapeUvAngleRangeZeroMid;
#endif
vec3 convertUvToShapeUvSpace(in vec3 positionUv) {
vec3 positionLocal = positionUv * 2.0 - 1.0; // [-1,+1]
// Compute radius
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_RADIUS_FLAT)
float radius = 1.0;
#else
float radius = length(positionLocal.xy); // [0,1]
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_RADIUS)
radius = radius * u_cylinderUvToShapeUvRadius.x + u_cylinderUvToShapeUvRadius.y; // x = scale, y = offset
#endif
#endif
// Compute height
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_HEIGHT_FLAT)
float height = 1.0;
#else
float height = positionUv.z; // [0,1]
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_HEIGHT)
height = height * u_cylinderUvToShapeUvHeight.x + u_cylinderUvToShapeUvHeight.y; // x = scale, y = offset
#endif
#endif
// Compute angle
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_RANGE_EQUAL_ZERO)
float angle = 1.0;
#else
float angle = (atan(positionLocal.y, positionLocal.x) + czm_pi) / czm_twoPi; // [0,1]
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE)
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_MAX_REVERSED)
// Comparing against u_cylinderShapeUvAngleMinMax has precision problems. u_cylinderShapeUvAngleRangeZeroMid is more conservative.
angle += float(angle < u_cylinderShapeUvAngleRangeZeroMid);
#endif
// Avoid flickering from reading voxels from both sides of the -pi/+pi discontinuity.
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_DISCONTINUITY)
angle = angle > u_cylinderShapeUvAngleRangeZeroMid ? u_cylinderShapeUvAngleMinMax.x : angle;
#elif defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MAX_DISCONTINUITY)
angle = angle < u_cylinderShapeUvAngleRangeZeroMid ? u_cylinderShapeUvAngleMinMax.y : angle;
#endif
angle = angle * u_cylinderUvToShapeUvAngle.x + u_cylinderUvToShapeUvAngle.y; // x = scale, y = offset
#endif
#endif
return vec3(radius, height, angle);
}
`;var jF=`/* Ellipsoid defines (set in Scene/VoxelEllipsoidShape.js)
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MIN_DISCONTINUITY
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MAX_DISCONTINUITY
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_RANGE_EQUAL_ZERO
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_MIN_MAX_REVERSED
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE_RANGE_EQUAL_ZERO
#define ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_MIN
#define ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_FLAT
#define ELLIPSOID_IS_SPHERE
*/
uniform vec3 u_ellipsoidRadiiUv; // [0,1]
#if !defined(ELLIPSOID_IS_SPHERE)
uniform vec3 u_ellipsoidInverseRadiiSquaredUv;
#endif
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MIN_DISCONTINUITY) || defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MAX_DISCONTINUITY) || defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_MIN_MAX_REVERSED)
uniform vec3 u_ellipsoidShapeUvLongitudeMinMaxMid;
#endif
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)
uniform vec2 u_ellipsoidUvToShapeUvLongitude; // x = scale, y = offset
#endif
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE)
uniform vec2 u_ellipsoidUvToShapeUvLatitude; // x = scale, y = offset
#endif
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_MIN) && !defined(ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_FLAT)
uniform float u_ellipsoidInverseHeightDifferenceUv;
uniform vec2 u_ellipseInnerRadiiUv; // [0,1]
#endif
// robust iterative solution without trig functions
// https://github.com/0xfaded/ellipse_demo/issues/1
// https://stackoverflow.com/questions/22959698/distance-from-given-point-to-given-ellipse
// Pro: Good when radii.x ~= radii.y
// Con: Breaks at pos.x ~= 0.0, especially inside the ellipse
// Con: Inaccurate with exterior points and thin ellipses
float ellipseDistanceIterative (vec2 pos, vec2 radii) {
vec2 p = abs(pos);
vec2 invRadii = 1.0 / radii;
vec2 a = vec2(1.0, -1.0) * (radii.x * radii.x - radii.y * radii.y) * invRadii;
vec2 t = vec2(0.70710678118); // sqrt(2) / 2
vec2 v = radii * t;
const int iterations = 3;
for (int i = 0; i < iterations; ++i) {
vec2 e = a * pow(t, vec2(3.0));
vec2 q = normalize(p - e) * length(v - e);
t = normalize((q + e) * invRadii);
v = radii * t;
}
return length(v * sign(pos) - pos) * sign(p.y - v.y);
}
vec3 convertUvToShapeUvSpace(in vec3 positionUv) {
// Compute position and normal.
// Convert positionUv [0,1] to local space [-1,+1] to "normalized" cartesian space [-a,+a] where a = (radii + height) / (max(radii) + height).
// A point on the largest ellipsoid axis would be [-1,+1] and everything else would be smaller.
vec3 positionLocal = positionUv * 2.0 - 1.0;
#if defined(ELLIPSOID_IS_SPHERE)
vec3 posEllipsoid = positionLocal * u_ellipsoidRadiiUv.x;
vec3 normal = normalize(posEllipsoid);
#else
vec3 posEllipsoid = positionLocal * u_ellipsoidRadiiUv;
vec3 normal = normalize(posEllipsoid * u_ellipsoidInverseRadiiSquaredUv); // geodetic surface normal
#endif
// Compute longitude
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_RANGE_EQUAL_ZERO)
float longitude = 1.0;
#else
float longitude = (atan(normal.y, normal.x) + czm_pi) / czm_twoPi;
// Correct the angle when max < min
// Technically this should compare against min longitude - but it has precision problems so compare against the middle of empty space.
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_MIN_MAX_REVERSED)
longitude += float(longitude < u_ellipsoidShapeUvLongitudeMinMaxMid.z);
#endif
// Avoid flickering from reading voxels from both sides of the -pi/+pi discontinuity.
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MIN_DISCONTINUITY)
longitude = longitude > u_ellipsoidShapeUvLongitudeMinMaxMid.z ? u_ellipsoidShapeUvLongitudeMinMaxMid.x : longitude;
#endif
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MAX_DISCONTINUITY)
longitude = longitude < u_ellipsoidShapeUvLongitudeMinMaxMid.z ? u_ellipsoidShapeUvLongitudeMinMaxMid.y : longitude;
#endif
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)
longitude = longitude * u_ellipsoidUvToShapeUvLongitude.x + u_ellipsoidUvToShapeUvLongitude.y;
#endif
#endif
// Compute latitude
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE_RANGE_EQUAL_ZERO)
float latitude = 1.0;
#else
float latitude = (asin(normal.z) + czm_piOverTwo) / czm_pi;
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE)
latitude = latitude * u_ellipsoidUvToShapeUvLatitude.x + u_ellipsoidUvToShapeUvLatitude.y;
#endif
#endif
// Compute height
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_FLAT)
// TODO: This breaks down when minBounds == maxBounds. To fix it, this
// function would have to know if ray is intersecting the front or back of the shape
// and set the shape space position to 1 (front) or 0 (back) accordingly.
float height = 1.0;
#else
#if defined(ELLIPSOID_IS_SPHERE)
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_MIN)
float height = (length(posEllipsoid) - u_ellipseInnerRadiiUv.x) * u_ellipsoidInverseHeightDifferenceUv;
#else
float height = length(posEllipsoid);
#endif
#else
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_HEIGHT_MIN)
// Convert the 3D position to a 2D position relative to the ellipse (radii.x, radii.z) (assuming radii.x == radii.y which is true for WGS84).
// This is an optimization so that math can be done with ellipses instead of ellipsoids.
vec2 posEllipse = vec2(length(posEllipsoid.xy), posEllipsoid.z);
float height = ellipseDistanceIterative(posEllipse, u_ellipseInnerRadiiUv) * u_ellipsoidInverseHeightDifferenceUv;
#else
// TODO: this is probably not correct
float height = length(posEllipsoid);
#endif
#endif
#endif
return vec3(longitude, latitude, height);
}
`;var YF=`// These octree flags must be in sync with GpuOctreeFlag in VoxelTraversal.js
#define OCTREE_FLAG_INTERNAL 0
#define OCTREE_FLAG_LEAF 1
#define OCTREE_FLAG_PACKED_LEAF_FROM_PARENT 2
#define OCTREE_MAX_LEVELS 32 // Harcoded value because GLSL doesn't like variable length loops
uniform sampler2D u_octreeInternalNodeTexture;
uniform vec2 u_octreeInternalNodeTexelSizeUv;
uniform int u_octreeInternalNodeTilesPerRow;
#if (SAMPLE_COUNT > 1)
uniform sampler2D u_octreeLeafNodeTexture;
uniform vec2 u_octreeLeafNodeTexelSizeUv;
uniform int u_octreeLeafNodeTilesPerRow;
#endif
struct OctreeNodeData {
int data;
int flag;
};
struct TraversalData {
ivec4 octreeCoords;
int parentOctreeIndex;
};
struct SampleData {
int megatextureIndex;
ivec4 tileCoords;
vec3 tileUv;
#if (SAMPLE_COUNT > 1)
float weight;
#endif
};
// Integer mod: For WebGL1 only
int intMod(in int a, in int b) {
return a - (b * (a / b));
}
int normU8_toInt(in float value) {
return int(value * 255.0);
}
int normU8x2_toInt(in vec2 value) {
return int(value.x * 255.0) + 256 * int(value.y * 255.0);
}
float normU8x2_toFloat(in vec2 value) {
return float(normU8x2_toInt(value)) / 65535.0;
}
OctreeNodeData getOctreeNodeData(in vec2 octreeUv) {
vec4 texData = texture(u_octreeInternalNodeTexture, octreeUv);
OctreeNodeData data;
data.data = normU8x2_toInt(texData.xy);
data.flag = normU8x2_toInt(texData.zw);
return data;
}
OctreeNodeData getOctreeChildData(in int parentOctreeIndex, in ivec3 childCoord) {
int childIndex = childCoord.z * 4 + childCoord.y * 2 + childCoord.x;
int octreeCoordX = intMod(parentOctreeIndex, u_octreeInternalNodeTilesPerRow) * 9 + 1 + childIndex;
int octreeCoordY = parentOctreeIndex / u_octreeInternalNodeTilesPerRow;
vec2 octreeUv = u_octreeInternalNodeTexelSizeUv * vec2(float(octreeCoordX) + 0.5, float(octreeCoordY) + 0.5);
return getOctreeNodeData(octreeUv);
}
int getOctreeParentIndex(in int octreeIndex) {
int octreeCoordX = intMod(octreeIndex, u_octreeInternalNodeTilesPerRow) * 9;
int octreeCoordY = octreeIndex / u_octreeInternalNodeTilesPerRow;
vec2 octreeUv = u_octreeInternalNodeTexelSizeUv * vec2(float(octreeCoordX) + 0.5, float(octreeCoordY) + 0.5);
vec4 parentData = texture(u_octreeInternalNodeTexture, octreeUv);
int parentOctreeIndex = normU8x2_toInt(parentData.xy);
return parentOctreeIndex;
}
/**
* Convert a position in the uv-space of the tileset bounding shape
* into the uv-space of a tile within the tileset
*/
vec3 getTileUv(in vec3 shapePosition, in ivec4 octreeCoords) {
// PERFORMANCE_IDEA: use bit-shifting (only in WebGL2)
float dimAtLevel = pow(2.0, float(octreeCoords.w));
return shapePosition * dimAtLevel - vec3(octreeCoords.xyz);
}
void getOctreeLeafSampleData(in OctreeNodeData data, in ivec4 octreeCoords, out SampleData sampleData) {
sampleData.megatextureIndex = data.data;
sampleData.tileCoords = (data.flag == OCTREE_FLAG_PACKED_LEAF_FROM_PARENT)
? ivec4(octreeCoords.xyz / 2, octreeCoords.w - 1)
: octreeCoords;
}
#if (SAMPLE_COUNT > 1)
void getOctreeLeafSampleDatas(in OctreeNodeData data, in ivec4 octreeCoords, out SampleData sampleDatas[SAMPLE_COUNT]) {
int leafIndex = data.data;
int leafNodeTexelCount = 2;
// Adding 0.5 moves to the center of the texel
float leafCoordXStart = float(intMod(leafIndex, u_octreeLeafNodeTilesPerRow) * leafNodeTexelCount) + 0.5;
float leafCoordY = float(leafIndex / u_octreeLeafNodeTilesPerRow) + 0.5;
// Get an interpolation weight and a flag to determine whether to read the parent texture
vec2 leafUv0 = u_octreeLeafNodeTexelSizeUv * vec2(leafCoordXStart + 0.0, leafCoordY);
vec4 leafData0 = texture(u_octreeLeafNodeTexture, leafUv0);
float lerp = normU8x2_toFloat(leafData0.xy);
sampleDatas[0].weight = 1.0 - lerp;
sampleDatas[1].weight = lerp;
// TODO: this looks wrong? Should be comparing to OCTREE_FLAG_PACKED_LEAF_FROM_PARENT
sampleDatas[0].tileCoords = (normU8_toInt(leafData0.z) == 1)
? ivec4(octreeCoords.xyz / 2, octreeCoords.w - 1)
: octreeCoords;
sampleDatas[1].tileCoords = (normU8_toInt(leafData0.w) == 1)
? ivec4(octreeCoords.xyz / 2, octreeCoords.w - 1)
: octreeCoords;
// Get megatexture indices for both samples
vec2 leafUv1 = u_octreeLeafNodeTexelSizeUv * vec2(leafCoordXStart + 1.0, leafCoordY);
vec4 leafData1 = texture(u_octreeLeafNodeTexture, leafUv1);
sampleDatas[0].megatextureIndex = normU8x2_toInt(leafData1.xy);
sampleDatas[1].megatextureIndex = normU8x2_toInt(leafData1.zw);
}
#endif
OctreeNodeData traverseOctreeDownwards(in vec3 shapePosition, inout TraversalData traversalData) {
float sizeAtLevel = 1.0 / pow(2.0, float(traversalData.octreeCoords.w));
vec3 start = vec3(traversalData.octreeCoords.xyz) * sizeAtLevel;
vec3 end = start + vec3(sizeAtLevel);
OctreeNodeData childData;
for (int i = 0; i < OCTREE_MAX_LEVELS; ++i) {
// Find out which octree child contains the position
// 0 if before center, 1 if after
vec3 center = 0.5 * (start + end);
vec3 childCoord = step(center, shapePosition);
// Get octree coords for the next level down
ivec4 octreeCoords = traversalData.octreeCoords;
traversalData.octreeCoords = ivec4(octreeCoords.xyz * 2 + ivec3(childCoord), octreeCoords.w + 1);
childData = getOctreeChildData(traversalData.parentOctreeIndex, ivec3(childCoord));
if (childData.flag != OCTREE_FLAG_INTERNAL) {
// leaf tile - stop traversing
break;
}
// interior tile - keep going deeper
start = mix(start, center, childCoord);
end = mix(center, end, childCoord);
traversalData.parentOctreeIndex = childData.data;
}
return childData;
}
/**
* Transform a given position to an octree tile coordinate and a position within that tile,
* and find the corresponding megatexture index and texture coordinates
*/
void traverseOctreeFromBeginning(in vec3 shapePosition, out TraversalData traversalData, out SampleData sampleDatas[SAMPLE_COUNT]) {
traversalData.octreeCoords = ivec4(0);
traversalData.parentOctreeIndex = 0;
OctreeNodeData nodeData = getOctreeNodeData(vec2(0.0));
if (nodeData.flag != OCTREE_FLAG_LEAF) {
nodeData = traverseOctreeDownwards(shapePosition, traversalData);
}
#if (SAMPLE_COUNT == 1)
getOctreeLeafSampleData(nodeData, traversalData.octreeCoords, sampleDatas[0]);
sampleDatas[0].tileUv = getTileUv(shapePosition, sampleDatas[0].tileCoords);
#else
getOctreeLeafSampleDatas(nodeData, traversalData.octreeCoords, sampleDatas);
sampleDatas[0].tileUv = getTileUv(shapePosition, sampleDatas[0].tileCoords);
sampleDatas[1].tileUv = getTileUv(shapePosition, sampleDatas[1].tileCoords);
#endif
}
bool inRange(in vec3 v, in vec3 minVal, in vec3 maxVal) {
return clamp(v, minVal, maxVal) == v;
}
bool insideTile(in vec3 shapePosition, in ivec4 octreeCoords) {
vec3 tileUv = getTileUv(shapePosition, octreeCoords);
bool inside = inRange(tileUv, vec3(0.0), vec3(1.0));
// Assume (!) the position is always inside the root tile.
return inside || octreeCoords.w == 0;
}
void traverseOctreeFromExisting(in vec3 shapePosition, inout TraversalData traversalData, inout SampleData sampleDatas[SAMPLE_COUNT]) {
if (insideTile(shapePosition, traversalData.octreeCoords)) {
for (int i = 0; i < SAMPLE_COUNT; i++) {
sampleDatas[0].tileUv = getTileUv(shapePosition, sampleDatas[0].tileCoords);
}
return;
}
// Go up tree until we find a parent tile containing shapePosition
for (int i = 0; i < OCTREE_MAX_LEVELS; ++i) {
traversalData.octreeCoords.xyz /= 2;
traversalData.octreeCoords.w -= 1;
if (insideTile(shapePosition, traversalData.octreeCoords)) {
break;
}
traversalData.parentOctreeIndex = getOctreeParentIndex(traversalData.parentOctreeIndex);
}
// Go down tree
OctreeNodeData nodeData = traverseOctreeDownwards(shapePosition, traversalData);
#if (SAMPLE_COUNT == 1)
getOctreeLeafSampleData(nodeData, traversalData.octreeCoords, sampleDatas[0]);
sampleDatas[0].tileUv = getTileUv(shapePosition, sampleDatas[0].tileCoords);
#else
getOctreeLeafSampleDatas(nodeData, traversalData.octreeCoords, sampleDatas);
sampleDatas[0].tileUv = getTileUv(shapePosition, sampleDatas[0].tileCoords);
sampleDatas[1].tileUv = getTileUv(shapePosition, sampleDatas[1].tileCoords);
#endif
}
`;var qF=`// See Octree.glsl for the definitions of SampleData and intMod
/* Megatexture defines (set in Scene/VoxelRenderResources.js)
#define SAMPLE_COUNT ###
#define NEAREST_SAMPLING
#define PADDING
*/
uniform ivec2 u_megatextureSliceDimensions; // number of slices per tile, in two dimensions
uniform ivec2 u_megatextureTileDimensions; // number of tiles per megatexture, in two dimensions
uniform vec2 u_megatextureVoxelSizeUv;
uniform vec2 u_megatextureSliceSizeUv;
uniform vec2 u_megatextureTileSizeUv;
uniform ivec3 u_dimensions; // does not include padding
#if defined(PADDING)
uniform ivec3 u_paddingBefore;
uniform ivec3 u_paddingAfter;
#endif
// Integer min, max, clamp: For WebGL1 only
int intMin(int a, int b) {
return a <= b ? a : b;
}
int intMax(int a, int b) {
return a >= b ? a : b;
}
int intClamp(int v, int minVal, int maxVal) {
return intMin(intMax(v, minVal), maxVal);
}
vec2 index1DTo2DTexcoord(int index, ivec2 dimensions, vec2 uvScale)
{
int indexX = intMod(index, dimensions.x);
int indexY = index / dimensions.x;
return vec2(indexX, indexY) * uvScale;
}
/*
How is 3D data stored in a 2D megatexture?
In this example there is only one loaded tile and it has 2x2x2 voxels (8 voxels total).
The data is sliced by Z. The data at Z = 0 is placed in texels (0,0), (0,1), (1,0), (1,1) and
the data at Z = 1 is placed in texels (2,0), (2,1), (3,0), (3,1).
Note that there could be empty space in the megatexture because it's a power of two.
0 1 2 3
+---+---+---+---+
| | | | | 3
+---+---+---+---+
| | | | | 2
+-------+-------+
|010|110|011|111| 1
|--- ---|--- ---|
|000|100|001|101| 0
+-------+-------+
When doing linear interpolation the megatexture needs to be sampled twice: once for
the Z slice above the voxel coordinate and once for the slice below. The two slices
are interpolated with fract(coord.z - 0.5). For example, a Z coordinate of 1.0 is
halfway between two Z slices so the interpolation factor is 0.5. Below is a side view
of the 3D voxel grid with voxel coordinates on the left side.
2 +---+
|001|
1 +-z-+
|000|
0 +---+
When doing nearest neighbor the megatexture only needs to be sampled once at the closest Z slice.
*/
Properties getPropertiesFromMegatexture(in SampleData sampleData) {
vec3 tileUv = clamp(sampleData.tileUv, vec3(0.0), vec3(1.0)); // TODO is the clamp necessary?
int tileIndex = sampleData.megatextureIndex;
vec3 voxelCoord = tileUv * vec3(u_dimensions);
ivec3 voxelDimensions = u_dimensions;
#if defined(PADDING)
voxelDimensions += u_paddingBefore + u_paddingAfter;
voxelCoord += vec3(u_paddingBefore);
#endif
#if defined(NEAREST_SAMPLING)
// Round to the center of the nearest voxel
voxelCoord = floor(voxelCoord) + vec3(0.5);
#endif
// Tile location
vec2 tileUvOffset = index1DTo2DTexcoord(tileIndex, u_megatextureTileDimensions, u_megatextureTileSizeUv);
// Slice location
float slice = voxelCoord.z - 0.5;
int sliceIndex = int(floor(slice));
int sliceIndex0 = intClamp(sliceIndex, 0, voxelDimensions.z - 1);
vec2 sliceUvOffset0 = index1DTo2DTexcoord(sliceIndex0, u_megatextureSliceDimensions, u_megatextureSliceSizeUv);
// Voxel location
vec2 voxelUvOffset = clamp(voxelCoord.xy, vec2(0.5), vec2(voxelDimensions.xy) - vec2(0.5)) * u_megatextureVoxelSizeUv;
// Final location in the megatexture
vec2 uv0 = tileUvOffset + sliceUvOffset0 + voxelUvOffset;
#if defined(NEAREST_SAMPLING)
return getPropertiesFromMegatextureAtUv(uv0);
#else
float sliceLerp = fract(slice);
int sliceIndex1 = intMin(sliceIndex + 1, voxelDimensions.z - 1);
vec2 sliceUvOffset1 = index1DTo2DTexcoord(sliceIndex1, u_megatextureSliceDimensions, u_megatextureSliceSizeUv);
vec2 uv1 = tileUvOffset + sliceUvOffset1 + voxelUvOffset;
Properties properties0 = getPropertiesFromMegatextureAtUv(uv0);
Properties properties1 = getPropertiesFromMegatextureAtUv(uv1);
return mixProperties(properties0, properties1, sliceLerp);
#endif
}
// Convert an array of sample datas to a final weighted properties.
Properties accumulatePropertiesFromMegatexture(in SampleData sampleDatas[SAMPLE_COUNT]) {
#if (SAMPLE_COUNT == 1)
return getPropertiesFromMegatexture(sampleDatas[0]);
#else
// When more than one sample is taken the accumulator needs to start at 0
Properties properties = clearProperties();
for (int i = 0; i < SAMPLE_COUNT; ++i) {
float weight = sampleDatas[i].weight;
// Avoid reading the megatexture when the weight is 0 as it can be costly.
if (weight > 0.0) {
Properties tempProperties = getPropertiesFromMegatexture(sampleDatas[i]);
tempProperties = scaleProperties(tempProperties, weight);
properties = sumProperties(properties, tempProperties);
}
}
return properties;
#endif
}
`;function g_t(e){let t=new NA;this.shaderBuilder=t;let n=e._customShader,i=ht(e._uniformMap,n.uniformMap);e._uniformMap=i;let o=n.uniforms;for(let p in o)if(o.hasOwnProperty(p)){let g=o[p];t.addUniform(g.type,p,Ee.FRAGMENT)}t.addUniform("sampler2D","u_megatextureTextures[METADATA_COUNT]",Ee.FRAGMENT),this.uniformMap=i;let r=e._clippingPlanes,s=u(r)&&r.enabled?r.length:0;this.clippingPlanes=r,this.clippingPlanesLength=s,t.addVertexLines([NF]),t.addFragmentLines([n.fragmentShaderText,"#line 0",YF,FF,qF]),s>0&&(t.addDefine("CLIPPING_PLANES",void 0,Ee.FRAGMENT),t.addDefine("CLIPPING_PLANES_COUNT",s,Ee.FRAGMENT),r.unionClippingRegions&&t.addDefine("CLIPPING_PLANES_UNION",void 0,Ee.FRAGMENT),t.addFragmentLines([VF])),e._depthTest&&(t.addDefine("DEPTH_TEST",void 0,Ee.FRAGMENT),t.addFragmentLines([UF]));let a=e._provider.shape;a==="BOX"?(t.addDefine("SHAPE_BOX",void 0,Ee.FRAGMENT),t.addFragmentLines([GF,kF,wC])):a==="CYLINDER"?t.addFragmentLines([zF,wC,WF]):a==="ELLIPSOID"&&t.addFragmentLines([HF,wC,jF]),t.addFragmentLines([LF]);let c=e._shape,l=c.shaderDefines;for(let p in l)if(l.hasOwnProperty(p)){let g=l[p];u(g)&&(g=g===!0?void 0:g,t.addDefine(p,g,Ee.FRAGMENT))}let f=c.shaderMaximumIntersectionsLength;s>0&&(t.addDefine("CLIPPING_PLANES_INTERSECTION_INDEX",f,Ee.FRAGMENT),s===1?f+=1:r.unionClippingRegions?f+=2:f+=1),e._depthTest&&(t.addDefine("DEPTH_INTERSECTION_INDEX",f,Ee.FRAGMENT),f+=1),t.addDefine("INTERSECTION_COUNT",f,Ee.FRAGMENT),(!m.equals(e.paddingBefore,m.ZERO)||!m.equals(e.paddingAfter,m.ZERO))&&t.addDefine("PADDING",void 0,Ee.FRAGMENT),e._useLogDepth&&t.addDefine("LOG_DEPTH_READ_ONLY",void 0,Ee.FRAGMENT),e._jitter&&t.addDefine("JITTER",void 0,Ee.FRAGMENT),e._nearestSampling&&t.addDefine("NEAREST_SAMPLING",void 0,Ee.FRAGMENT);let d=e._traversal;t.addDefine("SAMPLE_COUNT",`${d._sampleCount}`,Ee.FRAGMENT)}var XF=g_t;function y_t(e,t){let{shaderBuilder:n}=e,{names:i,types:o,componentTypes:r,minimumValues:s,maximumValues:a}=t._provider,c=o.length,l=u(s)&&u(a);n.addDefine("METADATA_COUNT",c,Ee.FRAGMENT),l&&n.addDefine("STATISTICS",void 0,Ee.FRAGMENT);for(let O=0;O<c;O++){let L=i[O],N=o[O],_=`PropertyStatistics_${L}`,b=`PropertyStatistics_${L}`;n.addStruct(_,b,Ee.FRAGMENT);let v=oH(N);n.addStructField(_,v,"min"),n.addStructField(_,v,"max")}let f="Statistics",d="Statistics",p="statistics";n.addStruct(f,d,Ee.FRAGMENT);for(let O=0;O<c;O++){let L=i[O],N=`PropertyStatistics_${L}`,_=L;n.addStructField(f,N,_)}let g="Metadata",h="Metadata",A="metadata";n.addStruct(g,h,Ee.FRAGMENT),n.addStructField(g,d,p);for(let O=0;O<c;O++){let L=i[O],N=o[O],_=oH(N);n.addStructField(g,_,L)}for(let O=0;O<c;O++){let L=i[O],N=o[O],_=x_t(N),b=`VoxelProperty_${L}`,v=`VoxelProperty_${L}`;n.addStruct(b,v,Ee.FRAGMENT),n.addStructField(b,_,"partialDerivativeLocal"),n.addStructField(b,_,"partialDerivativeWorld"),n.addStructField(b,_,"partialDerivativeView"),n.addStructField(b,_,"partialDerivativeValid")}let x="Voxel",C="Voxel",T="voxel";n.addStruct(x,C,Ee.FRAGMENT);for(let O=0;O<c;O++){let L=i[O],N=`VoxelProperty_${L}`;n.addStructField(x,N,L)}n.addStructField(x,"vec3","positionEC"),n.addStructField(x,"vec3","positionUv"),n.addStructField(x,"vec3","positionShapeUv"),n.addStructField(x,"vec3","positionUvLocal"),n.addStructField(x,"vec3","viewDirUv"),n.addStructField(x,"vec3","viewDirWorld"),n.addStructField(x,"vec3","surfaceNormal"),n.addStructField(x,"float","travelDistance");let E="FragmentInput",S="FragmentInput";n.addStruct(E,S,Ee.FRAGMENT),n.addStructField(E,h,A),n.addStructField(E,C,T);let w="Properties",D="Properties",M="properties";n.addStruct(w,D,Ee.FRAGMENT);for(let O=0;O<c;O++){let L=i[O],N=o[O],_=oH(N);n.addStructField(w,_,L)}{let O="clearProperties";n.addFunction(O,`${D} clearProperties()`,Ee.FRAGMENT),n.addFunctionLines(O,[`${D} ${M};`]);for(let L=0;L<c;L++){let N=i[L],_=o[L],b=r[L],v=oH(_,b);n.addFunctionLines(O,[`${M}.${N} = ${v}(0.0);`])}n.addFunctionLines(O,[`return ${M};`])}{let O="sumProperties";n.addFunction(O,`${D} sumProperties(${D} propertiesA, ${D} propertiesB)`,Ee.FRAGMENT),n.addFunctionLines(O,[`${D} ${M};`]);for(let L=0;L<c;L++)
{
material.diffuse = vec3(1.0);
material.alpha = 1.0;
}`});function SAe(){this.ready=!0,this.shape=Gi.BOX,this.dimensions=new m(1,1,1),this.names=["data"],this.types=[Ht.SCALAR],this.componentTypes=[on.FLOAT32],this.maximumTileCount=1}SAe.prototype.requestData=function(e){if(!((u(e)?y(e.tileLevel,0):0)>=1))return Promise.resolve([new Float32Array(1)])};Mh.DefaultProvider=new SAe;var HS=Mh;function kX(){fe.throwInstantiationError()}Object.defineProperties(kX.prototype,{ready:{get:fe.throwInstantiationError},readyPromise:{get:fe.throwInstantiationError},globalTransform:{get:fe.throwInstantiationError},shapeTransform:{get:fe.throwInstantiationError},shape:{get:fe.throwInstantiationError},minBounds:{get:fe.throwInstantiationError},maxBounds:{get:fe.throwInstantiationError},dimensions:{get:fe.throwInstantiationError},paddingBefore:{get:fe.throwInstantiationError},paddingAfter:{get:fe.throwInstantiationError},names:{get:fe.throwInstantiationError},types:{get:fe.throwInstantiationError},componentTypes:{get:fe.throwInstantiationError},minimumValues:{get:fe.throwInstantiationError},maximumValues:{get:fe.throwInstantiationError},maximumTileCount:{get:fe.throwInstantiationError},keyframeCount:{get:fe.throwInstantiationError},timeIntervalCollection:{get:fe.throwInstantiationError}});kX.prototype.requestData=fe.throwInstantiationError;var zX=kX;function PC(){fe.throwInstantiationError()}Object.defineProperties(PC.prototype,{orientedBoundingBox:{get:fe.throwInstantiationError},boundingSphere:{get:fe.throwInstantiationError},boundTransform:{get:fe.throwInstantiationError},shapeTransform:{get:fe.throwInstantiationError},shaderUniforms:{get:fe.throwInstantiationError},shaderDefines:{get:fe.throwInstantiationError},shaderMaximumIntersectionsLength:{get:fe.throwInstantiationError}});PC.prototype.update=fe.throwInstantiationError;PC.prototype.computeOrientedBoundingBoxForTile=fe.throwInstantiationError;PC.prototype.computeApproximateStepSize=fe.throwInstantiationError;PC.DefaultMinBounds=fe.throwInstantiationError;PC.DefaultMaxBounds=fe.throwInstantiationError;var HX=PC;async function GX(e,t){let n=t.terrainProvider,i=t.mapProjection,o=i.ellipsoid,r,s=t.camera.getRectangleCameraCoordinates(e);if(t.mode===ne.SCENE3D?r=o.cartesianToCartographic(s):r=i.unproject(s),!u(n))return r;await n._readyPromise;let a=n.availability;if(!u(a)||t.mode===ne.SCENE2D)return r;let c=[le.center(e),le.southeast(e),le.southwest(e),le.northeast(e),le.northwest(e)],l=await GX._sampleTerrainMostDetailed(n,c),f=!1,d=l.reduce(function(g,h){return u(h.height)?(f=!0,Math.max(h.height,g)):g},-Number.MAX_VALUE),p=r;return f&&(p.height+=d),p}GX._sampleTerrainMostDetailed=g_;var OC=GX;var dgt=new k,mgt=new k,hgt=new k,pgt=new k,vAe=new re,e2=new Uint8Array(4);function wAe(e,t,n,i){let o=t.height===n.height?0:(e-t.height)/(n.height-t.height);return k.lerp(t.color,n.color,o,i)}function aH(e,t){return{height:e,color:k.clone(t)}}function DAe(e){return e=e.filter(function(t,n,i){let o=n>0,r=n<i.length-1,s=o?t.height===i[n-1].height:!0,a=r?t.height===i[n+1].height:!0;return!s||!a}),e=e.filter(function(t,n,i){let o=n>0,r=n<i.length-1,s=o?k.equals(t.color,i[n-1].color):!1,a=r?k.equals(t.color,i[n+1].color):!1;return!s||!a}),e=e.filter(function(t,n,i){let o=n>0,r=o?k.equals(t.color,i[n-1].color):!1,s=o?t.height===i[n-1].height:!0;return!r||!s}),e}function _gt(e){let t,n,i=[],o=e.length;for(t=0;t<o;t++){let r=e[t],s=r.entries,a=s.length,c=[];for(n=0;n<a;n++){let g=s[n],h=P.clamp(g.height,Hl._minimumHeight,Hl._maximumHeight),A=k.clone(g.color,dgt);A.red*=A.alpha,A.green*=A.alpha,A.blue*=A.alpha,c.push(aH(h,A))}let l=!0,f=!0;for(n=0;n<a-1;n++){let g=c[n+0],h=c[n+1];l=l&&g.height<=h.height,f=f&&g.height>=h.height}f?c=c.reverse():l||w_(c,function(g,h){return P.sign(g.height-h.height)});let d=y(r.extendDownwards,!1),p=y(r.extendUpwards,!1);c.length===1&&!d&&!p&&(d=!0,p=!0),d&&c.splice(0,0,aH(Hl._minimumHeight,c[0].color)),p&&c.splice(c.length,0,aH(Hl._maximumHeight,c[c.length-1].color)),c=DAe(c),i.push(c)}return i}function ggt(e){let t=_gt(e),n=[],i=[],o;function r(l,f){n.push(aH(l,f))}function s(l,f,d){let p=k.multiplyByScalar(d,1-f.alpha,
${t}
${h}`);let A=document.createElement("div");A.className="cesium-widget-errorPanel-message-details collapsed";let x=document.createElement("span");x.className="cesium-widget-errorPanel-more-details",x.appendChild(document.createTextNode("See more...")),A.appendChild(x),A.onclick=function(C){A.removeChild(x),A.appendChild(document.createTextNode(h)),A.className="cesium-widget-errorPanel-message-details",r.className="cesium-widget-errorPanel-content expanded",A.onclick=void 0},a.appendChild(A)}g.innerHTML=`<p>${t}</p>`}let d=document.createElement("div");d.className="cesium-widget-errorPanel-buttonPanel",r.appendChild(d);let p=document.createElement("button");p.setAttribute("type","button"),p.className="cesium-button",p.appendChild(document.createTextNode("OK")),p.onclick=function(){u(c)&&u(window.removeEventListener)&&window.removeEventListener("resize",c,!1),i.removeChild(o)},d.appendChild(p),i.appendChild(o)};MC.prototype.isDestroyed=function(){return!1};MC.prototype.destroy=function(){u(this._scene)&&(this._scene.renderError.removeEventListener(this._onRenderError),this._scene=this._scene.destroy()),this._container.removeChild(this._element),this._creditContainer.removeChild(this._innerCreditContainer),ue(this)};MC.prototype.resize=function(){let e=this._canvas;!this._forceResize&&this._canvasClientWidth===e.clientWidth&&this._canvasClientHeight===e.clientHeight&&this._lastDevicePixelRatio===window.devicePixelRatio||(this._forceResize=!1,PAe(this),OAe(this),this._scene.requestRender())};MC.prototype.render=function(){if(this._canRender){this._scene.initializeFrame();let e=this._clock.tick();this._scene.render(e)}else this._clock.tick()};var t2=MC;function Egt(e){e=y(e,y.EMPTY_OBJECT),this.typedArray=e.typedArray,this.width=e.width,this.height=e.height,this.pixelFormat=y(e.pixelFormat,st.RGBA),this.pixelDatatype=y(e.pixelDatatype,Ke.UNSIGNED_BYTE);let t=e.url;typeof t=="string"&&(t=Ie.createIfNeeded(t)),this.resource=t;let i=y(e.repeat,!0)?wn.REPEAT:wn.CLAMP_TO_EDGE;this.sampler=new fn({wrapS:i,wrapT:i,minificationFilter:e.minificationFilter,magnificationFilter:e.magnificationFilter,maximumAnisotropy:e.maximumAnisotropy})}var KX=Egt;var bgt={FLOAT:"float",VEC2:"vec2",VEC3:"vec3",VEC4:"vec4",MAT2:"mat2",MAT3:"mat2",MAT4:"mat4"},JX=Object.freeze(bgt);var ZX=`uniform sampler2D u_depthTexture;
in vec2 v_textureCoordinates;
void main()
{
float z_window = czm_unpackDepth(texture(u_depthTexture, v_textureCoordinates));
z_window = czm_reverseLogDepth(z_window);
float n_range = czm_depthRange.near;
float f_range = czm_depthRange.far;
float z_ndc = (2.0 * z_window - n_range - f_range) / (f_range - n_range);
float scale = pow(z_ndc * 0.5 + 0.5, 8.0);
out_FragColor = vec4(mix(vec3(0.0), vec3(1.0), scale), 1.0);
}
`;function Sgt(e,t,n){let i;try{return i=e(t,n),i}catch(o){return Promise.reject(o)}}function vgt(e){let t;return function(n){let i=n.data,o=[],r={id:i.id,result:void 0,error:void 0};return Promise.resolve(Sgt(e,i.parameters,o)).then(function(s){r.result=s}).catch(function(s){s instanceof Error?r.error={name:s.name,message:s.message,stack:s.stack}:r.error=s}).finally(function(){u(t)||(t=y(self.webkitPostMessage,self.postMessage)),i.canTransferArrayBuffer||(o.length=0);try{t(r,o)}catch(s){r.result=void 0,r.error=`postMessage failed with error: ${ph(s)}
with responseMessage: ${JSON.stringify(r)}`,t(r)}})}}var QX=vgt;globalThis.CESIUM_VERSION="1.104";var n2;typeof ko<"u"&&(n2=ko);(function(){/*!
* Knockout JavaScript library v3.5.1
* (c) The Knockout.js team - http://knockoutjs.com/
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
*/(function(){(function(e){var t=this||(0,eval)("this"),n=t.document,i=t.navigator,o=t.jQuery,r=t.JSON;o||typeof jQuery>"u"||(o=jQuery),function(s){s(t.ko={})}(function(s,a){function c(_,b){return _===null||typeof _ in A?_===b:!1}function l(_,b){var v;return function(){v||(v=h.a.setTimeout(function(){v=e,_()},b))}}function f(_,b){var v;return function(){clearTimeout(v),v=h.a.setTimeout(_,b)}}function d(_,b){b&&b!=="change"?b==="beforeChange"?this.pc(_):this.gb(_,b):this.qc(_)}function p(_,b){b!==null&&b.s&&b.s()}function g(_,b){var v=this.qd,I=v[S];I.ra||(this.Qb&&this.mb[b]?(v.uc(b,_,this.mb[b]),this.mb[b]=null,--this.Qb):I.I[b]||v.uc(b,_,I.J?{da:_}:v.$c(_)),_.Ja&&_.gd())}var h=typeof s<"u"?s:{};h.b=function(_,b){for(var v=_.split("."),I=h,R=0;R<v.length-1;R++)I=I[v[R]];I[v[v.length-1]]=b},h.L=function(_,b,v){_[b]=v},h.version="3.5.1",h.b("version",h.version),h.options={deferUpdates:!1,useOnlyNativeEvents:!1,foreachHidesDestroyed:!1},h.a=function(){function _(W,K){for(var J in W)R.call(W,J)&&K(J,W[J])}function b(W,K){if(K)for(var J in K)R.call(K,J)&&(W[J]=K[J]);return W}function v(W,K){return W.__proto__=K,W}function I(W,K,J,ge){var Ce=W[K].match(Y)||[];h.a.D(J.match(Y),function(se){h.a.Na(Ce,se,ge)}),W[K]=Ce.join(" ")}var R=Object.prototype.hasOwnProperty,F={__proto__:[]}instanceof Array,z=typeof Symbol=="function",V={},G={};V[i&&/Firefox\/2/i.test(i.userAgent)?"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"],V.MouseEvents="click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave".split(" "),_(V,function(W,K){if(K.length)for(var J=0,ge=K.length;J<ge;J++)G[K[J]]=W});var U={propertychange:!0},q=n&&function(){for(var W=3,K=n.createElement("div"),J=K.getElementsByTagName("i");K.innerHTML="<!--[if gt IE "+ ++W+"]><i></i><![endif]-->",J[0];);return 4<W?W:e}(),Y=/\S+/g,Q;return{Jc:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],D:function(W,K,J){for(var ge=0,Ce=W.length;ge<Ce;ge++)K.call(J,W[ge],ge,W)},A:typeof Array.prototype.indexOf=="function"?function(W,K){return Array.prototype.indexOf.call(W,K)}:function(W,K){for(var J=0,ge=W.length;J<ge;J++)if(W[J]===K)return J;return-1},Lb:function(W,K,J){for(var ge=0,Ce=W.length;ge<Ce;ge++)if(K.call(J,W[ge],ge,W))return W[ge];return e},Pa:function(W,K){var J=h.a.A(W,K);0<J?W.splice(J,1):J===0&&W.shift()},wc:function(W){var K=[];return W&&h.a.D(W,function(J){0>h.a.A(K,J)&&K.push(J)}),K},Mb:function(W,K,J){var ge=[];if(W)for(var Ce=0,se=W.length;Ce<se;Ce++)ge.push(K.call(J,W[Ce],Ce));return ge},jb:function(W,K,J){var ge=[];if(W)for(var Ce=0,se=W.length;Ce<se;Ce++)K.call(J,W[Ce],Ce)&&ge.push(W[Ce]);return ge},Nb:function(W,K){if(K instanceof Array)W.push.apply(W,K);else for(var J=0,ge=K.length;J<ge;J++)W.push(K[J]);return W},Na:function(W,K,J){var ge=h.a.A(h.a.bc(W),K);0>ge?J&&W.push(K):J||W.splice(ge,1)},Ba:F,extend:b,setPrototypeOf:v,Ab:F?v:b,P:_,Ga:function(W,K,J){if(!W)return W;var ge={},Ce;for(Ce in W)R.call(W,Ce)&&(ge[Ce]=K.call(J,W[Ce],Ce,W));return ge},Tb:function(W){for(;W.firstChild;)h.removeNode(W.firstChild)},Yb:function(W){W=h.a.la(W);for(var K=(W[0]&&W[0].ownerDocument||n).createElement("div"),J=0,ge=W.length;J<ge;J++)K.appendChild(h.oa(W[J]));return K},Ca:function(W,K){for(var J=0,ge=W.length,Ce=[];J<ge;J++){var se=W[J].cloneNode(!0);Ce.push(K?h.oa(se):se)}return Ce},va:function(W,K){if(h.a.Tb(W),K)for(var J=0,ge=K.length;J<ge;J++)W.appendChild(K[J])},Xc:function(W,K){var J=W.nodeType?[W]:W;if(0<J.length){for(var ge=J[0],Ce=ge.parentNode,se=0,xe=K.length;se<xe;se++)Ce.insertBefore(K[se],ge);for(se=0,xe=J.length;se<xe;se++)h.removeNode(J[se])}},Ua:function(W,K){if(W.length){for(K=K.nodeType===8&&K.parentNode||K;W.length&&W[0].parentNode!==K;)W.splice(0,1);for(;1<W.length&&W[W.length-1].parentNode!==K;)W.length--;if(1<W.length){var J=W[0],ge=W[W.length-1];for(W.length=0;J!==ge;)W.push(J),J=J.nextSibling;W.push(ge)}}return W},Zc:function(W,K){7>q?W.setAttribute("selected",K):W.selected=K},Db:function(W){return W===null||W===e?"":W.trim?W.trim():W.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},Ud:function(W,K){return W=W||"
,`;var G=[],U=V.match(I),q,Y=[],Q=0;if(1<U.length){for(var W=0,K;K=U[W];++W){var J=K.charCodeAt(0);if(J===44){if(0>=Q){G.push(q&&Y.length?{key:q,value:Y.join("")}:{unknown:q||Y.join("")}),q=Q=0,Y=[];continue}}else if(J===58){if(!Q&&!q&&Y.length===1){q=Y.pop();continue}}else{if(J===47&&1<K.length&&(K.charCodeAt(1)===47||K.charCodeAt(1)===42))continue;J===47&&W&&1<K.length?(J=U[W-1].match(R))&&!F[J[0]]&&(V=V.substr(V.indexOf(K)+1),U=V.match(I),W=-1,K="/"):J===40||J===123||J===91?++Q:J===41||J===125||J===93?--Q:q||Y.length||J!==34&&J!==39||(K=K.slice(1,-1))}Y.push(K)}if(0<Q)throw Error("Unbalanced parentheses, braces, or brackets")}return G}var b=["true","false","null","undefined"],v=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,I=RegExp(`"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|\`(?:\\\\.|[^\`])*\`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*
|/(?:\\\\.|[^/])+/w*|[^\\s:,/][^,"'\`{}()/:[\\]]*[^\\s,"'\`{}()/:[\\]]|[^\\s]`,"g"),R=/[\])"'A-Za-z0-9_$]+$/,F={in:1,return:1,typeof:1},z={};return{Ra:[],wa:z,ac:_,vb:function(V,G){function U(J,ge){var Ce;if(!W){var se=h.getBindingHandler(J);if(se&&se.preprocess&&!(ge=se.preprocess(ge,J,U)))return;(se=z[J])&&(Ce=ge,0<=h.a.A(b,Ce)?Ce=!1:(se=Ce.match(v),Ce=se===null?!1:se[1]?"Object("+se[1]+")"+se[2]:Ce),se=Ce),se&&Y.push("'"+(typeof z[J]=="string"?z[J]:J)+"':function(_z){"+Ce+"=_z}")}Q&&(ge="function(){return "+ge+" }"),q.push("'"+J+"':"+ge)}G=G||{};var q=[],Y=[],Q=G.valueAccessors,W=G.bindingParams,K=typeof V=="string"?_(V):V;return h.a.D(K,function(J){U(J.key||J.unknown,J.value)}),Y.length&&U("_ko_property_writers","{"+Y.join(",")+" }"),q.join(",")},Id:function(V,G){for(var U=0;U<V.length;U++)if(V[U].key==G)return!0;return!1},eb:function(V,G,U,q,Y){V&&h.O(V)?!h.Za(V)||Y&&V.v()===q||V(q):(V=G.get("_ko_property_writers"))&&V[U]&&V[U](q)}}}(),h.b("expressionRewriting",h.m),h.b("expressionRewriting.bindingRewriteValidators",h.m.Ra),h.b("expressionRewriting.parseObjectLiteral",h.m.ac),h.b("expressionRewriting.preProcessBindings",h.m.vb),h.b("expressionRewriting._twoWayBindings",h.m.wa),h.b("jsonExpressionRewriting",h.m),h.b("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",h.m.vb),function(){function _(U){return U.nodeType==8&&F.test(R?U.text:U.nodeValue)}function b(U){return U.nodeType==8&&z.test(R?U.text:U.nodeValue)}function v(U,q){for(var Y=U,Q=1,W=[];Y=Y.nextSibling;){if(b(Y)&&(h.a.g.set(Y,G,!0),Q--,Q===0))return W;W.push(Y),_(Y)&&Q++}if(!q)throw Error("Cannot find closing comment tag to match: "+U.nodeValue);return null}function I(U,q){var Y=v(U,q);return Y?0<Y.length?Y[Y.length-1].nextSibling:U.nextSibling:null}var R=n&&n.createComment("test").text==="<!--test-->",F=R?/^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,z=R?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,V={ul:!0,ol:!0},G="__ko_matchedEndComment__";h.h={ea:{},childNodes:function(U){return _(U)?v(U):U.childNodes},Ea:function(U){if(_(U)){U=h.h.childNodes(U);for(var q=0,Y=U.length;q<Y;q++)h.removeNode(U[q])}else h.a.Tb(U)},va:function(U,q){if(_(U)){h.h.Ea(U);for(var Y=U.nextSibling,Q=0,W=q.length;Q<W;Q++)Y.parentNode.insertBefore(q[Q],Y)}else h.a.va(U,q)},Vc:function(U,q){var Y;_(U)?(Y=U.nextSibling,U=U.parentNode):Y=U.firstChild,Y?q!==Y&&U.insertBefore(q,Y):U.appendChild(q)},Wb:function(U,q,Y){Y?(Y=Y.nextSibling,_(U)&&(U=U.parentNode),Y?q!==Y&&U.insertBefore(q,Y):U.appendChild(q)):h.h.Vc(U,q)},firstChild:function(U){if(_(U))return!U.nextSibling||b(U.nextSibling)?null:U.nextSibling;if(U.firstChild&&b(U.firstChild))throw Error("Found invalid end comment, as the first child of "+U);return U.firstChild},nextSibling:function(U){if(_(U)&&(U=I(U)),U.nextSibling&&b(U.nextSibling)){var q=U.nextSibling;if(b(q)&&!h.a.g.get(q,G))throw Error("Found end comment without a matching opening comment, as child of "+U);return null}return U.nextSibling},Cd:_,Vd:function(U){return(U=(R?U.text:U.nodeValue).match(F))?U[1]:null},Sc:function(U){if(V[h.a.R(U)]){var q=U.firstChild;if(q)do if(q.nodeType===1){var Y;Y=q.firstChild;var Q=null;if(Y)do if(Q)Q.push(Y);else if(_(Y)){var W=I(Y,!0);W?Y=W:Q=[Y]}else b(Y)&&(Q=[Y]);while(Y=Y.nextSibling);if(Y=Q)for(Q=q.nextSibling,W=0;W<Y.length;W++)Q?U.insertBefore(Y[W],Q):U.appendChild(Y[W])}while(q=q.nextSibling)}}}}(),h.b("virtualElements",h.h),h.b("virtualElements.allowedBindings",h.h.ea),h.b("virtualElements.emptyNode",h.h.Ea),h.b("virtualElements.insertAfter",h.h.Wb),h.b("virtualElements.prepend",h.h.Vc),h.b("virtualElements.setDomNodeChildren",h.h.va),function(){h.ga=function(){this.nd={}},h.a.extend(h.ga.prototype,{nodeHasBindings:function(_){switch(_.nodeType){case 1:return _.getAttribute("data-bind")!=null||h.j.getComponentNameForNode(_);case 8:return h.h.Cd(_);default:return!1}},getBindings:function(_,b){var v=this.getBindingsString(_,b),v=v?this.parseBindingsString(v,b,_):null;return h.j.tc(v,_,b,!1)},getBindingAccessors:function(_,b){var v=this.getBindingsString(_,b),v=v?this.parseBindingsString(v,b,_,{val
Bindings value: `+_+`
Message: `+U.message,U}}}),h.ga.instance=new h.ga}(),h.b("bindingProvider",h.ga),function(){function _(se){var xe=(se=h.a.g.get(se,Ce))&&se.N;xe&&(se.N=null,xe.Tc())}function b(se,xe,me){this.node=se,this.yc=xe,this.kb=[],this.H=!1,xe.N||h.a.K.za(se,_),me&&me.N&&(me.N.kb.push(se),this.Kb=me)}function v(se){return function(){return se}}function I(se){return se()}function R(se){return h.a.Ga(h.u.G(se),function(xe,me){return function(){return se()[me]}})}function F(se,xe,me){return typeof se=="function"?R(se.bind(null,xe,me)):h.a.Ga(se,v)}function z(se,xe){return R(this.getBindings.bind(this,se,xe))}function V(se,xe){var me=h.h.firstChild(xe);if(me){var ve,Pe=h.ga.instance,Ve=Pe.preprocessNode;if(Ve){for(;ve=me;)me=h.h.nextSibling(ve),Ve.call(Pe,ve);me=h.h.firstChild(xe)}for(;ve=me;)me=h.h.nextSibling(ve),G(se,ve)}h.i.ma(xe,h.i.H)}function G(se,xe){var me=se,ve=xe.nodeType===1;ve&&h.h.Sc(xe),(ve||h.ga.instance.nodeHasBindings(xe))&&(me=q(xe,null,se).bindingContextForDescendants),me&&!J[h.a.R(xe)]&&V(me,xe)}function U(se){var xe=[],me={},ve=[];return h.a.P(se,function Pe(Ve){if(!me[Ve]){var Xe=h.getBindingHandler(Ve);Xe&&(Xe.after&&(ve.push(Ve),h.a.D(Xe.after,function(_t){if(se[_t]){if(h.a.A(ve,_t)!==-1)throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+ve.join(", "));Pe(_t)}}),ve.length--),xe.push({key:Ve,Mc:Xe})),me[Ve]=!0}}),xe}function q(se,xe,me){var ve=h.a.g.Ub(se,Ce,{}),Pe=ve.hd;if(!xe){if(Pe)throw Error("You cannot apply bindings multiple times to the same element.");ve.hd=!0}Pe||(ve.context=me),ve.Zb||(ve.Zb={});var Ve;if(xe&&typeof xe!="function")Ve=xe;else{var Xe=h.ga.instance,_t=Xe.getBindingAccessors||z,Gt=h.$(function(){return(Ve=xe?xe(me,se):_t.call(Xe,se,me))&&(me[Q]&&me[Q](),me[K]&&me[K]()),Ve},null,{l:se});Ve&&Gt.ja()||(Gt=null)}var dn=me,mt;if(Ve){var Tn=function(){return h.a.Ga(Gt?Gt():Ve,I)},Zn=Gt?function(Wt){return function(){return I(Gt()[Wt])}}:function(Wt){return Ve[Wt]};Tn.get=function(Wt){return Ve[Wt]&&I(Zn(Wt))},Tn.has=function(Wt){return Wt in Ve},h.i.H in Ve&&h.i.subscribe(se,h.i.H,function(){var Wt=(0,Ve[h.i.H])();if(Wt){var Qe=h.h.childNodes(se);Qe.length&&Wt(Qe,h.Ec(Qe[0]))}}),h.i.pa in Ve&&(dn=h.i.Cb(se,me),h.i.subscribe(se,h.i.pa,function(){var Wt=(0,Ve[h.i.pa])();Wt&&h.h.firstChild(se)&&Wt(se)})),ve=U(Ve),h.a.D(ve,function(Wt){var Qe=Wt.Mc.init,_e=Wt.Mc.update,pe=Wt.key;if(se.nodeType===8&&!h.h.ea[pe])throw Error("The binding '"+pe+"' cannot be used with virtual elements");try{typeof Qe=="function"&&h.u.G(function(){var Se=Qe(se,Zn(pe),Tn,dn.$data,dn);if(Se&&Se.controlsDescendantBindings){if(mt!==e)throw Error("Multiple bindings ("+mt+" and "+pe+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");mt=pe}}),typeof _e=="function"&&h.$(function(){_e(se,Zn(pe),Tn,dn.$data,dn)},null,{l:se})}catch(Se){throw Se.message='Unable to process binding "'+pe+": "+Ve[pe]+`"
Message: `+Se.message,Se}})}return ve=mt===e,{shouldBindDescendants:ve,bindingContextForDescendants:ve&&dn}}function Y(se,xe){return se&&se instanceof h.fa?se:new h.fa(se,e,e,xe)}var Q=h.a.Da("_subscribable"),W=h.a.Da("_ancestorBindingInfo"),K=h.a.Da("_dataDependency");h.c={};var J={script:!0,textarea:!0,template:!0};h.getBindingHandler=function(se){return h.c[se]};var ge={};h.fa=function(se,xe,me,ve,Pe){function Ve(){var Zn=dn?Gt():Gt,Wt=h.a.f(Zn);return xe?(h.a.extend(Xe,xe),W in xe&&(Xe[W]=xe[W])):(Xe.$parents=[],Xe.$root=Wt,Xe.ko=h),Xe[Q]=mt,_t?Wt=Xe.$data:(Xe.$rawData=Zn,Xe.$data=Wt),me&&(Xe[me]=Wt),ve&&ve(Xe,xe,Wt),xe&&xe[Q]&&!h.S.o().Vb(xe[Q])&&xe[Q](),Tn&&(Xe[K]=Tn),Xe.$data}var Xe=this,_t=se===ge,Gt=_t?e:se,dn=typeof Gt=="function"&&!h.O(Gt),mt,Tn=Pe&&Pe.dataDependency;Pe&&Pe.exportDependencies?Ve():(mt=h.xb(Ve),mt.v(),mt.ja()?mt.equalityComparer=null:Xe[Q]=e)},h.fa.prototype.createChildContext=function(se,xe,me,ve){if(!ve&&xe&&typeof xe=="object"&&(ve=xe,xe=ve.as,me=ve.extend),xe&&ve&&ve.noChildContext){var Pe=typeof se=="function"&&!h.O(se);return new h.fa(ge,this,null,function(Ve){me&&me(Ve),Ve[xe]=Pe?se():se},ve)}return new h.fa(se,this,xe,function(Ve,Xe){Ve.$parentContext=Xe,Ve.$parent=Xe.$data,Ve.$parents=(Xe.$parents||[]).slice(0),Ve.$parents.unshift(Ve.$parent),me&&me(Ve)},ve)},h.fa.prototype.extend=function(se,xe){return new h.fa(ge,this,null,function(me){h.a.extend(me,typeof se=="function"?se(me):se)},xe)};var Ce=h.a.g.Z();b.prototype.Tc=function(){this.Kb&&this.Kb.N&&this.Kb.N.sd(this.node)},b.prototype.sd=function(se){h.a.Pa(this.kb,se),!this.kb.length&&this.H&&this.Cc()},b.prototype.Cc=function(){this.H=!0,this.yc.N&&!this.kb.length&&(this.yc.N=null,h.a.K.yb(this.node,_),h.i.ma(this.node,h.i.pa),this.Tc())},h.i={H:"childrenComplete",pa:"descendantsComplete",subscribe:function(se,xe,me,ve,Pe){var Ve=h.a.g.Ub(se,Ce,{});return Ve.Fa||(Ve.Fa=new h.T),Pe&&Pe.notifyImmediately&&Ve.Zb[xe]&&h.u.G(me,ve,[se]),Ve.Fa.subscribe(me,ve,xe)},ma:function(se,xe){var me=h.a.g.get(se,Ce);if(me&&(me.Zb[xe]=!0,me.Fa&&me.Fa.notifySubscribers(se,xe),xe==h.i.H)){if(me.N)me.N.Cc();else if(me.N===e&&me.Fa&&me.Fa.Wa(h.i.pa))throw Error("descendantsComplete event not supported for bindings on this node")}},Cb:function(se,xe){var me=h.a.g.Ub(se,Ce,{});return me.N||(me.N=new b(se,me,xe[W])),xe[W]==me?xe:xe.extend(function(ve){ve[W]=me})}},h.Td=function(se){return(se=h.a.g.get(se,Ce))&&se.context},h.ib=function(se,xe,me){return se.nodeType===1&&h.h.Sc(se),q(se,xe,Y(me))},h.ld=function(se,xe,me){return me=Y(me),h.ib(se,F(xe,me,se),me)},h.Oa=function(se,xe){xe.nodeType!==1&&xe.nodeType!==8||V(Y(se),xe)},h.vc=function(se,xe,me){if(!o&&t.jQuery&&(o=t.jQuery),2>arguments.length){if(xe=n.body,!xe)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?")}else if(!xe||xe.nodeType!==1&&xe.nodeType!==8)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");G(Y(se,me),xe)},h.Dc=function(se){return!se||se.nodeType!==1&&se.nodeType!==8?e:h.Td(se)},h.Ec=function(se){return(se=h.Dc(se))?se.$data:e},h.b("bindingHandlers",h.c),h.b("bindingEvent",h.i),h.b("bindingEvent.subscribe",h.i.subscribe),h.b("bindingEvent.startPossiblyAsyncContentBinding",h.i.Cb),h.b("applyBindings",h.vc),h.b("applyBindingsToDescendants",h.Oa),h.b("applyBindingAccessorsToNode",h.ib),h.b("applyBindingsToNode",h.ld),h.b("contextFor",h.Dc),h.b("dataFor",h.Ec)}(),function(_){function b(z,V){var G=Object.prototype.hasOwnProperty.call(R,z)?R[z]:_,U;G?G.subscribe(V):(G=R[z]=new h.T,G.subscribe(V),v(z,function(q,Y){var Q=!(!Y||!Y.synchronous);F[z]={definition:q,Gd:Q},delete R[z],U||Q?G.notifySubscribers(q):h.na.zb(function(){G.notifySubscribers(q)})}),U=!0)}function v(z,V){I("getConfig",[z],function(G){G?I("loadComponent",[z,G],function(U){V(U,G)}):V(null,null)})}function I(z,V,G,U){U||(U=h.j.loaders.slice(0));var q=U.shift();if(q){var Y=q[z];if(Y){var Q=!1;if(Y.apply(q,V.concat(function(W){Q?G(null):W!==null?G(W):I(z,V,G,U)}))!==_&&(Q=!0,!q.suppressLoaderExceptions))throw Error("Componen
* @license
* Knockout ES5 plugin - https://github.com/SteveSanderson/knockout-es5
* Copyright (c) Steve Sanderson
* MIT license
*/var $X="__knockoutObservables",eK="__knockoutSubscribable";function MAe(e,t){if(!e)throw new Error("When calling ko.track, you must pass an object as the first parameter.");var n=this,i=RAe(e,!0);return t=t||Object.getOwnPropertyNames(e),t.forEach(function(o){if(!(o===$X||o===eK)&&!(o in i)){var r=e[o],s=r instanceof Array,a=n.isObservable(r)?r:s?n.observableArray(r):n.observable(r);Object.defineProperty(e,o,{configurable:!0,enumerable:!0,get:a,set:n.isWriteableObservable(a)?a:void 0}),i[o]=a,s&&Igt(n,a)}}),e}function RAe(e,t){var n=e[$X];return!n&&t&&(n={},Object.defineProperty(e,$X,{value:n})),n}function Dgt(e,t,n){var i=this,o={owner:e,deferEvaluation:!0};if(typeof n=="function")o.read=n;else{if("value"in n)throw new Error('For ko.defineProperty, you must not specify a "value" for the property. You must provide a "get" function.');if(typeof n.get!="function")throw new Error('For ko.defineProperty, the third parameter must be either an evaluator function, or an options object containing a function called "get".');o.read=n.get,o.write=n.set}return e[t]=i.computed(o),MAe.call(i,e,[t]),e}function Igt(e,t){var n=null;e.computed(function(){n&&(n.dispose(),n=null);var i=t();i instanceof Array&&(n=Pgt(e,t,i))})}function Pgt(e,t,n){var i=Ogt(e,n);return i.subscribe(t)}function Ogt(e,t){var n=t[eK];if(!n){n=new e.subscribable,Object.defineProperty(t,eK,{value:n});var i={};Mgt(t,n,i),Rgt(e,t,n,i)}return n}function Mgt(e,t,n){["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){var o=e[i];e[i]=function(){var r=o.apply(this,arguments);return n.pause!==!0&&t.notifySubscribers(this),r}})}function Rgt(e,t,n,i){["remove","removeAll","destroy","destroyAll","replace"].forEach(function(o){Object.defineProperty(t,o,{enumerable:!1,value:function(){var r;i.pause=!0;try{r=e.observableArray.fn[o].apply(e.observableArray(t),arguments)}finally{i.pause=!1}return n.notifySubscribers(t),r}})})}function BAe(e,t){if(!e)return null;var n=RAe(e,!1);return n&&n[t]||null}function Bgt(e,t){var n=BAe(e,t);n&&n.valueHasMutated()}function Lgt(e){e.track=MAe,e.getObservable=BAe,e.valueHasMutated=Bgt,e.defineProperty=Dgt}var i2={attachToKo:Lgt};var LAe="http://www.w3.org/2000/svg",NAe="cesium-svgPath-svg",Ngt={register:function(e){e.bindingHandlers.cesiumSvgPath={init:function(t,n){let i=document.createElementNS(LAe,"svg:svg");i.setAttribute("class",NAe);let o=document.createElementNS(LAe,"path");return i.appendChild(o),e.virtualElements.setDomNodeChildren(t,[i]),e.computed({read:function(){let r=e.unwrap(n());o.setAttribute("d",e.unwrap(r.path));let s=e.unwrap(r.width),a=e.unwrap(r.height);i.setAttribute("width",s),i.setAttribute("height",a),i.setAttribute("viewBox",`0 0 ${s} ${a}`),r.css&&i.setAttribute("class",`${NAe} ${e.unwrap(r.css)}`)},disposeWhenNodeIsRemoved:t}),{controlsDescendantBindings:!0}}},e.virtualElements.allowedBindings.cesiumSvgPath=!0}},o2=Ngt;i2.attachToKo(RC);o2.register(RC);var Te=RC;function r2(e){u(e)||(e=new Fd),this._clock=e,this._eventHelper=new Dr,this._eventHelper.add(e.onTick,this.synchronize,this),this.systemTime=Te.observable(ee.now()),this.systemTime.equalityComparer=ee.equals,this.startTime=Te.observable(e.startTime),this.startTime.equalityComparer=ee.equals,this.startTime.subscribe(function(t){e.startTime=t,this.synchronize()},this),this.stopTime=Te.observable(e.stopTime),this.stopTime.equalityComparer=ee.equals,this.stopTime.subscribe(function(t){e.stopTime=t,this.synchronize()},this),this.currentTime=Te.observable(e.currentTime),this.currentTime.equalityComparer=ee.equals,this.currentTime.subscribe(function(t){e.currentTime=t,this.synchronize()},this),this.multiplier=Te.observable(e.multiplier),this.multiplier.subscribe(function(t){e.multiplier=t,this.synchronize()},this),this.clockStep=Te.observable(e.clockStep),this.clockStep.subscribe(function(t){e.clockStep=t,this.synchronize()},this),this.clockRange=Te.observable(e.clockRange),this.clockRange.subscribe(function(t){e.clockRange=t,this.synchronize()},this),this.canAnimate=Te.observable(e.canAnimate),this.canAnimate.subscribe(function(t){e.
${h}`:u(g)?g:h}),this.buttonImageUrl=void 0,Te.defineProperty(this,"buttonImageUrl",function(){let d=this.selectedImagery;if(u(d))return d.iconUrl}),this.selectedImagery=void 0;let c=Te.observable();this._currentImageryLayers=[],Te.defineProperty(this,"selectedImagery",{get:function(){return c()},set:function(d){if(c()===d){this.dropDownVisible=!1;return}let p,g=this._currentImageryLayers,h=g.length,A=this._globe.imageryLayers,x=!1;for(p=0;p<h;p++){let C=A.length;for(let T=0;T<C;T++){let E=A.get(T);if(E===g[p]){A.remove(E),x=!0;break}}}if(u(d)){let C=d.creationCommand();if(Array.isArray(C)){let T=C.length;for(this._currentImageryLayers=[],p=T-1;p>=0;p--){let E=Us.fromProviderAsync(C[p]);A.add(E,0),this._currentImageryLayers.push(E)}}else{this._currentImageryLayers=[];let T=Us.fromProviderAsync(C);if(T.name=d.name,x)A.add(T,0);else{let E=A.get(0);u(E)&&A.remove(E),A.add(T,0)}this._currentImageryLayers.push(T)}}c(d),this.dropDownVisible=!1}}),this.selectedTerrain=void 0;let l=Te.observable();Te.defineProperty(this,"selectedTerrain",{get:function(){return l()},set:function(d){if(l()===d){this.dropDownVisible=!1;return}let p;u(d)&&(p=d.creationCommand());let g=!1,h=this._globe.terrainProviderChanged.addEventListener(()=>{g=!0,h()}),x=new OF(Promise.resolve(p)).readyEvent.addEventListener(C=>{g||(this._globe.depthTestAgainstTerrain=!(C instanceof v_),this._globe.terrainProvider=C,x())});l(d),this.dropDownVisible=!1}});let f=this;this._toggleDropDown=Cn(function(){f.dropDownVisible=!f.dropDownVisible}),this.selectedImagery=y(e.selectedImageryProviderViewModel,n[0]),this.selectedTerrain=y(e.selectedTerrainProviderViewModel,i[0])}Object.defineProperties(HAe.prototype,{toggleDropDown:{get:function(){return this._toggleDropDown}},globe:{get:function(){return this._globe}}});var d2=HAe;function dH(e,t){e=In(e);let n=new d2(t),i=document.createElement("button");i.type="button",i.className="cesium-button cesium-toolbar-button",i.setAttribute("data-bind","attr: { title: buttonTooltip },click: toggleDropDown"),e.appendChild(i);let o=document.createElement("img");o.setAttribute("draggable","false"),o.className="cesium-baseLayerPicker-selected",o.setAttribute("data-bind","attr: { src: buttonImageUrl }, visible: !!buttonImageUrl"),i.appendChild(o);let r=document.createElement("div");r.className="cesium-baseLayerPicker-dropDown",r.setAttribute("data-bind",'css: { "cesium-baseLayerPicker-dropDown-visible" : dropDownVisible }'),e.appendChild(r);let s=document.createElement("div");s.className="cesium-baseLayerPicker-sectionTitle",s.setAttribute("data-bind","visible: imageryProviderViewModels.length > 0"),s.innerHTML="Imagery",r.appendChild(s);let a=document.createElement("div");a.className="cesium-baseLayerPicker-section",a.setAttribute("data-bind","foreach: _imageryProviders"),r.appendChild(a);let c=document.createElement("div");c.className="cesium-baseLayerPicker-category",a.appendChild(c);let l=document.createElement("div");l.className="cesium-baseLayerPicker-categoryTitle",l.setAttribute("data-bind","text: name"),c.appendChild(l);let f=document.createElement("div");f.className="cesium-baseLayerPicker-choices",f.setAttribute("data-bind","foreach: providers"),c.appendChild(f);let d=document.createElement("div");d.className="cesium-baseLayerPicker-item",d.setAttribute("data-bind",'css: { "cesium-baseLayerPicker-selectedItem" : $data === $parents[1].selectedImagery },attr: { title: tooltip },visible: creationCommand.canExecute,click: function($data) { $parents[1].selectedImagery = $data; }'),f.appendChild(d);let p=document.createElement("img");p.className="cesium-baseLayerPicker-itemIcon",p.setAttribute("data-bind","attr: { src: iconUrl }"),p.setAttribute("draggable","false"),d.appendChild(p);let g=document.createElement("div");g.className="cesium-baseLayerPicker-itemLabel",g.setAttribute("data-bind","text: name"),d.appendChild(g);let h=document.createElement("div");h.className="cesium-baseLayerPicker-sectionTitle",h.setAttribute("data-bind","visible: terrainProviderViewModels.length > 0"),h.innerHTML="Terrain",r.appendChild(h);let A=documen
http://www.esri.com`,category:"Other",creationFunction:function(){return Ah.fromUrl("https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",{enablePickFeatures:!1})}})),e.push(new gs({name:"ESRI World Street Map",iconUrl:tn("Widgets/Images/ImageryProviders/esriWorldStreetMap.png"),tooltip:`This worldwide street map presents highway-level data for the world. Street-level data includes the United States; much of Canada; Japan; most countries in Europe; Australia and New Zealand; India; parts of South America including Argentina, Brazil, Chile, Colombia, and Venezuela; Ghana; and parts of southern Africa including Botswana, Lesotho, Namibia, South Africa, and Swaziland.
http://www.esri.com`,category:"Other",creationFunction:function(){return Ah.fromUrl("https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",{enablePickFeatures:!1})}})),e.push(new gs({name:"ESRI National Geographic",iconUrl:tn("Widgets/Images/ImageryProviders/esriNationalGeographic.png"),tooltip:`This web map contains the National Geographic World Map service. This map service is designed to be used as a general reference map for informational and educational purposes as well as a basemap by GIS professionals and other users for creating web maps and web mapping applications.
http://www.esri.com`,category:"Other",creationFunction:function(){return Ah.fromUrl("https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/",{enablePickFeatures:!1})}})),e.push(new gs({name:"Open\xADStreet\xADMap",iconUrl:tn("Widgets/Images/ImageryProviders/openStreetMap.png"),tooltip:`OpenStreetMap (OSM) is a collaborative project to create a free editable map of the world.
http://www.openstreetmap.org`,category:"Other",creationFunction:function(){return new uC({url:"https://a.tile.openstreetmap.org/"})}})),e.push(new gs({name:"Stamen Watercolor",iconUrl:tn("Widgets/Images/ImageryProviders/stamenWatercolor.png"),tooltip:`Reminiscent of hand drawn maps, Stamen watercolor maps apply raster effect area washes and organic edges over a paper texture to add warm pop to any map.
http://maps.stamen.com`,category:"Other",creationFunction:function(){return new uC({url:"https://stamen-tiles.a.ssl.fastly.net/watercolor/",credit:"Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA."})}})),e.push(new gs({name:"Stamen Toner",iconUrl:tn("Widgets/Images/ImageryProviders/stamenToner.png"),tooltip:`A high contrast black and white map.
http://maps.stamen.com`,category:"Other",creationFunction:function(){return new uC({url:"https://stamen-tiles.a.ssl.fastly.net/toner/",credit:"Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA."})}})),e.push(new gs({name:"Sentinel-2",iconUrl:tn("Widgets/Images/ImageryProviders/sentinel-2.png"),tooltip:"Sentinel-2 cloudless by EOX IT Services GmbH (Contains modified Copernicus Sentinel data 2016 and 2017).",category:"Cesium ion",creationFunction:function(){return Vf.fromAssetId(3954)}})),e.push(new gs({name:"Blue Marble",iconUrl:tn("Widgets/Images/ImageryProviders/blueMarble.png"),tooltip:"Blue Marble Next Generation July, 2004 imagery from NASA.",category:"Cesium ion",creationFunction:function(){return Vf.fromAssetId(3845)}})),e.push(new gs({name:"Earth at night",iconUrl:tn("Widgets/Images/ImageryProviders/earthAtNight.png"),tooltip:"The Earth at night, also known as The Black Marble, is a 500 meter resolution global composite imagery layer released by NASA.",category:"Cesium ion",creationFunction:function(){return Vf.fromAssetId(3812)}})),e.push(new gs({name:"Natural Earth\xA0II",iconUrl:tn("Widgets/Images/ImageryProviders/naturalEarthII.png"),tooltip:`Natural Earth II, darkened for contrast.
http://www.naturalearthdata.com/`,category:"Cesium ion",creationFunction:function(){return bh.fromUrl(tn("Assets/Textures/NaturalEarthII"))}})),e}var h2=Xgt;function Kgt(){let e=[];return e.push(new gs({name:"WGS84 Ellipsoid",iconUrl:tn("Widgets/Images/TerrainProviders/Ellipsoid.png"),tooltip:"WGS84 standard ellipsoid, also known as EPSG:4326",category:"Cesium ion",creationFunction:function(){return new v_}})),e.push(new gs({name:"Cesium World Terrain",iconUrl:tn("Widgets/Images/TerrainProviders/CesiumWorldTerrain.png"),tooltip:"High-resolution global terrain tileset curated from several datasources and hosted by Cesium ion",category:"Cesium ion",creationFunction:function(){return qx({requestWaterMask:!0,requestVertexNormals:!0})}})),e}var p2=Kgt;function Jgt(e){let t;if(u(e)){t="Command Statistics";let n=e.commandsInFrustums;for(let i in n)if(n.hasOwnProperty(i)){let o=parseInt(i,10),r;if(o===7)r="1, 2 and 3";else{let s=[];for(let a=2;a>=0;a--){let c=Math.pow(2,a);o>=c&&(s.push(a+1),o-=c)}r=s.reverse().join(" and ")}t+=`<br>&nbsp;&nbsp;&nbsp;&nbsp;${n[i]} in frustum ${r}`}t+=`<br>Total: ${e.totalCommands}`}return t}function sK(e,t,n){let i=Math.min(n,t);return i=Math.max(i,e),i}var Zgt=new Dn,Qgt=new m;function _2(e,t){let n=this,i=e.canvas,o=new Pu(i);this._eventHandler=o,this._scene=e,this._canvas=i,this._primitive=void 0,this._tile=void 0,this._modelMatrixPrimitive=void 0,this._performanceDisplay=void 0,this._performanceContainer=t;let r=this._scene.globe;r.depthTestAgainstTerrain=!0,this.frustums=!1,this.frustumPlanes=!1,this.performance=!1,this.shaderCacheText="",this.primitiveBoundingSphere=!1,this.primitiveReferenceFrame=!1,this.filterPrimitive=!1,this.tileBoundingSphere=!1,this.filterTile=!1,this.wireframe=!1,this.depthFrustum=1,this._numberOfFrustums=1,this.suspendUpdates=!1,this.tileCoordinates=!1,this.frustumStatisticText=!1,this.tileText="",this.hasPickedPrimitive=!1,this.hasPickedTile=!1,this.pickPrimitiveActive=!1,this.pickTileActive=!1,this.dropDownVisible=!0,this.generalVisible=!0,this.primitivesVisible=!1,this.terrainVisible=!1,this.depthFrustumText="",Te.track(this,["frustums","frustumPlanes","performance","shaderCacheText","primitiveBoundingSphere","primitiveReferenceFrame","filterPrimitive","tileBoundingSphere","filterTile","wireframe","depthFrustum","suspendUpdates","tileCoordinates","frustumStatisticText","tileText","hasPickedPrimitive","hasPickedTile","pickPrimitiveActive","pickTileActive","dropDownVisible","generalVisible","primitivesVisible","terrainVisible","depthFrustumText"]),this._toggleDropDown=Cn(function(){n.dropDownVisible=!n.dropDownVisible}),this._toggleGeneral=Cn(function(){n.generalVisible=!n.generalVisible}),this._togglePrimitives=Cn(function(){n.primitivesVisible=!n.primitivesVisible}),this._toggleTerrain=Cn(function(){n.terrainVisible=!n.terrainVisible}),this._frustumsSubscription=Te.getObservable(this,"frustums").subscribe(function(l){n._scene.debugShowFrustums=l,n._scene.requestRender()}),this._frustumPlanesSubscription=Te.getObservable(this,"frustumPlanes").subscribe(function(l){n._scene.debugShowFrustumPlanes=l,n._scene.requestRender()}),this._performanceSubscription=Te.getObservable(this,"performance").subscribe(function(l){l?n._performanceDisplay=new F_({container:n._performanceContainer}):n._performanceContainer.innerHTML=""}),this._showPrimitiveBoundingSphere=Cn(function(){return n._primitive.debugShowBoundingVolume=n.primitiveBoundingSphere,n._scene.requestRender(),!0}),this._primitiveBoundingSphereSubscription=Te.getObservable(this,"primitiveBoundingSphere").subscribe(function(){n._showPrimitiveBoundingSphere()}),this._showPrimitiveReferenceFrame=Cn(function(){if(n.primitiveReferenceFrame){let l=n._primitive.modelMatrix;n._modelMatrixPrimitive=new ML({modelMatrix:l}),n._scene.primitives.add(n._modelMatrixPrimitive)}else u(n._modelMatrixPrimitive)&&(n._scene.primitives.remove(n._modelMatrixPrimitive),n._modelMatrixPrimitive=void 0);return n._scene.requestRender(),!0}),this._primitiveReferenceFrameSubscription=Te.getObservable(this,"primitiveReferenceFrame").subscribe(fun
<ul class="cesium-cesiumInspector-statistics">
<li><strong>Geometry Memory (MB): </strong>${A2(e.geometryByteLength)}</li>
<li><strong>Texture Memory (MB): </strong>${A2(e.texturesByteLength)}</li>
</ul>
`}var tyt=[{text:"Highlight",value:ml.HIGHLIGHT},{text:"Replace",value:ml.REPLACE},{text:"Mix",value:ml.MIX}],WAe=new k(1,1,0,.4),nyt=new k,hH=new k;function la(e,t){let n=this,i=e.canvas;this._eventHandler=new Pu(i),this._scene=e,this._performanceContainer=t,this._canvas=i,this._performanceDisplay=new F_({container:t}),this._statisticsText="",this._pickStatisticsText="",this._resourceCacheStatisticsText="",this._editorError="",this.performance=!1,this.showStatistics=!0,this.showPickStatistics=!0,this.showResourceCacheStatistics=!1,this.inspectorVisible=!0,this.tilesetVisible=!1,this.displayVisible=!1,this.updateVisible=!1,this.loggingVisible=!1,this.styleVisible=!1,this.tileDebugLabelsVisible=!1,this.optimizationVisible=!1,this.styleString="{}",this.hasEnabledWireframe=!1,this._tileset=void 0,this._feature=void 0,this._tile=void 0,Te.track(this,["performance","inspectorVisible","_statisticsText","_pickStatisticsText","_resourceCacheStatisticsText","_editorError","showPickStatistics","showStatistics","showResourceCacheStatistics","tilesetVisible","displayVisible","updateVisible","loggingVisible","styleVisible","optimizationVisible","tileDebugLabelsVisible","styleString","_feature","_tile","_tileset","hasEnabledWireframe"]),this._properties=Te.observable({}),this.properties=[],Te.defineProperty(this,"properties",function(){let U=[],q=n._properties();for(let Y in q)q.hasOwnProperty(Y)&&U.push(Y);return U});let o=Te.observable();Te.defineProperty(this,"dynamicScreenSpaceError",{get:function(){return o()},set:function(U){o(U),u(n._tileset)&&(n._tileset.dynamicScreenSpaceError=U)}}),this.dynamicScreenSpaceError=!1;let r=Te.observable();Te.defineProperty(this,"colorBlendMode",{get:function(){return r()},set:function(U){r(U),u(n._tileset)&&(n._tileset.colorBlendMode=U,n._scene.requestRender())}}),this.colorBlendMode=ml.HIGHLIGHT;let s=Te.observable(),a=Te.observable();Te.defineProperty(this,"picking",{get:function(){return a()},set:function(U){a(U),U?n._eventHandler.setInputAction(function(q){let Y=e.pick(q.endPosition);if(Y instanceof Cs?(n.feature=Y,n.tile=Y.content.tile):u(Y)&&u(Y.content)?(n.feature=void 0,n.tile=Y.content.tile):(n.feature=void 0,n.tile=void 0),!!u(n._tileset)){if(s&&u(Y)&&u(Y.content)){let Q;e.pickPositionSupported&&(Q=e.pickPosition(q.endPosition),u(Q)&&(n._tileset.debugPickPosition=Q)),n._tileset.debugPickedTile=Y.content.tile}else n._tileset.debugPickedTile=void 0;n._scene.requestRender()}},An.MOUSE_MOVE):(n.feature=void 0,n.tile=void 0,n._eventHandler.removeInputAction(An.MOUSE_MOVE))}}),this.picking=!0;let c=Te.observable();Te.defineProperty(this,"colorize",{get:function(){return c()},set:function(U){c(U),u(n._tileset)&&(n._tileset.debugColorizeTiles=U,n._scene.requestRender())}}),this.colorize=!1;let l=Te.observable();Te.defineProperty(this,"wireframe",{get:function(){return l()},set:function(U){l(U),u(n._tileset)&&(n._tileset.debugWireframe=U,n._scene.requestRender())}}),this.wireframe=!1;let f=Te.observable();Te.defineProperty(this,"showBoundingVolumes",{get:function(){return f()},set:function(U){f(U),u(n._tileset)&&(n._tileset.debugShowBoundingVolume=U,n._scene.requestRender())}}),this.showBoundingVolumes=!1;let d=Te.observable();Te.defineProperty(this,"showContentBoundingVolumes",{get:function(){return d()},set:function(U){d(U),u(n._tileset)&&(n._tileset.debugShowContentBoundingVolume=U,n._scene.requestRender())}}),this.showContentBoundingVolumes=!1;let p=Te.observable();Te.defineProperty(this,"showRequestVolumes",{get:function(){return p()},set:function(U){p(U),u(n._tileset)&&(n._tileset.debugShowViewerRequestVolume=U,n._scene.requestRender())}}),this.showRequestVolumes=!1;let g=Te.observable();Te.defineProperty(this,"freezeFrame",{get:function(){return g()},set:function(U){g(U),u(n._tileset)&&(n._tileset.debugFreezeFrame=U,n._scene.debugShowFrustumPlanes=U,n._scene.requestRender())}}),this.freezeFrame=!1,Te.defineProperty(this,"showOnlyPickedTileDebugLabel",{get:function(){return s()},set:function(U){s(U),u(n._tileset)&&(n._tileset.debugPickedTileLabelOnly=U,n._scene.requestRender())}}),this
`),c=a.length,l;if(t.shiftKey)for(l=0;l<c;++l)a[l][0]===" "&&(a[l][1]===" "?(a[l]=a[l].substr(2),r-=2):(a[l]=a[l].substr(1),r-=1));else for(l=0;l<c;++l)a[l]=` ${a[l]}`,r+=2;let f=a.join(`
`);n.value=n.value.slice(0,i)+f+n.value.slice(o),n.selectionStart=i!==o?i:r,n.selectionEnd=r}else t.ctrlKey&&(t.keyCode===10||t.keyCode===13)&&this.compileStyle();return!0};la.prototype._update=function(){let e=this._tileset;if(this.performance&&this._performanceDisplay.update(),u(e)){if(e.isDestroyed()){this.tile=void 0,this.feature=void 0,this.tileset=void 0;return}let t=e.style;this._style!==e.style&&(this._shouldStyle?(e.style=this._style,this._shouldStyle=!1):(this._style=t,this.styleString=JSON.stringify(t.style,null," ")))}this.showStatistics&&(this._statisticsText=x2(e,!1),this._pickStatisticsText=x2(e,!0),this._resourceCacheStatisticsText=YAe())};la.prototype.isDestroyed=function(){return!1};la.prototype.destroy=function(){this._eventHandler.destroy(),this._removePostRenderEvent();let e=this;return this._definedProperties.forEach(function(t){Te.getObservable(e,t).dispose()}),ue(this)};la.getStatistics=x2;var C2=la;function pH(e,t){e=In(e);let n=document.createElement("div"),i=document.createElement("div");i.setAttribute("data-bind","visible: performance");let o=new C2(t,i);this._viewModel=o,this._container=e,this._element=n;let r=document.createElement("div");r.textContent="3D Tiles Inspector",r.className="cesium-cesiumInspector-button",r.setAttribute("data-bind","click: toggleInspector"),n.appendChild(r),n.className="cesium-cesiumInspector cesium-3DTilesInspector",n.setAttribute("data-bind",'css: { "cesium-cesiumInspector-visible" : inspectorVisible, "cesium-cesiumInspector-hidden" : !inspectorVisible}'),e.appendChild(n);let s=document.createElement("div");s.className="cesium-cesiumInspector-dropDown",n.appendChild(s);let a=Ia.createSection,c=Ia.createCheckbox,l=Ia.createRangeInput,f=Ia.createButton,d=a(s,"Tileset","tilesetVisible","toggleTileset"),p=a(s,"Display","displayVisible","toggleDisplay"),g=a(s,"Update","updateVisible","toggleUpdate"),h=a(s,"Logging","loggingVisible","toggleLogging"),A=a(s,"Tile Debug Labels","tileDebugLabelsVisible","toggleTileDebugLabels"),x=a(s,"Style","styleVisible","toggleStyle"),C=a(s,"Optimization","optimizationVisible","toggleOptimization"),T=document.createElement("div");T.className="field-group";let E=document.createElement("label");E.className="field-label",E.appendChild(document.createTextNode("Properties: "));let S=document.createElement("div");S.setAttribute("data-bind","text: properties"),T.appendChild(E),T.appendChild(S),d.appendChild(T),d.appendChild(f("Pick Tileset","togglePickTileset","pickActive")),d.appendChild(f("Trim Tiles Cache","trimTilesCache")),d.appendChild(c("Enable Picking","picking")),p.appendChild(c("Colorize","colorize"));let w=p.appendChild(c("Wireframe","wireframe","_tileset === undefined || hasEnabledWireframe")),D=document.createElement("p");D.setAttribute("data-bind","visible: _tileset !== undefined && !hasEnabledWireframe"),D.setAttribute("class","cesium-3DTilesInspector-disabledElementsInfo"),D.innerText="Set enableDebugWireframe to true in the tileset constructor to enable this option.",w.appendChild(D),p.appendChild(c("Bounding Volumes","showBoundingVolumes")),p.appendChild(c("Content Volumes","showContentBoundingVolumes")),p.appendChild(c("Request Volumes","showRequestVolumes")),p.appendChild(c("Point Cloud Shading","pointCloudShading"));let M=document.createElement("div");M.setAttribute("data-bind","visible: pointCloudShading"),M.appendChild(l("Geometric Error Scale","geometricErrorScale",0,2,.01)),M.appendChild(l("Maximum Attenuation","maximumAttenuation",0,32,1)),M.appendChild(l("Base Resolution","baseResolution",0,1,.01)),M.appendChild(c("Eye Dome Lighting (EDL)","eyeDomeLighting")),p.appendChild(M);let O=document.createElement("div");O.setAttribute("data-bind","visible: eyeDomeLighting"),O.appendChild(l("EDL Strength","eyeDomeLightingStrength",0,2,.1)),O.appendChild(l("EDL Radius","eyeDomeLightingRadius",0,4,.1)),M.appendChild(O),g.appendChild(c("Freeze Frame","freezeFrame")),g.appendChild(c("Dynamic Screen Space Error","dynamicScreenSpaceError"));let L=document.createElement("div");L.appendChild(l("Maximum Screen Space Error","maximumS
`),n;for(n=0;n<t.length&&!t[n].match(/\S/);n++);if(n===t.length)return"";let i="",o=/^\s*/,s=t[n].match(o)[0].length;for(let a=n;a<t.length;a++){let c=t[a];c.match(o)[0].length>=s&&(c=c.slice(s)),i+=`${c}
`}return i}function Xf(e){this._scene=e,this._voxelPrimitive=void 0,this._customShaderCompilationRemoveCallback=void 0,this._definedProperties=[],this._getPrimitiveFunctions=[],this._modelMatrixReady=!1;let t=this;function n(o){let{name:r,initialValue:s}=o;t._definedProperties.push(r);let a=o.setPrimitiveFunction;a===!0&&(a=function(f){t._voxelPrimitive[r]=f});let c=o.getPrimitiveFunction;c===!0&&(c=function(){t[r]=t._voxelPrimitive[r]}),u(c)&&t._getPrimitiveFunctions.push(c);let l=Te.observable();return Te.defineProperty(t,r,{get:function(){return l()},set:function(f){typeof s=="number"&&typeof f=="string"&&(f=Number(f),isNaN(f)&&(f=s)),typeof s=="boolean"&&typeof f=="number"&&(f=f===1),l(f),u(a)&&u(t._voxelPrimitive)&&(a(f),e.requestRender())}}),t[r]=s,l}function i(o,r){return function(s){let a=t._voxelPrimitive[o].clone();a[r]=s,t._voxelPrimitive[o]=a}}n({name:"inspectorVisible",initialValue:!0}),n({name:"displayVisible",initialValue:!1}),n({name:"transformVisible",initialValue:!1}),n({name:"boundsVisible",initialValue:!1}),n({name:"clippingVisible",initialValue:!1}),n({name:"shaderVisible",initialValue:!1}),n({name:"shaderString",initialValue:"",getPrimitiveFunction:function(){let o=t._voxelPrimitive.customShader.fragmentShaderText;t.shaderString=mxe(o)}}),n({name:"shaderCompilationMessage",initialValue:""}),n({name:"shaderCompilationSuccess",initialValue:!0}),n({name:"depthTest",initialValue:!1,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"show",initialValue:!0,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"disableUpdate",initialValue:!1,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"debugDraw",initialValue:!1,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"jitter",initialValue:!0,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"nearestSampling",initialValue:!0,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"screenSpaceError",initialValue:4,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"stepSize",initialValue:1,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"shapeIsBox",getPrimitiveFunction:function(){let o=t._voxelPrimitive.shape;t.shapeIsBox=o===Gi.BOX}}),n({name:"shapeIsEllipsoid",getPrimitiveFunction:function(){let o=t._voxelPrimitive.shape;t.shapeIsEllipsoid=o===Gi.ELLIPSOID}}),n({name:"shapeIsCylinder",getPrimitiveFunction:function(){let o=t._voxelPrimitive.shape;t.shapeIsCylinder=o===Gi.CYLINDER}}),n({name:"boundsBoxMaxX",initialValue:0,setPrimitiveFunction:i("maxBounds","x"),getPrimitiveFunction:function(){t.boundsBoxMaxX=t._voxelPrimitive.maxBounds.x}}),n({name:"boundsBoxMinX",initialValue:0,setPrimitiveFunction:i("minBounds","x"),getPrimitiveFunction:function(){t.boundsBoxMinX=t._voxelPrimitive.minBounds.x}}),n({name:"boundsBoxMaxY",initialValue:0,setPrimitiveFunction:i("maxBounds","y"),getPrimitiveFunction:function(){t.boundsBoxMaxY=t._voxelPrimitive.maxBounds.y}}),n({name:"boundsBoxMinY",initialValue:0,setPrimitiveFunction:i("minBounds","y"),getPrimitiveFunction:function(){t.boundsBoxMinY=t._voxelPrimitive.minBounds.y}}),n({name:"boundsBoxMaxZ",initialValue:0,setPrimitiveFunction:i("maxBounds","z"),getPrimitiveFunction:function(){t.boundsBoxMaxZ=t._voxelPrimitive.maxBounds.z}}),n({name:"boundsBoxMinZ",initialValue:0,setPrimitiveFunction:i("minBounds","z"),getPrimitiveFunction:function(){t.boundsBoxMinZ=t._voxelPrimitive.minBounds.z}}),n({name:"boundsEllipsoidMaxLongitude",initialValue:0,setPrimitiveFunction:i("maxBounds","x"),getPrimitiveFunction:function(){t.boundsEllipsoidMaxLongitude=t._voxelPrimitive.maxBounds.x}}),n({name:"boundsEllipsoidMinLongitude",initialValue:0,setPrimitiveFunction:i("minBounds","x"),getPrimitiveFunction:function(){t.boundsEllipsoidMinLongitude=t._voxelPrimitive.minBounds.x}}),n({name:"boundsEllipsoidMaxLatitude",initialValue:0,setPrimitiveFunction:i("maxBounds","y"),getPrimitiveFunction:function(){t.boundsEllipsoidMaxLatitude=t._voxelPrimitive.maxBounds.y}}),n({name:"boundsEllipsoidMinLatitude",initialValue:0,setPrimitiveFunction:i("minBounds","y"),getPrimitiveFunction:function(){t.bou
`),c=a.length,l;if(t.shiftKey)for(l=0;l<c;++l)a[l][0]===" "&&(a[l][1]===" "?(a[l]=a[l].substr(2),r-=2):(a[l]=a[l].substr(1),r-=1));else for(l=0;l<c;++l)a[l]=` ${a[l]}`,r+=2;let f=a.join(`
`);n.value=n.value.slice(0,i)+f+n.value.slice(o),n.selectionStart=i!==o?i:r,n.selectionEnd=r}else t.ctrlKey&&(t.keyCode===10||t.keyCode===13)&&this.compileShader();return!0};Xf.prototype.isDestroyed=function(){return!1};Xf.prototype.destroy=function(){let e=this;return this._definedProperties.forEach(function(t){Te.getObservable(e,t).dispose()}),ue(this)};var q2=Xf;function MH(e,t){e=In(e);let n=document.createElement("div"),i=new q2(t);this._viewModel=i,this._container=e,this._element=n;let o=document.createElement("div");o.textContent="Voxel Inspector",o.className="cesium-cesiumInspector-button",o.setAttribute("data-bind","click: toggleInspector"),n.appendChild(o),n.className="cesium-cesiumInspector cesium-VoxelInspector",n.setAttribute("data-bind",'css: { "cesium-cesiumInspector-visible" : inspectorVisible, "cesium-cesiumInspector-hidden" : !inspectorVisible}'),e.appendChild(n);let r=document.createElement("div");r.className="cesium-cesiumInspector-dropDown",n.appendChild(r);let s=Ia.createSection,a=Ia.createCheckbox,c=Ia.createRangeInput,l=Ia.createButton,f=s(r,"Display","displayVisible","toggleDisplay"),d=s(r,"Transform","transformVisible","toggleTransform"),p=s(r,"Bounds","boundsVisible","toggleBounds"),g=s(r,"Clipping","clippingVisible","toggleClipping"),h=s(r,"Shader","shaderVisible","toggleShader");f.appendChild(a("Depth Test","depthTest")),f.appendChild(a("Show","show")),f.appendChild(a("Disable Update","disableUpdate")),f.appendChild(a("Debug Draw","debugDraw")),f.appendChild(a("Jitter","jitter")),f.appendChild(a("Nearest Sampling","nearestSampling")),f.appendChild(c("Screen Space Error","screenSpaceError",0,128)),f.appendChild(c("Step Size","stepSize",0,2));let A=10,x=10,C=P.PI;d.appendChild(c("Translation X","translationX",-A,+A)),d.appendChild(c("Translation Y","translationY",-A,+A)),d.appendChild(c("Translation Z","translationZ",-A,+A)),d.appendChild(c("Scale X","scaleX",0,+x)),d.appendChild(c("Scale Y","scaleY",0,+x)),d.appendChild(c("Scale Z","scaleZ",0,+x)),d.appendChild(c("Heading","angleX",-C,+C)),d.appendChild(c("Pitch","angleY",-C,+C)),d.appendChild(c("Roll","angleZ",-C,+C));let T=Gi.getMinBounds(Gi.BOX),E=Gi.getMaxBounds(Gi.BOX),S=m.fromElements(Gi.getMinBounds(Gi.ELLIPSOID).x,Gi.getMinBounds(Gi.ELLIPSOID).y,-oe.WGS84.maximumRadius,new m),w=m.fromElements(Gi.getMaxBounds(Gi.ELLIPSOID).x,Gi.getMaxBounds(Gi.ELLIPSOID).y,1e7,new m),D=Gi.getMinBounds(Gi.CYLINDER),M=Gi.getMaxBounds(Gi.CYLINDER);qS("Max X","Min X","Max Y","Min Y","Max Z","Min Z","boundsBoxMaxX","boundsBoxMinX","boundsBoxMaxY","boundsBoxMinY","boundsBoxMaxZ","boundsBoxMinZ",T,E,"shapeIsBox",p),qS("Max Longitude","Min Longitude","Max Latitude","Min Latitude","Max Height","Min Height","boundsEllipsoidMaxLongitude","boundsEllipsoidMinLongitude","boundsEllipsoidMaxLatitude","boundsEllipsoidMinLatitude","boundsEllipsoidMaxHeight","boundsEllipsoidMinHeight",S,w,"shapeIsEllipsoid",p),qS("Max Radius","Min Radius","Max Height","Min Height","Max Angle","Min Angle","boundsCylinderMaxRadius","boundsCylinderMinRadius","boundsCylinderMaxHeight","boundsCylinderMinHeight","boundsCylinderMaxAngle","boundsCylinderMinAngle",D,M,"shapeIsCylinder",p),qS("Max X","Min X","Max Y","Min Y","Max Z","Min Z","clippingBoxMaxX","clippingBoxMinX","clippingBoxMaxY","clippingBoxMinY","clippingBoxMaxZ","clippingBoxMinZ",T,E,"shapeIsBox",g),qS("Max Longitude","Min Longitude","Max Latitude","Min Latitude","Max Height","Min Height","clippingEllipsoidMaxLongitude","clippingEllipsoidMinLongitude","clippingEllipsoidMaxLatitude","clippingEllipsoidMinLatitude","clippingEllipsoidMaxHeight","clippingEllipsoidMinHeight",S,w,"shapeIsEllipsoid",g),qS("Max Radius","Min Radius","Max Height","Min Height","Max Angle","Min Angle","clippingCylinderMaxRadius","clippingCylinderMinRadius","clippingCylinderMaxHeight","clippingCylinderMinHeight","clippingCylinderMaxAngle","clippingCylinderMinAngle",D,M,"shapeIsCylinder",g);let O=document.createElement("div");h.appendChild(O);let L=document.createElement("textarea");L.setAttribute("data-bind","textInput: shaderString, event: { keydown: shaderEdit